New display engine for games and more
-
- Posts: 330
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
New display engine for games and more
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.
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 239 times
/Adam
Re: New display engine for games and more
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
nice little demo Adam, anyone who has unraveled the code spaghetti and stack trick employed in this display routine gets brownie points from me
regards Andy
regards Andy
what's that Smell.... smells like fresh flux and solder fumes...
Re: New display engine for games and more
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
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
http://zx81.ddns.net/ZxTeaM
-
- Posts: 330
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
Re: New display engine for games and more
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?!
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
Re: New display engine for games and more
@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...
Re: New display engine for games and more
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
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...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.
so erm ignore my previous post and fire up the debugger in Eightyone
Regard Andy
what's that Smell.... smells like fresh flux and solder fumes...
-
- Posts: 330
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
Re: New display engine for games and more
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.
I copied the jump and address from lower memory to upper memory that ends the status text.
- Attachments
-
- engine2.zip
- (4.48 KiB) Downloaded 208 times
/Adam
-
- Posts: 330
- Joined: Sat Sep 27, 2014 8:02 pm
- Location: Stockholm, Sweden
Re: New display engine for games and more
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
/Adam