News: 11 March 2016 - Forum Rules

Author Topic: Help understanding a routine in a Rockman 2 hack  (Read 2447 times)

cschifani

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Help understanding a routine in a Rockman 2 hack
« on: January 13, 2019, 11:20:24 am »
I'm totally new to ROM hacking, and right now I'm just trying to understand some things from hacks others have done in order to learn. What I want to do is find the full routine that runs in a Rockman 2 hack (an early version of Rockman Mindroar that lets you switch gravity by pressing select) when the select button is pressed. I've been toying with the FCEUX emulator and its debugging features, but have not found a systematic way to go about things that also gives me information I can more or less understand. If anyone could provide guidance on what I might do to isolate this routine, I would be very grateful. Many thanks in advance for your help.

Canight

  • Jr. Member
  • **
  • Posts: 2
    • View Profile
Re: Help understanding a routine in a Rockman 2 hack
« Reply #1 on: March 03, 2019, 01:01:26 pm »
Hey, I'm also a newbie so maybe this isn't the best way but what did help me in finding a specific sub-routine was using the trace logger + code/data logger in FCEUX together. Actually, I specifically was looking for what happens when you press select the same as you are (I wanted to see the pause code). What I did was start up the Code Data Logger and don't press anything and wait for the "PRG Logged as Code" to stop increasing. This means there isn't any new code being executed at the moment. Then on the trace logger, check the checkbox that says "Only log newly mapped code" and then start logging. Then press the select button in game, wait for everything to finish and stop the trace logger. You should be able to see only the code responsible for the gravity switching!

Cyneprepou4uk

  • Hero Member
  • *****
  • Posts: 877
  • I am the baldest romhacker
    • View Profile
Re: Help understanding a routine in a Rockman 2 hack
« Reply #2 on: March 03, 2019, 09:43:25 pm »
Canight, you know, this is a very good idea indeed. Don't know why I haven't thought one can do that in several years  :banghead: I'm able to find stuff without it, but it can definitely be helpful for novices. I'll add this method to my guide for sure. Thank you stranger :angel:

Canight

  • Jr. Member
  • **
  • Posts: 2
    • View Profile
Re: Help understanding a routine in a Rockman 2 hack
« Reply #3 on: March 04, 2019, 08:26:23 pm »
Yeah, combined with already knowing a few key memory locations (like the memory holding the state of the gravity in OP's case) you can pinpoint the exact code you're looking for pretty quickly!
« Last Edit: March 05, 2019, 02:21:08 am by MathOnNapkins »

nesrocks

  • Hero Member
  • *****
  • Posts: 745
    • View Profile
    • nesrocks.com
Re: Help understanding a routine in a Rockman 2 hack
« Reply #4 on: May 01, 2019, 05:42:29 pm »
"Only log newly mapped code"
I had never thought of a use for this option. Good idea! :beer:

cschifani

  • Jr. Member
  • **
  • Posts: 35
    • View Profile
Re: Help understanding a routine in a Rockman 2 hack
« Reply #5 on: May 11, 2019, 09:42:14 pm »
Thank you all, especially Canight, for your helpful suggestions. I tried what Canight suggested, got a large amount of code, attempted to edit the changed areas into a regular Rockmman 2 ROM, and got no result. One thing I have noticed from other tests, however, is that RAM address $0078 cycles from 0-2 when the select button is pressed, while $0077 cycles between 0 to 1 with each press of select (and each change in gravity). I'm not sure how to use this information to zero in on the code that goes from select pressed to gravity changed, although I think they are related. Any thoughts on what I can do next? Thanks again for your help!

May 12, 2019, 12:47:47 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
This bit of code from my last test using Canight's method seems to have most of the info I should need. I just don't know what to do with it. Any advice would be greatly appreciated.

FCEUX 2.2.3 - Trace Log File
(1217792 lines skipped)
    $F8B9:A5 F9     LDA $00F9 = #$00                             A:04 X:02 Y:00 S:FB P:nvUbdIzc
    $F8BB:D0 2F     BNE $F8EC                                    A:00 X:02 Y:00 S:FB P:nvUbdIZc
    $F8BD:AD A0 04  LDA $04A0 = #$B4                             A:00 X:02 Y:00 S:FB P:nvUbdIZc
    $F8C0:C9 09     CMP #$09                                     A:B4 X:02 Y:00 S:FB P:NvUbdIzc
    $F8C2:90 28     BCC $F8EC                                    A:B4 X:02 Y:00 S:FB P:NvUbdIzC
    $F8C4:A5 78     LDA $0078 = #$00                             A:B4 X:02 Y:00 S:FB P:NvUbdIzC
    $F8C6:D0 24     BNE $F8EC                                    A:00 X:02 Y:00 S:FB P:nvUbdIZC
    $F8C8:A5 79     LDA $0079 = #$00                             A:00 X:02 Y:00 S:FB P:nvUbdIZC
    $F8CA:D0 20     BNE $F8EC                                    A:00 X:02 Y:00 S:FB P:nvUbdIZC
    $F8CC:A9 3F     LDA #$3F                                     A:00 X:02 Y:00 S:FB P:nvUbdIZC
    $F8CE:20 51 C0  JSR $C051                                    A:3F X:02 Y:00 S:FB P:nvUbdIzC
      $C051:A4 66     LDY $0066 = #$00                             A:3F X:02 Y:00 S:F9 P:nvUbdIzC
      $C053:C0 10     CPY #$10                                     A:3F X:02 Y:00 S:F9 P:nvUbdIZC
      $C055:B0 05     BCS $C05C                                    A:3F X:02 Y:00 S:F9 P:NvUbdIzc
      $C057:99 80 05  STA $0580,Y @ $0580 = #$30                   A:3F X:02 Y:00 S:F9 P:NvUbdIzc
      $C05A:E6 66     INC $0066 = #$00                             A:3F X:02 Y:00 S:F9 P:NvUbdIzc
      $C05C:60        RTS (from $C051) --------------------------- A:3F X:02 Y:00 S:F9 P:nvUbdIzc
    $F8D1:A9 02     LDA #$02                                     A:3F X:02 Y:00 S:FB P:nvUbdIzc
    $F8D3:85 78     STA $0078 = #$00                             A:02 X:02 Y:00 S:FB P:nvUbdIzc
    $F8D5:A5 77     LDA $0077 = #$00                             A:02 X:02 Y:00 S:FB P:nvUbdIzc
    $F8D7:49 01     EOR #$01                                     A:00 X:02 Y:00 S:FB P:nvUbdIZc
    $F8D9:85 77     STA $0077 = #$00                             A:01 X:02 Y:00 S:FB P:nvUbdIzc
    $F8DB:A9 00     LDA #$00                                     A:01 X:02 Y:00 S:FB P:nvUbdIzc
    $F8DD:38        SEC                                          A:00 X:02 Y:00 S:FB P:nvUbdIZc
    $F8DE:ED 60 06  SBC $0660 = #$C0                             A:00 X:02 Y:00 S:FB P:nvUbdIZC
    $F8E1:8D 60 06  STA $0660 = #$C0                             A:40 X:02 Y:00 S:FB P:nvUbdIzc
    $F8E4:A9 00     LDA #$00                                     A:40 X:02 Y:00 S:FB P:nvUbdIzc
    $F8E6:ED 40 06  SBC $0640 = #$FF                             A:00 X:02 Y:00 S:FB P:nvUbdIZc
    $F8E9:8D 40 06  STA $0640 = #$FF                             A:00 X:02 Y:00 S:FB P:nvUbdIZc
« Last Edit: May 12, 2019, 12:47:47 pm by cschifani »