Wilf's NOVA2005 for 50 Hz Zeddies?

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
User avatar
siggi
Posts: 880
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Wilf's NOVA2005 for 50 Hz Zeddies?

Post by siggi » Fri Mar 02, 2018 12:59 pm

I wanted to use Wilf's great Nova2005 program, but unfortunatley it generates the video at a frame rate of 60 Hz, which is not good for us on the "other side of the pond" (from Wilf's view). But maybe one of the "video gurus" here has an idea, what has to be changed to make a 50 Hz video timing.

Here is Wilf's documentation (set the text coding to "western" to see it correctly in the browser): http://www.user.dccnet.com/wrigter/inde ... va2005.htm

Here is his source code (extracted from Wilf's page):

Code: Select all


                        ;NOVA SOURCE CODE LISTING   
                        ;COMPATIBLE WITH ARTIC ASSEMBLER
 
                        ;** NEW VIDEO VECTOR **
STRT1 LD IX,VDR         ;NEVER CALL VDR DIRECTLY
      RET
                        ;** MAIN LOOP **
VDR   CALL SDP          ;STATUS LINE (RTC)
      CALL FRM          ;RTC UPDATE
      CALL VDP          ;VARIABLE LENGTH DFILE OR A$
                        ;CALC BOTTOM BLANK LINES
      CALL ZDP          ;ZX COMMAND LINE 24 (?)
      CALL RTN          ;KEY REPEAT(?) AND RETURN TO BASIC
                       
VDR1  CALL SNC          ;FRAMES, KEYBOARD, VERTICAL SYNC
      LD B,07           ;ALIGN SCREEN
      CALL DLY          ;VARIABLE DELAY ROUTINE
      LD A,EC           ;NUMBER OF TOP BLANK LINES
      EX AF             ;SAVE FOR NMI
      CALL TRCE         ;BASIC LINE TRACE ROUTINE
      CALL USR          ;DO USER ROUTINE
      LD IX,VDR         ;RESTORE VDR JUMP VECTOR
      JP 02A4           ;EXIT TO BASIC UNTIL NEXT VDR
           
                        ;** VARIABLE DELAY ROUTINE **
DLY   NOP               ;DELAY TIME DEPENDS ON
DLY0  NOP               ;REGISTER B AND ENTRY POINT
DLY2  NOP               ;
DLY3  NOP               ;
DLY1  NOP               ;EACH NOP = 4T STATES
DLY4  NOP               ;PLUS REG B X 12T + 7T
DLY5  NOP
DLYB  DJNZ DLYB
      RET
                        ;** VSYNC VIA KEY SCAN **    
SNC   PUSH AF           ;DUMMY REGISTER PUSH TO
      PUSH BC           ;FORCE RETURN TO VDR (NOT BASIC)
      PUSH DE          
      PUSH HL          
      JP 0229           ;FRAMES, KEYBOARD AND VSYNC
           
RTN   LD A,(FLAG)       ;CHECK FLAG      
      BIT 1,A           ;FOR REPEAT BIT 1 SET  
      JR Z RTN1         ;EXIT IS NO REPEAT
      XOR A             ;REPEAT SET SO 
      LD (4027),A       ;RESET DEBOUNCE SYSVAR       
RTN1  POP IX            ;SAVE RETURN ADDRESS IN REG IX
      JP 02A2           ;START NMI AND RETURN TO BASIC
                       
                        ;** TOP OF DISPLAY SCREEM **
SDP   LD B,02           ;SYNCHRONIZE WITH DISPLAY
      CALL DLY          ;
      LD HL,RTCL        ;POINT TO THE STATUS LINE    
      JR ZDP1           ;AND DISPLAY IT
 
                        ;** MIDDLE OF DISPLAY SCREEM **
VDP   LD B,29           ;SYNCRONIZE DISPLAY
      CALL DLY1         ;
      LD DE,(OFFST)     ;FIND THE START OF THE MAIN DISPLAY
      LD A,E            ;IF OFFSET IS ZERO,
      OR D              ;
      JR Z VDP1         ;THEN DISPLAY D-FILE
      LD HL,(4010)      ;ELSE FIND START OF VARIABLES
      ADD HL,DE         ;ADD THE OFFSET
      LD DE,0005        ;ADD A$ HEADER LENGTH  
      JR VDP2           ;AND DISPLAY VFILE
VDP1  LD HL,(400C)      ;LOAD DFILE START
      ADD HL,DE         ;DELAY
      LD DE,0001        ;SKIP LEADING N/L
      JR NZ VDP2        ;DELAY
VDP2  ADD HL,DE         ;TRUE START OF DISPLAY
      LD A,(LINES)      ;CALCULATE NUMBER OF LINES
      AND 1F            ;
      LD B,A            ;SAVE IN B
      RLCA              ;CALCULATE BALNK LINES
      RLCA              ;
      RLCA              ;
      ADD A,3B          ;
      EX AF             ;SAVE IN AF’ FOR NMI
      LD C,08           ;
      JR ZDP2           ;GO DISPLAY MAIN SCREEN ALREADY
 
                        ;** BOTTOM OF DISPLAY SCREEN **
ZDP   LD B,73           ;VSYNC DELAY
      CALL DLY5         ;
      LD A,(FLAG)       ;DISPLAY ZX COMMAND LINE 24 (?)          
      BIT 2,A           ;
      JR NZ ZDP0        ;YES, GO DISPLAY LINE 24     
      EX AF             ;NO LINE 24 = ADD EXTRA BLANK TIME 
      SUB   09          ;
      EX AF             ;SAVE FOR NMI
      RET               ;
ZDP0  XOR A             ;START OF LINE 24 CAN BE FOUND BY          
      LD HL,(4010)      ;START OF VAR AREA
      LD DE,0021        ;32 CHARACTERS PLUS NEWLINE
      SBC HL,DE         ;SUBTRACT TO POINT TO START OF LINE 24
ZDP1  LD BC,0108        ;ONE ROW OR 8 HORIZONTAL LINES           
ZDP2  SET 7,H           ;ECHO DISPLAY ABOVE 32K
      LD A,DD           ;34 CHARACTERS PER LINE OR N/L (HALT WITH A6 INTERRUPT) 
      JP 0041           ;GO TO ZX INTERRUPT ROUTINE AND RETURN
 
                        ;CONVERT LINE NUMBER IN (4007) TO DECIMAL
TRCE  LD A,(FLAG)       ;CHECK FLAG FOR BASIC LINE TRACE ON (?)
      BIT 0,A           ;
      RET Z             ;RETURN IF NO TRACE
      LD DE,TRCL        ;START OF TOP STATUS LINE    
      LD HL,(4007)      ;BASIC LINE NUMBER
      LD BC,FC18        ;DIVIDE BY 1000
      CALL TR1          ;
      LD BC,FF9C        ;DIVIDE BY 100
      CALL TR1          ;
      LD BC,FFF6        ;DIVIDE BY 10          
      CALL TR1          ;
      LD A,1C           ;PLUS UNITS
      ADD A,L           ;
      JR TR3            ;
           
TR1   LD A,1C           ;DECIMAL CONVERSION HAS 
TR2   ADD HL,BC         ;VARIABLE EXECUTION TIME
      INC A             ;SO RUN WHILE NMI IS ON
      JR C TR2          ;SUBTRACT BC UNTIL OVERFLOW
      SBC HL,BC         ;SUBTRACT ONE LOOP
      DEC A             ;ADJUST DIGIT
TR3   AND 3F            ;LIMIT RESULT
      LD (DE),A         ;LOAD DIGIT IN TRACE FIELD
      INC DE            ;NEXT DIGIT
      RET               ;
                       
                        ;UPDATE 100 HR TIMER
FRM   LD DE,TITL-1      ;POINTER TO TIMER FIELD LEAST SIGNIFICANT DIGIT
      LD HL,FRM6+1      ;POINTER TO DIGIT LIMITS AND COLON FLAG
      LD B,08           ;8 DIGITS
      SCF               ;FIXED EXECUTION TIME BETWEEN STATUS LINE AND VDP
FRM1  LD A,(DE)         ;GET DIGIT
      ADC A,00          ;CARRY FLAG ADDS ONE TO DIGIT
      CP (HL)           ;CHECK AGAINST LIMIT
      CCF               ;IF LIMIT THEN RESET DIGIT TO ZERO
      JR C FRM2         ;AND CARRY INCREMENTS NEXT DIGIT
      LD (DE),A         ;ELSE NO CARRY AND LOAD TIMER FIELD WITH DIGIT+1
      JR FRM3           ;
FRM2  LD A,1C           ;SET DIGIT TO ZERO
      LD (DE),A         ;LOAD TIMER FIELD WITH ZERO DIGIT
FRM3  DEC DE            ;
      DEC HL            ;
      BIT 7,(HL)        ;TEST FOR COLON FLAG         
      JR Z FRM5         ;JR IF NOT COLON
      DEC DE            ;POINT TO NEXT DIGIT
      DEC HL            ;POINT TO NEXT LIMIT
FRM5  DJNZ FRM1         ;DO EIGHT TIMES
      RET               ;
           
      26 26 80          ; LIMIT 99: (HRS)
      22 26 80          ; LIMIT 59: (MIN)
      22 26 80          ; LIMIT 59: (SEC)
FRM6  22 26             ; LIMIT 59  (1/60SEC)
                        
                        ;INITIALIZE THE COMVAR STRING ARRAY
DIM1  XOR A             ;USING DIM ?$ (USR 32671)
      LD HL,(4016)      ;USE CH-AD TO POINT TO NAME
      LD DE,000F        ;IN THE BASIC LINE
      SBC HL,DE         ;
      LD A,(HL)         ;GET NAME
      LD HL,ATFR        ;SAVE NAME IN ATFR           
      LD (HL),A         ;
      LD C,20           ;USR MUST RETURN 32
      LD B,00           ;AS THE DIMENSION OF THE ARRAY
      RET               ;
     
ULD1  CALL ALD          ;LOAD DATA FROM COMVAR TO STATUS LINE
      JR DLD2           ;GO TRANSFER
           
DLD1  CALL ALD          ;LOAD DATA FROM STATUS LINE TO COMVAR
      EX DE,HL          ;
DLD2  LDIR              ;ACTUAL TRANSFER
      JR ALD1           ;
           
ALD   LD HL,(4016)      ;SAVE THE CH-ADD POINTER
      EX (SP),HL        ;
      PUSH HL           ;
      LD HL,ATFR        ;POINT TO COMVAR NAME
      CALL 004D         ;SET CH-ADD TO COMVAR NAME
      CALL 111C         ;LOOK UP COMVAR ADDRESS
      LD DE,0006        ;SKIP COMVAR HEADER          
      ADD HL,DE         ;
      LD DE,RTCL        ;POINTER TO TIMER/CLOCK FIELD
      LD BC,000B        ;LENGTH OF TIMER/CLOCK FIELD
      RET               ;
 
ALD1  POP HL            ;RESTORE CH-ADD
      LD (4016),HL      ;
      RET               ;
 
                        ;CHECK IF OFFSET EXCEEDS VFIEL
SOFT1 LD HL,(4016)      ;SAVE CH-ADD
      PUSH HL           ;
      RST 20            ;FIRST CHECK IF A$ EXISTS
      LD HL,(4010)      ;EXIT TO DFILE IF A$ WAS ERASED
      LD A,(HL)         ;BECAUSE OF RUN, CLEAR, ETC.
      CP C6             ;
      JR NZ SOFT2       ;    
      CALL 1300         ;NOW FIND END OF ARRAY
      LD HL,0340        ;ASSUME A FULL SCREEN IS REQUIRED  
      EX DE,HL          ;CAUSE LINES CAN BE ADJUSTED
      SBC HL,DE         ;ENOUGH ROOM FOR A FULL SCREEN?
      JR C SOFT2        ;          
      CALL 12DD         ;EVALUATE THE USR EXPRESSION 
      JR NC SOFT3       ;AND SAVE IN BC
SOFT2 LD BC,0000        ;SET BC TO ZERO
SOFT3 LD (OFFST),BC     ;SAVE IN OFFSET
      JR ALD1           ;
     
JPTBL                   ;START OF PROGRAM VARIABLE AREA
SPARE "12345"           ;SPARE BYTES
FLAG  04                ;FLAG CONTROLS FEATURES (eg COMMAND LINE on)
LINES 18                ;NUMBER OF DISPLAYED LINES
OFFST 00                ;OFFSET FROM START OF A$ VARIABLE
      00                ;OR “0000” IS DFILE
USR   RET               ;3 BYTE USER CALL TO SHORT ROUTINE 
      00                ;MUST RETURN BEFORE TIME IS UP
      00                ;
ATFR  "Z$"              ;NAME OF COMVAR (TRANSFERS DATA TO LINE 1) 
RTCL  "00:00:00:00"     ;THESE THREE FIELDS MAKE UP STATUS LINE 1
TITL  "  NOVA 1000 V1.0";
TRCL  "    <"           ;
                        ;JUMP TABLE FOR NOVA ROUTINES
STRT  JP STRT1          ;ACTIVATE NOVA VIDEO ROUTINE
DIM   JP DIM1           ;INITIALIZE COMVAR NAME 
ULD   JP ULD1           ;MOVE COMVAR TO STATUS LINE
DLD   JP DLD1           ;MOVE STATUS LINE TO COMVAR
SOFT  JP SOFT1          ;TEST AND LOAD OFFSET

Regards
Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by PokeMon » Fri Mar 02, 2018 6:15 pm

I think it's here:

Code: Select all

VDR1  CALL SNC          ;FRAMES, KEYBOARD, VERTICAL SYNC
      LD B,07           ;ALIGN SCREEN
      CALL DLY          ;VARIABLE DELAY ROUTINE
      LD A,EC           ;NUMBER OF TOP BLANK LINES
      EX AF             ;SAVE FOR NMI
      CALL TRCE         ;BASIC LINE TRACE ROUTINE
      CALL USR          ;DO USER ROUTINE
      LD IX,VDR         ;RESTORE VDR JUMP VECTOR
      JP 02A4           ;EXIT TO BASIC UNTIL NEXT VDR
I guess there are more lines displayed than on usual Zeddy (status line ?) - so LD A,EC has to be replaced.
I would just take the difference (24 lines between NTSC and PAL) and subtract it from "EC".
So would mean to take C8 to get more blank lines and result in 50 instead of 60 frames.
Other timing stuff should not be affected.

User avatar
siggi
Posts: 880
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by siggi » Sat Mar 03, 2018 7:05 pm

Hi Karl

I have patched NOVA2005 at address 16606, which contains (before relocation to top of ram) the value $EC (236) and poked it to 200 ($C8).
Now the midiplayer runs approximately at the correct speed (compared to a PC) and the monitor does not switch to NTSC (so the frame rate seems to be correct), but the picture (normally only 1 line visible) is distorted:

IMG_0015_640x480.JPG

Normal display:

IMG_0016_640x480.JPG
Gruß
Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
zsolt
Posts: 194
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by zsolt » Sun Mar 04, 2018 1:03 pm

siggi wrote:
Sat Mar 03, 2018 7:05 pm
I have patched NOVA2005 at address 16606, which contains (before relocation to top of ram) the value $EC (236) and poked it to 200 ($C8).
Try it using $CC (204) - the line counter seems to be 4 at start of displaying.
Gruß
Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]

User avatar
siggi
Posts: 880
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by siggi » Sun Mar 04, 2018 4:43 pm

I have tried 204 and the screen is looking good :mrgreen: , but the midiplayer is a little bit too fast. Now I am using 188, which gives as stable picture and the midi-timing seems also to be OK:
IMG_0018_640x480.JPG

Thanks
Siggi
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
zsolt
Posts: 194
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by zsolt » Sun Mar 04, 2018 8:31 pm

Hi Siggi,

I think the timing problem comes from elsewhere - you have to modify this part also:

Code: Select all

VDP2  ADD HL,DE         ;TRUE START OF DISPLAY
      LD A,(LINES)      ;CALCULATE NUMBER OF LINES
      AND 1F            ;
      LD B,A            ;SAVE IN B
      RLCA              ;CALCULATE BALNK LINES
      RLCA              ;
      RLCA              ;
      ADD A,3B          ;
      EX AF             ;SAVE IN AF’ FOR NMI
      LD C,08           ;
      JR ZDP2           ;GO DISPLAY MAIN SCREEN ALREADY
The ADD A,$3B is wrong - use ADD A,$32 instead, because:

312-6(VSYNC)-64(TOP BORDER)-192(24LINES)=50 ($32)

Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by PokeMon » Sun Mar 04, 2018 11:18 pm

siggi wrote:
Sun Mar 04, 2018 4:43 pm
I have tried 204 and the screen is looking good :mrgreen: , but the midiplayer is a little bit too fast. Now I am using 188, which gives as stable picture and the midi-timing seems also to be OK:
Seems I can not calculate. You have subtract 24 decimal (=$18). $EC-$18=$D4 (212).
This explains the effect with wrong line counter ...

The rest of the video routine is more complex than thought.
It is obviously necessary to adapt the A contents but you have to adjust in full char lines (8 scanlines).
It is possible to adjust the line counter here too in general but I wouldn't recommend.
Better is to use the correct offset.

I have to load the NOVA driver and measure something out.
The calculation is not so easy as some routines are placed (SDP/FRM/VDP) after the top blanking lines and are consumpting time for several scanlines, too.

Assuming that the timing in general is correct, I would propose to subtract 24/$18 from the bottom blank lines value also - so add $23 instead of $3B.
The article is a bit confusing from Wilf as it states that the display can hold 24, 28 or 29 lines. This is mixed up with the status line and ZX status line. I would recommend to load the driver and measure a bit. I am unsure what happens with the timing when the lines value is increased above 24 (to 28) and how it will effect the timing. He wrote:

Code: Select all

Increased number of lines with up to 29 lines (in 50Hz mode)


The calculation of the AF' value is tricky. So he used lines*8+$3B. If lines is 24 it matches 251 which results in 5 scanlines plus sync scanline. Every missing displayed line increments this value by 8 (243=13 scanlines plus syncline). But if you poke it to 28 this calculated value is 283-256=27 which results in 230 additional bottom blank lines and this will get timing totally out of control.

So he must have thought about the NTSC/PAL stuff in general. ;)

User avatar
siggi
Posts: 880
Joined: Thu May 08, 2008 9:30 am
Location: Dauernheim, Germany
Contact:

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by siggi » Tue Mar 06, 2018 9:38 am

There is one thing more, that needs to be done for a 50 Hz version: Wilf's "real time clock", visible at the top line of the screen (could also be used for time dependant BASIC actions) counts the ticks up to 59, before a rollover to a new second is performed. This rollover need to take place at 49 for 50 Hz video.

But that is one of the minor problems .... ;)
My ZX81 web-server: online since 2007
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
Paul
Posts: 998
Joined: Thu May 27, 2010 8:15 am
Location: Germanys west end

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by Paul » Tue Mar 06, 2018 10:17 am

Are you creating an alternative or will the new nova driver detect the video frequency and switch to the needed value?
Kind regards Paul
In theory, there is no difference between theory and practice. But, in practice, there is.

User avatar
PokeMon
Posts: 2225
Joined: Sat Sep 17, 2011 6:48 pm

Re: Wilf's NOVA2005 for 50 Hz Zeddies?

Post by PokeMon » Tue Mar 06, 2018 9:55 pm

If the delay routine is adapted it will be possible to read the MARGIN value. 8-)

Code: Select all

VDR1  CALL SNC          ;FRAMES, KEYBOARD, VERTICAL SYNC
      LD B,07           ;ALIGN SCREEN
      CALL DLY          ;VARIABLE DELAY ROUTINE

Post Reply