"Extreme" 1k programs for ZX80 and ZX81: starter kit

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
marste
Posts: 135
Joined: Sun Aug 10, 2014 9:58 pm
Location: Italy
Contact:

"Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by marste » Sun Apr 23, 2017 12:19 am

Hoping to contribute to the community and development on this little computers, attached there is an extract of my experience with Super Micro Chess porting to the old Zeddy platform: elaborating all the information got from many sources (documents, support from community, and my own experiments) I synthetized a little starter kit for the 1k in the form of a minimal starting code with ready places to fill the program…

Some notes:
- I use it in a Linux development environment, but since fasmg (the assembler) is multiplatform you can easily switch to windows
- the kit is not a ready program, but a skeleton for a multiplatform source: as used in Super Micro Chess, with external define switches ("-i" parameter with the line to include) I generate all the various versions for ZX80 and ZX81 from a single source
- In the comments I tried to be didascalic even if the standard user of this kit should be a tough assembler programmer! :)
- I inserted already fasmg and ez80 includes for convenience, but please have a look also the original websites: https://flatassembler.net/download.php and https://github.com/jacobly0/fasmg-ez80

This is a “pre-release”: I tried to clean up as much as possible, but there are surely still edge to smooth up. If you use/improve it please let me know and I'll keep the kit updated! And let’s discuss it here!

Happy hacking!
_Stefano
Attachments
zx80zx81-1k-kit.zip
(74.49 KiB) Downloaded 138 times

dr beep
Posts: 1232
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by dr beep » Sun Apr 23, 2017 8:46 pm

My experience:
LASTK, MARGIN, FLAGX, FRAMES and CDFLAG can't be used.

You can set the start to machine code (only BASIC-command ever on reusable memory (best on variablesmemory or array or on screen that gets cleared directly after loading)


Smallest needed code is 11 bytes. where 4 bytes can be coded.

BASIC-prog:
Linenumber: 2 bytes, byte 1 max value 63 second all values allowed
Linelength: 2 bytes, every length (and code) allowed
BASIC-call: 3 bytes defb 249, 212, 28 "RANDOMIZE USR 0"
Marker start floating point: 1 byte, 126
Floating point short: 3 bytes defb 143, 0, 18 (address #4009 where you code JP START)
Final 2 bytes of floatingpoint number can be skipped as can end of BASIC.

dr beep
Posts: 1232
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by dr beep » Sun Apr 23, 2017 8:55 pm

Code: Select all

           ORG  #4009             ;#4009                        
                                                                
           JP   init                                            
                                                                
d_file     DEFW dfile                                           
dfcc       DEFW dfile+1                                         
.... rest of sysvar

basic      DEFB 0,0               ; only used to start program  
           DEFB 0,0               ; cleared by code             
           DEFB 249,212,28                                      
           DEFB 126                                             
           DEFB 143,0,18
           BASIC jumps to #4009 which then goes whereever you want.

User avatar
marste
Posts: 135
Joined: Sun Aug 10, 2014 9:58 pm
Location: Italy
Contact:

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by marste » Sun Apr 23, 2017 9:40 pm

dr beep wrote:
Sun Apr 23, 2017 8:46 pm
My experience:
LASTK, MARGIN, FLAGX, FRAMES and CDFLAG can't be used.
Talking about ZX81 (and not thinking to have a custom display routine anyway needing a pointer) also DFILE cannot be used and I added also DB_ST (but on this I may be wrong), while FLAGX in my experience can be used (I mean if you put values there they will be kept when program will be run), while I think you can use CDFLAG (and many others listed with xx and maybe also the ? ones) as memory after the asm program start.

dr beep wrote:
Sun Apr 23, 2017 8:46 pm
You can set the start to machine code (only BASIC-command ever on reusable memory (best on variablesmemory or array or on screen that gets cleared directly after loading)
In the kit is at the end, and infact all the memory after "maxstack available line" is used by stack in SuperMicro (in order of clearing: basic pgm -firsto to go-, asm init code, initial chess playing logic - last to go but cleared when main logic start playing)

dr beep wrote:
Sun Apr 23, 2017 8:46 pm
Smallest needed code is 11 bytes. where 4 bytes can be coded.
Yes, you gave me this idea!! :)
dr beep wrote:
Sun Apr 23, 2017 8:46 pm
BASIC-prog:
Linenumber: 2 bytes, byte 1 max value 63 second all values allowed
Linelength: 2 bytes, every length (and code) allowed
I highlighted this in ZX80 basic routine, but infact I should write properly the limits for ZX81!

dr beep wrote:
Sun Apr 23, 2017 8:46 pm
BASIC-call: 3 bytes defb 249, 212, 28 "RANDOMIZE USR 0"
Marker start floating point: 1 byte, 126
Floating point short: 3 bytes defb 143, 0, 18 (address #4009 where you code JP START)
Final 2 bytes of floatingpoint number can be skipped as can end of BASIC.
The final 2 bytes can be whateve value since they are the decimal digits of the FP number. In order to save (and use differently) also the useful 3 bytes at 4009 I developed the formula you can see in the kit (calculated by the assembler at compile time) based on reported documentation to jump directly to init (without the double jump).


Last note: hope that you also will start to develop for ZX80! The kit is already multiplatform, meaning you can use the same source for both platforms! :)


Happy hacking!
_Stefano

dr beep
Posts: 1232
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by dr beep » Fri Mar 22, 2019 9:03 pm

I have optimized the base model further for coding machine code in 1K.

The whole BASIC-call to MC is set over sysvar and the repair after loading too.
This will give the maximum codeable bytes in 1K.
modelzx81.asm
(1.45 KiB) Downloaded 96 times

User avatar
kpalser
Posts: 60
Joined: Sun Jun 03, 2012 2:18 pm
Location: Dundee, Scotland

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by kpalser » Thu Mar 28, 2019 9:23 pm

Hi Stefano,
Off topic - can I include your 1K chess port into my iOS ZX81 emulator?
Thanks,
Kevin

dr beep
Posts: 1232
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by dr beep » Wed May 22, 2019 9:44 pm

marste wrote:
Sun Apr 23, 2017 12:19 am
Hoping to contribute to the community and development on this little computers, attached there is an extract of my experience with Super Micro Chess porting to the old Zeddy platform: elaborating all the information got from many sources (documents, support from community, and my own experiments) I synthetized a little starter kit for the 1k in the form of a minimal starting code with ready places to fill the program…

Some notes:
- I use it in a Linux development environment, but since fasmg (the assembler) is multiplatform you can easily switch to windows
- the kit is not a ready program, but a skeleton for a multiplatform source: as used in Super Micro Chess, with external define switches ("-i" parameter with the line to include) I generate all the various versions for ZX80 and ZX81 from a single source
- In the comments I tried to be didascalic even if the standard user of this kit should be a tough assembler programmer! :)
- I inserted already fasmg and ez80 includes for convenience, but please have a look also the original websites: https://flatassembler.net/download.php and https://github.com/jacobly0/fasmg-ez80

This is a “pre-release”: I tried to clean up as much as possible, but there are surely still edge to smooth up. If you use/improve it please let me know and I'll keep the kit updated! And let’s discuss it here!

Happy hacking!
_Stefano
Can I get a cleared version with only ZX80 with flickering. I want to try something but I don't want to clear the code as it is now.

User avatar
marste
Posts: 135
Joined: Sun Aug 10, 2014 9:58 pm
Location: Italy
Contact:

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by marste » Sat May 25, 2019 12:33 pm

kpalser wrote:
Thu Mar 28, 2019 9:23 pm
Hi Stefano,
Off topic - can I include your 1K chess port into my iOS ZX81 emulator?
Thanks,
Kevin

Ciao Kevin,
Sorry for late reply.
Sure you can use! Is an honor for me! :)
Thank you!
_Stefano

User avatar
marste
Posts: 135
Joined: Sun Aug 10, 2014 9:58 pm
Location: Italy
Contact:

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by marste » Sat May 25, 2019 12:47 pm

dr beep wrote:
Wed May 22, 2019 9:44 pm
Can I get a cleared version with only ZX80 with flickering. I want to try something but I don't want to clear the code as it is now.
Ciao Johan, not sure I've got exactly what you're looking for. Anyway if you want to eliminate the ZX81 parts is enough to delete the lines that will be included just if ROMPLATFORM eq "ZX81" (and ZX80 autorun and ZX80 flickerfree if you don't want them :D ). If I didn't make mistake in deleting attached the ZX80 "flickering" and "no autorun trick" version of the skeleton.
Happy hacking!
_Stefano
Attachments
kit_zx1k - just ZX80.asm
(6.16 KiB) Downloaded 46 times

User avatar
kpalser
Posts: 60
Joined: Sun Jun 03, 2012 2:18 pm
Location: Dundee, Scotland

Re: "Extreme" 1k programs for ZX80 and ZX81: starter kit

Post by kpalser » Mon May 27, 2019 7:42 pm

marste wrote:
Sat May 25, 2019 12:33 pm
kpalser wrote:
Thu Mar 28, 2019 9:23 pm
Hi Stefano,
Off topic - can I include your 1K chess port into my iOS ZX81 emulator?
Thanks,
Kevin

Ciao Kevin,
Sorry for late reply.
Sure you can use! Is an honor for me! :)
Thank you!
_Stefano
Thank you! Now in the latest version (1.6.0) on the App Store.

Post Reply