Skip to content

Saturn decompilation

Luciano Ciccariello edited this page Oct 12, 2024 · 1 revision

Internals

Overlays

File Name Stage
STAGE_00.PRG Final Stage: Bloodlines
STAGE_0X.PRG Entrance (1st visit)
STAGE_01.PRG Entrance (2nd visit)
STAGE_02.PRG Alchemy Laboratory
STAGE_03.PRG Marble Gallery
STAGE_04.PRG Outer Wall
STAGE_14.PRG Center / Maria Boss
STAGE_15.PRG Underground Garden / Skeleton Leader
STAGE_16.PRG Cursed Prison
BOSS_02.PRG Slogra & Gaibon
LOGO.PRG Intro copyright logo
TITLE.PRG Title screen and main menu

Memory mapping (Alucard)

Address End addr. Memory Area File name Description
06004080 ~060505df High Work Ram 0.BIN A mix of SEGA libraries and some DRA.BIN
06066000 ~0608008b High Work Ram GAME.PRG Similar to DRA.BIN
060A5000 High Work Ram ALUCARD.PRG Alucard code overlay
060CF000 ~060d5fff High Work Ram T_BAT.PRG etc. Familiar code overlay

Memory mapping (Richter/Maria)

Address End addr. Memory Area File name Description
00232000 Low Work Ram RICHTER.CHR/MARIA.CHR Secondary player sprite graphics
06004080 High Work Ram 0.BIN Entry point, Sega libraries
06060000 High Work Ram GAME.PRG Probably the equivalent of DRA.BIN
060A5000 High Work Ram RICHTER.PRG/MARIA.PRG Secondary player code overlay
060DC000 High Work Ram STAGE_XX.PRG Stage code overlay
05C1D980 VDP1 Ram RIC_W.CHR/MAR_W.CHR Secondary player sprite graphics
05C2F820 VDP1 Ram STAGE_XX.CHR Stage sprite graphics

Scratches

0.BIN

Saturn Func PSX Func Scratch Matched? Note
f_0000ae08 ratan2 https://decomp.me/scratch/889Ky

GAME.PRG

Saturn Func PSX Func Scratch Matched? Note
f_0000921C func_800FD4C0 https://decomp.me/scratch/1CORM
f_000092C0 func_800FD5BC https://decomp.me/scratch/DFpq8 Probably matching
f_00009328 func_800FD664 https://decomp.me/scratch/WEMRF
f_000152f4 Random https://decomp.me/scratch/F5nPH
f_000157b4 CheckCollision https://decomp.me/scratch/GZerS
f_0606F798 LearnSpell y
f_0606F800 func_800FDD44 y
f_0606FC60 IsRelicActive y
f_060A80E0 func_8011203C y

ALUCARD.PRG

Saturn Func PSX Func Scratch Matched? Note
f_060A7DE8 BatFormFinished y
f_060AA23C ControlBatForm y
f_060AC574 y Part of EntityAlucard

T_BAT.PRG

Saturn Func PSX Func Scratch Matched? Note
data_00000000 g_ServantDesc https://decomp.me/scratch/Eex58 Y
func_00000294 func_801713C8 https://decomp.me/scratch/FeLXE
func_000021b8 func_80173E78 https://decomp.me/scratch/kMCmY Y
func_00002224 func_80173F30 https://decomp.me/scratch/ccc2s Should be equivalent
func_060D11DC func_80173EB0 https://decomp.me/scratch/z4bWL
func_060D125C func_80173F74 https://decomp.me/scratch/nVmi2
func_0000225C func_80173F74 https://decomp.me/scratch/ha1kO
func_000022AC func_80173FE8 https://decomp.me/scratch/vOfP4 Y

STAGE_02.PRG (Alchemy Lab)

Saturn Func PSX Func Scratch Matched? Note
func_060EAFAC EntityBloodyZombie https://decomp.me/scratch/ZvlTe

Compiler patterns

Function return values

If you have an issue like this with jsr @r1 vs jsr @r0, your function prototype generally needs to return void to get r1, and non-void to get r0.

void DestroyEntity(Entity*);

  10:    mov.l   50 ,r1           
  12:    jsr     @r1
s32 DestroyEntity(Entity*);

r 10:    mov.l   50 ,r0         
r 12:    jsr     @r0

Equivalent code that produces different asm

The following two functions produce different asm. https://decomp.me/scratch/oNzR9

bool func_06013320(void) {
    if (DAT_060644C0 == 2) {
        return 1;
    }
    return 0;
}

bool func_06013320(void) { return DAT_060644C0 == 2; }

Ghidra output patterns:

Struct pointer dereference:

*(undefined *)(param_1 + 0x11) = 10;
param_1->unk11 = 10;

Graphics Info

Tile graphics are loaded by func_6008588. NOPing this out shows that the tilemap is present but the graphics aren't:

image

WIP https://decomp.me/scratch/TXaHJ

Part of the Richter sprite graphics are loaded by func_600A490. I think there's two banks loaded to different RAM areas. NOPing this out removes one of the banks.

image

Tile maps and collision data seem to be loaded by func_606C774. NOPing this out gives the following showing that the tile graphics are loaded but the map is messed up.

image

These functions all call func_0600f96C which is responsible for writing to an area of Low WRAM around ~26a750.

This area gets read by instructions at 0x60088BC (func_0600871C) or 0x60099fe (func_060098F0) or 0x6009bee (func_06009AE8). which transfers it to a buffer starting at high WRAM 0x0605C120.

NOPing out func_060098F0 prevents part of the transfer to high WRAM and you get this:

image

NOPing out func_06009AE8 gets this:

image

Then 0x0605C120 is processed and transferred to VDP2 Ram by func_60098F0. The instruction that does the write is at 0x6009a04.