Yu-Gi-Oh! Monster Capsule GB/ROM map

From Data Crystal
< Yu-Gi-Oh! Monster Capsule GB
Revision as of 11:19, 20 March 2025 by Mantidactyle (talk | contribs) (→‎Bank 0)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Chip tiny.png The following article is a ROM map for Yu-Gi-Oh! Monster Capsule GB.

Bank 0

rst

rst 18 - jump to: hl += a

ROM0:0018 18 65            jr   007F

hl += a

ROM0:007F 85               add  l           ;a += l
ROM0:0080 30 01            jr   nc,0083     ;if there's no carry after a += l, skip next instruction
ROM0:0082 24               inc  h           ;h++
ROM0:0083 6F               ld   l,a         ;l = a
ROM0:0084 C9               ret  

0:02BA (related to sound?)

ROM0:02BA F0 40            ld   a,(ff00+40)
ROM0:02BC CB 7F            bit  7,a
ROM0:02BE C8               ret  z
ROM0:02BF C5               push bc
ROM0:02C0 D5               push de
ROM0:02C1 E5               push hl
ROM0:02C2 F0 9F            ld   a,(ff00+9F)
ROM0:02C4 CB 67            bit  4,a
ROM0:02C6 C4 9F 0D         call nz,0D9F
ROM0:02C9 CD B7 18         call 18B7
ROM0:02CC CD 62 1B         call 1B62
ROM0:02CF F0 9F            ld   a,(ff00+9F)
ROM0:02D1 F6 80            or   a,80
ROM0:02D3 E0 9F            ld   (ff00+9F),a
ROM0:02D5 76               halt 
ROM0:02D6 00               nop  
ROM0:02D7 F0 9F            ld   a,(ff00+9F)
ROM0:02D9 CB 7F            bit  7,a
ROM0:02DB 20 F8            jr   nz,02D5
ROM0:02DD E1               pop  hl
ROM0:02DE D1               pop  de
ROM0:02DF C1               pop  bc
ROM0:02E0 C9               ret  

Load intro

ROM0:2B4D 3E FF            ld   a,FF
ROM0:2B4F EA 01 C2         ld   (C201),a
ROM0:2B52 EA BD C2         ld   (C2BD),a
ROM0:2B55 3E 09            ld   a,00
ROM0:2B57 EA 00 C2         ld   (C200),a         ;Intro
ROM0:2B5A F0 96            ld   a,(ff00+96)
ROM0:2B5C F6 02            or   a,02
ROM0:2B5E E0 96            ld   (ff00+96),a
ROM0:2B60 CD 62 32         call 3262
ROM0:2B63 CD 46 0A         call 0A46

Load requested screen

ROM0:2C26 FA 00 C2         ld   a,(C200)         ;Screen ID
ROM0:2C29 4F               ld   c,a
ROM0:2C2A 87               add  a
ROM0:2C2B 81               add  c
ROM0:2C2C 21 92 2C         ld   hl,2C92
ROM0:2C2F 06 00            ld   b,00
ROM0:2C31 4F               ld   c,a
ROM0:2C32 09               add  hl,bc            ;hl = 0x2C92 + (Screen ID × 3)
ROM0:2C33 2A               ldi  a,(hl)
ROM0:2C34 4F               ld   c,a
ROM0:2C35 2A               ldi  a,(hl)
ROM0:2C36 47               ld   b,a
ROM0:2C37 2A               ldi  a,(hl)           ;Load pointer + bank
ROM0:2C38 CD ED 0A         call 0AED             ;Bank switch
ROM0:2C3B 69               ld   l,c
ROM0:2C3C 60               ld   h,b
ROM0:2C3D 01 42 2C         ld   bc,2C42
ROM0:2C40 C5               push bc
ROM0:2C41 E9               jp   hl               ;Jump to pointer
ROM0:2C42 CD BA 02         call 02BA
ROM0:2C45 CD 69 22         call 2269
ROM0:2C48 CD 2E 32         call 322E
ROM0:2C4B FA 01 C2         ld   a,(C201)
ROM0:2C4E FE FF            cp   a,FF
ROM0:2C50 28 D4            jr   z,2C26
ROM0:2C52 FA 01 C2         ld   a,(C201)
ROM0:2C55 EA 00 C2         ld   (C200),a
ROM0:2C58 3E FF            ld   a,FF
ROM0:2C5A EA 01 C2         ld   (C201),a
ROM0:2C5D F0 96            ld   a,(ff00+96)
ROM0:2C5F CB 7F            bit  7,a
ROM0:2C61 28 13            jr   z,2C76
ROM0:2C63 FA 00 C2         ld   a,(C200)
ROM0:2C66 FE 07            cp   a,07
ROM0:2C68 28 0C            jr   z,2C76
ROM0:2C6A FE 08            cp   a,08
ROM0:2C6C 28 08            jr   z,2C76
ROM0:2C6E FE 05            cp   a,05
ROM0:2C70 CC 89 2C         call z,2C89
ROM0:2C73 CD 58 0D         call 0D58
ROM0:2C76 CD 46 0A         call 0A46
ROM0:2C79 7F               ld   a,a
ROM0:2C7A 45               ld   b,l
ROM0:2C7B 03               inc  bc
ROM0:2C7C FA 00 C2         ld   a,(C200)
ROM0:2C7F B7               or   a
ROM0:2C80 C2 99 2B         jp   nz,2B99
ROM0:2C83 CD 58 0D         call 0D58
ROM0:2C86 C3 5A 2B         jp   2B5A
ROM0:2C89 3E 49            ld   a,49
ROM0:2C8B CD 8C 16         call 168C
ROM0:2C8E CD 42 16         call 1642
ROM0:2C91 C9               ret  

Screen pointers and banks

ROM0:2C92
B0 2C 00 - Intro
7B 40 18
F9 4B 18
AE 49 18
16 44 02
00 40 01
00 40 01
05 40 08
14 40 08
8C 51 03 - Sound test
05 03 08

0:3B77 (Load soundtrack ?)

ROM0:3B77 F5               push af
ROM0:3B78 C5               push bc
ROM0:3B79 47               ld   b,a              ;b = soundtrack_id
ROM0:3B7A F0 95            ld   a,(ff00+95)
ROM0:3B7C F5               push af
ROM0:3B7D CD FA 0A         call 0AFA
ROM0:3B80 78               ld   a,b
ROM0:3B81 CD 8B 3B         call 3B8B
ROM0:3B84 F1               pop  af
ROM0:3B85 CD 12 0B         call 0B12
ROM0:3B88 C1               pop  bc
ROM0:3B89 F1               pop  af
ROM0:3B8A C9               ret

0:3B8B

ROM0:3B8B F5               push af
ROM0:3B8C F0 94            ld   a,(ff00+94)
ROM0:3B8E EA 25 A7         ld   (A725),a
ROM0:3B91 F1               pop  af
ROM0:3B92 E5               push hl
ROM0:3B93 21 DC FF         ld   hl,FFDC
ROM0:3B96 CB CE            set  1,(hl)
ROM0:3B98 D5               push de
ROM0:3B99 C5               push bc
ROM0:3B9A F5               push af
ROM0:3B9B CD 1B 3C         call 3C1B
ROM0:3B9E FA 25 A7         ld   a,(A725)
ROM0:3BA1 E0 94            ld   (ff00+94),a
ROM0:3BA3 EA 00 20         ld   (2000),a
ROM0:3BA6 F1               pop  af
ROM0:3BA7 C1               pop  bc
ROM0:3BA8 D1               pop  de
ROM0:3BA9 21 DC FF         ld   hl,FFDC
ROM0:3BAC CB 8E            res  1,(hl)
ROM0:3BAE E1               pop  hl
ROM0:3BAF C9               ret

0:3C1B - write soundtrack_id in SRAM sA709, and ?

ROM0:3C1B EA 09 A7         ld   (A709),a           ;write soundtrack_id in SRAM sA709
ROM0:3C1E B7               or   a
ROM0:3C1F 20 11            jr   nz,3C32
ROM0:3C21 EA 26 A7         ld   (A726),a
ROM0:3C24 3E 1D            ld   a,1D
ROM0:3C26 E0 94            ld   (ff00+94),a
ROM0:3C28 EA 00 20         ld   (2000),a
ROM0:3C2B C3 73 48         jp   4873
ROM0:3C2E EA 1C A7         ld   (A71C),a
ROM0:3C31 C9               ret

0:3C32

ROM0:3C32 21 1B A7         ld   hl,A71B
ROM0:3C35 CB 46            bit  0,(hl)
ROM0:3C37 20 F5            jr   nz,3C2E
ROM0:3C39 CB 7F            bit  7,a
ROM0:3C3B 28 0C            jr   z,3C49
ROM0:3C3D 47               ld   b,a
ROM0:3C3E FA 26 A7         ld   a,(A726)
ROM0:3C41 B8               cp   b
ROM0:3C42 20 01            jr   nz,3C45
ROM0:3C44 C9               ret

0:3C32 - setting debug values in SRAM for playing soundtrack in Sound Test ?

ROM0:3C45 78               ld   a,b                ;a = soundtrack_id
ROM0:3C46 EA 26 A7         ld   (A726),a           ;sA726 = soundtrack_id
ROM0:3C49 AF               xor  a
ROM0:3C4A EA 17 A7         ld   (A717),a
ROM0:3C4D FA 1A A7         ld   a,(A71A)
ROM0:3C50 CB 47            bit  0,a
ROM0:3C52 20 1D            jr   nz,3C71
ROM0:3C54 FA 0A A7         ld   a,(A70A)
ROM0:3C57 B7               or   a
ROM0:3C58 28 0D            jr   z,3C67
ROM0:3C5A CB 47            bit  0,a
ROM0:3C5C 28 13            jr   z,3C71
ROM0:3C5E CB 87            res  0,a
ROM0:3C60 CB C7            set  0,a
ROM0:3C62 EA 0A A7         ld   (A70A),a
ROM0:3C65 18 0A            jr   3C71
ROM0:3C67 0E 24            ld   c,24
ROM0:3C69 F2               ld   a,(ff00+c)
ROM0:3C6A FE 77            cp   a,77
ROM0:3C6C 28 03            jr   z,3C71
ROM0:3C6E 3E 77            ld   a,77
ROM0:3C70 E2               ld   (ff00+c),a
ROM0:3C71 FA 09 A7         ld   a,(A709)          ;a = soundtrack_id
ROM0:3C74 47               ld   b,a
ROM0:3C75 FE 80            cp   a,80
ROM0:3C77 30 0D            jr   nc,3C86           ;if (soundtrack_id > 0x80, jump to 0x3C86)
ROM0:3C79 3E 1D            ld   a,1D
ROM0:3C7B E0 94            ld   (ff00+94),a
ROM0:3C7D EA 00 20         ld   (2000),a          ;ROM Bank switch to 0x1D
ROM0:3C80 78               ld   a,b
ROM0:3C81 21 FE 3F         ld   hl,3FFE           ;hl = 0x3FFE
ROM0:3C84 18 20            jr   3CA6
ROM0:3C86 FE C0            cp   a,C0
ROM0:3C88 30 0F            jr   nc,3C99           ;if (soundtrack_id > 0xC0, jump to 0x3C99); Battle OSTs, Dungeon world OSTs, testing sounds
ROM0:3C8A 3E 1E            ld   a,1E
ROM0:3C8C E0 94            ld   (ff00+94),a
ROM0:3C8E EA 00 20         ld   (2000),a          ;ROM Bank switch to 0x1E
ROM0:3C91 78               ld   a,b
ROM0:3C92 21 FE 3F         ld   hl,3FFE           ;hl = 0x3FFE
ROM0:3C95 D6 80            sub  a,80              ;soundtrack_id -= 0x80
ROM0:3C97 18 0D            jr   3CA6
ROM0:3C99 3E 1F            ld   a,1F
ROM0:3C9B E0 94            ld   (ff00+94),a
ROM0:3C9D EA 00 20         ld   (2000),a          ;ROM Bank switch to 0x1F
ROM0:3CA0 78               ld   a,b
ROM0:3CA1 21 FE 3F         ld   hl,3FFE           ;hl = 0x3FFE
ROM0:3CA4 D6 C0            sub  a,C0              ;soundtrack_id -= 0xC0
ROM0:3CA6 CD 11 3F         call 3F11
ROM0:3CA9 2A               ldi  a,(hl)
ROM0:3CAA EA 08 A7         ld   (A708),a
ROM0:3CAD 46               ld   b,(hl)
ROM0:3CAE 23               inc  hl
ROM0:3CAF 5D               ld   e,l
ROM0:3CB0 54               ld   d,h
ROM0:3CB1 21 00 A0         ld   hl,A000
ROM0:3CB4 CB 08            rrc  b
ROM0:3CB6 DC 63 3D         call c,3D63
ROM0:3CB9 24               inc  h
ROM0:3CBA CB 08            rrc  b
ROM0:3CBC DC 63 3D         call c,3D63
ROM0:3CBF 24               inc  h
ROM0:3CC0 CB 08            rrc  b
ROM0:3CC2 DC 63 3D         call c,3D63
ROM0:3CC5 78               ld   a,b
ROM0:3CC6 07               rlca 
ROM0:3CC7 07               rlca 
ROM0:3CC8 07               rlca 
ROM0:3CC9 47               ld   b,a
ROM0:3CCA 21 00 A0         ld   hl,A000
ROM0:3CCD CB 38            srl  b
ROM0:3CCF DC 68 3D         call c,3D68
ROM0:3CD2 21 00 A1         ld   hl,A100
ROM0:3CD5 CB 38            srl  b
ROM0:3CD7 DC 68 3D         call c,3D68
ROM0:3CDA 21 00 A2         ld   hl,A200
ROM0:3CDD CB 38            srl  b
ROM0:3CDF DC 68 3D         call c,3D68
ROM0:3CE2 AF               xor  a
ROM0:3CE3 EA 10 A7         ld   (A710),a
ROM0:3CE6 CB 38            srl  b
ROM0:3CE8 D0               ret  nc
ROM0:3CE9 21 00 A3         ld   hl,A300
ROM0:3CEC FA 08 A7         ld   a,(A708)
ROM0:3CEF BE               cp   (hl)
ROM0:3CF0 D8               ret  c
ROM0:3CF1 FA 0A A7         ld   a,(A70A)
ROM0:3CF4 B7               or   a
ROM0:3CF5 20 06            jr   nz,3CFD
ROM0:3CF7 EA 0B A7         ld   (A70B),a
ROM0:3CFA EA 0C A7         ld   (A70C),a
ROM0:3CFD AF               xor  a
ROM0:3CFE EA 0D A7         ld   (A70D),a
ROM0:3D01 EA 06 A7         ld   (A706),a
ROM0:3D04 CD 1D 3D         call 3D1D
ROM0:3D07 CB 38            srl  b
ROM0:3D09 21 00 A4         ld   hl,A400
ROM0:3D0C DC 1D 3D         call c,3D1D
ROM0:3D0F CB 38            srl  b
ROM0:3D11 21 00 A5         ld   hl,A500
ROM0:3D14 DC 1D 3D         call c,3D1D
ROM0:3D17 CB 38            srl  b
ROM0:3D19 21 00 A6         ld   hl,A600
ROM0:3D1C D0               ret  nc
ROM0:3D1D FA 08 A7         ld   a,(A708)
ROM0:3D20 22               ldi  (hl),a
ROM0:3D21 FA 09 A7         ld   a,(A709)
ROM0:3D24 22               ldi  (hl),a
ROM0:3D25 1A               ld   a,(de)
ROM0:3D26 22               ldi  (hl),a
ROM0:3D27 13               inc  de
ROM0:3D28 1A               ld   a,(de)
ROM0:3D29 13               inc  de
ROM0:3D2A 22               ldi  (hl),a
ROM0:3D2B 3E 01            ld   a,01
ROM0:3D2D 22               ldi  (hl),a
ROM0:3D2E AF               xor  a
ROM0:3D2F 22               ldi  (hl),a
ROM0:3D30 22               ldi  (hl),a
ROM0:3D31 22               ldi  (hl),a
ROM0:3D32 77               ld   (hl),a
ROM0:3D33 2E 14            ld   l,14
ROM0:3D35 77               ld   (hl),a
ROM0:3D36 2E 24            ld   l,24
ROM0:3D38 22               ldi  (hl),a
ROM0:3D39 22               ldi  (hl),a
ROM0:3D3A 22               ldi  (hl),a
ROM0:3D3B 22               ldi  (hl),a
ROM0:3D3C 22               ldi  (hl),a
ROM0:3D3D 22               ldi  (hl),a
ROM0:3D3E 77               ld   (hl),a
ROM0:3D3F 2E 48            ld   l,48
ROM0:3D41 22               ldi  (hl),a
ROM0:3D42 22               ldi  (hl),a
ROM0:3D43 22               ldi  (hl),a
ROM0:3D44 22               ldi  (hl),a
ROM0:3D45 22               ldi  (hl),a
ROM0:3D46 22               ldi  (hl),a
ROM0:3D47 22               ldi  (hl),a
ROM0:3D48 77               ld   (hl),a
ROM0:3D49 2E 1F            ld   l,1F
ROM0:3D4B 22               ldi  (hl),a
ROM0:3D4C 22               ldi  (hl),a
ROM0:3D4D 22               ldi  (hl),a
ROM0:3D4E 77               ld   (hl),a
ROM0:3D4F 2E 51            ld   l,51
ROM0:3D51 22               ldi  (hl),a
ROM0:3D52 22               ldi  (hl),a
ROM0:3D53 22               ldi  (hl),a
ROM0:3D54 22               ldi  (hl),a
ROM0:3D55 22               ldi  (hl),a
ROM0:3D56 22               ldi  (hl),a
ROM0:3D57 77               ld   (hl),a
ROM0:3D58 EA 1C A7         ld   (A71C),a
ROM0:3D5B EA 1B A7         ld   (A71B),a
ROM0:3D5E 3D               dec  a
ROM0:3D5F EA 0F A7         ld   (A70F),a
ROM0:3D62 C9               ret

0:3F11 - Load pointer to Soundtrack from the start of loaded ROM Bank

ROM0:3F11 CB 27            sla  a            ;a = soundtrack_id << 1
ROM0:3F13 06 00            ld   b,00
ROM0:3F15 CB 10            rl   b
ROM0:3F17 4F               ld   c,a
ROM0:3F18 09               add  hl,bc
ROM0:3F19 2A               ldi  a,(hl)
ROM0:3F1A 66               ld   h,(hl)       ;hl = 0x3FFE + [soundtrack_id << 2 | soundtrack_id << 1]
ROM0:3F1B 6F               ld   l,a
ROM0:3F1C C9               ret

Bank 1

1:4004

ROM1:4004 CD 46 6E         call 6E46
ROM1:4007 CD 9C 58         call 589C
ROM1:400A CF               rst  08
=> to 1:40BE

1:40BE

ROM1:40BE FA FE C3         ld   a,(C3FE)
ROM1:40C1 E6 80            and  a,80
ROM1:40C3 C0               ret  nz
ROM1:40C4 CD 33 4E         call 4E33
ROM1:40C7 CD 46 0A         call 0A46
ROM1:40CA 69               ld   l,c
ROM1:40CB 40               ld   b,b
ROM1:40CC 03               inc  bc
ROM1:40CD FE FF            cp   a,FF
ROM1:40CF 28 1B            jr   z,40EC
ROM1:40D1 47               ld   b,a
ROM1:40D2 FA 3F C6         ld   a,(C63F)
ROM1:40D5 E6 F7            and  a,F7
ROM1:40D7 EA 3F C6         ld   (C63F),a
ROM1:40DA FA 32 C4         ld   a,(C432)
ROM1:40DD EA 33 C4         ld   (C433),a
ROM1:40E0 FA 5B C6         ld   a,(C65B)
ROM1:40E3 B8               cp   b
ROM1:40E4 D8               ret  c
ROM1:40E5 FA 5C C6         ld   a,(C65C)
ROM1:40E8 3C               inc  a
ROM1:40E9 C3 3F 40         jp   403F
ROM1:40EC F0 AA            ld   a,(ff00+AA)
ROM1:40EE E6 F0            and  a,F0
ROM1:40F0 28 08            jr   z,40FA
ROM1:40F2 3E 10            ld   a,10
ROM1:40F4 CD 23 40         call 4023
ROM1:40F7 C3 04 40         jp   4004
ROM1:40FA F0 A9            ld   a,(ff00+A9)
ROM1:40FC E6 0F            and  a,0F
ROM1:40FE 28 08            jr   z,4108
ROM1:4100 3E 20            ld   a,20
ROM1:4102 CD 23 40         call 4023
ROM1:4105 C3 04 40         jp   4004
ROM1:4108 FA AF C2         ld   a,(C2AF)
ROM1:410B E6 0F            and  a,0F
ROM1:410D FE 02            cp   a,02
ROM1:410F 28 0F            jr   z,4120
ROM1:4111 FA D6 C2         ld   a,(C2D6)
ROM1:4114 B7               or   a
ROM1:4115 C8               ret  z
ROM1:4116 CD 32 4C         call 4C32
ROM1:4119 CD 46 0A         call 0A46
ROM1:411C ED               -    
ROM1:411D 60               ld   h,b
ROM1:411E 02               ld   (bc),a
ROM1:411F C9               ret

1:4E33

ROM1:4E33 F0 A0            ld   a,(ff00+A0)
ROM1:4E35 E6 1F            and  a,1F
ROM1:4E37 C0               ret  nz
ROM1:4E38 FA B0 C2         ld   a,(C2B0)
ROM1:4E3B E6 F0            and  a,F0
ROM1:4E3D FE 00            cp   a,00
ROM1:4E3F C0               ret  nz
ROM1:4E40 F0 9F            ld   a,(ff00+9F)
ROM1:4E42 E6 20            and  a,20
ROM1:4E44 C0               ret  nz
ROM1:4E45 3E 03            ld   a,03
ROM1:4E47 CD 46 0A         call 0A46
ROM1:4E4A 6A               ld   l,d
ROM1:4E4B 63               ld   h,e
ROM1:4E4C 02               ld   (bc),a
ROM1:4E4D B7               or   a
ROM1:4E4E C0               ret  nz
ROM1:4E4F CD 9E 4E         call 4E9E
ROM1:4E52 B7               or   a
ROM1:4E53 C8               ret  z
ROM1:4E54 CD 46 0A         call 0A46
ROM1:4E57 6A               ld   l,d
ROM1:4E58 63               ld   h,e
ROM1:4E59 02               ld   (bc),a
ROM1:4E5A 21 76 C6         ld   hl,C676
ROM1:4E5D DF               rst  18
ROM1:4E5E 7E               ld   a,(hl)
ROM1:4E5F CD 8C 4E         call 4E8C
ROM1:4E62 CD CB 4E         call 4ECB
ROM1:4E65 B7               or   a
ROM1:4E66 C8               ret  z
ROM1:4E67 47               ld   b,a
ROM1:4E68 3E 03            ld   a,03
ROM1:4E6A CD 46 0A         call 0A46
ROM1:4E6D 6A               ld   l,d
ROM1:4E6E 63               ld   h,e
ROM1:4E6F 02               ld   (bc),a
ROM1:4E70 B7               or   a
ROM1:4E71 3E 00            ld   a,00
ROM1:4E73 20 07            jr   nz,4E7C
ROM1:4E75 78               ld   a,b
ROM1:4E76 CD 46 0A         call 0A46
ROM1:4E79 6A               ld   l,d
ROM1:4E7A 63               ld   h,e
ROM1:4E7B 02               ld   (bc),a
ROM1:4E7C 11 79 C6         ld   de,C679
ROM1:4E7F E7               rst  20
ROM1:4E80 1A               ld   a,(de)
ROM1:4E81 CD FD 4D         call 4DFD
ROM1:4E84 B7               or   a
ROM1:4E85 C0               ret  nz
ROM1:4E86 3E 01            ld   a,01
ROM1:4E88 CD 3D 4F         call 4F3D
ROM1:4E8B C9               ret

1:4E8C

ROM1:4E8C F5               push af
ROM1:4E8D C5               push bc
ROM1:4E8E 01 12 00         ld   bc,0012
ROM1:4E91 21 A3 B0         ld   hl,B0A3
ROM1:4E94 B7               or   a
ROM1:4E95 28 04            jr   z,4E9B
ROM1:4E97 09               add  hl,bc
ROM1:4E98 3D               dec  a
ROM1:4E99 20 FC            jr   nz,4E97
ROM1:4E9B C1               pop  bc
ROM1:4E9C F1               pop  af
ROM1:4E9D C9               ret

1:4F6E

ROM1:4F6E 21 A3 B0         ld   hl,B0A3
ROM1:4F71 06 0B            ld   b,0B         ;b = 11
ROM1:4F73 0E 00            ld   c,00         ;c = 0
ROM1:4F75 7E               ld   a,(hl)
ROM1:4F76 E6 60            and  a,60
ROM1:4F78 FE 60            cp   a,60
ROM1:4F7A 20 10            jr   nz,4F8C      ;if either bits 6 or 7 of sB0A3 are not set, jump to 1:4F8C
ROM1:4F7C CD 9E 4F         call 4F9E
ROM1:4F7F 0C               inc  c
ROM1:4F80 B7               or   a
ROM1:4F81 28 09            jr   z,4F8C
ROM1:4F83 7E               ld   a,(hl)
ROM1:4F84 E6 04            and  a,04
ROM1:4F86 C4 DC 4F         call nz,4FDC
ROM1:4F89 CD DC 4F         call 4FDC
ROM1:4F8C 3E 12            ld   a,12
ROM1:4F8E DF               rst  18           ;hl += 0x12
ROM1:4F8F 05               dec  b            ;b--
ROM1:4F90 20 E3            jr   nz,4F75      ;loop to 1:4F75 if b ≠ 0
ROM1:4F92 79               ld   a,c
ROM1:4F93 B7               or   a
ROM1:4F94 C8               ret  z
ROM1:4F95 FA A1 B0         ld   a,(B0A1)
ROM1:4F98 F6 80            or   a,80
ROM1:4F9A EA A1 B0         ld   (B0A1),a     ;sB0A1 | 0x80
ROM1:4F9D C9               ret

1:4F9E

ROM1:4F9E C5               push bc
ROM1:4F9F D5               push de
ROM1:4FA0 E5               push hl
ROM1:4FA1 CD 27 50         call 5027
ROM1:4FA4 B7               or   a
ROM1:4FA5 28 1A            jr   z,4FC1
ROM1:4FA7 4F               ld   c,a
ROM1:4FA8 7E               ld   a,(hl)
ROM1:4FA9 E6 04            and  a,04
ROM1:4FAB 28 0A            jr   z,4FB7
ROM1:4FAD CD 47 50         call 5047
ROM1:4FB0 CD 47 50         call 5047
ROM1:4FB3 3E 01            ld   a,01
ROM1:4FB5 18 21            jr   4FD8
ROM1:4FB7 79               ld   a,c
ROM1:4FB8 E6 01            and  a,01
ROM1:4FBA CC 47 50         call z,5047
ROM1:4FBD 3E 01            ld   a,01
ROM1:4FBF 18 17            jr   4FD8
ROM1:4FC1 CD 35 50         call 5035
ROM1:4FC4 78               ld   a,b
ROM1:4FC5 B7               or   a
ROM1:4FC6 28 07            jr   z,4FCF
ROM1:4FC8 CD F5 4F         call 4FF5
ROM1:4FCB 3E 01            ld   a,01
ROM1:4FCD 18 09            jr   4FD8
ROM1:4FCF 7E               ld   a,(hl)
ROM1:4FD0 E6 DB            and  a,DB
ROM1:4FD2 77               ld   (hl),a
ROM1:4FD3 3E 11            ld   a,11
ROM1:4FD5 DF               rst  18
ROM1:4FD6 AF               xor  a
ROM1:4FD7 77               ld   (hl),a
ROM1:4FD8 E1               pop  hl
ROM1:4FD9 D1               pop  de
ROM1:4FDA C1               pop  bc
ROM1:4FDB C9               ret

1:5027

ROM1:5027 E5               push hl
ROM1:5028 3E 0F            ld   a,0F
ROM1:502A DF               rst  18
ROM1:502B 7E               ld   a,(hl)
ROM1:502C 3D               dec  a
ROM1:502D 22               ldi  (hl),a
ROM1:502E 46               ld   b,(hl)
ROM1:502F 20 02            jr   nz,5033
ROM1:5031 05               dec  b
ROM1:5032 70               ld   (hl),b
ROM1:5033 E1               pop  hl
ROM1:5034 C9               ret

1:5047

ROM1:5047 E5               push hl
ROM1:5048 3E 06            ld   a,06
ROM1:504A DF               rst  18
ROM1:504B 46               ld   b,(hl)
ROM1:504C 3E 07            ld   a,07
ROM1:504E DF               rst  18
ROM1:504F 78               ld   a,b
ROM1:5050 B7               or   a
ROM1:5051 28 08            jr   z,505B
ROM1:5053 3D               dec  a
ROM1:5054 28 0A            jr   z,5060
ROM1:5056 3D               dec  a
ROM1:5057 28 0D            jr   z,5066
ROM1:5059 18 10            jr   506B
ROM1:505B 7E               ld   a,(hl)
ROM1:505C 3D               dec  a
ROM1:505D 77               ld   (hl),a
ROM1:505E 18 0F            jr   506F
ROM1:5060 23               inc  hl
ROM1:5061 7E               ld   a,(hl)
ROM1:5062 3C               inc  a
ROM1:5063 77               ld   (hl),a
ROM1:5064 18 09            jr   506F
ROM1:5066 7E               ld   a,(hl)
ROM1:5067 3C               inc  a
ROM1:5068 77               ld   (hl),a
ROM1:5069 18 04            jr   506F
ROM1:506B 23               inc  hl
ROM1:506C 7E               ld   a,(hl)
ROM1:506D 3D               dec  a
ROM1:506E 77               ld   (hl),a
ROM1:506F E1               pop  hl
ROM1:5070 C9               ret

Star Chips

Return number of Star Chips owned

ROM1:551C FA ED C2         ld   a,(C2ED)    ;a = star_chips
ROM1:551F C9               ret

Add 1 Star Chip

ROM1:5520 FA ED C2         ld   a,(C2ED)
ROM1:5523 FE 63            cp   a,63
ROM1:5525 D0               ret  nc          ;if (star_chips ≥ 99), exit
ROM1:5526 3C               inc  a           ;star_chips++
ROM1:5527 EA ED C2         ld   (C2ED),a    ;Store star_chips in wC2ED
ROM1:552A C9               ret

Remove 1 Star Chip

ROM1:552B FA ED C2         ld   a,(C2ED)
ROM1:552E FE 02            cp   a,02
ROM1:5530 D8               ret  c             ;if (star_chips < 2), exit
ROM1:5531 3D               dec  a             ;star_chips--
ROM1:5532 EA ED C2         ld   (C2ED),a      ;Store star_chips in wC2ED
ROM1:5535 C9               ret

1:589C - Compare wC2B0 with wC2B1, adjusts flags in wC2B2

ROM1:589C FA B0 C2         ld   a,(C2B0)
ROM1:589F 47               ld   b,a
ROM1:58A0 FA B1 C2         ld   a,(C2B1)
ROM1:58A3 B8               cp   b
ROM1:58A4 28 0A            jr   z,58B0
ROM1:58A6 FA B2 C2         ld   a,(C2B2)
ROM1:58A9 F6 20            or   a,20
ROM1:58AB EA B2 C2         ld   (C2B2),a     ;wC2B2 | 0x20
ROM1:58AE 18 08            jr   58B8
ROM1:58B0 FA B2 C2         ld   a,(C2B2)
ROM1:58B3 E6 DF            and  a,DF
ROM1:58B5 EA B2 C2         ld   (C2B2),a     ;wC2B2 & 0xDF
ROM1:58B8 78               ld   a,b
ROM1:58B9 EA B1 C2         ld   (C2B1),a     ;wC2B1 = wC2B0
ROM1:58BC CB 37            swap a
ROM1:58BE E6 0F            and  a,0F
ROM1:58C0 C9               ret

1:6E46

ROM1:6E46 FA FE C3         ld   a,(C3FE)
ROM1:6E49 47               ld   b,a
ROM1:6E4A E6 80            and  a,80          ;a = wC3FE & 0x80
ROM1:6E4C C8               ret  z
ROM1:6E4D 78               ld   a,b
ROM1:6E4E E6 40            and  a,40          ;a = wC3FE & 0x40
ROM1:6E50 C2 56 6E         jp   nz,6E56
ROM1:6E53 CD 6A 34         call 346A
ROM1:6E56 C3 59 6E         jp   6E59
ROM1:6E59 FA 13 C4         ld   a,(C413)      ;a = wC413
ROM1:6E5C FE FF            cp   a,FF
ROM1:6E5E 28 05            jr   z,6E65
ROM1:6E60 FE FE            cp   a,FE
ROM1:6E62 C8               ret  z
ROM1:6E63 18 09            jr   6E6E
ROM1:6E65 FA FE C3         ld   a,(C3FE)
ROM1:6E68 CB BF            res  7,a
ROM1:6E6A EA FE C3         ld   (C3FE),a      ;unset bit 7 on wC3FE
ROM1:6E6D C9               ret  

1:7A2A - Attempts to remove 1 Star Chip, then wC418++

ROM1:7A2A CD 2B 55         call 552B          ;Remove 1 Star Chip
ROM1:7A2D 38 03            jr   c,7A32        ;if the Star Chip could not be removed, skip next instruction
ROM1:7A2F C3 75 7F         jp   7F75          ;wC418++, and exit
ROM1:7A32 3E 04            ld   a,04
ROM1:7A34 06 01            ld   b,01
ROM1:7A36 CD 46 0A         call 0A46
ROM1:7A39 D2 48 03         jp   nc,0348
ROM1:7A3C FA 18 C4         ld   a,(C418)
ROM1:7A3F C6 05            add  a,05
ROM1:7A41 EA 18 C4         ld   (C418),a      ;wC418 += 5
ROM1:7A44 C9               ret

1:7F75 - wC418++

ROM1:7F75 FA 18 C4         ld   a,(C418)
ROM1:7F78 3C               inc  a
ROM1:7F79 EA 18 C4         ld   (C418),a
ROM1:7F7C C9               ret

Bank 3

Sound Test - load Sound Track

ROM3:5222 AF               xor  a                ;soundtrack_id = 0
ROM3:5223 CD 77 3B         call 3B77
ROM3:5226 CD BA 02         call 02BA
ROM3:5229 F0 88            ld   a,(ff00+88)      ;a = soundtrack_id
ROM3:522B CD 77 3B         call 3B77
ROM3:522E C9               ret

Sound Test - load Sound Effect

ROM3:522F F0 89            ld   a,(ff00+89)      ;a = sound_effect_id
ROM3:5231 CD 77 3B         call 3B77
ROM3:5234 C9               ret

Bank 8

8:4E95

ROM8:4E95 CD F6 56         call 56F6          ;00s battle values in wC7E1-wC7F9 area
ROM8:4E98 CD 65 56         call 5665          ;00s battle values in wC69A-wC6BE area
ROM8:4E9B CD AF 62         call 62AF
ROM8:4E9E FA A6 C7         ld   a,(C7A6)
ROM8:4EA1 CD 42 55         call 5542
ROM8:4EA4 CD 36 5A         call 5A36
ROM8:4EA7 FA F9 C7         ld   a,(C7F9)
ROM8:4EAA EA FA C7         ld   (C7FA),a
ROM8:4EAD FA A5 C7         ld   a,(C7A5)
ROM8:4EB0 CB 87            res  0,a
ROM8:4EB2 EA A5 C7         ld   (C7A5),a
ROM8:4EB5 FA 83 C7         ld   a,(C783)
ROM8:4EB8 3C               inc  a
ROM8:4EB9 EA 83 C7         ld   (C783),a
ROM8:4EBC AF               xor  a
ROM8:4EBD EA 84 C7         ld   (C784),a
ROM8:4EC0 18 00            jr   4EC2
ROM8:4EC2 C9               ret

00s battle values in wC69A-wC6BE area

  • 0x21665 - Initializes battle values, including the probability to hit.
ROM8:5665 F5               push af
ROM8:5666 C5               push bc
ROM8:5667 E5               push hl
ROM8:5668 21 9A C6         ld   hl,C69A
ROM8:566B AF               xor  a
ROM8:566C 06 24            ld   b,24
ROM8:566E 22               ldi  (hl),a
ROM8:566F 05               dec  b
ROM8:5670 20 FC            jr   nz,566E
ROM8:5672 E1               pop  hl
ROM8:5673 C1               pop  bc
ROM8:5674 F1               pop  af
ROM8:5675 C9               ret

00s battle values in wC7E1-wC7F9 area

ROM8:56F6 F5               push af
ROM8:56F7 C5               push bc
ROM8:56F8 E5               push hl
ROM8:56F9 21 E1 C7         ld   hl,C7E1
ROM8:56FC AF               xor  a
ROM8:56FD 06 18            ld   b,18
ROM8:56FF 22               ldi  (hl),a
ROM8:5700 05               dec  b
ROM8:5701 20 FC            jr   nz,56FF          ;loop 24 times
ROM8:5703 E1               pop  hl
ROM8:5704 C1               pop  bc
ROM8:5705 F1               pop  af
ROM8:5706 C9               ret  

8:62AF - call 8:6339, set wC732 to 0

ROM8:62AF F5               push af
ROM8:62B0 C5               push bc
ROM8:62B1 D5               push de
ROM8:62B2 E5               push hl
ROM8:62B3 CD 39 63         call 6339
ROM8:62B6 AF               xor  a
ROM8:62B7 EA 32 C7         ld   (C732),a
ROM8:62BA E1               pop  hl
ROM8:62BB D1               pop  de
ROM8:62BC C1               pop  bc
ROM8:62BD F1               pop  af
ROM8:62BE C9               ret  

8:6339

ROM8:6339 06 1B            ld   b,1B
ROM8:633B FA 33 C7         ld   a,(C733)
ROM8:633E FE 02            cp   a,02
ROM8:6340 20 02            jr   nz,6344
ROM8:6342 06 24            ld   b,24
ROM8:6344 FA 34 C7         ld   a,(C734)
ROM8:6347 26 C0            ld   h,C0
ROM8:6349 6F               ld   l,a
ROM8:634A AF               xor  a
ROM8:634B 22               ldi  (hl),a
ROM8:634C 23               inc  hl
ROM8:634D 23               inc  hl
ROM8:634E 23               inc  hl
ROM8:634F 05               dec  b
ROM8:6350 20 F9            jr   nz,634B
ROM8:6352 C9               ret

Bank 18

Title screen

Checks button pressed

RO18:4AF5 5F               ld   e,a
RO18:4AF6 71               ld   (hl),c
RO18:4AF7 1A               ld   a,(de)
RO18:4AF8 7F               ld   a,a
RO18:4AF9 72               ld   (hl),d
RO18:4AFA EA 49 1A         ld   (1A49),a
RO18:4AFD 21 84 03         ld   hl,0384
RO18:4B00 CD 1D 46         call 461D
RO18:4B03 21 09 4B         ld   hl,4B09
RO18:4B06 CD DD 45         call 45DD
RO18:4B09 F0 AA            ld   a,(ff00+AA)
RO18:4B0B E6 90            and  a,90
RO18:4B0D 20 0A            jr   nz,4B19          ;if(button == A || button == Start), jump to 18:4B19
RO18:4B0F CD 26 46         call 4626
RO18:4B12 C0               ret  nz
RO18:4B13 3E 01            ld   a,01
RO18:4B15 EA 01 C2         ld   (C201),a
RO18:4B18 C9               ret  

Button A or Start pressed

RO18:4B19 3E DC            ld   a,DC
RO18:4B1B CD 77 3B         call 3B77
RO18:4B1E AF               xor  a
RO18:4B1F CD 67 4B         call 4B67
RO18:4B22 21 05 00         ld   hl,0005
RO18:4B25 CD 22 47         call 4722
RO18:4B28 3E 01            ld   a,01
RO18:4B2A CD 67 4B         call 4B67
RO18:4B2D 21 05 00         ld   hl,0005
RO18:4B30 CD 22 47         call 4722
RO18:4B33 06 08            ld   b,08
RO18:4B35 21 C8 49         ld   hl,49C8
RO18:4B38 CD D0 15         call 15D0
RO18:4B3B 3E 00            ld   a,00
RO18:4B3D E0 9C            ld   (ff00+9C),a
RO18:4B3F 21 04 00         ld   hl,0004
RO18:4B42 CD 22 47         call 4722
RO18:4B45 AF               xor  a
RO18:4B46 CD 67 4B         call 4B67
RO18:4B49 21 01 00         ld   hl,0001
RO18:4B4C CD 22 47         call 4722
RO18:4B4F 06 08            ld   b,08
RO18:4B51 21 FA 4A         ld   hl,4AFA
RO18:4B54 CD D0 15         call 15D0
RO18:4B57 3E E4            ld   a,E4
RO18:4B59 E0 9C            ld   (ff00+9C),a
RO18:4B5B 21 39 00         ld   hl,0039
RO18:4B5E CD 22 47         call 4722
RO18:4B61 3E 04            ld   a,04
RO18:4B63 EA 01 C2         ld   (C201),a
RO18:4B66 C9               ret