Armadillo - dendy bugfix

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
krzysiobal
Posts: 1036
Joined: Sun Jun 12, 2011 12:06 pm
Location: Poland
Contact:

Armadillo - dendy bugfix

Post by krzysiobal »

Japanese game (Armadillo) has an homebrew english translation:
https://www.romhacking.net/translations/774/

There is also homebrew hack of this game (Mario 4) that patches graphic of the game to "Mario".
Image Image Image

Unfortunately both of the patches were designed for original Japanese version. Trying to apply them one after another will result in glitched title screen:
Image

This is because the english patch rearranges position of tiles in title screen. I find out that the data for title screen (32 x 8 tiles) is stored in rom starting at offset $227CB and just need to be tuned to the new sprite set

The second, more irritating problem that I encoutered (both for original, translated and mario version) is that the game crashes with black screen when played in Dendy Mode (don't know of any other game, except a few Codemasters' titles, which has similar problem)
Yet another pirate port of this game (Super Mario Bros IV (Unl) (Armadillo Hack) (J) [!]), that is another mario hack, but with only mario's sprites altered:
Image
also suffer from the same problem. But this game was released as "famiclone" cartridge, seems weird that pirates weren't aware of that. Or maybe the multicartridge versions were fixed?
1)viewtopic.php?t=17524
2) Image

Anyway, the source of problem is that game executes this code

Code: Select all

>0F:C26B: 20 73 D6  JSR $D673
 0F:C26E: 20 02 C4  JSR $C402
 0F:C271: 20 6A C4  JSR $C46A
 0F:C274: 20 C3 C3  JSR $C3C3
 0F:C277: 20 A9 C5  JSR $C5A9
 0F:C27A: 20 3D F8  JSR $F83D
 0F:C27D: 20 53 F8  JSR $F853
 0F:C280: 20 44 C4  JSR $C444
 0F:C283: A9 10     LDA #$10
 0F:C285: 0D 07 06  ORA $0607 
 0F:C288: 8D 07 06  STA $0607 
 0F:C28B: A9 00     LDA #$00
 0F:C28D: 85 53     STA $0053 
 0F:C28F: A9 01     LDA #$01
 0F:C291: 85 BF     STA $00BF 
 0F:C293: A9 03     LDA #$03
 0F:C295: 85 BE     STA $00BE 
 0F:C297: A5 BE     LDA $00BE 
 0F:C299: C5 BF     CMP $00BF 
 0F:C29B: D0 FA     BNE $C297
and then spins on waiting for $BE=$BF (wchich becomes set during NMI)

In PAL/NTSC, the NMI fires when code is during spin waiting at three last opcodes.
For unknown reason, in Dendy mode the NMI fires much earlier (when $BE is equal to zero).
The NMI routine uses the value of BE as pointer to some jump, which for value of 0 makes jump to garbage location

Code: Select all

0F:D6DA: A5 BE     LDA $00BE = #$00
0F:D6DC: 0A        ASL
0F:D6DD: AA        TAX
0F:D6DE: BD EB D6  LDA $D6EB,X 
0F:D6E1: 85 5D     STA $005D
0F:D6E3: BD EC D6  LDA $D6EC,X 
0F:D6E6: 85 5E     STA $005E 
0F:D6E8: 6C 5D 00  JMP ($005D) 
I did not have patience to analyze what all these JSR do, but when moving the initialization of $00BE to $#03 before all those JSRs, it works but the splash screen with clouds is not displayed at all. So my idea was instead to check and fix the value of $BE before using it as offset in NMI:

Code: Select all

        -------old---------- ---------new----------------
03D6EA: A5 BE     LDA $00BE | 20 CF FF      JSR $FFCF
03D6EC: 0A        ASL       |
03D6ED: AA        TAX       |
  
03FFDF  -here is some-      | A5 BE                      LDA $00BE
(FFCF)  -free space-        | D0 02                      BNE nofix
                            | A9 03                      LDA #$03
                            |                  nofix:   
                            | 0A                         ASL
                            | 60                         RTS
Attachments
Mario IV english fixed title screen+dendy patch[apply over Armadillo(J)].ips
(25.57 KiB) Downloaded 81 times
Armadillo Dendy Fix.ips
(29 Bytes) Downloaded 85 times
Post Reply