ZX81 Assembly on OSX

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
wietze
Posts: 12
Joined: Thu Jun 25, 2020 2:30 pm

Re: ZX81 Assembly on OSX

Post by wietze »

Thank you for the explanation. I knew the gist of it, but you uncovered a few very interesing points, like the custom display mode change the ratio of cpu spent on display mode. I was not aware this was possible.

Would you be able to point me to some more in depth resources regarding this?
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: ZX81 Assembly on OSX

Post by mrtinb »

The Nova program from Wilf Rigter, makes it possible for you to select how many lines you want on your display.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
1024MAK
Posts: 5101
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: ZX81 Assembly on OSX

Post by 1024MAK »

wietze wrote: Fri Jul 10, 2020 4:39 pm Would you be able to point me to some more in depth resources regarding this?
Read Wilf Rigter’s Video Tutorial first ;)

Note: by default the pages at the linked to web site may not display correctly, so switch your character set to "western" for correct display.

Mark
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.
wietze
Posts: 12
Joined: Thu Jun 25, 2020 2:30 pm

Re: ZX81 Assembly on OSX

Post by wietze »

Awesome, thanks, I will!
wietze
Posts: 12
Joined: Thu Jun 25, 2020 2:30 pm

Re: ZX81 Assembly on OSX

Post by wietze »

Ok, Ive spend a few evenings trying to digest whats being mentioned here.

It seems to me that one of the tricks to gain more CPU for user program per frame is to display less `lines' of memory, e.g. have the CPU active less lines.

I am still very much a Z80 noob, but from the code listings, I kind of derive that it is altering internal counters to do this. I ASSUME that these counters make use of the shadow-registers that the ZX has, together with the special purpose address register. What I do not get entirely yet is the following:

Is it possible to have user defined interrupt vectors? I thought it was not possible, and thus basically only ROM code is executed. Then it seems to me that the user code needs to overwrite the video-related shadow registers after VBLANK. I guess I need to dive into the system variables that are captured in RAM from $4000 on.

So far it has been a very interesting journey. I am wondering, is there some context where I can learn more about what (shadow) registers are keeping which information, or should I dig through the ROM/OS function for this. So far Ive been reading the excerpts listed at https://cdn.hackaday.io/files/289631239 ... -02-09.htm and mentioned at the Wilf Rigter documents.

This is awesome stuff guys, Im very motivated to get into this, thanks for the help so far!

Wietze
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: ZX81 Assembly on OSX

Post by mrtinb »

You have two options when programming for the ZX81:
  1. Use the ROM interrupt routine, and this displays only text 32x24.
  2. Use your own interrupt routine, to generate the display with the same sync timings as the ROM routine. This routine has to be very precise, or it will fail to show on all TVs/monitors. Since we all don't have old forgiving TVs, you better copy an interrupt routine that is known to work.
    • If you need hires in your program, you need a custom interrupt routine. Here Wilf Rigter's WRX routine is recommended.
    • If you need pseudo hires, you need a custom interrupt routine. Here Paul Farrow's Celebration routine is recommended.
    • If you need text mode, but with fewer lines, to get more CPU, you need a custom interrupt routine. Here Wilf Rigter's NOVA routine is recommended.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
wietze
Posts: 12
Joined: Thu Jun 25, 2020 2:30 pm

Re: ZX81 Assembly on OSX

Post by wietze »

Thanks so far for the information; Im getting the hang of it!

I have another question; for my develop -> assemble -> run cycle time, Id like to make a .p file that automatically starts running after loading the program. (Now I have to type RUN and press enter). Is there a way to include this into the coding template, or does one need to rework the resulting assembled .p file?

Thanks in advance!
Wietze
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: ZX81 Assembly on OSX

Post by mrtinb »

When you save a .P file, then within the file is also saved the memory address of the next Basic line to execute. That way the program can continue where it has left off, when being loaded again.

We use this feature to auto-RUN programs.

So lets say you have a line

Code: Select all

30 RAND USR 16514
That is at memory $4099

Code: Select all

4099: 00 1E (line number 30 is 001E in hex)
409B: 0E 00 (length of line is 14 which is 000E in hex)
409D: F9 (keyword RAND)
409E: D4 (keyword USR)
409F: 1D 22 21 1D 20 7E 8F 01 04 00 00 (Sinclair's representation of 16514 in text and float format)
40AA: 76 (newline)
That's fine, but we also need to tell your program to use that line, as the next line just after the program has loaded.

That information is stored in one of the system variables before the Basic lines. The system variables are also saved as part of the program. The system variable we need to setup in the source is NXTLIN. This is at address $4029.

So somewhere in your source you have a line which will compile to line $4029 and this needs the address of the Basic line e.g.:

Code: Select all

NXTLIN: DW 4099h
I don't know how to do that in your assembler, but you must make sure that address $4029 points to the address of the first byte of the Basic line number (the first byte is where the line number is stored).
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
wietze
Posts: 12
Joined: Thu Jun 25, 2020 2:30 pm

Re: ZX81 Assembly on OSX

Post by wietze »

Ah yes thats it! Thanks!
I was feeding this with the address to the actual assembly code, but it needed to point to the basic command.
Good, this works! Thanks again!
Post Reply