SPI RAM games

Use this forum to share and discuss Uzebox games and demos.
Post Reply
User avatar
danboid
Posts: 1937
Joined: Sun Jun 14, 2020 12:14 am

SPI RAM games

Post by danboid »

Have any games been written that require and use SPI RAM yet? Which ones?
User avatar
Jubatian
Posts: 1563
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: SPI RAM games

Post by Jubatian »

Nothing I am aware of. I made a specialized kernel though, here, with some demos, but then I didn't continue that effort, last thing I tried was optimizing the sprite blitter further.
User avatar
danboid
Posts: 1937
Joined: Sun Jun 14, 2020 12:14 am

Re: SPI RAM games

Post by danboid »

Thank Jubatien!

Sounds like there's not much need for SPI support in cuzebox yet then.

Am I right in thinking Uzenet adds about 128K SPI RAM? Considering this is up from 4K, I thought 128K might've made higher display resolutions possible but I have no idea how anything works yet.

On a regular UB, how much RAM does the user have available after its booted the kernel?
User avatar
Jubatian
Posts: 1563
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: SPI RAM games

Post by Jubatian »

CUzeBox supports the SPI RAM! So you can try all the demos with it to see what they look like! :)

The difficulty is that SPI RAM is SPI. You can get one byte from it in 18 cycles at best. One scanline is 1820 cycles, which translates to at most 101 bytes fetched. The SPI RAM kernel's various demos exploit the absolute highest memory usage possible for generating graphics on an SPI RAM Uzebox! That is, the theoretical maximum is 101 bytes per line from SPI RAM, and, aiming for 224 lines, you might be able to afford to throw 16 bytes of ATmega SRAM in addition to this for each scanline.

The 232 pixels wide image displays in that kernel do exactly that, fetching 100 bytes off of SPI RAM each scanline, supplementing it with 16 bytes of RAM data. So 116 bytes, multiply that by 2 for 4bpp (each byte has two pixels), and you get 232. It is hardly possible to do anything more.

A similar technique to the SPI RAM is what CunningFellow does in Tempest, with the SD Card streaming. The core concept is the same, just with the SPI RAM, it is substantially easier as it is deterministic and reliable, unlike the card with such usage.

With the normal kernel, it depends entirely on what you are doing with it. Use an inline mixer (saves more than 500 bytes). The video modes take away memory for their tile map, and then more for the sprites, each tile block covered by a sprite having to use RAM. With Mode 3 (8bpp), this is 64 bytes per tile you use for this purpose. There are other video modes which are less greedy in this regard.
User avatar
nicksen782
Posts: 714
Joined: Wed Feb 01, 2012 8:23 pm
Location: Detroit, United States
Contact:

Re: SPI RAM games

Post by nicksen782 »

I've used SPIRAM on some of my games/demos. The thing with the AVR is that instructions can only be run from FLASH, and not RAM. (I'm not exactly sure how code tiles work but it mixes instructions into the tile data somehow.)

But, you can DRAW a ramtile and you can certainly fill in a ramtile with whatever data you want (does not need to actually be graphics.) There is a function that you can run that sets the starting ramtile index (other than 0) so you can reserve ramtiles for your own uses.

Once your graphical tile is in a ramtile you can do whatever you want with it. For example, I have some animated flowers that are completely sourced by SPIRAM and ramtiles. http://nicksen782.net/r_uzerpg.php then click on the Milestone v1 link. The flower animations are two screens down. If you go into the Tavern & Inn ALL the characters are sourced this way too. The X-flipping is done in RAM. Click the (F3) DEBUG button and you can see the work on the ram part, especially on the flowers. A TON of work had to be done to get the data into a format that would work. Check out Dialog Test 1 (mp4) and
RamTile Map Animations 1 (mp4) while you are at it. To do the chat dialog I would copy the data structures from ram into SPIRAM and then replace the RAM with the chat stuff. Then, when the dialog is over I swap it all back. Think page file or swap file. Uzebox has limited ram but there are ways to use it better.
Post Reply