Z64

Please login or register.

Login with username, password and session length
Advanced search  

News:

Check out and improve the wiki!

Author Topic: Starfox 64 Hello World  (Read 3743 times)

mojobojo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Starfox 64 Hello World
« on: April 25, 2011, 01:37:15 PM »

I am quite proud of this, considering I just started. I reversed Starfox 64 and found the string printing function. I did this using the nemu64 debugger and LemAsm. I was not using my MIPS toolchain properly at the time. This can not be applied directly to the rom only manually apply to memory.



Code: [Select]
0x8009CD90
void sf64_print_string(int x, int y, float x_scale, float y_scale, char *str);

Code: [Select]
code hook jump
Address  : Bytecode : Instruction
800B7BA0 : 0C036400 : JAL   0x800D9000

hook code
Address  : Bytecode : Instruction
800D9000 : 00000000 : NOP
800D9004 : 24040080 : ADDIU A0, R0, 0x0080
800D9008 : 24050020 : ADDIU A1, R0, 0x0020
800D900C : 3C063F80 : LUI   A2, 0x3F80
800D9010 : 3C073F80 : LUI   A3, 0x3F80
800D9014 : 3C0D800E : LUI   T5, 0x800E
800D9018 : 21AD9080 : ADDI  T5, T5, 0x9080
800D901C : AFAD0010 : SW    T5, 0x0010(SP)
800D9020 : 0C027364 : JAL   0x8009CD90
800D9024 : 00000000 : NOP
800D9028 : 0C02DEE9 : JAL   0x800B7BA4

800D9080 : 48454C4C : HELL
800D9084 : 4F20574F : O WO
800D9088 : 524C4400 : RLD\x00

« Last Edit: April 25, 2011, 02:42:00 PM by mojobojo »
Logged

Marshall

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • 64.vg
    • Email
Re: Starfox 64 Hello World
« Reply #1 on: April 25, 2011, 08:20:21 PM »

Good work, champ. Nice to see more people treating hacking intelligently.

spinout

  • Administrator
  • Sr. Member
  • *****
  • Posts: 309
    • View Profile
    • Email
Re: Starfox 64 Hello World
« Reply #2 on: April 26, 2011, 05:25:07 AM »

11/10
Good work, champ. Nice to see more people treating hacking intelligently.
Logged
biggrin.gif

mojobojo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Starfox 64 Hello World
« Reply #3 on: April 26, 2011, 08:57:55 PM »

A very strange thing I am trying to fix. The text is default white, however when a characters text box pops up, the text turns yellow, then when I charge my lasers it turns red.

@ spinout
Can you point me into the direction of the mips toolchain you use. The one I am building is failing when I try to compile "bla <address>". Also it would be alot easier to type into terminal "mips-gcc" other than "mips-unknown-linux-gnu-gcc".
Logged

spinout

  • Administrator
  • Sr. Member
  • *****
  • Posts: 309
    • View Profile
    • Email
Re: Starfox 64 Hello World
« Reply #4 on: April 27, 2011, 01:06:41 AM »

If you are running *nix, download these four scripts and run make.sh

If you are running windows, I would imagine that this would help.
Logged
biggrin.gif

mojobojo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Starfox 64 Hello World
« Reply #5 on: April 27, 2011, 01:44:16 AM »

Both are actually good for right now. I usually have a dual boot Windows 7 and Fedora. I messed up the fedora install a few days ago and haven't got into restoring it. Thanks, I hope you don't mind I am using your ld script from here, no sense in rewriting it.
Logged

spinout

  • Administrator
  • Sr. Member
  • *****
  • Posts: 309
    • View Profile
    • Email
Re: Starfox 64 Hello World
« Reply #6 on: April 27, 2011, 02:16:27 AM »

It's not my LD script but I have no problem with you using it. I no longer use that one, however, I use this one, but for the purposes of dumping the binary or converting the binary - it doesn't make much of a difference which is used.
Logged
biggrin.gif

Marshall

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • 64.vg
    • Email
Re: Starfox 64 Hello World
« Reply #7 on: April 27, 2011, 05:05:31 AM »

@mojobojo: Galatea can hook into Nemu and make quick inline assembly codes fun and easy to write! (GNU syntax) There are some examples here: http://64.vg/w/Mario_Kart_64

But obviously, the best way to go about it is what you're doing.

mojobojo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Starfox 64 Hello World
« Reply #8 on: April 27, 2011, 06:45:08 AM »

I am actually having a problem. My code seems to be locking up the game. First I disassembled it and checked to see if it was referencing the data properly it did so then debugged it and found it called the function twice and then no longer calls it, all it dose is play the music. I don't know what the problem is so any help would be great. I used the options I found from spinouts makefiles from his projects.

EDIT: The code hook was in the wrong place. But the text dose not show up so I am still having a problem.
« Last Edit: April 27, 2011, 07:53:50 AM by mojobojo »
Logged

Marshall

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • 64.vg
    • Email
Re: Starfox 64 Hello World
« Reply #9 on: April 27, 2011, 09:56:04 AM »

Seems like you probably corrupted the code running in that thread (and not the music thread since it was still running). Usually the best place to put your code is in the upper 4MB of RAM, and then just replacing JAL instructions where appropriate. See http://64.vg/dr/node/4, and http://bb.64.vg/mk64-test/overview for a practical example. The second link does essentially the same thing you are doing albeit with Mario Kart 64.
« Last Edit: April 27, 2011, 09:59:35 AM by Marshall »
Logged

mojobojo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Starfox 64 Hello World
« Reply #10 on: April 27, 2011, 10:42:35 AM »

Alright, I am going to reverse the method I originally put it in a bit more. I was copying over a conditional branch which worked, but wasn't good. That function (800B7150), from what I saw may control some of the 2d objects on the screen. I messed with it a bit and some 2d objects from when you finished the level popped up.
Logged

Marshall

  • Jr. Member
  • **
  • Posts: 70
    • View Profile
    • 64.vg
    • Email
Re: Starfox 64 Hello World
« Reply #11 on: April 28, 2011, 06:08:21 AM »

Just noticed this now: you are passing the floats as hexadecimal instead of as the numbers they actually are.

mojobojo

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Starfox 64 Hello World
« Reply #12 on: April 29, 2011, 03:48:19 AM »

I noticed that too. For some reason I thought at the time running them like that wouldn't matter.
Logged