Hidden BASIC lines at end of program space

Anything Sinclair ZX Basic related; history, development, tips - differences between BASIC on the ZX80 and ZX81
stroebeljc
Posts: 67
Joined: Thu Apr 23, 2020 6:02 am

Re: Hidden BASIC lines at end of program space

Post by stroebeljc »

dr beep wrote: Fri May 01, 2020 7:26 pm I am coding directly in a compiler and compile to .P
My BASIC is always just 1 line, the call to MC only.
My MC is stored in every available address.
I have placed my BASIC line call to MC fully over the sysvar.
My games have autostart. When you would hack the NXTLIN you still don't get a line of BASIC since it is placed over sysvar.
Because I am not using the editor to enter lines I can make such games.
If you want to code the most out of a ZX81 you must not code ON the ZX81 but on other platform and make it only loadable for the ZX81.
Yes, back in the day we didn't have all of the fancy tools we do now.
I would love to learn more about your sysvar technique.
John
dr beep
Posts: 2076
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Hidden BASIC lines at end of program space

Post by dr beep »

This is the base model I use, even the compressed screen is in its shortest mode by placing the JP (HL) at the last NewLine

Code: Select all

; Base model for optimal ZX81 code in lowres 

; 12 bytes from #4000 to #400B free reuseble for own "variables"

	org #4009

; in LOWRES more sysvar are used, but in this way the shortest code
; over sysvar to start machinecode. This saves 11 bytes of BASIC

; DO NOT CHANGE AFTER BASIC+3 (=DFILE)
basic   ld h,dfile/256			; highbyte of dfile
        jr init1

	db 236				; BASIC over DFILE data
	db 212,28			
	db 126,143,0,18

eline	dw last
chadd	dw last-1
        db 0,0,0,0,0,0			; x
berg	db 0				; x

mem	db 0,0				; x OVERWRITTEN ON LOAD

init1	ld l, dfile mod 256		; low byte of dfile
	jr init2			
		
lastk	db 255,255,255
margin  db 55

nxtlin  dw basic			; BASIC-line over sysvar	

flagx   equ init2+2
init2	ld (basic+3),hl			; repair correct DFILE flagx will be set with 64, the correct value
	
	ld h,vars/256
	db 0,0				; x used by ZX81, not effective code after loading

	ld l,vars mod 256
frames  db #37				; 1 more than actual command
	db #e9				; this must have bit 7 set

	jp gamecode			; YOUR ACTUAL GAMECODE, can be everywhere
	db 0,0

cdflag  db 64
; DO NOT CHANGE SYSVAR ABOVE!

; free codeable memory
gamecode jr gamecode			; your code, this is example to show this works

; the display file, Code the lines needed.
dfile 	db 118

; each line has text and a Newline
	db 28,29,30,31,32,33,34,35,36,37
	db 28,29,30,31,32,33,34,35,36,37
	db 28,29,30,31,32,33,34,35,36,37
	db 28,29,30,31,32,33,34,35,36,37
	db 118
 	db "T"+101,"E"+101,"S"+101,"T"+101
	db 118

; this byte fills the unused part of the screen	
vars    db 128		; becomes JP (HL), saves another byte
last	equ $   	

end                	
Post Reply