Ringo-8 64x48 GFX Lib

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
User avatar
DenisGrachev
Dizzy
Posts: 88
Joined: Fri Feb 09, 2018 2:32 am
Location: Novosibirsk, RU
Contact:

Ringo-8 64x48 GFX Lib

Post by DenisGrachev »

Ringo-8 is a 64x48 Graphics Library For ZX Spectrum 128KB based on my render engine from Ringo

I hope someone will find it useful :)

Have fun!

https://github.com/DenisGrachev/Ringo-8

See ya!

Czarnikjak
Dizzy
Posts: 67
Joined: Wed Feb 02, 2022 10:53 am

Re: Ringo-8 64x48 GFX Lib

Post by Czarnikjak »

Impressive! Hopefully we will see some games using it.

It shows you how difficult and CPU intensive (engine takes something like 85% CPU cycles if I counted correctly) it is to do smooth animation and scrolling on ZX Spectrum without hardware sprites and scrolling support.

Out of curiosity, what is the biggest feasible tileMap size? (tileMapWidth x tileMapHeight)
XoRRoX
Manic Miner
Posts: 233
Joined: Wed Jul 11, 2018 6:34 am

Re: Ringo-8 64x48 GFX Lib

Post by XoRRoX »

A very impressive engine, Denis. Great work.


And thank you so much for sharing the source, very generous :)
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Ringo-8 64x48 GFX Lib

Post by Joefish »

Nicely done. I see this is a 2-frame process. Are you drawing an over-sized view first with whole tiles drawn (no clipping), adding the sprites, then copying a window of those attributes into the video RAM? When do you combine two colours into one attribute (I'd guess it's when you're drawing the tiles into a buffer, to be most efficient)?
Did you consider simply having one black column at the side of every tile, to make them easier to shift left and right without overlapping?

On another issue, what was the frame rate in GLUF, when you were doing (vertical) scrolling and 8x2 multicolour?
XoRRoX
Manic Miner
Posts: 233
Joined: Wed Jul 11, 2018 6:34 am

Re: Ringo-8 64x48 GFX Lib

Post by XoRRoX »

Czarnikjak wrote: Tue Dec 20, 2022 11:21 am Out of curiosity, what is the biggest feasible tileMap size? (tileMapWidth x tileMapHeight)
You'll find the documentation on Github interesting ;)
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Ringo-8 64x48 GFX Lib

Post by Joefish »

XoRRoX wrote: Tue Dec 20, 2022 11:50 am You'll find the documentation on Github interesting ;)
I've been trying to find the documentation! Is that ReadMe file all there is? Something this complicated could use a bit more in the way of instructions.
User avatar
DenisGrachev
Dizzy
Posts: 88
Joined: Fri Feb 09, 2018 2:32 am
Location: Novosibirsk, RU
Contact:

Re: Ringo-8 64x48 GFX Lib

Post by DenisGrachev »

Czarnikjak wrote: Tue Dec 20, 2022 11:21 am Out of curiosity, what is the biggest feasible tileMap size? (tileMapWidth x tileMapHeight)
Actually it limited by free ram, BUT if you need a big levels you just need something like 17x13 tilemap maybe, just like on consoles. Tilemap it's just what draws on screen so you free to copy rows and collums from another ram page with big level )
Joefish wrote: Tue Dec 20, 2022 11:40 am Nicely done. I see this is a 2-frame process. Are you drawing an over-sized view first with whole tiles drawn (no clipping), adding the sprites, then copying a window of those attributes into the video RAM? When do you combine two colours into one attribute (I'd guess it's when you're drawing the tiles into a buffer, to be most efficient)?
Did you consider simply having one black column at the side of every tile, to make them easier to shift left and right without overlapping?
On another issue, what was the frame rate in GLUF, when you were doing (vertical) scrolling and 8x2 multicolour?
Yep, it done how you write. It redraws 9x7 tiles in buffer with proper displacement based on camera X, select a tiles page with proper shift for a tile, put a super quick sprites on top and then copy it on 2 screens with a pattern:

screen1,screen2,screen2,screen1

It gives me a way to switch a screens every 8 lines, not 4, since we have a free hardware flip %)

Tiles combined with just ORing a sides, check tilesCodeSHifted in Engine folder and macros DRAW_TILE_LINES_SHIFTED
it looks something like this:

ld hl,ADDR ;10t
pop af ; 10t
or (hl) ;7t
ld (hl),a ;7t
pop hl : ld (ADDR+0),hl ;26
pop hl : ld (ADDR+2),hl ;26

Gluf also 25 FPS render as Old Tower, i'm using same beam avoiding logic all the way )

Old Tower use pop hl : ld (addr),hl chunk of code to draw from buffer and tiles list to render on top

Gluf use ld push buffer and draws tiles and sprites right inside big ld push code. Gluf sprites also support ORing so it looks natural when sprites overlap with elevators paper, there is also multicolor double buffer that haelpa a lot
Joefish wrote: Tue Dec 20, 2022 12:04 pm I've been trying to find the documentation! Is that ReadMe file all there is? Something this complicated could use a bit more in the way of instructions.
Oh, dat my fault, i'm bad on writes one. I'll try to update it one day with more info %)
Personally i love to teach from samples so i make more samples not docs )
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Ringo-8 64x48 GFX Lib

Post by Joefish »

DenisGrachev wrote: Tue Dec 20, 2022 1:41 pm Gluf also 25 FPS render as Old Tower, i'm using same beam avoiding logic all the way )
Old Tower use pop hl : ld (addr),hl chunk of code to draw from buffer and tiles list to render on top
Gluf use ld push buffer and draws tiles and sprites right inside big ld push code. Gluf sprites also support ORing so it looks natural when sprites overlap with elevators paper, there is also multicolor double buffer that haelpa a lot
So you draw the attributes to a double buffer, but you must draw the pixels straight to the screen, as it's a 48K game? So how does using pop hl : ld (addr),hl to draw tiles work when the tiles need to scroll up and down by 2 pixels? I can only see it working if you have 8 copies of that function, and there is not enough memory for that! I have tried to use PUSH to draw rows using a limit of 4 tile types on a row (PUSH AF, BC, DE or HL), but I could not make that work fast enough! :idea: Ah! :idea: - or do you have the whole level drawn in memory in columns (not tiles) and just copy what you need each frame?
User avatar
DenisGrachev
Dizzy
Posts: 88
Joined: Fri Feb 09, 2018 2:32 am
Location: Novosibirsk, RU
Contact:

Re: Ringo-8 64x48 GFX Lib

Post by DenisGrachev »

Joefish wrote: Tue Dec 20, 2022 5:00 pm So you draw the attributes to a double buffer, but you must draw the pixels straight to the screen, as it's a 48K game? So how does using pop hl : ld (addr),hl to draw tiles work when the tiles need to scroll up and down by 2 pixels? I can only see it working if you have 8 copies of that function, and there is not enough memory for that! I have tried to use PUSH to draw rows using a limit of 4 tile types on a row (PUSH AF, BC, DE or HL), but I could not make that work fast enough! :idea: Ah! :idea: - or do you have the whole level drawn in memory in columns (not tiles) and just copy what you need each frame?
pop hl : ld (addr) in Old Tower just copy from a big linear buffer where level is drawn, it not use any tiles and it's 48k game, vertical scroll is easy, just change sp at start

in Gluf big chunk of ld : push code it's a level ) i draw everything in it, so code IS a buffer, to move it verticaly i just jump to corresponding line and patch exit with jp (hl)

Multicolor is doublebuffered, so it swaps buffer right after pixels are redrawed and multicolor starts. I use double buffer since it was a pain in OldTower
GLuf is 128k game, there is a whole page of 16k for buffers, 4096b buffer with original colors to restore, 2x4096b buffers for double buffering and one 4096 buffer filled with red for postprocess red dead fx %)

You can grab a sources, but now they are cryptic even for me )
https://www.retrosouls.net/?page_id=848
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Ringo-8 64x48 GFX Lib

Post by Joefish »

DenisGrachev wrote: Wed Dec 21, 2022 2:18 am in Gluf big chunk of ld : push code it's a level ) i draw everything in it, so code IS a buffer, to move it verticaly i just jump to corresponding line and patch exit with jp (hl)
GLuf is 128k game, there is a whole page of 16k for buffers, 4096b buffer with original colors to restore, 2x4096b buffers for double buffering and one 4096 buffer filled with red for postprocess red dead fx %)
OK, I've seen it listed as 48K/128K. I've posted the correction to the database. It makes more sense if you can fill up memory banks with your drawing instructions and multicolour buffers. I've only just started seeing what I can do with memory paging and the sound chip in the 128K.

But I can never make any sense of reading anyone else's code!

I did try synching a 50fps horizontal PUSH scroller with an 8x4 attribute switch using the two screens, but it was very limited how much of the screen I could redraw. Also 8x4 attribute sprites and tiles don't really look much better than 8x8! And it's very limiting how many sprites you can add at 50fps. But I did try and maintain 8x2 attributes in a narrow column in the centre of the screen, so the player sprite could be multicolour.

But I was always drawing on the hidden half of the screens. Now I think about it, it should be possible to work behind the raster on the first frame, drawing on the half-rows of the screen just shown, then on the next frame, those worked half-rows will be hidden, and I can work behind the raster on the other half-rows, for a 25fps update.

Still a lot of work though, for something that would probably look no better than Green Beret, just with slightly thinner rows of colours!
TymoDEV
Drutt
Posts: 44
Joined: Wed Oct 19, 2022 2:52 am

Re: Ringo-8 64x48 GFX Lib

Post by TymoDEV »

How to switch graphic mode? What is initializing procedure?
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Ringo-8 64x48 GFX Lib

Post by Joefish »

DenisGrachev wrote: Wed Dec 21, 2022 2:18 am Multicolor is doublebuffered, so it swaps buffer right after pixels are redrawed and multicolor starts. I use double buffer since it was a pain in OldTower
One thing I sometimes do with a Multicolour buffer is have the address of the next line of the buffer at the end of each line, so it can be read with another POP HL then LD SP,HL (instead of having the LD SP,nnnn address hard-coded in the copy routine). It then means it's easy to make the buffer wrap around top-to-bottom, for when you want to make it scroll.
User avatar
DenisGrachev
Dizzy
Posts: 88
Joined: Fri Feb 09, 2018 2:32 am
Location: Novosibirsk, RU
Contact:

Re: Ringo-8 64x48 GFX Lib

Post by DenisGrachev »

TymoDEV wrote: Wed Dec 21, 2022 11:50 am How to switch graphic mode? What is initializing procedure?
Check a samples, it's enableRender proc. Bassicly it just start a renderFrame1&renderFrame2 chain in interrupt
Joefish wrote: Wed Dec 21, 2022 5:16 pm One thing I sometimes do with a Multicolour buffer is have the address of the next line of the buffer at the end of each line, so it can be read with another POP HL then LD SP,HL (instead of having the LD SP,nnnn address hard-coded in the copy routine). It then means it's easy to make the buffer wrap around top-to-bottom, for when you want to make it scroll.
Yep, it's common trick, i use it in DiceLegends Prototype.

We in the exUSSR scene joke that everything was invented in the 90's and we are reinventing everything now. We were lucky to get an extra 10 years in Spectrum development compared to your scene. The last of the tricks that make me fun was a clever and very fast way to throw data onto the screen from Ukranian coder Robus. It send byte to screen for 8.5tStates, but very fun way :)

ld sp,screen
call #8a8a
org #8a8a
call #8b8b
org #8b8b
e.t.c
User avatar
Joefish
Rick Dangerous
Posts: 2059
Joined: Tue Nov 14, 2017 10:26 am

Re: Ringo-8 64x48 GFX Lib

Post by Joefish »

DenisGrachev wrote: Thu Dec 22, 2022 3:13 amWe in the exUSSR scene joke that everything was invented in the 90's and we are reinventing everything now. We were lucky to get an extra 10 years in Spectrum development compared to your scene.
It's true, but it all went into demos, not games! What a WASTE!!!! :lol:
worcestersource
Manic Miner
Posts: 530
Joined: Thu Feb 03, 2022 11:05 pm

Re: Ringo-8 64x48 GFX Lib

Post by worcestersource »

Joefish wrote: Thu Dec 22, 2022 11:57 am It's true, but it all went into demos, not games! What a WASTE!!!! :lol:
I always used to think “wow, couldn’t they do that with games?”. To see actual games using these techniques is truly amazing and well worth the wait!
robpearmain
Drutt
Posts: 21
Joined: Thu Jun 13, 2019 11:52 pm
Location: York, UK
Contact:

Re: Ringo-8 64x48 GFX Lib

Post by robpearmain »

Fantastic
Post Reply