News: 11 March 2016 - Forum Rules

Author Topic: hacking ms.pac-man rom?  (Read 6590 times)

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
hacking ms.pac-man rom?
« on: March 16, 2015, 12:43:50 pm »
Hi there,
I am in need of a suggestion or thought to complexity.

I want to build a mini arcade of ms. Pac-Man solely to be used to ask my girlfriend to marry me :)

My idea is to use a raspberry pi 2 with a servo controller and a hacked rom.

I want to be able to turn it on and it look normal , however the fruit sprites would now be a ring instead and when caught it triggers game to instantly go to the "they meet" cut scene then shuts down the game to switch over to a slide show and at end of slideshow triggers the servo to open a door and spit out a ring .

Is that an impossible or highly complex thing?

I have some time fortunately but little experience outside making the machine itself.

Any help or suggestion would be appreciated .

FAST6191

  • Hero Member
  • *****
  • Posts: 3524
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #1 on: March 16, 2015, 01:21:04 pm »
So you have a scene that is already in the game ( https://www.youtube.com/watch?v=GzZysHkdC6U ) an action that causes some kind of even trigger in the game (even if it is just removing it from the screen and adding some points) and then want that to trigger one of a rasp pi's IO pins (presumably then leading to a transistor or a relay or something that powers your servo).

That is a pretty doable hack, the only real problem I can see is some of the debug options for old arcade boards are not quite as nice as some of the stuff we see for the NES, SNES and all the other stuff commonly looked at by the hackers around here.

The IO part might be annoying but if you can compile the emulator to speak to the IO then you could also just as easily add something that the memory does not normally touch (or a value it does not normally have) to instead speak to the IO.

The fruit sprite should be a fairly basic graphics hack, I don't think it pulls double duty ( http://www.todayifoundout.com/wp-content/uploads/2010/01/today-i-found-out-mario.jpg ) or pulls from the same palette as something else but that should not be so bad to deal with.
Getting the fruit should cause a branch/function call in the game (normally to remove the sprite, possibly reset a timer and add something to the score)
Getting to the cut scene should have a branch/function call happen to activate it.
Hopefully you could just cause the fruit function to launch the cut scene with a simple one instruction/destination change, if not you might have to fiddle with whatever the cutscene needs to run (if it needs some memory cleared or something before it does it then do that).
At the end of the cut scene it should have another branch/function call to get back to the game, tell it to flip a bit in memory that the emulator is watching for (or set the score to 999999 or something) and at which point the emulator should able to fire the IO ( http://openmicros.org/index.php/articles/94-ciseco-product-documentation/raspberry-pi/217-getting-started-with-raspberry-pi-gpio-and-python ).

For me the most annoying part, assuming there are stumbling blocks in the hack, would probably be compiling the emulator with the mod (I have not compiled an emulator in a few years but it was never especially fun). I would be surprised if there is not some kind of mod of an emulator for the pi to have an external score counter, lives LEDs or something for a game though. Should not be too hard to port code there out to it.

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #2 on: March 16, 2015, 02:47:30 pm »
First , thank you .

A very encouraging reply as so far I haven't had any , I ask a similar question in the pi forums and was only told it would take an experienced programmer 6 months of 10-12 hour days to do what I ask . So that said, I came here :)
I had a feeling that the emulator would be the controller to it as the game would probably not have that ability unless written from scratch on its own In python or something thus eliminating the need to emulate .

So in essence you suggest that I need to find what calls basic game functions and alter those to accommodate something that the emulator can react to in a real world event .

would you suggest possibly not using the arcade ROM and going console as a better means to accomplish this ?
I just figured the original given its age and size maybe wouldn't be as complex tear down.

I don't even need the whole game,  just a reappearing level until the trigger is accomplished to set off the rest.

FAST6191

  • Hero Member
  • *****
  • Posts: 3524
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #3 on: March 16, 2015, 07:15:56 pm »
6 months of 10-12 hour days... I would have my own replica arcade machine, suitably modified of course, and probably time to pan for the gold and jewels needed for the ring as well as forge it for that much work.

I do not know if you know assembly for something (does not need to be whatever ms pac man uses -- learn one and you do well at most, learn two and it is just a matter of learning a new instruction set most of the time) or general programming is like. Depending upon the people you have to help then this would be the stumbling block.

Assuming you do have a basic concepts of programming on lock

The game probably has some kind of loop when the fruit is on screen as I believe it only lasts for a limited time. I do not know what the coding will be, for the sake of easiness we will go some kind of high level theory coding.

The normal game would run something like

[ms pac man level]
at and of level goto "they meet" cutscene
at end of cutscene goto level 2

part of [ms pac man level] would have something like
[fruit on timer]
If fruit is touched (probably more like if pac man location = fruit location) then call sound effect, remove sprite, reset timer/set no more fruit flag, add bonus points, carry on with life.

----

All you would do is then change the end of level to go back to level one. Change the if the fruit (now a ring if you find and alter the sprite) is touched to goto/jump/branch to cutscene and at the end of the cutscene you would set it to set whatever the emulator is watching for (a certain place in memory, a certain score value.....). If you had wanted it to play some massive custom animation and then some custom audio tune... well I probably tell you to look more at custom emulator coding and getting it load it as an avi and mp3, but if I had to do it in a game then yeah it would be a nightmare project.
If you did have a proper arcade machine then they often have some basic IO you could wire a transistor/relay to so as to power whatever you wanted.

Get me to do this on a system with tools that I know and I reckon I could have the hack done... it is 23:00 as I type this so possibly by 3am if it goes as such things usually do, then some high volume swearing as I fight with emulator code (though if I can do it on a PC with one of those nice Lua supporting emulators then it will be a breeze*) and just be after the morning rush hour to get me to hospital as I slice my fingers off owing to being the kind of idiot that operates power tools on no sleep. For an arcade ROM/board/architecture I do not know and having to go in cold then yeah it will be a weekend project for a couple of weekends, if only because the debug tools. If I had to also learn assembly in general... I don't know but a bit longer still and I would be tempted to drag in someone that does.

* http://retroachievements.org/ (a site to add trophments to old games) already do something very similar -- they will pop up a message on screen in response to a game event (level cleared in certain time, 100 kills in a level, score over a certain amount), aka run code based upon the events of an emulated game which is all that is necessary to tickle the IO.

Seihen

  • Sr. Member
  • ****
  • Posts: 402
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #4 on: March 16, 2015, 07:22:28 pm »
Maybe this is just me being lazy here, but since you want to do so many little small changes and don't need the full game, wouldn't it be more practical to just use one of the many thousands of Ms. PacMan remakes and modify that to fit your fancy? There has GOT to be a HTML5 or Javascript version available somewhere that would be infinitely easier to modify the source of rather than trying to get hooks into emulators and debug compiled code written in low-level assembly (or whatever it was written in back then).

Maybe look around for something like that first? Unless you're really interested in the challenge...

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #5 on: March 16, 2015, 09:53:49 pm »
:)
"Lazy" is fine also if I reach my goal , the last time I attempted anything was on my C64(god I feel old), so learning would be needed again as too many years away from it all and life itself getting in way too often .

I just want a nice thing to be remembered.  It doesn't have to be perfect to get it's point across but I'm unfortunately really anal to so as good as I can get is always nice.

I've already started the easy stuff with my 3D printer and just got the pi in a few days ago and have a screen coming.  I don't want to feel overwhelmed by it yet am eager to dive in.

you both seem knowledgeable and are helping my thought process on this and it's appreciated .

Do you feel a Java/html variety would have the ability to accomplish the goal without too much hair pulling on the pi?


Seihen

  • Sr. Member
  • ****
  • Posts: 402
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #6 on: March 16, 2015, 11:33:54 pm »
Frankly, I feel that a it would be worlds easier to modify an open source HTML5 version (try here, maybe?) than working in the limitations of the original rom and in trying to implement hooks to launch the slideshow and move the servos. I'm pretty sure you can do it all in a web-browser on the pi, actually.

Jorpho

  • Hero Member
  • *****
  • Posts: 5231
  • The cat screams with the voice of a man.
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #7 on: March 17, 2015, 09:36:54 am »
A quick Google suggests there might be one person out there who has disassembled the Ms. Pac-Man ROM.
http://bartgrantham.com/projects/ms-pacman-disassembly/

Whether it would be easier to work with said disassembly instead of an HTML5 version, I cannot say, but it would probably be easier than trying to hack away at the binary yourself.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #8 on: March 17, 2015, 12:34:29 pm »
I've got the source for Shaunew.com java Pac-Man bundle and I've contacted Bart , hopefully he will respond .
I was aware of some emulators sniffing the roms for achievements from watching Kickstarter and the "ignition"
Project for raspberry pi , so I  know it can and has been done.
I'm currently building as much of a resource as I can on these suggestions .
Getting excited :)

March 18, 2015, 07:25:49 am - (Auto Merged - Double Posts are not allowed before 7 days.)
Bart responded with his source code , very nice man . All z80 assembly ... I think that'll be a challenge for sure .
« Last Edit: March 18, 2015, 07:25:49 am by mubo »

Jorpho

  • Hero Member
  • *****
  • Posts: 5231
  • The cat screams with the voice of a man.
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #9 on: March 20, 2015, 01:15:59 am »
Come to think of it, I may have been thinking of http://www.donhodges.com/how_high_can_you_get2.htm and http://www.donhodges.com/how_high_can_you_get3.htm , which are very interesting reading and might provide some insight if you haven't found them yourself already.  It links to http://umlautllama.com/projects/pacdocs/mspac/mspac.asm , another commented disassembly.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #10 on: March 20, 2015, 11:54:18 am »
No I hadn't found those yet,  thank you . All the more to scramble my brain with :)

March 23, 2015, 11:45:59 am - (Auto Merged - Double Posts are not allowed before 7 days.)
I'm going to try to use the java version. All the code is there so digging into it and adding what's needed can be done , the author Shaun was very nice also and told me it shouldn't be an issue, only thing he wasn't sure of was having it come up on boot on the raspberry pi and servo function . Any suggestions on how to boot into the Javascript and make it full screen without sign of browser existing or maybe a shell ???
« Last Edit: March 23, 2015, 11:45:59 am by mubo »

Seihen

  • Sr. Member
  • ****
  • Posts: 402
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #11 on: March 23, 2015, 07:25:57 pm »
No I hadn't found those yet,  thank you . All the more to scramble my brain with :)

March 23, 2015, 11:45:59 am - (Auto Merged - Double Posts are not allowed before 7 days.)
I'm going to try to use the java version. All the code is there so digging into it and adding what's needed can be done , the author Shaun was very nice also and told me it shouldn't be an issue, only thing he wasn't sure of was having it come up on boot on the raspberry pi and servo function . Any suggestions on how to boot into the Javascript and make it full screen without sign of browser existing or maybe a shell ???

Depending on the browser, it should definitely have a full-screen mode. Which web-browser do you intend to use?

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #12 on: March 24, 2015, 09:04:51 am »
Possibly chromium in a kiosk mode of sorts , so long as performance is acceptable .
I'm determined to pulled this off some how but man every turn seems an obstacle of some sort .:)

Seihen

  • Sr. Member
  • ****
  • Posts: 402
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #13 on: March 24, 2015, 07:36:45 pm »
Possibly chromium in a kiosk mode of sorts , so long as performance is acceptable .
I'm determined to pulled this off some how but man every turn seems an obstacle of some sort .:)

The best thing to do in a case like this is to just break it down into parts. For example, the first part is to modify the Java Ms. PacMan to do exactly what you want it to do, even if you're only getting it to work on your PC. Next, get it to run on the RasPi. Then get the RasPi to boot into it. Then build the door opening servos (even if they open with a manual switch). Then get it to open through code. Finally, get the game to run that code.

Baby steps! It's definitely doable.

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #14 on: March 25, 2015, 07:29:41 am »
I didn't even realize that the Javascript version I was looking at didn't have sound :( , the computer I was using doesn't have speakers so that one's a no go . It's the little things :)
I'd be satisfied with a nes/snes/genny/intellivision hack at this moment , I don't care which ms.pac so long as it's accomplished and functional  . I really need to consider the scale of this I guess .
I appreciate everyone's help and suggestions , thanks

March 25, 2015, 09:55:44 am - (Auto Merged - Double Posts are not allowed before 7 days.)
What about : http://www.raspberrypi.org/forums/viewtopic.php?f=78&t=18874

Something like that maybe?
« Last Edit: March 25, 2015, 09:55:44 am by mubo »

Jorpho

  • Hero Member
  • *****
  • Posts: 5231
  • The cat screams with the voice of a man.
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #15 on: March 26, 2015, 01:10:04 am »
Hacking just about any binary version of the game would probably be just about as difficult as hacking the MAME ROMs.  Altering source code would be considerably simpler, as Mr. Seihen suggests.

...It occurs to me that you don't really need to jump to the "They Meet" sequence in the game itself, because really you're just going to run the slide show afterwards, right?  So you could just as easily use some kind of screen recording software to make an AVI (or whatever) movie of the sequence in question.

That means you're really only left with two problems: changing the graphic, and setting up something in an emulator that will spontaneously jump to a media player as soon as the fruit is collected.

It occurs to me that a fairly trivial way to alter the ring graphic would be to use RAINE.  I haven't tried it myself, but RAINE supports something called "EmuDX" that lets you replace the graphics with whatever you want, presumably in a fashion that would be easier than fishing around in the ROM.
http://rainemu.swishparty.co.uk/html/download/extras.html

Someone was saying the other day that an Android release is imminent, so the code might not be as dead as it looks.

As for the fruit, what if you looked for a program that could recognize the fruit-collection sound effect and act accordingly?  It's a fairly distinctive sound.  Then you wouldn't have to dig around inside game code or emulator code at all.  It's spectacularly kludgy, but it might work.  If EmuDX loads the sound effect from a specific file, then you might even be able to get away with somehow monitoring accesses of that file.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #16 on: March 30, 2015, 07:22:48 am »
Yes,  I was thinking the very same about just using a clip of the scene as it wouldn't be noticed either way.  As far as the emudx and raine , they can run on linux I see however wouldn't the arm processor be a problem?

Jorpho

  • Hero Member
  • *****
  • Posts: 5231
  • The cat screams with the voice of a man.
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #17 on: March 30, 2015, 08:37:19 am »
I have no idea.  You might have to compile it yourself.  (This may be quite the headache.)  If you get really desperate, I think someone ported DOSBox to the Raspberry Pi, and there might still be a suitable DOS version of RAINE (or stand-alone EmuDX) that will run in DOSBox.  (Whee, kludges!)
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

mubo

  • Jr. Member
  • **
  • Posts: 9
    • View Profile
Re: hacking ms.pac-man rom?
« Reply #18 on: March 30, 2015, 10:46:50 am »
Yeah kludges lol , definitely eh :crazy: