Skip to content
This repository was archived by the owner on Jul 29, 2020. It is now read-only.
PlatinumMaster edited this page Sep 24, 2017 · 3 revisions

So essentially, the way this works is by making an assembly script with commands inside of it that is passed to an assembler. As the assembler does not natively recognize the commands, we must define them ourselves. This is where the slightly more involved part comes in.

@ ---------------------------------------------------------------------------------------------    
@ Configuration
@ ---------------------------------------------------------------------------------------------    
.align 2
.text 
.thumb

.include "./Source/commands/B2W2.s" @ Use commands from Black 2 and White 2.
.include "./Source/commands/Custom.s" @ Custom commands.

As you can see, I have posted a header here. Every script you make with this system must have this at the top. Why? I'll go over that right now.

.align 2
.text 
.thumb

These three settings each tell the assembler exactly how to export the script. These should not be changed unless otherwise designated.

.include "./Source/commands/B2W2.s" @ Use commands from Black 2 and White 2.
.include "./Source/commands/Custom.s" @ Custom commands.

The first include would include the commands for B2W2. B2W2 can be replaced by any game in the Gen 4/5 series, however their commands have not been implemented into this system yet. The second include would be for custom commands which I add. Currently, these are to help with the creation of scripts - the games use a relative pointer system, I'll explain that in a bit as well. But as time goes on, you may be able to make your own scripting commands as well.

Header:
		Header Main
		EndHeader
@ ---------------------------------------------------------------------------------------------	
@ Script 0
@ ---------------------------------------------------------------------------------------------	
Main:
                PlaySound 0x547
				
Movement:
	       WaitMovement
                Message2 0x0 0x0 0x0 0x0 
                YesNo 0x8010
                StoreVar 0x8010
                CompareTo 0x0
                Condition EqualTo
				 
Conditional:
				If False GetOffset StartTrainerBattle Conditional
				Message2 0x2 0x0 0x0 0x0
				WaitButton
				End

StartTrainerBattle:
	       PlaySound 0x573
                AngryMessage 0x1 0x0 0x0 
                CloseAngryMessage
				SingleTrainerBattle 0x9D 0x9E 0x0
				End @ Ends the script.

This is the actual script itself. Now you're probably wondering, what's up with StartTrainerBattle and Conditional? If you are familiar with XSE, you may remember orgs. Well, this is essentially the same thing.

Header:
				Header Main
				EndHeader

B2W2's script files can be thought of as a container. There is a container for each map, and inside that container there are different scripts. But how do we determine which script is which? Let's take a look at the compiled version of the script.

13 FD - Declares the ending of the pointer section.
---------------
A6 00 47 05 - Play a sound. In this case, "clink".
3D 00 00 04 00 00 00 00 00 00 00 00 - Open the first message in a text file for that map, at the bottom of the screen.
47 00 10 80 - Open a yes or no box. Store the result of the player choice in variable 8010
09 00 10 80 - Stores the variable.
08 00 00 00 - Sets value to compare to.
11 00 01 00 - Sets criterion for comparing. 
---------------------------------------------------
1F 00 FF 10 00 00 00 - If the value is FF, jump to the offset of the destination (relatively. it would take the destination's offset "StartTrainerBattle" and it's own offset "Conditional", and do [destination] - [current] in order to get [distance], which would be 0x10). Otherwise, it will continue reading the script as normal.

---------------------
Condition 1:
3D 00 00 04 02 00 00 00 00 00 00 00 
32 00 
02 00
---------------------
Condition 2:
A6 00 73 05 
4A 00 01 00 00 00 00 
4B 00 
85 00 9D 00 9E 00 00 00 
02 00
----------------------

The pointer section is the distance after the pointer (meaning how many bytes after the entire pointer. The pointer is in fact 4 bytes. So if something was at 0x6, the pointer to it would be 0x2, as it is two bytes after the pointer. To make it easier, I have included a Header command, along with an EndHeader command. Essentially, the header command would point to the label of the first script. In this case, the first script is named "Main". The endheader command would designate the end of the pointer section, and the start of the command section.

Clone this wiki locally