# DonPachi (MAME set 'donpachi', US, Ver.1.12 1995/05/2x) - 68000 program symbols
#
# Addresses and names only: no game data lives in this file.
# Format:  ADDRESS  KIND  NAME  [LAYOUT]   [# comment]
#   KIND: func = function entry, code = code label, data = data label
# Addresses are the 68000's, 000000-07FFFF (the program has no mirrors; work RAM is at 100000-10FFFF).
#
# Modelled on tmntarcade-decomp's symbols.txt. The analysis starts at the exception vectors, so the reset and the
# interrupt handlers are found without being listed; the lines here give them their names and add what the
# analysis cannot work out alone (tables of code addresses, jumps through registers).
#
# Everything below was read from the vector table and the first bytes of the program (tools/show_vectors.py), not
# yet from a disassembly: names are provisional.

# ======== the C's files ========
# ADDRESS file PATH  # description: the functions from ADDRESS up to the next file line go to src/PATH.c (a file may
# take several stretches). One file for now; split it by subject as the code is understood.
000420  file  game/program  # the whole program, to be split into files by subject

# ======== the vectors and the version string ========
# 000000-0003FF are the 256 vectors (stack pointer 00110000, reset 0003425A); the version string follows
000400  data  version_string  # "DONPACHI Ver1.121995/05/2x XXXXX", 32 bytes, 000400-00041F

# ======== the first stubs (000420-00043F) ========
# read by hand from the bytes, to check against the listing: two NOPs and a branch back (60FA) to 000420
000420  func  idle_loop
# stop #$2700 (4E72 2700) and a jump back to it (4EF9 0000042A)
00042A  func  halt
# interrupt levels 2-7 (vectors 26-31) all go here: two NOPs and a branch back (60FA) to 000434
000434  func  unused_interrupt_loop
# The task table: 61 stubs of 8 bytes, "jmp $xxxxxx.l" and two bytes more, one for each of the main loop's 61 task slots
# (the loop at 00083C-000876: "lea ($43a,PC), A0" ... "jsr (A0,D0.w)" with D0 = slot * 8). It ends exactly where
# level_1_interrupt begins (00043A + 61 * 8 = 000622). TURN THIS LINE ON only after tools/probe_table.py 0x43A 8 61 shows
# every record as a jmp, and delete this comment's "#":
00043A  data  task_table  record=8 count=61 code=2

# ======== the boot and the interrupts ========
# the reset vector (vector 1): the first instruction after power-on
03425A  func  reset
# the level 1 interrupt (vector 25, at 000064): the only one the game uses (MAME's cave_state sets irq level 1), raised
# every frame at the vblank; the cause is read from 900000-900007
000622  func  level_1_interrupt

# ======== the exceptions (vectors 2-5 and 6-15, 24) ========
# five routines 0x1A bytes apart, probably copies of one stub, each for its own exception
# ======== the main loop and the frame (read from the first listing) ========
# the boot's last step jumps here (034464 "jmp $81a.l"): the loop that runs the 61 task slots each frame, then the
# frame's other work. The listing shows it inside level_1_interrupt only because it follows the rte at 000818
00081A  func  main_loop
# toggles bit 0 of 101200 and points 101202/101206 at the sprite buffer to fill, 500000 or 504000 (the other half of
# the 64 KB sprite RAM), and writes 0 or 1 to 900008: double-buffered sprites. The interrupt calls it first (000640)
002E44  func  swap_sprite_buffers
# D0 + 1 frames: wait_for_frame D0 + 1 times
002EA4  func  wait_frames
# enables interrupts, clears frame_flag and spins until the level 1 interrupt sets it (002ED2 "clr.w $100f44.l",
# 002EDC "tst.w $100f44.l"), then looks at the buttons in 1018EA (a pause or a debug mode?)
002EB8  func  wait_for_frame

# A second, smaller set of tasks: 56 stubs of 8 bytes like task_table (tools/probe_table.py 0x2E096 8 56: every record
# a jmp). Slot 0 is the main table's too (00694E), slots 5-54 all go to 012D50 (object_task, the objects') and the others
# are 1-4 (02D50C, 02B968, 02B8CC, 0126B2) and 55 (02B148). The two bytes after each jmp are never run.
02E096  data  task2_table  record=8 count=56 code=2
# runs slots 1-55 once through task2_table, as the main loop does through task_table. Called over and over by the routine
# at 02DEB4 (02E03C "bsr $2e04c") until bit 2 of the slot 1's byte 3 is set; that routine is called from the main loop's
# button check (000910 "jsr $2deb4.l"): a mode of its own, to be named once the listing shows what it does
02E04C  func  run_task_subset

# ======== variables (work RAM 100000-10FFFF) ========
# the task slot the main loop is on, 0-60 (000842 "move.w $100000.l, D0"); a second loop at 02E05A counts 1-55
100000  var  current_task   u16
# the frame flag: the interrupt sets it (000626 "st $100f44.l"), wait_for_frame clears it and waits for it
100F44  var  frame_flag     u16
# the buffer the sprites are written to (swap_sprite_buffers: bit 0 of 101200)
101200  var  sprite_buffer  u8
# frames since the boot: the interrupt adds one each (00080C "addq.w #1, $101260.l")
101260  var  frame_counter  u16

0364AE  func  exception_default
0364C8  func  exception_bus_error
0364E2  func  exception_address_error
0364FC  func  exception_illegal_instruction
036516  func  exception_divide_by_zero

# ======== the object types, the script commands and the states (read from the listing) ========
# 168 object types, 8 bytes each, from the second record (type 0 is left alone by the code: 012CFA "beq $12cf0", and
# record 0 points back into the table). Each: +0 a data pointer read a word at a time (012D06 "move.w (A1)+, D0"), +4
# the routine 012D86 jumps to ("movea.l ($4,A0,D0.w), A1", "jmp (A1)"). The index is the byte at +0C of the object
# times 8 (012CF6, 012CFC). The table ends where the code at 012C9E begins
01275E  data  object_types  record=8 count=168 code=4

# the sound driver's sequencer (it was taken for an object script interpreter at first): sound_update runs it for each
# of the 8 channels with a sequence playing. The channels are 32-byte records from 101412: +0 bit 15 playing, +2 the
# sample, +6 the volume, +A frames to wait, +C a repeat count, +E added to the sample, +10 the sequence's pointer.
# Records 0-3 play on the effects' M6295 (B00010, its NMK112 banks at B00028), 4-7 on the music's (B00000, B00020).
# A word of the sequence: its low 4 bits the command (00164E "jsr (A0,D0.w)"); 0 and 10-15 do nothing
00162C  func  sound_channel_run
0016A2  func  sound_command_none
# 1: frames to wait and the volume, then the sample played; 2: the same with the volume kept
0016A4  func  sound_command_play_volume
0016AE  func  sound_command_play
# 3: frames to wait; 4: a number added to the samples (+E); 5: the repeat count (+C)
001756  func  sound_command_wait
00175C  func  sound_command_sample_base
001762  func  sound_command_set_repeat
# 6: back to the address that follows while the count lasts; 7: on at the address that follows
001768  func  sound_command_repeat
00176E  func  sound_command_jump
# 8: the chip's four NMK112 banks: 0, 1 and the operand's two 5-bit numbers
00177E  func  sound_command_banks
# 9: the sample stopped (the voice's stop bit from the sample table rom_003946) and the channel off
00179C  func  sound_command_stop

# the state machine at 029194: the state in 101698 (masked to 0-15, times 4) picks a routine; only 1-9 exist
029194  func  run_state
0294C4  func  state_1
02959A  func  state_2
02956C  func  state_3
0295B8  func  state_4
0295DE  func  state_5
0291EA  func  state_6
029450  func  state_7
029366  func  state_8
029472  func  state_9

01275E  data  object_types  record=8 count=168 code=4
# Jump tables found by tools/find_tables.py from the listing (a jmp or jsr (d,PC,Xn) reads a table of jump stubs).
# Names are placeholders: case_<table>_<entry>. A table read by a jsr gives functions (the routines it calls);
# one read only by a jmp gives code labels (its cases lie inside the routine that jumps). Review each table.

# the table at 007438 (read at 007420, 00748E): 8 records of 2 bytes, codes
007428  code  case_007438_00
007426  code  case_007438_01
00742A  code  case_007438_02
00742C  code  case_007438_03
007432  code  case_007438_04
007430  code  case_007438_05
007424  code  case_007438_06
007434  code  case_007438_07

# the table at 00752C (read at 007518): 8 records of 2 bytes, codes
007524  code  case_00752C_00
00751C  code  case_00752C_01

# the table at 0076E8 (read at 0076A0): 7 records of 4 bytes, codes
007704  code  case_0076E8_00
007710  code  case_0076E8_01
007718  code  case_0076E8_02
00772E  code  case_0076E8_03
007732  code  case_0076E8_04
00773A  code  case_0076E8_05
007758  code  case_0076E8_06

# the table at 008146 (read at 008138): 8 records of 4 bytes, funcs
008166  func  case_008146_00
00891A  func  case_008146_01
0089BC  func  case_008146_05
0089BE  func  case_008146_06
0089C0  func  case_008146_07

# the table at 008AF2 (read at 008AE4): 8 records of 4 bytes, funcs
008B12  func  case_008AF2_00
008B46  func  case_008AF2_01
008B80  func  case_008AF2_02
008B8C  func  case_008AF2_03
008BBE  func  case_008AF2_04
008BC6  func  case_008AF2_05

# the table at 008D5A (read at 008D56): 3 records of 4 bytes, codes
008D66  code  case_008D5A_00
008F06  code  case_008D5A_01
009542  code  case_008D5A_02

# the table at 0097AC (read at 0097A8): 3 records of 4 bytes, codes
0097B8  code  case_0097AC_00
009EB6  code  case_0097AC_01
00A8A4  code  case_0097AC_02

# the table at 00BB8C (read at 00BB88): 3 records of 4 bytes, codes
00BB9C  code  case_00BB8C_00
00BBCA  code  case_00BB8C_01
00BC20  code  case_00BB8C_02

# the table at 00C03C (read at 00C02C): 27 records of 4 bytes, funcs
00C128  func  case_00C03C_00
00C144  func  case_00C03C_01
00C12E  func  case_00C03C_03
00C130  func  case_00C03C_04
00C132  func  case_00C03C_05
00C134  func  case_00C03C_06
00C136  func  case_00C03C_07
00C138  func  case_00C03C_08
00C13A  func  case_00C03C_09
00C142  func  case_00C03C_10
00C12A  func  case_00C03C_11
00C146  func  case_00C03C_12
00C172  func  case_00C03C_13
00C1A6  func  case_00C03C_15
00C1A8  func  case_00C03C_16
00C1AA  func  case_00C03C_17
00C1B2  func  case_00C03C_18
00C1BA  func  case_00C03C_20
00C1C2  func  case_00C03C_21
00C1D2  func  case_00C03C_23
00C1E6  func  case_00C03C_24
00C20E  func  case_00C03C_25
00C21E  func  case_00C03C_26

# the table at 00C49C (read at 00C48E): 55 records of 4 bytes, funcs
00C574  func  case_00C49C_00
00C578  func  case_00C49C_01
00C596  func  case_00C49C_02
00C59A  func  case_00C49C_03
00C5EA  func  case_00C49C_06
00C5F2  func  case_00C49C_07
00C61C  func  case_00C49C_08
00C636  func  case_00C49C_10
00C650  func  case_00C49C_12
00C66A  func  case_00C49C_14
00C684  func  case_00C49C_16
00C69E  func  case_00C49C_18
00C6AE  func  case_00C49C_19
00C746  func  case_00C49C_20
00C74A  func  case_00C49C_21
00C770  func  case_00C49C_22
00C774  func  case_00C49C_23
00C788  func  case_00C49C_24
00C78C  func  case_00C49C_25
00C7A2  func  case_00C49C_26
00C7A6  func  case_00C49C_27
00C7F4  func  case_00C49C_30
00C7F8  func  case_00C49C_31
00C80C  func  case_00C49C_32
00C82A  func  case_00C49C_33
00C8C4  func  case_00C49C_34
00C90C  func  case_00C49C_35
00C98A  func  case_00C49C_36
00C996  func  case_00C49C_37
00C9CC  func  case_00C49C_38
00C9EE  func  case_00C49C_39
00CA0C  func  case_00C49C_40
00CA14  func  case_00C49C_41
00CA4C  func  case_00C49C_42
00CA6C  func  case_00C49C_43
00CA86  func  case_00C49C_44
00CAA8  func  case_00C49C_45
00CAC6  func  case_00C49C_46
00CACA  func  case_00C49C_47
00CB4C  func  case_00C49C_48
00CB50  func  case_00C49C_49
00CBC6  func  case_00C49C_53
00C238  func  case_00C49C_54

# the table at 0291BE (read at 0291B0): 10 records of 4 bytes, funcs

# the table at 029B38 (read at 029B2A): 8 records of 4 bytes, funcs
029B58  func  case_029B38_00
02A270  func  case_029B38_01
02A51C  func  case_029B38_02
02A6E4  func  case_029B38_03
02A768  func  case_029B38_04
02A76A  func  case_029B38_05
02A76C  func  case_029B38_06
02A76E  func  case_029B38_07

# the table at 02B1FA (read at 02B1EC): 6 records of 4 bytes, funcs
02B212  func  case_02B1FA_00
02B3BA  func  case_02B1FA_01
02B51E  func  case_02B1FA_02
02B6A8  func  case_02B1FA_03
02B764  func  case_02B1FA_04
02B7DA  func  case_02B1FA_05

# the table at 02C072 (read at 02C06E): 3 records of 4 bytes, codes
02C0BA  code  case_02C072_00
02C16A  code  case_02C072_01
02C218  code  case_02C072_02

# the table at 02DA4C (read at 02DA48): 19 records of 4 bytes, codes
02DC80  code  case_02DA4C_00
02DDD6  code  case_02DA4C_01
02DDEE  code  case_02DA4C_02
02DCB2  code  case_02DA4C_03
02DCC8  code  case_02DA4C_04
02DD16  code  case_02DA4C_05
02DD3E  code  case_02DA4C_06
02DD6E  code  case_02DA4C_07
02DDA4  code  case_02DA4C_08
02DDCA  code  case_02DA4C_09
02DDE2  code  case_02DA4C_10
02DE16  code  case_02DA4C_11
02DE22  code  case_02DA4C_12
02DE2E  code  case_02DA4C_13
02DE3A  code  case_02DA4C_14
02DE46  code  case_02DA4C_15
02DE58  code  case_02DA4C_16
02DE5C  code  case_02DA4C_17
02DE7A  code  case_02DA4C_18

# the table at 02E3F6 (read at 02E3AC): 16 records of 4 bytes, funcs
02E436  func  case_02E3F6_00
02E46C  func  case_02E3F6_01
02E4A2  func  case_02E3F6_02
02E4D2  func  case_02E3F6_03
02E51C  func  case_02E3F6_04
02E51E  func  case_02E3F6_05
02E520  func  case_02E3F6_06
02E522  func  case_02E3F6_07

# the table at 02ECE0 (read at 02ECD2, 02ED0A): 6 records of 4 bytes, funcs
02ED9E  func  case_02ECE0_00
02EEBA  func  case_02ECE0_01
02EFD8  func  case_02ECE0_02
02F0FC  func  case_02ECE0_03
02F13C  func  case_02ECE0_04
02F1E8  func  case_02ECE0_05

# the table at 030610 (read at 0305B4): 3 records of 4 bytes, funcs
030680  func  case_030610_00
03073C  func  case_030610_01
030778  func  case_030610_02

# the table at 032C9C (read at 032C98): 17 records of 4 bytes, codes: the game's modes (game_mode_task, below)
032CE0  code  game_mode_00
032D30  code  game_mode_01
032DF6  code  game_mode_02
032E9E  code  game_mode_03
032EBA  code  game_mode_04
0330F6  code  game_mode_05
033306  code  game_mode_06
03353E  code  game_mode_07
0339A8  code  game_mode_08
033A2A  code  game_mode_09
033B7E  code  game_mode_10
033CE6  code  game_mode_11
033F5C  code  game_mode_12
033FD2  code  game_mode_13
0340AC  code  game_mode_14
0340FA  code  game_mode_15
034168  code  game_mode_16

# the table at 0367C8 (read at 0367BA): 11 records of 4 bytes, funcs
0367F4  func  case_0367C8_00
03688E  func  case_0367C8_01
036928  func  case_0367C8_02
0369C6  func  case_0367C8_03
036A5C  func  case_0367C8_04
036AE8  func  case_0367C8_05
036B58  func  case_0367C8_06
036BB4  func  case_0367C8_07
036C4E  func  case_0367C8_08
036CE8  func  case_0367C8_09
036D58  func  case_0367C8_10

# the table at 036EAA (read at 036E9C): 9 records of 4 bytes, funcs
036ECA  func  case_036EAA_00
036ECE  func  case_036EAA_01
036F26  func  case_036EAA_02
036FB2  func  case_036EAA_03
037066  func  case_036EAA_04
0370CE  func  case_036EAA_05
037120  func  case_036EAA_06
037122  func  case_036EAA_07
037124  func  case_036EAA_08

# the table at 037754 (read at 037750): 3 records of 4 bytes, codes
037A18  code  case_037754_00
037760  code  case_037754_01
037C22  code  case_037754_02

# the table at 03D8B0 (read at 03D8AA): 9 records of 6 bytes, codes
03D8E6  code  case_03D8B0_00
03D988  code  case_03D8B0_01
03D8F4  code  case_03D8B0_02
03D904  code  case_03D8B0_03
03D912  code  case_03D8B0_04
03D91C  code  case_03D8B0_05
03D942  code  case_03D8B0_06
03D952  code  case_03D8B0_07
03D978  code  case_03D8B0_08

# the table at 03DAC4 (read at 03DABE): 8 records of 6 bytes, codes
03DAF4  code  case_03DAC4_00
03DB0C  code  case_03DAC4_01
03DB1C  code  case_03DAC4_02
03DB2A  code  case_03DAC4_03
03DB3A  code  case_03DAC4_04
03DB48  code  case_03DAC4_05
03DB52  code  case_03DAC4_06
03DB80  code  case_03DAC4_07

# the table at 03DDEC (read at 03DDE6): 4 records of 6 bytes, codes
03DE04  code  case_03DDEC_00
03DE8A  code  case_03DDEC_02
03DE9A  code  case_03DDEC_03

# the table at 03EC18 (read at 03EC14): 6 records of 4 bytes, codes
03EC30  code  case_03EC18_00
03ED76  code  case_03EC18_01
03EF3A  code  case_03EC18_02
03EFF0  code  case_03EC18_03
03F172  code  case_03EC18_04
03F28E  code  case_03EC18_05

# the table at 040266 (read at 04025A): 3 records of 4 bytes, funcs
0403B0  func  case_040266_00
04032C  func  case_040266_01
040272  func  case_040266_02

# the table at 0405F6 (read at 0405F2): 3 records of 4 bytes, codes
040602  code  case_0405F6_00
040656  code  case_0405F6_01
0406E2  code  case_0405F6_02

# the table at 0429D0 (read at 0429C8): 4 records of 4 bytes, funcs
0429E0  func  case_0429D0_00
042A00  func  case_0429D0_01
042A34  func  case_0429D0_02
042AB2  func  case_0429D0_03

# the table at 042F18 (read at 042F10): 2 records of 4 bytes, funcs  <- only a few: check by hand
042F20  func  case_042F18_00
042F54  func  case_042F18_01

# the table at 043324 (read at 04331C): 4 records of 4 bytes, funcs
043334  func  case_043324_00
04335C  func  case_043324_01
043394  func  case_043324_02
0433F2  func  case_043324_03
# from the table at 01275E: the field at +0 of each record, plus 2 (tools/table_funcs.py)
0139A2  func  object_init_001
013DBE  func  object_init_002
0139DE  func  object_init_003
013FD2  func  object_init_004
00D24E  func  object_init_005
00D504  func  object_init_006
00D53C  func  object_init_007
00D57C  func  object_init_008
00D5BC  func  object_init_009
00D7FE  func  object_init_010
00D85C  func  object_init_011
00DCB4  func  object_init_012
03FF44  func  object_init_013
00DF0C  func  object_init_014
00E27C  func  object_init_015
00E5D6  func  object_init_016
00EC0A  func  object_init_017
00EFAE  func  object_init_018
00F47A  func  object_init_019
00FA72  func  object_init_020
0101C8  func  object_init_021
010526  func  object_init_022
01068E  func  object_init_023
00D128  func  object_init_024
014246  func  object_init_025
014524  func  object_init_026
0146FE  func  object_init_027
014A94  func  object_init_028
015272  func  object_init_029
0159CA  func  object_init_030
011AB8  func  object_init_031
01CD44  func  object_init_032
016AAE  func  object_init_033
01702C  func  object_init_034
016728  func  object_init_035
0168F2  func  object_init_036
016A0A  func  object_init_037
0206D2  func  object_init_038
020E5C  func  object_init_039
020E52  func  object_init_040
020EB8  func  object_init_041
020F12  func  object_init_042
017366  func  object_init_043
017418  func  object_init_044
01742C  func  object_init_045
01744C  func  object_init_046
0174E6  func  object_init_047
0372C0  func  object_init_048
0211FA  func  object_init_049
017516  func  object_init_050
0113D4  func  object_init_051
017AC6  func  object_init_052
017B10  func  object_init_053
017C50  func  object_init_054
0181B0  func  object_init_055
0184A4  func  object_init_056
018878  func  object_init_057
018B8C  func  object_init_058
02440E  func  object_init_059
025862  func  object_init_060
0190D8  func  object_init_061
019434  func  object_init_062
0384DC  func  object_init_063
0267CA  func  object_init_064
0269DE  func  object_init_065
019988  func  object_init_066
022C86  func  object_init_067
01A1B8  func  object_init_068
01C5AE  func  object_init_069
01B10A  func  object_init_070
01B1BE  func  object_init_071
01B258  func  object_init_072
039652  func  object_init_075
00DB34  func  object_init_076
038B3C  func  object_init_078
03BEDC  func  object_init_079
022ED2  func  object_init_080
01BA8E  func  object_init_082
01BBB6  func  object_init_083
01BE96  func  object_init_084
01C268  func  object_init_085
011682  func  object_init_086
01C88C  func  object_init_087
026E98  func  object_init_088
03A2F4  func  object_init_089
03A744  func  object_init_090
0230DE  func  object_init_091
028420  func  object_init_092
011748  func  object_init_093
0117B0  func  object_init_094
011920  func  object_init_095
011A8A  func  object_init_096
011D54  func  object_init_097
026A52  func  object_init_098
01CB14  func  object_init_099
01CCDE  func  object_init_100
02341E  func  object_init_101
0237E0  func  object_init_102
023AD0  func  object_init_103
028664  func  object_init_104
023D2A  func  object_init_106
03AEA8  func  object_init_107
011E74  func  object_init_108
01C860  func  object_init_109
01C876  func  object_init_110
0435BE  func  object_init_111
0426AA  func  object_init_112
042BAA  func  object_init_113
0431C8  func  object_init_114
023358  func  object_init_115
04254A  func  object_init_116
043170  func  object_init_117
042B24  func  object_init_118
03C268  func  object_init_119
03C7B0  func  object_init_120
03CA02  func  object_init_121
03CC0A  func  object_init_122
03CE40  func  object_init_123
03E358  func  object_init_124
012000  func  object_init_126
01219C  func  object_init_127
01CF3E  func  object_init_128
01D1F0  func  object_init_129
01D774  func  object_init_130
01DA94  func  object_init_131
01DCAC  func  object_init_132
01DD94  func  object_init_133
01DE82  func  object_init_134
01E038  func  object_init_135
01E1BE  func  object_init_136
01FF60  func  object_init_137
043446  func  object_init_138
01E584  func  object_init_139
03F812  func  object_init_140
012308  func  object_init_141
01ED50  func  object_init_142
01F4B8  func  object_init_143
03F906  func  object_init_144
03FD72  func  object_init_145
00D246  func  object_init_146
01FDCE  func  object_init_147
01FDBE  func  object_init_148
03FC26  func  object_init_149
03C63E  func  object_init_150
01237E  func  object_init_152
04041C  func  object_init_153
0404F8  func  object_init_154
0407D6  func  object_init_155
03DEE2  func  object_init_156
0201CA  func  object_init_157
02030A  func  object_init_158
020514  func  object_init_159
01FE6E  func  object_init_160

016346  func  object_spawn_a
0162E2  func  object_spawn_b
00BD36  func  draw_routine_a
00BD56  func  draw_routine_b
# Tables of code addresses found by tools/find_pointer_tables.py: a movea.l (d,PC,Dn), An read one, a jmp or
# jsr (An) went through it. Names are placeholders. Review each table before keeping it.

# read at 007830: 6 entries
007850  data  jump_table_007850  record=4 count=6 code=0

# read at 007934: 6 entries
007962  data  jump_table_007962  record=4 count=6 code=0

# read at 0140B2: 4 entries
0140B8  data  jump_table_0140B8  record=4 count=4 code=0

# read at 0185AA: 4 entries
0185B0  data  jump_table_0185B0  record=4 count=4 code=0

# read at 01B5BE: 4 entries
01B5C4  data  jump_table_01B5C4  record=4 count=4 code=0

# read at 01F0C0: 4 entries
01F0C6  data  jump_table_01F0C6  record=4 count=4 code=0

# read at 027E26: 9 entries
027E2C  data  jump_table_027E2C  record=4 count=9 code=0

# ======== the second script interpreter (animation commands), read from the listing ========
# 013596-0135C6: a timer at +10 of the object counts down; at zero the next word is read through the pointer at +14. A
# positive word is a new timer (and a value stored at +4); a negative one is a command, number = bits 1-4 of the word
# (0135B6 "lea $136de.l, A3", "andi.w #$1e, D1", "jsr (A3,D1.w)"). Commands 10-15 all go to 013790
01371E  func  anim_command_00
013724  func  anim_command_01
01372C  func  anim_command_02
013742  func  anim_command_03
013756  func  anim_command_04
01375C  func  anim_command_05
013762  func  anim_command_06
013774  func  anim_command_07
01377C  func  anim_command_08
013786  func  anim_command_09
013790  func  anim_command_none

# 013674-01368C: two bits of the word at +2 of the object (bits 4-5) pick one of four jmp stubs of 6 bytes
# ("lea $13692.l, A3", "jmp (A3,D1.w)"). Two of them go to the same place
013692  data  branch_table  record=6 count=4 code=2

0413E4  code  switch_0413C4_00
041414  code  switch_0413C4_01
0416D6  code  switch_0413C4_02
041722  code  switch_0413C4_03
04186C  code  switch_0413C4_04
04194A  code  switch_0413C4_05
041980  code  switch_0413C4_06
0419A8  code  switch_0413C4_07

03D252  data  switch_03D252_table  record=6 count=16 code=2



# ======== names from the first full decompile (08-11-2026), the most used routines and variables ========
# the task system: task_table (00043A) holds, for each kind of task, a jump to its code and at +6 how many slots it
# has; the slots are 64 bytes from 100002, word 0 = 8000 + the task's number while it runs, bit 6 = paused
# start a task of kind D0 in its group's first free slot, with D1-D3 at +4 (004134); carry set when the group is full
004102  func  start_task
# start_task, then the 24 bytes of task_params copied after them (00414E)
004144  func  start_task_with_params
# set / clear bit 6 of every slot of the group of D0 (004178 "bset #$6, (A0)", 0041A2 "bclr")
00415C  func  pause_task_group
004186  func  resume_task_group
# the 24 bytes the callers fill before start_task_with_params (0168B8 "lea $108820.l, A0")
108820  var  task_params    u8

# the sprites: an entry of 16 bytes each in the list swap_sprite_buffers starts (101202, 500000 or 504000)
# the object at A6: its long at +2, x = (+6 + +C) >> 6, y = (+8 + +E) >> 6, its word at +A (00520C-005228)
005202  func  draw_object_sprite
# the same from D1-D5 (005266-005272)
00525C  func  draw_sprite
# the entries left at the end of the list get an off-screen place (0052B8 "move.l #$2a002a0, D0")
0052A8  func  hide_unused_sprites
# two more lists, in the spare sprite RAM at 50C000 and 50E000, emptied each frame by the main loop (00083C) and drawn
# after the rest (02B154, 02B166), so their sprites are written last
005362  func  clear_late_sprite_lists
005384  func  queue_late_sprite_a
0053A8  func  queue_late_sprite_a_at
0053C6  func  draw_late_sprites_a
0053DC  func  queue_late_sprite_b
005400  func  queue_late_sprite_b_at
00541E  func  draw_late_sprites_b
101202  var  sprite_list_start   u32
101206  var  sprite_list_end     u32
101212  var  late_sprites_a_end  u32
101216  var  late_sprites_b_end  u32

# a sound: D0 the sound's code (006690 "move.w #$225d, D0"); saves every register (0037C0), the work is at 0037CE
0037C0  func  play_sound

# a byte from a table of random numbers: the low byte of random_index goes up by one at each call (003C86)
003C86  func  random_byte
003D98  func  random_byte_2
101262  var  random_index   u16

# adds the BCD number in D0 to the 4-byte BCD number that ends at A0 ("abcd -(A1), -(A0)" four times, 006944)
00693A  func  add_bcd

# clears the parts of the object at A5 (the +4 byte, the count less one, of 32-byte records from the pointer at +6)
# and the object itself (012D92-012D9C)
012D88  func  remove_object

# the inputs, as the interrupt reads them (00071E "move.w $c00000.l, D0", "not.w D0"): 1 = pressed
10127E  var  input_1        u16
101280  var  input_2        u16
# the stage, 0-4: the stage scripts (02D33E) and the tables 007850 and 007962 are read by it
101A40  var  stage          u16
# how far the stage has scrolled: the scripts' records run when it reaches their position (02DA28, 02DA98)
101A56  var  scroll_position u16
# the routine script command 15 sets (02DE46) and 02D996 jumps to; no stage's script sets it
10885C  var  script_callback u32
# what the game is doing (the interrupt compares it with 1 and 5, 0007BC-0007D0)
1018EC  var  game_mode      u16
# the main loop adds one each time round (00096C); its bit 0 picks which player's code runs (000938)
10125E  var  loop_counter   u16
# the two players' records of 64 bytes (000942, 000958: the main loop's player code takes A5 at each)
102158  var  player_1       u16
102198  var  player_2       u16

# ======== named from what the port has learnt of the game (13-11-2026) ========
# (the port's own reading of the game's memory: ports/sdl2's training.c, stats.c, widgets.h, hitbox.h, own_cheats.c,
# fast_timing.c; and the listing)

# ---- the sound driver ----
# the board's sound set up: both chips' NMK112 banks 0-3, the channels' records cleared, both chips told to stop (78),
# then waits for the music chip's voices to be quiet (from the test mode, 037754)
001578  func  sound_reset
# each vblank interrupt: the 8 channels, from record 0 (on the effects' chip) to 7, each playing one run by
# sound_channel_run
0015E6  func  sound_update
# plays the channel's sample on its chip: waits for the voice to be free, sets the bank (effects' channels on 4-7),
# then the M6295's two bytes (the sample, then the voice and the volume)
0016B2  func  sound_channel_play
# play_sound's work: D0 the sound's code; a music code (bit 15, low byte below 10) starts channel 4's sequence from
# the table rom_001304; the others take an effects' channel. None while 1018EB bit 7 and 101286 bit 3 are set (the
# attract mode with its sound off)
0037CE  func  sound_request
# everything stopped: both chips, the effects' channels and the music's (00394E saves the registers)
00394E  func  stop_all_sound
00395A  func  stop_all_sound_work
# the music stopped: its chip, and channel 4 (0039AE saves the registers)
0039AE  func  stop_music
0039BA  func  stop_music_work
# the effects' chip stopped and its banks set to 0, 4, 2, 3 (the ending's voices, 02868A)
0039E2  func  sfx_chip_reset
# a sample on the effects' chip directly (not through a channel): D0 the sample, D1 added to it, D2 the voice and
# volume; 003A6C stops it
003A32  func  sfx_play_sample
003A6C  func  sfx_stop_sample
# the music's channel (channel 4's record, 101492 = 101412 + 4 x 32): its first long
101492  var  music_channel  u32

# ---- the text and the tile layers ----
# a line of text: D0 the text's number, the table at 0028BC (8 bytes: the place in layer 2 at 404000, the
# characters); the characters up to "\" (5C). 003604 one tile a character (from 20, the test mode's and the error
# screens'); 003646 two tiles high (from 1DA, the game's); 0036A8 the same in the second font (from 312); 00370A as
# 003646 with the registers kept
003604  func  draw_text_small
003646  func  draw_text
0036A8  func  draw_text_font_2
00370A  func  draw_text_keep
# one tile (the long in D0) into layer 2 at A0; 00376E a block of 2 x 2
00378A  func  put_text_tile
00376E  func  put_tile_2x2
# a block of tiles in layer 2: D0 the first, D2 + 1 columns of D3 + 1 rows, numbered down then across
003198  func  put_tile_block
# the layers emptied: 0 (003242), 1 (003258), 2 (00326C); the scroll registers' copies put back to 0 (003280);
# 00329E all four
003242  func  clear_layer_0
003258  func  clear_layer_1
00326C  func  clear_layer_2
003280  func  reset_scroll
00329E  func  clear_screen
# a rectangle of layer 2 filled with D0's long (00320E: with 0)
003210  func  fill_tile_block
00320E  func  clear_tile_block
# the word in D0 (0-65535) as BCD (abcd: D1 D2 D3 bytes, the number in D2's long)
003AB0  func  binary_to_bcd
# a BCD number (D2) into layer 2 at A0, from its last digit: 003AD8 up to its last digit not 0, 003B36 the 8 digits
# with blanks for the leading zeros, 003B94 all 8 with the zeros (palette FA); 003C34 in the second font, 003C2E the
# same in palette D6
003AD8  func  draw_bcd_number
003B36  func  draw_bcd_number_blanked
003B94  func  draw_bcd_number_zeros
003C34  func  draw_small_bcd_number
003C2E  func  draw_small_bcd_number_d6
# D0 added to one of the scroll registers' copies (1013C0 + D1)
0037B4  func  add_scroll

# ---- the buttons ----
# the players' new presses: 10380E / 103810 the button bytes held (high byte) and just pressed (low byte)
003106  func  read_new_buttons
10380E  var  buttons_new_1  u16
103810  var  buttons_new_2  u16

# ---- the game's flow ----
# the game's mode (game_mode, 1018EC: 7 player 1 alone, 6 player 2 alone, 0 both and the title screen, 0xB the ship
# select, 8 the continue count, 1 and 5 the attract mode's demonstration, 2 and 4 the coins and start; ports/sdl2's
# game_mode.h) picks one of 17 routines from the table at 032C9C, game_mode_00-16 (named there)
032C8E  func  game_mode_task
# the developers' debug tools, run by the main loop in debug mode (101398 bit 2): the palette editor, the object
# spawner, the stage select (ports/sdl2/own_cheats.c)
035D78  func  debug_tools
# the buttons' byte the interrupt makes from player 1's and 2's buttons; bit 2 the debug mode, which it clears
101398  var  debug_buttons  u8
# 1 shows the developers' RAM editor (own_cheats.c)
1018E8  var  ram_editor  u8
# the program's frame made (bit 0): the vblank interrupt then sets the scroll and copies the palette
# (ports/sdl2/fast_timing.c)
1011FC  var  frame_ready  u16
# the scroll's step this frame (its high bits): what the ground objects move down by (scroll_with_ground)
1013C4  var  scroll_step  u16
# the screen shake's entry (a pointer: the 3 layers' x and y added to their scroll)
1013CC  var  shake_entry  u32
# the settings from the EEPROM: the difficulty (low 2 bits), 101287 bit 0 the coinage (2 credits a game), bit 2
# C BUTTON FULL-AUTO, 101286 bit 3 the attract mode's sound off (sound_request); the rank's base
101284  var  difficulty  u16
101286  var  game_settings  u16
101288  var  rank_base  u16
10139A  var  credits  u16
# the loop, 0 or 1 (stage is the area in the loop, 0-4)
101A42  var  loop_number  u16
# the rank (its low byte, 0-63): the enemies' bullets' speed and number
101A32  var  rank  u16

# ---- the players ----
# each ship's task (slot 2 of task_table and task2_table: player 1's; slot 3: player 2's): the first time round its
# chain's variables cleared, then
# player_ship with A6 at its record (player_1 / player_2), A3 at its bomb slots
02B968  func  player_1_task
02B8CC  func  player_2_task
# a ship's frame: the stick and buttons, its shot, laser and bombs, being hit, the respawn
02BBF2  func  player_ship
# the hit test for the ship at A5 (the main loop, a ship a frame by turns, 000950 / 000966): the enemies' bullets
# (each one's point) and the enemies (their boxes) against it (ports/sdl2/hitbox.h)
0055DA  func  ship_hit_test
# the enemies' 75 bullets cleared (a ship shot down)
02CB82  func  clear_enemy_bullets
# the lives (the low bytes: 101A2F player 1's, 101A31 player 2's)
101A2E  var  lives_1  u16
101A30  var  lives_2  u16
# 1 at MAX power (a power-up then gives the bonus)
101A86  var  max_power_1  u16
101A88  var  max_power_2  u16
# the bomb slots, 3-7 (the next byte: the bombs used toward one more)
101A8A  var  bomb_slots_1  u8
101A8C  var  bomb_slots_2  u8
# the bees taken in the area
10379A  var  bees_1  u16
10379E  var  bees_2  u16
# a bomb going off (bit 7)
106E14  var  bomb_active  u8

# ---- the score and the Get Point chain ----
# points to the players (D0, BCD; D1 bit 4 player 1, bit 3 player 2), added to the score at the frame's end
006698  func  add_score
# a hit on an enemy: its sound (225D) unless it has none (bit 1 at A6), and 10 points
006686  func  score_hit
# an enemy shot down: its points, and the chain (its timer back to 30, its hits and points: ports/sdl2/widgets.h)
0066C4  func  score_kill
10177A  var  score_1  u32
10177E  var  score_2  u32
# the HUD's HIGH: the table's #1, until a player's score goes over it
101782  var  hud_high_score  u32
# the high score table's #1 (BCD; then #2-#5, the names from 10185A)
101846  var  high_score_top  u32
# the chain: its timer (30 at each kill, down 1 a frame, over at 0), the sum of its base values, its points (the
# HUD's "+N GP", BCD), its hits, the best chain (the "MAX GP COUNTS")
101742  var  chain_timer_1  u16
101760  var  chain_timer_2  u16
101746  var  chain_base_1  u32
101764  var  chain_base_2  u32
10174A  var  chain_points_1  u32
101768  var  chain_points_2  u32
10174E  var  chain_hits_1  u16
10176C  var  chain_hits_2  u16
101754  var  best_chain_1  u16
101772  var  best_chain_2  u16

# ---- the enemies ----
# the objects' task (the slots from 5 on): the first time round the object's type (its +C byte) picks its
# record of object_types, then each frame its routine
012D50  func  object_task
# an enemy bullet into the first free of 55 of the 75 bullets (104E94, 64 bytes each): D0 its kind (the table
# rom_00BEE8), D2 its place, D1 its way. None while 101906, 1018AC or 108868 is set
00BCFA  func  fire_enemy_bullet
# the object at A6 moved down with the ground's scroll (scroll_step)
00738A  func  scroll_with_ground
# how far the object at A6 is from (D2, D3): the larger of the two distances plus half the smaller (007AA8); from a
# ship (007A9A); from the nearer ship (007A7E)
007AA8  func  distance_to
007A9A  func  distance_to_player
007A7E  func  nearest_player_distance
# the bosses' routines, as the side panels read their health (ports/sdl2/widgets.c): the areas' bosses and the
# true last boss of area 10 (area 5's comes back as area 10's first)
0213B8  func  boss_area_1
026FA2  func  boss_area_2
03985C  func  boss_area_3
024582  func  boss_area_4
03B0F4  func  boss_area_5
03E5C8  func  true_boss
