News:

As a consequence of the forum being updated and repaired, the chatbox has been lost.
However, you can still come say hi on our Discord server!

Main Menu

Unfortunate Realisation...

Started by Rolina, 06, October, 2009, 11:06:00 PM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Rolina

I just realized something...  For the more extensive hacks, a scripting editor is going to be required.  Something that will help you cause events to trigger properly.

And if my basic knowledge of programming serves me correctly... that is NO EASY TASK.

This is more a question to Atrius than anything else, but... when the time comes, how are you going to approach it?  A standalone script editor, or something that you'll gradually build into other editors?  Or a combination of both?  I can't image it'd be easy, in fact, just thinking about it gives me headaches... not to mention the whole bit with the compressed data...

Atrius (He/Him)

I've already made great strides in making compressed data editable by getting the text editor working.

As for a script editor, that certainly will be tricky.  I already have an assembly code disassembler working in V.02, reversing the process would still be rather tricky, but doable.  Although assembly code isn't the most friendly coding language, making an editor for it would certainly provide good foundation for building a full fledged script editor.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Rolina

...I know... It dawned on me that right now we can edit things, but we can't just go in and add or change things.  That is to say, if we want to have a new event, there's no way to script said event.  No way to tell the game that you need item x so that door y will open, unless a script already exists.

Basically, we're stuck with the pre-existing events, and when I thought about, and depending on how the game does it, it can either be really hard, or infuriatingly hard to implement a decent script editor.

First, how does the game reference things?  Does it reference a certain line of code, or objects?  Basically, if you put a new line of code halfway through the game, does it break the game?  Or does it not matter?

Forgive me if I got some programming terms wrong, it's been several years since I took computer science...

This post has been edited by Role on Oct 8 2009, 04:14 PM

Atrius (He/Him)

Actually it doesn't have prewritten scripts for things like that per say.

Each map has it's own code data to handle stuff like that.  They use function calls for basic things like checking if the player has item X in his inventory, and there would be a separate function call to open door Y.  So all of the complex interactions are coded into each room individually, but the basic steps of them are handled through function calls.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Rolina

Oh!  So this kind of thing would just be a part of the map editor...

Well, how about other things that would require scripting?  Such as a sprite changing with storyline, or if you have a certain set of equipment on?  Kinda like how they did it in GS1's intro with Isaac and Garet, I guess.

One of the things I hope to do, for example, is that when you have the main character's "signature set of equipment" on, their overworld and battle sprites change to reflect it, but if you have any component missing, it's just the normal sprites.  That'd probably require some kind of script to be written, so...

Atrius (He/Him)

That would be quite a bit more complex, I'm not sure how that could be managed yet.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Salanewt

Hm... Reading this topic over a few times is getting me thinking about scripts now. Anyway, what if (for some of these scripts) you were to create a new one that is similar to an original, but has different text, items, and is a bit different in other ways as well. Would we be able to, for example, make a script that temporarily removes a certain amount of characters from your party? I am thinking of the script that removes Jenna and Sheba from your party on Jupiter Lighthouse.

It would be nice if, after altering it enough, there were to be a final fight against Alex, and the characters slowly re-enter the battle, kind of like how Jenna and Sheba jumped in when Felix and the robot were fighting Agatio and Karst, but have it so three characters jump in.

Piers is okay...

Have a nice day.
:MercurySet:  :MercuryDjinni:  
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Rolina

Ah, I totally forgot about that.  Yeah, that's a pretty good point.  There's a lot of scripts that I figure we'd need to have, and some of them would probably have to be of the manual-input variety.  Meaning, you have to code it yourself.  In such a case, it'd be quite helpful if the editor had some shortcuts to help out.

I figure that with what I wanted, it'd be a simple equipment check... if items W, X, Y, and Z are equipped, sprite changes from Set A to Set B for Overworld and Battle.  I figure it'd be like how Kid Isaac and Garet have their weapons permanent on their sprites, it'd be similar in nature here.  Basically, rather than having the base and weapon sprite present, it'd use the same thing that Kid Isaac/Garet had that caused them to simply have one sprite, rather than 4-5.

This post has been edited by Role on Oct 9 2009, 05:35 PM

Salanewt

Seems interesting, and I would like something like that for my hack. However, for them using different sprites, I am not sure if that has anything to do with equipment (even if it shows it), but rather, it looks like they use that sprite until a certain flag has been hit. This is sort of how Mario and Luigi: Superstar Saga works, but it also has preset sprite sets for each room, instead of the way that Golden Sun handles them (I think, but Atrius would know more about this for Golden Sun than I would (my idea is just a theory)).

However, it would be awesome to get a character's appearance to change by wearing different equipment, which is how it is done for the Machete and kid Isaac/Garet.

I never realised how unique some of these scripts are.

Have a nice day.
:MercurySet:  :MercuryDjinni:

This post has been edited by Salanewt on Oct 9 2009, 06:05 PM
Oh yeah baby, £ me harder.

Fusion is just a cheap tactic to make weak Adepts stronger.

Yoshi's Lighthouse is a hacking website in progress. Why not check it out if you like Yoshi or the Mario & Luigi games?

Atrius (He/Him)

I know whether you're kid Isaac/Garet in battle is determined by whether you currently have the Machete equipped, So I'd imagine it's doable.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Rolina

THAT'S what determines it?  Huh, I'd been wondering how that was done.  I guess that explains why you can't unequip it, too.  If that's the basis for it, then scripting equipment sets seems like it'd be the next logical step.

Hell, we could take it one step further than a 'signature set of equipment'... I could see maybe using a Nurse's Cap, Gown, and Gloves to trigger a sprite change as well, for no reason other than for lulz.  Good to know that the basis for how to approach that sort of thing already exists... It just means we have to expand on something that's already there...


So then, what about triggering flags for scenes?  How is that handled?  For example, the infamous "Mad Kraden" scene, where you had to say "No" to certain questions.  Also, triggering optional cut scenes dependent not just on location, but other things as well, such as having certain other events happen or attaining a certain item, etc...

Rolina

Huh... Well, either this isn't as complex as I thought, or you just have a way of making it sound a lot less complicated than it is...

Atrius (He/Him)

There are functions the room scripts call for setting, and checking flags.  It just gives them the index of the flag.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Atrius (He/Him)

Well, lets have a look at the exact code for such a scene.

In Madra there's a chance that Karst appears outside the Mayors house, here's the code that determines if she appears there:

0200804C: push {lr}
0200804E: move r0, #0x80
02008050: lsl r0, r0, #0x04
02008052: add r0, #0xFF
02008054: bl $0200aad8
02008058: cmp r0, #0x0
0200805A: beq $02008060
0200805C: ldr r0, [$02008064] (=$0200AFF0)
0200805E: b $02008062
02008060: ldr r0, [$02008068] (=$0200AD38)
02008062: pop {pc}


Yes it's GBA assembly code, don't worry I'll explain it.

0200804C: push {lr}
Just saving the location code was being executed from before it called this script somewhere safe.


0200804E: move r0, #0x80
02008050: lsl r0, r0, #0x04
02008052: add r0, #0xFF

A little bit of strange math, that just serves to set r0 to the value of 0x8FF.


02008054: bl $0200aad8
Here is the function call I mentioned, this command executes some code stored at another location in memory.  There's no need to fully explain the code there, essentially what it does is check whether the story flag whose index is stored in r0 is set or not.  If it is, it'll set r0 to 1, if not it'll set it to 0.


02008058: cmp r0, #0x0
0200805A: beq $02008060

Compare the value the previous function call set r0 to to 0, if it's equal jump to the code at location 0x02008060.


0200805C: ldr r0, [$02008064] (=$0200AFF0)
0200805E: b $02008062

This code is executed if we didn't jump during the previous bit of code, meaning r0 was set to 1, or the story flag 0x8FF was in fact set.  It loads a value (0x0200AFF0) to r0, and jumps to the code at 0x02008062.


02008060: ldr r0, [$02008068] (=$0200AD38)[code]
This is the code at 0x02008060 that gets executed when r0 was equal to 0, or story flag 0x8FF was not set.  It loads the value 0x0200AD38 into r0.


[code]02008062: pop {pc}

This reloads the location code was being executed from before the script was called, and jumps back to it.  Whatever code is there uses the pointer stored in r0 to find the NPC data for the room, which may or may not contain Karst in front of the mayors house depending on which value was sent.



Basically all of that converted into easy to read script format could look something like this:

if flagSet(0x8FF)
 npcDataPointer=0x0200AFF0;
else
 npcDataPointer=0x0200AD38;
return npcDataPointer;
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Charon

So instead of the scripts having their own commands defined by a table of predetermined ASM routines (like Pokemon), they're... all ASM themselves? o.o

Atrius (He/Him)

They are ASM, but they also do a lot of function calls to predetermined ASM routines.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Rolina

Huh.  When you get the version of the editor up with the script editor, you may need to either A - REEEEALY simplify it, or B - provide a how-to .txt file with it.

Either way, just to be safe, perhaps the editor can check to make sure it doesn't screw anything up?  I figure some errors will be trial and error, but certain others the editor could check for by compiling and seeing if it'll work.

Charon

I think Script Editing will be something for the more advanced from the looks of it. It seems like you'll be calling certain RAM offsets often... so a suggestion for you:

For the individual pointers to RAM/ROM offsets, you should compile a predetermined list... for example:

Let's assume that at 0x8123450, there's an ASM routine that can be used in a script that opens up a textbox and requires a pointer as an argument (I'm basing this off of my Pokemon scripting knowledge, this is probably set up differently in GS). Instead of something bulky like this:
callasm 0x8123450
argpointer 0x8987650


You could make it so that the user doesn't need to recall the actual pointer to the ASM, like this:
textbox
argpointer 0x8987650


It would make it a lot easier on the user's part, especially if the user doesn't want to have a list of pointers open all the time.

However, flags should be simply represented by their number for clarity's sake, with a list of common flags in the guide.

Debugging sounds like a good idea as well, and it should try to point out errors by highlighting unrecognized commands, and by highlighting the lines with errors caused by leaving something out.

Atrius (He/Him)

The goal of the editor is to be as user friendly as possible, I don't intend to throw ASM at the user if it can be avoided.  Like I said this:

0200804C: push {lr}
0200804E: move r0, #0x80
02008050: lsl r0, r0, #0x04
02008052: add r0, #0xFF
02008054: bl $0200aad8
02008058: cmp r0, #0x0
0200805A: beq $02008060
0200805C: ldr r0, [$02008064] (=$0200AFF0)
0200805E: b $02008062
02008060: ldr r0, [$02008068] (=$0200AD38)
02008062: pop {pc}

Could be represented like this:

if flagSet(0x8FF)
 npcDataPointer=0x0200AFF0
else
 npcDataPointer=0x0200AD38
return npcDataPointer

Of course you'd have the option to use regular numbers instead of Hex, and hopefully I'd even be able to come up with some constants to represent the possible values for npcDataPointer.
[sprite=220,4,0]I'm shaking my head in general disapproval of everything[/sprite]

Rolina

Ah, that is much easier to work with.  I'll glady choose that over that crazy stuff I didn't understand.