Page 1 of 2

New display engine for games and more

Posted: Thu Jan 18, 2018 7:40 pm
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.

Re: New display engine for games and more

Posted: Thu Jan 18, 2018 10:51 pm
by sirmorris
I'm constantly amazed at what people can make this little machine do. Stunning work, Adam. Absolutely stunning.

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 12:08 am
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

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 10:32 am
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

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 11:11 am
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?!

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 11:41 am
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.

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 1:32 pm
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.

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 5:54 pm
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

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 6:03 pm
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.

Re: New display engine for games and more

Posted: Fri Jan 19, 2018 6:12 pm
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