Mac CS Hacks!

Jul 7, 2010 at 3:22 AM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
Well, after about 1 hour of exploring and hex editing, I am somewhat proud to announce a slightly hacked version of Cave Story for the mac.
This basic hack has the (C)Pixel removed and has been modified read .bmp files as opposed to .pbm files, allowing for simple graphic edits. Not the most useful, I know this is replacing my regular Cave Story because it doesn't change gameplay!
Download Here!
Well, that's about it.
I used a mac hex editor to hack the executable (found in the .app).
Thanks to Noxid, GIRakaCHEEZER, and Celticminstrel for the help and explanations!
This really is a basic hack, but it is one of (if not the) first CS Mac hacks.
Please tell me if the game glitches out and dies for some reason! : D
The original CS for mac can be found here, for those who don't do .dmg files :)

WARNINGS:
>For Cave Story mac to read your edited .bmp files, they must be set to 8-bit.
 
Jul 7, 2010 at 3:30 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Research is ongoing on the mac executable.
Analysis so far: It is hella optimized and really confusing and also lots of things are out of place.
 
Jul 7, 2010 at 3:42 AM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
Noxid said:
Research is ongoing on the mac executable.
Analysis so far: It is hella optimized and really confusing and also lots of things are out of place.

About how much of a head start does a PC Cave Story hacker have over a new Mac Cave Story hacker with no experience?
 
Jul 7, 2010 at 5:46 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Impressive, this could open up a lot of possibilities for mac editing. Unfortunately, I don't have a mac, so I'm not going to be able to run this.

So, back to the entertainment known as staring at hex numbers. I don't believe there's any significant difference between a mac hex editor and a windows one, functionality-wise.

For example, I can find the classic 0xcafebabe string in the mac executable:

diph.php


More info if you're confused.
 
Jul 7, 2010 at 6:30 AM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6211
Age: 38
Is this with the "Universal" or "PowerPC" binary?
 
Jul 7, 2010 at 12:48 PM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
cultr1 said:
About how much of a head start does a PC Cave Story hacker have over a new Mac Cave Story hacker with no experience?

An entire compendium's worth?
Anyway... map data starts at 9FD84 and 1467E4
Near as I can tell it's got the same format but like, i don't know.
What else do you need for hacking..? Start position, starting health, err... most other stuff is in the .px* files isn't it?
 
Jul 7, 2010 at 1:21 PM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6211
Age: 38
1. All you need for most mods in the exe is the map data.

2. Can you upload the original "Cave Story.app" folder? I want to attempt something but I can't extract files from .dmg images at the moment.

3. I compared the map data between mac and pc and it looks like a 1-on-1 match.
 
Jul 7, 2010 at 1:22 PM
Vanished.
Bobomb says: "I need a hug!"
Join Date: Apr 5, 2008
Location:
Posts: 776
I tried to do edit Linux CS.

I got a problem:
After I remove the (C)Pixel requirement from the binary,
I have to remove it from every .pbm or else it crashes and I get

./data/Loading.pbm,0
./data/MyChar.pbm,0
./data/Title.pbm,0
./data/ArmsImage.pbm,0
./data/Arms.pbm,0
./data/ItemImage.pbm,0
./data/StageImage.pbm,0
./data/Npc/NpcSym.pbm,0
./data/Npc/NpcRegu.pbm,0
./data/TextBox.pbm,0
./data/Caret.pbm,0
./data/Bullet.pbm,0
./data/Face.pbm,0
./data/Fade.pbm,0

That.
Why is that?
Normaly you only have to remove it in the binary...
 
Jul 7, 2010 at 5:52 PM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
andwhyisit said:
1. All you need for most mods in the exe is the map data.

2. Can you upload the original "Cave Story.app" folder? I want to attempt something but I can't extract files from .dmg images at the moment.

3. I compared the map data between mac and pc and it looks like a 1-on-1 match.

Uplaoded.
I put the download link in my first post.
NEW DEVELOPMENTS: idk if this happens in windows CS too, but if i make a .tsc file into .txt and open it, it looks like this (the particular one is ArmsItem.tsc):
diph.php

This is the whole code.
if you look around a bit, you will find that the TSC commands (<NOD, <MSG, etc.) are in plain english as opposed to unicode.
Does this happen on windows too?
Becuase it helps you get an idea of where what is in the code, and could be helpful for mac hacking in the future.
 
Jul 7, 2010 at 5:59 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
ArmsItems.tsc looks exactly the same in Windows notepad as it does on your mac.
 
Jul 7, 2010 at 6:11 PM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
carrotlord said:
ArmsItems.tsc looks exactly the same in Windows notepad as it does on your mac.

ooh ok.
SO has anyone tried to edit .tsc files that way before?
Because if that gets figured out, then mac hacking could actually be plausible.
 
Jul 7, 2010 at 7:19 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Okay, so this is how TSC files are encoded.

(Hex code = Plain Text = Actual TSC)
0x43 = C = # (at the beginning of every event)
0x50 = P = 0
0x2D2A = -* = [newline character]
0x5C = \ = < (the first character of every TSC command)
0x59 = Y = 9

Now, notice this:

0x23 = the ascii code for #
0x30 = the ascii code for 0
0x31 = the ascii code for 1
0x32 = the ascii code for 2
...
0x39 = the ascii code for 9
0x3C = the ascii code for <

So, the only difference between an editable script of TSC and a real TSC file is that every character has 0x20 added to its respective ASCII code (with the exception of the newline character). Now, this means you should be able to type in TSC-scripts into a text file, use a hex editor, and add 0x20 to every value (taking into account special chars like newlines) and then you'll get a usable TSC file that works in-game.

I'll try to write a Python script to do the encoding/decoding automatically. Since Python is cross-platform, that means the script should work the same on a Mac, i.e., a Mac TSC editor (I hope...).
 
Jul 7, 2010 at 7:37 PM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
But there's still the issue of map editing.
I could work with an ASCII based map editor, if only I had one...
I imagine a could also work with each tile getting a four digit number (like in TSC Coding).
 
Jul 8, 2010 at 12:50 AM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6211
Age: 38
Just do the mod in Sue's (or CaveEditor if you make sure that you don't use the additional map space) and port the files and mapdata over. For things like framerects, minor hex edits, asm, etc., you are on your own at this point.
 
Jul 8, 2010 at 1:24 AM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
I have encountered something of a glitch.
It seems as if altering graphics that use color cause the entire spritesheet to read blank.
I was attempting to port A Lost Land to Mac, and everything worked pretty well, but textbox.bmp and many others came up as black. The title screen, however worked just fine, as did all the .tsc codes.
Has anything like this ever happened on windows before?
 
Jul 8, 2010 at 2:30 AM
In my body, in my head
Forum Moderator
"Life begins and ends with Nu."
Join Date: Aug 28, 2009
Location: The Purple Zone
Posts: 5998
Not to my knowledge. Probably something to do with like... the pallet format or whatever. You did say you changed the extension right?

Anyway, how was this so hard to do? it literally took me like 30 seconds to find the map data once I decided "Hm. I should find the map data".

Now someone needs to make the editor of course.
 
Jul 8, 2010 at 3:07 AM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
The TSC research is starting to get interesting. It turns out that each TSC file is encoded with a special character within the file itself. The character is always located in the middle of the TSC file. That also means, if you change the filesize of the TSC file, you change the way it's encoded.

For example, in the exact middle of the ArmsItem.tsc file, there is a (space) character. Now, the ascii code for the (space) character is 0x20. In the actual encoded TSC file, the 0x20 character in the middle gets replaced with 0x00. All the other characters, including the other space characters, get +0x20 added to their hex codes.

Now, it was a stroke of luck that cultr1 happened to pick ArmsItems.tsc. The method for converting an uppercase letter into a lowercase letter is to add 0x20 to the ascii code of that letter. That caused <FRE, <WAI to turn into fre, wai, so that you could see the TSC commands. For most of the other TSC files, all you would see is a jumble of total nonsense unicode.

So, now I need to get working on a deciphering routine. I believe it's still possible to finish the Mac TSC editor, though it might take a bit longer.
 
Jul 8, 2010 at 3:41 AM
Only Love, Maximum Love, Forever
"Life begins and ends with Nu."
Join Date: May 6, 2009
Location: somewhere new
Posts: 2137
Age: 29
thank you carrotlord!
Also, I am happy to announce that i have solved the graphical problem!
For CS mac to read the files, the images MUST BE 8-BIT.
So carrotlod, can you upload those for me? My mac has no such feature. :)
Also, your TSC code fix didn't fix anything.
It just made it so that as soon as i press new game, it goes to a black screen, the back to the title D:
Please double check your work!
 
Jul 8, 2010 at 5:31 AM
Administrator
Forum Administrator
"Life begins and ends with Nu."
Join Date: Jul 15, 2007
Location: Australia
Posts: 6211
Age: 38
cultr1 said:
I have encountered something of a glitch.
It seems as if altering graphics that use color cause the entire spritesheet to read blank.
I was attempting to port A Lost Land to Mac, and everything worked pretty well, but textbox.bmp and many others came up as black. The title screen, however worked just fine, as did all the .tsc codes.
Has anything like this ever happened on windows before?
Porting A Lost Land would be difficult due to it exceeding the max available map data for non-CE-hacked executables, well at least that was the problem when I tried to port it to psp. If you want A Lost Land on mac you need to either rearrange the maps till they fit and make alterations to the tsc files to match, or you will need to use assembly to redirect the map data to the end of the executable.

The black is likely due to textbox.bmp being saved in a format or bit depth that CSMac doesn't like. Also watch out for images that save the same colour multiple times in the pallette, especially black.
 
Top