; Dream: Land of Giants (SNES prototype) curated labels. Format:
;   <24-bit addr> <name>      code entry (traced as a subroutine)
;   data <addr> <name>        data label only
;   ram <addr> <name>         WRAM / direct page variable
; Addresses are HiROM ($C0:0000 = file offset 0). Bank $00/$80 mirrors of the
; high half resolve to the same file offset.

; ---- entry points (from the vector table at file 0xFFE4) ----
C08000 reset                  ; native RESET: clears WRAM, inits sound, jumps to main loop
C0A4D1 nmi                    ; NMI: saves regs, reads RDNMI, then jmp ($0000) -> handler pointer in RAM
C0A442 unused_vec             ; COP/BRK/ABORT/IRQ vectors all point here
data C00000 stale_build_image     ; low half of bank $C0: older build leftover, calls into live code at off-by-one addresses (e.g. $ABCB)

; ---- sound (bank $C1 high half = $81:8000) ----
C18000 spc_init               ; jsl target: IPL handshake, upload loader + driver from $C2:0000
C1805A spc_ipl_upload_loader  ; uploads 0x88 bytes from $C2:0000 to SPC $04D8 via IPL protocol
C1809F spc_upload_driver      ; src ptr $04/$06 = $C2:0088, streams blocks via custom loader
C1830A upload_inline_spc_block ; block header at [$04]: word dest, word count, then words (name: p4plus2 DKC2 bank_B5)
C18324 upload_spc_block        ; (name: p4plus2 DKC2 bank_B5)
C183CE spc_command            ; jsl target, A = command (0 at boot, 1/2 from reset)

; ---- core ----
C0A385 ppu_init               ; writes most $21xx regs, NMITIMEN, clears OAM/VRAM
C0A2DE read_joypads           ; JOYSER0/1 + JOY1..4
C0A4A8 set_bg_scroll          ; writes BGxHOFS/VOFS, returns with M=16
C0A500 clear_sprite_table     ; zeroes $0400..$041E, $94=$0200
; C08152 (was wait_and_enable_nmi) lands mid-instruction inside nmi_handler_gameplay; not a routine
; C08BDB is not a routine: it is the fall-through second half of mode0_camera_zone_update (see recomp/src/top_level.c)
data C0826A game_mode_table        ; jsr (table,X) with X = game_mode*2

; C0814C (was alt_mode_table) mid-instruction inside nmi_handler_gameplay; stale-image artefact
data C20000 spc_loader_image  ; 0x88-byte SPC700 loader uploaded by IPL
data C20088 spc_driver_blocks ; block list uploaded by spc_upload_driver

; ---- RAM ----
ram 0000 nmi_handler_ptr      ; 16-bit pointer used by nmi: jmp ($0000)
ram 0004 ptr_04               ; generic 24-bit pointer ($04/$06): SPC upload source, handler dispatch via jmp ($0004), data reads
ram 0007 spc_dest_addr
ram 0009 spc_word_count
ram 0034 nmitimen_shadow
ram 0046 spc_port0_counter
ram 0094 oam_write_ptr         ; live pointer into oam_buffer ($0200), not a count (see docs/dkc_crossref.md 4.3)
ram 009C init_magic_AA55
ram 009E init_magic_FFFF
ram 00A4 game_mode            ; index into game_mode_table
; ram 00B5 (stale image only)

; ---- from out/handler_tables.md (RAM-dispatched handlers) ----
; ---- $B66A velocity -> animation-rate handlers (jmp ($0004) at $99B6; entry DB=$80, A=|vel|, X=entity) ----
data C0B66A anim_rate_fn_table
data C0B6DC entity_state_velocity_table
data C0B7AE entity_state_anim_table
data C0B652 facing_flag_table
data C0B654 facing_state_bits_table
C099B9 anim_rate_3_16 m0x0
C099BA anim_rate_3_8 m0x0
C099D1 anim_rate_1_8 m0x0
C099D2 anim_rate_1_4 m0x0
C099D4 anim_rate_store
; unreferenced variants in the same run (optional)
C099C4 anim_rate_3_32 m0x0
C099D0 anim_rate_1_16 m0x0
C099D3 anim_rate_1_2 m0x0

; ---- $B022 animation-script callbacks (pointers in bank $C4 scripts; entry X=entity, Y=record) ----
data C41858 anim_script_table
C0AEC8 anim_update
data C0B022 anim_callback_dispatch
C0B0C5 play_sound_effect
C0B171 entity_hit_react
C0B1B1 set_entity_state
C0B025 anim_cb_sfx_0704 m0x0
C0B052 anim_cb_sfx_0506 m0x0
C0B057 anim_cb_sfx_0606 m0x0
C0B05C anim_cb_sfx_0602 m0x0
C0B061 anim_cb_sfx_0507 m0x0
C0B066 anim_cb_sfx_050C m0x0
C0B06B anim_cb_sfx_0508 m0x0
C0B070 anim_cb_sfx_0709 m0x0
C0B08F anim_cb_sfx_060E m0x0
C0B0CE anim_cb_hit_player m0x0
C0B0FE anim_cb_hit_enemies m0x0
C0B1AE anim_cb_reset_state m0x0
; unreferenced fragment (optional)
C0B1FE entity_clear_anim_unused m0x0

; ---- adopted from p4plus2's DKC2-disassembly bank_B5.asm (byte-identical sound interface; see docs/dkc_crossref.md) ----
C180C1 upload_global_samples
C180FF write_spc_command       ; X = packed param:cmd word
C18119 upload_song_data        ; A = song number
C1813D upload_song_sound_effects ; A = song number
C18392 upload_song_sample_set  ; A = song number
C1803E execute_spc_sound_engine
data C1804C unused_spc_execute ; dead twin of execute_spc_sound_engine (present in DKC2 and KI too)
; ---- RAM adopted from Yoshifanatic1's DKC2 RAM map, justified by the shared clear_sprite_table ----
ram 0200 oam_buffer            ; 128 x 4-byte sprite entries
ram 0400 oam_buffer_upper      ; high OAM table

; ---- from docs/naming_proposals.md (high + medium confidence; behaviour-derived) ----
; ---- game-mode init (docs/naming_proposals.md section 1) ----
C08292 mode0_level_init
C0848C dma_setup_channel_step
C084D7 mode1_level_init
C08798 mode2_level_init
C088AB title_screen_init
C0A4A6 set_bg_scroll_prep
C09234 vram_upload_shared_tileset_c5

; ---- NMI handlers + per-mode scroll (section 2) ----
C080F4 nmi_handler_gameplay
C0BD20 nmi_handler_title_fade
C08E9B nmi_scroll_mode0
C08F47 nmi_scroll_mode1
C09049 nmi_scroll_mode2
C090FA nmi_scroll_title

; ---- PPU/VRAM/OAM DMA helpers (section 3) ----
C0A445 dma_fill_vram_zero
C0A46A dma_upload_to_vram
C0A483 dma_upload_to_cgram
C09FB7 build_metatile_column_580
C09E83 build_metatile_column_500
C0A0F1 vram_upload_column_580
C0A148 vram_upload_column_500
C0A538 entity_build_oam_frame
C09C16 vram_generate_particle_tile
C09C28 vram_write_tile_row_planes
C09C62 vram_stream_descriptor_dispatch
C0A757 oam_emit_frame_1row
C0A772 oam_emit_frame_2row
C0A8F6 oam_emit_frame_1row_flip
C0A911 oam_emit_frame_2row_flip
C0AAAA oam_emit_frame_3row
C0AC40 oam_emit_frame_3row_flip
C0ADE7 oam_hide_unused_sprites
C0ADFD oam_dma_upload
C0AE7E entity_upload_pending_tiles
C0AE1F entity_sort_draw_order
C0AEB9 entity_render_order_reset
C09D32 cgram_upload_queue_flush

; ---- entity update / AI dispatch (section 4) ----
C09AF6 entity_animate_only m0x0
C09A61 entity_apply_hit_reaction m0x0
C09AB8 entity_spawn_transform_a m0x0
C09B00 entity_spawn_transform_b m0x0
C09B89 entity_spawn_transform_c m0x0
C099EF entity_ai_chase_player m0x0
C09A5F entity_ai_none m0x0
C098DA entity_update_tick
C0A232 entity_accelerate_velocity_x
C0A26F entity_apply_velocity_x
C0A2B9 entity_apply_velocity_y
C09BDA entity_ground_y_lookup
C08E8E check_pending_player_attack
C0A1B0 camera_follow_player
C0A212 random_next
C09D6A entity_init_from_table

; ---- particle/weather subsystem (section 5) ----
C09246 particle_table_clear
C09253 particle_spawn_mode0_weather
C092F3 mode1_reset_particles_and_oam
C09331 particle_update_and_draw_mode0
C09227 mode0_particle_draw_dispatch
C094E4 sparkle_array_init
C09521 sparkle_update_and_draw
C0922A mode1_particle_dispatch
C09230 mode2_particle_dispatch
C09233 particle_dispatch_noop
C095E3 particle_spawn_from_table
C09781 particle_spawn_random
C0B075 play_footstep_sound
C0B0BC play_zone_transition_sound

; ---- sound interface (section 6) ----
C1815F sample_uploader
C18415 sfx_command_dispatch

; ---- RAM (section 7 entity fields + section 8 DP scratch) ----
ram 0708 entity_type
ram 0728 entity_state
ram 0768 entity_hitstun_timer
ram 0788 entity_flags
ram 07C8 entity_frame_id
ram 0828 entity_x
ram 0848 entity_x_sub
ram 0868 entity_vel_x
ram 0888 entity_vel_x_target
ram 08A8 entity_y
ram 08C8 entity_y_sub
ram 0948 entity_vel_y
ram 0968 entity_parent_index
ram 0988 entity_depth_key
ram 09A8 entity_render_order
ram 09E8 entity_anim_id
ram 0A68 entity_anim_rate
ram 0062 camera_x
ram 0068 camera_y
ram 0002 dma_pending_mask
ram 0096 entity_render_index
ram 004C entity_screen_x
ram 004E entity_screen_y
ram 0026 sprite_frame_ptr
ram 0028 sprite_frame_bank
ram 002A sprite_frame_ptr2
ram 002C sprite_frame_bank2
ram 0054 oam_entry_ptr
ram 007A tilemap_a_addr
ram 007C tilemap_a_bank
ram 007E tilemap_b_addr
ram 0080 metatile_data_bank
ram 0086 level_width_mask
ram 0088 level_height_mask
ram 0098 layer_parallax_mode
ram 009A camera_y_lookahead
ram 0070 walk_cycle_timer
ram 0072 walk_cycle_parity
; ---- from the mode-init recomp batch (behaviour read from the C transcription) ----
C08A74 mode0_camera_zone_update   ; per-frame mode-0 arm: 180-frame effect cycle, camera_x zone ladder selecting HDMA layer masks
C091BB cgram_palette_ramp_step    ; steps $0C1D by $80 toward the sign of $0C1B and queues a 32-colour CGRAM record from $C4:7103

; ---- remaining auto-named routines, named from behaviour (out/dream.asm) ----
; dead: reads data_C0B208,X as if it were a jump-table entry and dispatches via jmp ($0004);
; the B208 table has since been repurposed as the VRAM streaming-descriptor array (non-code),
; so this path is unreachable garbage; see NOTES.md "Open items" #1 (dream.asm:2093-2100).
C09206 unused_stream_desc_dispatch
; entity_update_tick's airborne branch (jsr at C0994B): negates entity_vel_x, arithmetic-shifts
; it right by 2 (cmp #$8000/ror x2, a sign-preserving /4), then re-negates unless $0BAE==0 (the
; ground_y_lookup_threshold sentinel), and stores the result to entity_vel_y (dream.asm:4210-4211).
C0A1F3 entity_vel_y_from_vel_x
; dead twin of entity_apply_velocity_x/_y: same sub-pixel-accumulate-then-integer-add pattern,
; but on the fields at $0928 (vel)/$0908 (sub)/$08E8 (pos): a third per-entity axis that
; entity_init_from_table clears/seeds (data_C0B4AE) but no live code ever advances via velocity;
; unreferenced (dream.asm:4316-4315).
C0A294 unused_entity_apply_velocity_z
; unreferenced duplicate of reset's WRAM-clear sequence (DP $0000-$01FE via tcd, $0200-$1FFE,
; then WRAM bank $7E $2000-$FFFE); never called (dream.asm:4424-4384).
C0A35C unused_wram_clear_full

; ---- sound_iface: remaining auto-named/undissected bytes ----
; dead duplicate of spc_command's tail: sends SPC command $F9 (cmd1_set_E7, spc/driver.asm) then
; $FE (play), skipping the upload steps spc_command does first; unreferenced (dream.asm:7607-7614).
C183F1 unused_spc_set_e7_and_play
; raw bytes right after orphan_C183F1/unused_spc_set_e7_and_play, byte-identical to it except
; command $FB instead of $F9 (cmd3_fade_and_song): a second dead sibling, left undecoded by
; the tracer's orphan sweep because the gap (18 bytes) is under its min_gap=24 floor. Forced
; here as its own routine since the bytes are valid, unreferenced 65816 (dream.asm:7616-7618).
C18403 unused_spc_set_fb_and_play m0x0

; ---- data tables inside the code/sound_iface regions (named so progress.py counts them) ----
; three overlapping DMA-source windows (len 0x10/0x20/0x30 from offsets 84A2/84A9/84B0) copied
; by mode0_level_init via dma_setup_channel_step before its main HDMA setup; byte-shaped like
; the {tag=$48,ptr16} triples used elsewhere for indirect HDMA (dream.asm:465-489).
data C084A2 mode0_init_dma_curve_table
; symmetric 17-entry triangle wave (0,0,0,0,1,1,2,2,3,3,3,3,2,2,1,1,0 as words), read indexed
; from two call sites (dream.asm:1810, 2516); amplitude ramp for a periodic screen effect.
data C084B5 camera_shake_ramp_table
; single byte written to CGDATA right after CGADD=$E1 in mode1_level_init (dream.asm:8780-8784).
data C08791 mode1_flash_cgram_lo
; second CGDATA byte for the same $E1 write, plus 5 trailing unreferenced bytes (dream.asm:8787-8792).
data C08792 mode1_flash_cgram_hi
; {$03,$0C,$30,$C0}: the four 2-bit-field masks isolating one sprite's slot within an OAM
; high-table byte (4 sprites/byte); indexed by sprite-slot & 3 (dream.asm:4879-4880, 4934).
data C0A6D3 oam_size_bit_mask_table
; 128-entry precomputed OAM high-table byte, indexed by a shifted frame-width value and ORed
; into oam_entry_ptr (dream.asm:4882, 5051).
data C0A6D7 oam_size_preset_table
; VRAM streaming-descriptor record array read by vram_stream_descriptor_dispatch and (dead) by
; unused_stream_desc_dispatch; interleaved 8-byte records, one field-view label per word offset.
data C0B208 vram_stream_desc_table
data C0B20A vram_stream_desc_addr
data C0B20C vram_stream_desc_bank
data C0B20E vram_stream_desc_payload
; per-zone index into the streaming-descriptor table above, selected from camera_x
; (dream.asm:3462, 6564-6567).
data C0B24C stream_zone_index_table
; particle_spawn_from_table's per-game-mode spawn coordinate lists (first words are per-mode
; start offsets into the same array, dream.asm:2589-2610).
data C0B26C particle_spawn_list_x
data C0B26E particle_spawn_list_y
; entity_ground_y_lookup's compare threshold ($0008) and fallback ground Y ($00D0)
; (dream.asm:3380-3390).
data C0B2F6 ground_y_lookup_threshold
data C0B2F8 ground_y_lookup_default
; large per-index Y-position lookup read by entity_ground_y_lookup (dream.asm:3395).
data C0B2FA entity_state_ground_y_table
; entity_init_from_table's per-entity init record array (18-byte interleaved records; the
; first 8 bytes double as the 4 per-game-mode start offsets into the same array), one
; field-view label per word offset (dream.asm:3583-3624).
data C0B4A4 entity_init_table
data C0B4A6 entity_init_state
data C0B4A8 entity_init_unk_07a8
data C0B4AA entity_init_x
data C0B4AC entity_init_y
data C0B4AE entity_init_unk_08e8
data C0B4B0 entity_init_flags
data C0B4B2 entity_init_parent
data C0B4B4 entity_init_hitstun

; ---- small unlabeled dead/source-table fragments found while closing the code-section gap ----
; 5-byte DMA/HDMA source table for the dma_setup_channel_step call in mode2_level_init's tail
; (ptr_04 = #$88A6, loaded at C08899); same family as mode0_init_dma_curve_table.
data C088A6 mode2_init_dma_table
; 26-byte HDMA/DMA source table before mode0_camera_zone_update; ptr_04 = #$8A6D (loaded at
; C08A4D, inside the same overlapping-window mode0_level_init tail as data_C084A2/84A9/84B0).
; This is the "8A5A" table referenced in the naming brief.
data C08A5A mode0_zone_hdma_table
; dead tail right after loc_C0921C's rts (the exit of unused_stream_desc_dispatch): INC $0BB8
; twice then STZ $0BBA, RTS: more cleanup code for the same dead dispatcher, never reached.
data C0921D unused_stream_desc_dispatch_tail
; dead fragment inside particle_spawn_from_table, right after loc_C097DD's rts: dex/dex/bpl/
; jmp $98D7: never reached by any traced path.
data C097E7 unused_particle_spawn_tail
; dead duplicate of entity_animate_only's own tail (tyx/pla/rts), sitting right after it.
data C09AFD unused_entity_animate_tail
; two zero bytes used as a fixed DMA source by dma_fill_vram_zero (lda #$A443) to fill VRAM
; with zero via repeated-byte DMA mode.
data C0A443 dma_fill_zero_word
; three unreached jmp instructions inside nmi_handler_title_fade (jmp $BDD6/$BDBF/$BDB0).
data C0BEB7 unused_title_fade_jmp_stub
