Author Topic: the source code for SNES/SFC Myth Cart menu v0.05  (Read 53657 times)

0 Members and 1 Guest are viewing this topic.

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #120 on: May 03, 2010, 06:43:06 AM »
GG and PAR codes both do ROM and RAM. RAM codes will not work on the Myth as it is not really a GG or PAR. ROM codes work because they patch the ROM. RAM codes require special hardware that intercepts RAM reads and replaces the value with it's own value.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #121 on: May 03, 2010, 01:01:53 PM »
GG on the SNES didn't handle RAM, only the AR did (unless the info I've found is wrong).
The Myth might actually be able to do cheats that patch RAM, unless the cheat routine that gets copied to the FPGA's RAM just was an idea Neoflash had that didn't get implemented (look at run_3800 and CHEAT in neo2.asm - those are both from the original menu code and not written by me).
« Last Edit: May 03, 2010, 01:42:22 PM by mic_ »

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #122 on: May 03, 2010, 01:58:03 PM »
The SNES Myth provides sram at 0x3800 to 0x3FFF so that the menu has a way to start the game without the flash being mapped into the address space. This allows the start code to clear all the SNES RAM and hardware so the game starts clean. It doesn't take up all the sram, so there's room for patches to individual games - when a game is loaded, the code could be patched to jump to a small routine in the sram which does it's thing, then returns back to the game. I think the CHEAT code is an example of that. The loader would patch the game to jump from the correct spot to 0x3E00 to the CHEAT code, which then returns back to the game. This would have to be done by a programmer for each individual game.

Example: let's say we have a GG or PAR code that we know patches RAM. We don't have hardware to patch RAM, so what we do is look at the game in question and find it's vertical blank handler. Then we alter the exit code of the handler to jump to 0x3E00 instead. The code there would store the correct GG or PAR value to the correct place in RAM and then exit. So each and every vblank would force the RAM to the value from the cheat code. That would probably work for many games. It's just a matter of knowing where to patch the game to make the jump to the cheat code in the sram. It wouldn't necessarily need to be the vertical blank - it could be the code that reads the controller pad, or some other routine called right before the RAM in question is used.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #123 on: May 03, 2010, 02:06:47 PM »
Patching the vblank vector (or intercepting the read) is exactly how the AR worked on the SNES iirc. For GG codes you don't have to worry about that since they only target ROM. One could of course come up with new GG codes that target RAM, which would then work on the Myth or in an emulator but not on a real GG.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #124 on: May 03, 2010, 06:49:43 PM »
The NMI vector seems to be stored right before the RESET vector, i.e. at $FFFA. One could keep a small table (for 4-8 codes) that the Cheat routine goes through to patch the relevant RAM locations every frame before jumping to the original NMI vector. You could re-use the current code editing menu since AR codes are the same length as GG codes (8 bytes). The difference is that AR code don't need to be deciphered in any way, they're entered directly as BBOOOOVV (BB=bank, OOOO=offset, VV=value).
I can try doing this later unless someone else does it before me.

 

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #125 on: May 04, 2010, 11:31:07 AM »
Menu v0.22 is now available: http://jiggawatt.org/badc0de/myth_menu-0.22.zip

The biggest news in this version is that you can now use game genie codes (up to 4 of them).
Some of the controls have changed a bit from earlier versions of the menu, but I've included a readme in the zip that explains the controls for all the submenus.

Screenshot:


A video showing the game genie functionality: http://www.youtube.com/watch?v=c8ZfmludfKA


The source code is no longer available on my server. I've moved it to the same google code repository where the MD menu is hosted: http://code.google.com/p/neo-myth-menu/

Just posted it on the news page  :)

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #126 on: May 05, 2010, 04:02:54 AM »
Action Replay support has been added in the latest version: http://jiggawatt.org/badc0de/myth_menu-0.23.zip

Screenshots:


Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #127 on: May 05, 2010, 05:00:42 AM »
Action Replay support has been added in the latest version: http://jiggawatt.org/badc0de/myth_menu-0.23.zip

Screenshots:


I have just updated the main page  :D
By the way , maybe its time to open a new thread with your releases ?  :)

Offline King Of Chaos

  • Full Member
  • ***
  • Posts: 117
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #128 on: May 05, 2010, 10:20:11 AM »
Holy ****! Excellent work man, love this menu! I'm wondering though if 4 codes is the absolute limit possible? If not, 8 may be more logical (since there's room on the right side). :)
« Last Edit: May 05, 2010, 10:29:07 AM by King Of Chaos »

Offline ronaldo_76

  • Full Member
  • ***
  • Posts: 196
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #129 on: May 05, 2010, 02:38:49 PM »
great work. fantastic menĂ¼! :-*

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #130 on: May 05, 2010, 03:30:37 PM »
Holy ****! Excellent work man, love this menu! I'm wondering though if 4 codes is the absolute limit possible? If not, 8 may be more logical (since there's room on the right side). :)

You can actually have up to 8 codes now; 4 GG codes and 4 AR codes. There's no memory limitation to prevent supporting more codes though. I just capped it at 4 each because I thought "who's gonna want to do that much typing before playing a game anyway?".
One possibility for the empty space is to merge the GG and AR codes screens into one unified cheat screen, with GG codes to the left and AR codes to the right.

A feature that could be added in some future version is to have a cheat code database stored in the menu for some of the more common games. Assuming that your ROMs have good headers, the menu could then auto-detect which game you've highlighted by looking at the checksum (and possibly other header fields). By pressing a button you could then get a list of cheats for that game that you can pick from.

Offline King Of Chaos

  • Full Member
  • ***
  • Posts: 117
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #131 on: May 05, 2010, 10:02:16 PM »
You can actually have up to 8 codes now; 4 GG codes and 4 AR codes.

Yeah, I found that out and was messing with that. :P 8 GG and 8 PAR codes would be neat though which is more provided than the SNES PowerPak (only 5 Game Genie slots which doesn't support the Pro Action Replay codes). Thinking about it, if there's no limit perhaps by pressing a button it'll add a new code line to the list to add another code (which you can delete/remove by pressing another key)?

I just capped it at 4 each because I thought "who's gonna want to do that much typing before playing a game anyway?".

Me. There's some games out there with some interesting multiple codes. :P That and it'd be neat to test codes I hack on the real hardware instead of emulators.

One possibility for the empty space is to merge the GG and AR codes screens into one unified cheat screen, with GG codes to the left and AR codes to the right.

This could confuse some people - I think it's perfect as-is right now with separate menus.

A feature that could be added in some future version is to have a cheat code database stored in the menu for some of the more common games. Assuming that your ROMs have good headers, the menu could then auto-detect which game you've highlighted by looking at the checksum (and possibly other header fields). By pressing a button you could then get a list of cheats for that game that you can pick from.

I like this. How would the format be set up? There's a few databases of codes including an XML file out there, maybe it wouldn't be hard to whip a little something up to test. :P
« Last Edit: May 05, 2010, 10:07:30 PM by King Of Chaos »

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #132 on: May 05, 2010, 11:13:39 PM »
Quote
I like this. How would the format be set up? There's a few databases of codes including an XML file out there, maybe it wouldn't be hard to whip a little something up to test.

I was thinking of doing it manually since I'm talking about maybe a couple of dozen games and a few hundred codes in total.

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #133 on: May 06, 2010, 03:01:37 AM »
Here's the kind of design I had in mind:

Code: [Select]
// cheat.h

#define CODE_TYPE_AR 1
#define CODE_TYPE_GG 2

typedef struct
{
char *codes;
char *description;
u8 codeType;
} cheat_t;


typedef struct
{
u16 romChecksum;
u16 romChecksumCompl;
cheat_t const **cheats;
} cheatDbEntry_t;


// super_mario_world.c

const cheat_t super_mario_world_cheats[] =
{
{"7E0F3099", "Fast timer", CODE_TYPE_AR},
{"7E0DBF63", "Infinite coins", CODE_TYPE_AR},
{"7E0DAA80", "Can\'t jump", CODE_TYPE_AR},
{"7E0DC101", "Always have Yoshi", CODE_TYPE_AR},
{"009E2562", "Start with 99 lives", CODE_TYPE_AR},
{"008E2888", "Timer doesn't count down", CODE_TYPE_AR},
{"009E35E6", "Start as Super Mario", CODE_TYPE_AR},
{"00D0B6A9", "Keep powerups when you fall and die", CODE_TYPE_AR},
{"3E2CAF6F", "Unlimited jumps", CODE_TYPE_GG},
{"DDB46F07", "Start with 1 life", CODE_TYPE_GG},
{"D6B46F07", "Start with 9 lives", CODE_TYPE_GG},
{"D02CAF6F", "Low jump", CODE_TYPE_GG},
{"D42CAF6F", "Super jump", CODE_TYPE_GG},
{"DF2CAF6F", "Mega jump", CODE_TYPE_GG},
{"CBB76D67D4B76DA73CB76FD769B76F07", "Start as Caped Mario", CODE_TYPE_GG},
{"DFCE64A0", "Little Yoshi grows into big Yoshi after eating 1 enemy", CODE_TYPE_GG}
};



// cheat_database.c

extern const cheat_t super_mario_world_cheats[];

const cheatDbEntry_t cheatDatabase[] =
{
{0xC536, 0x3AC9, super_mario_world_cheats}, // (E) (V1.1) [!]
{0xA0DA, 0x5F25, super_mario_world_cheats}, // (U) [!]
};

Note: This is not something I've tried compiling. I'm just giving you an idea of how a simple cheat database could be represented.

Each game would have its own C file with an array of cheats. And then cheatDatabase[] would keep a pointer to those arrays along with the ROM's checksum to be used for identification.
A cheat that require multiple codes would just store all the codes in one long sequence, as with the "Start as Caped Mario" cheat.
« Last Edit: May 06, 2010, 03:03:11 AM by mic_ »

Offline King Of Chaos

  • Full Member
  • ***
  • Posts: 117
Re: the source code for SNES/SFC Myth Cart menu v0.05
« Reply #134 on: May 06, 2010, 04:05:17 AM »
That'd work for me. Super Mario World and Super Metroid are basically the few worthy ones anyways. :P Here's some of my favorites for Super Mario World...

"7E1497FF","Invincibility (Walk Though Enemies)"
"7E1490FF","Invincibility (Starman Effect)"
"89E4-AFD9+89C6-D4DB","Invincibility (Yoshi)"
"C2EC-0700","Infinite flying time for Yoshi"
"C222-D4DD","Infinite lives"
"7E001900","Always Small Mario"
"7E001901","Always Big Mario"
"7E001902","Always Cape Mario"
"7E001903","Always Fire Mario"
"DDC1-64DD+DDC5-6DAD","Nintendo's Debug"
"DDA6-DF07","Nintendo's Debug 2"
« Last Edit: May 06, 2010, 04:19:04 AM by King Of Chaos »