Gamecoding in machinecode on a ZX81.

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
Spinnetti
Posts: 253
Joined: Sat Sep 12, 2020 11:29 pm

Re: Gamecoding in machinecode on a ZX81.

Post by Spinnetti »

Thanks!
Zeddy: ZX80, ZX81/ZXpand, TS1000/ZXpand, TS1500/Zxpand+
Speccy: 48k, +, +2, +3, TS2068, "Bare Metal" Pi, Next KS2, IF1/Microdrives/Vdrive/Light Gun/VGA-Joy
QL: Minerva/QL-VGA/Custom PSU
C5: 24v, LiFE battery, Disc brakes
Brimbard
Posts: 10
Joined: Wed Dec 01, 2021 8:12 pm

Re: Gamecoding in machinecode on a ZX81.

Post by Brimbard »

Hello,

I am late starter hoping this discussion did not die yet.

First of all I have created a personal version:
GAME1-012.asm
(10.12 KiB) Downloaded 241 times
Since I use using FASM-ZX, you may need to adept to your assembler of choice.
game1-011_test2.png
The weird character in the listing below is actually showing as a ZX81 graphics.
And the double colon makes the conversion to the ZX81 char set.

In my version when the time is up the actual dot gets replaced with an invers 'X'.
just before 'playon':

Code: Select all

        jr nz,playon            ; time we still can play

        push hl
        ld hl,(dot)             ; replace the dot with a block
        ld (hl),,'ú'            ; set a block
        pop hl
//use a life counter?
        jr newdot

// non-reachable code, when to end (life counter)?
        jp gamecode             ; temporary end of game

playon: push hl
This is leaving me with some more "TODO's" ;)

To make such chars blocking the player I continue at label test2: with:

Code: Select all

test2:  cp 61+128               ; 'ú'
        jr nz,goodpos
        ld bc,(lastpos)         ; reset position (don't move)
        call field              ; and screen pos to draw

goodpos:ld (hl),,'ð'            ; we write an invers "O" on the screen
        ld (lastpos),bc         ; remember actual XY as last one

timecnt:
Those code snippets make use of memory variables which I have defined upfront just before gamecode:.

Code: Select all

dot     dw $0000                ; position of actual dot
lastpos dw $0000                ; last position of the player

gamecode:
And this where I would like to ask: There are limitations set by the display routine, I know.
But still, Can't we make use of the shadow registers and at least IY?
I thought IY is only used by the Basic interpreter and could be simply reset to $4000 in case we intend to go back.

So what is/are the experience/recommendations here?
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Gamecoding in machinecode on a ZX81.

Post by dr beep »

Brimbard wrote: Sun Dec 05, 2021 10:04 am Hello,

I am late starter hoping this discussion did not die yet.
Well, it is inactive and I nee to revive it.
Need to get some time for it, which might be possible since I stopped coding 1K hires games now for valid reasons.
And this where I would like to ask: There are limitations set by the display routine, I know.
But still, Can't we make use of the shadow registers and at least IY?
I thought IY is only used by the Basic interpreter and could be simply reset to $4000 in case we intend to go back.

So what is/are the experience/recommendations here?
Yes, shadowregisters can be used, but not needed (yet) here.

IY is a problem. When not set to #4000 the intrupt might crash.
The display uses IY at #294 and #297.
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Gamecoding in machinecode on a ZX81.

Post by mrtinb »

That’s what I’ve heard as well, but I haven’t used IY.

What does “Master Machine Code on your ZX81” say about using IY-register?
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
User avatar
mrtinb
Posts: 1906
Joined: Fri Nov 06, 2015 5:44 pm
Location: Denmark
Contact:

Re: Gamecoding in machinecode on a ZX81.

Post by mrtinb »

I’ve just looked through “Mastering Machine Code on your ZX81”, and I cannot find any mentioning of IY usage.
Martin
https://zx.rtin.be
ZX81, Lambda 8300, Commodore 64, Mac G4 Cube
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: Gamecoding in machinecode on a ZX81.

Post by dr beep »

mrtinb wrote: Sun Dec 05, 2021 12:06 pm That’s what I’ve heard as well, but I haven’t used IY.

What does “Master Machine Code on your ZX81” say about using IY-register?
I tried using IY in my hires games, assuming that I could PUSH and POP it in intrupt or assuming my hires routine didn't use IY so it was free.
It crashed on the use mentioned.
Moggy
Posts: 3231
Joined: Wed Jun 18, 2008 2:00 pm

Re: Gamecoding in machinecode on a ZX81.

Post by Moggy »

The book, Assembly language assembled for the Sinclair ZX81 written by Anthony Woods has programs plus a listing for the emulation "Life" which use the index registers but everything has to be run in fast mode when those registers are called.

The programs in the book, I find, don't do anything really useful and there are errors in places but hopefully you may find something of use concerning your problem.


The PDF can be found here...

https://datassette.nyc3.cdn.digitalocea ... r_zx81.pdf
Brimbard
Posts: 10
Joined: Wed Dec 01, 2021 8:12 pm

Re: Gamecoding in machinecode on a ZX81.

Post by Brimbard »

Thanks for pointing to #292 and #297.

My first approach looking at the documentation (Ian Logan)
Logan_292.PNG
made me first doubt because I read the '(MARGIN)' and '(CDFLAGS)' as simple references to the system vars as described in the original Sinclair handbook.

But thanks to today's emulators I could quickly verify, that indeed the IY-register is used:
mem_292.png
Seems reading the documentation is not that easy. :D

Thanks for the quick reply.
MrVertigo
Posts: 105
Joined: Fri May 27, 2022 9:06 pm

Re: Gamecoding in machinecode on a ZX81.

Post by MrVertigo »

Not sure if this thread is still active, but the instructions fail for me right at the start. I drag the Game file to the Bat file. I get the dos window telling me to press any key. But I don’t get a .P file or a .LST file in the folder when dos window closes. I get nothing.

Any suggestions for why this is? I’m using Windows XP.
User avatar
XavSnap
Posts: 1940
Joined: Sat May 10, 2008 4:23 pm
Location: 'Zx81 France' Fb group.

Re: Gamecoding in machinecode on a ZX81.

Post by XavSnap »

Hi,
I get nothing.
In DOS mode, just type a batch file (BAT) to launch the assembler...

COMPIL.BAT

Code: Select all

ASM myfile.bin myfile.TXT
PAUSE
The PAUSE will wait a key and will freeze the DOS screen, to allow to read the onscreen error restult.

Use:

Code: Select all

ASM -h
ASM -?
PAUSE
to get ASM syntax,.

On DOS assembler, use the 8+3 format "12345678.123" file name format!

Try to close all editors text or binary used with your file.

Used to uncompress the zip before uses, it decompressed in a private temporary folder with long (Windows) name format...
Simple use a private folder "c:/ASM/TMP", never "c:/my_dally_work/my_precious_project"

Not on the Descktop, the Download or Temporary Windows directory !


Don't use any specials language characters... "âàéù"... and don't use the space character in the name too.

With Win 10, use an emulator like "DosBox" to run old DOS programs.

Code: Select all

LD C,(IY+$3B)
Is a relative jump, always in decimal.

LD C,(IY+59) to avoid to use LD A,($403B) ; LD C,A

... LD C,($403B) can't be use on the Z80 !

To retrieve BC, you had to get BC (16 bits;2 bytes) LD BC,($403B), but B is overwritten.
Xavier ...on the Facebook groupe : "Zx81 France"(fr)
Post Reply