logo
 drop

Main

Community

Submissions

Help

78361086 visitors

Author Topic: Mega Man X3 (Clearing Dialogue - Layer 3)  (Read 2859 times)

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Mega Man X3 (Clearing Dialogue - Layer 3)
« on: June 02, 2012, 09:47:18 am »
There's not really any code that I can post as it's more or less a question.

I'm reworking the dialogue system to be more dynamic and much quicker than it originally was.  Now since I've essentially removed text scrolling from in-game dialogue, I'm trying to figure out a way I can go about clearing previous dialogue off of layer 3 then put the new dialogue.  Which route would be the best way of doing this?

I have the idea in mind of having it reload the dialogue again but set it to a dialogue that completely blanks out everything currently and insta places the text, then right away after it'll start writing the new text.  Though I feel like that can be a much more simple method.

For an example of what I mean by wanting to clear the dialogue, this is what happens otherwise.

- It's writing the new text but the original stays.
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

Bregalad

  • Hero Member
  • *****
  • Posts: 1647
  • Location: 46.48°N 6.84°E
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #1 on: June 02, 2012, 04:40:28 pm »
I have no idea about the internal workings of the game, but there is a 99% probability that there is some kind of buffer before the game writes the text to the screen.
Also there is a 99% probability that the routine that clears the buffer and the screen already exists and is called before the first message. Then you just have to hack the game to call it on every phrase now.

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5082
  • Location: Hikone, Japan
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #2 on: June 02, 2012, 05:22:41 pm »
Essentially there's a routine that writes blank spaces every time a new window is made. So you just have to write something similar to that.

~DS
Red Comet: :'( Poor DS. Nobody loves him like RC does. :'(
Sliver-X: LET ME INFRINGE UPON IT WITH MY MOUTH
DSRH - Currently working on: Demon's Blazon, Romancing SaGa, FFIV EasyType.
http://www.youtube.com/user/DarknessSavior

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #3 on: June 03, 2012, 08:06:02 am »
Code: [Select]
$02/FCE0 A9 04       LDA #$04                A:0013 X:1818 Y:0000 P:envMxdIzc
$02/FCE2 1C C1 00    TRB $00C1  [$06:00C1]   A:0004 X:1818 Y:0000 P:envMxdIzc
- Apparently setting this completely clears the text.  The issue that comes with it now is that now that the next lines of text no longer appear ._.  Now, if you forcefully load the dialogue to come with it after, it for some reason starts writing the other text first then it jumps to redoing the whole original string.  But in general, setting that completely removes all text first.

Edit: Actually this may dictate the later of the font itself.  So this isn't the right code.  Grr..

But I have found that.

Code: [Select]
$00/E73F 7C 42 E7    JMP ($E742,x)[$00:E8E7] A:0012 X:0012 Y:0001 P:envMXdIzc
$00/E8E7 20 21 E9    JSR $E921  [$00:E921]   A:0012 X:0012 Y:0001 P:envMXdIzc
$00/E921 22 00 00 40 JSL $400000[$40:0000]   A:0012 X:0012 Y:0001 P:envMXdIzc
- This code loads everytime before a new 'page' of text.  So this would be where to stick the screen wipe.
« Last Edit: June 03, 2012, 08:14:23 am by justin3009 »
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

LostTemplar

  • Hero Member
  • *****
  • Posts: 1003
  • Location: Germany
    • View Profile
    • au-ro-ra.net
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #4 on: June 03, 2012, 08:11:38 am »
You should probably opt for first understanding what the heck's going on. You could try tracing that bit 2 of $c1 and see what it actually influences (in assembler, that is) by setting a data read breakpoint on it. That's how I do it anyway.

Or you could just write your own routine. Clearing the tilemap shouldn't be very difficult, but I usually recommend just using the facilities the game already provides - that way there are less changes where bugs could creep in.

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #5 on: June 03, 2012, 08:17:49 am »
I'm trying to figure out what essentially CLEARS Layer 3.  But from the looks of it I'm not finding it.  And yeah, I just found out that the $C1 is actually the layer of the font itself.  That data in that entire area is just what layer and palette everything is.

I haven't essentially worked with clearing a tilemap, so I'm not really sure how it works.  I've been tinkering with the idea of it loading a large blank data of text but then that means it'd lose it's tracking place in which part of the dialogue it's at.  I'm not honestly sure how I'd go about that way.  I'll keep looking for a screen wipe of layer 3 but I feel like there isn't one at all.

Edit: Well it definitely clears it before it loads new dialogue from what I'm seeing.  I removed a chunk of code after and changed layer visibility.  It seems Layer 3 actually sticks around for the whole time, just the palette gets swapped to something darker and visibility is removed, but it IS there.

Edit 2: It's as DarknessSavior said.  It gets wiped whenever a new box appears.  Not.. really sure how to duplicate that without it screwing everything up.
« Last Edit: June 03, 2012, 08:51:59 am by justin3009 »
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

LostTemplar

  • Hero Member
  • *****
  • Posts: 1003
  • Location: Germany
    • View Profile
    • au-ro-ra.net
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #6 on: June 03, 2012, 08:50:52 am »
Should be this piece of code. It transfers the #$00 at $7E2622 #$1000 times to VRAM offset #$0800 (which is auto-incremented), thus clearing the BG3 tilemap. I only looked at the very first dialog between Zero and X, but it was called before and after.

Code: [Select]
$7E/21A6 A9 80       LDA #$80
$7E/21A8 8D 15 21    STA $2115
$7E/21AB A0 00 10    LDY #$1000
$7E/21AE A2 09 18    LDX #$1809 ; fixed source address, CPU->PPU
$7E/21B1 8E 00 43    STX $4300
$7E/21B4 A2 22 26    LDX #$2622 ; source offset (contains #$00)
$7E/21B7 8E 02 43    STX $4302
$7E/21BA A9 7E       LDA #$7E ; source bank
$7E/21BC 8D 04 43    STA $4304

$7E/21BF 46 A3       LSR $A3
$7E/21C1 90 0E       BCC $0E [$21D1]
$7E/21D1 46 A3       LSR $A3
$7E/21D3 90 0E       BCC $0E [$21E3]
$7E/21E3 46 A3       LSR $A3
$7E/21E5 90 0E       BCC $0E [$21F5]

$7E/21E7 A2 00 08    LDX #$0800 ; destination VRAM offset in words (offset of BG3 tilemap)
$7E/21EA 8E 16 21    STX $2116
$7E/21ED 8C 05 43    STY $4305 ; count (#$1000 <- size of BG3 tilemap)
$7E/21F0 A9 01       LDA #$01
$7E/21F2 8D 0B 42    STA $420B ; start DMA

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #7 on: June 03, 2012, 09:03:29 am »
That's what I thought it was!  The big thing there is I have no clue how the game calls that data.  The logs I've had never picks it up and putting a breakpoint on that doesn't seem to help in the slightest either.
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

LostTemplar

  • Hero Member
  • *****
  • Posts: 1003
  • Location: Germany
    • View Profile
    • au-ro-ra.net
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #8 on: June 03, 2012, 09:10:01 am »
It's part of the NMI handler. Can't give you much more information without diving in myself though.

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #9 on: June 03, 2012, 09:26:17 am »
Yeah, it's definitely part of that.  I've noticed that the common pattern of code seems to always end up like this.

Code: [Select]
$02/FA12 A9 04       LDA #$04                A:1800 X:0002 Y:00AF P:envMXdIZc
$02/FA14 85 02       STA $02    [$00:181A]   A:1804 X:0002 Y:00AF P:envMXdIzc
$02/FA16 A9 04       LDA #$04                A:1804 X:0002 Y:00AF P:envMXdIzc
$02/FA18 0C A3 00    TSB $00A3  [$06:00A3]   A:1804 X:0002 Y:00AF P:envMXdIzc
$02/FA1B C2 30       REP #$30                A:1804 X:0002 Y:00AF P:envMXdIZc
$02/FA1D 8B          PHB                     A:1804 X:0002 Y:00AF P:envmxdIZc
$02/FA1E A2 00 03    LDX #$0300              A:1804 X:0002 Y:00AF P:envmxdIZc
$02/FA21 A0 00 BC    LDY #$BC00              A:1804 X:0300 Y:00AF P:envmxdIzc
$02/FA24 A9 1F 00    LDA #$001F              A:1804 X:0300 Y:BC00 P:eNvmxdIzc
$02/FA27 54 7F 00    MVN 00 7F               A:001F X:0300 Y:BC00 P:envmxdIzc
$02/FA2A AB          PLB                     A:FFFF X:0320 Y:BC20 P:envmxdIzc
$02/FA2B E2 30       SEP #$30                A:FFFF X:0320 Y:BC20 P:envmxdIzc
$02/FA2D 6B          RTL                     A:FFFF X:0020 Y:0020 P:envMXdIzc
*** NMI

$7E/21A4 C2 10       REP #$10                A:0004 X:0031 Y:0000 P:envMXdIzc
$7E/21A8 8D 15 21    STA $2115
....

So I at least know what to use for the code and a general idea of things.  I'll have to dig farther when I'm home from work later tonight.

Edit:
Code: [Select]
$00/E8E7 A9 04       LDA #$04                A:2012 X:0012 Y:0013 P:envMXdIzc
$00/E8E9 0C A3 00    TSB $00A3  [$06:00A3]   A:2004 X:0012 Y:0013 P:envMXdIzc
- Setting this will completely remove all dialogue then write the next!

The only issue with this is that the screen flashes for a second.  Not sure how to fix this quite yet.
« Last Edit: June 04, 2012, 07:32:01 am by justin3009 »
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

ETG

  • Newbie
  • *
  • Posts: 39
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #10 on: June 04, 2012, 08:06:57 pm »
Well, here's a thought. This may take more care in crafting your data, but what if each page of text writes a whole screen of tiles every time. Each paragraph would have enough blank spaces before and after to clear the entire text box on it's own. If it can handle some form of RLE, it wouldn't add but a few bytes to each screen.

Also, could the flashing be hidden by a quick palette animation?

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #11 on: June 04, 2012, 09:41:23 pm »
I was thinking of doing that but it's so horribly inefficient and ugly :/  I need as much room as possible as well for how much is going to change.
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

LostTemplar

  • Hero Member
  • *****
  • Posts: 1003
  • Location: Germany
    • View Profile
    • au-ro-ra.net
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #12 on: June 05, 2012, 03:01:47 am »
Clearing BG3 by setting bit 2 of $A3 before the game shows a new paragraph should be the most efficient approach. I can't imagine why the screen would flash, though, as it's all happening in vblank. What exactly are you doing? Did you accidentally set any other bits of $A3 or anything like that?

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #13 on: June 05, 2012, 10:08:25 am »
Changing the value of A3 to 04 will keep everything and clear BG3.  Any other value will basically cause the background itself to disappear or other whacked out stuff.  And I'm not doing anything else with A3 from what I know of.

Code: [Select]
$00/E8E7 20 21 E9    JSR $E921  [$00:E921]   A:0012 X:0012 Y:0001 P:envMXdIzc. - Loads PC check to load correct table and values for text
That's bumped to $00/E727.  Then basically does this.

Code: [Select]
$00/E727 A9 04       LDA #$04                A:0012 X:0012 Y:0001 P:envMXdIzc
$00/E729 0C A3 00    TSB $00A3  [$06:00A3]   A:0004 X:0012 Y:0001 P:envMXdIZc
$00/E72C 20 21 E9    JSR $E921  [$00:E921]   A:0004 X:0012 Y:0001 P:envMXdIZc

From what I've heard from someone else, it's probably flashing because I'm interrupting some kind of transfer.
« Last Edit: June 05, 2012, 10:20:28 am by justin3009 »
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

LostTemplar

  • Hero Member
  • *****
  • Posts: 1003
  • Location: Germany
    • View Profile
    • au-ro-ra.net
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #14 on: June 05, 2012, 10:53:20 am »
You could verify that no (H)DMA channels collide. From what I can gather from the very first dialog, the game uses channel 0 for about everything DMA and 6/7 for HDMA stuff. You could try and change the channel in that BG clearing routine to another one.

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #15 on: June 05, 2012, 12:49:54 pm »
Wouldn't that interfere with how the game actually clears anything in general and cause other issues?  I'm not sure how anything would be colliding though.  It only runs the routine to clear, not draw anything else.  Which is highly odd.

Edit:

Code: [Select]
$7E/21F0 A9 01       LDA #$01
$7E/21F2 8D 0B 42    STA $420B ; start DMA
- This is what seems to cause the flashing and the BG3 wiping.  Removing this stops the flash but doesn't erase anything anymore.

Edit 2: Setting A9 02 8D 0B 42 in empty space at E8D3 makes it so it doesn't flash when it loads the next string of text.  Though it still flashes before hand, when the code is first called.  Pretty strange still but at least part of the problem is fixed.

Edit 3: I'm going through Rockman & Forte's code for the text box/clearing.  That game remove all text automatically before the next string is loaded.  From what I'm seeing so far, this game has a MUCH more dynamic system than the X series.  Too bad this didn't come BEFORE X3 came out, as I'm sure it would have been used.  I may see if I can transfer over the system into the X series.  It's seriously so much better in every way possible.
« Last Edit: June 11, 2012, 05:04:05 pm by justin3009 »
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

justin3009

  • Hero Member
  • *****
  • Posts: 973
  • Location: Wisconsin
  • Welp
    • View Profile
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #16 on: June 25, 2012, 06:50:58 pm »
A double post, or a merge whatever this decides to do, but I figured out how to essentially 'clear' Layer 3 now after a LONG break.

I looked at the level select code in which it erases the dialogue off screen when you move to a new level to select.  Figured out what it did, mimiced the exact code for the actual dialogue system and now it instantaneously writes blank tiles all over Layer 3 just before the new dialogue appears with NO lag or flashing or anything.  All I have to do now is create a quick loop so it loads about 6 pointers one after another and erases a certain portion of the screen.

Edit: Fun part also!  I can use this SAME code to instantaneously draw the dialogue display as well :)  This thing is a miracle!

Edit 2: http://www.youtube.com/watch?v=eKs2wce3Dpw&feature=plcp - In action!
« Last Edit: June 25, 2012, 07:34:40 pm by justin3009 »
'We have to find some way to incorporate the general civilians in the plot'

'We'll kill off children in the Juuban district with an infection where they cough up blood and are found hanging themselves from cherry blossom trees.'

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5082
  • Location: Hikone, Japan
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: Mega Man X3 (Clearing Dialogue - Layer 3)
« Reply #17 on: June 25, 2012, 09:24:57 pm »
Looks impressive. I can't wait to see what you do with this hack. :D

~DS
Red Comet: :'( Poor DS. Nobody loves him like RC does. :'(
Sliver-X: LET ME INFRINGE UPON IT WITH MY MOUTH
DSRH - Currently working on: Demon's Blazon, Romancing SaGa, FFIV EasyType.
http://www.youtube.com/user/DarknessSavior