abacaxi wrote: ↑Wed Mar 12, 2025 1:36 am
(beep, why do you ld sp,dfile-1+1024 and not just dfile-1?)
On a 1K ZX81 this will mirror back to RAM 1K lower. On a ZX81 with more RAM the SP will be 1K higher.
My ZX81-emulator on the ZX Spectrum is coded on maximal speed not on perfect emulation.
This means that during an intrupt more registers are stacked than on a ZX81.
When a game in 1K has a tight stack (many of my games) then these would crash in my own emulator so I always use the displaced SP trick
to have tight games run on my own emulator.
Thank you. I found several similar optimizations myself, whenever I find myself doing something similar several times there's usually a lot to save by restructuring. The key detection in particular can be made much shorter I'm sure. It's a mess.
You want to keep any key pressed during the delay.
This is not needed. Better is to do the delay and then use the IN A,(254) to read B to space and check the bits
LD HL,frames
LD A,(HL)
SUB 7
wait CP (HL)
JR NZ,wait
LD A,127 ; IN port B-space
IN A,(254) ; read port
BIT 2,A ; test M pressed
JR Z,do-M
BIT 3,A ; test N pressed
JR Z,do_N
Yes but the responsiveness increases a lot if I check every frame, and I need to check for key up in order to avoid double turns, I'm not checking that it's still down. A common strategy in this type of game is to very quickly double tap a key to make a u turn, which was very sketchy when l only checked after the delay.