C Hacks

Nov 21, 2012 at 9:24 PM
Neophyte Member
"Fresh from the Bakery"
Join Date: Aug 23, 2012
Location:
Posts: 3
You can write Cave Story hacks in C.
But you still need to know assembly.

Code:
#DEFINE
int asciiToNumber(int asciiValue) {="offset 421900 | push ebp | mov ebp, esp"
asciiValue=[ebp+8]
}="mov esp,ebp | pop ebp | retn"
"int *pointerToNumber = "="mov eax, "
"char "=
"digit0 = "="movzx edx, byte "
*pointerToNumber=[eax]
"int c = 0"="xor ecx, ecx"
"c += (digit - 0x30) * 1000"="sub edx, 30 | imul edx, edx, ~1000 | add ecx, edx"
"digit = *(pointerToNumber + 1)"="movzx edx, byte [eax + 1]"
"digit = *(pointerToNumber + 2)"="movzx edx, byte [eax + 2]"
"digit = *(pointerToNumber + 3)"="movzx edx, byte [eax + 3]"
"#def #"=
"c += (digit - 0x30) * 100"="sub edx, 30 | imul edx, edx, ~100 | add ecx, edx"
"c += (digit - 0x30) * 10"="sub edx, 30 | imul edx, edx, ~10 | add ecx, edx"
"c += digit - 0x30"="sub edx, 30 | add ecx, edx"
"return c"="mov eax, ecx | retn"
#ENDDEFINE
int asciiToNumber(int asciiValue) {
int c = 0;
int *pointerToNumber = asciiValue;
char digit = *pointerToNumber;
c += (digit - 0x30) * 1000;
digit = *(pointerToNumber + 1);
c += (digit - 0x30) * 100;
digit = *(pointerToNumber + 2);
c += (digit - 0x30) * 10;
digit = *(pointerToNumber + 3);
c += digit - 0x30;
return c;
}

Does anyone have a C to assembly translator?
That would be great. Then I wouldn't have to bother with the define statements.
*I hope this post is in the right forum
 
Nov 21, 2012 at 9:42 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
Pronouns: he/him
I think that's called a "compiler"
and from the look of all those defines, are you really writing C at all?
I've thought about making a "library" of Cave Story offsets for use with C it would have been too much work for not enough gain compared to just straight-out writing ASM.

See also http://www.delorie.com/djgpp/v2faq/faq8_20.html maybe? since that would technically be "C to assembly"
 
Nov 21, 2012 at 10:00 PM
Not anymore
"Run, rabbit run. Dig that hole, forget the sun."
Join Date: Jan 28, 2010
Location: Internet
Posts: 1369
Age: 34
Pronouns: he/him
Since you joined in August, you learned assembly in 3 months?

If we had a C compiler that was built for patching Cave Story, then that would be awesome.
But no such thing exists because I am lazy and I don't know how to write a compiler only an assembler.

Also I think that all the other coders capable of making a compiler on this forum are working on other projects such as Booster's Lab or WTF Story.
 
Nov 22, 2012 at 3:50 AM
Professional Whatever
"Life begins and ends with Nu."
Join Date: Jan 13, 2011
Location: Lasagna
Posts: 4481
Pronouns: she/her
Join date isn't a synonym for lurking time. It is possible to view these forums without an account, and assembly isn't exclusive to Cave Story.
 
Back
Top