Page 4 of 6

Re: Gamecoding in machinecode on a ZX81.

Posted: Mon Apr 19, 2021 7:42 pm
by Spinnetti
Thanks!

Re: Gamecoding in machinecode on a ZX81.

Posted: Sun Dec 05, 2021 10:04 am
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 253 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?

Re: Gamecoding in machinecode on a ZX81.

Posted: Sun Dec 05, 2021 12:02 pm
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.

Re: Gamecoding in machinecode on a ZX81.

Posted: Sun Dec 05, 2021 12:06 pm
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?

Re: Gamecoding in machinecode on a ZX81.

Posted: Sun Dec 05, 2021 12:16 pm
by mrtinb
I’ve just looked through “Mastering Machine Code on your ZX81”, and I cannot find any mentioning of IY usage.

Re: Gamecoding in machinecode on a ZX81.

Posted: Sun Dec 05, 2021 1:13 pm
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.

Re: Gamecoding in machinecode on a ZX81.

Posted: Sun Dec 05, 2021 3:08 pm
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

Re: Gamecoding in machinecode on a ZX81.

Posted: Sun Dec 05, 2021 7:31 pm
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.

Re: Gamecoding in machinecode on a ZX81.

Posted: Thu Jul 14, 2022 2:27 pm
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.

Re: Gamecoding in machinecode on a ZX81.

Posted: Thu Jul 14, 2022 4:12 pm
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.