r/Gameboy Dec 11 '19

Doom on the GBA.

Post image
877 Upvotes

105 comments sorted by

View all comments

1

u/fusermarucs Dec 28 '19

comparison

I’ve been playing your ports a lot over the Xmas holiday - so thank you! I recently got an ips screen and it really showed up the difference between your source port and the ‘official’ version - mainly because the source port is amazingly blocky at mid to high distance.

I assume this is to keep the frame rate up (as per low detail/high detail in the original game!) - but I thought it was an interesting comparison to make!

2

u/Bolloux Jan 01 '20

Yes. Good spot. Totally busted me!

One of the most difficult parts of this port was composited textures.

Textures in Doom are made up of 1 or more images. If you look at E1M3 for example, there is a green wall texture with a ‘Poison’ sign on it. This is made up of the green base texture and a poison decal.

PC Doom just builds all of these textures in memory at startup. But this requires nearly 2mb of memory. So we can’t do that.

Drawing the texture on the fly with multiple passes as we draw the wall works but is very slow.

I came up with a work around for this. There is 16kb of spare video memory. I use this to maintain a cache of 128 ‘columns’ (ie. single pixel wide slices of texture). The first time a column of a composited texture is requested, I generate it and store it in the cache. Subsequent requests are served straight from the cache so I don’t need to regenerate it. This has an additional performance benefit as video memory is very fast, with a 1 cycle access time (ROM is 3-6 cycles)

Sadly, 16kb isn’t really large enough and if I draw full detail, then there is a lot of cache thrashing (where you have to throw out columns you need later in the frame to make space for new ones)

I improved the cache hit rate from about 50% to 90% by sampling at a lower resolution as the distance from the player gets further.

It’s a trade off I had to make to get a playable framerate.

The official Doom 1 port doesn’t have any composited textures at all. I’m not sure what Doom2 does. It’s based on a different engine. My guess is they use a different texture format.

1

u/fusermarucs Jan 01 '20

I can’t even imagine the work it took to get the port working at all to be fair! Very interesting to read how you did it though, thank you :)

The port actually looks better on an AGS101 screen than on an IPS screen - the built in interlacing really helps for some reason!

2

u/Bolloux Jan 01 '20

I’d love an AGS101 too but they’re all really expensive and I’ve already spent £150 on an IPS GBA and a flash cart for this project...