Post subject: NES Mickey's Safari in Letterland
Joined: 7/21/2017
Posts: 54
Quick question. I was looking into memory addresses that seem to be involved with what letter one will get at the end of each level. I tested this out and found that when 000E is unsigned 64 the letter will be "W", and if it is unsigned 80 it will be a "Y". 000E seems to be used for other things, but I did notice that it seems to be involved when the letter is revealed. I forced an 80 on those frames when it should be a "W" and the top was a "W" and the bottom was a "Y". I looked into the code of what is writing to 000E, as to why this value is different in each case to find what may be the ultimate factor or main memory address involved. Here is a bit of code, they both seem to have A and X registers identical but yet later in the code it seems to function as if the X register is different. Help is appreciated in understanding this. Seems to be different because of instruction ASL, what is this?
$9FAF:20 7D E4  JSR $E47D                                    A:07 X:00 Y:02 S:74 P:nvUbdizc 
             $E47D:85 5D     STA $005D = #$08                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E47F:A9 00     LDA #$00                                     A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E481:8D 27 00  STA $0027 = #$01                             A:00 X:00 Y:02 S:72 P:nvUbdiZc 
             $E484:A9 07     LDA #$07                                     A:00 X:00 Y:02 S:72 P:nvUbdiZc 
             $E486:05 5C     ORA $005C = #$40                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E488:8D 00 80  STA $8000 = #$A9                             A:47 X:00 Y:02 S:72 P:nvUbdizc 
             $E48B:A5 5D     LDA $005D = #$07                             A:47 X:00 Y:02 S:72 P:nvUbdizc 
             $E48D:8D 01 80  STA $8001 = #$04                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E490:AD 27 00  LDA $0027 = #$00                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E493:D0 EA     BNE $E47F                                    A:00 X:00 Y:02 S:72 P:nvUbdiZc 
             $E495:60        RTS (from $E47D) --------------------------- A:00 X:00 Y:02 S:72 P:nvUbdiZc 
           $9FB2:68        PLA                                          A:00 X:00 Y:02 S:74 P:nvUbdiZc 
          $9FB3:0A        ASL                                          A:18 X:00 Y:02 S:75 P:nvUbdizc 
          $9FB4:AA        TAX                                          A:30 X:00 Y:02 S:75 P:nvUbdizc 
          $9FB5:BD 74 BF  LDA $BF74,X @ $BFA4 = #$50                   A:30 X:30 Y:02 S:75 P:nvUbdizc 
          $9FB8:85 0E     STA $000E = #$E0                             A:50 X:30 Y:02 S:75 P:nvUbdizc 
          $9FBA:BD 75 BF  LDA $BF75,X @ $BFA5 = #$BF                   A:50 X:30 Y:02 S:75 P:nvUbdizc 
          $9FBD:85 0F     STA $000F = #$01                             A:BF X:30 Y:02 S:75 P:NvUbdizc 
          $9FBF:A0 04     LDY #$04                                     A:BF X:30 Y:02 S:75 P:NvUbdizc 
          $9FC1:B1 0E     LDA ($0E),Y @ $BF54 = #$62                   A:BF X:30 Y:04 S:75 P:nvUbdizc 
          $9FC3:85 A6     STA $00A6 = #$76                             A:62 X:30 Y:04 S:75 P:nvUbdizc 
          $9FC5:C8        INY                                          A:62 X:30 Y:04 S:75 P:nvUbdizc 
          $9FC6:B1 0E     LDA ($0E),Y @ $BF55 = #$63                   A:62 X:30 Y:05 S:75 P:nvUbdizc 
          $9FC8:85 A7     STA $00A7 = #$77                             A:63 X:30 Y:05 S:75 P:nvUbdizc 
Compared to this:
$9FAF:20 7D E4  JSR $E47D                                    A:07 X:00 Y:02 S:74 P:nvUbdizc 
             $E47D:85 5D     STA $005D = #$08                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E47F:A9 00     LDA #$00                                     A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E481:8D 27 00  STA $0027 = #$01                             A:00 X:00 Y:02 S:72 P:nvUbdiZc 
             $E484:A9 07     LDA #$07                                     A:00 X:00 Y:02 S:72 P:nvUbdiZc 
             $E486:05 5C     ORA $005C = #$40                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E488:8D 00 80  STA $8000 = #$A9                             A:47 X:00 Y:02 S:72 P:nvUbdizc 
             $E48B:A5 5D     LDA $005D = #$07                             A:47 X:00 Y:02 S:72 P:nvUbdizc 
             $E48D:8D 01 80  STA $8001 = #$04                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E490:AD 27 00  LDA $0027 = #$00                             A:07 X:00 Y:02 S:72 P:nvUbdizc 
             $E493:D0 EA     BNE $E47F                                    A:00 X:00 Y:02 S:72 P:nvUbdiZc 
             $E495:60        RTS (from $E47D) --------------------------- A:00 X:00 Y:02 S:72 P:nvUbdiZc 
           $9FB2:68        PLA                                          A:00 X:00 Y:02 S:74 P:nvUbdiZc 
          $9FB3:0A        ASL                                          A:16 X:00 Y:02 S:75 P:nvUbdizc 
          $9FB4:AA        TAX                                          A:2C X:00 Y:02 S:75 P:nvUbdizc 
          $9FB5:BD 74 BF  LDA $BF74,X @ $BFA0 = #$40                   A:2C X:2C Y:02 S:75 P:nvUbdizc 
          $9FB8:85 0E     STA $000E = #$E0                             A:40 X:2C Y:02 S:75 P:nvUbdizc 
          $9FBA:BD 75 BF  LDA $BF75,X @ $BFA1 = #$BF                   A:40 X:2C Y:02 S:75 P:nvUbdizc 
          $9FBD:85 0F     STA $000F = #$01                             A:BF X:2C Y:02 S:75 P:NvUbdizc 
          $9FBF:A0 04     LDY #$04                                     A:BF X:2C Y:02 S:75 P:NvUbdizc 
          $9FC1:B1 0E     LDA ($0E),Y @ $BF44 = #$5E                   A:BF X:2C Y:04 S:75 P:nvUbdizc 
          $9FC3:85 A6     STA $00A6 = #$76                             A:5E X:2C Y:04 S:75 P:nvUbdizc 
          $9FC5:C8        INY                                          A:5E X:2C Y:04 S:75 P:nvUbdizc 
          $9FC6:B1 0E     LDA ($0E),Y @ $BF45 = #$5F                   A:5E X:2C Y:05 S:75 P:nvUbdizc 
          $9FC8:85 A7     STA $00A7 = #$77                             A:5F X:2C Y:05 S:75 P:nvUbdizc 
Chambers_N
MESHUGGAH
Other
Skilled player (1920)
Joined: 11/14/2009
Posts: 1353
Location: 𝔐𝔞𝔤𝑦𝔞𝔯
The difference probably comes from different stack. In FCEUX you can check it out in the debugger. The change start at PLA. PLA: pull accumulator ASL: arithmetic shift left
PhD in TASing 🎓 speedrun enthusiast ❤🚷🔥 white hat hacker ▓ black box tester ░ censorships and rules...
Joined: 7/21/2017
Posts: 54
I see that the stack is $0174 according to the debugger, and of the values displayed there I do see the 18 and 16 respectively at the beginning, which seem to be address $0175 when I check this in the Hex Editor. When I debug to find what writes to $0175 it shows a subroutine which runs three times per frame E496, and when I check this routine in the trace logger the address $0175 is never involved. It is a curious thing that it should be so complicated to track what letter graphic is shown down to why it shows one letter over another.
Chambers_N
MESHUGGAH
Other
Skilled player (1920)
Joined: 11/14/2009
Posts: 1353
Location: 𝔐𝔞𝔤𝑦𝔞𝔯
Regarding the stack: your observations are right. More info: https://wiki.nesdev.com/w/index.php/Stack It shows how does values get in to the stack and how it works basicly. E496 is the subroutine you want to check I guess.
PhD in TASing 🎓 speedrun enthusiast ❤🚷🔥 white hat hacker ▓ black box tester ░ censorships and rules...