News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: MegaED X, the Megaman X hacking tool (Now with MMX2 support)  (Read 190177 times)

RedGuy

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #120 on: February 19, 2016, 11:27:37 pm »
Someone pointed me at the source for this editor a few weeks ago after I offered some C++ help.  I now have a local copy of the editor with the following changes:

- X2 and X3 support
- Event editor
- Minor tweaks to make the Scene and other editors easier to use
- A really basic (hack) Sprite editor (displays a fixed region of memory as 4bpp graphic tiles)

There's also code to resort the tiles for better compression, but it's not very smart or well tested.  This makes it easier to edit tiles and have them fit into the same space as the original compressed region.

This is the first time I've done windows gui programming or any rom hacking (snes or otherwise) so some of the changes are not clean.  The editor also has some things that could be improved that I haven't touched.  E.g. losing edits if the level is changed without saving.  The code could use some cleanup if I were to share it so I wanted to see if it's useful to anyone.  I need to learn how to use git, too.  Let me know if there is any interest in this.

DackR

  • Full Member
  • ***
  • Posts: 130
  • Mo~
    • View Profile
    • Hackaday.io Page
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #121 on: February 19, 2016, 11:39:57 pm »
Someone pointed me at the source for this editor a few weeks ago after I offered some C++ help.  I now have a local copy of the editor with the following changes:

- X2 and X3 support
- Event editor
- Minor tweaks to make the Scene and other editors easier to use
- A really basic (hack) Sprite editor (displays a fixed region of memory as 4bpp graphic tiles)

There's also code to resort the tiles for better compression, but it's not very smart or well tested.  This makes it easier to edit tiles and have them fit into the same space as the original compressed region.

This is the first time I've done windows gui programming or any rom hacking (snes or otherwise) so some of the changes are not clean.  The editor also has some things that could be improved that I haven't touched.  E.g. losing edits if the level is changed without saving.  The code could use some cleanup if I were to share it so I wanted to see if it's useful to anyone.  I need to learn how to use git, too.  Let me know if there is any interest in this.

Dude. No question this would be helpful for people. Put it on github so we can fork it! :)

justin3009

  • Hero Member
  • *****
  • Posts: 1658
  • Welp
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #122 on: February 20, 2016, 11:18:25 am »
SERRIOOUUSSLLLY have interest in this!  I'm no C# or C++ coder sadly, I only have a few broad understanding of it, but if you need anything X2/X3 ASM wise I'm more than glad to help with it.  Especially with Sprite Editing, Sprite Assembly and Animation Data as well.  I've messed with enough of that to have a decent understanding of it.
'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.'

RedGuy

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #123 on: February 20, 2016, 06:11:45 pm »
For those of you who have visual studio or want to look at the source here's a github link: https://github.com/RedGuyyyy/MegaEdX.git

And for those who want to try a precompiled version: https://drive.google.com/file/d/0Bx9gzQZCkH8qSy0tVGRDN2JHYzQ/view?usp=sharing

The precompiled binary is just temporary until I figure out if/how it should be distributed.
« Last Edit: February 20, 2016, 06:26:32 pm by RedGuy »

Seeeeph

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #124 on: February 25, 2016, 06:14:42 pm »
.
« Last Edit: June 01, 2016, 09:28:47 pm by Seeeeph »

RedGuy

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #125 on: February 25, 2016, 11:58:31 pm »
Glad to hear people are finding the editor updates useful.

I updated the source with an enemy property editor that supports editing HP and the Damage Modifier for some enemies.  You need to know the enemy ID to edit the right one.  It's a bit of a hack because in X1 and X2 the values are constants in LDA instructions.  So the editor tries to walk through and find the right STAs and the preceding LDA.  It has a dumb pattern matcher so it's possible (though unlikely) it will think it found a value when it's actually some other part of memory.  It may or may not work for bosses assuming it can actually find their HP and Damage modifier.  The damage modifier is shared across a lot of enemies so changing one will change other enemies.  HP seems unique, though.  X3 has a table in rom with the values which is a lot easier to work with.

Here's a compiled version: https://drive.google.com/file/d/0Bx9gzQZCkH8qT0d1TkRZMERiOFE/view?usp=sharing

justin3009

  • Hero Member
  • *****
  • Posts: 1658
  • Welp
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #126 on: February 26, 2016, 08:14:56 am »
Might be a good idea in the long run to possibly have every enemy have their own damage values, if not that, maybe allow for adding a new feature in the editor where you can dictate which enemy shares what damage table with the others but you have the option of creating a new one.
'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.'

Seeeeph

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #127 on: February 26, 2016, 09:30:49 am »
.
« Last Edit: June 01, 2016, 09:28:23 pm by Seeeeph »

RedGuy

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #128 on: February 26, 2016, 09:59:02 am »
Are you referring to the scene editor?  That's already changed to:

- Include a scene window, block window, and selected/replaced window.
- Right mouse selects a block in any of the following windows: scene, block, replaced.  The block window goes to the selected block.  The selected window changes to a picture of the block.
- Left mouse replaces the block under the cursor in the scene window.  The replaced window changes to a picture of the replaced block (only if the block number changed).
- There are focus rectangles help identify the block in the scene and block window.

It's a big hack right now, but there are also changes to allow typing new hex values in the other editors which have spinboxes.  The previous version of the editor wouldn't record changes that were typed in.

I'll take a look at separating the hp and damage values in X1 and X2 into a table like X3.  That would make editing them a lot easier and eliminate the cases where enemies share the same value.

Here's a picture of the scene editor.


Seeeeph

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #129 on: February 26, 2016, 11:16:43 am »
.
« Last Edit: June 01, 2016, 09:27:56 pm by Seeeeph »

RedGuy

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #130 on: February 29, 2016, 12:22:24 pm »
I updated the source to try to decompress the graphics for sprites.  It mostly works, but there are a few sprites that might not be compressed.  Also, the palette selection is kind of annoying right now.  I still need to find where the assembly information is... hopefully that has the palette reference.

The editing feature is disabled as modifying compressed data can lead to a larger compressed block which might overwrite other data.  That is solved with background tiles by hardcoding the original size for each level in the editor to check for a larger compressed block and sorting to improve compression.  This is a lot more work to do for 100+ compressed regions and I haven't found the sprite assembly information to fix the pointers if tiles are resorted.

The sprite editor is likely to remain a sprite viewer for a while.  I'm trying to get a fully assembled frame of the enemy with the correct palette to appear on the level when an enemy event is selected in the event editor.

Here's a binary: https://drive.google.com/file/d/0Bx9gzQZCkH8qZEtJVE5lTFd0VUE/view?usp=sharing

justin3009

  • Hero Member
  • *****
  • Posts: 1658
  • Welp
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #131 on: February 29, 2016, 01:30:31 pm »
If you need help locating anything, just say the word and I'll do what I can to find whatever information you need.
'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.'

Seeeeph

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #132 on: February 29, 2016, 02:15:59 pm »
.
« Last Edit: June 01, 2016, 09:27:32 pm by Seeeeph »

RedGuy

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #133 on: March 01, 2016, 10:54:07 am »
I was able to get 90% of a gun volt to load on the map when its event is selected.  In the picture below you can see I'm missing the pieces that change.  They are propably in a separate map.  I need to locate the other sprite assembly pointers to fill in the missing pieces, load the correct palette, and get the other enemies working.  It helped to read about VRAM, OAM, and sprite assembly in order to figure it out.  After that the traces and RAM dumps started making sense.  The info in the mmx 1-3 thread from justin3009 also helped to understand how sprites work.  Thanks for that.

Thanks for the info, Seeeeph.  I thought the events of type=2 (1=background sprite?, 3=enemy) did the graphics loading, but it looks like the checkpoint structure is also important.  I'll take a look at it when I have more time.


slidelljohn

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #134 on: March 01, 2016, 12:14:00 pm »
Glad to see this is being worked on again. I have a lot of the level data figured out and documented for v1.1 ROM. Here is a little bit of code that might help you out with the sprites graphics and color palettes. I have a bunch of documents i can send you that would save you a lot of time if you are interested in them just pm me your email and next time i get a chance I will send them to you.

/*part of level data of 1st level when you start a new game*/
$85:8302                  02      type of event                02 = graphics and color palettes
$85:8303-$85:8304 80 01 X location
$85:8305                 15      ???
$85:8306                  11     graphics and color palettes  stored at 7e:1d20
$85:8307-$85:8308 C0 81 Y location                   


/*where level data for graphics and color palettes for enemies, cars... are stored in ram*/
7e:1d10-7e:1d15                                //??? maybe here too not sure
7e:1d20-7e:1d25 80 01 15 11 16 FA             
7e:1d30-7e:1d35
7e:1d40-7e:1d45
7e:1d50-7e:1d55


/*step 1 of asm code for loading new vram for enemies, cars, .....*/
$83/FE0C E2 30       SEP #$30                 
$83/FE0E A5 0B       LDA $0B    [$00:1D23]       //$7e:1d23
$83/FE10 29 0F       AND #$0F               
$83/FE12 8D 08 1F    STA $1F08  [$86:1F08]    //$7e:1F08 graphics palette pointer


/*step 2 of asm code for loading new vram for enemies, cars, .....*/
$80/B09D AD 08 1F    LDA $1F08  [$86:1F08]   
$80/B0A0 29 FF 00    AND #$00FF               
$80/B0A3 0A             ASL A                   
$80/B0A4 85 00        STA $00    [$00:0000]   
$80/B0A6 AD 7A 1F    LDA $1F7A  [$86:1F7A]     //$7e:1F7a current level
$80/B0A9 29 FF 00    AND #$00FF
$80/B0AC 0A             ASL A                   
$80/B0AD AA             TAX                     
$80/B0AE BD EE AC    LDA $ACEE,x[$86:ACEE]     //$86:ACEE start of data for each level
$80/B0B1 18            CLC                     
$80/B0B2 65 00       ADC $00    [$00:0000]   
$80/B0B4 AA            TAX                     
$80/B0B5 BD EE AC    LDA $ACEE,x[$86:AD36]     //pointer to graphics and color palettes
$80/B0B8 AA             TAX                     
$80/B0B9 E2 20        SEP #$20                 
$80/B0BB BD EE AC    LDA $ACEE,x[$86:B647]     //graphics and color palettes
$80/B0BE C9 FF         CMP #$FF                A:0939 X:0959 Y:0000 D:0000 DB:86


/*data to load for graphics and color palettes for enemies, cars... (1st set 1st level)*/
86:b647-86:b65f
39 C0 14 9C 00 50
3A C0 17
9E 00 60
3B C0 1B C0 00 70
1F 00 10 3E 00 40 FF //FF = end of data to load
 |         |   |
 |         |    --------color palette
 |          -----------location in vram to store graphics
  -------------------graphics (1F = spiky)

Seeeeph

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #135 on: March 01, 2016, 01:53:18 pm »
.
« Last Edit: June 01, 2016, 09:27:03 pm by Seeeeph »

justin3009

  • Hero Member
  • *****
  • Posts: 1658
  • Welp
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #136 on: March 01, 2016, 05:53:20 pm »
The enemies and such, if I remember correctly, are all preset for the level.  They're not all loaded at the same time but the specific VRAM setup is level specific.
'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.'

RedGuy

  • Jr. Member
  • **
  • Posts: 89
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #137 on: March 02, 2016, 01:08:36 am »
Looks like I wasn't loading the 16x16 sprites correctly.  That fixed some of the bugs with gun volt.  I must also not be ordering the tiles properly because it isn't layered quite right.  I can't find a good way to go from an enemy Id to an offset into the graphics data in the ROM to load the tiles.  Right now the gun volt offset is hardcoded to match with the gun volt Id.  The best way to do this is probably maintain VRAM by reading the checkpoint and walking through all graphics loading events up to the enemy displayed.  Then I can use the VRAM address stored with the sprite assembly to read the tiles directly.

Anyone know how the priority works for each sprite tile so they are layered properly?

Seeeeph, that mario level is pretty cool.  You can probably fix that (fish thing?) enemy graphics by adding in the all the events of type 2 before which might load it to VRAM from the original stage.

slidelljohn, I'll send you a PM.  Thanks.



slidelljohn

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #138 on: March 02, 2016, 02:47:41 am »
This shows you where the priority bit is.
http://emu-docs.org/Super%20NES/General/snesdoc.html

I'm curious do you have vsnes? If not you should get
it because it will help you out a lot with building your
sprites and setting the bits for priority, color palette,
flipping. If you don't have vsnes I can show you how
to use it if you can't figure it out.

Also if the first and second tile in oam ram have the
same priority bit set the first tile will have priority over
the second tile. You could try drawing the last tile for
each sprite first and the first tile last and that will
probably solve your priority issue.
« Last Edit: March 02, 2016, 06:22:31 am by slidelljohn »

justin3009

  • Hero Member
  • *****
  • Posts: 1658
  • Welp
    • View Profile
Re: MegaED X, the Megaman X hacking tool (Now with MMX2 support)
« Reply #139 on: March 02, 2016, 06:19:52 am »
Sprite tile priority is based on which tile is technically drawn first for them through their Sprite Assembly.
'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.'