Yu-Gi-Oh! Duel Monsters II: Dark Duel Stories/ROM map

From Data Crystal
Jump to navigation Jump to search

Chip tiny.png The following article is a ROM map for Yu-Gi-Oh! Duel Monsters II: Dark Duel Stories.

Bank 0

rst

rst 00

ROM0:0000 F3               di
ROM0:0001 C3 9B 17         jp   179B

rst 08

ROM0:0008 C3 D5 11         jp   11D5          ;rst 08 instructions

rst 10 (error trap)

ROM0:0010 18 FE            jr   0010

rst 18 (error trap)

ROM0:0018 18 FE            jr   0018

rst 20 (error trap)

ROM0:0020 18 FE            jr   0020

rst 28 (error trap)

ROM0:0028 18 FE            jr   0028

rst 30 (error trap)

ROM0:0030 18 FE            jr   0030

rst 38 (error trap)

ROM0:0038 18 FE            jr   0038

rst 40 (vblank)

ROM0:0040 C3 36 04         jp   0436

rst 48 (LCD)

ROM0:0048 C3 0F DD         jp   DD0F

rst 50 (timer)

ROM0:0050 C3 2C 17         jp   172C

rst 58 (serial)

ROM0:0058 C3 EC 01         jp   01EC

rst 60 (joypad)

ROM0:0060 18 FE            jr   0060

ROM start

ROM0:0100 00               nop
ROM0:0101 C3 50 01         jp   0150
ROM0:0150 E0 DD            ld   (ff00+DD),a	// System running the game
ROM0:0152 21 00 D0         ld   hl,D000
ROM0:0155 F9               ld   sp,hl
ROM0:0156 21 A0 D5         ld   hl,D5A0
ROM0:0159 11 00 00         ld   de,0000
ROM0:015C 0E 00            ld   c,00
ROM0:015E 1A               ld   a,(de)
ROM0:015F 22               ldi  (hl),a
ROM0:0160 13               inc  de
ROM0:0161 0D               dec  c
ROM0:0162 20 FA            jr   nz,015E
ROM0:0164 0E 00            ld   c,00
ROM0:0166 1A               ld   a,(de)
ROM0:0167 22               ldi  (hl),a
ROM0:0168 13               inc  de
ROM0:0169 0D               dec  c
ROM0:016A 20 FA            jr   nz,0166
ROM0:016C 0E 00            ld   c,00
ROM0:016E 1A               ld   a,(de)
ROM0:016F 22               ldi  (hl),a
ROM0:0170 13               inc  de
ROM0:0171 0D               dec  c
ROM0:0172 20 FA            jr   nz,016E
ROM0:0174 CD 22 12         call 1222		// Initialize Bank, enable Interrupts
ROM0:0177 CF               rst  08
ROM0:0178 07               rlca
ROM0:0179 04               inc  b
ROM0:017A CD F5 31         call 31F5		// (DD07) = 0
ROM0:017D 3E 00            ld   a,00
ROM0:017F CF               rst  08

Wait for vblank

  • 0x436-0x45E - Wait for vblank
ROM0:0436 F5               push af
ROM0:0437 E5               push hl
ROM0:0438 C5               push bc
ROM0:0439 D5               push de
ROM0:043A 06 00            ld   b,00
ROM0:043C FA 7D D8         ld   a,(D87D)
ROM0:043F 4F               ld   c,a
ROM0:0440 21 48 04         ld   hl,0448
ROM0:0443 09               add  hl,bc
ROM0:0444 2A               ldi  a,(hl)
ROM0:0445 66               ld   h,(hl)
ROM0:0446 6F               ld   l,a
ROM0:0447 E9               jp   hl
ROM0:0448 66               ld   h,(hl)
ROM0:0449 04               inc  b
ROM0:044A 7F               ld   a,a
ROM0:044B 04               inc  b
ROM0:044C A5               and  l
ROM0:044D 04               inc  b
ROM0:044E CE 04            adc  a,04
ROM0:0450 41               ld   b,c
ROM0:0451 05               dec  b
ROM0:0452 F0 06            ld   a,(ff00+06)		// TIMEMOD
ROM0:0454 48               ld   c,b
ROM0:0455 08 22 09         ld   (0922),sp
ROM0:0458 68               ld   l,b
ROM0:0459 0A               ld   a,(bc)
ROM0:045A C0               ret  nz
ROM0:045B 0B               dec  bc
ROM0:045C 61               ld   h,c
ROM0:045D 0C               inc  c
ROM0:045E C3 30 4C         jp   4C30

0:0F16 (called by Main Menu)

  • 0xF16-0xF33 - ? (called by Main Menu)
ROM0:0F16 F5               push af
ROM0:0F17 C5               push bc
ROM0:0F18 E5               push hl
ROM0:0F19 EA 7C D8         ld   (D87C),a
ROM0:0F1C 4F               ld   c,a
ROM0:0F1D 06 00            ld   b,00
ROM0:0F1F 21 34 0F         ld   hl,0F34
ROM0:0F22 09               add  hl,bc
ROM0:0F23 2A               ldi  a,(hl)
ROM0:0F24 66               ld   h,(hl)
ROM0:0F25 6F               ld   l,a
ROM0:0F26 01 2B 0F         ld   bc,0F2B
ROM0:0F29 C5               push bc
ROM0:0F2A E9               jp   hl
ROM0:0F2B 3E 00            ld   a,00
ROM0:0F2D EA 7B D8         ld   (D87B),a
ROM0:0F30 E1               pop  hl
ROM0:0F31 C1               pop  bc
ROM0:0F32 F1               pop  af
ROM0:0F33 C9               ret

0:1107 (call 0:1881)

ROM0:1107 F5               push af
ROM0:1108 CD 81 18         call 1881
          80 E4

0:110D (reti from 0:1881)

ROM0:110D CD 9B 17         call 179B
ROM0:1110 CD 60 18         call 1860
          80 E4
ROM0:1115 28 F6            jr   z,110D
ROM0:1117 F1               pop  af
ROM0:1118 C9               ret

rst 08 instructions

  • 0x11D5-0x120A - rst 08 jumps here: bank switch, load pointer to next instructions
ROM0:11D5 F5               push af
ROM0:11D6 E8 FD            add  sp,FD
ROM0:11D8 F5               push af
ROM0:11D9 E5               push hl
ROM0:11DA C5               push bc
ROM0:11DB D5               push de
ROM0:11DC F8 06            ld   hl,sp+06
ROM0:11DE 54               ld   d,h
ROM0:11DF 5D               ld   e,l
ROM0:11E0 F8 0E            ld   hl,sp+0E
ROM0:11E2 3A               ldd  a,(hl)
ROM0:11E3 47               ld   b,a
ROM0:11E4 3A               ldd  a,(hl)
ROM0:11E5 4F               ld   c,a
ROM0:11E6 FA 00 40         ld   a,(4000)	// Load current Bank in accumulator
ROM0:11E9 32               ldd  (hl),a
ROM0:11EA 7E               ld   a,(hl)
ROM0:11EB 12               ld   (de),a
ROM0:11EC 3E 12            ld   a,12
ROM0:11EE 32               ldd  (hl),a
ROM0:11EF 3E 0B            ld   a,0B
ROM0:11F1 32               ldd  (hl),a
ROM0:11F2 0A               ld   a,(bc)
ROM0:11F3 5F               ld   e,a
ROM0:11F4 03               inc  bc
ROM0:11F5 16 40            ld   d,40
ROM0:11F7 0A               ld   a,(bc)
ROM0:11F8 03               inc  bc
ROM0:11F9 EA 00 20         ld   (2000),a	// Bank switch
ROM0:11FC 1A               ld   a,(de)
ROM0:11FD 32               ldd  (hl),a
ROM0:11FE 1D               dec  e
ROM0:11FF 1A               ld   a,(de)
ROM0:1200 77               ld   (hl),a		// Address to return to
ROM0:1201 F8 0D            ld   hl,sp+0D
ROM0:1203 79               ld   a,c
ROM0:1204 22               ldi  (hl),a
ROM0:1205 70               ld   (hl),b
ROM0:1206 D1               pop  de
ROM0:1207 C1               pop  bc
ROM0:1208 E1               pop  hl
ROM0:1209 F1               pop  af
ROM0:120A C9               ret

Initialize Bank and enable Interrupts

ROM0:1222 F5               push af
ROM0:1223 F3               di
ROM0:1224 3E 00            ld   a,00
ROM0:1226 EA 00 20         ld   (2000),a		;ROM Bank 0
ROM0:1229 3E 00            ld   a,00
ROM0:122B EA 00 30         ld   (3000),a
ROM0:122E 3E 00            ld   a,00
ROM0:1230 EA 00 40         ld   (4000),a		;RAM Bank 0
ROM0:1233 3E 00            ld   a,00
ROM0:1235 E0 4F            ld   (ff00+4F),a
ROM0:1237 FB               ei
ROM0:1238 F1               pop  af
ROM0:1239 C9               ret

Bank switch

  • 0x123A-0x123D - Bank switch
ROM0:123A EA 00 20         ld   (2000),a
ROM0:123D C9               ret

0:13BE (to document)

  • 0x13BE-0x13E3 - ?
ROM0:13BE F5               push af
ROM0:13BF E5               push hl
ROM0:13C0 D5               push de
ROM0:13C1 16 00            ld   d,00
ROM0:13C3 CB 23            sla  e
ROM0:13C5 CB 23            sla  e
ROM0:13C7 21 00 D5         ld   hl,D500
ROM0:13CA 19               add  hl,de		// hl = D500 + (e × 4)
ROM0:13CB D1               pop  de
ROM0:13CC 79               ld   a,c
ROM0:13CD 22               ldi  (hl),a
ROM0:13CE 78               ld   a,b
ROM0:13CF 22               ldi  (hl),a
ROM0:13D0 7A               ld   a,d
ROM0:13D1 22               ldi  (hl),a
ROM0:13D2 3E 00            ld   a,00
ROM0:13D4 22               ldi  (hl),a
ROM0:13D5 79               ld   a,c
ROM0:13D6 22               ldi  (hl),a
ROM0:13D7 78               ld   a,b
ROM0:13D8 C6 08            add  a,08
ROM0:13DA 22               ldi  (hl),a
ROM0:13DB 7A               ld   a,d
ROM0:13DC C6 02            add  a,02
ROM0:13DE 22               ldi  (hl),a
ROM0:13DF 36 00            ld   (hl),00
ROM0:13E1 E1               pop  hl
ROM0:13E2 F1               pop  af
ROM0:13E3 C9               ret

Alt PRNG

  • 0x1403-0x1419 - ?
ROM0:1403 F5               push af
ROM0:1404 C5               push bc
ROM0:1405 1E 00            ld   e,00
ROM0:1407 0E 08            ld   c,08
ROM0:1409 CB 22            sla  d
ROM0:140B CB 13            rl   e
ROM0:140D 7B               ld   a,e
ROM0:140E B8               cp   b
ROM0:140F 38 03            jr   c,1414
ROM0:1411 90               sub  b
ROM0:1412 5F               ld   e,a
ROM0:1413 14               inc  d
ROM0:1414 0D               dec  c
ROM0:1415 20 F2            jr   nz,1409
ROM0:1417 C1               pop  bc
ROM0:1418 F1               pop  af
ROM0:1419 C9               ret

0:141A

ROM0:141A F5               push af
ROM0:141B C5               push bc
ROM0:141C E5               push hl
ROM0:141D 62               ld   h,d
ROM0:141E 6B               ld   l,e
ROM0:141F 11 00 00         ld   de,0000
ROM0:1422 3E 10            ld   a,10
ROM0:1424 F5               push af
ROM0:1425 CB 25            sla  l
ROM0:1427 CB 14            rl   h
ROM0:1429 CB 13            rl   e
ROM0:142B CB 12            rl   d
ROM0:142D CD A7 1D         call 1DA7
ROM0:1430 FE 00            cp   a,00
ROM0:1432 28 06            jr   z,143A
ROM0:1434 7B               ld   a,e
ROM0:1435 91               sub  c
ROM0:1436 5F               ld   e,a
ROM0:1437 7A               ld   a,d
ROM0:1438 98               sbc  b
ROM0:1439 57               ld   d,a
ROM0:143A F1               pop  af
ROM0:143B 3D               dec  a
ROM0:143C 20 E6            jr   nz,1424
ROM0:143E E1               pop  hl
ROM0:143F C1               pop  bc
ROM0:1440 F1               pop  af
ROM0:1441 C9               ret

0:1442

ROM0:1442 F5               push af
ROM0:1443 C5               push bc
ROM0:1444 E5               push hl
ROM0:1445 21 00 00         ld   hl,0000
ROM0:1448 3E 10            ld   a,10
ROM0:144A F5               push af
ROM0:144B CB 23            sla  e
ROM0:144D CB 12            rl   d
ROM0:144F CB 15            rl   l
ROM0:1451 CB 14            rl   h
ROM0:1453 7C               ld   a,h
ROM0:1454 B8               cp   b
ROM0:1455 38 19            jr   c,1470
ROM0:1457 7C               ld   a,h
ROM0:1458 B8               cp   b
ROM0:1459 20 0D            jr   nz,1468
ROM0:145B 7D               ld   a,l
ROM0:145C B9               cp   c
ROM0:145D 38 07            jr   c,1466
ROM0:145F 91               sub  c
ROM0:1460 6F               ld   l,a
ROM0:1461 7C               ld   a,h
ROM0:1462 98               sbc  b
ROM0:1463 67               ld   h,a
ROM0:1464 CB C3            set  0,e
ROM0:1466 18 08            jr   1470
ROM0:1468 7D               ld   a,l
ROM0:1469 91               sub  c
ROM0:146A 6F               ld   l,a
ROM0:146B 7C               ld   a,h
ROM0:146C 98               sbc  b
ROM0:146D 67               ld   h,a
ROM0:146E CB C3            set  0,e
ROM0:1470 F1               pop  af
ROM0:1471 3D               dec  a
ROM0:1472 20 D6            jr   nz,144A
ROM0:1474 E1               pop  hl
ROM0:1475 C1               pop  bc
ROM0:1476 F1               pop  af
ROM0:1477 C9               ret


0:1478

ROM0:1478 F5               push af
ROM0:1479 C5               push bc
ROM0:147A D5               push de
ROM0:147B 16 00            ld   d,00
ROM0:147D 21 00 00         ld   hl,0000
ROM0:1480 0E 08            ld   c,08
ROM0:1482 CB 38            srl  b              ;loop start
ROM0:1484 30 01            jr   nc,1487
ROM0:1486 19               add  hl,de
ROM0:1487 CB 23            sla  e
ROM0:1489 CB 12            rl   d
ROM0:148B 0D               dec  c
ROM0:148C 20 F4            jr   nz,1482        ;loop 8 times
ROM0:148E D1               pop  de
ROM0:148F C1               pop  bc
ROM0:1490 F1               pop  af
ROM0:1491 C9               ret

? operation

  • 0x14A2-0x14C1 - ? operation
ROM0:14A2 F5               push af
ROM0:14A3 78               ld   a,b
ROM0:14A4 BA               cp   d
ROM0:14A5 20 0B            jr   nz,14B2		// If(PRN ≠ b), jump to 0:14B2
ROM0:14A7 79               ld   a,c
ROM0:14A8 BB               cp   e
ROM0:14A9 20 07            jr   nz,14B2		// If(e ≠ c), jump to 0:14B2
ROM0:14AB 01 00 00         ld   bc,0000
ROM0:14AE 1E 01            ld   e,01
ROM0:14B0 18 0E            jr   14C0		// Else bc = 0, e = 1, and get out of this function
ROM0:14B2 7B               ld   a,e
ROM0:14B3 91               sub  c
ROM0:14B4 27               daa
ROM0:14B5 4F               ld   c,a
ROM0:14B6 7A               ld   a,d
ROM0:14B7 98               sbc  b
ROM0:14B8 27               daa
ROM0:14B9 47               ld   b,a		// b = PRN - ((max - min) + 1)
ROM0:14BA 1E 02            ld   e,02
ROM0:14BC 30 02            jr   nc,14C0
ROM0:14BE 1E 00            ld   e,00
ROM0:14C0 F1               pop  af
ROM0:14C1 C9               ret

0:179B (to document)

  • 0x179B-0x180A - ?
ROM0:179B E5               push hl
ROM0:179C 21 FF FF         ld   hl,FFFF
ROM0:179F CB 96            res  2,(hl)
ROM0:17A1 F5               push af
ROM0:17A2 C5               push bc
ROM0:17A3 D5               push de
ROM0:17A4 F3               di
ROM0:17A5 F0 DF            ld   a,(ff00+DF)
ROM0:17A7 4F               ld   c,a
ROM0:17A8 D6 E0            sub  a,E0
ROM0:17AA 47               ld   b,a
ROM0:17AB 07               rlca
ROM0:17AC 80               add  b
ROM0:17AD 5F               ld   e,a
ROM0:17AE 3E 00            ld   a,00
ROM0:17B0 E2               ld   (ff00+c),a
ROM0:17B1 0C               inc  c
ROM0:17B2 79               ld   a,c
ROM0:17B3 FE E4            cp   a,E4
ROM0:17B5 20 02            jr   nz,17B9
ROM0:17B7 0E E0            ld   c,E0
ROM0:17B9 F2               ld   a,(ff00+c)
ROM0:17BA FE 01            cp   a,01
ROM0:17BC 20 F3            jr   nz,17B1
ROM0:17BE 79               ld   a,c
ROM0:17BF E0 DF            ld   (ff00+DF),a
ROM0:17C1 3E 02            ld   a,02
ROM0:17C3 E2               ld   (ff00+c),a
ROM0:17C4 3E E8            ld   a,E8
ROM0:17C6 83               add  e
ROM0:17C7 4F               ld   c,a
ROM0:17C8 F8 00            ld   hl,sp+00
ROM0:17CA 7D               ld   a,l
ROM0:17CB E2               ld   (ff00+c),a
ROM0:17CC 0C               inc  c
ROM0:17CD 7C               ld   a,h
ROM0:17CE E2               ld   (ff00+c),a
ROM0:17CF 0C               inc  c
ROM0:17D0 FA 00 40         ld   a,(4000)
ROM0:17D3 E2               ld   (ff00+c),a
ROM0:17D4 F0 DF            ld   a,(ff00+DF)
ROM0:17D6 D6 E0            sub  a,E0
ROM0:17D8 47               ld   b,a
ROM0:17D9 07               rlca
ROM0:17DA 80               add  b
ROM0:17DB 5F               ld   e,a
ROM0:17DC C6 E8            add  a,E8
ROM0:17DE 4F               ld   c,a
ROM0:17DF F2               ld   a,(ff00+c)
ROM0:17E0 6F               ld   l,a
ROM0:17E1 0C               inc  c
ROM0:17E2 F2               ld   a,(ff00+c)
ROM0:17E3 67               ld   h,a
ROM0:17E4 F9               ld   sp,hl
ROM0:17E5 0C               inc  c
ROM0:17E6 F2               ld   a,(ff00+c)
ROM0:17E7 EA 00 20         ld   (2000),a
ROM0:17EA 16 00            ld   d,00
ROM0:17EC 21 EF 16         ld   hl,16EF
ROM0:17EF 19               add  hl,de
ROM0:17F0 7E               ld   a,(hl)
ROM0:17F1 E0 05            ld   (ff00+05),a		// TIMECNT
ROM0:17F3 2A               ldi  a,(hl)
ROM0:17F4 E0 06            ld   (ff00+06),a		// TIMEMOD
ROM0:17F6 2A               ldi  a,(hl)
ROM0:17F7 E0 07            ld   (ff00+07),a		// TIMCONT
ROM0:17F9 7E               ld   a,(hl)
ROM0:17FA E0 07            ld   (ff00+07),a
ROM0:17FC D1               pop  de
ROM0:17FD C1               pop  bc
ROM0:17FE F1               pop  af
ROM0:17FF 21 0F FF         ld   hl,FF0F
ROM0:1802 CB 96            res  2,(hl)
ROM0:1804 2E FF            ld   l,FF
ROM0:1806 CB D6            set  2,(hl)
ROM0:1808 E1               pop  hl
ROM0:1809 D9               reti
ROM0:180A C9               ret

0:1832 (error trap)

ROM0:1832 18 FE            jr   1832

0:1881

ROM0:1881 F5               push af
ROM0:1882 C5               push bc
ROM0:1883 D5               push de
ROM0:1884 E5               push hl
ROM0:1885 F8 08            ld   hl,sp+08
ROM0:1887 2A               ldi  a,(hl)
ROM0:1888 5F               ld   e,a
ROM0:1889 56               ld   d,(hl)
ROM0:188A 1A               ld   a,(de)
ROM0:188B 47               ld   b,a
ROM0:188C 13               inc  de
ROM0:188D 1A               ld   a,(de)
ROM0:188E 4F               ld   c,a
ROM0:188F 13               inc  de
ROM0:1890 7A               ld   a,d
ROM0:1891 32               ldd  (hl),a
ROM0:1892 73               ld   (hl),e
ROM0:1893 F3               di
ROM0:1894 3E FF            ld   a,FF
ROM0:1896 A8               xor  b
ROM0:1897 47               ld   b,a
ROM0:1898 F2               ld   a,(ff00+c)
ROM0:1899 A0               and  b
ROM0:189A E2               ld   (ff00+c),a
ROM0:189B E1               pop  hl
ROM0:189C D1               pop  de
ROM0:189D C1               pop  bc
ROM0:189E F1               pop  af
ROM0:189F D9               reti
ROM0:18A0 C9               ret

Updates current Row and Column with bc

  • 0x1CE4-0x1CEE - Updates current Row and Column with registers bc
ROM0:1CE4 F5               push af
ROM0:1CE5 78               ld   a,b
ROM0:1CE6 EA 6B DA         ld   (DA6B),a
ROM0:1CE9 79               ld   a,c
ROM0:1CEA EA 6C DA         ld   (DA6C),a
ROM0:1CED F1               pop  af
ROM0:1CEE C9               ret

Write Fusion Monster ID to the selected area

ROM0:1D0F F5               push af
ROM0:1D10 C5               push bc
ROM0:1D11 E5               push hl
ROM0:1D12 CD 4A 1D         call 1D4A
ROM0:1D15 60               ld   h,b
ROM0:1D16 69               ld   l,c
ROM0:1D17 FA 6D DA         ld   a,(DA6D)
ROM0:1D1A 22               ldi  (hl),a       ;Copy monster ID from wDA6D to the selected area
ROM0:1D1B FA 6E DA         ld   a,(DA6E)
ROM0:1D1E 22               ldi  (hl),a
ROM0:1D1F FA 6F DA         ld   a,(DA6F)
ROM0:1D22 22               ldi  (hl),a       ;Copy card flags from wDA6F to the selected area
ROM0:1D23 E1               pop  hl
ROM0:1D24 C1               pop  bc
ROM0:1D25 F1               pop  af
ROM0:1D26 C9               ret
ROM0:1D27 F5               push af
ROM0:1D28 C5               push bc
ROM0:1D29 E5               push hl
ROM0:1D2A CD 4A 1D         call 1D4A
ROM0:1D2D 60               ld   h,b

Updates current card ID + status

ROM0:1D2E 69               ld   l,c
ROM0:1D2F 2A               ldi  a,(hl)
ROM0:1D30 EA 6D DA         ld   (DA6D),a
ROM0:1D33 2A               ldi  a,(hl)
ROM0:1D34 EA 6E DA         ld   (DA6E),a
ROM0:1D37 2A               ldi  a,(hl)
ROM0:1D38 EA 6F DA         ld   (DA6F),a
ROM0:1D3B E1               pop  hl
ROM0:1D3C C1               pop  bc
ROM0:1D3D F1               pop  af
ROM0:1D3E C9               ret

Call Fusion check

ROM0:1D3F F5               push af
ROM0:1D40 C5               push bc
ROM0:1D41 CF               rst  08
ROM0:1D42 05               dec  b
ROM0:1D43 09               add  hl,bc
ROM0:1D44 CD 0F 1D         call 1D0F
ROM0:1D47 C1               pop  bc
ROM0:1D48 F1               pop  af
ROM0:1D49 C9               ret

0:1D4A

ROM0:1D4A F5               push af
ROM0:1D4B E5               push hl
ROM0:1D4C 06 00            ld   b,00
ROM0:1D4E FA 6C DA         ld   a,(DA6C)
ROM0:1D51 4F               ld   c,a
ROM0:1D52 CB 21            sla  c
ROM0:1D54 21 72 1D         ld   hl,1D72
ROM0:1D57 09               add  hl,bc
ROM0:1D58 2A               ldi  a,(hl)
ROM0:1D59 66               ld   h,(hl)
ROM0:1D5A 6F               ld   l,a
ROM0:1D5B E5               push hl
ROM0:1D5C 06 00            ld   b,00
ROM0:1D5E FA 6B DA         ld   a,(DA6B)
ROM0:1D61 4F               ld   c,a
ROM0:1D62 CB 21            sla  c
ROM0:1D64 21 7A 1D         ld   hl,1D7A
ROM0:1D67 09               add  hl,bc
ROM0:1D68 2A               ldi  a,(hl)
ROM0:1D69 46               ld   b,(hl)
ROM0:1D6A 4F               ld   c,a
ROM0:1D6B E1               pop  hl
ROM0:1D6C 09               add  hl,bc
ROM0:1D6D 44               ld   b,h
ROM0:1D6E 4D               ld   c,l
ROM0:1D6F E1               pop  hl
ROM0:1D70 F1               pop  af
ROM0:1D71 C9               ret

Checks if Card ID is 721

  • 0x1D86-0x1D97 - ?
ROM0:1D86 D5               push de
ROM0:1D87 1E 00            ld   e,00
ROM0:1D89 78               ld   a,b
ROM0:1D8A FE 02            cp   a,02
ROM0:1D8C 20 07            jr   nz,1D95
ROM0:1D8E 79               ld   a,c
ROM0:1D8F FE D0            cp   a,D0
ROM0:1D91 20 02            jr   nz,1D95
ROM0:1D93 1E 01            ld   e,01
ROM0:1D95 7B               ld   a,e
ROM0:1D96 D1               pop  de
ROM0:1D97 C9               ret

Comparison between bc and de

ROM0:1D98 E5               push hl
ROM0:1D99 2E 01            ld   l,01
ROM0:1D9B 78               ld   a,b
ROM0:1D9C BA               cp   d
ROM0:1D9D 20 05            jr   nz,1DA4
ROM0:1D9F 79               ld   a,c
ROM0:1DA0 BB               cp   e
ROM0:1DA1 20 01            jr   nz,1DA4
ROM0:1DA3 2D               dec  l
ROM0:1DA4 7D               ld   a,l
ROM0:1DA5 E1               pop  hl
ROM0:1DA6 C9               ret

0:1DA7 (to document)

  • 0x1DA7-0x1DC1 - ?
ROM0:1DA7 C5               push bc
ROM0:1DA8 D5               push de
ROM0:1DA9 E5               push hl
ROM0:1DAA 2E 02            ld   l,02
ROM0:1DAC CD A2 14         call 14A2
ROM0:1DAF 7B               ld   a,e
ROM0:1DB0 FE 01            cp   a,01
ROM0:1DB2 20 02            jr   nz,1DB6
ROM0:1DB4 2E 01            ld   l,01
ROM0:1DB6 7B               ld   a,e
ROM0:1DB7 FE 00            cp   a,00
ROM0:1DB9 20 02            jr   nz,1DBD
ROM0:1DBB 2E 00            ld   l,00
ROM0:1DBD 7D               ld   a,l
ROM0:1DBE E1               pop  hl
ROM0:1DBF D1               pop  de
ROM0:1DC0 C1               pop  bc
ROM0:1DC1 C9               ret

PRNG

  • 0x20DB-0x210A - Pseudo-Random Number Generator
ROM0:20DB F5               push af
ROM0:20DC C5               push bc
ROM0:20DD D5               push de
ROM0:20DE FA 19 DB         ld   a,(DB19)
ROM0:20E1 47               ld   b,a
ROM0:20E2 4F               ld   c,a
ROM0:20E3 FA 18 DB         ld   a,(DB18)
ROM0:20E6 CB 19            rr   c
ROM0:20E8 1F               rra
ROM0:20E9 CB 1A            rr   d
ROM0:20EB A8               xor  b
ROM0:20EC CB 12            rl   d
ROM0:20EE 17               rla
ROM0:20EF CB 11            rl   c
ROM0:20F1 EA 19 DB         ld   (DB19),a
ROM0:20F4 FA 17 DB         ld   a,(DB17)
ROM0:20F7 EA 18 DB         ld   (DB18),a
ROM0:20FA FA 16 DB         ld   a,(DB16)
ROM0:20FD EA 17 DB         ld   (DB17),a
ROM0:2100 79               ld   a,c
ROM0:2101 EA 16 DB         ld   (DB16),a
ROM0:2104 EA 1C DB         ld   (DB1C),a
ROM0:2107 D1               pop  de
ROM0:2108 C1               pop  bc
ROM0:2109 F1               pop  af
ROM0:210A C9               ret

Pseudo-Random Number between m and n

  • 0x210B-0x2132 - Stores a Pseudo-Random Number between (DB1A) and (DB1B) in (DB1C)
ROM0:210B F5               push af
ROM0:210C C5               push bc
ROM0:210D D5               push de
ROM0:210E FA 1A DB         ld   a,(DB1A)	// Min value for PRN
ROM0:2111 4F               ld   c,a
ROM0:2112 FA 1B DB         ld   a,(DB1B)	// Max value for PRN
ROM0:2115 B9               cp   c
ROM0:2116 20 05            jr   nz,211D		// If(min ≠ max), jump to 0:211D
ROM0:2118 EA 1C DB         ld   (DB1C),a	// PRN = max
ROM0:211B 18 12            jr   212F		// Get out of this function
ROM0:211D 91               sub  c
ROM0:211E 47               ld   b,a
ROM0:211F 04               inc  b		// b = (max - min) + 1
ROM0:2120 CD DB 20         call 20DB		// PRNG
ROM0:2123 FA 1C DB         ld   a,(DB1C)
ROM0:2126 57               ld   d,a		// d = PRN
ROM0:2127 CD 03 14         call 1403		// Alt PRNG; set e to 0, 1 or 2
ROM0:212A 7B               ld   a,e
ROM0:212B 81               add  c		// a = e + min
ROM0:212C EA 1C DB         ld   (DB1C),a	// Store the value in (DB1C)
ROM0:212F D1               pop  de
ROM0:2130 C1               pop  bc
ROM0:2131 F1               pop  af
ROM0:2132 C9               ret

0:2297 - Fusion handling ?

ROM0:2297 C5               push bc
ROM0:2298 D5               push de
ROM0:2299 E5               push hl
ROM0:229A 2E 01            ld   l,01
ROM0:229C FA 4E DB         ld   a,(DB4E)
ROM0:229F 4F               ld   c,a
ROM0:22A0 FA 4F DB         ld   a,(DB4F)
ROM0:22A3 47               ld   b,a           ;bc = monster_card_id_1
ROM0:22A4 11 D0 02         ld   de,02D0
ROM0:22A7 CD 98 1D         call 1D98          ;Comparison between bc and de
ROM0:22AA A7               and  a
ROM0:22AB 28 28            jr   z,22D5
ROM0:22AD FA 50 DB         ld   a,(DB50)
ROM0:22B0 4F               ld   c,a
ROM0:22B1 FA 51 DB         ld   a,(DB51)
ROM0:22B4 47               ld   b,a           ;bc = monster_card_id_2
ROM0:22B5 CD 98 1D         call 1D98          ;Comparison between bc and de
ROM0:22B8 A7               and  a
ROM0:22B9 28 1A            jr   z,22D5
ROM0:22BB CD E2 22         call 22E2
ROM0:22BE FE 00            cp   a,00
ROM0:22C0 20 04            jr   nz,22C6
ROM0:22C2 2E 00            ld   l,00
ROM0:22C4 18 0F            jr   22D5
ROM0:22C6 CD 76 22         call 2276
ROM0:22C9 CD E2 22         call 22E2
ROM0:22CC FE 00            cp   a,00
ROM0:22CE 20 02            jr   nz,22D2
ROM0:22D0 2E 00            ld   l,00
ROM0:22D2 CD 76 22         call 2276
ROM0:22D5 7B               ld   a,e
ROM0:22D6 EA 52 DB         ld   (DB52),a
ROM0:22D9 7A               ld   a,d
ROM0:22DA EA 53 DB         ld   (DB53),a
ROM0:22DD 7D               ld   a,l
ROM0:22DE E1               pop  hl
ROM0:22DF D1               pop  de
ROM0:22E0 C1               pop  bc
ROM0:22E1 C9               ret

Fusion Summoning stuff

0:22E2 - Fusion Summoning handling

ROM0:22E2 C5               push bc
ROM0:22E3 E5               push hl
ROM0:22E4 E8 FF            add  sp,FF
ROM0:22E6 FA 00 40         ld   a,(4000)
ROM0:22E9 F5               push af
ROM0:22EA 3E 1B            ld   a,1B
ROM0:22EC CD 3A 12         call 123A          ;Bank switch to 0x1B
ROM0:22EF FA 4E DB         ld   a,(DB4E)
ROM0:22F2 4F               ld   c,a
ROM0:22F3 FA 4F DB         ld   a,(DB4F)
ROM0:22F6 47               ld   b,a           ;bc = monster_card_id_1
ROM0:22F7 CF               rst  08
 => 03 1B
ROM0:22FA EA 48 DB         ld   (DB48),a      ;updates Bank #1 containing the Fusion table
ROM0:22FD CF               rst  08
 => 05 1B
ROM0:2300 79               ld   a,c
ROM0:2301 EA 4A DB         ld   (DB4A),a
ROM0:2304 78               ld   a,b
ROM0:2305 EA 4B DB         ld   (DB4B),a      ;updates pointer to Fusion table
ROM0:2308 FA 4E DB         ld   a,(DB4E)
ROM0:230B C6 01            add  a,01
ROM0:230D 4F               ld   c,a
ROM0:230E FA 4F DB         ld   a,(DB4F)
ROM0:2311 CE 00            adc  a,00
ROM0:2313 47               ld   b,a           ;bc = monster_card_id_1 + 1 (the actual Monster #)
ROM0:2314 CF               rst  08
 => 03 1B
ROM0:2317 EA 49 DB         ld   (DB49),a      ;updates Bank #2 containing the Fusion table
ROM0:231A CF               rst  08
 => 05 1B
ROM0:231D 79               ld   a,c
ROM0:231E EA 4C DB         ld   (DB4C),a
ROM0:2321 78               ld   a,b
ROM0:2322 EA 4D DB         ld   (DB4D),a      ;updates end of the Fusion table
ROM0:2325 F8 02            ld   hl,sp+02
ROM0:2327 36 01            ld   (hl),01
ROM0:2329 FA 48 DB         ld   a,(DB48)
ROM0:232C CD 3A 12         call 123A         ;Bank switch to Bank containing the Fusion table
ROM0:232F CD 76 23         call 2376
ROM0:2332 FE 00            cp   a,00
ROM0:2334 28 25            jr   z,235B
ROM0:2336 FA 4A DB         ld   a,(DB4A)
ROM0:2339 6F               ld   l,a
ROM0:233A FA 4B DB         ld   a,(DB4B)
ROM0:233D 67               ld   h,a          ;hl = Pointer to the Fusion table
ROM0:233E 2A               ldi  a,(hl)
ROM0:233F 56               ld   d,(hl)
ROM0:2340 5F               ld   e,a          ;de = potential_fusion_material_2
ROM0:2341 FA 50 DB         ld   a,(DB50)
ROM0:2344 4F               ld   c,a
ROM0:2345 FA 51 DB         ld   a,(DB51)
ROM0:2348 47               ld   b,a           ;bc = fusion_material_2
ROM0:2349 CD 98 1D         call 1D98          ;Comparison between bc and de
ROM0:234C FE 00            cp   a,00
ROM0:234E 20 06            jr   nz,2356       ;if (fusion_material_2 ≠ potential_fusion_material_2), jump to 0:2356
ROM0:2350 F8 02            ld   hl,sp+02
ROM0:2352 36 00            ld   (hl),00
ROM0:2354 18 05            jr   235B
ROM0:2356 CD 9E 23         call 239E          ;
ROM0:2359 18 D4            jr   232F
ROM0:235B FA 4A DB         ld   a,(DB4A)
ROM0:235E C6 02            add  a,02
ROM0:2360 6F               ld   l,a
ROM0:2361 FA 4B DB         ld   a,(DB4B)
ROM0:2364 CE 00            adc  a,00
ROM0:2366 67               ld   h,a           ;hl = Pointer to current position in the Fusion table + 2
ROM0:2367 2A               ldi  a,(hl)
ROM0:2368 56               ld   d,(hl)
ROM0:2369 5F               ld   e,a           ;de = fusion_result_card_id
ROM0:236A F1               pop  af
ROM0:236B CD 3A 12         call 123A          ;Bank switch to a
ROM0:236E F8 00            ld   hl,sp+00
ROM0:2370 7E               ld   a,(hl)
ROM0:2371 E8 01            add  sp,01
ROM0:2373 E1               pop  hl
ROM0:2374 C1               pop  bc
ROM0:2375 C9               ret

0:2376 - Set registers accordingly if Fusion table is located on two different Banks

ROM0:2376 C5               push bc
ROM0:2377 D5               push de
ROM0:2378 E5               push hl
ROM0:2379 2E 01            ld   l,01
ROM0:237B FA 48 DB         ld   a,(DB48)
ROM0:237E 4F               ld   c,a
ROM0:237F FA 49 DB         ld   a,(DB49)
ROM0:2382 B9               cp   c
ROM0:2383 20 14            jr   nz,2399       ;if the two Banks are identical, get out
ROM0:2385 FA 4A DB         ld   a,(DB4A)
ROM0:2388 5F               ld   e,a
ROM0:2389 FA 4B DB         ld   a,(DB4B)
ROM0:238C 57               ld   d,a           ;fusion_table_start
ROM0:238D FA 4C DB         ld   a,(DB4C)
ROM0:2390 4F               ld   c,a
ROM0:2391 FA 4D DB         ld   a,(DB4D)
ROM0:2394 47               ld   b,a           ;fusion_table_end
ROM0:2395 CD 98 1D         call 1D98          ;Comparison between bc and de
ROM0:2398 6F               ld   l,a
ROM0:2399 7D               ld   a,l
ROM0:239A E1               pop  hl
ROM0:239B D1               pop  de
ROM0:239C C1               pop  bc
ROM0:239D C9               ret

0:239E - Updates current position in the Fusion table

ROM0:239E C5               push bc
ROM0:239F D5               push de
ROM0:23A0 01 00 80         ld   bc,8000
ROM0:23A3 FA 4A DB         ld   a,(DB4A)
ROM0:23A6 C6 04            add  a,04
ROM0:23A8 5F               ld   e,a
ROM0:23A9 FA 4B DB         ld   a,(DB4B)
ROM0:23AC CE 00            adc  a,00
ROM0:23AE 57               ld   d,a          ;de = current_position_in_fusion_table + 4
ROM0:23AF CD 98 1D         call 1D98
ROM0:23B2 FE 00            cp   a,00
ROM0:23B4 20 0E            jr   nz,23C4
ROM0:23B6 FA 48 DB         ld   a,(DB48)
ROM0:23B9 C6 01            add  a,01
ROM0:23BB EA 48 DB         ld   (DB48),a
ROM0:23BE CD 3A 12         call 123A
ROM0:23C1 11 04 40         ld   de,4004
ROM0:23C4 7B               ld   a,e
ROM0:23C5 EA 4A DB         ld   (DB4A),a
ROM0:23C8 7A               ld   a,d
ROM0:23C9 EA 4B DB         ld   (DB4B),a
ROM0:23CC D1               pop  de
ROM0:23CD C1               pop  bc
ROM0:23CE C9               ret

Load CPU Deck

ROM0:24EF F5               push af
ROM0:24F0 3E 40            ld   a,40
ROM0:24F2 CD 3A 12         call 123A
ROM0:24F5 CD 20 40         call 4020          ;40:4020, load pointer to CPU deck
ROM0:24F8 7A               ld   a,d
ROM0:24F9 CD 3A 12         call 123A
ROM0:24FC CD 07 25         call 2507          ;Choose a random Card 1
ROM0:24FF F1               pop  af
ROM0:2500 CD 3A 12         call 123A
ROM0:2503 E1               pop  hl
ROM0:2504 D1               pop  de
ROM0:2505 F1               pop  af
ROM0:2506 C9               ret

Choose a random Card 1

  • 0x2507-0x2566 - ?
ROM0:2507 F5               push af
ROM0:2508 D5               push de
ROM0:2509 E5               push hl
ROM0:250A 3E 00            ld   a,00
ROM0:250C EA 1A DB         ld   (DB1A),a      ;min_PRN = 0
ROM0:250F 3E FF            ld   a,FF
ROM0:2511 EA 1B DB         ld   (DB1B),a      ;max_PRN = 255
ROM0:2514 CD 0B 21         call 210B          ;Pseudo-Random Number between m and n
ROM0:2517 FA 1C DB         ld   a,(DB1C)      ;a = PRN
ROM0:251A 5F               ld   e,a
ROM0:251B 3E 00            ld   a,00
ROM0:251D EA 1A DB         ld   (DB1A),a      ;min_PRN = 0
ROM0:2520 3E 07            ld   a,07
ROM0:2522 EA 1B DB         ld   (DB1B),a      ;max_PRN = 7
ROM0:2525 CD 0B 21         call 210B          ;Pseudo-Random Number between m and n
ROM0:2528 FA 1C DB         ld   a,(DB1C)      ;a = PRN
ROM0:252B 57               ld   d,a           ;de = PRN[0;2047]
ROM0:252C 60               ld   h,b
ROM0:252D 69               ld   l,c           ;hl = pointer from 40:410D
ROM0:252E 01 00 00         ld   bc,0000       ;bc = 0
ROM0:2531 AF               xor  a             ;a = 0
ROM0:2532 F5               push af
ROM0:2533 C5               push bc
ROM0:2534 E6 01            and  a,01
ROM0:2536 20 14            jr   nz,254C
ROM0:2538 2A               ldi  a,(hl)
ROM0:2539 47               ld   b,a
ROM0:253A 7E               ld   a,(hl)
ROM0:253B E6 F0            and  a,F0
ROM0:253D CB 38            srl  b
ROM0:253F 1F               rra
ROM0:2540 CB 38            srl  b
ROM0:2542 1F               rra
ROM0:2543 CB 38            srl  b
ROM0:2545 1F               rra
ROM0:2546 CB 38            srl  b
ROM0:2548 1F               rra
ROM0:2549 4F               ld   c,a
ROM0:254A 18 06            jr   2552
ROM0:254C 2A               ldi  a,(hl)
ROM0:254D E6 0F            and  a,0F
ROM0:254F 47               ld   b,a
ROM0:2550 2A               ldi  a,(hl)
ROM0:2551 4F               ld   c,a
ROM0:2552 CD A7 1D         call 1DA7
ROM0:2555 C1               pop  bc
ROM0:2556 FE 00            cp   a,00
ROM0:2558 20 04            jr   nz,255E
ROM0:255A E8 02            add  sp,02
ROM0:255C 18 05            jr   2563
ROM0:255E 03               inc  bc
ROM0:255F F1               pop  af
ROM0:2560 3C               inc  a
ROM0:2561 18 CF            jr   2532
ROM0:2563 E1               pop  hl
ROM0:2564 D1               pop  de
ROM0:2565 F1               pop  af
ROM0:2566 C9               ret

Stage 5 opponents Decks IDs

  • 0x25BE-0x25CC - Loads Stage 5 opponent's Deck ID
ROM0:25BE 23               inc  hl
ROM0:25BF 04               inc  b
ROM0:25C0 06 00            ld   b,00
ROM0:25C2 4F               ld   c,a
ROM0:25C3 21 CD 25         ld   hl,25CD
ROM0:25C6 09               add  hl,bc
ROM0:25C7 7E               ld   a,(hl)
ROM0:25C8 EA 87 DB         ld   (DB87),a
ROM0:25CB F1               pop  af
ROM0:25CC C9               ret
  • 0x25CD-0x25D0 - Stage 5 opponents Decks IDs
ROM0:25CD
0F 12 13 14

Gives a random Card 2

  • 0x29E7-0x2A04 - ?
ROM0:29E7 F5               push af
ROM0:29E8 D5               push de
ROM0:29E9 E5               push hl
ROM0:29EA FA 00 40         ld   a,(4000)
ROM0:29ED F5               push af
ROM0:29EE 3E 40            ld   a,40
ROM0:29F0 CD 3A 12         call 123A		// Switch to Bank 40
ROM0:29F3 CD 23 40         call 4023
ROM0:29F6 7A               ld   a,d
ROM0:29F7 CD 3A 12         call 123A		// Switch to Bank 24 or 25, from RO40:410D
ROM0:29FA CD 07 25         call 2507
ROM0:29FD F1               pop  af
ROM0:29FE CD 3A 12         call 123A		// Switch to Bank D
ROM0:2A01 E1               pop  hl
ROM0:2A02 D1               pop  de
ROM0:2A03 F1               pop  af
ROM0:2A04 C9               ret

Initialize Duel Records

  • 0x2A10-0x2A2A - Sets Duel Records to either 0 duels, or 9 duels if debug game
ROM0:2A10 FE 00            cp   a,00
ROM0:2A12 20 05            jr   nz,2A19		// If debug, jump to 0:2A19
ROM0:2A14 11 49 2A         ld   de,2A49
ROM0:2A17 18 03            jr   2A1C		// Else, jump to 0:2A1C
ROM0:2A19 11 A1 2A         ld   de,2AA1
ROM0:2A1C 0E 16            ld   c,16
ROM0:2A1E 1A               ld   a,(de)
ROM0:2A1F 22               ldi  (hl),a
ROM0:2A20 13               inc  de
ROM0:2A21 1A               ld   a,(de)
ROM0:2A22 22               ldi  (hl),a
ROM0:2A23 13               inc  de
ROM0:2A24 0D               dec  c
ROM0:2A25 20 F7            jr   nz,2A1E
ROM0:2A27 21 FB DB         ld   hl,DBFB
ROM0:2A2A CF               rst  08
  • 0x2A2D-0x2A48 - Sets Duel Records to either 0 wins, or 9 wins if debug game
ROM0:2A2D FE 00            cp   a,00
ROM0:2A2F 20 05            jr   nz,2A36		// If debug, jump to 0:2A36
ROM0:2A31 11 75 2A         ld   de,2A75
ROM0:2A34 18 03            jr   2A39		// Else, jump to 0:2A39
ROM0:2A36 11 CD 2A         ld   de,2ACD
ROM0:2A39 0E 16            ld   c,16
ROM0:2A3B 1A               ld   a,(de)
ROM0:2A3C 22               ldi  (hl),a
ROM0:2A3D 13               inc  de
ROM0:2A3E 1A               ld   a,(de)
ROM0:2A3F 22               ldi  (hl),a
ROM0:2A40 13               inc  de
ROM0:2A41 0D               dec  c
ROM0:2A42 20 F7            jr   nz,2A3B
ROM0:2A44 E1               pop  hl
ROM0:2A45 D1               pop  de
ROM0:2A46 C1               pop  bc
ROM0:2A47 F1               pop  af
ROM0:2A48 C9               ret
  • 0x2A49-0x2AA0 - Duel Records
ROM0:2A49
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00
  • 0x2AA1-0x2AF8 - Debug Duel Records
ROM0:2AA1
09 00 09 00 09 00 09 00 09 00 09 00 09 00 09 00
09 00 09 00 09 00 09 00 09 00 09 00 09 00 09 00
09 00 09 00 04 00 04 00 04 00 04 00 09 00 09 00
09 00 09 00 09 00 09 00 09 00 09 00 09 00 09 00
09 00 09 00 09 00 09 00 09 00 09 00 09 00 09 00
04 00 04 00 04 00 04

idk for now

Set wC920 to accumulator

ROM0:2D0A F5               push af
ROM0:2D0B C5               push bc
ROM0:2D0C D5               push de
ROM0:2D0D E5               push hl
ROM0:2D0E CF               rst  08
          07 3E => pointer 3E:4007, function 3E:4076 - Set wC920 to accumulator
ROM0:2D11 E1               pop  hl
ROM0:2D12 D1               pop  de
ROM0:2D13 C1               pop  bc
ROM0:2D14 F1               pop  af
ROM0:2D15 C9               ret

0:2D16 (Set wC920 to 0, and?)

ROM0:2D16 F5               push af
ROM0:2D17 3E 00            ld   a,00          ;a = 0
ROM0:2D19 CD 0A 2D         call 2D0A          ;Set wC920 to 0
ROM0:2D1C CD 07 11         call 1107
ROM0:2D1F F1               pop  af
ROM0:2D20 C9               ret

0:2D21 (Set wC920 to 2, and?)

ROM0:2D21 F5               push af
ROM0:2D22 3E 02            ld   a,02          ;a = 2
ROM0:2D24 CD 0A 2D         call 2D0A          ;Set wC920 to 2
ROM0:2D27 CD 07 11         call 1107
ROM0:2D2A F1               pop  af
ROM0:2D2B C9               ret

0:2D2C (Set wC920 to 3, and?)

ROM0:2D2C F5               push af
ROM0:2D2D 3E 03            ld   a,03          ;a = 3
ROM0:2D2F CD 0A 2D         call 2D0A          ;Set wC920 to 3
ROM0:2D32 CD 07 11         call 1107
ROM0:2D35 F1               pop  af
ROM0:2D36 C9               ret

0:2D37 (Set wC920 to 4, and?)

ROM0:2D37 F5               push af
ROM0:2D38 3E 04            ld   a,04          ;a = 4
ROM0:2D3A CD 0A 2D         call 2D0A          ;Set wC920 to 4
ROM0:2D3D CD 07 11         call 1107
ROM0:2D40 F1               pop  af
ROM0:2D41 C9               ret

0:2D42 (Set wC920 to 5, and?)

ROM0:2D42 F5               push af
ROM0:2D43 3E 05            ld   a,05          ;a = 5
ROM0:2D45 CD 0A 2D         call 2D0A          ;Set wC920 to 5
ROM0:2D48 CD 07 11         call 1107
ROM0:2D4B F1               pop  af
ROM0:2D4C C9               ret

0:2D4D (Set wC920 to 6, and?)

ROM0:2D4D F5               push af
ROM0:2D4E 3E 06            ld   a,06          ;a = 6
ROM0:2D50 CD 0A 2D         call 2D0A          ;Set wC920 to 6
ROM0:2D53 CD 07 11         call 1107
ROM0:2D56 F1               pop  af
ROM0:2D57 C9               ret

0:2D58 (Set wC920 to 10, and?)

ROM0:2D58 F5               push af
ROM0:2D59 3E 0A            ld   a,0A          ;a = 10
ROM0:2D5B CD 0A 2D         call 2D0A          ;Set wC920 to 10
ROM0:2D5E CD 07 11         call 1107
ROM0:2D61 F1               pop  af
ROM0:2D62 C9               ret

0:2D63 (Set wC920 to 11, and?)

ROM0:2D63 F5               push af
ROM0:2D64 3E 0B            ld   a,0B          ;a = 11
ROM0:2D66 CD 0A 2D         call 2D0A          ;Set wC920 to 11
ROM0:2D69 CD 07 11         call 1107
ROM0:2D6C F1               pop  af
ROM0:2D6D C9               ret

0:2D6E (Set wC920 to 12, and?)

ROM0:2D6E F5               push af
ROM0:2D6F 3E 0C            ld   a,0C          ;a = 12
ROM0:2D71 CD 0A 2D         call 2D0A          ;Set wC920 to 12
ROM0:2D74 CD 07 11         call 1107
ROM0:2D77 F1               pop  af
ROM0:2D78 C9               ret

0:2D79 (Set wC920 to 13, and?)

ROM0:2D79 F5               push af
ROM0:2D7A 3E 0D            ld   a,0D          ;a = 13
ROM0:2D7C CD 0A 2D         call 2D0A          ;Set wC920 to 13
ROM0:2D7F CD 07 11         call 1107
ROM0:2D82 F1               pop  af
ROM0:2D83 C9               ret

0:2D84 (Set wC920 to 14, and?)

ROM0:2D84 F5               push af
ROM0:2D85 3E 0E            ld   a,0E          ;a = 14
ROM0:2D87 CD 0A 2D         call 2D0A          ;Set wC920 to 14
ROM0:2D8A CD 07 11         call 1107
ROM0:2D8D F1               pop  af
ROM0:2D8E C9               ret

0:2D8F (Set wC920 to 15, and?)

ROM0:2D8F F5               push af
ROM0:2D90 3E 0F            ld   a,0F          ;a = 15
ROM0:2D92 CD 0A 2D         call 2D0A          ;Set wC920 to 15
ROM0:2D95 CD 07 11         call 1107
ROM0:2D98 F1               pop  af
ROM0:2D99 C9               ret

0:2D9A (Set wC920 to 18, and?)

ROM0:2D9A F5               push af
ROM0:2D9B 3E 12            ld   a,12          ;a = 18
ROM0:2D9D CD 0A 2D         call 2D0A          ;Set wC920 to 18
ROM0:2DA0 CD 07 11         call 1107
ROM0:2DA3 F1               pop  af
ROM0:2DA4 C9               ret

0:2DA5 (Set wC920 to 16, and?)

ROM0:2DA5 F5               push af
ROM0:2DA6 3E 10            ld   a,10          ;a = 16
ROM0:2DA8 CD 0A 2D         call 2D0A          ;Set wC920 to 16
ROM0:2DAB CD 07 11         call 1107
ROM0:2DAE F1               pop  af
ROM0:2DAF C9               ret

0:2DB0 (Set wC920 to 7, and?)

ROM0:2DB0 F5               push af
ROM0:2DB1 3E 07            ld   a,07          ;a = 7
ROM0:2DB3 CD 0A 2D         call 2D0A          ;Set wC920 to 7
ROM0:2DB6 CD 07 11         call 1107
ROM0:2DB9 F1               pop  af
ROM0:2DBA C9               ret

0:2DBB (Set wC920 to 19, and?)

ROM0:2DBB F5               push af
ROM0:2DBC 3E 13            ld   a,13          ;a = 19
ROM0:2DBE CD 0A 2D         call 2D0A          ;Set wC920 to 19
ROM0:2DC1 CD 07 11         call 1107
ROM0:2DC4 F1               pop  af
ROM0:2DC5 C9               ret

0:2DC6 (Set wC920 to 1, and?)

ROM0:2DC6 F5               push af
ROM0:2DC7 3E 01            ld   a,01          ;a = 1
ROM0:2DC9 CD 0A 2D         call 2D0A          ;Set wC920 to 1
ROM0:2DCC CD 07 11         call 1107
ROM0:2DCF F1               pop  af
ROM0:2DD0 C9               ret

0:2DD1 (Set wC920 to 9, and?)

ROM0:2DD1 F5               push af
ROM0:2DD2 3E 09            ld   a,09          ;a = 9
ROM0:2DD4 CD 0A 2D         call 2D0A          ;Set wC920 to 9
ROM0:2DD7 CD 07 11         call 1107
ROM0:2DDA F1               pop  af
ROM0:2DDB C9               ret

idk for now, again

0:2E3D - 0x97 - 0d151

ROM0:2E3D 3E 97            ld   a,97
ROM0:2E3F CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E42 CD 07 11         call 1107
ROM0:2E45 F1               pop  af
ROM0:2E46 C9               ret

0:2E47 - 0x96 - 0d150

ROM0:2E47 F5               push af
ROM0:2E48 3E 96            ld   a,96
ROM0:2E4A CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E4D CD 07 11         call 1107
ROM0:2E50 F1               pop  af
ROM0:2E51 C9               ret

0:2E52 - 0x95 - 0d149

ROM0:2E52 F5               push af
ROM0:2E53 3E 95            ld   a,95
ROM0:2E55 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E58 CD 07 11         call 1107
ROM0:2E5B F1               pop  af
ROM0:2E5C C9               ret

0:2E5D - 0x98 - 0d152

ROM0:2E5D F5               push af
ROM0:2E5E 3E 98            ld   a,98
ROM0:2E60 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E63 CD 07 11         call 1107
ROM0:2E66 F1               pop  af
ROM0:2E67 C9               ret

0:2E68 - 0x9D - 0d157

ROM0:2E68 F5               push af
ROM0:2E69 3E 9D            ld   a,9D
ROM0:2E6B CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E6E CD 07 11         call 1107
ROM0:2E71 F1               pop  af
ROM0:2E72 C9               ret

0:2E73 - 0x9E - 0d158

ROM0:2E73 F5               push af
ROM0:2E74 3E 9E            ld   a,9E
ROM0:2E76 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E79 CD 07 11         call 1107
ROM0:2E7C F1               pop  af
ROM0:2E7D C9               ret

0:2E7E - 0x9F - 0d159

ROM0:2E7E F5               push af
ROM0:2E7F 3E 9F            ld   a,9F
ROM0:2E81 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E84 CD 07 11         call 1107
ROM0:2E87 F1               pop  af
ROM0:2E88 C9               ret

0:2E89 - 0xA0 - 0d160

ROM0:2E89 F5               push af
ROM0:2E8A 3E A0            ld   a,A0
ROM0:2E8C CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E8F CD 07 11         call 1107
ROM0:2E92 F1               pop  af
ROM0:2E93 C9               ret

0:2E94 - 0xA2 - 0d162

ROM0:2E94 F5               push af
ROM0:2E95 3E A2            ld   a,A2
ROM0:2E97 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2E9A CD 07 11         call 1107
ROM0:2E9D F1               pop  af
ROM0:2E9E C9               ret

0:2E9F - 0x99 - 0d153

ROM0:2E9F F5               push af
ROM0:2EA0 3E 99            ld   a,99
ROM0:2EA2 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EA5 CD 07 11         call 1107
ROM0:2EA8 F1               pop  af
ROM0:2EA9 C9               ret

0:2EAA - 0x95 - 0d149 (copy of 0:2E52)

ROM0:2EAA F5               push af
ROM0:2EAB 3E 95            ld   a,95
ROM0:2EAD CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EB0 CD 07 11         call 1107
ROM0:2EB3 F1               pop  af
ROM0:2EB4 C9               ret

0:2EB5 - 0xA4 - 0d164

ROM0:2EB5 F5               push af
ROM0:2EB6 3E A4            ld   a,A4
ROM0:2EB8 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EBB CD 07 11         call 1107
ROM0:2EBE F1               pop  af
ROM0:2EBF C9               ret

0:2EC0 - 0x9B - 0d155

ROM0:2EC0 F5               push af
ROM0:2EC1 3E 9B            ld   a,9B
ROM0:2EC3 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EC6 CD 07 11         call 1107
ROM0:2EC9 F1               pop  af
ROM0:2ECA C9               ret

0:2ECB - 0x9A - 0d154

ROM0:2ECB F5               push af
ROM0:2ECC 3E 9A            ld   a,9A
ROM0:2ECE CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2ED1 CD 07 11         call 1107
ROM0:2ED4 F1               pop  af
ROM0:2ED5 C9               ret

0:2ED6 - 0xA3 - 0d163

ROM0:2ED6 F5               push af
ROM0:2ED7 3E A3            ld   a,A3
ROM0:2ED9 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EDC CD 07 11         call 1107
ROM0:2EDF F1               pop  af
ROM0:2EE0 C9               ret

0:2EE1 - 0x11 - 0d17

ROM0:2EE1 F5               push af
ROM0:2EE2 3E 11            ld   a,11
ROM0:2EE4 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EE7 CD 07 11         call 1107
ROM0:2EEA F1               pop  af
ROM0:2EEB C9               ret

0:2EEC - 0x08 - 0d08

ROM0:2EEC F5               push af
ROM0:2EED 3E 08            ld   a,08
ROM0:2EEF CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EF2 CD 07 11         call 1107
ROM0:2EF5 F1               pop  af
ROM0:2EF6 C9               ret

0:2EF7 - accumulator as argument

ROM0:2EF7 F5               push af
ROM0:2EF8 CD 0A 2D         call 2D0A          ;Store accumulator in wC920
ROM0:2EFB CD 07 11         call 1107
ROM0:2EFE F1               pop  af
ROM0:2EFF C9               ret

0:31F5 (sets (DD07) to 0)

  • 0x31F5-0x31FC - Sets (DD07) to 0
ROM0:31F5 F5               push af
ROM0:31F6 3E 00            ld   a,00
ROM0:31F8 EA 07 DD         ld   (DD07),a
ROM0:31FB F1               pop  af
ROM0:31FC C9               ret

0:31FD (sets (DD07) to 0 or 4)

  • 0x31FD-0x3225 - Sets (DD07) to 0 or 4
ROM0:31FD F5               push af
ROM0:31FE C5               push bc
ROM0:31FF E5               push hl
ROM0:3200 78               ld   a,b
ROM0:3201 FE 00            cp   a,00
ROM0:3203 20 0C            jr   nz,3211
ROM0:3205 79               ld   a,c
ROM0:3206 FE 11            cp   a,11
ROM0:3208 20 05            jr   nz,320F
ROM0:320A 3E 04            ld   a,04
ROM0:320C EA 07 DD         ld   (DD07),a
ROM0:320F 18 11            jr   3222
ROM0:3211 FA 07 DD         ld   a,(DD07)
ROM0:3214 FE 04            cp   a,04
ROM0:3216 28 0A            jr   z,3222
ROM0:3218 06 00            ld   b,00
ROM0:321A 21 26 32         ld   hl,3226
ROM0:321D 09               add  hl,bc
ROM0:321E 7E               ld   a,(hl)
ROM0:321F EA 07 DD         ld   (DD07),a
ROM0:3222 E1               pop  hl
ROM0:3223 C1               pop  bc
ROM0:3224 F1               pop  af
ROM0:3225 C9               ret

Bank 1

Initialize Cards in trunk

  • 0x474F-0x4774 - Initialize the cards owned to 0, or 200 if debug game
ROM1:474F FE 00            cp   a,00
ROM1:4751 20 04            jr   nz,4757		// If debug, jump to 1:4757
ROM1:4753 3E FF            ld   a,FF
ROM1:4755 18 02            jr   4759		// Else, jump to 1:4759
ROM1:4757 3E C8            ld   a,C8		// If debug, gives the player 200 copies of each card
ROM1:4759 06 02            ld   b,02
ROM1:475B 0E 00            ld   c,00
ROM1:475D 22               ldi  (hl),a
ROM1:475E 0D               dec  c
ROM1:475F 20 FC            jr   nz,475D
ROM1:4761 05               dec  b
ROM1:4762 20 F7            jr   nz,475B
ROM1:4764 0E D0            ld   c,D0
ROM1:4766 22               ldi  (hl),a
ROM1:4767 0D               dec  c
ROM1:4768 20 FC            jr   nz,4766		// Set (D5A0) to (D86F) to 0, or 200 if debug game
ROM1:476A AF               xor  a
ROM1:476B EA B7 D8         ld   (D8B7),a	// Set (D8B7) and (D8B8) to 0
ROM1:476E EA B8 D8         ld   (D8B8),a
ROM1:4771 E1               pop  hl
ROM1:4772 C1               pop  bc
ROM1:4773 F1               pop  af
ROM1:4774 C9               ret

1:4775

ROM1:4775 F5               push af
ROM1:4776 CD 86 1D         call 1D86          ;Checks if Card ID is 721
ROM1:4779 FE 00            cp   a,00
ROM1:477B 20 08            jr   nz,4785
ROM1:477D 79               ld   a,c
ROM1:477E EA B7 D8         ld   (D8B7),a
ROM1:4781 78               ld   a,b
ROM1:4782 EA B8 D8         ld   (D8B8),a
ROM1:4785 F1               pop  af
ROM1:4786 C9               ret

1:4787

ROM1:4787 F5               push af
ROM1:4788 C5               push bc
ROM1:4789 CD 18 48         call 4818
ROM1:478C FE FF            cp   a,FF
ROM1:478E 20 04            jr   nz,4794
ROM1:4790 AF               xor  a
ROM1:4791 CD 03 48         call 4803
ROM1:4794 FA B7 D8         ld   a,(D8B7)
ROM1:4797 4F               ld   c,a
ROM1:4798 FA B8 D8         ld   a,(D8B8)
ROM1:479B 47               ld   b,a
ROM1:479C CD 84 49         call 4984          ;Check if card is forbidden
ROM1:479F FE 00            cp   a,00
ROM1:47A1 20 0D            jr   nz,47B0
ROM1:47A3 CD 18 48         call 4818
ROM1:47A6 FE FA            cp   a,FA
ROM1:47A8 28 04            jr   z,47AE
ROM1:47AA 3C               inc  a
ROM1:47AB CD 03 48         call 4803
ROM1:47AE 18 04            jr   47B4
ROM1:47B0 AF               xor  a
ROM1:47B1 CD 03 48         call 4803
ROM1:47B4 C1               pop  bc
ROM1:47B5 F1               pop  af
ROM1:47B6 C9               ret  

1:47B7

ROM1:47B7 C5               push bc
ROM1:47B8 D5               push de
ROM1:47B9 16 01            ld   d,01
ROM1:47BB FA B7 D8         ld   a,(D8B7)
ROM1:47BE 4F               ld   c,a
ROM1:47BF FA B8 D8         ld   a,(D8B8)
ROM1:47C2 47               ld   b,a
ROM1:47C3 CD 84 49         call 4984          ;Check if card is forbidden
ROM1:47C6 FE 00            cp   a,00
ROM1:47C8 20 19            jr   nz,47E3
ROM1:47CA 16 00            ld   d,00
ROM1:47CC CD 18 48         call 4818          ;Retrieve number of copies of card ID in Trunk/Chest
ROM1:47CF FE 00            cp   a,00
ROM1:47D1 20 04            jr   nz,47D7
ROM1:47D3 16 01            ld   d,01
ROM1:47D5 18 0C            jr   47E3
ROM1:47D7 FE FF            cp   a,FF
ROM1:47D9 20 04            jr   nz,47DF
ROM1:47DB 16 01            ld   d,01
ROM1:47DD 18 04            jr   47E3
ROM1:47DF 3D               dec  a
ROM1:47E0 CD 03 48         call 4803
ROM1:47E3 7A               ld   a,d
ROM1:47E4 D1               pop  de
ROM1:47E5 C1               pop  bc
ROM1:47E6 C9               ret

1:47E7

ROM1:47E7 F5               push af
ROM1:47E8 CD 18 48         call 4818          ;Retrieve number of copies of card ID in Trunk/Chest
ROM1:47EB FE FF            cp   a,FF
ROM1:47ED 28 04            jr   z,47F3
ROM1:47EF 3D               dec  a
ROM1:47F0 CD 03 48         call 4803
ROM1:47F3 F1               pop  af
ROM1:47F4 C9               ret  

1:47F5

ROM1:47F5 F5               push af
ROM1:47F6 CD 18 48         call 4818          ;Retrieve number of copies of card ID in Trunk/Chest
ROM1:47F9 FE FF            cp   a,FF
ROM1:47FB 20 04            jr   nz,4801
ROM1:47FD AF               xor  a
ROM1:47FE CD 03 48         call 4803
ROM1:4801 F1               pop  af
ROM1:4802 C9               ret  

1:4803

ROM1:4803 C5               push bc
ROM1:4804 E5               push hl
ROM1:4805 F5               push af
ROM1:4806 FA B7 D8         ld   a,(D8B7)
ROM1:4809 4F               ld   c,a
ROM1:480A FA B8 D8         ld   a,(D8B8)
ROM1:480D 47               ld   b,a
ROM1:480E 21 A0 D5         ld   hl,D5A0
ROM1:4811 09               add  hl,bc
ROM1:4812 F1               pop  af
ROM1:4813 4F               ld   c,a
ROM1:4814 77               ld   (hl),a
ROM1:4815 E1               pop  hl
ROM1:4816 C1               pop  bc
ROM1:4817 C9               ret  

Retrieve number of copies of card ID in Trunk/Chest

ROM1:4818 C5               push bc
ROM1:4819 E5               push hl
ROM1:481A FA B7 D8         ld   a,(D8B7)
ROM1:481D 4F               ld   c,a
ROM1:481E FA B8 D8         ld   a,(D8B8)
ROM1:4821 47               ld   b,a
ROM1:4822 21 A0 D5         ld   hl,D5A0
ROM1:4825 09               add  hl,bc
ROM1:4826 7E               ld   a,(hl)
ROM1:4827 E1               pop  hl
ROM1:4828 C1               pop  bc
ROM1:4829 C9               ret

1:482A

ROM1:482A C5               push bc
ROM1:482B D5               push de
ROM1:482C 1E 01            ld   e,01
ROM1:482E FA B7 D8         ld   a,(D8B7)
ROM1:4831 4F               ld   c,a
ROM1:4832 FA B8 D8         ld   a,(D8B8)
ROM1:4835 47               ld   b,a           ;bc = Current Card ID
ROM1:4836 C5               push bc
ROM1:4837 CF               rst  08
 => 0F 0E
ROM1:483A 78               ld   a,b
ROM1:483B C1               pop  bc
ROM1:483C FE 00            cp   a,00
ROM1:483E 20 0C            jr   nz,484C
ROM1:4840 CD B7 47         call 47B7
ROM1:4843 FE 00            cp   a,00
ROM1:4845 20 05            jr   nz,484C        ;if card is Forbidden, is not in the Trunk/Chest or has no copies left in the Trunk/Chest, get out of this function
ROM1:4847 CF               rst  08
 => 0D 0E
ROM1:484A 1E 00            ld   e,00
ROM1:484C 7B               ld   a,e
ROM1:484D D1               pop  de
ROM1:484E C1               pop  bc
ROM1:484F C9               ret

1:4932

ROM1:4932 F5               push af
ROM1:4933 E5               push hl
ROM1:4934 E8 FE            add  sp,FE
ROM1:4936 F8 00            ld   hl,sp+00
ROM1:4938 AF               xor  a
ROM1:4939 22               ldi  (hl),a
ROM1:493A 22               ldi  (hl),a
ROM1:493B 22               ldi  (hl),a
ROM1:493C 01 00 00         ld   bc,0000
ROM1:493F CF               rst  08
          03 09
ROM1:4942 FA 81 D9         ld   a,(D981)        ;a = Card_Type_ID
ROM1:4945 FE 14            cp   a,14
ROM1:4947 30 23            jr   nc,496C
ROM1:4949 CF               rst  08
          3D 05
ROM1:494C 5F               ld   e,a
ROM1:494D FA 83 D9         ld   a,(D983)
ROM1:4950 BB               cp   e
ROM1:4951 28 02            jr   z,4955
ROM1:4953 30 17            jr   nc,496C
ROM1:4955 CD 75 47         call 4775
ROM1:4958 CD 18 48         call 4818
ROM1:495B FE FF            cp   a,FF
ROM1:495D 20 01            jr   nz,4960
ROM1:495F AF               xor  a
ROM1:4960 F8 00            ld   hl,sp+00
ROM1:4962 86               add  (hl)
ROM1:4963 22               ldi  (hl),a
ROM1:4964 3E 00            ld   a,00
ROM1:4966 8E               adc  (hl)
ROM1:4967 22               ldi  (hl),a
ROM1:4968 3E 00            ld   a,00
ROM1:496A 8E               adc  (hl)
ROM1:496B 77               ld   (hl),a
ROM1:496C 03               inc  bc
ROM1:496D 11 D0 02         ld   de,02D0     ;de = 0d720
ROM1:4970 CD 98 1D         call 1D98        ;Comparison between bc and de
ROM1:4973 FE 00            cp   a,00
ROM1:4975 20 C8            jr   nz,493F
ROM1:4977 F8 00            ld   hl,sp+00
ROM1:4979 2A               ldi  a,(hl)
ROM1:497A 5F               ld   e,a
ROM1:497B 2A               ldi  a,(hl)
ROM1:497C 4F               ld   c,a
ROM1:497D 2A               ldi  a,(hl)
ROM1:497E 47               ld   b,a
ROM1:497F E8 02            add  sp,02
ROM1:4981 E1               pop  hl
ROM1:4982 F1               pop  af
ROM1:4983 C9               ret

Check if card is forbidden

ROM1:4984 C5               push bc
ROM1:4985 D5               push de
ROM1:4986 E5               push hl
ROM1:4987 50               ld   d,b
ROM1:4988 59               ld   e,c
ROM1:4989 21 AD 49         ld   hl,49AD
ROM1:498C 2A               ldi  a,(hl)
ROM1:498D 4F               ld   c,a
ROM1:498E 2A               ldi  a,(hl)
ROM1:498F 47               ld   b,a
ROM1:4990 CD 86 1D         call 1D86          ;Checks if Card ID is 721
ROM1:4993 FE 01            cp   a,01
ROM1:4995 20 04            jr   nz,499B
ROM1:4997 0E 00            ld   c,00
ROM1:4999 18 0D            jr   49A8
ROM1:499B CD 98 1D         call 1D98          ;Comparison between bc and de
ROM1:499E FE 00            cp   a,00
ROM1:49A0 20 04            jr   nz,49A6
ROM1:49A2 0E 01            ld   c,01
ROM1:49A4 18 02            jr   49A8
ROM1:49A6 18 E4            jr   498C
ROM1:49A8 79               ld   a,c
ROM1:49A9 E1               pop  hl
ROM1:49AA D1               pop  de
ROM1:49AB C1               pop  bc
ROM1:49AC C9               ret

Forbidden cards array

ROM1:49AD
6B 01 - Black Luster Soldi
67 01 - Zera The Mant
63 01 - Super War-lion
6C 01 - Fiend's Mirror
7B 01 - B.eye Ultra Dragon
75 01 - Gate Guardian
BC 02 - Performance of Swo
BD 02 - Hungry Burger
BE 02 - Sengenjin
BF 02 - Skull Guardian
C0 02 - Tri-horned Dragon
C1 02 - Serpent Night Dra
C5 02 - Crab Turtle
CF 02 - Mask of Shine & Da
C4 02 - Chakra
CA 02 - Psycho-Puppet
CC 02 - Javelin Beetle
CB 02 - Garma Sword
C3 02 - Cosmo Queen
CE 02 - Dokurorider
CD 02 - Fortress Whale
C8 02 - Meteor B. Dragon
D0 02 - end-of-array marker?

1:4CC2 - Add card to Player's Deck general routine ?

ROM1:4CC2 F5               push af
ROM1:4CC3 C5               push bc
ROM1:4CC4 D5               push de
ROM1:4CC5 E5               push hl
ROM1:4CC6 FA AD D8         ld   a,(D8AD)
ROM1:4CC9 47               ld   b,a
ROM1:4CCA 1E 05            ld   e,05
ROM1:4CCC CD 78 14         call 1478
ROM1:4CCF FA AA D8         ld   a,(D8AA)
ROM1:4CD2 85               add  l
ROM1:4CD3 4F               ld   c,a
ROM1:4CD4 7C               ld   a,h
ROM1:4CD5 CE 00            adc  a,00
ROM1:4CD7 47               ld   b,a
ROM1:4CD8 CF               rst  08
ROM1:4CD9 03               inc  bc
ROM1:4CDA 09               add  hl,bc
ROM1:4CDB CF               rst  08
ROM1:4CDC 3B               dec  sp
ROM1:4CDD 05               dec  b
ROM1:4CDE 5F               ld   e,a
ROM1:4CDF FA 83 D9         ld   a,(D983)
ROM1:4CE2 BB               cp   e
ROM1:4CE3 28 0E            jr   z,4CF3
ROM1:4CE5 38 0C            jr   c,4CF3
ROM1:4CE7 CD 5D 2E         call 2E5D          ;store 0x98 to wC920, and ?
ROM1:4CEA AF               xor  a
ROM1:4CEB EA A9 D8         ld   (D8A9),a
ROM1:4CEE EA AB D8         ld   (D8AB),a
ROM1:4CF1 18 33            jr   4D26
ROM1:4CF3 CD 75 47         call 4775
ROM1:4CF6 CD 2A 48         call 482A          ;check if card is Forbidden, is not in the Trunk/Chest or has no copies left in the Trunk/Chest ?
ROM1:4CF9 FE 00            cp   a,00
ROM1:4CFB 28 0C            jr   z,4D09
ROM1:4CFD CD 5D 2E         call 2E5D
ROM1:4D00 AF               xor  a
ROM1:4D01 EA A9 D8         ld   (D8A9),a
ROM1:4D04 EA AB D8         ld   (D8AB),a
ROM1:4D07 18 1D            jr   4D26
ROM1:4D09 CD 47 2E         call 2E47
ROM1:4D0C AF               xor  a
ROM1:4D0D EA A9 D8         ld   (D8A9),a
ROM1:4D10 EA AB D8         ld   (D8AB),a
ROM1:4D13 3E 04            ld   a,04
ROM1:4D15 CD 16 0F         call 0F16
ROM1:4D18 CD 1A 44         call 441A
ROM1:4D1B CD 9A 10         call 109A
ROM1:4D1E CD 07 11         call 1107
ROM1:4D21 1E 05            ld   e,05
ROM1:4D23 CD B8 44         call 44B8
ROM1:4D26 E1               pop  hl
ROM1:4D27 D1               pop  de
ROM1:4D28 C1               pop  bc
ROM1:4D29 F1               pop  af
ROM1:4D2A C9               ret

Graphics 1

  • 0x5000-0x5B00 - Cursors

Checks Game Boy Color

ROM1:5BB3 F5               push af
ROM1:5BB4 F0 DD            ld   a,(ff00+DD)
ROM1:5BB6 FE 11            cp   a,11
ROM1:5BB8 20 03            jr   nz,5BBD		// If(system ≠ GBC), get out of this function
ROM1:5BBA CD D7 5B         call 5BD7
ROM1:5BBD F1               pop  af
ROM1:5BBE C9               ret

Bank 2

2:4D8A

ROM2:4D8A F5               push af
ROM2:4D8B CD 16 2D         call 2D16
ROM2:4D8E 3E 04            ld   a,04
ROM2:4D90 EA BF D9         ld   (D9BF),a
ROM2:4D93 3E 71            ld   a,71
ROM2:4D95 EA C0 D9         ld   (D9C0),a
ROM2:4D98 CF               rst  08
ROM2:4D99 03               inc  bc
ROM2:4D9A 06 CD            ld   b,CD
ROM2:4D9C 6E               ld   l,(hl)
ROM2:4D9D 2D               dec  l
ROM2:4D9E CD B2 43         call 43B2
ROM2:4DA1 F1               pop  af
ROM2:4DA2 C9               ret

Bank 3

CPU Deck

Initialize CPU Deck

  • 0xB24A-0xB263 - Initialize CPU Deck
ROM3:424A F5               push af
ROM3:424B C5               push bc
ROM3:424C E5               push hl
ROM3:424D 3E 00            ld   a,00
ROM3:424F EA 65 D9         ld   (D965),a	// Current card in CPU Deck is the first card
ROM3:4252 21 15 D9         ld   hl,D915
ROM3:4255 0E 28            ld   c,28
ROM3:4257 3E D0            ld   a,D0
ROM3:4259 22               ldi  (hl),a
ROM3:425A 3E 02            ld   a,02
ROM3:425C 22               ldi  (hl),a
ROM3:425D 0D               dec  c
ROM3:425E 20 F7            jr   nz,4257		// Fills CPU deck with 0x2D0 (no card)
ROM3:4260 E1               pop  hl
ROM3:4261 C1               pop  bc
ROM3:4262 F1               pop  af
ROM3:4263 C9               ret

Change top card of CPU's Deck

  • 0xB264-0xB26E - Current card in CPU Deck
ROM3:4264 EA 65 D9         ld   (D965),a          ;Current card in CPU Deck = accumulator
ROM3:4267 C9               ret

00s top card of CPU's Deck

ROM3:4268 F5               push af
ROM3:4269 AF               xor  a
ROM3:426A EA 65 D9         ld   (D965),a          ;Current card in CPU Deck is the first card
ROM3:426D F1               pop  af
ROM3:426E C9               ret

Remove card from CPU Deck

  • 0xB26F-0xB286 - Delete the card CPU drew from its Deck
ROM3:426F F5               push af
ROM3:4270 C5               push bc
ROM3:4271 E5               push hl
ROM3:4272 06 00            ld   b,00
ROM3:4274 FA 65 D9         ld   a,(D965)	// Current card in CPU Deck
ROM3:4277 4F               ld   c,a
ROM3:4278 CB 21            sla  c
ROM3:427A 21 15 D9         ld   hl,D915
ROM3:427D 09               add  hl,bc
ROM3:427E 3E D0            ld   a,D0
ROM3:4280 22               ldi  (hl),a
ROM3:4281 36 02            ld   (hl),02		// Replace card in deck by 0x2D0 (no card)
ROM3:4283 E1               pop  hl
ROM3:4284 C1               pop  bc
ROM3:4285 F1               pop  af
ROM3:4286 C9               ret

CPU draw a card

  • 0xB287-0xB29B - Read next card to be drawn by CPU
ROM3:4287 F5               push af
ROM3:4288 E5               push hl
ROM3:4289 06 00            ld   b,00
ROM3:428B FA 65 D9         ld   a,(D965)	// Current card in CPU Deck
ROM3:428E 4F               ld   c,a
ROM3:428F CB 21            sla  c
ROM3:4291 21 15 D9         ld   hl,D915
ROM3:4294 09               add  hl,bc
ROM3:4295 2A               ldi  a,(hl)
ROM3:4296 4F               ld   c,a
ROM3:4297 3A               ldd  a,(hl)		// bc = card at (D915) + (cards drawn × 2)
ROM3:4298 47               ld   b,a
ROM3:4299 E1               pop  hl
ROM3:429A F1               pop  af
ROM3:429B C9               ret

Increase pointer to card in CPU Deck

  • 0xB29C-0xB2A9 - Increase pointer to card in CPU Deck
ROM3:429C F5               push af
ROM3:429D FA 65 D9         ld   a,(D965)	// Current card in CPU Deck
ROM3:42A0 FE 28            cp   a,28
ROM3:42A2 30 04            jr   nc,42A8		// If no more cards in CPU deck, get out of this function
ROM3:42A4 3C               inc  a
ROM3:42A5 EA 65 D9         ld   (D965),a	// (D965)++
ROM3:42A8 F1               pop  af
ROM3:42A9 C9               ret

Add card to CPU Deck

  • 0xB2AA-0xB2BF - Add card to CPU Deck
ROM3:42AA F5               push af
ROM3:42AB E5               push hl
ROM3:42AC C5               push bc
ROM3:42AD 06 00            ld   b,00
ROM3:42AF FA 65 D9         ld   a,(D965)	// Current card in CPU Deck
ROM3:42B2 4F               ld   c,a
ROM3:42B3 CB 21            sla  c
ROM3:42B5 21 15 D9         ld   hl,D915
ROM3:42B8 09               add  hl,bc
ROM3:42B9 C1               pop  bc		// Card to add in CPU Deck
ROM3:42BA 79               ld   a,c
ROM3:42BB 22               ldi  (hl),a
ROM3:42BC 70               ld   (hl),b		// Add card to CPU Deck
ROM3:42BD E1               pop  hl
ROM3:42BE F1               pop  af
ROM3:42BF C9               ret

CPU Draw Phase

  • 0xB2AA-0xB2BF - Probably the whole CPU Draw Phase
ROM3:42C0 F5               push af
ROM3:42C1 C5               push bc
ROM3:42C2 47               ld   b,a
ROM3:42C3 CD 65 4C         call 4C65
ROM3:42C6 FE 00            cp   a,00
ROM3:42C8 28 26            jr   z,42F0
ROM3:42CA FA 65 D9         ld   a,(D965)	// Current card in CPU Deck
ROM3:42CD FE 28            cp   a,28
ROM3:42CF 30 1F            jr   nc,42F0		// If the CPU has no card left in its deck, get out of this function
ROM3:42D1 0E 00            ld   c,00
ROM3:42D3 CD E4 1C         call 1CE4
ROM3:42D6 CD 87 42         call 4287		// CPU draw a card
ROM3:42D9 CD 6F 42         call 426F		// Remove card from CPU Deck
ROM3:42DC CD 9C 42         call 429C		// Increase pointer to card in CPU Deck
ROM3:42DF 79               ld   a,c
ROM3:42E0 EA 6D DA         ld   (DA6D),a
ROM3:42E3 78               ld   a,b
ROM3:42E4 EA 6E DA         ld   (DA6E),a
ROM3:42E7 CD C5 21         call 21C5
ROM3:42EA CD 77 21         call 2177
ROM3:42ED CD 3F 1D         call 1D3F
ROM3:42F0 C1               pop  bc
ROM3:42F1 F1               pop  af
ROM3:42F2 C9               ret

3:42F3 (to document)

  • 0xB2F3-0xB306 - ?
ROM3:42F3 F5               push af
ROM3:42F4 C5               push bc
ROM3:42F5 CD 68 42         call 4268		// Current card in CPU Deck is the first card
ROM3:42F8 06 00            ld   b,00
ROM3:42FA 0E 05            ld   c,05
ROM3:42FC 78               ld   a,b
ROM3:42FD CD C0 42         call 42C0
ROM3:4300 04               inc  b
ROM3:4301 0D               dec  c
ROM3:4302 20 F8            jr   nz,42FC
ROM3:4304 C1               pop  bc
ROM3:4305 F1               pop  af
ROM3:4306 C9               ret

3:447F (to document)

  • 0xB47F-0xB482 - Stores ? in (DA22)
ROM3:447F EA 22 DA         ld   (DA22),a
ROM3:4482 C9               ret

3:4483 (set DA22 to 0)

  • 0xB483-0xB489 - ?
ROM3:4483 F5               push af
ROM3:4484 AF               xor  a
ROM3:4485 EA 22 DA         ld   (DA22),a		// (DA22) = 0
ROM3:4488 F1               pop  af
ROM3:4489 C9               ret

3:448A (to document)

  • 0xB48A-0xB4A1 - ?
ROM3:448A F5               push af
ROM3:448B C5               push bc
ROM3:448C E5               push hl
ROM3:448D 06 00            ld   b,00
ROM3:448F FA 22 DA         ld   a,(DA22)
ROM3:4492 4F               ld   c,a
ROM3:4493 CB 21            sla  c
ROM3:4495 21 D2 D9         ld   hl,D9D2
ROM3:4498 09               add  hl,bc
ROM3:4499 3E D0            ld   a,D0
ROM3:449B 22               ldi  (hl),a
ROM3:449C 36 02            ld   (hl),02
ROM3:449E E1               pop  hl
ROM3:449F C1               pop  bc
ROM3:44A0 F1               pop  af
ROM3:44A1 C9               ret

3:44A2 (to document)

  • 0xB4A2-0xB4B5 - ?
ROM3:44A2 F5               push af
ROM3:44A3 E5               push hl
ROM3:44A4 06 00            ld   b,00
ROM3:44A6 FA 22 DA         ld   a,(DA22)
ROM3:44A9 4F               ld   c,a
ROM3:44AA CB 21            sla  c
ROM3:44AC 21 D2 D9         ld   hl,D9D2
ROM3:44AF 09               add  hl,bc		// hl = D9D2 + ((DA22) × 2)
ROM3:44B0 2A               ldi  a,(hl)
ROM3:44B1 4F               ld   c,a
ROM3:44B2 46               ld   b,(hl)		// Loads card ID (or 0x2D0 if no card)
ROM3:44B3 E1               pop  hl
ROM3:44B4 F1               pop  af
ROM3:44B5 C9               ret

3:59EC (to document)

  • 0xC9EC-0xC9F3 - ?
ROM3:59EC FA 1C DB         ld   a,(DB1C)
ROM3:59EF 57               ld   d,a
ROM3:59F0 CD 04 5A         call 5A04
ROM3:59F3 CF               rst  08

3:5A04 (to document)

  • 0xCA04-0xCA25 - ?
ROM3:5A04 F5               push af
ROM3:5A05 C5               push bc
ROM3:5A06 D5               push de
ROM3:5A07 E5               push hl
ROM3:5A08 5F               ld   e,a
ROM3:5A09 7B               ld   a,e
ROM3:5A0A CD 7F 44         call 447F
ROM3:5A0D CD A2 44         call 44A2
ROM3:5A10 CD 86 1D         call 1D86          ;Checks if Card ID is 721
ROM3:5A13 FE 01            cp   a,01
ROM3:5A15 28 0A            jr   z,5A21        ;if(bc == 721), get out of this function
ROM3:5A17 1C               inc  e
ROM3:5A18 7B               ld   a,e
ROM3:5A19 FE 28            cp   a,28
ROM3:5A1B 20 02            jr   nz,5A1F
ROM3:5A1D 1E 00            ld   e,00
ROM3:5A1F 18 E8            jr   5A09
ROM3:5A21 E1               pop  hl
ROM3:5A22 D1               pop  de
ROM3:5A23 C1               pop  bc
ROM3:5A24 F1               pop  af
ROM3:5A25 C9               ret

3:5B2A - Handles Fusion Summon ?

ROM3:5B2A F5               push af
ROM3:5B2B C5               push bc
ROM3:5B2C E5               push hl
ROM3:5B2D CD CA 4A         call 4ACA          ;Stores Fusion Material #1 and 2 in wDB4E and wDB50
ROM3:5B30 CD 6A 5B         call 5B6A
ROM3:5B33 CD 68 71         call 7168
ROM3:5B36 E1               pop  hl
ROM3:5B37 C1               pop  bc
ROM3:5B38 F1               pop  af
ROM3:5B39 C9               ret

Bank 4

rst 08 pointers

ROM4:4002
28 40
7E 40
1E 4A
3A 4A - Save file sanity check
BC 4A - Save after a Duel
D2 4A
D5 4B - Normal New Game
E8 4B - Debug New Game
2B 4A - Enable MBC2 RAM
33 4A - Disable MBC2 RAM
FB 4B - Enables Debug
0F 44 - ?
59 4D
6A 4F
A1 58
BE 58
08 5A
E4 59 - Determines if Grandpa will give out a card ?
48 5A

Main Menu

Main Menu handler

  • 0x1017F-0x101A7 - Main Menu handler
ROM4:417F C5               push bc
ROM4:4180 E5               push hl
ROM4:4181 3E 04            ld   a,04
ROM4:4183 CD 16 0F         call 0F16
ROM4:4186 CD AC 42         call 42AC		// Branch to selected Menu
ROM4:4189 CD 9A 10         call 109A
ROM4:418C CD 07 11         call 1107
ROM4:418F 06 00            ld   b,00
ROM4:4191 FA 1D DB         ld   a,(DB1D)
ROM4:4194 4F               ld   c,a
ROM4:4195 CB 21            sla  c
ROM4:4197 21 A8 41         ld   hl,41A8
ROM4:419A 09               add  hl,bc
ROM4:419B 2A               ldi  a,(hl)
ROM4:419C 66               ld   h,(hl)
ROM4:419D 6F               ld   l,a
ROM4:419E 01 A3 41         ld   bc,41A3
ROM4:41A1 C5               push bc
ROM4:41A2 E9               jp   hl
ROM4:41A3 3E 01            ld   a,01
ROM4:41A5 E1               pop  hl
ROM4:41A6 C1               pop  bc
ROM4:41A7 C9               ret

Updates Menu ID

  • 0x10271-0x10283 - Updates Menu ID in Main Menu
ROM4:4271 3E 04            ld   a,04
ROM4:4273 CD 16 0F         call 0F16
ROM4:4276 CD 8D 42         call 428D
ROM4:4279 CD AC 42         call 42AC
ROM4:427C CD 9A 10         call 109A
ROM4:427F CD 07 11         call 1107
ROM4:4282 AF               xor  a
ROM4:4283 C9               ret

Initializes Menu ID

  • 0x10284-0x1028A - Initializes Menu ID to 0
ROM4:4284 F5               push af
ROM4:4285 AF               xor  a
ROM4:4286 EA 1D DB         ld   (DB1D),a
ROM4:4289 F1               pop  af
ROM4:428A C9               ret

Increment Menu ID

  • 0x1028D-0x1029B - Menu ID + 1
ROM4:428D F5               push af
ROM4:428E FA 1D DB         ld   a,(DB1D)
ROM4:4291 3C               inc  a
ROM4:4292 FE 06            cp   a,06
ROM4:4294 20 01            jr   nz,4297
ROM4:4296 AF               xor  a
ROM4:4297 EA 1D DB         ld   (DB1D),a
ROM4:429A F1               pop  af
ROM4:429B C9               ret

Decrement Menu ID

  • 0x1029C-0x102AB - Menu ID - 1
ROM4:429C F5               push af
ROM4:429D FA 1D DB         ld   a,(DB1D)
ROM4:42A0 3D               dec  a
ROM4:42A1 FE FF            cp   a,FF
ROM4:42A3 20 02            jr   nz,42A7
ROM4:42A5 3E 05            ld   a,05
ROM4:42A7 EA 1D DB         ld   (DB1D),a
ROM4:42AA F1               pop  af
ROM4:42AB C9               ret

Branch to selected Menu

  • 0x102AC-0x102C1 - Branch to specific instructions for selected Menu ID
ROM4:42AC F5               push af
ROM4:42AD C5               push bc
ROM4:42AE D5               push de
ROM4:42AF E5               push hl
ROM4:42B0 FA 1D DB         ld   a,(DB1D)
ROM4:42B3 CD C2 42         call 42C2
ROM4:42B6 79               ld   a,c
ROM4:42B7 11 02 00         ld   de,0002
ROM4:42BA CD BE 13         call 13BE
ROM4:42BD E1               pop  hl
ROM4:42BE D1               pop  de
ROM4:42BF C1               pop  bc
ROM4:42C0 F1               pop  af
ROM4:42C1 C9               ret

Load data of selected Menu ID

  • 0x102C2-0x102D2 - Load array corresponding to Menu ID
ROM4:42C2 F5               push af
ROM4:42C3 E5               push hl
ROM4:42C4 06 00            ld   b,00
ROM4:42C6 4F               ld   c,a
ROM4:42C7 CB 21            sla  c
ROM4:42C9 21 D3 42         ld   hl,42D3
ROM4:42CC 09               add  hl,bc		// hl = 0x42D3 + (Menu ID × 2)
ROM4:42CD 2A               ldi  a,(hl)
ROM4:42CE 47               ld   b,a
ROM4:42CF 4E               ld   c,(hl)
ROM4:42D0 E1               pop  hl
ROM4:42D1 F1               pop  af
ROM4:42D2 C9               ret

Menus pointers

  • 0x102D3-0x102E2 - Menus pointers array
ROM4:42D3
50 26 - Campaign
74 3B - Versus
73 62 - Trade
51 78 - Records
2E 62 - Change Name
2D 3B - Password
F5 C5 - Sound Test
0E 01 - Character Viewer

SRAM management

4:4403 (to document)

  • 0x10403-0x10407 - Calls 4:440F, then rst 08
ROM4:4403 F5               push af
ROM4:4404 CD 0F 44         call 440F
ROM4:4407 CF               rst  08
  • 0x1040F-0x1041E - ?
ROM4:440F C5               push bc
ROM4:4410 E5               push hl
ROM4:4411 06 00            ld   b,00
ROM4:4413 CD 08 5A         call 5A08		// Load Stage 5 opponent ID
ROM4:4416 4F               ld   c,a
ROM4:4417 21 1F 44         ld   hl,441F
ROM4:441A 09               add  hl,bc
ROM4:441B 7E               ld   a,(hl)
ROM4:441C E1               pop  hl
ROM4:441D C1               pop  bc
ROM4:441E C9               ret
  • 0x1041F-0x10422 - Array ?
ROM4:441F
14 15 16 17

Enable MBC2 RAM

  • 0x10A2B-0x10A32 - Enable MBC2 battery RAM
ROM4:4A2B F5               push af
ROM4:4A2C 3E 0A            ld   a,0A
ROM4:4A2E EA 00 00         ld   (0000),a
ROM4:4A31 F1               pop  af
ROM4:4A32 C9               ret

Disable MBC2 RAM

  • 0x10A33-0x10A39 - Disable MBC2 battery RAM
ROM4:4A33 F5               push af
ROM4:4A34 AF               xor  a
ROM4:4A35 EA 00 00         ld   (0000),a
ROM4:4A38 F1               pop  af
ROM4:4A39 C9               ret

Save file sanity check

  • 0x10A3A-0x10A74 - Save file sanity check, creates a new save file if the current save is corrupted
ROM4:4A3A F5               push af
ROM4:4A3B CD 2B 4A         call 4A2B		// Enable MBC2 RAM
ROM4:4A3E FA FF B7         ld   a,(B7FF)	// Debug
ROM4:4A41 EA 96 DB         ld   (DB96),a	// Copies Debug value to (DB96)
ROM4:4A44 3E 00            ld   a,00
ROM4:4A46 EA 98 DB         ld   (DB98),a	// (DB98) = 0
ROM4:4A49 CD 6F 4C         call 4C6F		// SRAM KONAMI check
ROM4:4A4C FE 01            cp   a,01
ROM4:4A4E 20 0B            jr   nz,4A5B		// If the « KONAMI » string is correct, jump to 4:4A5B
ROM4:4A50 CD 73 50         call 5073		// Name Input screen
ROM4:4A53 CD 75 4A         call 4A75		// Erase SRAM and create a new Save File
ROM4:4A56 3E 01            ld   a,01
ROM4:4A58 EA 98 DB         ld   (DB98),a	// (DB98) = 1
ROM4:4A5B CD 93 4B         call 4B93		// Check SRAM Block and Checksum
ROM4:4A5E FE 01            cp   a,01
ROM4:4A60 20 0B            jr   nz,4A6D		// If the save file is not corrupted, jump to 4:4A6D
ROM4:4A62 CD 73 50         call 5073		// Name Input screen
ROM4:4A65 CD 75 4A         call 4A75		// Erase SRAM and create a new Save File
ROM4:4A68 3E 01            ld   a,01
ROM4:4A6A EA 98 DB         ld   (DB98),a	// (DB98) = 1
ROM4:4A6D CD E2 4A         call 4AE2		// Clones SRAM if SRAM block 2
ROM4:4A70 CD 33 4A         call 4A33		// Disable MBC2 RAM
ROM4:4A73 F1               pop  af
ROM4:4A74 C9               ret

New Save file

  • 0x10A3A-0x10A74 - Creates a new Save file
ROM4:4A75 CD 8E 4A         call 4A8E		// Erases save file
ROM4:4A78 CD A6 4A         call 4AA6		// Blanks (B800) to (BFFF), set Stage 5 opponent and (FFDB) to a PRN
ROM4:4A7B CD 4D 4C         call 4C4D
ROM4:4A7E CD 13 4C         call 4C13		// SRAM Block 1
ROM4:4A81 CD 8C 4C         call 4C8C		// Copy Data in SRAM
ROM4:4A84 CD 20 4C         call 4C20		// SRAM Block 1
ROM4:4A87 CD EF 4A         call 4AEF		// Clones SRAM
ROM4:4A8A CD 06 4C         call 4C06		// SRAM write successful !
ROM4:4A8D C9               ret

Blanks SRAM

  • 0x10A8E-0x10AA5 - 00s SRAM area (A000) to (BFFF)
ROM4:4A8E F5               push af
ROM4:4A8F C5               push bc
ROM4:4A90 D5               push de
ROM4:4A91 E5               push hl
ROM4:4A92 21 00 A0         ld   hl,A000
ROM4:4A95 AF               xor  a
ROM4:4A96 06 20            ld   b,20
ROM4:4A98 0E 00            ld   c,00
ROM4:4A9A 22               ldi  (hl),a
ROM4:4A9B 0D               dec  c
ROM4:4A9C 20 FC            jr   nz,4A9A
ROM4:4A9E 05               dec  b
ROM4:4A9F 20 F7            jr   nz,4A98
ROM4:4AA1 E1               pop  hl
ROM4:4AA2 D1               pop  de
ROM4:4AA3 C1               pop  bc
ROM4:4AA4 F1               pop  af
ROM4:4AA5 C9               ret
  • 0x10AA6-0x10AB5 - Calls 4:5866, then rst 08
ROM4:4AA6 CD 66 58         call 5866	// Blanks (B800) to (BFFF), set Stage 5 opponent and (FFDB) to a PRN
ROM4:4AA9 CF               rst  08

Save after a Duel

  • 0x10ABC-0x10AD1 - Save after a Duel
ROM4:4ABC CD 2B 4A         call 4A2B		// Enable MBC2 RAM
ROM4:4ABF CD 13 4C         call 4C13		// SRAM Block 1
ROM4:4AC2 CD 8C 4C         call 4C8C		// Copy Data in SRAM
ROM4:4AC5 CD 20 4C         call 4C20		// SRAM Block 2
ROM4:4AC8 CD EF 4A         call 4AEF		// Clones SRAM
ROM4:4ACB CD 06 4C         call 4C06		// SRAM block 0
ROM4:4ACE CD 33 4A         call 4A33		// Disable MBC2 RAM
ROM4:4AD1 C9               ret

Save after Deck change

  • 0x10ABC-0x10AD1 -
ROM4:4AD2 CD 2B 4A         call 4A2B		// Enable MBC2 RAM
ROM4:4AD5 CD 06 4C         call 4C06		// SRAM Block 0
ROM4:4AD8 CD 13 4B         call 4C13		// SRAM Block 1
ROM4:4ADB CD BA 4C         call 4CBA
ROM4:4ADE CD 33 4A         call 4A33		// Disable MBC2 RAM
ROM4:4AE1 C9               ret

Clones SRAM

  • 0x10AE2-0x10AEE - Checks SRAM block, and clones it if it's a temporary block
ROM4:4AE2 F5               push af
ROM4:4AE3 FA F0 B7         ld   a,(B7F0)
ROM4:4AE6 FE 02            cp   a,02
ROM4:4AE8 20 03            jr   nz,4AED		// If(SRAM block ≠ 2), jump to 4:4AED
ROM4:4AEA CD EF 4A         call 4AEF		// Clones SRAM
ROM4:4AED F1               pop  af
ROM4:4AEE C9               ret
  • 0x10AEF-0x10B12 - Clones SRAM 0xA000-0xABF8
ROM4:4AEF F5               push af
ROM4:4AF0 C5               push bc
ROM4:4AF1 D5               push de
ROM4:4AF2 E5               push hl
ROM4:4AF3 21 00 A0         ld   hl,A000
ROM4:4AF6 11 F8 AB         ld   de,ABF8
ROM4:4AF9 0E F8            ld   c,F8
ROM4:4AFB 2A               ldi  a,(hl)
ROM4:4AFC 12               ld   (de),a
ROM4:4AFD 13               inc  de
ROM4:4AFE 0D               dec  c
ROM4:4AFF 20 FA            jr   nz,4AFB
ROM4:4B01 06 0B            ld   b,0B
ROM4:4B03 0E 00            ld   c,00
ROM4:4B05 2A               ldi  a,(hl)
ROM4:4B06 12               ld   (de),a
ROM4:4B07 13               inc  de
ROM4:4B08 0D               dec  c
ROM4:4B09 20 FA            jr   nz,4B05
ROM4:4B0B 05               dec  b
ROM4:4B0C 20 F5            jr   nz,4B03
ROM4:4B0E E1               pop  hl
ROM4:4B0F D1               pop  de
ROM4:4B10 C1               pop  bc
ROM4:4B11 F1               pop  af
ROM4:4B12 C9               ret

SRAM checksum pointers

  • 0x10B55-0x10B58 - SRAM checksum pointers array
ROM4:4B57
F6 AB
EE B7

SRAM Checksum calculation

  • 0x10B59-0x10B8E - Calculate SRAM checksum
ROM4:4B59 F5               push af
ROM4:4B5A C5               push bc
ROM4:4B5B E5               push hl
ROM4:4B5C 06 00            ld   b,00
ROM4:4B5E FA 97 DB         ld   a,(DB97)
ROM4:4B61 4F               ld   c,a
ROM4:4B62 CB 21            sla  c
ROM4:4B64 21 8F 4B         ld   hl,4B8F
ROM4:4B67 09               add  hl,bc		// hl = 0x4B8F + (Save file block × 2)
ROM4:4B68 2A               ldi  a,(hl)
ROM4:4B69 66               ld   h,(hl)
ROM4:4B6A 6F               ld   l,a		// hl = Save file block pointer
ROM4:4B6B 11 00 00         ld   de,0000
ROM4:4B6E 0E F6            ld   c,F6
ROM4:4B70 2A               ldi  a,(hl)		// Add every byte of the SRAM block
ROM4:4B71 83               add  e
ROM4:4B72 5F               ld   e,a
ROM4:4B73 3E 00            ld   a,00
ROM4:4B75 8A               adc  d
ROM4:4B76 57               ld   d,a
ROM4:4B77 0D               dec  c
ROM4:4B78 20 F6            jr   nz,4B70
ROM4:4B7A 06 0B            ld   b,0B
ROM4:4B7C 0E 00            ld   c,00
ROM4:4B7E 2A               ldi  a,(hl)
ROM4:4B7F 83               add  e
ROM4:4B80 5F               ld   e,a
ROM4:4B81 3E 00            ld   a,00
ROM4:4B83 8A               adc  d
ROM4:4B84 57               ld   d,a
ROM4:4B85 0D               dec  c
ROM4:4B86 20 F6            jr   nz,4B7E
ROM4:4B88 05               dec  b
ROM4:4B89 20 F1            jr   nz,4B7C		// Loop until it's finished
ROM4:4B8B E1               pop  hl
ROM4:4B8C C1               pop  bc
ROM4:4B8D F1               pop  af
ROM4:4B8E C9               ret

SRAM blocks pointers

  • 0x10B8F-0x10B92 - SRAM blocks pointers array
ROM4:4B8F
00 A0 - Block 1
F8 AB - Block 2

SRAM Block and Checksum check

  • 0x10AEF-0x10B12 - Save file sanity check
ROM4:4B93 C5               push bc
ROM4:4B94 D5               push de
ROM4:4B95 E5               push hl
ROM4:4B96 FA F0 B7         ld   a,(B7F0)	// SRAM block
ROM4:4B99 FE 03            cp   a,03
ROM4:4B9B 38 04            jr   c,4BA1		// If the SRAM block is valid, jump to 4:4BA1
ROM4:4B9D 3E 01            ld   a,01		// Else, flag the save file as corrupted...
ROM4:4B9F 18 2D            jr   4BCE		// ...and get out of this function
ROM4:4BA1 06 00            ld   b,00
ROM4:4BA3 FA F0 B7         ld   a,(B7F0)
ROM4:4BA6 4F               ld   c,a
ROM4:4BA7 21 D2 4B         ld   hl,4BD2
ROM4:4BAA 09               add  hl,bc		// hl = 0x4BD2 + SRAM block
ROM4:4BAB 7E               ld   a,(hl)
ROM4:4BAC EA 97 DB         ld   (DB97),a	// (DB97) = Save file block
ROM4:4BAF CD 59 4B         call 4B59		// de = SRAM Checksum
ROM4:4BB2 06 00            ld   b,00
ROM4:4BB4 FA 97 DB         ld   a,(DB97)
ROM4:4BB7 4F               ld   c,a
ROM4:4BB8 CB 21            sla  c
ROM4:4BBA 21 55 4B         ld   hl,4B55
ROM4:4BBD 09               add  hl,bc		// hl = 0x4B55 + (Save file block × 2)
ROM4:4BBE 2A               ldi  a,(hl)
ROM4:4BBF 66               ld   h,(hl)
ROM4:4BC0 6F               ld   l,a
ROM4:4BC1 2A               ldi  a,(hl)
ROM4:4BC2 BB               cp   e
ROM4:4BC3 28 02            jr   z,4BC7
ROM4:4BC5 06 01            ld   b,01		// If the checksum is invalid, flag the save file as corrupted
ROM4:4BC7 7E               ld   a,(hl)
ROM4:4BC8 BA               cp   d
ROM4:4BC9 28 02            jr   z,4BCD
ROM4:4BCB 06 01            ld   b,01		// If the checksum is invalid, flag the save file as corrupted
ROM4:4BCD 78               ld   a,b
ROM4:4BCE E1               pop  hl
ROM4:4BCF D1               pop  de
ROM4:4BD0 C1               pop  bc
ROM4:4BD1 C9               ret
  • 0x10BD2-0x10BD5 - Save file blocks array
ROM4:4BD2
01 01 00

Normal New Game

  • 0x10BD5-0x10BE7 - Normal New Game
ROM4:4BD5 F5               push af
ROM4:4BD6 CD 2B 4A         call 4A2B		// Enable MBC2 RAM
ROM4:4BD9 3E AA            ld   a,AA
ROM4:4BDB EA F1 B7         ld   (B7F1),a
ROM4:4BDE 3E 00            ld   a,00
ROM4:4BE0 EA FF B7         ld   (B7FF),a	// No debug
ROM4:4BE3 CD 33 4A         call 4A33		// Disable MBC2 RAM
ROM4:4BE6 F1               pop  af
ROM4:4BE7 C9               ret

Debug New Game

  • 0x10BD5-0x10BE7 - Debug New Game
ROM4:4BE8 F5               push af
ROM4:4BE9 CD 2B 4A         call 4A2B		// Enable MBC2 RAM
ROM4:4BEC 3E AA            ld   a,AA
ROM4:4BEE EA F1 B7         ld   (B7F1),a
ROM4:4BF1 3E 01            ld   a,01
ROM4:4BF3 EA FF B7         ld   (B7FF),a	// Debug
ROM4:4BF6 CD 33 4A         call 4A33		// Disable MBC2 RAM
ROM4:4BF9 F1               pop  af
ROM4:4BFA C9               ret
  • 0x10BFB-0x10C05 - Enables Debug features if RAM 0xDB96 ≠ 0 (copy from SRAM 0xB7FF), and the xor a is removed
ROM4:4BFB FA 96 DB         ld   a,(DB96)
ROM4:4BFE FE 00            cp   a,00
ROM4:4C00 28 02            jr   z,4C04
ROM4:4C02 3E 01            ld   a,01
ROM4:4C04 AF               xor  a
ROM4:4C05 C9               ret

SRAM blocks

  • 0x10C06-0x10C12 - Writes 0x00 to SRAM 0xB7F0, writes 0x00 to WRAM 0xDB97
ROM4:4C06 F5               push af
ROM4:4C07 3E 00            ld   a,00
ROM4:4C09 EA F0 B7         ld   (B7F0),a
ROM4:4C0C 3E 00            ld   a,00
ROM4:4C0E EA 97 DB         ld   (DB97),a
ROM4:4C11 F1               pop  af
ROM4:4C12 C9               ret
  • 0x10C13-0x10C1F - Writes 0x01 to SRAM 0xB7F0, writes 0x00 to WRAM 0xDB97
ROM4:4C13 F5               push af
ROM4:4C14 3E 01            ld   a,01
ROM4:4C16 EA F0 B7         ld   (B7F0),a
ROM4:4C19 3E 00            ld   a,00
ROM4:4C1B EA 97 DB         ld   (DB97),a
ROM4:4C1E F1               pop  af
ROM4:4C1F C9               ret
  • 0x10C20-0x10C2C - Writes 0x02 to SRAM 0xB7F0, writes 0x01 to WRAM 0xDB97
ROM4:4C20 F5               push af
ROM4:4C21 3E 02            ld   a,02
ROM4:4C23 EA F0 B7         ld   (B7F0),a
ROM4:4C26 3E 01            ld   a,01
ROM4:4C28 EA 97 DB         ld   (DB97),a
ROM4:4C2B F1               pop  af
ROM4:4C2C C9               ret

SRAM KONAMI check

  • 0x10C64-0x10C6E - Date of build and « KONAMI » string used to check SRAM existence in function 4:4C6F.
ROM4:4C64
99 04 11 00 02 4B 4F 4E 41 4D 49
April 11, 1999 - KONAMI
  • 0x10C6F-0x10C8B - Control the presence of date of build and « KONAMI » string in SRAM at 0xB7F1-0xB7FB, to determine if save data exists.
ROM4:4C6F C5               push bc
ROM4:4C70 D5               push de
ROM4:4C71 E5               push hl
ROM4:4C72 06 00            ld   b,00
ROM4:4C74 21 F1 B7         ld   hl,B7F1
ROM4:4C77 11 64 4C         ld   de,4C64
ROM4:4C7A 0E 0B            ld   c,0B
ROM4:4C7C 1A               ld   a,(de)
ROM4:4C7D BE               cp   (hl)
ROM4:4C7E 28 02            jr   z,4C82		// If the current character is ok, jump to 4:4CB2
ROM4:4C80 06 01            ld   b,01		// Else b = 1
ROM4:4C82 23               inc  hl
ROM4:4C83 13               inc  de
ROM4:4C84 0D               dec  c
ROM4:4C85 20 F5            jr   nz,4C7C		// Loops 11 times to see if « 99 04 11 KONAMI » is present in SRAM at (B7F1)-(B7FB).
ROM4:4C87 78               ld   a,b
ROM4:4C88 E1               pop  hl
ROM4:4C89 D1               pop  de
ROM4:4C8A C1               pop  bc
ROM4:4C8B C9               ret

Copy data to SRAM after a Duel

  • 0x10C8C-0x10CB9 - Copy various data in SRAM, including Stage 5 opponent
ROM4:4C8C F5               push af
ROM4:4C8D C5               push bc
ROM4:4C8E D5               push de
ROM4:4C8F E5               push hl
ROM4:4C90 11 00 A0         ld   de,A000
ROM4:4C93 01 E5 4C         ld   bc,4CE5
ROM4:4C96 0A               ld   a,(bc)
ROM4:4C97 6F               ld   l,a
ROM4:4C98 03               inc  bc
ROM4:4C99 0A               ld   a,(bc)
ROM4:4C9A 67               ld   h,a		// Load RAM pointer from 4:4CE5
ROM4:4C9B 03               inc  bc
ROM4:4C9C FE 00            cp   a,00
ROM4:4C9E 20 05            jr   nz,4CA5
ROM4:4CA0 7D               ld   a,l
ROM4:4CA1 FE 00            cp   a,00
ROM4:4CA3 28 0D            jr   z,4CB2		// If there's no more data to be saved, jump to 4:4CB2
ROM4:4CA5 C5               push bc
ROM4:4CA6 0A               ld   a,(bc)
ROM4:4CA7 4F               ld   c,a		// Load # of bytes to be read
ROM4:4CA8 2A               ldi  a,(hl)		// Load data at RAM pointer
ROM4:4CA9 12               ld   (de),a		// ... And write it to SRAM
ROM4:4CAA 13               inc  de
ROM4:4CAB 0D               dec  c
ROM4:4CAC 20 FA            jr   nz,4CA8		// If there's still data to be retrieved from RAM, loop to 4:4AC8
ROM4:4CAE C1               pop  bc
ROM4:4CAF 03               inc  bc
ROM4:4CB0 18 E4            jr   4C96		// Jump to 4:4C96 (next data to be copied to SRAM)
ROM4:4CB2 CD 37 4B         call 4B37
ROM4:4CB5 E1               pop  hl
ROM4:4CB6 D1               pop  de
ROM4:4CB7 C1               pop  bc
ROM4:4CB8 F1               pop  af
ROM4:4CB9 C9               ret

Copy data to SRAM after a Deck change

  • 0x10CBA-0x10CE4 - Copy various data in SRAM
ROM4:4CBA F5               push af
ROM4:4CBB C5               push bc
ROM4:4CBC D5               push de
ROM4:4CBD E5               push hl
ROM4:4CBE 11 00 A0         ld   de,A000
ROM4:4CC1 01 E5 4C         ld   bc,4CE5
ROM4:4CC4 0A               ld   a,(bc)
ROM4:4CC5 6F               ld   l,a
ROM4:4CC6 03               inc  bc
ROM4:4CC7 0A               ld   a,(bc)
ROM4:4CC8 67               ld   h,a
ROM4:4CC9 03               inc  bc
ROM4:4CCA FE 00            cp   a,00
ROM4:4CCC 20 05            jr   nz,4CD3
ROM4:4CCE 7D               ld   a,l
ROM4:4CCF FE 00            cp   a,00
ROM4:4CD1 28 0D            jr   z,4CE0
ROM4:4CD3 C5               push bc
ROM4:4CD4 0A               ld   a,(bc)
ROM4:4CD5 4F               ld   c,a
ROM4:4CD6 1A               ld   a,(de)
ROM4:4CD7 22               ldi  (hl),a
ROM4:4CD8 13               inc  de
ROM4:4CD9 0D               dec  c
ROM4:4CDA 20 FA            jr   nz,4CD6
ROM4:4CDC C1               pop  bc
ROM4:4CDD 03               inc  bc
ROM4:4CDE 18 E4            jr   4CC4
ROM4:4CE0 E1               pop  hl
ROM4:4CE1 D1               pop  de
ROM4:4CE2 C1               pop  bc
ROM4:4CE3 F1               pop  af
ROM4:4CE4 C9               ret

WRAM and HRAM pointers

  • 0x10CE5-0x10D1F - RAM pointers
ROM4:4CE5
16 DB 04 - PRNG, 4 bytes
47 DC 04 - (DC47), 4 bytes
DC FF 01 - Stage 5 opponent, 1 byte
DB FF 01 - (FFDB), 1 byte
4F DC 01 - (DC4F), 1 byte
C5 D8 50 - Player's Deck, 80 bytes
A0 D5 C8 - Cards in trunk, 720 bytes
68 D6 C8 - ...
30 D7 C8 - ...
F8 D7 78 - ...
CF DB 2C - Duel Records, 44 bytes
FB DB 2C - Wins Records, 44 bytes
30 DC 08 - (DC30), 8 bytes
00 B8 C8 - (B800), 200 bytes
C8 B8 C8 - (B8C8), 200 bytes
90 B9 C8 - (B990), 200 bytes
58 BA C8 - (BA58), 200 bytes
1B DD 5A - (DD1B), 90 bytes
D9 FF 02 - Deck Capacity, 2 bytes

Call Name Input screen

  • 0x11073-0x11076 - a = 0x0A, then rst 08 to the Name Input screen
ROM4:5073 F5               push af
ROM4:5074 3E 0A            ld   a,0A
ROM4:5076 CF               rst  08	// Continue to 3B:4004 (Name Input screen)
  • 0x11077-0x11078 - Pointer to 3B:4003
ROM4:5077
03 3B

Blanks SRAM (B800), set (FFDB) (FFDC)

  • 0x11866-0x118A0 - Blanks (B800) to (BFFF), set Stage 5 opponent and (FFDB) to a Pseudo-Random Number
ROM4:5866 F5               push af
ROM4:5867 C5               push bc
ROM4:5868 D5               push de
ROM4:5869 E5               push hl
ROM4:586A 21 16 DB         ld   hl,DB16
ROM4:586D 11 47 DC         ld   de,DC47
ROM4:5870 0E 04            ld   c,04
ROM4:5872 2A               ldi  a,(hl)
ROM4:5873 12               ld   (de),a
ROM4:5874 13               inc  de
ROM4:5875 0D               dec  c
ROM4:5876 20 FA            jr   nz,5872
ROM4:5878 21 00 B8         ld   hl,B800
ROM4:587B AF               xor  a
ROM4:587C 06 04            ld   b,04
ROM4:587E 0E C8            ld   c,C8
ROM4:5880 22               ldi  (hl),a		 ;Blanks (B800) to (BFFF)
ROM4:5881 0D               dec  c
ROM4:5882 20 FC            jr   nz,5880
ROM4:5884 05               dec  b		 ;Loop 800 times
ROM4:5885 20 F7            jr   nz,587E
ROM4:5887 AF               xor  a
ROM4:5888 EA 4F DC         ld   (DC4F),a	 ;(DC4F) = 0
ROM4:588B FA 48 DC         ld   a,(DC48)	 ;a = PRN
ROM4:588E E6 03            and  a,03
ROM4:5890 E0 DC            ld   (ff00+DC),a	 ;Stage 5 opponent = a
ROM4:5892 CD DB 20         call 20DB		 ;PRNG
ROM4:5895 FA 1C DB         ld   a,(DB1C)
ROM4:5898 E6 07            and  a,07
ROM4:589A E0 DB            ld   (ff00+DB),a      ;stores PRN & 7 in hFFDB
ROM4:589C E1               pop  hl
ROM4:589D D1               pop  de
ROM4:589E C1               pop  bc
ROM4:589F F1               pop  af
ROM4:58A0 C9               ret

Determines if Grandpa is activated

  • 0x119E4-0x11A07 - Determines if Grandpa gets/is activated, to give out a card after every battle. Only 1 in 8 saves have a chance at activating Grandpa, at a 1/256 probability. If this subroutine returns 0, Grandpa will give out a card. If this subroutine returns 1, Grandpa will not give out a card.
ROM4:59E4 C5               push bc
ROM4:59E5 0E 01            ld   c,01              ;c = 1
ROM4:59E7 F0 DB            ld   a,(ff00+DB)
ROM4:59E9 E6 07            and  a,07              ;a = Initial PRN set at SRAM creation; range [0;7]
ROM4:59EB 20 10            jr   nz,59FD           ;if (Initial SRAM PRN[0;7] ≠ 0), jump to 4:59FD
ROM4:59ED CD DB 20         call 20DB              ;PRNG
ROM4:59F0 FA 1C DB         ld   a,(DB1C)
ROM4:59F3 FE 49            cp   a,49
ROM4:59F5 20 06            jr   nz,59FD           ;if (PRN ≠ 73), jump to 4:59FD
ROM4:59F7 F0 DB            ld   a,(ff00+DB)
ROM4:59F9 F6 80            or   a,80
ROM4:59FB E0 DB            ld   (ff00+DB),a       ;Activate Grandpa: hFFDB &= 0x80
ROM4:59FD F0 DB            ld   a,(ff00+DB)
ROM4:59FF E6 80            and  a,80              ;a = grandpa_activation_flag
ROM4:5A01 28 02            jr   z,5A05            ;if (grandpa_activation_flag), jump to 4:5A05
ROM4:5A03 0E 00            ld   c,00              ;c = 0
ROM4:5A05 79               ld   a,c               ;a = c
ROM4:5A06 C1               pop  bc
ROM4:5A07 C9               ret

Stage 5 opponent

Loads Stage 5 opponent ID

  • 0x11A08-0x11A0C - Loads the Stage 5 opponent ID
ROM4:5A08 F0 DC            ld   a,(ff00+DC)
ROM4:5A0A E6 03            and  a,03
ROM4:5A0C C9               ret

Changes Stage 5 opponent

  • 0x11A0D-0x11A47 - Calls PRNG to determine if the Stage 5 opponent changes
3/4096 chance to change Stage 5 opponent after each duel: 1/256, then 1/4, then 3/4
ROM4:5A0D F5               push af
ROM4:5A0E C5               push bc
ROM4:5A0F CD DB 20         call 20DB		// PRNG, between 0 and 255
ROM4:5A12 FA 1C DB         ld   a,(DB1C)
ROM4:5A15 FE 00            cp   a,00
ROM4:5A17 20 2C            jr   nz,5A45		// If PRN ≠ 0, get out of this function
ROM4:5A19 3E 00            ld   a,00
ROM4:5A1B EA 1A DB         ld   (DB1A),a	// min = 0
ROM4:5A1E 3E 03            ld   a,03
ROM4:5A20 EA 1B DB         ld   (DB1B),a	// max = 3
ROM4:5A23 CD 0B 21         call 210B		// PRNG, between 0 and 3
ROM4:5A26 FA 1C DB         ld   a,(DB1C)
ROM4:5A29 FE 00            cp   a,00
ROM4:5A2B 20 18            jr   nz,5A45		// If(PRN ≠ 0), get out of this function
ROM4:5A2D F0 DC            ld   a,(ff00+DC)
ROM4:5A2F 47               ld   b,a		// b = Stage 5 opponent ID
ROM4:5A30 3E 00            ld   a,00
ROM4:5A32 EA 1A DB         ld   (DB1A),a	// min = 0
ROM4:5A35 3E 03            ld   a,03
ROM4:5A37 EA 1B DB         ld   (DB1B),a	// max = 3
ROM4:5A3A CD 0B 21         call 210B		// PRNG, between 0 and 3
ROM4:5A3D FA 1C DB         ld   a,(DB1C)
ROM4:5A40 B8               cp   b
ROM4:5A41 28 02            jr   z,5A45		// If(PRN == Stage 5 opponent ID), get out of this function
ROM4:5A43 E0 DC            ld   (ff00+DC),a	// Load new Stage 5 opponent ID in (FFDC)
ROM4:5A45 C1               pop  bc
ROM4:5A46 F1               pop  af
ROM4:5A47 C9               ret

Bank 5

Deck Capacity

Initial DC

  • 0x15B2E-0x15B45 - Initial Deck Capacity
ROM5:5B2E FE 00            cp   a,00
ROM5:5B30 20 0A            jr   nz,5B3C              ;if debug, jump to 5:5B3C
ROM5:5B32 3E 90            ld   a,90
ROM5:5B34 E0 D9            ld   (ff00+D9),a
ROM5:5B36 3E 01            ld   a,01
ROM5:5B38 E0 DA            ld   (ff00+DA),a          ;set Deck Capacity to 400
ROM5:5B3A 18 08            jr   5B44
ROM5:5B3C 3E 0F            ld   a,0F
ROM5:5B3E E0 D9            ld   (ff00+D9),a
ROM5:5B40 3E 27            ld   a,27
ROM5:5B42 E0 DA            ld   (ff00+DA),a          ;set Deck Capacity to 9999
ROM5:5B44 F1               pop  af
ROM5:5B45 C9               ret

Retrieve current DC

ROM5:5B46 F5               push af
ROM5:5B47 F0 D9            ld   a,(ff00+D9)
ROM5:5B49 4F               ld   c,a
ROM5:5B4A F0 DA            ld   a,(ff00+DA)
ROM5:5B4C 47               ld   b,a          ;bc = deck_capacity
ROM5:5B4D F1               pop  af
ROM5:5B4E C9               ret

5:5B4F

ROM5:5B4F C5               push bc
ROM5:5B50 F0 D9            ld   a,(ff00+D9)
ROM5:5B52 4F               ld   c,a
ROM5:5B53 F0 DA            ld   a,(ff00+DA)
ROM5:5B55 47               ld   b,a          ;bc = deck_capacity
ROM5:5B56 CD 60 5B         call 5B60
ROM5:5B59 C1               pop  bc
ROM5:5B5A C9               ret

a = 13, push / pop deck_capacity

ROM5:5B5B C5               push bc
ROM5:5B5C 3E 0D            ld   a,0D
ROM5:5B5E C1               pop  bc
ROM5:5B5F C9               ret

Duelist Level calculation

ROM5:5B60 C5               push bc
ROM5:5B61 D5               push de
ROM5:5B62 79               ld   a,c
ROM5:5B63 D6 90            sub  a,90
ROM5:5B65 5F               ld   e,a
ROM5:5B66 78               ld   a,b
ROM5:5B67 DE 01            sbc  a,01
ROM5:5B69 57               ld   d,a             ;de = deck_capacity - 400
ROM5:5B6A 01 07 00         ld   bc,0007         ;bc = 7
ROM5:5B6D CD 42 14         call 1442
ROM5:5B70 7B               ld   a,e
ROM5:5B71 C6 0F            add  a,0F            ;a += 15
ROM5:5B73 5F               ld   e,a
ROM5:5B74 7A               ld   a,d
ROM5:5B75 CE 00            adc  a,00
ROM5:5B77 57               ld   d,a
ROM5:5B78 7A               ld   a,d
ROM5:5B79 FE 00            cp   a,00
ROM5:5B7B 28 02            jr   z,5B7F
ROM5:5B7D 1E FF            ld   e,FF
ROM5:5B7F 7B               ld   a,e
ROM5:5B80 D1               pop  de
ROM5:5B81 C1               pop  bc
ROM5:5B82 C9               ret

Increment DC

ROM5:5B83 F5               push af
ROM5:5B84 C5               push bc
ROM5:5B85 D5               push de
ROM5:5B86 F0 D9            ld   a,(ff00+D9)
ROM5:5B88 C6 01            add  a,01
ROM5:5B8A 4F               ld   c,a
ROM5:5B8B F0 DA            ld   a,(ff00+DA)
ROM5:5B8D CE 00            adc  a,00
ROM5:5B8F 47               ld   b,a              ;deck_capacity ++
ROM5:5B90 11 0F 27         ld   de,270F          ;de = 9999
ROM5:5B93 CD A7 1D         call 1DA7
ROM5:5B96 FE 00            cp   a,00
ROM5:5B98 20 02            jr   nz,5B9C          ;if(deck_capacity ≤ 9999), jump to 5:5B9C
ROM5:5B9A 42               ld   b,d
ROM5:5B9B 4B               ld   c,e              ;else deck_capacity = 9999
ROM5:5B9C 79               ld   a,c
ROM5:5B9D E0 D9            ld   (ff00+D9),a
ROM5:5B9F 78               ld   a,b
ROM5:5BA0 E0 DA            ld   (ff00+DA),a      ;store deck_capacity in hFFD9
ROM5:5BA2 D1               pop  de
ROM5:5BA3 C1               pop  bc
ROM5:5BA4 F1               pop  af
ROM5:5BA5 C9               ret

Decrement DC

ROM5:5BA6 F5               push af
ROM5:5BA7 C5               push bc
ROM5:5BA8 D5               push de
ROM5:5BA9 F0 D9            ld   a,(ff00+D9)
ROM5:5BAB D6 01            sub  a,01
ROM5:5BAD 4F               ld   c,a
ROM5:5BAE F0 DA            ld   a,(ff00+DA)
ROM5:5BB0 DE 00            sbc  a,00
ROM5:5BB2 47               ld   b,a              ;deck_capacity --
ROM5:5BB3 11 90 01         ld   de,0190          ;de = 400
ROM5:5BB6 CD A7 1D         call 1DA7
ROM5:5BB9 FE 02            cp   a,02
ROM5:5BBB 20 02            jr   nz,5BBF          ;if(deck_capacity ≥ 400), jump to 5:5BBF
ROM5:5BBD 42               ld   b,d
ROM5:5BBE 4B               ld   c,e              ;else deck_capacity = 400
ROM5:5BBF 79               ld   a,c
ROM5:5BC0 E0 D9            ld   (ff00+D9),a
ROM5:5BC2 78               ld   a,b
ROM5:5BC3 E0 DA            ld   (ff00+DA),a      ;store deck_capacity in hFFD9
ROM5:5BC5 D1               pop  de
ROM5:5BC6 C1               pop  bc
ROM5:5BC7 F1               pop  af
ROM5:5BC8 C9               ret

DC + 3

ROM5:5BC9 F5               push af
ROM5:5BCA 3E 03            ld   a,03
ROM5:5BCC CD 83 5B         call 5B83        ;Increment DC
ROM5:5BCF 3D               dec  a
ROM5:5BD0 20 FA            jr   nz,5BCC
ROM5:5BD2 F1               pop  af
ROM5:5BD3 C9               ret

DC + 2

ROM5:5BD4 F5               push af
ROM5:5BD5 3E 02            ld   a,02
ROM5:5BD7 CD 83 5B         call 5B83        ;Increment DC
ROM5:5BDA 3D               dec  a
ROM5:5BDB 20 FA            jr   nz,5BD7
ROM5:5BDD F1               pop  af
ROM5:5BDE C9               ret

DC + 10

ROM5:5BDF F5               push af
ROM5:5BE0 3E 0A            ld   a,0A
ROM5:5BE2 CD 83 5B         call 5B83        ;Increment DC
ROM5:5BE5 3D               dec  a
ROM5:5BE6 20 FA            jr   nz,5BE2
ROM5:5BE8 F1               pop  af
ROM5:5BE9 C9               ret

DC + 5

ROM5:5BEA F5               push af
ROM5:5BEB 3E 05            ld   a,05
ROM5:5BED CD 83 5B         call 5B83        ;Increment DC
ROM5:5BF0 3D               dec  a
ROM5:5BF1 20 FA            jr   nz,5BED
ROM5:5BF3 F1               pop  af
ROM5:5BF4 C9               ret

DC + 1

ROM5:5BF5 F5               push af
ROM5:5BF6 3E 01            ld   a,01
ROM5:5BF8 CD 83 5B         call 5B83        ;Increment DC
ROM5:5BFB 3D               dec  a
ROM5:5BFC 20 FA            jr   nz,5BF8
ROM5:5BFE F1               pop  af
ROM5:5BFF C9               ret

DC - 50

ROM5:5C00 F5               push af
ROM5:5C01 C5               push bc
ROM5:5C02 D5               push de
ROM5:5C03 01 32 00         ld   bc,0032
ROM5:5C06 11 00 00         ld   de,0000
ROM5:5C09 CD A6 5B         call 5BA6          ;Decrement DC
ROM5:5C0C 0B               dec  bc
ROM5:5C0D CD 98 1D         call 1D98          ;Comparison between bc and de
ROM5:5C10 FE 00            cp   a,00
ROM5:5C12 20 F5            jr   nz,5C09
ROM5:5C14 D1               pop  de
ROM5:5C15 C1               pop  bc
ROM5:5C16 F1               pop  af
ROM5:5C17 C9               ret

5:5C18

ROM5:5C18 C5               push bc
ROM5:5C19 D5               push de
ROM5:5C1A E5               push hl
ROM5:5C1B 2E 00            ld   l,00
ROM5:5C1D CF               rst  08
          09 0E
ROM5:5C20 F0 D9            ld   a,(ff00+D9)
ROM5:5C22 5F               ld   e,a
ROM5:5C23 F0 DA            ld   a,(ff00+DA)
ROM5:5C25 57               ld   d,a                 ;de = deck_capacity
ROM5:5C26 CD A7 1D         call 1DA7
ROM5:5C29 FE 00            cp   a,00
ROM5:5C2B 20 02            jr   nz,5C2F
ROM5:5C2D 2E 01            ld   l,01
ROM5:5C2F 7D               ld   a,l
ROM5:5C30 E1               pop  hl
ROM5:5C31 D1               pop  de
ROM5:5C32 C1               pop  bc
ROM5:5C33 C9               ret

Check Link Duel DC

ROM5:5C34 C5               push bc
ROM5:5C35 D5               push de
ROM5:5C36 E5               push hl
ROM5:5C37 CF               rst  08
          09 0E
ROM5:5C3A 16 00            ld   d,00
ROM5:5C3C CF               rst  08
          89 0E
ROM5:5C3F 5F               ld   e,a
ROM5:5C40 CB 23            sla  e
ROM5:5C42 21 59 5C         ld   hl,5C59
ROM5:5C45 19               add  hl,de
ROM5:5C46 2A               ldi  a,(hl)
ROM5:5C47 56               ld   d,(hl)
ROM5:5C48 5F               ld   e,a                 ;de = max_deck_capacity
ROM5:5C49 CD A7 1D         call 1DA7
ROM5:5C4C 2E 00            ld   l,00
ROM5:5C4E FE 00            cp   a,00
ROM5:5C50 20 02            jr   nz,5C54
ROM5:5C52 2E 01            ld   l,01
ROM5:5C54 7D               ld   a,l
ROM5:5C55 E1               pop  hl
ROM5:5C56 D1               pop  de
ROM5:5C57 C1               pop  bc
ROM5:5C58 C9               ret
Link Duel DC array
ROM5:5C59
F4 01 -  500
BC 02 -  700
E8 03 - 1000
D0 07 - 2000
0F 27 - 9999


Check if enough DC for Password mode

  • Check if Deck Capacity ≥ 600 when trying to access Password menu
ROM5:5C63 C5               push bc
ROM5:5C64 D5               push de
ROM5:5C65 E5               push hl
ROM5:5C66 2E 00            ld   l,00
ROM5:5C68 01 58 02         ld   bc,0258              ;bc = 600
ROM5:5C6B F0 D9            ld   a,(ff00+D9)
ROM5:5C6D 5F               ld   e,a
ROM5:5C6E F0 DA            ld   a,(ff00+DA)
ROM5:5C70 57               ld   d,a                  ;de = Deck Capacity
ROM5:5C71 CD A7 1D         call 1DA7
ROM5:5C74 FE 00            cp   a,00
ROM5:5C76 20 02            jr   nz,5C7A
ROM5:5C78 2E 01            ld   l,01
ROM5:5C7A 7D               ld   a,l
ROM5:5C7B E1               pop  hl
ROM5:5C7C D1               pop  de
ROM5:5C7D C1               pop  bc
ROM5:5C7E C9               ret

Bank 9

9:4030 (Updates a card_id, used by Fusion)

ROM9:4030 F5               push af
ROM9:4031 C5               push bc
ROM9:4032 FA 6D DA         ld   a,(DA6D)
ROM9:4035 4F               ld   c,a
ROM9:4036 FA 6E DA         ld   a,(DA6E)
ROM9:4039 47               ld   b,a           ;bc = wDA6D ; Current Card ID ?
ROM9:403A CD 6E 40         call 406E
ROM9:403D CD EF 1C         call 1CEF
ROM9:4040 CD 63 40         call 4063
ROM9:4043 CD 4C 40         call 404C
ROM9:4046 CD C9 40         call 40C9
ROM9:4049 C1               pop  bc
ROM9:404A F1               pop  af
ROM9:404B C9               ret  

Retrieve card data

ROM9:406E F5               push af
ROM9:406F C5               push bc
ROM9:4070 D5               push de
ROM9:4071 E5               push hl
ROM9:4072 79               ld   a,c
ROM9:4073 EA 79 D9         ld   (D979),a
ROM9:4076 78               ld   a,b
ROM9:4077 EA 7A D9         ld   (D97A),a        ;wD979 = Current_Card_ID 
ROM9:407A 21 F7 4E         ld   hl,4EF7
ROM9:407D 09               add  hl,bc
ROM9:407E 7E               ld   a,(hl)          ;a = Card_Type_ID
ROM9:407F EA 81 D9         ld   (D981),a        ;wD981 = Card_Type_ID ; is checked if < 20 by 1:4942 when accessing Password mode
ROM9:4082 21 C8 51         ld   hl,51C8
ROM9:4085 09               add  hl,bc
ROM9:4086 7E               ld   a,(hl)
ROM9:4087 EA 83 D9         ld   (D983),a
ROM9:408A 21 3B 5A         ld   hl,5A3B
ROM9:408D 09               add  hl,bc
ROM9:408E 7E               ld   a,(hl)
ROM9:408F EA 84 D9         ld   (D984),a
ROM9:4092 21 99 54         ld   hl,5499
ROM9:4095 09               add  hl,bc
ROM9:4096 7E               ld   a,(hl)
ROM9:4097 EA 85 D9         ld   (D985),a
ROM9:409A 21 6A 57         ld   hl,576A
ROM9:409D 09               add  hl,bc
ROM9:409E 7E               ld   a,(hl)
ROM9:409F EA 86 D9         ld   (D986),a
ROM9:40A2 CB 21            sla  c
ROM9:40A4 CB 10            rl   b
ROM9:40A6 21 0B 43         ld   hl,430B
ROM9:40A9 09               add  hl,bc
ROM9:40AA 2A               ldi  a,(hl)
ROM9:40AB 56               ld   d,(hl)
ROM9:40AC 5F               ld   e,a
ROM9:40AD 7B               ld   a,e
ROM9:40AE EA 7D D9         ld   (D97D),a
ROM9:40B1 7A               ld   a,d
ROM9:40B2 EA 7E D9         ld   (D97E),a
ROM9:40B5 21 AD 48         ld   hl,48AD
ROM9:40B8 09               add  hl,bc
ROM9:40B9 2A               ldi  a,(hl)
ROM9:40BA 56               ld   d,(hl)
ROM9:40BB 5F               ld   e,a
ROM9:40BC 7B               ld   a,e
ROM9:40BD EA 7F D9         ld   (D97F),a
ROM9:40C0 7A               ld   a,d
ROM9:40C1 EA 80 D9         ld   (D980),a
ROM9:40C4 E1               pop  hl
ROM9:40C5 D1               pop  de
ROM9:40C6 C1               pop  bc
ROM9:40C7 F1               pop  af
ROM9:40C8 C9               ret

Card Types array

ROM9:4EF7
00 01 04 00 07 07 00 13 02 00 0A 03 06 04 03 01
01 01 01 01 01 07 05 02 07 04 04 12 04 02 00 0A
03 01 01 02 00 03 00 11 03 01 03 01 0F 05 05 07
09 09 0B 09 09 09 09 09 09 07 0A 0C 05 06 06 04
05 03 09 04 00 10 10 09 0D 12 13 0B 0B 03 0A 0A
0A 00 07 07 07 07 07 07 10 08 05 04 03 00 07 02
02 02 02 03 11 07 07 01 0A 01 03 02 08 03 08 07
05 01 01 09 06 03 07 03 05 00 13 0E 06 08 03 01
01 08 10 02 11 08 02 07 07 03 02 10 09 01 01 01
01 02 03 07 07 10 03 10 02 02 05 03 13 13 05 03
03 07 05 07 03 03 12 00 07 08 07 03 07 01 07 11
10 07 01 13 07 03 01 01 03 06 05 05 05 01 0F 08
10 07 03 10 02 08 10 00 05 05 02 07 10 10 06 08
09 11 0F 05 01 03 02 01 00 0A 04 01 09 07 10 03
03 03 10 02 08 0C 03 07 07 03 03 03 12 13 03 07
02 07 10 12 07 04 0C 05 10 03 0C 05 01 07 05 03
12 10 01 08 07 03 12 08 10 03 03 01 07 10 07 06
13 13 0E 08 07 09 07 03 07 05 0E 01 0B 0E 04 07
10 03 11 10 03 03 07 00 0E 00 03 06 14 14 14 14
14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14
14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14
14 14 14 14 14 14 14 14 14 14 14 14 14 14 02 03
0D 03 0E 05 00 00 02 07 10 03 01 03 07 12 09 02
03 0E 0F 01 10 03 09 03 07 03 07 00 0B 04 00 05
07 00 01 0E 03 0E 07 0E 10 0E 08 08 09 10 03 0B
07 07 05 05 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E 0E
0E 0E 0E 0E 0E 0E 0E 00 0F 12 00 01 08 10 10 10
01 03 10 0C 0C 0E 0C 0C 0E 0D 0D 10 10 10 10 0D
10 10 10 10 12 12 12 12 12 0F 0F 0F 0F 0F 0F 06
06 06 06 06 03 02 07 07 11 10 0B 09 09 09 09 09
05 0A 05 10 09 01 05 13 13 07 06 08 01 0C 01 05
10 07 09 07 09 03 10 07 12 09 0C 0E 0A 13 13 0E
0E 0E 12 12 12 10 10 10 06 06 07 10 01 07 05 05
11 01 12 01 09 09 09 0B 0F 06 02 08 05 0C 0C 0E
02 0C 13 02 10 10 01 06 03 03 00 02 0E 12 03 07
00 09 07 02 0C 0B 13 0A 0B 0A 00 03 0A 01 05 09
06 01 13 0E 06 08 10 08 0E 03 05 13 13 0B 12 08
10 13 06 02 05 05 10 07 08 10 00 05 10 10 05 08
09 0F 07 01 0F 09 10 08 0C 03 01 13 03 01 12 10
10 0C 04 01 05 0B 01 12 08 10 03 06 13 13 10 09
03 05 0E 11 0E 10 10 0E 03 07 14 14 14 14 14 14
14 14 14 14 14 14 14 14 16 16 16 14 14 16 16 14
16 16 16 16 16 16 16 16 15 15 15 15 15 15 15 15
15 15 16 16 16 16 16 16 16 16 16 16 03 03 04 03
00 00 01 01 07 10 00 00 00 05 07 03 09 0C 02 01

Bank D

Grandpa

  • 0x34037-0x34045 - Check if it is a debug game
ROMD:4037 FE 00            cp   a,00
ROMD:4039 20 07            jr   nz,4042          ;if(debug), jump to D:4042
ROMD:403B CF               rst  08
ROMD:403C 25               dec  h
ROMD:403D 04               inc  b
ROMD:403E FE 00            cp   a,00
ROMD:4040 20 0C            jr   nz,404E          ;else if(!grandpa_drop), get out of this function
ROMD:4042 CD 5D 40         call 405D
ROMD:4045 CF               rst  08
  • 0x34046-0x34050 - ?
ROMD:4046 0D               dec  c
ROMD:4047 01 CF 17         ld   bc,17CF
ROMD:404A 01 CF 23         ld   bc,23CF
ROMD:404D 02               ld   (bc),a
ROMD:404E C1               pop  bc
ROMD:404F F1               pop  af
ROMD:4050 C9               ret
  • 0x34051-0x3405C - ?
ROMD:4051 F5               push af
ROMD:4052 06 00            ld   b,00
ROMD:4054 CF               rst  08
ROMD:4055 0F               rrca
ROMD:4056 02               ld   (bc),a
ROMD:4057 4F               ld   c,a
ROMD:4058 CD E7 29         call 29E7
ROMD:405B F1               pop  af
ROMD:405C C9               ret
  • 0x3405D-0x34066 - ?
ROMD:405D F5               push af
ROMD:405E 06 00            ld   b,00
ROMD:4060 0E 12            ld   c,12
ROMD:4062 CD E7 29         call 29E7	// Gives a random Card 2
ROMD:4065 F1               pop  af
ROMD:4066 C9               ret

Password mode

D:43B2 (Check ? when accessing Password)

ROMD:43B2 C5               push bc
ROMD:43B3 D5               push de
ROMD:43B4 CF               rst  08
          09 01
ROMD:43B7 16 00            ld   d,00
ROMD:43B9 78               ld   a,b
ROMD:43BA FE 00            cp   a,00
ROMD:43BC 20 0C            jr   nz,43CA          ;if(b ≠ 0), exit this function
ROMD:43BE 79               ld   a,c
ROMD:43BF FE 00            cp   a,00
ROMD:43C1 20 07            jr   nz,43CA          ;if(c ≠ 0), exit this function
ROMD:43C3 7B               ld   a,e
ROMD:43C4 FE 32            cp   a,32
ROMD:43C6 30 02            jr   nc,43CA          ;if(e ≥ 50), exit this function
ROMD:43C8 16 01            ld   d,01             ;d = 1
ROMD:43CA 7A               ld   a,d              ;a = 1
ROMD:43CB D1               pop  de
ROMD:43CC C1               pop  bc
ROMD:43CD C9               ret

Card Passwords

  • 0x3476A-0x352A9 - Cards Passwords

Bank E

E:657C

ROME:657C F5               push af
ROME:657D C5               push bc
ROME:657E D5               push de
ROME:657F E5               push hl
ROME:6580 3E 00            ld   a,00
ROME:6582 EA C4 D8         ld   (D8C4),a
ROME:6585 21 C5 D8         ld   hl,D8C5
ROME:6588 0E 28            ld   c,28
ROME:658A 3E D0            ld   a,D0
ROME:658C 22               ldi  (hl),a
ROME:658D 3E 02            ld   a,02
ROME:658F 22               ldi  (hl),a
ROME:6590 0D               dec  c
ROME:6591 20 F7            jr   nz,658A
ROME:6593 E1               pop  hl
ROME:6594 D1               pop  de
ROME:6595 C1               pop  bc
ROME:6596 F1               pop  af
ROME:6597 C9               ret

E:6598

ROME:6598 EA C4 D8         ld   (D8C4),a
ROME:659B C9               ret

E:659C

ROME:659C F5               push af
ROME:659D C5               push bc
ROME:659E D5               push de
ROME:659F E5               push hl
ROME:65A0 16 00            ld   d,00
ROME:65A2 FA C4 D8         ld   a,(D8C4)
ROME:65A5 5F               ld   e,a
ROME:65A6 CB 23            sla  e
ROME:65A8 21 C5 D8         ld   hl,D8C5
ROME:65AB 19               add  hl,de
ROME:65AC 79               ld   a,c
ROME:65AD 22               ldi  (hl),a
ROME:65AE 70               ld   (hl),b
ROME:65AF E1               pop  hl
ROME:65B0 D1               pop  de
ROME:65B1 C1               pop  bc
ROME:65B2 F1               pop  af
ROME:65B3 C9               ret

E:65B4

ROME:65B4 F5               push af
ROME:65B5 E5               push hl
ROME:65B6 06 00            ld   b,00
ROME:65B8 FA C4 D8         ld   a,(D8C4)
ROME:65BB 4F               ld   c,a
ROME:65BC CB 21            sla  c
ROME:65BE 21 C5 D8         ld   hl,D8C5
ROME:65C1 09               add  hl,bc
ROME:65C2 2A               ldi  a,(hl)
ROME:65C3 46               ld   b,(hl)
ROME:65C4 4F               ld   c,a
ROME:65C5 E1               pop  hl
ROME:65C6 F1               pop  af
ROME:65C7 C9               ret  

E:65C8

ROME:65C8 C5               push bc
ROME:65C9 D5               push de
ROME:65CA 50               ld   d,b
ROME:65CB 59               ld   e,c
ROME:65CC CD 14 66         call 6614
ROME:65CF 78               ld   a,b
ROME:65D0 FE 00            cp   a,00
ROME:65D2 20 09            jr   nz,65DD
ROME:65D4 79               ld   a,c
ROME:65D5 CD 98 65         call 6598
ROME:65D8 42               ld   b,d
ROME:65D9 4B               ld   c,e
ROME:65DA CD 9C 65         call 659C
ROME:65DD D1               pop  de
ROME:65DE C1               pop  bc
ROME:65DF C9               ret

E:65E0

ROME:65E0 F5               push af
ROME:65E1 C5               push bc
ROME:65E2 D5               push de
ROME:65E3 E5               push hl
ROME:65E4 FA C4 D8         ld   a,(D8C4)
ROME:65E7 6F               ld   l,a
ROME:65E8 16 00            ld   d,00
ROME:65EA 1E 00            ld   e,00
ROME:65EC 7B               ld   a,e
ROME:65ED CD 98 65         call 6598
ROME:65F0 CD B4 65         call 65B4
ROME:65F3 7B               ld   a,e
ROME:65F4 BD               cp   l
ROME:65F5 28 08            jr   z,65FF
ROME:65F7 7A               ld   a,d
ROME:65F8 CD 98 65         call 6598
ROME:65FB CD 9C 65         call 659C
ROME:65FE 14               inc  d
ROME:65FF 1C               inc  e
ROME:6600 7B               ld   a,e
ROME:6601 FE 28            cp   a,28
ROME:6603 38 E7            jr   c,65EC
ROME:6605 7A               ld   a,d
ROME:6606 CD 98 65         call 6598
ROME:6609 01 D0 02         ld   bc,02D0
ROME:660C CD 9C 65         call 659C
ROME:660F E1               pop  hl
ROME:6610 D1               pop  de
ROME:6611 C1               pop  bc
ROME:6612 F1               pop  af
ROME:6613 C9               ret

E:6614 - Check if there are 40 valid cards in deck ?

ROME:6614 F5               push af
ROME:6615 D5               push de
ROME:6616 E5               push hl
ROME:6617 21 C5 D8         ld   hl,D8C5         ;hl = pointer to Player's Deck
ROME:661A 1E 00            ld   e,00
ROME:661C 2A               ldi  a,(hl)          ;loop start
ROME:661D 4F               ld   c,a
ROME:661E 2A               ldi  a,(hl)
ROME:661F 47               ld   b,a             ;bc = current_card_id
ROME:6620 CD 86 1D         call 1D86            ;Checks if Card ID is 721
ROME:6623 FE 01            cp   a,01
ROME:6625 28 06            jr   z,662D          ;if empty card slot (id = 721), jump directly to E:662D
ROME:6627 1C               inc  e
ROME:6628 7B               ld   a,e
ROME:6629 FE 28            cp   a,28
ROME:662B 38 EF            jr   c,661C          ;if all 40 cards in Player's Deck have not yet been checked, loop to E:6636
ROME:662D 06 00            ld   b,00            ;b = 0
ROME:662F 4B               ld   c,e
ROME:6630 79               ld   a,c
ROME:6631 FE 28            cp   a,28
ROME:6633 20 01            jr   nz,6636         ;if there are not 40 valid cards in the deck, loop to E:6636
ROME:6635 04               inc  b               ;b = 1
ROME:6636 E1               pop  hl
ROME:6637 D1               pop  de
ROME:6638 F1               pop  af
ROME:6639 C9               ret

Is there a Save file ?

  • 0x3BB64-0x3BB6C - Is there a Save file ?
ROME:7B64 F5               push af
ROME:7B65 FA 88 DB         ld   a,(DB88)
ROME:7B68 FE 00            cp   a,00
ROME:7B6A 20 03            jr   nz,7B6F          ;If there is a save file, jump to the integrity check
ROME:7B6C CF               rst  08               ;Else create a new Save file
 => 0F 04
ROME:7B6F CF               rst  08
 => 09 04
ROME:7B72 CF               rst  08
 => 0D 04
ROME:7B75 F1               pop  af
ROME:7B76 C9               ret

E:7B77

ROME:7B77 F5               push af
ROME:7B78 FA 88 DB         ld   a,(DB88)
ROME:7B7B FE 01            cp   a,01
ROME:7B7D 20 06            jr   nz,7B85
ROME:7B7F CF               rst  08
 => 09 04
ROME:7B82 CF               rst  08
 => 0D 04
ROME:7B85 F1               pop  af
ROME:7B86 C9               ret

E:7B87

ROME:7B87 F5               push af
ROME:7B88 FA 88 DB         ld   a,(DB88)
ROME:7B8B 3C               inc  a
ROME:7B8C FE 02            cp   a,02
ROME:7B8E 20 01            jr   nz,7B91
ROME:7B90 AF               xor  a                  ;a = 0
ROME:7B91 EA 88 DB         ld   (DB88),a
ROME:7B94 F1               pop  af
ROME:7B95 C9               ret  

E:7B96

ROME:7B96 F5               push af
ROME:7B97 C5               push bc
ROME:7B98 D5               push de
ROME:7B99 E5               push hl
ROME:7B9A FA 88 DB         ld   a,(DB88)
ROME:7B9D 5F               ld   e,a
ROME:7B9E CB 23            sla  e
ROME:7BA0 16 00            ld   d,00
ROME:7BA2 21 B4 7B         ld   hl,7BB4
ROME:7BA5 19               add  hl,de
ROME:7BA6 2A               ldi  a,(hl)
ROME:7BA7 47               ld   b,a
ROME:7BA8 4E               ld   c,(hl)
ROME:7BA9 11 02 00         ld   de,0002
ROME:7BAC CD BE 13         call 13BE
ROME:7BAF E1               pop  hl
ROME:7BB0 D1               pop  de
ROME:7BB1 C1               pop  bc
ROME:7BB2 F1               pop  af
ROME:7BB3 C9               ret

rst 08 pointers

  • 0x3BB6D-0x3BB75 - Pointers + Bank used after a rst 08
0F 04 - Normal New Game
CF - rst 08
09 04 - Save file sanity check
CF - rst 08
0D 04

Bank 18

Graphics 2

0x48000 - ?

Bank 1B

Fusion Summon

Fusion Summon - Load Bank containing the Fusion table for the provided monster_card_id

RO1B:4000 1B               dec  de
RO1B:4001 00               nop  
RO1B:4002 06 40            ld   b,40
RO1B:4004 0E 40            ld   c,40
RO1B:4006 E5               push hl
RO1B:4007 21 1E 40         ld   hl,401E
RO1B:400A 09               add  hl,bc          ;hl = 0x401E + monster_card_id
RO1B:400B 7E               ld   a,(hl)         ;a = Bank to load
RO1B:400C E1               pop  hl
RO1B:400D C9               ret  
RO1B:400E F5               push af
RO1B:400F E5               push hl
RO1B:4010 CB 21            sla  c
RO1B:4012 CB 10            rl   b
RO1B:4014 21 EF 42         ld   hl,42EF
RO1B:4017 09               add  hl,bc
RO1B:4018 2A               ldi  a,(hl)
RO1B:4019 46               ld   b,(hl)
RO1B:401A 4F               ld   c,a
RO1B:401B E1               pop  hl
RO1B:401C F1               pop  af
RO1B:401D C9               ret

Fusion Summon - Load pointer to the Fusion list for the provided monster_card_id

RO1B:400E F5               push af
RO1B:400F E5               push hl
RO1B:4010 CB 21            sla  c
RO1B:4012 CB 10            rl   b
RO1B:4014 21 EF 42         ld   hl,42EF
RO1B:4017 09               add  hl,bc          ;hl = 0x42EF + monster_card_id
RO1B:4018 2A               ldi  a,(hl)
RO1B:4019 46               ld   b,(hl)
RO1B:401A 4F               ld   c,a            ;bc = pointer to the Fusion list
RO1B:401B E1               pop  hl
RO1B:401C F1               pop  af
RO1B:401D C9               ret

Fusion Summon - Fusion Banks array

  • 0x6C01E - 0x6C2EE

Fusion Summon - Fusion pointers array

  • 0x6C2EF - 0x6C891

00s

The Bank is empty and unused after 18:4892 / 0x6C892.

Bank 24 - 25

Card drops lists

0x90002 - Card drops lists, each drop rate is encoded on 3 nibbles, out of 2048.

aa ab bb cc cd dd ...

Bank 26 - 27

CPU Decks

0x98002 - CPU Decks cards lists, each card probability is encoded on 3 nibbles, out of 2048.

aa ab bb cc cd dd ...

Bank 28

Graphics 3

0xA0000 - ?

Bank 3B

rst 08 pointer

  • 0xEC002-0xEC003 - rst 08 pointer
04 40

Game Initialization

Name Input screen display

  • 0xEC004-0xEC043 - Name Input screen
RO3B:4004 F5               push af
RO3B:4005 C5               push bc
RO3B:4006 D5               push de
RO3B:4007 E5               push hl
RO3B:4008 4F               ld   c,a
RO3B:4009 F0 FF            ld   a,(ff00+FF)
RO3B:400B 57               ld   d,a
RO3B:400C E6 FC            and  a,FC
RO3B:400E E0 FF            ld   (ff00+FF),a	// Disable V-Blank and LCD STAT
RO3B:4010 D5               push de
RO3B:4011 CD 50 40         call 4050		// Blanks screen, checks system running the game
RO3B:4014 F5               push af
RO3B:4015 F0 DE            ld   a,(ff00+DE)	// a = (FFDE)
RO3B:4017 FE 00            cp   a,00
RO3B:4019 20 04            jr   nz,401F
RO3B:401B E8 04            add  sp,04
RO3B:401D 18 20            jr   403F
RO3B:401F FE 01            cp   a,01
RO3B:4021 20 04            jr   nz,4027
RO3B:4023 E8 04            add  sp,04
RO3B:4025 18 18            jr   403F
RO3B:4027 F1               pop  af
RO3B:4028 06 00            ld   b,00
RO3B:402A 21 44 40         ld   hl,4044
RO3B:402D 09               add  hl,bc
RO3B:402E 2A               ldi  a,(hl)
RO3B:402F 66               ld   h,(hl)
RO3B:4030 6F               ld   l,a
RO3B:4031 01 36 40         ld   bc,4036
RO3B:4034 C5               push bc
RO3B:4035 E9               jp   hl
RO3B:4036 D1               pop  de
RO3B:4037 21 40 FF         ld   hl,FF40
RO3B:403A CB FE            set  7,(hl)
RO3B:403C 7A               ld   a,d
RO3B:403D E0 FF            ld   (ff00+FF),a	// Restore previous Interrupt flags
RO3B:403F E1               pop  hl
RO3B:4040 D1               pop  de
RO3B:4041 C1               pop  bc
RO3B:4042 F1               pop  af
RO3B:4043 C9               ret


Blanks screen, checks system running the game

  • 0xEC050-0xEC0CC - Blanks screen, checks system running the game
RO3B:4050 F5               push af
RO3B:4051 C5               push bc
RO3B:4052 D5               push de
RO3B:4053 E5               push hl
RO3B:4054 FE 00            cp   a,00
RO3B:4056 20 70            jr   nz,40C8
RO3B:4058 3E 00            ld   a,00
RO3B:405A E0 47            ld   (ff00+47),a	// White BG (Game Boy only)
RO3B:405C 21 40 FF         ld   hl,FF40
RO3B:405F CB FE            set  7,(hl)		// Enable LCD Display
RO3B:4061 21 0F 45         ld   hl,450F
RO3B:4064 CD 16 41         call 4116
RO3B:4067 1E 00            ld   e,00
RO3B:4069 F0 44            ld   a,(ff00+44)	// LCD Y-Coordinate
RO3B:406B FE 00            cp   a,00
RO3B:406D 20 FA            jr   nz,4069		// Wait for LCD Driver to be on first vertical line
RO3B:406F F0 44            ld   a,(ff00+44)
RO3B:4071 FE 90            cp   a,90
RO3B:4073 38 FA            jr   c,406F		// Wait for V-Blank period
RO3B:4075 16 0A            ld   d,0A
RO3B:4077 3E 20            ld   a,20		// Button keys
RO3B:4079 E0 00            ld   (ff00+00),a
RO3B:407B F0 00            ld   a,(ff00+00)
RO3B:407D F0 00            ld   a,(ff00+00)
RO3B:407F 3E 10            ld   a,10		// Direction keys
RO3B:4081 E0 00            ld   (ff00+00),a
RO3B:4083 F0 00            ld   a,(ff00+00)
RO3B:4085 F0 00            ld   a,(ff00+00)
RO3B:4087 F0 00            ld   a,(ff00+00)
RO3B:4089 F0 00            ld   a,(ff00+00)
RO3B:408B F0 00            ld   a,(ff00+00)
RO3B:408D F0 00            ld   a,(ff00+00)
RO3B:408F 3E 30            ld   a,30		// Button keys and Direction keys
RO3B:4091 E0 00            ld   (ff00+00),a
RO3B:4093 3E 30            ld   a,30
RO3B:4095 E0 00            ld   (ff00+00),a
RO3B:4097 3E 30            ld   a,30
RO3B:4099 E0 00            ld   (ff00+00),a
RO3B:409B 3E 30            ld   a,30
RO3B:409D E0 00            ld   (ff00+00),a
RO3B:409F F0 00            ld   a,(ff00+00)
RO3B:40A1 FE FE            cp   a,FE
RO3B:40A3 20 02            jr   nz,40A7
RO3B:40A5 1E 01            ld   e,01
RO3B:40A7 15               dec  d
RO3B:40A8 20 CD            jr   nz,4077	// Loop 10 times
RO3B:40AA 21 1F 45         ld   hl,451F
RO3B:40AD CD 16 41         call 4116		// Initialize Joypad
RO3B:40B0 16 00            ld   d,00
RO3B:40B2 06 00            ld   b,00
RO3B:40B4 CB 23            sla  e
RO3B:40B6 0E 00            ld   c,00
RO3B:40B8 F0 DD            ld   a,(ff00+DD)	// a = System running the game
RO3B:40BA FE FF            cp   a,FF
RO3B:40BC 20 02            jr   nz,40C0
RO3B:40BE 0E 01            ld   c,01
RO3B:40C0 21 CD 40         ld   hl,40CD
RO3B:40C3 19               add  hl,de
RO3B:40C4 09               add  hl,bc
RO3B:40C5 7E               ld   a,(hl)		// Read corresponding value from array 3B:40CD
RO3B:40C6 E0 DE            ld   (ff00+DE),a
RO3B:40C8 E1               pop  hl
RO3B:40C9 D1               pop  de
RO3B:40CA C1               pop  bc
RO3B:40CB F1               pop  af
RO3B:40CC C9               ret

System running the game array

RO3B:40CD
00 - Game Boy Color
01
02 - Game Boy
03 - Super Game Boy 2

Wait for Input

  • 0xEC116-0xEC15B - Wait for Input at the Name Input screen
RO3B:4116 F5               push af
RO3B:4117 C5               push bc
RO3B:4118 D5               push de
RO3B:4119 F0 44            ld   a,(ff00+44)	// LCD Y-Coordinate
RO3B:411B FE 90            cp   a,90
RO3B:411D 38 FA            jr   c,4119		// Wait for V-Blank period
RO3B:411F 3E 30            ld   a,30
RO3B:4121 E0 00            ld   (ff00+00),a
RO3B:4123 3E 00            ld   a,00
RO3B:4125 E0 00            ld   (ff00+00),a
RO3B:4127 3E 30            ld   a,30
RO3B:4129 E0 00            ld   (ff00+00),a	// Initialize Joypad
RO3B:412B 16 10            ld   d,10
RO3B:412D 2A               ldi  a,(hl)
RO3B:412E 47               ld   b,a
RO3B:412F 1E 08            ld   e,08
RO3B:4131 CB 38            srl  b
RO3B:4133 38 0A            jr   c,413F
RO3B:4135 3E 20            ld   a,20
RO3B:4137 E0 00            ld   (ff00+00),a
RO3B:4139 3E 30            ld   a,30
RO3B:413B E0 00            ld   (ff00+00),a
RO3B:413D 18 08            jr   4147
RO3B:413F 3E 10            ld   a,10
RO3B:4141 E0 00            ld   (ff00+00),a
RO3B:4143 3E 30            ld   a,30
RO3B:4145 E0 00            ld   (ff00+00),a
RO3B:4147 1D               dec  e
RO3B:4148 20 E7            jr   nz,4131
RO3B:414A 15               dec  d
RO3B:414B 20 E0            jr   nz,412D
RO3B:414D 3E 20            ld   a,20
RO3B:414F E0 00            ld   (ff00+00),a
RO3B:4151 3E 30            ld   a,30
RO3B:4153 E0 00            ld   (ff00+00),a
RO3B:4155 CD 5C 41         call 415C
RO3B:4158 D1               pop  de
RO3B:4159 C1               pop  bc
RO3B:415A F1               pop  af
RO3B:415B C9               ret

Bank 3E

Set wC920 to accumulator

RO3E:4076 EA 20 C9         ld   (C920),a
RO3E:4079 C9               ret

Bank 40

40:4002 - jump to routines related to Card Drops and CPU Decks

RO40:4002 C3 26 40         jp   4026
RO40:4005 C3 3B 40         jp   403B
RO40:4008 C3 50 40         jp   4050
RO40:400B C3 65 40         jp   4065
RO40:400E C3 7A 40         jp   407A
RO40:4011 C3 8F 40         jp   408F
RO40:4014 C3 A4 40         jp   40A4
RO40:4017 C3 B9 40         jp   40B9
RO40:401A C3 CE 40         jp   40CE
RO40:401D C3 E3 40         jp   40E3
RO40:4020 C3 F8 40         jp   40F8          ;load pointer to CPU deck
RO40:4023 C3 0D 41         jp   410D

Load pointer to CPU deck

RO40:40F8 F5               push af
RO40:40F9 E5               push hl
RO40:40FA 21 CD 4A         ld   hl,4ACD
RO40:40FD 09               add  hl,bc
RO40:40FE 56               ld   d,(hl)
RO40:40FF CB 21            sla  c
RO40:4101 CB 10            rl   b
RO40:4103 21 E5 4A         ld   hl,4AE5
RO40:4106 09               add  hl,bc
RO40:4107 2A               ldi  a,(hl)
RO40:4108 46               ld   b,(hl)
RO40:4109 4F               ld   c,a
RO40:410A E1               pop  hl
RO40:410B F1               pop  af
RO40:410C C9               ret  

40:410D (to document)

RO40:410D F5               push af
RO40:410E E5               push hl
RO40:410F 21 15 4B         ld   hl,4B15
RO40:4112 09               add  hl,bc
RO40:4113 56               ld   d,(hl)		// Stores bank 24 or 25 to register d, from array at RO40:4B15
RO40:4114 CB 21            sla  c
RO40:4116 CB 10            rl   b
RO40:4118 21 2D 4B         ld   hl,4B2D
RO40:411B 09               add  hl,bc
RO40:411C 2A               ldi  a,(hl)
RO40:411D 46               ld   b,(hl)
RO40:411E 4F               ld   c,a
RO40:411F E1               pop  hl
RO40:4120 F1               pop  af
RO40:4121 C9               ret

40:4B15 (Bank and pointers arrays)

  • 0x100B15 - 0x100B2C - Array, bank 24 or 25
RO40:4B15
24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 25
25 25 25 25 25 25 25 25
  • 0x100B2D - 0x100B5C - Array, pointers
RO40:4B2D
02 40 3A 44 72 48 AA 4C E2 50 1A 55 52 59 52 59
8A 5D C2 61 FA 65 32 6A 6A 6E A2 72 DA 76 02 40
3A 44 72 48 72 48 AA 4C E2 50 1A 55 52 59 8A 5D