News:

11 March 2016 - Forum Rules

Main Menu

NES hard-coded pointer

Started by Her-Saki, June 07, 2017, 05:09:09 PM

Previous topic - Next topic

Her-Saki

Hi everyone.
I'm currently working on modifying a string of a translation that needs one, ONE extra tile (sounds weird but it's really a pain), but the routine seems to be heavily hard-coded, maintaining the necessary values to get the final result along with other routines and compromising (and corrupting them after changing) other no-text-belonged tiles within.

Here:

A:2D X:48 Y:01 S:F9 P:nvUbdIzc       $8CDE:8A        TXA
A:48 X:48 Y:01 S:F9 P:nvUbdIzc       $8CDF:29 20     AND #$20
A:00 X:48 Y:01 S:F9 P:nvUbdIZc       $8CE1:D0 1E     BNE $8D01
A:00 X:48 Y:01 S:F9 P:nvUbdIZc       $8CE3:8A        TXA
A:48 X:48 Y:01 S:F9 P:nvUbdIzc       $8CE4:29 1F     AND #$1F
A:08 X:48 Y:01 S:F9 P:nvUbdIzc       $8CE6:D0 01     BNE $8CE9
A:08 X:48 Y:01 S:F9 P:nvUbdIzc       $8CE9:85 94     STA $0094 = #$00
A:08 X:48 Y:01 S:F9 P:nvUbdIzc       $8CEB:A5 90     LDA $0090 = #$2D
A:2D X:48 Y:01 S:F9 P:nvUbdIzc       $8CED:85 92     STA $0092 = #$2A
A:2D X:48 Y:01 S:F9 P:nvUbdIzc       $8CEF:A5 91     LDA $0091 = #$D1
A:D1 X:48 Y:01 S:F9 P:NvUbdIzc       $8CF1:85 93     STA $0093 = #$D1
A:D1 X:48 Y:01 S:F9 P:NvUbdIzc       $8CF3:20 21 8D  JSR $8D21
A:D1 X:48 Y:01 S:F7 P:NvUbdIzc         $8D21:A0 00     LDY #$00
A:D1 X:48 Y:00 S:F7 P:nvUbdIZc         $8D23:B1 92     LDA ($92),Y @ $D12D = #$92
A:92 X:48 Y:00 S:F7 P:NvUbdIzc         $8D25:8D 07 20  STA $2007 = #$00
A:92 X:48 Y:00 S:F7 P:NvUbdIzc         $8D28:A9 01     LDA #$01
A:01 X:48 Y:00 S:F7 P:nvUbdIzc         $8D2A:20 3C 8D  JSR $8D3C
A:01 X:48 Y:00 S:F5 P:nvUbdIzc           $8D3C:18        CLC
A:01 X:48 Y:00 S:F5 P:nvUbdIzc           $8D3D:65 92     ADC $0092 = #$2D
A:2E X:48 Y:00 S:F5 P:nvUbdIzc           $8D3F:85 92     STA $0092 = #$2D
A:2E X:48 Y:00 S:F5 P:nvUbdIzc           $8D41:90 02     BCC $8D45
A:2E X:48 Y:00 S:F5 P:nvUbdIzc           $8D45:60        RTS (from $8D3C) ---------------------------
A:2E X:48 Y:00 S:F7 P:nvUbdIzc         $8D2D:C6 94     DEC $0094 = #$08
A:2E X:48 Y:00 S:F7 P:nvUbdIzc         $8D2F:D0 F2     BNE $8D23
A:2E X:48 Y:00 S:F7 P:nvUbdIzc         $8D23:B1 92     LDA ($92),Y @ $D12E = #$A9
A:A9 X:48 Y:00 S:F7 P:NvUbdIzc         $8D25:8D 07 20  STA $2007 = #$00
A:A9 X:48 Y:00 S:F7 P:NvUbdIzc         $8D28:A9 01     LDA #$01
A:01 X:48 Y:00 S:F7 P:nvUbdIzc         $8D2A:20 3C 8D  JSR $8D3C
A:01 X:48 Y:00 S:F5 P:nvUbdIzc           $8D3C:18        CLC
A:01 X:48 Y:00 S:F5 P:nvUbdIzc           $8D3D:65 92     ADC $0092 = #$2E
A:2F X:48 Y:00 S:F5 P:nvUbdIzc           $8D3F:85 92     STA $0092 = #$2E
A:2F X:48 Y:00 S:F5 P:nvUbdIzc           $8D41:90 02     BCC $8D45
A:2F X:48 Y:00 S:F5 P:nvUbdIzc           $8D45:60        RTS (from $8D3C) ---------------------------

Etc, I tried to find common pointers (of course they don't exist or the routine seems to not make good use of them), implement DTE (corrupts the post-intro) and change the counter in $0094 (which corrupts every tile whatsoever)
Is there a way to change the indirect adressing for the game to read in other adress? I hope someone can help with this little but damn hard problem.
Thanks in advance!

Disch

I assume you're talking about the pointer at ($92).  In the pasted code I can see it's copying the data from $90,91:

A:08 X:48 Y:01 S:F9 P:nvUbdIzc       $8CEB:A5 90     LDA $0090 = #$2D
A:2D X:48 Y:01 S:F9 P:nvUbdIzc       $8CED:85 92     STA $0092 = #$2A    ; moving data from 90,91 to 92,93
A:2D X:48 Y:01 S:F9 P:nvUbdIzc       $8CEF:A5 91     LDA $0091 = #$D1
A:D1 X:48 Y:01 S:F9 P:NvUbdIzc       $8CF1:85 93     STA $0093 = #$D1     ; 92,93 is later used as the pointer


But we cannot see from the code where the values in $90,91 came from.

You'll need to trace back further until you find where in ROM those values are coming from.

Her-Saki

#2
A:0F X:FF Y:00 S:FB P:NvUbdIzc     $A9B4:10 F4     BPL $A9AA
A:0F X:FF Y:00 S:FB P:NvUbdIzc     $A9B6:A9 36     LDA #$36
A:36 X:FF Y:00 S:FB P:nvUbdIzc     $A9B8:85 46     STA $0046 = #$32
A:36 X:FF Y:00 S:FB P:nvUbdIzc     $A9BA:A9 34     LDA #$34
A:34 X:FF Y:00 S:FB P:nvUbdIzc     $A9BC:85 47     STA $0047 = #$02
A:34 X:FF Y:00 S:FB P:nvUbdIzc     $A9BE:A9 D0     LDA #$D0
A:D0 X:FF Y:00 S:FB P:NvUbdIzc     $A9C0:85 91     STA $0091 = #$A1
A:D0 X:FF Y:00 S:FB P:NvUbdIzc     $A9C2:A9 5A     LDA #$5A
A:5A X:FF Y:00 S:FB P:nvUbdIzc     $A9C4:85 90     STA $0090 = #$53
A:5A X:FF Y:00 S:FB P:nvUbdIzc     $A9C6:20 B7 8C  JSR $8CB7
A:5A X:FF Y:00 S:F9 P:nvUbdIzc       $8CB7:20 F7 E3  JSR $E3F7
A:5A X:FF Y:00 S:F7 P:nvUbdIzc         $E3F7:A5 08     LDA $0008 = #$A8
A:A8 X:FF Y:00 S:F7 P:NvUbdIzc         $E3F9:29 FB     AND #$FB
A:A8 X:FF Y:00 S:F7 P:NvUbdIzc         $E3FB:8D 00 20  STA $2000 = #$A8
A:A8 X:FF Y:00 S:F7 P:NvUbdIzc         $E3FE:60        RTS (from $E3F7) ---------------------------

This is the very first routine that manage tiles after a bunch of DEX commands, so changing that values in the right way, which will later be copied to $92, $93 will change the adress that the game reads from?

Disch


A:34 X:FF Y:00 S:FB P:nvUbdIzc     $A9BE:A9 D0     LDA #$D0
A:D0 X:FF Y:00 S:FB P:NvUbdIzc     $A9C0:85 91     STA $0091 = #$A1
A:D0 X:FF Y:00 S:FB P:NvUbdIzc     $A9C2:A9 5A     LDA #$5A
A:5A X:FF Y:00 S:FB P:nvUbdIzc     $A9C4:85 90     STA $0090 = #$53


There's your pointer.  The D0 and 5A.  They're at addresses $A9BF and $A9C3, respectively.

Last step is to convert that to ROM offsets.  Easiest way to do this is to have a breakpoint trip on any of those lines, then go in FCEUX's hex editor, right click on $A9BF and select "go here in ROM file".  That'll give you the offset you need.

Her-Saki

I see! I hope it works, but, hell, is still a lot of work for a simple tile to change...
Anyway, thanks for ya help!

nesrocks

Fceux now has a feature that displays the rom offset addresses directly on the debugger. I find it very useful.

Her-Saki

... I don't have words to thank you, the thing works! Thanks again for helping me to understand the indirect adressing!

Disch

@nesrocks:  I didn't know that!  That's actually awesome.


@Her-Saki:  Glad to help!  And glad you got it working!   :thumbsup: