Emiliano Fierro wrote: ↑June 19th, 2020, 6:25 pm
In some of my mods I found an interesting bug which I would like to fix because it's not comfortable pressing so many keys
If you put many loose floors on other loose floors or by triggering many loose floors, appears a message which says
Mobs Overflow
Press any Key to Continue
This error appears because PoP1 can handle only 14 falling loose floors at the same time.
In SDLPoP, we could change the numbers here:
https://github.com/NagyD/SDLPoP/blob/ma ... ata.h#L489 (array declaration)
https://github.com/NagyD/SDLPoP/blob/ma ... 007.c#L952 (overflow check)
In the original PoP, it's not this simple to change the limits.
If you just change the number in the overflow check, then the game will just overwrite whatever memory is after the Mobs table.
Some loose floors even disappear, because some of those memory areas are regularly zeroed. (They are used to mark tiles for redraw.)
So we need to find some unused area where we can put a bigger Mobs table.
The size of the WipeTable is 2100 bytes. (300 elements, of 7 bytes each.)
Palace walls use 7 elements per tile, so a room full of walls (see level 10) uses 30*7=210 elements.
This means we can use the rest, 2100-(210*7) = 630 bytes for the Mobs table.
The Mobs table uses 6 bytes per element, so we have space for 630/6 = 105 elements here. That's much more than 14!
First, reduce number in the WipeTable check to 210 = 0x00D2.
Search: A1 AE 42 89 46 FE 3D 2C 01
Change: 2C 01 to D2 00 (offset: 0xC732)
Then move the Mobs table from 0x4BB4 to its new place.
WipeTable is at 0x34D2.
The shortened WipeTable ends at: 0x34D2 + 0xD2 * 7 = 0x3A90.
Search: 05 B4 4B 50
Change: B4 4B to 90 3A
There are 8 occurrences. You need to replace all of them! (offsets: 0xAE35, 0xAE81, 0xAEA8, 0xAEDF, 0xAEEE, 0xB0F6, 0xB117, 0xB1C3)
The game also uses the offset 0x4BB4 + 3 = 0x4BB7.
We change it to: 0x3A90 + 3 = 0x3A93
Search: 80 BC B7 4B FF
Change: B7 4B to 93 3A (offset: 0xAED3)
Then increase the number in the Mobs check to 100 = 0x64.
Search: 83 3E 8C 40 0E 7C 09
Change: 0E to 64 (offset: 0xAE14)
That's all, now it should be possible to have more loose floors falling at the same time.