1; 2; ZX81 libraries - Stefano Dec 2012 3; 4;---------------------------------------------------------------- 5; 6; $Id: gen_tv_field.asm,v 1.4 2016-06-26 20:36:33 dom Exp $ 7; 8;---------------------------------------------------------------- 9; 10; ZX80 (and ZX81 in FAST mode) trick to try to keep the display stable. 11; This subroutine should be called in theory after every 1475ms (4731 T-states, corresponding to 22.99 scan lines). 12; According to this article: http://www.fruitcake.plus.com/Sinclair/ZX80/FlickerFree/ZX80_DisplayMechanism.htm 13; .. a margin has to be considered. 14 15; 16;---------------------------------------------------------------- 17 18 SECTION code_clib 19 PUBLIC gen_tv_field 20 PUBLIC _gen_tv_field 21 PUBLIC DFILE_PTRA 22 PUBLIC DFILE_PTRB 23 24gen_tv_field: 25_gen_tv_field: 26 OUT ($FF),A ; 11 Turn off the vertical sync generator. 27 28; Generate the top border and main display area. 29 30; NOP 31DFILE_PTRA: 32 LD A,$E9 ; 7 Timing counter for the duration of the first 33 ; scan line of the top border. Thereafter set 34 ; to $DD by the ROM. 35; LD BC,$1900 ; 10 There are 25 HALTs within the display file, 36 LD B,$19 37 ; i.e. 24 rows and 1 top border. C is set only 38 ; to achieve perfect timing. 39; LD HL,DFILE+$8000 ; 10 Point to the start of the display file, i.e. 40 ; the initial HALT representing the top border, 41 ; but with bit 15 of the address set. 42 43 LD HL,($400C) ;; point HL to D-FILE the first HALT 44 ;; instruction. 45 SET 7,H ;; now point to the DFILE echo in the 46 ;; top 32K of address space. 47 48DFILE_PTRB: 49 ;LD C,24 ; 50 LD C,48 ; 7 There are 48 scan lines (UK) above the ZX80 51 ; main display area, or 24 for USA models. 52 53 CALL $01B0 ; 17+n Produce the top border and main area. 54 55; Generate the bottom border. 56 57 LD A,$EC ; 7 Timing counter for the duration of the first 58 ; scan line of the bottom border. Thereafter 59 ; set to $DD by the ROM. 60 INC B ; 4 Increment the row count, i.e. B holds $01. 61 DEC HL ; 6 Decrement the screen address, i.e. point to 62 ; the last HALT. 63 LD C,$2F ; 7 the blank line counter, i.e. 47 or 23 64 ; scan lines below the ZX80 main display area. 65 CALL $01B0 ; 17+n Produce the bottom border. 66 67; Start the vertical sync pulse. 68 69 IN A,($FE) ; 11 Turn on the vertical sync generator. It be 70 ; will be turned off approximately 23 scan 71 RET ; 10 lines from now. 72