News: 11 March 2016 - Forum Rules

Author Topic: Hack Ninja Gaiden Arcade (original 1988) for MAME  (Read 7950 times)

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #20 on: January 25, 2022, 04:14:04 pm »
It does exactly what was said: each line combines four different files into one larger file. (What did you think it did?)
Okay, I had not read the second part well, that once the odd and even files were combined, the resulting files had to be interleaved.

Look at the picture that was posted earlier. It has vertical lines running through it because half the bytes have to come from a different file. That's what interleaving fixes.
After interleaving the EvenGFX.Bin and OddGFX.Bin files, I have obtained OutGFX.bin and when editing it with Tile Molester, I still cannot see any sprites.


Well, maybe you're going to have to learn..? In your first post you were going to go ahead and disassemble the entire ROM; did you not expect programming would be involved?
I want to learn and I really appreciate you sharing your knowledge with me.

Jorpho

  • Hero Member
  • *****
  • Posts: 5231
  • The cat screams with the voice of a man.
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #21 on: January 25, 2022, 05:11:52 pm »
Sir, I suggest you show your appreciation by taking the time to carefully read what people are writing.

Someone already said that you need to set Tile Molester to 2BPP Linear with blocks set to 2x2. Is that what you did?
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #22 on: January 25, 2022, 05:21:19 pm »
You're right, I read it quickly from the mobile.

Yes, I have tried that way and also in other ways but I can't see any sprite.

Jorpho

  • Hero Member
  • *****
  • Posts: 5231
  • The cat screams with the voice of a man.
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #23 on: January 25, 2022, 09:15:46 pm »
Then either you are doing something wrong, or there is something wrong with the file.

Working with the unmodified files, have you been able to get the same image that was posted on the previous page?
Spoiler:
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #24 on: January 26, 2022, 01:31:13 am »
You should look for "4 bpp linear" I believe.

I used this utility: http://www.romhacking.net/utilities/93/

I opened the resulting OutGFX.Bin that the interleave program I showed you produced and I can see the Ninja's sprites at the beginning. On the arcade hardware sprites can be 8x8, 16x16, 32x32, or 64x64 pixels in size. Depending on the size of the sprite being displayed it will determine which areas in ROM are fetched. There may be settings in Tile Molester to rearrange the viewer to make them appear arranged like the hardware would do so for a 16x16 or larger sprite, or it might not.

If you have never edited graphics in a ROM before it might be a better choice to try doing it on a console game like for the NES, SNES, or Genesis. There are more tutorials available to help you with that sort of things. Hacking arcade games will be more difficult due to the lack of resources available. You can make up for that if you have enough experience with other things but if you are just starting it's going to be very difficult. So you might want to try something a bit easier and come back to this idea once you have some experience.

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #25 on: January 26, 2022, 02:29:04 am »
Working with the unmodified files, have you been able to get the same image that was posted on the previous page?
Yeah I got the same sprite but I only got to see that one.

I opened the resulting OutGFX.Bin that the interleave program I showed you produced and I can see the Ninja's sprites at the beginning. On the arcade hardware sprites can be 8x8, 16x16, 32x32, or 64x64 pixels in size. Depending on the size of the sprite being displayed it will determine which areas in ROM are fetched. There may be settings in Tile Molester to rearrange the viewer to make them appear arranged like the hardware would do so for a 16x16 or larger sprite, or it might not.
What settings did you use other than 4 linear bpp?

January 26, 2022, 07:09:27 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Good!! I have managed to see the sprites in OutGFX.bin.

Is there a way to see them larger? They look cut off.

How can I see the colors of the sprites palette correctly?

https://ibb.co/hccbRwW
« Last Edit: January 26, 2022, 07:10:24 am by fhrans »

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #26 on: January 27, 2022, 02:51:16 am »
You are seeing the sprites as they are stored in ROM. They aren't going to look neat and organized like you might have thought. The data for different frames of animation or even the blocks of sprites that make up a frame may not be next to each other in ROM to appear correct in your graphics editor. That is just how it is, there is nothing you can do about it.

The graphics ROM does not contain any palette data. If you want to see a sprite with the correct palette it is up to you to enter the correct palette into your graphics editor. You can find what palettes look like if you run the game in MAME with the debug mode enabled.

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #27 on: January 27, 2022, 03:26:07 am »
Wow, that greatly reduces the possibilities for editing the sprite graphics.

So just to be clear, can I set the correct palette in Tile Molester? I already extracted the palette with MameDebug.

Once I have made the modifications in the OutGFX.bin file, how do I unmerge the OutGFX.bin file to be able to have the loose files of the rom again and later compress them to a zip?

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #28 on: January 27, 2022, 06:35:45 pm »
Editing sprites in any game can be difficult. If you only need to change the pattern data, it's not too bad. But if you need to change the arrangement of sprite cells it's going to require altering data in the program rom.

Yes you can set the correct palette if you know the colors and the order of them, which you can see in MAME.

After making your modifications you need to do the reverse of what the program source code I posted does. You'll be taking the first byte and outputting that to a EvenGFX.bin, then the next byte to OddGFX.bin, and repeat until reaching the end. Then after you have those you'd just need to chop out each section for the original rom files.

All of this is very simple to do if you know a programming language to make a program to do it for you.

Also MAME doesn't require zipped roms so you could just place them in the appropriate folder in the ROMS folder. Be aware that MAME might complain if your ROMs are modified and you may have to use a command to tell it to ignore that and load the ROMs anyway.

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #29 on: January 28, 2022, 03:02:27 am »
So, there are sprites that are cut, for example, the trunk and on the other hand the legs. I don't see a way to edit an entire sequence. Sequences such as walking, running, jumping...

I wonder how they edited Dragon Bowl? In it, they replaced all the graphics except the sound.
https://www.youtube.com/watch?v=BcVqSL5rGCA

I already have Ryu Hayabusa's palette. I'm going to try editing the palette in Tile Molester and show you the results.

I don't really understand how to do it:
Here is the code you posted. What should I modify?
#include <stdio.h>
#include <stdlib.h>

FILE *fEven;
FILE *fOdd;
FILE *fOut;

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");

}

What command should I use if MAME won't run the modified game?

I know I ask a lot of questions but many doubts arise as I go along.

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #30 on: January 28, 2022, 04:02:58 am »
I think MAME will run your modified ROMs as long as you launch the game from the command line. So by typing at the command prompt "mame.exe gaiden" for example.

Dragon Bowl was a "professional" bootleg made by people with enough knowledge and experience to do such a ROM hack. There is no secret to it.

It would not help you for me to tell you what to modify in the C program code I posted. If you understand what the program is doing, then you will understand how to make it "undo" what it is doing. But if you have no understanding of programming then you need to learn and that's beyond what anyone can teach you here in a few posts.

I will explain one more time about what the program is doing. The program takes the Even and Odd graphics ROM data and combines them into one file which represents how the arcade hardware sees the graphics data. So you can see in the program where it opens the two files and then creates a third file for the output. It then creates the output file by switching between reads a byte from the Even data and then the Odd data until all of the even and odd data has been read.

To reverse this you need a program to read the OutGFX.Bin and write new EvenGFX.bin and OddGFX.bin files. The program would read a byte from the OutGFX and write it to the EvenGFX, then read the next byte and write that to the OddGFX, and repeat that process in the same way it did before until all the data has been written.

The final step would be to take the EvenGFX and OddGFX files and cut them into pieces which made up the original ROM files. You could write a program to do this for you if you learn C or another programming language. It's all very simple moving data around.

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #31 on: January 28, 2022, 08:22:53 am »
Good!
Do you know any book or website that stands out to learn C/C++?

I've already got the right palette for Ryu hayabusa.
https://ibb.co/K78t5Gw


Jorpho

  • Hero Member
  • *****
  • Posts: 5231
  • The cat screams with the voice of a man.
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #32 on: January 28, 2022, 11:29:24 am »
Do you know any book or website that stands out to learn C/C++?
You really don't have to know much about C specifically in order to do this, except maybe the particular syntax of "fputc" and "fgetc". Just look at each line and think about what it is doing. You don't even have to use C if you don't want to; other languages will have similar commands.

If you've never, ever programmed before I might suggest starting with Python. There are lots of Python courses for non-programmers out there. A Byte of Python seems popular.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #33 on: January 28, 2022, 04:26:52 pm »
There are many languages you could achieve what you need to do. A long time ago I liked BlitzBasic. The related BlitzPlus is available here:
https://blitzresearch.itch.io/

It's pretty easy to use. Though it may cost money, I don't think it's free. Alternatively if you want to use the C program I posted and adapt it to do the other tasks you could setup something like DevCpp which is free. You can find the setup for that here:
https://sourceforge.net/projects/orwelldevcpp/files/Setup%20Releases/Dev-Cpp%205.11%20TDM-GCC%204.9.2%20Setup.exe/download

As Jorpho said, just look over the example program I posted and you can learn how you can open files either to read or write and how to read a byte or write a byte. Just take your time to understand and figure out how it works.

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #34 on: January 28, 2022, 06:02:06 pm »
I'm going to try to modify the code you posted to do what I want.
I really appreciate the patience and help you offer me, it is a pleasure to deal with such wise people.

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #35 on: January 29, 2022, 03:11:18 am »
Good luck. With some time and patience you can figure it out.

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #36 on: February 03, 2022, 03:08:26 am »
I have one more query. To change the color palette, for example, the colors of Ryu Hayabusa's clothes, you would have to do it from Tile Molester or by modifying the code in another way. In the event that it was with another program, with which one would it be and how could it be done?
Thanks!

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #37 on: February 04, 2022, 01:07:56 am »
If you want to alter the palette in the game that will require finding the palette data in the Program ROM data. I believe the palette entries are organized like this:

(xxxxBBBBGGGGRRRR)

x = Not Used.
B = Blue
G = Green
R = Red

Palette RAM on the hardware is mapped at 078000-079fff.

I would suggest using MAME in Debug mode and once Ryu's palette is loaded into Palette RAM use the memory viewer in MAME to see the exact values of all 16 colors of his palette in RAM and then use a hex editor to see if you can find that same data in program ROM. However like the Graphics ROMs the Program ROMs are 8-bit and you'll need to combine them by interleaving the data from both ROMs. gaiden_1.3s is the Odd bytes and gaiden_2.4s is the Even bytes I believe.

Or in the MAME debug window you can type in this command
Code: [Select]
save gaidenprg.bin,0,40000
It will save the program data to a file for you and then you can open that in a hex editor. But once you find the data if you change it in the combined (16-bit) file you'll need to make a program or find one to take the rom back apart into two 8-bit roms so you can have MAME load from the original file names. Or you could find the data and then try to find it in each of the original 8-bit files and edit it there.

fhrans

  • Jr. Member
  • **
  • Posts: 25
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #38 on: February 04, 2022, 01:22:08 pm »
How can I see that the palette is already loaded in Palette RAM?
Where is it and how can I use the MAME memory viewer?
Which hex editor is better?
I found a C++ teacher but I haven't started classes yet.

MottZilla

  • Jr. Member
  • **
  • Posts: 55
    • View Profile
Re: Hack Ninja Gaiden Arcade (original 1988) for MAME
« Reply #39 on: February 04, 2022, 06:35:44 pm »
When you run MAME you need to add a command line option which is
Code: [Select]
-d
If you aren't familiar with the command line you can right click on the MAME program and click Create Shortcut. Then right click on the shortcut and select properties. In the box that says Target, add the -d to the end which should be after the .exe

This will make MAME start with the debugger on when you start it through the shortcut.

There will be a window where if you look in the File menu you can tell it to make a New Memory Window. Then you just need to go look starting at that 78000 address I mentioned before. The memory in that section from 78000 to 79fff will change as the game runs.

Another thing, when the game is running press F4 to bring up a graphics viewer. Press Enter to cycle through different options. One option will show you the palettes, others will show different things related to the graphics.