Castlevania II - Belmont's Revenge:ROM map

From Data Crystal
Revision as of 20:05, 5 September 2022 by NaOH (talk | contribs)
Jump to navigation Jump to search

Format for PRG-ROM is Bank:RAM address.

(r:symbol) marks the start of a callable subroutine. (RSTxy:symbol) marks a callable subroutine which can be called with the special quick-access RST commands.

X:7FFF all swappable banks store list their bank number as the last byte of the bank.
0:0000 (RST00:jumptable_entity_state) jumptable (indirect jump by entry in table following call to RST00 according to current entity's state variable)
0:0003 (r:jumptable) jumptable by A.
0:0010 (RST10:entity_set_image) sets entity's image (see "Images" section below)
0:0018 (RST18:entity_set_timer) sets entity property $08 to A. This seems to be the entity's timer, such as how long until fire despawns or belmont's hitstun.
0:0030 (RST30:entity_inc_state) increments the state variable (D:01) of the current entity.
0:0038 (RST38:entity_get_y) get Y position of current entity.
0:01D9 (r:longcall_2_438D) stores current bank (read from $7FFF) on stack, calls routine 2:438D, then returns to caller bank.
0:0D23 (r:entity_set_state_and_substate) entity state <- b, substate (attacking) <- c
0:2AC7 (r:wait_for_blank) Seems to wait to the end of the current blanking period (if applicable) and then to the start of the next.
0:297B (r:leftshift_bc_4) leftshifts bc by 4.
0:2986 (r:lda_00) a <- $00
0:2989 (r:lda_06) a <- $06
0:298C (r:lda_7F) a <- $7F
0:298F (r:lda_06) a <- $80
0:35A9 (r:mbc_bankswap_1) loads swappable bank 1.
0:35AA (r:mbc_bankswap) loads swappable bank from cpu register a.
0:35AF (r:mbc_bankswap_2) loads swappable bank 2.
0:35B5 (r:mbc_bankswap_6) loads swappable bank 6.
0:35BB (r:mbc_bankswap_7) loads swappable bank 7.
0:35C1 (r:mbc_bankswap_3) loads swappable bank 3.
0:38E0 (r:entity_set_animation) Set animation (prop 0C,0B,0A) to (bc):0:(bc+1) (bc):0:(bc+1)
0:3DAC (r:entity_set_x_velocity_0) Entity x velocity <- 00.
0:3DAF (r:entity_set_x_velocity) Entity x velocity <- cb.
0:3DB4 (r:entity_set_y_velocity_0) Entity y velocity <- 00.
0:3DB7 (r:entity_set_y_velocity) Entity y velocity <- cb.
0:3DBA (r:write_word) (hl) <- cb
0:3DBE (r:entity_get_x_velocity) cb <- Entity x velocity.
0:3DC5 (r:entity_get_y_velocity) cb <- Entity x velocity.
0:3DC8 (r:read_word) cb <- (hl)
6:421D (r:entity_update) Belmont frame update routine. Called from 0:05FA.
6:4235-4241 Belmont update jumptable
6:427F Belmont state 0 (standing) routine
6:4289 Belmont state 2 (crouching) routine
6:42E9 Belmont state 1 (walking) routine
6:4293 Belmont state 3 (jumping) routine
6:42A1 Belmont state 4 (??) routine
6:44A6 Belmont state 5 (??) routine
6:44D2 Belmont state 6 (??) routine
6:4510 Belmont state 7 (??) routine
6:461B (r:input_A_pressed) A gets zero or 10 depending on if the A button was pressed this frame. Status flags set
6:4621 (r:input_up_down_held) A and status flags
6:4627 (r:input_left_right_held) A and status flags
6:462D (r:input_B_pressed) A and status flags
6:4633 (r:input_B_held) A and status flags
6:4639 (r:input_down_held) A and status flags
6:464B (r:input_up_held) A and status flags
6:4651 (r:input_any_held) A and status flags
6:4801 (r:belmont_set_walk) Read left/right input and set Belmont to be walking left or right accordingly.
6:4817 (r:entity_move_face_right) Entity moves and faces right at velocity  0x90
6:4817 (r:entity_move_face_left)  Entity moves and faces left at velocity -0x90

Bank swap routines:

- All are in bank 0, and all write to $2180 to change the bank. For some reason, bank 5 is always swapped inline rather than by function call.

Images - Entities' images are stored in property 0A. Editing this value will change the entity's image -- for example, the axe might appear as a torch, at least until the axe's animation restores the image to the next frame of axe animation. Below is a partially-complete table of images (Please contribute!).

0: Torch (frame 0)
1: Torch (frame 1)
2: Coin (frame 0)
3: Coin (frame 1)
4: Score Orb
5: Small heart
6: Large Heart
7: Wall meat
08: fire (frame 0)
09: fire (frame 1)
0A: 1-up
0B: holy water (icon)
0C: holy water (projectile)
0D-10: Axe/Cross (frames 0-3)
11-23: Belmont poses
24-29: whip

and so on.