ZX81 Rom Routines

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Post Reply
swensont
Posts: 76
Joined: Tue Jan 18, 2011 4:55 am
Location: SF Bay Area
Contact:

ZX81 Rom Routines

Post by swensont »

After many years away, I've decided to get back to doing some Z80 assembly programming on the ZX81. I've updated the process a bit by using the TASM cross assembler and the EightyOne emulator.

I still have my copies of Toni Bakers Book "Mastering Machine Code ..." and the ZX81 Rom book by Dr. Logan. Through these and other sources, I've been able to figure out how to call a number of ZX81 ROM routines, but I'm still having a problem with two, UNPLOT and PAUSE.

From Update magazine, I found mention of how to use PLOT:

PLOT

ld b,YY
ld c,XX
ld a,$9B
call Plot ;$0BB2

And this works, but the published UNPLOT does not :

UNPLOT

ld b,YY
ld c,XX
ld a,$A0
call Plot ;$0BB2

I'm not sure what value to load into A that will perform the UNPLOT. Reading the ROM book has not been helpful.

For PAUSE, Toni Baker shows it like this:

LD HL,$0F00
LD ($4034),HL ;4034 is FRAMES
CALL PAUSE ;$0229

That does not work and seems to crash the system. There is a PAUSE defined in the ROM book. I've tried calling that and no luck.

Anyone know how these work?

P. S. I see lots of new games distributed with .P files. How about also distributing the source code so us newbies can learn a thing or two?
Moggy
Posts: 3267
Joined: Wed Jun 18, 2008 2:00 pm

Re: ZX81 Rom Routines

Post by Moggy »

Hi Swensont welcom aboard.

Try this link when refering to Tony/i Bakers book.
It's a re-write with most of the bugs and errors that plagued all three revisions of the book removed ; especially the calculator and rom routines.

Hope it helps. :)

Moggy

http://www.users.waitrose.com/~thunor/m ... index.html
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: ZX81 Rom Routines

Post by Andy Rea »

for un-plotting try to make sure memory address $4030 holds the value $9E before calling the routine, any value lower than $9E and the plot/unplot routine will call plot in any case, also the value of A prior to the call $0BB2 has noo effect, A is loaded with the value $2B (43 in decimal) to check the y-co-ord is in the acceptable range.

the pause one has got me. but you can try this.

LD BC,pausetime ;<=32767 this is in frames not seconds so 200 = approx 4 secs
CALL $0F35

All the best Andy
what's that Smell.... smells like fresh flux and solder fumes...
swensont
Posts: 76
Joined: Tue Jan 18, 2011 4:55 am
Location: SF Bay Area
Contact:

Re: ZX81 Rom Routines

Post by swensont »

I've done some tests and am a little bit closer.

PLOT / UNPLOT

For plot, I loaded BC with the X & Y values and it works.
For unplot, I loaded BC with the X & Y values, then put $9E in $4030, and this works.
But, the next call to plot, fails (I did not touch $4030 in between). I also found that putting zero in $4030 is bad too.
If I put $9E again in $4030, then call plot, that also fails.

Back to the drawing board on unplotting.

PAUSE

Andy, your suggestion for calling $0F35 after putting 200 in BC did not worked and caused a reset.

Moggy, Thanks for the link to the updated Baker book. I think my copy is from the first printing in the US.

Tim Swenson
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: ZX81 Rom Routines

Post by Andy Rea »

Hi Tim,

I have done a little bit of experimenting and have come up with the following.

Code: Select all

0061   4082 01 00 00    PLOT	LD	BC,$0000
0062   4085 2A 30 40    	LD	HL,($4030)
0063   4088 E5          	PUSH	HL		;SAVE t-ADDR
0064   4089 3E 98       	LD	A,$98		;AS LONG AS IT'S LESS THAN $9E SHOULD PLOT.
0065   408B 32 30 40    	LD	($4030),A
0066   408E CD B2 0B    	CALL 	$0BB2
0067   4091 E1          	POP	HL
0068   4092 22 30 40    	LD	($4030),HL	;RESTORE t-ADDR
0069   4095 C9          	RET
0070   4096             
0071   4096 01 00 00    UNPLOT	LD	BC,$0000
0072   4099 2A 30 40    	LD	HL,($4030)
0073   409C E5          	PUSH	HL		;SAVE t-ADDR
0074   409D 3E 9E       	LD	A,$9E		;I THINK ANYTHING GREATER THAN $9E SHOULD UNPLOT
0075   409F 32 30 40    	LD	($4030),A
0076   40A2 CD B2 0B    	CALL	$0BB2
0077   40A5 E1          	POP	HL
0078   40A6 22 30 40    	LD	($4030),HL	;RESTORE t-ADDR
0079   40A9 C9          	RET
0080   40AA             
0081   40AA 01 00 02    PAUSE	LD	BC,$0200	;PAUSE LENGTH.
0082   40AD CD 35 0F    	CALL	$0F35
0083   40B0 C9          	RET
i have assembled it into 1st rem line of small demo program for you works fine here on eighty one emulator and my real zx81

all the best Andy
Attachments
PLUNPA2.P
(1.5 KiB) Downloaded 248 times
what's that Smell.... smells like fresh flux and solder fumes...
swensont
Posts: 76
Joined: Tue Jan 18, 2011 4:55 am
Location: SF Bay Area
Contact:

Re: ZX81 Rom Routines

Post by swensont »

Andy,

Thanks for the code. I've tested it myself with TASM and EightyOne and it worked just fine.

Tim Swenson
User avatar
gus
Posts: 177
Joined: Fri May 16, 2008 10:18 pm
Location: Buenos Aires. Argentina
Contact:

Re: ZX81 Rom Routines

Post by gus »

swensont wrote:...
Back to the drawing board on unplotting.
...


Hi Tim

I have a copy of the Timex Sinclair 1000/ZX81 User's Handbook and on that book I found one example for call the Plot/Unplot ROM routine.

On That Book you can see a program where the 0x4030 memory location is loaded with 0x9B for Plot and with 0x0A for Unplot. In order to test it I write a little program and I confirm that this works fine.

Then I checked The Complete Timex TS1000/Sinclair ZX81 ROM Disassembly where we can see that the 0x4030 location is checked in order to determine if thew Plot or Unplot command was called.

So when we call the function from ASM it's necessary to change the 0x4030 (T-ADDR)

Hope this help
Gus
Post Reply