Hack Ninja Gaiden Arcade (original 1988) for MAME

Started by fhrans, November 23, 2021, 06:50:38 AM

Previous topic - Next topic

fhrans

#40
Yes, I know how to run MAME in debugger mode.
So for example if I wanted to change Ryu Hayabusa's clothes to yellow, would I just change that code and save?
I also knew the way to see the tiles and the palettes with F4, in fact, I have saved the palettes, but how can I apply them to make changes in the code according to the way you tell me?

February 05, 2022, 04:39:33 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

Ok, now I opened MAME in debugger mode and exported gaidenprg.bin.

https://ibb.co/gTZQYjF

What hex editor do you advise me to edit it?
Until I start the C++ classes, could you create the program or code for me to de-interleave the files? You would do me a great favor.
I have already opened the memory window and found the value 078000 but it is not clear to me if it can be edited from the MAME Debugger itself or if I have to do it from the exported gaidenprg.bin file. Because then, what is the point of finding that value in MAME Debugger if we then edit it from a hex editor?

MottZilla

If you type in different values at the 78000-79fff range in the memory viewer it may change the colors, it depends on both how the game is programmed and how MAME works. I haven't tried it. But if you look at the values in the range and look at what I already told you about how each 16-bit value relates to Red, Green, and Blue color values you could probably find Ryu's palette. Then you'd just search the program ROM for that string of values in a Hex Editor. If you find it, then you can modify it and see what happens.

I like the Hex Editor called HxD.


int main()
{

fEven = fopen("EvenGFX.bin","rb");
fOdd = fopen("OddGFX.bin","rb");
fOut = fopen("OutGFX.bin","wb");

if(fEven == NULL || fOdd == NULL || fOut == NULL)
{
   printf("Error");
   return 0;
}

for(int n=0;n<0x80000;n++)
{
  fputc(fgetc(fEven),fOut);
  fputc(fgetc(fOdd),fOut);
}

fclose(fEven);
fclose(fOdd);
fclose(fOut);

printf("Done");

}


Three files are opened. The ones with "rb" are being Read. The one with "wb" is being written. In this program you're interleaving the Even and Odd together. That's why in the loop which starts with "for(int n=0;n<0x80000;n++)" you see it is reading a byte from the even file and putting that in the output file, then reading a byte from the Odd file and putting that in the output file.

To reverse this you'd instead open two files from writing and one for reading. You would read a byte from your interleaved file and write to your Even output file. Then read another from the interleaved file, and write to the Odd output file. Pretty simple.

To change the palette data you'll be editing the values in the "gaidenprg.bin". You can maybe edit them in MAME but for permanent changes you need to edit the rom.

fhrans

I don't know how to look at the exact values of his 16 palette colors in RAM in MAME Debugger to find Ryu's palette.
For example, one of the hexadecimal color codes for Ryu's clothing is bbbbee but I don't know how it is expressed in the MAME memory window.
https://ibb.co/YLbFRVT

I also downloaded the HxD program and opened the gaidenprg.bin file that I exported in MAME Debugger earlier but when searching for the value 78000 for example, it doesn't find it.
https://ibb.co/RHgJdBs

MottZilla

You misunderstand, $78000 is the address in the hardware where palette RAM is located. If you point a Memory Viewer to that address by typing 78000 into the white box and press enter it will seek to there. The Blue Ninja is actually the very first palette when the game is running and the Red Ninja is the second palette. The values for his Blue Ninja palette are:

0000.0FFF.0040.0633.0855.0A77.0C99.0EBB.0008.000B.007F.0358.09BD.057A.0BDF.079C

Unfortunately I didn't find this string of bytes in ROM like that, which means changing the palette would take more research to do it. Using the MAME debugger you can find there is a function around $11C0 which tends to do all the writing to Palette RAM and it seems to source the data from WorkRAM rather than ROM. So the values in ROM are loaded into WorkRAM before they get sent to Palette RAM.

If you search for only part of the string like 09BD.057A.0BDF.079C you will find a match. I did not try modifying it to see if it is part of palette data in rom.

Edit: I did try changing the values and they did not appear to change anything. Most likely changing the palette in the game is going to require you to learn how to use the debugger and gain some understanding of 68000 assembly language. Sorry it's not an easy game to tackle.

fhrans

#44
Wow, I know it's hard and I really appreciate your help and patience, but I'm really looking forward to hacking this game, even if it's just changing the color of Ryu's clothes.  :)
Could you guide me in the process even if it is complicated to achieve it?
I will follow the steps you tell me.

February 08, 2022, 09:22:45 AM - (Auto Merged - Double Posts are not allowed before 7 days.)

Can the information in this file be of any use to us?
https://we.tl/t-FkLFuTpF0s
I downloaded it from this website:
http://adb.arcadeitalia.net/dettaglio_mame.php?game_name=gaiden

Jorpho

Quote from: fhrans on February 08, 2022, 04:47:23 AMCould you guide me in the process even if it is complicated to achieve it?
I will follow the steps you tell me.
Sooner or later you're going to have to figure out some of these things on your own.

QuoteCan the information in this file be of any use to us?
Isn't that the MAME source code? That was already referenced on the first page of the thread.

Quote from: MottZilla on January 23, 2022, 08:22:12 PM
Ninja Gaiden's sprite graphics are 4bpp. The data for sprites is stored on multiple 8-bit ROMs. You're going to need to combine these ROMs to see more than 2bpp. From MAME's source code:
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

fhrans

#46
My idea is to learn but I wanted to motivate myself by getting something simple first, like changing the color of her clothes but apparently it's not as simple as changing a code and that's it.
You are right, I already named the file gaiden.cpp. I wrote in many forums and I no longer remember if I had named it in this one.
The truth is that only in this forum I found interesting answers.
So, what steps do you advise me to follow?
How can I get to hack the game?
Learn C++
Learn how the MAME Debugger works
Learn 68000 assembly language
Correct?

February 08, 2022, 05:37:18 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

I found these videos:
https://www.youtube.com/watch?v=NGibh6uPKRA&t=186s
https://www.youtube.com/watch?v=jP-j4F-X9RM
https://www.youtube.com/watch?v=h6PiYtlv7qA
https://www.youtube.com/watch?v=yasHR7F9oBU&t=22s
https://www.youtube.com/watch?v=qbsJI2F1fjs&t=20s
https://www.youtube.com/watch?v=bIl5hgVB4JE&t=569s
https://www.youtube.com/watch?v=p-Wa8TMd2jI&t=392s
https://www.youtube.com/watch?v=5kYBgawhXJA&t=184s
https://www.youtube.com/watch?v=RPEKtR9xeCo&t=21s

MottZilla

Learning 68000 assembly language will help you understand what is going on when using the MAME debugger in Ninja Gaiden and other games using the 68000 processor. You don't need to be an expert, you just need to be familiar with it enough to figure out what is going on. Then learning about how you can use the MAME debugger will be more helpful.

Learning C++ is fine, but it doesn't have to be that. You could learn any programming language that would allow you to make programs to run on your computer. The reason you'd want to be able to do this is then these basic data manipulation tasks are something you can program yourself.

Yes, looking at the MAME source code for the "gaiden" driver can give you a lot of information if you know what you're looking at. But it won't tell you everything.

As I stated earlier, I did briefly look into seeing if the palette data loaded into palette RAM was present in ROM as-is and it was not. The data appears to get written to WorkRAM at some point which is then transferred to palette RAM by a function located near the beginning of progrom rom. So you'd probably want to seek out the part where the palette data gets placed into WorkRAM and see where those values are loaded from. This is something the MAME debugger can help you do.

fhrans

Download a 68000 assembly language manual. Due to my lack of programming knowledge, I see it as somewhat complicated.
https://ruidera.uclm.es/xmlui/bitstream/handle/10578/42/A_%20hardware_software_68000.pdf?sequence=1&isAllowed=y

To rule out alternatives, is it possible to modify the palette from Tile Molester and have it be modified in the ROM once you save it, or does the Tile Molester palette only serve to see the sprites with the correct colors and thus facilitate the location of the sprites?

Jorpho

Quote from: fhrans on February 10, 2022, 02:47:55 AMDue to my lack of programming knowledge, I see it as somewhat complicated.
So learn to program! I agree that 68000 assembly language might not be the best place to start if you've never, ever programmed before. (Even C++ might be a bit much.) You have already been provided some excellent resources.

Quoteis it possible to modify the palette from Tile Molester and have it be modified in the ROM once you save it, or does the Tile Molester palette only serve to see the sprites with the correct colors and thus facilitate the location of the sprites?
If it was possible to modify the palette in ROM using Tile Molester, then someone would have suggested that already.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

fhrans

Ok, as you advised me, a good start would be with BlitzPlus.

I have contacted the person who has the channel arcade-cabinets.com and he told me that this video can help me:
https://www.youtube.com/watch?v=Rmd-tjT7Qvw

MottZilla

That video is not going to help you with Ninja Gaiden. That video looks to be talking about much more simple hardware.

As I said before the Ninja Gaiden palette data is located somewhere in the Program ROM and gets written to WorkRAM before later being copied into Palette RAM. You'll have to figure out how this all happens and you can work backwards and by using the MAME debugger you may be able to discover where in ROM the data is located.

BlitzPlus would be one options for learning how to do some programming and would help you with making simple programs for manipulating the ROM data as needed.

fhrans

#52
In MAME Debugger the colors of the palette change but, I understand that there is no way to export the ROM saving the edited changes in the Memory window.
https://we.tl/t-JcLnHmjpnA
You commented that you only found a snippet of the palette's code chain and didn't change anything by modifying it.
I don't know where to look to find out how this process happens, I've looked on Google but I can't find anything.

February 15, 2022, 04:12:34 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

Can this website help to find the palette in the ROM?
https://web.archive.org/web/20161106154933/http://letshackarcadegames.com/?p=407