This is an old revision of the document!
When selecting a texture it is similar to C but is far more simplified. Normally, in C you would do the following:
#define Texture 0
In asm this translates to the following:
mov R7, 0 out GPU_SelectedTexture, R7
What is happening in the above snip of code is that we are putting in our number ID for our texture into register 7 and then feeding R7 into the GPU_SelectedTexture.
After you have successfully selected your texture you need to select a region inside your texture file. To accomplish this in asm you are repeating similar steps as to selecting a texture. Here is a sample of what that would look like:
mov R7, 1 out GPU_SelectedRegion, R7
Similarly to above, we are putting the id for a region into R7 and then feeding R7 into GPU_SelectedRegion.
To display your regions you have to say where you want to display the region. That is done by putting in values for X and Y into 2 different registers. Here is what that looks like:
mov R2, 20 ; X coordinate mov R3, 40 ; Y coordinate
First off you want to select the gamepad. The best way to do this would be:
mov R0, 0 out INP_SelectedGamepad, R0
this would select gamepad 0 for the currently selected gamepad.
Next you would want to make your gamepad direction functions and read into them the current gamepad direction. The best way to do this would be:
__left: ;Left Function in R10, INP_GamepadLeft ;Gamepad state is loaded into R10 and will return a value mov R4, 0 ;Put 0 into R4 to rest its value ilt R4, R10 ;If R4 < R10 jf R4, __right ;If it is false then go to the right function mov R8, 1 ;Assigning region value that will print the region you want to print when going left isub R2, 1 ;If it is true then subtract one value from R2 which would be the sprites X
When you reach the last direction instead of putting
jf R4, __direction
You should do:
jf R4, __function_gamepad_direction_return
or whatever the end of your function or loop is called. As long as you don't modify R2 between now and using R2 to in printing your texture then it will print at R2.
Implemented from scratch, in assembly: