Hello guys. Here is the research i've done in about 1 hour about the shoal cave, an aspect of the game that i find curious.
And so, i've decided to research it.
Games: Pokemon Emerald (U)
(I'll research this in ruby later)
So, the original map is (24,46), and i started by checking the level scripts to see how the map changed according to the tidals.
There i found the level script 03 0x236DC0, which is this one:
x
'--------------- #org 0x236DC0 special 0xD5 checkflag 0x89A if 0x1 goto 0x8236DD1 goto 0x8236DD5 '--------------- #org 0x236DD1 setmapfooter 0xA8 end '--------------- #org 0x236DD5 setmapfooter 0xA4 end
So,we can actually see what's happening: a special is called (0xD5), and a flag is checked, to see whether it loads the flooded map (mapfooter 0xA8, (24,46)) or the normal map (mapfooter 0xA4 (24,50))!
Pretty neat, uh? We can use this flag for events that can only happen in certain periods of the day.
Ok. So the only clue we have for the map change is that flag. Well, due to the fact i'm very curious, (xD) i suspect that that special has something to do with the map change and the flag too. Lets decompile it!! ;D
08137988 @ =============== S U B R O U T I N E =======================================
08137988 08137988 08137988 spD5_Control_ShoalCave: @ DATA XREF: ROM:special_table.o 08137988 PUSH {LR} 0813798A BL get_last_map_type @ This function retrieves the map type of where we were in! 0813798E LSLS R0, R0, #0x18 08137990 LSRS R0, R0, #0x18 08137992 BL check_overworld_map @ And this one checks if it was a Overworld map (includes underwater) 08137996 LSLS R0, R0, #0x18 08137998 CMP R0, #0 @ If it was a cave, secret base or a house 0813799A BEQ end @ then end the function here! 0813799C BL time_update 081379A0 LDR R1, =0x085B2B44 081379A2 LDR R0, =0x03005CF8 081379A4 LDRB R0, [R0,#Internal_Clock_RTC.hours] 081379A6 LSLS R0, R0, #0x18 081379A8 ASRS R0, R0, #0x18 081379AA ADDS R0, R0, R1 081379AC LDRB R0, [R0] 081379AE CMP R0, #0 081379B0 BEQ low_tidal 081379B2 LDR R0, =0x89A @ If we got a high tide 081379B4 BL flag_set @ then set set flag 0x89A 081379B8 B end 081379B8 @ --------------------------------------------------------------------------- 081379BA .byte 0 081379BB .byte 0 081379BC off_081379BC: .long shoal_cave_tidal_hours 081379BC @ DATA XREF: spD5_Control_ShoalCave+18.r 081379C0 off_081379C0: .long Internal_Clock_Data_HEX 081379C0 @ DATA XREF: spD5_Control_ShoalCave+1A.r 081379C4 dword_081379C4: .long 0x89A @ DATA XREF: spD5_Control_ShoalCave+2A.r 081379C8 @ --------------------------------------------------------------------------- 081379C8 081379C8 low_tidal: @ CODE XREF: spD5_Control_ShoalCave+28.j 081379C8 LDR R0, =0x89A @ If we got a low tide 081379CA BL flag_clear @ then clear flag 0x89A 081379CE 081379CE end: @ CODE XREF: spD5_Control_ShoalCave+12.j 081379CE @ spD5_Control_ShoalCave+30.j 081379CE POP {R0} 081379D0 BX R0 081379D0 @ End of function spD5_Control_ShoalCave 081379D0 081379D0 @ --------------------------------------------------------------------------- 081379D2 .byte 0 081379D3 .byte 0 081379D4 dword_081379D4: .long 0x89A @ DATA XREF: spD5_Control_ShoalCave:low_tidal.r
AH! There, you see it? I knew that the special 0xD5 was the one behind all the scenes! As you can see, when the tide is low, the flag is cleared, as
The comments should be self explanatory. The red offset is a table that dictates at which hours the tide is high, leaving the map flooded. The structure of that table is 24 bytes (24 hours), and if a certain hour byte is 1, we got a high tide.
The pink offset is where the clock RTC are stored. 2 bytes from that offset is hours.
Here's the table of tides by hours:
(Credits to Bulbapedia, even thou this can be easily discovered by analyzing the table i mentioned before in the rom).