Yu-Gi-Oh! Duel Monsters/Early Days Collection subroutines

From Data Crystal
Jump to navigation Jump to search

This is a sub-page of Yu-Gi-Oh! Duel Monsters.

This page lists the changes made by Digital Eclipse in the gbz80 code. It is apparent they did not have access to the source code, and opted to directly modify the game's subroutines in the ROM.

Early Days Collection's re-release of Duel Monsters 1 is, for all intents and purposes, a ROM hack.
This is even more evident when they didn't properly fix the ROM checksum in some of the GB(C) ROMs in the collection, improperly changed the ROM size in the headers, and when some instructions are simply nop'd rather than moving instructions around and modifying the calls and pointers.

Bank 0

ROM start

ROM0:0100 00               nop  
ROM0:0101 C3 50 01         jp   0150
...
ROM0:0150 E0 DD            ld   (ff00+DD),a
ROM0:0152 21 00 E0         ld   hl,E000
ROM0:0155 F9               ld   sp,hl
ROM0:0156 CD 90 10         call 1090
ROM0:0159 CF               rst  08
ROM0:015A 05               dec  b
ROM0:015B 04               inc  b
ROM0:015C 3E 00            ld   a,00
ROM0:015E CF               rst  08
ROM0:015F 03               inc  bc
ROM0:0160 3F               ccf  
ROM0:0161 CF               rst  08
ROM0:0162 03               inc  bc
ROM0:0163 3E CD            ld   a,CD
ROM0:0165 EA 14 CD         ld   (CD14),a
ROM0:0168 96               sub  (hl)
ROM0:0169 03               inc  bc
ROM0:016A CD D8 0D         call 0DD8
ROM0:016D CD 9F 01         call 019F
ROM0:0170 3E 02            ld   a,02
ROM0:0172 CF               rst  08
ROM0:0173 03               inc  bc
ROM0:0174 3F               ccf  
ROM0:0175 CF               rst  08
ROM0:0176 49               ld   c,c
ROM0:0177 01 3E 04         ld   bc,043E
ROM0:017A CF               rst  08
ROM0:017B 03               inc  bc
ROM0:017C 3F               ccf  
ROM0:017D CF               rst  08
ROM0:017E 4B               ld   c,e
ROM0:017F 01 3E 06         ld   bc,063E
ROM0:0182 CF               rst  08
       => 03 3F
ROM0:0184 3F               ccf  
ROM0:0185 CD 0C 04         call 040C
ROM0:0188 00               nop                  ;the rst 08 => 1:65F3 got nop'd, so the the 3rd splash screen after game bootup is not displayed
ROM0:0189 00               nop
ROM0:018A 00               nop
ROM0:018B CF               rst  08
      => 03 04
ROM0:018E CD 24 17         call 1724
ROM0:0191 3E 16            ld   a,16
ROM0:0193 CD E3 0D         call 0DE3
ROM0:0196 CD 2F 0F         call 0F2F
ROM0:0199 CD 1F 2D         call 2D1F
ROM0:019C 18 FE            jr   019C
ROM0:019E C9               ret

0:0F86 - delay before starting Monster battle in duels?

ROM0:0F86 C5               push bc
ROM0:0F87 0E 0A            ld   c,0A
ROM0:0F89 CD 18 3F         call 3F18            ;call 0:3F18 (a new subroutine) instead of 0:0F74
ROM0:0F8C 0D               dec  c
ROM0:0F8D 20 FA            jr   nz,0F89         ;call 0:3F18 either 10 times, or until a button is pressed (0:3F18 will set c to 1 in that case)
ROM0:0F8F C1               pop  bc
ROM0:0F90 C9               ret

0:3F00 (new subroutine) - Call 0:109F, then copy 1280 bytes from (hl) to (de)

New subroutine.

ROM0:3F00 CD 9F 10         call 109F
ROM0:3F03 0E 00            ld   c,00
ROM0:3F05 2A               ldi  a,(hl)
ROM0:3F06 12               ld   (de),a
ROM0:3F07 13               inc  de
ROM0:3F08 2A               ldi  a,(hl)
ROM0:3F09 12               ld   (de),a
ROM0:3F0A 13               inc  de
ROM0:3F0B 2A               ldi  a,(hl)
ROM0:3F0C 12               ld   (de),a
ROM0:3F0D 13               inc  de
ROM0:3F0E 2A               ldi  a,(hl)
ROM0:3F0F 12               ld   (de),a
ROM0:3F10 13               inc  de
ROM0:3F11 2A               ldi  a,(hl)
ROM0:3F12 12               ld   (de),a
ROM0:3F13 13               inc  de
ROM0:3F14 0D               dec  c
ROM0:3F15 20 EE            jr   nz,3F05         ;loop 256 times
ROM0:3F17 C9               ret

0:3F18 (new subroutine)

New subroutine. It checks if a button is pressed, in addition to calling 0:0F74. If a button is pressed, it sets c to 1

ROM0:3F18 CD 74 0F         call 0F74
ROM0:3F1B FA A5 CA         ld   a,(CAA5)
ROM0:3F1E B7               or   a
ROM0:3F1F C8               ret  z
ROM0:3F20 0E 01            ld   c,01
ROM0:3F22 C9               ret

Bank 1

1:5EB3

ROM1:5EB3 F5               push af
ROM1:5EB4 C5               push bc
ROM1:5EB5 D5               push de
ROM1:5EB6 E5               push hl
ROM1:5EB7 01 00 80         ld   bc,8000        ;instead of ld a,00; call 1842; ld a,(CD0F)
ROM1:5EBA CF               rst  08
      => 03 7F
ROM1:5EBD 18 31            jr   5EF0           ;exit this function
ROM1:5EBF CD 42 18         call 1842           ;the rest of this subroutine remains, but is unused
ROM1:5EC2 FA 10 CD         ld   a,(CD10)
ROM1:5EC5 CD 42 18         call 1842
ROM1:5EC8 CD 3E 17         call 173E
ROM1:5ECB 01 E6 CD         ld   bc,CDE6
ROM1:5ECE 05               dec  b
ROM1:5ECF 17               rla  
ROM1:5ED0 E2               ld   (ff00+c),a
ROM1:5ED1 01 00 80         ld   bc,8000
ROM1:5ED4 60               ld   h,b
ROM1:5ED5 69               ld   l,c
ROM1:5ED6 1E 0A            ld   e,0A
ROM1:5ED8 CD AB 17         call 17AB
ROM1:5EDB 1D               dec  e
ROM1:5EDC 20 FA            jr   nz,5ED8
ROM1:5EDE E1               pop  hl
ROM1:5EDF D1               pop  de
ROM1:5EE0 C1               pop  bc
ROM1:5EE1 F1               pop  af
ROM1:5EE2 C9               ret