OK, here is how I managed to free up a considerable amount of bytes
– by using what I want to call a bypass technique. Here is how it works:
I needed quite a lot of bytes in whatever ROM bank was swapped in when you are in the Inventory screen.
This happens to be ROM bank 09, which, as it turns out, is also swapped in when you are in Phthia or Phrygia.
When scanning for free bytes in this bank, I found this section of repetitive bytes.
First I assumed them to be ‘junk’ bytes and just blanked them out with zeros.
When I then played through the game – it crashed in a very specific spot.
The way that backgrounds are stored in the game is like stripes/columns of tiles.
These stripes are compressed (by each tile not using all bits in byte) and the background is made up by tables of pointers to these stripes.
That is what I had stumbled upon – it was just a very repetitive section of the background.
If you look at the picture above, you'll see that the flowerbed is made up of two unique tile-stripes that keeps alternating.
Here are the steps that I took to implement the bypass technique:
- HiJack the routine that loads the background tile-stripes and call your own sub-routine.
The sub-routine MUST be located in a ROM bank that is ALWAYS available and checks if ROM bank 09 is swapped in (I found a RAM-flag for that). If ROM bank 09 is swapped in – it calls the bypassing routine – which I placed in ROM bank 09 (where the background tile-stripe pointers where).
- The bypassing routine checks if the pointer address is within the range of the section of pointers and then calculates the value – instead of reading it from the ROM bank. This can be achieved in far less bytes than the amount taken by the pointer-table, thus freeing up a lot of bytes to be used for something else.
I also found two additional locations I could bypass. There are two identical sections, when travelling at sea, that also just alternates between two unique tile-stripes.
In conclusion, I had lots of space for custom ASM but I needed something else as well…
To do anything visual – you need tiles. Preferably tiles already loaded and ready to use.
After some debugging, I found that I could load up additional unused tiles by simply adjusting the AMOUNT of tiles to load/unload when bringing up the Inventory screen.
So, what to do with all the space and tiles available?
Why not add a dungeon-map!
This is a staple of the series that I was really missing in Zelda 2.
If you played Battle of Olympus, you know that this game is more un-linear than Zelda games.
There are no proper ‘dungeons’ and ‘bosses’ can appear anywhere within a section.
The section that comes the closest to being a dungeon is the island Crete and here is why:
- Most of the section takes place inside a maze-like pyramid.
- There are a lot of different rooms that ties together through doorways.
- The section has only ONE boss that guards an important item.
- There are additional items (treasure) to find within the section.
Also, the entire section is REALLY hard to navigate and most of the time you are just wandering around taking guesses which doorway to try next.
Well, not anymore:
I have made some minor adjustments to the layout (which was only possible to do in the first place AFTER I had the map implemented).
As you can see, it will show your current location and where all the items/fairies and the boss is located.
I might make these features require you finding certain items first (like the compass in the original Zelda) but for now the map function is complete right at the start.
So there you go – a dungeon map available from the Inventory screen.
As for the easter-egg....that's for another time (when it's finished