Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,558,822
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 05-08-24 03:35 AM
Guest: Register | Login

0 users currently in ROM Hacking | 3 guests | 1 bot

Main - ROM Hacking - Programming question New thread | New reply


H4ck3r
Posted on 10-13-11 03:56 PM Link | Quote | ID: 147990


Red Paragoomba
Level: 17

Posts: 33/50
EXP: 24283
Next: 460

Since: 06-08-11
From: The Netherlands

Last post: 3745 days
Last view: 2427 days
Hi everyone!
Previous week, i started programming a sma4 level viewer, which i have released ( it can be found here: http://code.google.com/p/super-mario-advance-4-level-editor/downloads/list). Now i have a problem and i don't know if you guy's wanna help me but alright. The problem is, how do i program my editor so, that it can edit the sma4 levels? Not something like Lunar Magic, but like hex. It's not that i am lazy or something, but i just can't figure it out. If anyone could help me, i would realy
appreciate it.

____________________



Jack in, Megaman! Power up!

NightKev
Posted on 10-13-11 04:15 PM Link | Quote | ID: 147991


Cape Luigi
Level: 131

Posts: 4698/4792
EXP: 26254550
Next: 170070

Since: 03-15-07

Last post: 3746 days
Last view: 3658 days
Perhaps you missed the already existing thread for this? I believe someone has already made substantial progress on a SMA4 editor, you should talk to him.

____________________

H4ck3r
Posted on 10-13-11 04:25 PM Link | Quote | ID: 147992


Red Paragoomba
Level: 17

Posts: 34/50
EXP: 24283
Next: 460

Since: 06-08-11
From: The Netherlands

Last post: 3745 days
Last view: 2427 days
Posted by NightKev
Perhaps you missed the already existing thread for this? I believe someone has already made substantial progress on a SMA4 editor, you should talk to him.

I know there is a SMA4 editor thread, and i asked them, via PM and via the thread itself, but i am not getting any reply, so that's why i ask it here.

____________________



Jack in, Megaman! Power up!

Stifu
Posted on 10-13-11 08:48 PM Link | Quote | ID: 147996


Cobrat
Level: 56

Posts: 360/666
EXP: 1362561
Next: 35615

Since: 02-22-07

Last post: 697 days
Last view: 319 days
Posted by H4ck3r
The problem is, how do i program my editor so, that it can edit the sma4 levels? Not something like Lunar Magic, but like hex. It's not that i am lazy or something, but i just can't figure it out.

When you load your ROM with your editor, you probably keep a byte array in memory that represents the content of the ROM file, right? If not, you should.
Then all you have to do is change some of these byte values, then create a new ROM file from this modified byte array.

What I do in my editor:
- Load the ROM file into a byte array (buffer), and keep it in memory (don't discard it, so you don't have to reload the ROM again later)
- Create various objects from reading this byte array (stages, tiles, enemies, etc)
- When the user modifies something, the objects are modified, but not the byte array (not yet)
- When the user saves, the values of all of the objects are used to update the byte array
- Just create a new file from the updated byte array

H4ck3r
Posted on 10-14-11 03:53 PM (rev. 3 of 10-14-11 03:59 PM) Link | Quote | ID: 148012


Red Paragoomba
Level: 17

Posts: 35/50
EXP: 24283
Next: 460

Since: 06-08-11
From: The Netherlands

Last post: 3745 days
Last view: 2427 days
Posted by Stifu
Posted by H4ck3r
The problem is, how do i program my editor so, that it can edit the sma4 levels? Not something like Lunar Magic, but like hex. It's not that i am lazy or something, but i just can't figure it out.

When you load your ROM with your editor, you probably keep a byte array in memory that represents the content of the ROM file, right? If not, you should.
Then all you have to do is change some of these byte values, then create a new ROM file from this modified byte array.

What I do in my editor:
- Load the ROM file into a byte array (buffer), and keep it in memory (don't discard it, so you don't have to reload the ROM again later)
- Create various objects from reading this byte array (stages, tiles, enemies, etc)
- When the user modifies something, the objects are modified, but not the byte array (not yet)
- When the user saves, the values of all of the objects are used to update the byte array
- Just create a new file from the updated byte array

Thank you for this helpfull info, Stifu!
Oh, and if i want that the editor ONLY opens SMA4, do i need to program that if the rom has that and that info, he only opens that? Am i right?

EDIT:
My editor ONLY show's an object list from SMA4 without opening the actual rom, but i think that if i know this, i will also be able to let it show a real object list when i know this. Oh, and is it possible to make a SMA4 editor ( that edit sma4 via hex ) in batch?

____________________



Jack in, Megaman! Power up!

Kawa
Posted on 10-14-11 06:30 PM Link | Quote | ID: 148013


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 5217/5344
EXP: 30973695
Next: 689286

Since: 02-20-07
From: The Netherlands

Last post: 4510 days
Last view: 2645 days
Posted by H4ck3r
Oh, and is it possible to make a SMA4 editor ( that edit sma4 via hex ) in batch?
You've got to be kidding me.

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

H4ck3r
Posted on 10-14-11 07:46 PM Link | Quote | ID: 148014


Red Paragoomba
Level: 17

Posts: 36/50
EXP: 24283
Next: 460

Since: 06-08-11
From: The Netherlands

Last post: 3745 days
Last view: 2427 days
Posted by Kawa
Posted by H4ck3r
Oh, and is it possible to make a SMA4 editor ( that edit sma4 via hex ) in batch?
You've got to be kidding me.

Just as i thought.
I am gonna write version 2 ( and the newer version's ) of my editor's in C.

____________________



Jack in, Megaman! Power up!

Stifu
Posted on 10-14-11 08:15 PM (rev. 2 of 10-14-11 08:17 PM) Link | Quote | ID: 148016


Cobrat
Level: 56

Posts: 361/666
EXP: 1362561
Next: 35615

Since: 02-22-07

Last post: 697 days
Last view: 319 days
Posted by H4ck3r
Oh, and if i want that the editor ONLY opens SMA4, do i need to program that if the rom has that and that info, he only opens that? Am i right?

Yes. You check some values to ensure you're about to open a correct ROM.
For example, check my code. I have a ValidateRom() method which calls 2 sub methods, IsSnesRom() and IsSuperMarioKart().

Posted by H4ck3r
Oh, and is it possible to make a SMA4 editor ( that edit sma4 via hex ) in batch?

What do you mean "in batch", exactly? Have one or more batches act as an editor? Sounds bad.
By the way, you'll end up understanding "via hex" doesn't actually make sense. You relate to hex editors because you've used them to edit ROMs, but hexa decimal is just a way to display / format data. You handle bytes, it doesn't matter on which base (bit, decimal, hex, nibble, whatever) you read or edit them, it's all the same in the end. Depending on the context, you may want to handle the data on a different base.

Kawa
Posted on 10-14-11 08:18 PM Link | Quote | ID: 148017


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 5218/5344
EXP: 30973695
Next: 689286

Since: 02-20-07
From: The Netherlands

Last post: 4510 days
Last view: 2645 days
Posted by Stifu
Depending on the context, you may want to handle the data on a different base.
For example, in my editors I display and edit coordinates in decimal, but have script pointers in hex.

Also, Stifu: batch = .bat files.

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

Stifu
Posted on 10-14-11 08:24 PM Link | Quote | ID: 148018


Cobrat
Level: 56

Posts: 362/666
EXP: 1362561
Next: 35615

Since: 02-22-07

Last post: 697 days
Last view: 319 days
Posted by Kawa
Also, Stifu: batch = .bat files.

Yeah, I know, but I couldn't really figure how it'd work. Like, the user would be supposed to pass parameters to the batch to define what he wants to change, or something?

Kawa
Posted on 10-14-11 08:47 PM Link | Quote | ID: 148019


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 5219/5344
EXP: 30973695
Next: 689286

Since: 02-20-07
From: The Netherlands

Last post: 4510 days
Last view: 2645 days
Batch files can't handle files on the required level on their own, I think.

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

H4ck3r
Posted on 10-14-11 10:21 PM Link | Quote | ID: 148020


Red Paragoomba
Level: 17

Posts: 37/50
EXP: 24283
Next: 460

Since: 06-08-11
From: The Netherlands

Last post: 3745 days
Last view: 2427 days
Posted by Stifu
Posted by H4ck3r
Oh, and if i want that the editor ONLY opens SMA4, do i need to program that if the rom has that and that info, he only opens that? Am i right?

Yes. You check some values to ensure you're about to open a correct ROM.
For example, check my code. I have a ValidateRom() method which calls 2 sub methods, IsSnesRom() and IsSuperMarioKart().

Posted by H4ck3r
Oh, and is it possible to make a SMA4 editor ( that edit sma4 via hex ) in batch?

What do you mean "in batch", exactly? Have one or more batches act as an editor? Sounds bad.
By the way, you'll end up understanding "via hex" doesn't actually make sense. You relate to hex editors because you've used them to edit ROMs, but hexa decimal is just a way to display / format data. You handle bytes, it doesn't matter on which base (bit, decimal, hex, nibble, whatever) you read or edit them, it's all the same in the end. Depending on the context, you may want to handle the data on a different base.

I think i get it now.
So if i want it to open SMA4 i type this in my code: ValidateRom() IsGbaRom() IsSuperMarioAdvance4(). Am i right?

____________________



Jack in, Megaman! Power up!

Stifu
Posted on 10-14-11 10:54 PM Link | Quote | ID: 148021


Cobrat
Level: 56

Posts: 363/666
EXP: 1362561
Next: 35615

Since: 02-22-07

Last post: 697 days
Last view: 319 days
Posted by H4ck3r
So if i want it to open SMA4 i type this in my code: ValidateRom() IsGbaRom() IsSuperMarioAdvance4(). Am i right?

That's the idea, but you'll have to implement each of these methods, of course, it's not magic. And you do not have to do it exactly like me.
(Not to mention C# naming conventions are different from C ones.)

H4ck3r
Posted on 10-15-11 09:49 AM Link | Quote | ID: 148027


Red Paragoomba
Level: 17

Posts: 38/50
EXP: 24283
Next: 460

Since: 06-08-11
From: The Netherlands

Last post: 3745 days
Last view: 2427 days
Posted by Stifu
Posted by H4ck3r
So if i want it to open SMA4 i type this in my code: ValidateRom() IsGbaRom() IsSuperMarioAdvance4(). Am i right?

That's the idea, but you'll have to implement each of these methods, of course, it's not magic. And you do not have to do it exactly like me.
(Not to mention C# naming conventions are different from C ones.)

Ok, so now i need to find a way to "play" with the bytes?

____________________



Jack in, Megaman! Power up!

Stifu
Posted on 10-15-11 11:18 AM Link | Quote | ID: 148028


Cobrat
Level: 56

Posts: 364/666
EXP: 1362561
Next: 35615

Since: 02-22-07

Last post: 697 days
Last view: 319 days
You just read certain bytes and create objects from the values you read.
To find out which bytes you want to read/write, you basically have 2 options: find out where index tables / offsets are defined in the ROM (so you can dynamically retrieve offsets), or hard-code offsets. You should try to go for the first option as much as possible, to ensure your editor is flexible and behaves closer to how the game runs.

Example: in the ROM, you have some kind of master index that defines the location of each stage in the ROM (no idea whether that's true for SMA4, just an example). You retrieve these offsets from the ROM, and then loop through each stage data to load them all. Or only load them one by one, on demand, because it might not be optimal to load them all at once (depending on your needs).

So... Got documentation on SMA4 that gives you some of the offsets you need? That'd be a good starting point.

Kawa
Posted on 10-15-11 02:45 PM Link | Quote | ID: 148032


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 5221/5344
EXP: 30973695
Next: 689286

Since: 02-20-07
From: The Netherlands

Last post: 4510 days
Last view: 2645 days
Ik heb zo'n donkerbruin vermoeden dat H4ck3r geen flauw benul heeft van wat -ie moet doen.

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

Stifu
Posted on 10-15-11 03:12 PM Link | Quote | ID: 148034


Cobrat
Level: 56

Posts: 365/666
EXP: 1362561
Next: 35615

Since: 02-22-07

Last post: 697 days
Last view: 319 days
Possibly. Gotta start somewhere.

To sum things up: making an editor is just the act of automating things you'd be able to do manually (through a hex editor, for example). If you couldn't do what you want manually, learn how to do that first.

H4ck3r
Posted on 10-15-11 10:43 PM Link | Quote | ID: 148039


Red Paragoomba
Level: 17

Posts: 39/50
EXP: 24283
Next: 460

Since: 06-08-11
From: The Netherlands

Last post: 3745 days
Last view: 2427 days
Posted by Kawa
Ik heb zo'n donkerbruin vermoeden dat H4ck3r geen flauw benul heeft van wat -ie moet doen.

Ik ben op dit moment C# aan het leren, zodat ik ( hopelijk ) op een dag in staat ben om een goedwerkende SMA4 editor te programeren

Ontopic: Ik kan er wel wat dingen uit opmaken van wat Stifu zegt, ik kan namelijk al een ( beetje ) Hex, dus als iemand ( bijvoorbeeld ) praat over offset's, of adressen, weet ik wel een beetje wat het betekent.

____________________



Jack in, Megaman! Power up!

Kawa
Posted on 10-16-11 02:21 PM Link | Quote | ID: 148049


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 5226/5344
EXP: 30973695
Next: 689286

Since: 02-20-07
From: The Netherlands

Last post: 4510 days
Last view: 2645 days
Protip: gebruik een BinaryWriter/Reader. Dan kan je tenminste de meeste standaard gegevenstypen lezen (bijv. Int16 en 32), plus de enkele bytes en reeksen van bytes die je met louter File.Open krijgt.

Maar gebruik 't niet voor strings -- BinaryWriter.ReadString verwacht dat "HELLO WORLD" opgeslagen is als "\x0BHELLO WORLD", dus met de lengte ervoor, terwijl de meeste strings in ROMs opgeslagen zijn met een vaste lengte of in C-stijl met Null terminators; "HELLO WORLD\0".



Bonus achtergrond uitleg: wat als je een string van meer dan 256 tekens wilt opslaan? De lengte van de string is een variabele-lengte waarde, net als MIDI deltatijden en UTF-8. Het slaat dus eigenlijk al toe bij strings van 128 tekens of meer. Maar in de context van ROM hacking moet je vooral niet BinaryReader/Writer gebruiken voor strings, dus maakt dat niet zoveel uit. Ik kan desnoods wel een functie voor je schrijven die C-stijl strings mogelijk maakt...

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

Main - ROM Hacking - Programming question New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.142 seconds. (339KB of memory used)
MySQL - queries: 105, rows: 144/147, time: 0.125 seconds.