doomhack / GBADoom

A port of prBoom to the Nintendo GBA.
182 stars 25 forks source link

Idea: Optimization Sidedef / Sectors Lump - Texture entries #26

Open sttng opened 2 years ago

sttng commented 2 years ago

Looking at the Sidedefs and Sectors format

Sidedef

x offset y offset Upper Texture Lower Texture Middle Texture Sector
32 0 GRAY1 GRAY1 - 7

Sectors

Floor Height Ceiling Height Floor Texture Ceiling Texture Light Level Special Tag
0 128 FLAT19 F_SKY1 144 8 0

Idea: Change Texture Name entry to Index (int16_t) similar to Doom 64 format.

This would need to be 1st implemented within GbaWadUtil. I guess a hashtable that keeps track of Texturenames already seen and replacing it with an int counter as necessary would work.

This could save a couple of bytes in cart/rom space. Not sure if there would be performance hits in the game to look-up

Also not sure if it'll be better to create an new look-up table for Texture-Index -> Name or directly modify the Map textures structure (name entry).

RetroGamer02 commented 2 years ago

I can tell you that packing Sidedefs helped me a lot in GBAFreeDoom to save on ram. The idea of building Optimization for it right into GbaWadUtil would be sweet.

doomhack commented 2 years ago

W_CacheLumpXXX returns a const* to the location in ROM.

On the GBA, the mapsector_t isn't loaded into ram.

The main memory usage on Plutonia Map 28 (Highest ram in Doom/2/Final Doom)

sector_t 17,836 side_t 44,416 linedata_t 20,168 _g->blocklinks 15,640 subsector_t 13,104 line_t 14,328 mobj_t 74,172

sttng commented 2 years ago

You could save ROM space with the suggestion I guess. As far as I can see:

Plutonia Map 28 (original <- not 'touched' with GBAWadUtil) SIDEDEFS: 108.40KB SECTORS: 7.54KB

Plutonia Map 28 (Texture Indices) SIDEDEFS: 43.36KB (60% smaller) SECTORS: 6.39KB (15% smaller)