• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best places on the 'net to talk Pokémon and more! Community members will not see the bottom screen advertisements.
  • Want to share your adventures playing Pokémon?
    Check out our new Travel Journals forum for sharing playthroughs of ROM Hacks, Fan Games, and other Pokémon content!
  • IMPORTANT: Following a takedown request, the following hacks have been delisted from PokéCommunity:

    • Pokémon Glazed
    • Pokémon: Giratina Strikes Back
    • Pokémon Flora Sky
    • Pokémon Stranded
    The downloads and discussion threads for these hacks will no longer be accessible, and staff will be unable to return questions regarding accessing this content.

GBA ASM Programming

chriskid198

Happy New Year!
159
Posts
13
Years
Yeah I know, I was just trying to explain what a routine was to him.
And thanks for that..

But I still don't understand how to insert it into the game.. I can't find that link for the package thing.

And one more question, is this basically scripting? Like this.
 

~Teh Panda~

Back in hacktion
918
Posts
16
Years
  • Seen Jul 20, 2022
And thanks for that..

But I still don't understand how to insert it into the game.. I can't find that link for the package thing.

And one more question, is this basically scripting? Like this.

Scripting is writing with the games pre-designed system for making in game events, in other words the way that pokemon games can read it, which is way you can't per say script your own game using that sort of scripting.

ASM is essentially working directly with the hardware
 

chriskid198

Happy New Year!
159
Posts
13
Years
Scripting is writing with the games pre-designed system for making in game events, in other words the way that pokemon games can read it, which is way you can't per say script your own game using that sort of scripting.

ASM is essentially working directly with the hardware
Ah, thanks ~Teh Panda~, do you mine if I call you Panda? :)

So, if you use ASM, you can use stuff thats not in the game? Like specials and stuff?
 

Shiny Quagsire

I'm Still Alive, Elsewhere
697
Posts
14
Years
Ah, thanks ~Teh Panda~, do you mine if I call you Panda? :)

So, if you use ASM, you can use stuff thats not in the game? Like specials and stuff?

Pretty much. You're only limited by the actual hardware and RAM.

Anyways, once I fix my computer's viruses I'm probably going to start writing a new section. It's either going to be on another data access thing or a game from scratch. If you'd like one of the two more, just comment ;)
 

Full Metal

C(++) Developer.
810
Posts
16
Years
"pokemon_data" and "var" are not a label. They're symbols.

Can you explain the difference between these two?
I thought that (labels/symbols) worked by the assembler calculating the distance between the (symbol/label) and the current instruction (and then doing stuff to make the instruction)
And you branch to a label, but in the end doesn't the assembler do the same sort of thing?
Not arguing, just trying to learn, i promise ^_^;
 

Shiny Quagsire

I'm Still Alive, Elsewhere
697
Posts
14
Years


Can you explain the difference between these two?
I thought that (labels/symbols) worked by the assembler calculating the distance between the (symbol/label) and the current instruction (and then doing stuff to make the instruction)
And you branch to a label, but in the end doesn't the assembler do the same sort of thing?
Not arguing, just trying to learn, i promise ^_^;

Codewise, there isn't really much of a difference. You could use a label or symbol and it really wouldn't matter. However, if your naming a section, I'm not so sure if that's OK.
 

Shiny Quagsire

I'm Still Alive, Elsewhere
697
Posts
14
Years
I like it, though I have a question.

About that sleep bit loading, how can one CHANGE the bits like the sleep bits, to induce sleep?

I've had to set bits, and I've found that the best way to do it is:
  1. Shift the bits right to ensure there isn't any sleep bits already there
  2. Add a number (Let's say, 3) to the amount
  3. Store that value back into the RAM with strb
 

Shiny Quagsire

I'm Still Alive, Elsewhere
697
Posts
14
Years
I'm a little confused...

may I have an example?

Sure :)

OK, lets take our initial routine:
Code:
.align 2
.thumb
.global example1

main:
		push {r0-r1,lr}
		ldr r0, pokemon_data
		ldrb r0, [r0]
		lsl r0, r0, #0x5
		lsr r0, r0, #0x5
		ldr r1, var
		strh r0, [r1]
		pop {r0-r1,pc}

.align 2

pokemon_data:
		.word 0x02024284 + 0x50
var:
		.word 0x020270B6 + (0x800D * 2)

Now, we want to replace all of our checking and returning stuff with this:

Code:
lsr r0, r0, #0x3				@Shift over initial sleeping bits (If there)
lsl r0, r0, #0x3				@Set it back
add r0, #0xyoursleepturns		@Add our number of sleeping turns
ldr r1, pokemon_data			@Load our writing destination
strh r0, [r1]				@store r0 in the address contained in r1

Our final result:

Code:
.align 2
.thumb
.global example1

main:
		push {r0-r1,lr}
		ldr r0, pokemon_data
		ldrb r0, [r0]
		lsr r0, r0, #0x3 
		lsl r0, r0, #0x3
		add r0, #0xyoursleepturns
		ldr r1, pokemon_data 
		strh r0, [r1] 
		pop {r0-r1,pc}

.align 2

pokemon_data:
		.word 0x02024284 + 0x50

Since I didn't need the var, I removed it :)
 

0m3GA ARS3NAL

Im comin' home...
1,816
Posts
16
Years
This pleases 0m3GA
Thanks, it makes more sense once I see a commented out routine.

Little ASM hacks like these are pretty easy now that I see it, but the bigger stuff, like Day and Night, and Havking the player's sprite to change it and keep it changed...
 

2RandomStudios

Angry Jigglypuff
76
Posts
13
Years
after much trial and error, I simply can't get the thumb.bat to work! it gives me errors such as "as.exe is missing" (which it isnt) and "can't compile example1_fr.asm the file does not exist" (which it does)
Please help!
 

forestw785

I divide by 0.
60
Posts
14
Years
  • Seen Dec 8, 2010
after much trial and error, I simply can't get the thumb.bat to work! it gives me errors such as "as.exe is missing" (which it isnt) and "can't compile example1_fr.asm the file does not exist" (which it does)
Please help!

I'm guessing you didn't route your cmd prompt to the folder with your ASM stuff.

If it's on your desktop, then how you route command prompt there would be:
xp: cd \Documents and Settings\(username for your computer)\Desktop\ASM
7/Vista: cd \Users\(username for your computer)\Desktop\ASM

And press enter, and then the command prompt is rerouted to your ASM folder.


My problems:
I follow your tutorial, and I get everything to work in the first two lessons with no problems, but even with your "explanations" I don't understand what these codes are actually doing. I'm basically just telling the ROM to behave a certain way without knowing how I'm making it behave that way.
Example:
  • What is a callasm?
  • What is buffernumber 0x0 lastresult

There are others too, and you even define them. An example of that would be:
.align 2-This aligns the ASM by a multiple of 2, since each instruction is 2 bytes long. (aligning the ASM does what exactly?, and a multiple of two what?)
push {r0-r1,lr}- This pushes registers r0, r1, and the link register into the stack. (what is {r0-r1,lr}? what is r0, r1, and lr?}

Look at it from someone else's perspective:
Gita monooto hon : These are words in another language, and they deal with sound.
Not specific enough, and provide no real understanding of the material, right?
 
Last edited:

2RandomStudios

Angry Jigglypuff
76
Posts
13
Years
I'm guessing you didn't route your cmd prompt to the folder with your ASM stuff.

If it's on your desktop, then how you route command prompt there would be:
xp: cd \Documents and Settings\(username for your computer)\Desktop\ASM
7/Vista: cd \Users\(username for your computer)\Desktop\ASM

And press enter, and then the command prompt is rerouted to your ASM folder.


My problems:
I follow your tutorial, and I get everything to work in the first two lessons with no problems, but even with your "explanations" I don't understand what these codes are actually doing. I'm basically just telling the ROM to behave a certain way without knowing how I'm making it behave that way.
Example:
  • What is a callasm?
  • What is buffernumber 0x0 lastresult

There are others too, and you even define them. An example of that would be:
.align 2-This aligns the ASM by a multiple of 2, since each instruction is 2 bytes long. (aligning the ASM does what exactly?, and a multiple of two what?)
push {r0-r1,lr}- This pushes registers r0, r1, and the link register into the stack. (what is {r0-r1,lr}? what is r0, r1, and lr?}

Look at it from someone else's perspective:
Gita monooto hon : These are words in another language, and they deal with sound.
Not specific enough, and provide no real understanding of the material, right?

I followed that step exactly and it tells me that "C:\Users\(name)\Desktop\ASM" is not a recognized command!
 

Shiny Quagsire

I'm Still Alive, Elsewhere
697
Posts
14
Years
I'm guessing you didn't route your cmd prompt to the folder with your ASM stuff.

If it's on your desktop, then how you route command prompt there would be:
xp: cd \Documents and Settings\(username for your computer)\Desktop\ASM
7/Vista: cd \Users\(username for your computer)\Desktop\ASM

And press enter, and then the command prompt is rerouted to your ASM folder.


My problems:
I follow your tutorial, and I get everything to work in the first two lessons with no problems, but even with your "explanations" I don't understand what these codes are actually doing. I'm basically just telling the ROM to behave a certain way without knowing how I'm making it behave that way.
Example:
  • What is a callasm?
  • What is buffernumber 0x0 lastresult

There are others too, and you even define them. An example of that would be:
.align 2-This aligns the ASM by a multiple of 2, since each instruction is 2 bytes long. (aligning the ASM does what exactly?, and a multiple of two what?)
push {r0-r1,lr}- This pushes registers r0, r1, and the link register into the stack. (what is {r0-r1,lr}? what is r0, r1, and lr?}

Look at it from someone else's perspective:
Gita monooto hon : These are words in another language, and they deal with sound.
Not specific enough, and provide no real understanding of the material, right?

Alright. It sounds like you havn't done too much scripting. Callasm calls a select routine from a script. It basically calls your ASM and returns. Call ASM. Buffernumber takes a number in a variable and stores it into a buffer such as [buffer1]. As for alignment, it makes sure the labels, and accessed data can are in addresses that are multiples of two.

ASM Book said:
A Simple Example
Boundaries are evenly divisible memory addresses. For example, an address that is aligned on a 4-BYTE (DWORD) boundary is evenly divisible by 4. The processor will always get it's data from DWORD boundaries and in DWORD sizes. So, if you had the following
1111 2222 3333 4444...
and you wanted to get the second DWORD, the processor would find it on an address divisible by 4 (a boundary) and get it in one fetch. However, if the data was misaligned like this
1122 2233 3344 4400...
and you wanted the same DWORD, the processor would
1. Get the first DWORD (FETCH 1)
2. Chop off the leftmost 3 bytes
3. Get the second DWORD (FETCH 2)
4. Chop off the rightmost 1 byte
5. Then put them both together.
This requires 2 memory fetches and takes longer to execute. This is how it applies to DWORDs as in the previous example. For word size values, there would be no change because the 2 bytes are available in the first pass in both cases. There are certain instructions that work better on 16-BYTE boundaries (such as movsd) and some that require it (some FPU instructions).

So basically it allows code to be acessed right and it helps the processor to be faster.

r0, r1, and lr are your variables. They are used to keep data for code, and then the data is used. Some times they hold addresses, data to be written, and arguments for other routines.
 

0m3GA ARS3NAL

Im comin' home...
1,816
Posts
16
Years
Thanks so much for the help. It works perfectly now!

Alternativly, you can go to

C:/Windows/System32/

Grab the CMD.exe file there and COPY it, then paste the copy in the folder with the as.exe file.

From then on all you've got to do is double click on the CMD.EXE and then go from there, no need to redirect it.
You can also put a shortcut onto the desktop for easy access.
 

SPG

Pyroblock
88
Posts
13
Years
  • Age 27
  • Seen May 4, 2013
quick question, how would i make a pokemon base stat go higherthan 255? i know this requirs asm and if i over looked it and its in this tut plz tell me so your time isn't wasted any more
 
Back
Top