Need for speed - the ROM-patches

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
User avatar
zsolt
Posts: 214
Joined: Wed Apr 20, 2011 11:43 am
Location: Fót, Hungary

Need for speed - the ROM-patches

Post by zsolt »

Hi All,

In the past 30 years, more solution was born to increase the speed of the ZX81.
The hardware-ideas are Well-documented: Kevin Baker's clock doubler (which was then improved by Wilf Rigter )
or even Wilf's "Why Wait" article, which promises to increase the SLOW mode program speed by 10%.

But what about the ROM-patches?

Full description of the ecellent SG81 can be found on Geoff Wermouth's website.

And where's the rest? I found nowhere. (for example what Siggi wrote "for/next", "gosub/return")

So it is possible that this little patch is a well-known mod, but nowhere described:

Code: Select all

; ------------------------------------
; THE 'NON MASKABLE INTERRUPT' ROUTINE
; ------------------------------------
;
;   ( It takes 29 clock cycles while incrementing towards zero - it was 32TS). 

;; NMI
L0066:
	  EX AF,AF'			; (4) switch in the NMI's copy of the 
					;	accumulator.
	  INC A			; (4) increment.
;
; JP M,L006D (10) was removed for faster NMI-service:  the user application gets +3TS/NMI
;
	  JR Z,L006C		; (12) forward to NMI-CONT
					; when line count has incremented to zero.
;
;; NMI-RET			(7!!!) else
;				
	  EX AF,AF'			; (4)  switch out the incremented line counter
					; or test result $80
	  RET 			; (10) return to User application for a while.
; ---
;   This branch is taken when the 55 (or 31) lines have been drawn.

;; NMI-CONT (its address was L006F) 
L006C:
	  EX AF,AF'			; (4) restore the main accumulator.

	  PUSH AF			; (11) *  Save Main Registers
	  PUSH BC			; (11) **
	  PUSH DE			; (11) ***
	  PUSH HL			; (11) ****

;   the next set-up procedure is only really applicable when the top set of 
;   blank lines have been generated.

	  LD HL,($400C)		; (16) fetch start of Display File from D_FILE
					; points to the HALT at beginning.
	  SET 7,H			; (8) point to upper 32K 'echo display file'

	  HALT			; (1) HALT synchronizes with NMI.  
					; Used with special hardware connected to the
					; Z80 HALT and WAIT lines to take 1 clock cycle.

	  OUT ($FD),A		; (11) Stop the NMI generator.

	  JP IX_to_PC		; (10) Delay because of the removed 'JP M,...'
IX_to_PC
	  JP (IX) 			; (8) forward to L0281 (after top) or L028F
Should we not collect them (all improvements) together into a standard 'Super81' ROM?

Zsolt
ZX81 (8K), ENTERPRISE 128, [ZX SPECTRUM (48K,+,+128K,+2,+2A), TS1000, TS1500, TS2068, Cambridge Z88, PRIMO A64 (red)]
User avatar
1024MAK
Posts: 5087
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Need for speed - the ROM-patches

Post by 1024MAK »

Why yes, of course we should... :D
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Buffer Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer later in the year.
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: Need for speed - the ROM-patches

Post by Andy Rea »

This is an excellent idea, the faster math of the SG rom should of course be included, whats this about quicker for/next loops ?

Andy
what's that Smell.... smells like fresh flux and solder fumes...
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: Need for speed - the ROM-patches

Post by sirmorris »

Will be in the next ZXpand ROM :)
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Need for speed - the ROM-patches

Post by siggi »

zsolt wrote: And where's the rest? I found nowhere. (for example what Siggi wrote "for/next", "gosub/return")
That "QCOM1-Patch" to speed up for/next and gosub/return was described in an early ZX-Team magazine (paper version). The source code for ASDIS, used to "poke" into the ROM (copied into RAM), is stored on my server in directory "d:source/rompatch/" (file "qcom1pat.p").
The patches are: instead of storing the line number to be extecuted after NEXT and RETURN the address of that line is stored. So a call to the "find-line" subroutine need not be called any more.

I will try to find the old description and will post also the "POKEs" to the original rom.

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Need for speed - the ROM-patches

Post by PokeMon »

BASIC is very slow due to consequent use of floating point arithmetic even for normal loops with increment of 1.
I think an implementation of integer data types could increase speed significantly, not only for the loops. ;)
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Need for speed - the ROM-patches

Post by siggi »

PokeMon wrote:BASIC is very slow due to consequent use of floating point arithmetic even for normal loops with increment of 1.
I think an implementation of integer data types could increase speed significantly, not only for the loops. ;)
but would be compatible to nothing :(
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Need for speed - the ROM-patches

Post by siggi »

QCOM1-3 patches have been described in the ZX-Team Magazine 6/2002 at page 24:
http://forum.tlienhard.com/magazin/2002/magazin_602.pdf

Team Magazine 1/2003 describes also a patch of the NMI routine (3T-Patch) at page 26:
http://forum.tlienhard.com/magazin/2003/magazin_103.pdf

POKEs will follow ...

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: Need for speed - the ROM-patches

Post by siggi »

For those who don't have access to Tom's forum (where the scanned ZX-TEAM-Magazines are stored as PDF): here is the QCOM1-source code of Ludwig:
qcom1.jpg
qcom1.jpg (117.04 KiB) Viewed 9072 times
And here is the ASDIS source which I used to make those "POKEs" "on the fly"
STARTLD HL,$0EB6 21B60E
LD A,$29 3E29
CALL PATCH CDB440
LD HL,$0EB8 21B80E
LD A,$00 3E00
CALL PATCH CDB440
LD HL,$0DF6 21F60D
LD A,$29 3E29
CALL PATCH CDB440
LD HL,$0DF9 21F90D
LD A,$00 3E00
CALL PATCH CDB440
LD HL,$0EE4 21E40E
LD A,$A9 3EA9
CALL PATCH CDB440
LD HL,$0E57 21570E
LD A,$36 3E36
CALL PATCH CDB440
END JR END 18FE
PATCHLD C,(HL) 4E
LD (HL),A 77
RET C9


HTH
Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
User avatar
PokeMon
Posts: 2264
Joined: Sat Sep 17, 2011 6:48 pm

Re: Need for speed - the ROM-patches

Post by PokeMon »

siggi wrote: but would be compatible to nothing :(
If Clive would have thought this pessimistic way we wouldn't have that ZX81 at all.
Keep looking forward, not backwards.

Could be made compatible while parsing the code automatically (if a variable is "calculated" other than plus/minus with integers).
And could be used to mark integer variables special for writing new programs.
If ZX81 does not support this patch these variables treated as non-integers (slow).

Could be made by convention / name of variable e.g. 8-)

If you want to do something new you have to leave all old concepts in your mind.
Compatibility comes after and if you think you will find a way in most cases.
Otherwise nothing really new would come to the world. :roll:
Post Reply