New display engine for games and more

Any discussions related to the creation of new hardware or software for the ZX80 or ZX81
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

New display engine for games and more

Post by nollkolltroll »

When Zedragon was released, I was immediately impressed with the scrolling of the screen. I had a quick look at the source code and realized that what had been done in the display engine was very good and could be expanded upon with stuff I have coded.

Thus I began deciphering what the code really did, to understand it fully. In the process I rewrote it a few times to reach the current point.
A new display engine that can take a character based map that is much larger than the display allows, and can start at any character (X- and Y-scrolling of characters).
It's also possible to fine-scroll every two pixels in X and every pixel in Y.
A static 40-character status text is placed below the main screen.

All this works without any copying of screen areas, so more cycles are available to the game code. Reducing the height of the screen frees up even more cycles, and the scrolling makes it possible to create games that work well even though the screen is only a small window to the game world.

This technique can be used with either plain ZX81-text mode or UDG text mode.

I hope some people write some truly amazing games and applications with this code! Imagine a Super Mario or R-type game, or perhaps a scrolling text-editor/viewer.

Along with the source code is a simple demonstration "game world", use arrow keys to move the sprite around.
Attachments
engine.zip
(4.42 KiB) Downloaded 232 times
/Adam
sirmorris
Posts: 2811
Joined: Thu May 08, 2008 5:45 pm

Re: New display engine for games and more

Post by sirmorris »

I'm constantly amazed at what people can make this little machine do. Stunning work, Adam. Absolutely stunning.
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: New display engine for games and more

Post by Andy Rea »

nice little demo Adam, anyone who has unraveled the code spaghetti and stack trick employed in this display routine gets brownie points from me :mrgreen:

regards Andy
what's that Smell.... smells like fresh flux and solder fumes...
User avatar
siggi
Posts: 988
Joined: Thu May 08, 2008 9:30 am
Location: Wetterau, Germany
Contact:

Re: New display engine for games and more

Post by siggi »

HI Adam
I tried to run it with EO V1.6 and an emulated ZX81 havng 48K ram, but it crashes :(
It works with 16K and 32K ram.

So it will not work with my real 56K Zeddies????

Siggi
My ZX81 web-server: online since 2007, running since dec. 2020 using ZeddyNet hardware
http://zx81.ddns.net/ZxTeaM
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: New display engine for games and more

Post by nollkolltroll »

Andy: it was really inspiring to unravel your code, and hopefully the power of open source has made my version a bit more readable for the next person.

Siggi: I've only tested this on 16/32k machines and EightyOne, but will have a look. The display code should be memory size agnostic. Can't be much worse than a faulty stack, surely?!
/Adam
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: New display engine for games and more

Post by Andy Rea »

@siggi it patches the original d-file and places a JP xxxx there the JP is interpreted ok but then because of no M1 signal your 56k machine is not getting the correct opperand bytes, you could copy the jump address to the corresponding location ( d-file address + $8000 ) in the upper ram.
what's that Smell.... smells like fresh flux and solder fumes...
dr beep
Posts: 2060
Joined: Thu Jun 16, 2011 8:35 am
Location: Boxmeer

Re: New display engine for games and more

Post by dr beep »

siggi wrote: Fri Jan 19, 2018 10:32 am HI Adam
I tried to run it with EO V1.6 and an emulated ZX81 havng 48K ram, but it crashes :(
It works with 16K and 32K ram.

So it will not work with my real 56K Zeddies????

Siggi
The famous 48K bug.
I encountered this in a 1K hires game.
During display in upper memory an opcode with bit 6 set and using multiple addresses is used.
(I.e. ADD A,n or JP lowmemory)
With 48K memory the second (and third) byte is read from the real address. When there is nothing a game will work
Incorrect or crashes.

My fixed solution makes a full game copy in uppermemory. Then the correct byte is read even with 48K memory.
User avatar
Andy Rea
Posts: 1606
Joined: Fri May 09, 2008 2:48 pm
Location: Planet Earth
Contact:

Re: New display engine for games and more

Post by Andy Rea »

Andy Rea wrote: Fri Jan 19, 2018 11:41 am @siggi it patches the original d-file and places a JP xxxx there the JP is interpreted ok but then because of no M1 signal your 56k machine is not getting the correct opperand bytes, you could copy the jump address to the corresponding location ( d-file address + $8000 ) in the upper ram.
Whooay Slow down cowboy.... would have been better that i look at Adams code a bit closer before jumping the gun, seems like Adam has took over entirely the IX register and does the margins and Vsync and keyboard read all in his own code...

so erm ignore my previous post and fire up the debugger in Eightyone :D

Regard Andy
what's that Smell.... smells like fresh flux and solder fumes...
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: New display engine for games and more

Post by nollkolltroll »

Here is a version that works in EO 1.8 regardless of memory size 16k or upwards. A Zxpand is the largest memory I have available for real HW, so I hope this fix works on real HW.
I copied the jump and address from lower memory to upper memory that ends the status text.
Attachments
engine2.zip
(4.48 KiB) Downloaded 198 times
/Adam
nollkolltroll
Posts: 325
Joined: Sat Sep 27, 2014 8:02 pm
Location: Stockholm, Sweden

Re: New display engine for games and more

Post by nollkolltroll »

Andy Rea wrote: Fri Jan 19, 2018 5:54 pm Whooay Slow down cowboy.... would have been better that i look at Adams code a bit closer before jumping the gun, seems like Adam has took over entirely the IX register and does the margins and Vsync and keyboard read all in his own code...
Yeah, I like to properly understand what is REALLY needed for things to work, and I find the ROM does things that are not needed from my perspective. It is also quite hard to follow the code as it snakes along. Minimality to the rescue ;)
Anyway, thanks to your post Andy, I had a fix very fast as soon as I understood what you meant together with dr Beeps comments. Not a slight feat with a high fever :D
/Adam
Post Reply