General Screen Swapping AR code

Discussion in 'NDS - ROM Hacking and Translations' started by froggestspirit, Apr 8, 2017.

  1. froggestspirit
    OP

    froggestspirit D/P/Pt Demix Guy

    Member
    1,118
    548
    Jul 28, 2011
    United States
    Here is the current game list and code maker: https://docs.google.com/spreadsheets/d/1-UzjWpiZVO2pRetsR83NGeoEnSecnmncIMErznfD8r0/edit?usp=sharing
    I finally managed to write a (in theory portable) AR code to swap screens for DS games.
    I believe this should also work with NitroHax, though I have not yet tested it. This is the basic structure:
    Code:
    arm7 AR code
    D3000000 0zzzzzzz+0x44
    94000130 FFF30000
    D4000000 00000001
    D0000000 00000000
    D6000000 00000000
    5zzzzzzz+0x44 00000001
    5zzzzzzz+0x48 00000000
    DC000000 FFFFFFF8
    D4000000 00007FFF
    D6000000 00000000
    D9000000 00000000
    D6000000 00000000
    D0000000 00000000
    D0000000 00000000
    D6000000 00000000
    D3000000 00000000
    94000130 FFF30000
    ARM9HOOK MOVr15fs
    6zzzzzzz E92D5FFF
    D3000000 0zzzzzzz
    E0000000 00000040
    E92D5FFF E59F2024
    E59F3024 E5931000
    E5920000 E0201001
    E0200000 E5820000
    E5831000 E8BD5FFF
    opopopop E59FF004
    0zzzzzzz+0x40 04000304
    ARM9HOOK+4 00000000
    D2000000 00000000
    
    You need a hook spot in the ARM9 loop, and freespace.
    ARM9HOOK=address where the opcode you're hooking into is at (ARM, not THUMB)
    MOVr15fs=A single ARM instruction that will jump to zzzzzzz (for mario, I used mov r15,02000000h)
    zzzzzzz=address of freespace (needs to be atleast 0x4C bytes)
    opopopop=the opcode that was hooked into (since the MOVr15fs overwrites it)
    
    I have only tested this with Super Mario 64DS (US) so far, and here is the code for that game specifically
    D3000000 02000044
    94000130 FFF30000
    D4000000 00000001
    D0000000 00000000
    D6000000 00000000
    52000044 00000001
    52000048 00000000
    DC000000 FFFFFFF8
    D4000000 00007FFF
    D6000000 00000000
    D9000000 00000000
    D6000000 00000000
    D0000000 00000000
    D0000000 00000000
    D6000000 00000000
    D3000000 00000000
    94000130 FFF30000
    02057DF4 E3A0F402
    62000000 E92D5FFF
    D3000000 02000000
    E0000000 00000040
    E92D5FFF E59F2024
    E59F3024 E5931000
    E5920000 E0201001
    E0200000 E5820000
    E5831000 E8BD5FFF
    E3A00000 E59FF004
    02000040 04000304
    02057DF8 00000000
    D2000000 00000000

    The only glitches, are that Sprites apparently don't swap with the screens. If anyone knows how to fix that, I can try to update that.
    If there is any interest, I'll explain this in a little more detail, or show how I found the hook address
    If anyone finds good addresses, let me know, and I'll add them to the table.
     
    Last edited by froggestspirit, Apr 19, 2017