Author Topic: How to do Step Mine for 0 MP  (Read 7532 times)

assassin

  • Bane of Retards
  • *
  • Posts: 987
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: How to do Step Mine for 0 MP
« Reply #15 on: January 07, 2010, 02:05:51 AM »
Quote
The way I did originally was extremely sloppy, I found code that executes in specific areas and hooked those. In essence, the frame counter is incrementing all the time except during transitions which might be true of the original game's behavior. I haven't checked, suppose I should.

please do.  if it's incrementing more often than 60x a second, it's not really a "frame counter".  now, it may still suffice for fixing the Randomosity bug, but it'll work differently than what i had in mind (i.e. the solution i proposed for the existing game).

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,661
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: How to do Step Mine for 0 MP
« Reply #16 on: January 07, 2010, 02:30:07 AM »
please do.  if it's incrementing more often than 60x a second, it's not really a "frame counter".  now, it may still suffice for fixing the Randomosity bug, but it'll work differently than what i had in mind (i.e. the solution i proposed for the existing game).
Good news: I'm consistent with the game's behavior, transitions stop $021E.
Bad news: I still can't tell if I have a frame counter or not. bsnes's hex editor updates "once every emulated second," which is far too slow for this test. Geiger's updates more frequently, but still not nearly fast enough. If FCEUXD could work for this, I'd have it made. That hex editor knows how to get it done. :happy:

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 987
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: How to do Step Mine for 0 MP
« Reply #17 on: January 07, 2010, 02:40:39 AM »
what variable did you use for the 0-255 counter?  it'll help me know what free RAM space to favor in my own efforts.

use Geiger to set a Write trace on the variable, and use it to set a Run trace on C3/13C8.  then compare how many breakpoints are hit for the former for every hit of the latter.

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,661
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: How to do Step Mine for 0 MP
« Reply #18 on: January 07, 2010, 03:20:30 AM »
There is a 0x40 byte range of free stuff starting at $1440, and I promptly took $1440 for my purpose.

119 bugs fixed and counting.

assassin

  • Bane of Retards
  • *
  • Posts: 987
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: How to do Step Mine for 0 MP
« Reply #19 on: January 07, 2010, 08:35:06 AM »
ah, thanks.  1 byte or 2?

Lenophis

  • Forum Overlord
  • *
  • Posts: 1,661
  • Gender: Male
  • I sad
    • View Profile
    • Slick Productions
Re: How to do Step Mine for 0 MP
« Reply #20 on: January 07, 2010, 02:06:12 PM »
Just one byte, a 65,535 counter would be a wee bit overkill. Well, maybe. :tongue:

119 bugs fixed and counting.

mblock129

  • Ymir
  • *
  • Posts: 13
    • View Profile
    • Zephyr
Re: How to do Step Mine for 0 MP
« Reply #21 on: January 13, 2010, 08:40:41 PM »

mblock, is this your discovery?

As far as I know.

Just in case anyone was wondering, I'm willing to waive any first dibs on making a bugfix for this. Not really my area of expertise.

assassin

  • Bane of Retards
  • *
  • Posts: 987
  • space bears are not gentle!
    • View Profile
    • My Barren Webpage
Re: How to do Step Mine for 0 MP
« Reply #22 on: September 17, 2012, 12:32:05 PM »
curiously, the MP cost under the Skills menu reads the correct variables, so it doesn't have either of the issues mblock129 described.  (i say "curious" because the Bank C3 coders are avoiding their own menu variables here, but it makes sense that people who coded the menus would be more familiar with their variables' limitations.)  however, it DOES have the problem i described with reading the Hours and Minutes as two separate bytes.  unless there are some precautions taken for the NMI, you could get an erroneous cost (1 or 2 MP too low, depending on what you consider "current" time) if you happen to pop into Skills-->Lore right as Minutes roll over to 0.  there's like a 1/8524 chance (7 / (3580000 / 60)) it'll bug, and that's assuming you know what frame to enter on (i don't) -- so VERY slim.

fortunately, their code to determine the cost is bigger than Bank C2's, so i can fix this theoretical flaw with at least 1 byte to spare.

EDIT: for that matter, the game reads hours/minutes and seconds separately (it has no choice; they're 3 bytes) when copying them into variables before saving them to SRAM.  what's to stop the bug from happening there?  or are menu actions "aligned" to take place at a certain part of a frame, so the game "knows" that NMIs will never conflict with them?  if that's the case, then neither the Save screen nor the Skills submenu would have the problem..

EDIT2: ok, this feared issue probably will never happen.  the main menu loop will wait on an NMI shortly before calling a menu action (such as loading the Lores submenu under Skills).  in order for another NMI to happen in the middle of this, the action would have to take over 59000 CPU cycles (3580000 CPU speed / 60 frames in a second).  a trace log of Lore submenu loading has only 8693 instructions, and assuming 3-4 cycles average per instruction, that'll be well short of the limit.

i haven't timed the act of saving your game (choosing "Yes" on "Erasing data.  Okay?"), but my guess is it's shorter.
« Last Edit: September 19, 2012, 08:49:33 PM by assassin »

Imzogelmo

  • Ogopogo Aficianado
  • *
  • Posts: 240
  • Gender: Male
  • Ask me about my other job.
    • View Profile
    • NEPROMR
Re: How to do Step Mine for 0 MP
« Reply #23 on: July 08, 2016, 01:05:44 AM »
 :scared: Necropost warning  :scared:

I can confirm Leno's observation that the frame counter $021E (and thus all time variables)  do(es) not update during certain transitions. I can't quite isolate the full gambit of changes that do this, but my first instinct is that this is happening when changing banks that have different NMI routines, such as going into/out of a battle.
5/31/16 - I have an assembly of the battle portion of C2, relocated to the F0 bank, which has both vanilla and patch code in my dropbox. I'll be updating it with additional patches as I have time. I will *not* be releasing it publicly, but ask me for the link and I'll share.