Author Topic: Looking into the possibility of a menu editor.  (Read 4323 times)

inuksuk

  • Earthbound (+15)
  • *
  • Posts: 43
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #15 on: January 31, 2025, 01:19:45 am »
Looks like you've made some good progress! I think I'm understanding a little of what I'm seeing.

How is user input handled by the menu? I think I can tell which commands are loading text and graphics packets. I don't see how the draw routines flow together, though. For example in the Equip menu, how does the flow work for calling the equipment selection and item selection draw routines?

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1801
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Looking into the possibility of a menu editor.
« Reply #16 on: January 31, 2025, 01:25:53 pm »
That's largely handled by code, making it a pain to add to a simple plugin.

Zakyrus

  • Entity
  • Magical Dreamer (+1250)
  • *
  • Posts: 1413
  • ...is trying to become a better MAN, and demi-god!
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #17 on: February 05, 2025, 01:12:47 pm »
But...however, basic code, not extra algorithms uneeded!


Code: [Select]

#include <iostream>
#include <fstream>
#include <vector>
#include <iomanip>  // For formatting hex output

using namespace std;

// Function to display a portion of the ROM file in hexadecimal
void displayHex(const vector<unsigned char>& romData, size_t start, size_t length) {
    for (size_t i = start; i < start + length && i < romData.size(); ++i) {
        cout << hex << setw(2) << setfill('0') << (int)romData[i] << " ";
        if ((i - start + 1) % 16 == 0) {
            cout << endl;
        }
    }
    cout << endl;
}

// Function to load the ROM file into memory
vector<unsigned char> loadROM(const string& filename) {
    ifstream file(filename, ios::binary | ios::ate);
    if (!file.is_open()) {
        cerr << "Error opening file!" << endl;
        exit(1);
    }

    size_t size = file.tellg();
    file.seekg(0, ios::beg);
    vector<unsigned char> romData(size);
    file.read(reinterpret_cast<char*>(romData.data()), size);
    file.close();

    return romData;
}

// Function to save the modified ROM data back to the file
void saveROM(const string& filename, const vector<unsigned char>& romData) {
    ofstream file(filename, ios::binary);
    if (!file.is_open()) {
        cerr << "Error saving file!" << endl;
        exit(1);
    }

    file.write(reinterpret_cast<const char*>(romData.data()), romData.size());
    file.close();
}

// Function to edit a byte at a specific location in the ROM data
void editByte(vector<unsigned char>& romData, size_t index, unsigned char newValue) {
    if (index >= romData.size()) {
        cerr << "Invalid index!" << endl;
        exit(1);
    }
    romData[index] = newValue;
}

int main() {
    string romFile = "yourfile.rom";  // Replace with your ROM file path
    vector<unsigned char> romData = loadROM(romFile);

    size_t startAddress = 0x1000;  // Example starting address for display
    size_t length = 64;  // Display length in bytes
    cout << "Displaying ROM data starting from address 0x" << hex << startAddress << ":" << endl;
    displayHex(romData, startAddress, length);

    // Ask user for byte to modify
    size_t indexToEdit;
    cout << "Enter the index (in decimal) of the byte you want to edit: ";
    cin >> indexToEdit;
    unsigned char newHexValue;
    cout << "Enter the new value (in hex, e.g., 0xAA): ";
    cin >> hex >> newHexValue;  // Input in hexadecimal format

    // Edit the byte at the specified index
    editByte(romData, indexToEdit, newHexValue);

    // Save the modified ROM back to the file
    saveROM(romFile, romData);

    cout << "ROM modified and saved successfully!" << endl;

    return 0;
}

~Z

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1801
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Looking into the possibility of a menu editor.
« Reply #18 on: February 06, 2025, 03:14:02 pm »
I've seen that code posted elsewhere, it's less effective than what I currently have, and addresses none of my issues with adding save functionality.

Please, just look at the current state of the plugin and tell me what you think about how useful it is.

Zakyrus

  • Entity
  • Magical Dreamer (+1250)
  • *
  • Posts: 1413
  • ...is trying to become a better MAN, and demi-god!
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #19 on: February 06, 2025, 06:08:34 pm »
Very USEFUL. We need save, lol.

I would love to have a COLORED ICON like " item_00 {sword} Wood Sword " (but have the {sword} colored 'brown' for item_00...



That makes sense, right?

Also, I would love to have 1-string windows or 8 DECISION_TEXT_BOX windows, based in EVENTS(check_RESULT) in theory would already work well...

1-line box:
"         TYRANO LAIR KEEP       "(delay 0A)(delay00)"
Used for walking into significant locations in the game...
How could this be done with this plugin?

~Z
« Last Edit: February 06, 2025, 06:12:12 pm by Zakyrus »

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1801
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Looking into the possibility of a menu editor.
« Reply #20 on: February 07, 2025, 03:21:09 pm »
Colored Icons: You'll probably run into palette limitations for the menu pretty quickly.

Events: Out of scope for this plugin.

Location names: Out of scope for this plugin.

Zakyrus

  • Entity
  • Magical Dreamer (+1250)
  • *
  • Posts: 1413
  • ...is trying to become a better MAN, and demi-god!
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #21 on: February 08, 2025, 01:39:34 pm »
Colored Icons: You'll probably run into palette limitations for the menu pretty quickly.

Events: Out of scope for this plugin.

Location names: Out of scope for this plugin.

This is good though!! These are the features "generally" people might want, and ROMHACKING is *for the sake of ART, going to figure this sh*t out someday anyways! Right,? Right! So when it comes to future expanded features, --if AT THE VERY LEAST these are capabilities we can add, outside of the 'normal usage of the editor' then that'd be fantastic!


It really can't be hard to make binary data do what we want, right?

:D

~Z

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1801
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Looking into the possibility of a menu editor.
« Reply #22 on: February 08, 2025, 10:29:55 pm »
There's a lot of things people might want, and not enough people coding these things. This will be time consuming, and there are other things I could develop first.

If you're focusing on what event commands can do, I can either assume this plugin isn't that useful to you, or you just haven't tested it.

Quote
It really can't be hard to make binary data do what we want, right?
It really can.

justin3009

  • Fan Project Leader
  • God of War (+3000)
  • *
  • Posts: 3297
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #23 on: February 09, 2025, 09:28:58 am »
Quote
It really can't be hard to make binary data do what we want, right?

It is way more difficult than one could imagine sometimes. It's honestly surprising at how something that seems basic on the front is actually horrifically convoluted and/or complicated behind the scenes.

Zakyrus

  • Entity
  • Magical Dreamer (+1250)
  • *
  • Posts: 1413
  • ...is trying to become a better MAN, and demi-god!
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #24 on: February 09, 2025, 02:37:50 pm »
There's a lot of things people might want, and not enough people coding these things. This will be time consuming, and there are other things I could develop first.

If you're focusing on what event commands can do, I can either assume this plugin isn't that useful to you, or you just haven't tested it.

Quote
It really can't be hard to make binary data do what we want, right?
It really can.

I'm weird. I have to test it realtime if it can save/load, lol. No offense.

~Z

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1801
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Looking into the possibility of a menu editor.
« Reply #25 on: February 09, 2025, 04:27:54 pm »
Quote
It really can't be hard to make binary data do what we want, right?

It is way more difficult than one could imagine sometimes. It's honestly surprising at how something that seems basic on the front is actually horrifically convoluted and/or complicated behind the scenes.
Yeah, this one is a pain because it's got an extra level of pointers, and most of the original pointers are scattered throughout the ROM, not in a nice table.

Quote
I'm weird. I have to test it realtime if it can save/load, lol. No offense.

Fair enough, I'll probably do some more later. Got another project catching my interest at the moment.

DemiFiend

  • Iokan (+1)
  • *
  • Posts: 2
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #26 on: February 10, 2025, 01:31:12 pm »
I'm looking "ATB main menu", guess this would be my primary interest. Being able to modify the length/size of individual boxes, maybe add custom elements later on when I'm more familiar with the format. As a whole my impression is, this is definitely on a more advanced level than other TF functions. IOW, learning curve. It'll take a while. But it does seem promising.

Zakyrus

  • Entity
  • Magical Dreamer (+1250)
  • *
  • Posts: 1413
  • ...is trying to become a better MAN, and demi-god!
    • View Profile
Re: Looking into the possibility of a menu editor.
« Reply #27 on: February 10, 2025, 04:46:19 pm »
Yeah, this one is a pain because it's got an extra level of pointers, and most of the original pointers are scattered throughout the ROM, not in a nice table.

Most "SuperSnes ROMS" being super compact, there might be an underlying algorithm to this, I will keep searching for it's "key" as well...

I'm looking "ATB main menu", guess this would be my primary interest. Being able to modify the length/size of individual boxes, maybe add custom elements later on when I'm more familiar with the format. As a whole my impression is, this is definitely on a more advanced level than other TF functions. IOW, learning curve. It'll take a while. But it does seem promising.

Start simple, make the ATB go "RAINBOW" when it's full for 4 seconds. Try stuff like that. Keep it simple. (Z asks 'too MUCH' at times, to try to further the ART).

~Z

Mauron

  • Guru of Reason Emeritus
  • Errare Explorer (+1500)
  • *
  • Posts: 1801
  • Nu-chan
    • View Profile
    • Hi trig!
Re: Looking into the possibility of a menu editor.
« Reply #28 on: February 11, 2025, 03:15:05 pm »
I'm looking "ATB main menu", guess this would be my primary interest. Being able to modify the length/size of individual boxes, maybe add custom elements later on when I'm more familiar with the format. As a whole my impression is, this is definitely on a more advanced level than other TF functions. IOW, learning curve. It'll take a while. But it does seem promising.
Thanks for the input.

Most "SuperSnes ROMS" being super compact, there might be an underlying algorithm to this, I will keep searching for it's "key" as well...
It's not a mystery, pointers are just loaded through code instead of in a table by index. It does make loading them more complex.

Start simple, make the ATB go "RAINBOW" when it's full for 4 seconds. Try stuff like that. Keep it simple. (Z asks 'too MUCH' at times, to try to further the ART).

~Z

That is NOT simple.