A modification to the display routine you listed is to call $01B0 instead of $01AD. This has the benefit that the IY register then becomes free and can be used in your program so long as you don't return to BASIC or call ROM routines that use it (if you do then simply reset it back to $4000 beforehand).
You can run sections of your program during the VSync period but this must always take a fixed number of clock cycles in order to achieve a steady display. The actual number isn't that critical, but aiming for a duration of 6 scan lines keeps the video output similar to the standard ZX80 display.
You can also increase the VSync period to allow more time for processing within your program by reducing the number of border lines shown. You can reduce the number of border lines by up to 16 and still achieve a full visible picture. However, a longer VSync pulse might cause problems on some TVs (although I haven't encountered this). The number of lines in the top border needs to be a multiple of 8, but this restriction does not apply to the bottom border. To minimise the code below, the top and bottom borders could both use the value stored in MARGIN_TOP and then reduce the VSync duration by 1 line's duration.
Code: Select all
IN A,($FE) ; Read the region indicator.
SBC A,A ; $FF (50Hz) or $00 (60Hz).
AND $18 ; $18 (50Hz) or $00 (60Hz).
ADD A,$20 ; $38 (50Hz) or $20 (60Hz), i.e. 56 (50Hz) or 32 (60Hz).
LD (MARGIN_TOP),A ; Store the top border count.
LD (MARGIN_BOTTOM),A ; Store the bottom border count.
; VSync delay of 6 scan lines
LD B,$19 ; B=1 'row' for top border of MARGIN_TOP lines, and 24 rows of 8 lines
INC B ; B=1 'row' for bottom border of MARGIN_BOTTOM lines
RET Z ; Delay 5 T-states to achieve perfect timing
JP LOOP ; Loop back to generate the next frame.
... another 23 x $76 here ...
The EightyOne and No$zx81 emulators definitely handle the display routine above.
If you don't need the full display file then you can reduce the number of $76 in the DFILE, adjust the number of rows in LD B,$19 and compensate by increasing the number of border lines.
Regarding other differences between the ZX80 and ZX81, some graphic characters have different character codes.