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: 153
Joined: Wed Apr 20, 2011 10:43 am
Location: Fót, Hungary

Need for speed - the ROM-patches

Post by zsolt » Fri Mar 16, 2012 2:48 pm

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

User avatar
1024MAK
Posts: 1771
Joined: Mon Sep 26, 2011 9:56 am
Location: Looking forward to summer in Somerset, UK...

Re: Need for speed - the ROM-patches

Post by 1024MAK » Fri Mar 16, 2012 5:08 pm

Why yes, of course we should... :D

User avatar
Andy Rea
Posts: 1267
Joined: Fri May 09, 2008 1:48 pm
Location: notts UK

Re: Need for speed - the ROM-patches

Post by Andy Rea » Fri Mar 16, 2012 10:12 pm

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
6 x ZX81, 1 x TS1500 , 1 x +3e, 1 x timex 2040 printer, 1 x timex 2020 cassette deck, siclair printer and some spectrum

User avatar
sirmorris
Posts: 2667
Joined: Thu May 08, 2008 4:45 pm
Location: oxon, uk

Re: Need for speed - the ROM-patches

Post by sirmorris » Fri Mar 16, 2012 10:56 pm

Will be in the next ZXpand ROM :)
--=== ZXpand+ ... A more moderner all-in-one upgrade solution for ZX81 ===--
* SD/MMC storage * 32K Hires-capable RAM * AY sound chip * Joystick port * Serial *
* BASIC enhancements - plug & play * Reset button * Auto-boot facility *

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

Re: Need for speed - the ROM-patches

Post by siggi » Sat Mar 17, 2012 10:41 am

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
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
PokeMon
Posts: 2137
Joined: Sat Sep 17, 2011 5:48 pm

Re: Need for speed - the ROM-patches

Post by PokeMon » Sat Mar 17, 2012 3:02 pm

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: 755
Joined: Thu May 08, 2008 8:30 am
Location: Dauernheim, Germany
Contact:

Re: Need for speed - the ROM-patches

Post by siggi » Sat Mar 17, 2012 4:40 pm

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
http://zx81-siggi.endoftheinternet.org/index.html

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

Re: Need for speed - the ROM-patches

Post by siggi » Sat Mar 17, 2012 4:50 pm

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
http://zx81-siggi.endoftheinternet.org/index.html

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

Re: Need for speed - the ROM-patches

Post by siggi » Sat Mar 17, 2012 5:57 pm

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 3028 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
http://zx81-siggi.endoftheinternet.org/index.html

User avatar
PokeMon
Posts: 2137
Joined: Sat Sep 17, 2011 5:48 pm

Re: Need for speed - the ROM-patches

Post by PokeMon » Sat Mar 17, 2012 7:09 pm

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

Who is online

Users browsing this forum: No registered users and 1 guest