Register - Login
Views: 99797315
Main - Memberlist - Active users - Calendar - Wiki - IRC Chat - Online users
Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies
05-03-22 05:52:23 AM
Jul - SM64 Hacking (Archive) - Mario 64 'C' header files New poll - New thread - New reply
Pages: 1 2 3Next newer thread | Next older thread
Hectamatatortron
Member
Level: 35


Posts: 146/232
EXP: 258215
For next: 21721

Since: 09-19-07


Since last post: 7.2 years
Last activity: 5.3 years

Posted on 04-23-09 06:36:07 PM Link | Quote
Just read someone's suggestion for a starting point in the level they designed.

Then I thought..."why start in the same place every time?"

Wouldn't it be cooler if the starting point of a level changed on a per star basis?

As for any actual hacks, it seems like the new fad is to get rid of the Act selection system, which would render a feasible way of implementing variable entrances absent. Still, maybe Missing Stars can do something with this idea. Maybe.

____________________
Stevoisiak
Member
Level: 38


Posts: 246/283
EXP: 345780
For next: 24667

Since: 11-22-07

From: New York, Long Island

Since last post: 12.4 years
Last activity: 5.6 years

Posted on 04-23-09 10:56:36 PM Link | Quote
Originally posted by Hectamatatortron
Just read someone's suggestion for a starting point in the level they designed.

Then I thought..."why start in the same place every time?"

Wouldn't it be cooler if the starting point of a level changed on a per star basis?

As for any actual hacks, it seems like the new fad is to get rid of the Act selection system, which would render a feasible way of implementing variable entrances absent. Still, maybe Missing Stars can do something with this idea. Maybe.

Well, there is already a feature in-game to have 3 sections of one painting warp to different areas...

____________________
The guy who acts like he actually knows what he's talking about
Hectamatatortron
Member
Level: 35


Posts: 147/232
EXP: 258215
For next: 21721

Since: 09-19-07


Since last post: 7.2 years
Last activity: 5.3 years

Posted on 04-24-09 01:20:13 AM Link | Quote
Ah, right. That could be manipulated too.

A sort of "pick your entrance out of three" system for all the levels would be cool.

That doesn't really change the entrance, though, just the water level. Making it change the entrance would be easy enough I'm imagine.

____________________
OniLink10
User
Level: 12


Posts: 1/21
EXP: 6626
For next: 1295

Since: 05-09-09


Since last post: 12.9 years
Last activity: 12.3 years

Posted on 05-09-09 07:35:44 PM Link | Quote
This is very helpful! However, sadly I've run into a problem with this. NEMU can't even open Etnded ROMs, so I can't test with NEMU, and Project64 won't let the code run, it will crash with a "Memory out of Range" or something. Can anyone help me? Here's my Code and the C Code for it if that helps find my problem:

812CB26C 0C10

812CB26E 0000
812CB278 1000
812CB27A 0040
813FF000 3C1C
813FF002 8040
813FF004 279C
813FF006 0030
813FF008 3C06
813FF00A 8040
813FF00C 24C6
813FF00E 001C
813FF010 2404
813FF012 000A
813FF014 080B
813FF016 59B0
813FF018 2405
813FF01A 0014
813FF01C 5465
813FF01E 7374
813FF020 696E
813FF022 672C
813FF024 2031
813FF026 2032
813FF028 2033
813FF02A 00AA
813FF02C AAAA
813FF02E AAAA




#include "include/n64.h"

#include "include/mario64.h"

void _start(void)
{
asm volatile("la $gp, _gp")
PrintXY(10,20,"Testing, 1 2 3")
}


Can anyone help?
messiaen
Catgirl
Level: 68


Posts: 586/1085
EXP: 2596323
For next: 132477

Since: 11-20-07


Since last post: 8.1 years
Last activity: 7.2 years

Posted on 05-09-09 08:21:01 PM (last edited by messiaen at 05-09-09 05:22 PM) Link | Quote
You can test it with Nemu64 by using the non-extended ROM. What's hapenning is that your Gameshark code isn't mapped correctly. After the mario64.bin file is produced, the Makefile calls an ulitity that converts the mario64.bin file to a Gameshark code:


[Makefile:]
all: $(PRJNAME).bin
$(BINCODE) $(PRJNAME).bin 80400000 codes.txt # Turn binary into GS code


The 80400000 is how your Gameshark code is mapped, and how it should be done if you are using the hook.txt file, which inserts a "JAL 0x80400000" into some of Mario's code.

You also need to adjust this in the "SECTIONS" part of the mario64.x :

. = 0x80400000 ;

With these adjustments, compile it again and the final.txt Gameshark code should work .
OniLink10
User
Level: 12


Posts: 2/21
EXP: 6626
For next: 1295

Since: 05-09-09


Since last post: 12.9 years
Last activity: 12.3 years

Posted on 05-09-09 08:34:10 PM Link | Quote
It works now! Thank you so much! But, could you explain something to me? I set the X Coordinate of the Text to 10, and the Y Coordinate to 20, yet the Text was at the very bottom, and the word "Testing," was all stacked up on the left. Does the game measure the X and Y Coordinates for Text in Characters?
messiaen
Catgirl
Level: 68


Posts: 587/1085
EXP: 2596323
For next: 132477

Since: 11-20-07


Since last post: 8.1 years
Last activity: 7.2 years

Posted on 05-09-09 09:02:41 PM Link | Quote
The text is sort of centered around the X coordinate, so try for instance using PrintXY(150,60,"Testing, 1 2 3");. I think the range of X, Y values is 320x240.
OniLink10
User
Level: 12


Posts: 3/21
EXP: 6626
For next: 1295

Since: 05-09-09


Since last post: 12.9 years
Last activity: 12.3 years

Posted on 05-09-09 09:57:35 PM Link | Quote
Originally posted by messiaen
The text is sort of centered around the X coordinate, so try for instance using PrintXY(150,60,"Testing, 1 2 3");. I think the range of X, Y values is 320x240.

Ah, that makes sense. Thanks so much!
messiaen
Catgirl
Level: 68


Posts: 608/1085
EXP: 2596323
For next: 132477

Since: 11-20-07


Since last post: 8.1 years
Last activity: 7.2 years

Posted on 06-03-09 07:15:16 PM Link | Quote
Cool stuff can be done with the Print functions .

<object width="425" height="344"><embed src="http://www.youtube.com/v/FBjUml6xPQo&hl=pt-br&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

Source code.
Lyskar
12210
-The Chaos within trumps the Chaos without-
Level: 192


Posts: 2736/12211
EXP: 99320674
For next: 552897

Since: 07-03-07

From: 52-2-88-7

Since last post: 7.4 years
Last activity: 7.3 years

Posted on 06-03-09 11:42:13 PM Link | Quote

Time/Date

&date&

Posts

&numposts&

Days Here

&numdays&

Level

&level&
Metal_Man88
Local Moderator
Wow... that's some pretty crazy stuff there. Can't wait to see what else it can do.

____________________
Jeez, not being Spontaneous Madness is gonna take some getting used to...
Original Layout © Tobias Kelmandia
OniLink10
User
Level: 12


Posts: 19/21
EXP: 6626
For next: 1295

Since: 05-09-09


Since last post: 12.9 years
Last activity: 12.3 years

Posted on 06-04-09 04:00:04 AM Link | Quote
I didn't mention this before, and I probably should have, but there appears to be no cat command in the DOS Prompt when converting the GS Cheats to NEMU-Style Cheats. This is a problem, I have to make the GS Cheats into NEMU-Style Cheats by hand. > Is there any alternative to cat?
messiaen
Catgirl
Level: 68


Posts: 609/1085
EXP: 2596323
For next: 132477

Since: 11-20-07


Since last post: 8.1 years
Last activity: 7.2 years

Posted on 06-04-09 11:02:11 AM Link | Quote
I guess the closest thing to cat in DOS would be the type command, though the functionality is probably more limited. Anyway, if you compile from the MSYS/MINGW shell (as outlined in the tutorial on the first post) you won't have this problem, since it provides you all the tools needed.

This tutorial should help you setting it.
messiaen
Catgirl
Level: 68


Posts: 632/1085
EXP: 2596323
For next: 132477

Since: 11-20-07


Since last post: 8.1 years
Last activity: 7.2 years

Posted on 09-04-09 03:04:37 PM Link | Quote
Recently I have been doing a lot of work finding more functions and making header files more user friendly. Here is my first attempt of building a new behavior from scratch:

<object width="425" height="344"><embed src="http://www.youtube.com/v/Pab2U3mH4fE&hl=pt&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>

Source Code (just for reference, the new header files aren't ready for release yet).

Something that bothers me with dialogs is that there are tons of hardcoded data when it comes to message numbers, such as sounds being played. Eventually we'll have to figure some way to expand the text table so we can have more entries without hardcoded stuff.
VL-Tone
Member
Super Mario 64 forum moderator
Level: 53


Posts: 512/621
EXP: 1136482
For next: 20637

Since: 07-27-07

From: Montreal, Canada

Since last post: 4.7 years
Last activity: 6 days

Posted on 09-05-09 02:24:38 AM Link | Quote
Time: One second ago - Date: Tomorrow - Weather: Sunshine - Mood: Moody Answer to the universe: Yes
Really amazing stuff messiaen! Possibilities could be endless!

You know what would be nice? It's probably too much work, but it's one of my dreams that one day we'll have a BASIC-like interpreter that includes all the standard SM64 game engine functions so more people could program custom behaviors in SM64.

Still, I certainly hope that your efforts will inspire others to program behaviors in C. I know I would, if I had more time and didn't have TT64 to program.

____________________
MarIO0
Member
Level: 16


Posts: 2/43
EXP: 19175
For next: 1081

Since: 09-03-09


Since last post: 9.3 years
Last activity: 8.6 years

Posted on 09-05-09 09:49:13 PM (last edited by MarIO0 at 04-13-10 07:17 PM) Link | Quote
Mario Y speed: 0x8033B1BC (IEEE 32-bit float) -> 0x4C inside mario _ obj.
Mario X speed: 0x8033B1C4 (IEEE 32-bit float) -> 0x54 inside mario _ obj.

Here's a GS code that sets the X speed to 400.0.




8133B1C4 43C8
8133B1C6 0000



(Works best when flying).

EDIT: Fix'd
Hectamatatortron
Member
Level: 35


Posts: 168/232
EXP: 258215
For next: 21721

Since: 09-19-07


Since last post: 7.2 years
Last activity: 5.3 years

Posted on 09-06-09 04:30:19 AM Link | Quote
X, Z, and Y positions stored at 0x8033B1AC statically
Speed variables for corresponding coordinates stored in same order immediately after

That's what I have.

____________________
BigBrain
Member
Level: 22


Posts: 52/85
EXP: 55318
For next: 3032

Since: 09-10-08


Since last post: 8.9 years
Last activity: 6.8 years

Posted on 09-06-09 06:46:33 AM (last edited by BigBrain at 09-06-09 07:39 AM) Link | Quote
I'm not sure if I missed something, but I'm still a bit uncertain about what hook.txt does exactly...
Can anyone explain to me what it does and what I need to put in it if that isn't too much effort?

EDIT:
Ok, apparently hook.txt consists of several lines of cheat codes (are these specific to Nemu64?) which happen to be the first few lines in the final cheat code as well, for example (taken from explosive_objects):

[CODE]812CB26C 0C10

812CB26E 0000
812CB278 1000
812CB27A 0040[/CODE]


I read on http://cheats.emulation64.com/nemu64/cheatfaq.htm , that these are 16 bit constant writes. That is, e.g. in line 1 it writes the hexadecimal 16 bit number 0C10 to the address 2CB26C (in RAM, right?). So, what do these actually do (yeah, hook into mario's behavior, but.. how does that work exactly)?
I'll be taking a few looks at mario's behavior I guess, maybe I'll get a clue out of all this...

EDIT2:
Thanks to http://sites.google.com/site/messiaen64/patching-gameshark-codes , I figured out that the RAM address 0x2CB26C maps to the ROM address 0x8626C. But... I can't find this address anywhere in http://homepage.mac.com/qubedstudios/SM64Behaviors.txt, so it can't be the mario behavior, can it?


____________________
GSoC 2009 - working for the Wine Project this year
messiaen
Catgirl
Level: 68


Posts: 633/1085
EXP: 2596323
For next: 132477

Since: 11-20-07


Since last post: 8.1 years
Last activity: 7.2 years

Posted on 09-06-09 02:07:30 PM Link | Quote
Originally posted by BigBrain
I'm not sure if I missed something, but I'm still a bit uncertain about what hook.txt does exactly...
Can anyone explain to me what it does and what I need to put in it if that isn't too much effort?



The specific hook.txt you posted is just an assembled binary of instruction "JAL 0x80400000", whichs calls the function uploaded to memory by the Gameshark code. Its patched not really in Mario's script but inside one of the functions called by Mario's behavior script. In the "custom behavior" video I just posted, this hook isn't necessary, because in that case what calls the object function is the behavior script itself (command 0x0C).

Let me explain a bit the need of correctly hooking the code. When dealing with objects, there is a global variable at 0x80361160 which is a pointer to the "current" object struct (actually, a pointer to a pointer). The game basically cycles through a list of objects and the first thing it does is to read the behavior script. Behavior scripts are very limited, so basically what they do is to call a function that will be responsible for the object. At the time that function is called, the 0x80361160 will contain a pointer to that specific object.

This is how I am declaring this variable:

Object **Obj = (void*)M64_CURR_OBJ_PTR; /* (0x80361160) */

Object is a typedef for the "object struct" defined in one of the header files. For instance, when using that hook.txt, this variable will point to Mario object, so if you write something like (*Obj)-> y_pos = 300; it will affect Mario's position.

But back to the hook.txt, if object-related code is what you want to do, you probably don't need an ASM patch to get your code called. The easiest way to go is to modify a behavior so that your code gets called. Take a look at Yoshi's behavior for instance:


ROM Addr: 0021E338 Hex Behav: 13004538
Description: Yoshi behavior
21E338/004538 00 04 00 00 <-- From here until the 0x08 command below, this will only be executed once
21E33C/00453C 11 01 20 09
21E340/004540 27 26 00 00 05 02 41 E8 <-- Sets animation pointer
21E348/004548 2F 00 00 00 00 80 00 00
21E350/004550 1E 00 00 00
21E354/004554 23 00 00 00 00 A0 00 96 <-- Sets collision sphere X,Y
21E35C/00455C 28 00 00 00
21E360/004560 2D 00 00 00
21E364/004564 0C 00 00 00 80 2F 8E 54 <-- Calls an initialization function (remember, only called once)
21E36C/00456C 08 00 00 00 <-- Begins 'loop area'
21E370/004570 10 05 00 00
21E374/004574 0C 00 00 00 80 2F 96 5C <-- Main object function, called constantly. This is what you probably will want to change to get your code called
21E37C/00457C 09 00 00 00


I hope things are clearer now. Hook.txt is basically just a hacky way to get your code called, I should probably take it out of my examples Makefile.
BigBrain
Member
Level: 22


Posts: 53/85
EXP: 55318
For next: 3032

Since: 09-10-08


Since last post: 8.9 years
Last activity: 6.8 years

Posted on 09-07-09 08:20:53 AM (last edited by BigBrain at 09-07-09 06:48 AM) Link | Quote
Thanks for the explanation, I'm starting to get a sense out of all this now

Just another few questions (I hope these are a bit simpler):
1. Concerning the first line - which writes 0x0C10 to that location - I'm a bit irritated from the forum discussions you guys had some years ago, is the instruction 0x10 after 0x0C executed or ignored? (... the hacking docs could need an update IMO :/ )
2. in Mario's behavior (and several others) I always see the line 0C 00 00 00 80 XX XX XX. Why is that always 0x80 in the fifth byte? 0C is supposed to jump to the RAM address given at bytes 5 to 8 (at least that's how I understand it), but the N64 only has got 4 MBs RAM, i.e. its maximal RAM address would be 0x400000.
3. Is there some document that lists how each MIPS assembly command maps to bytecode? (Maybe I could answer Q1 myself if I knew what 0x10 does) - cellar dweller's notes provide information about what the bytecodes do, but it'd be nice to be able to look at a MIPS assembly reference for more detailed info. - EDIT: Uhm, are the bytecodes used in the behavior scripts actually the same as the actual MIPS opcodes?

Concerning 1 (logging my own progress here, perhaps someone else can learn something from it):
0C 10 80 33 81 CE 0E 94
What I now (partially) understood from cellar dweller's notes, 0x10 converts the 16 bit signed int 0x3381 to a 32 bit signed integer and writes it to 0x88 + 4 * 0x80 and jumps {after, before} that to the RAM address 0x81CE0E94... Well, it's probably not quite like that, but I think I'm slowly approaching the right interpretation...

EDIT2:
I found the answer to Q2 - the address is not actually a RAM address but a virtual memory address, whereas in the virtual memory address space the RAM memory starts at 0x80000000 (and probably ends at 0x80400000, but what about the example 0C 10 80 33 [81 CE 0E 94] which is still above the possible RAM address space, then?)


____________________
GSoC 2009 - working for the Wine Project this year
messiaen
Catgirl
Level: 68


Posts: 635/1085
EXP: 2596323
For next: 132477

Since: 11-20-07


Since last post: 8.1 years
Last activity: 7.2 years

Posted on 09-07-09 02:41:43 PM (last edited by messiaen at 09-07-09 11:43 AM) Link | Quote
Originally posted by BigBrain

3. Is there some document that lists how each MIPS assembly command maps to bytecode? (Maybe I could answer Q1 myself if I knew what 0x10 does) - cellar dweller's notes provide information about what the bytecodes do, but it'd be nice to be able to look at a MIPS assembly reference for more detailed info. - EDIT: Uhm, are the bytecodes used in the behavior scripts actually the same as the actual MIPS opcodes?



Be careful not to confuse the scripts used in the game with actual assembled MIPS code. What the hook.txt files writes through Gameshark codes is a simple assembly hack. It's just a coincidence that the mnemonic for the JAL instruction is "0x0C" and the behavior script function that does something similar is number 0x0C in the behavior function table.

I recommend downloading Renegade64 which has a handy "code disassembler".

If you ran the hook.txt file through it, it will give this output:

802CB26C: JAL 0x00400000
[...]
802CB278: BEQ ZERO,ZERO,0x002CB37C

Read the ASM Hacking thread for some more information about MIPS assembly. Each instruction is 32 bytes long, so it will require two "81" (which writes 2 bytes to memory) Gameshark codes. So, "0x0C100000" is assembled MIPS instruction JAL 0x80400000, not to be confused with anything related to behavior or any other kind of script.

Originally posted by BigBrain
Just another few questions (I hope these are a bit simpler):
1. Concerning the first line - which writes 0x0C10 to that location - I'm a bit irritated from the forum discussions you guys had some years ago, is the instruction 0x10 after 0x0C executed or ignored? (... the hacking docs could need an update IMO :/ )


The 0x0C10 was already addressed above. When it comes to behavior functions, you are forgetting that there is a lenghtfor each script command. They aren't just bytes translated into something, but a specific set of commands in an arbitrary format. The 0x0C for instance is eight bytes long.

"0C 00 00 00 80 40 00 00"

The three 0 bytes are ignored. Only the next byte after "0x80400000" will be interpreted as a new command.

Again, the 0x0C100000 patched through the hook.txt is an assembled MIPS instruction, don't confuse it with this specific behavior command.

As for addresses above 0x80400000, the extension pak provides 4megs of additional memory, so it's possible to use up to 0x80800000. Anything above that and you are probably reading things wrong.

Feel free to ask more question about MIPS assembly/behaviors (and remember there are separate threads for it), it's important to have a clear picture about how things work.
Pages: 1 2 3Next newer thread | Next older thread
Jul - SM64 Hacking (Archive) - Mario 64 'C' header files New poll - New thread - New reply


Rusted Logic

Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.

34 database queries, 12 query cache hits.
Query execution time: 0.299673 seconds
Script execution time: 0.035368 seconds
Total render time: 0.335041 seconds