System Calls - Tpot-SSL/GameComHDK GitHub Wiki
Intro
Because the Game.com always has the OS loaded in memory, it offers a bunch of functions to simplify various tasks; These are referred to as System Calls, and they function a lot like common C-style functions.
Function arguments are setup by setting registers 8-15 And registers 0-4 are set when a function has any returning values.
So if we take FBFillColor for example. Filling the framebuffer with black is as simple as:
mov r8, #3 ; color 3 is black.
call FBFillColor
If you're not using one of the existing templates, and would rather implement system calls manually, Here's how you would implement them:
System_Call equ 20f1h
; replace SC with System Call hex value (#1Bh for FBFillColor)
pushw rr6
mov r7,#SCh
br System_Call
Known System Calls
0x1B - FBFillColor
FUNCTION: Fills the framebuffer with a specified color
INPUT:
r8 = Color to fill with
OUTPUT: N/A
IMPLEMENTATION:
--------------------------------------------------
FBFillColor:
pushw rr6
mov r7,#1Bh
br System_Call
--------------------------------------------------
0x1D - FBDrawGraphic
FUNCTION: Draws specified graphics to the framebuffer
INPUT:
r8 = Horizontal framebuffer displacement
r9 = Vertical framebuffer displacement
r10 = Horizontal graphic offset displacement
r11 = Vertical graphic offset displacement
r12 = Horizontal graphic size
r13 = Vertical graphic size
r14 = Bank #
r15 = Drawing behavior (Boolean flags)
- 0x00 = Draw Absolute / Override
- 0x01 = Draw with white as Transparency
- 0x02 = Draw to Page B
- 0x04 = Draw to Current Page
- 0x08 = Draw in XOR mode
- 0x40 = Draw Vertical flipped
- 0x80 = Draw Horizontal flipped
OUTPUT: N/A
IMPLEMENTATION:
--------------------------------------------------
FBDrawGraphic:
pushw rr6
mov r7,#1Dh
br System_Call
--------------------------------------------------
0x26 - FBDrawLineV
FUNCTION: Draws a completely vertical line on-screen (draws from top to bottom)
INPUT:
r8 = Starting horizontal coordinate
r9 = Starting vertical coordinate
r10 = Line length
r11 = Color to draw line with
r12 = Line width
r13 = ??? (Look into what exactly this is)
- 0 = Line gets drawn
- 1 = Line does not get drawn
OUTPUT: N/A
IMPLEMENTATION:
--------------------------------------------------
FBDrawLineV:
pushw rr6
mov r7,#26h
br System_Call
--------------------------------------------------
0x27 - FBDrawLineH
FUNCTION: Draws a completely horizontal line on-screen (draws from left to right)
INPUT:
r8 = Starting horizontal coordinate
r9 = Starting vertical coordinate
r10 = Line length
r11 = Color to draw line with
r12 = Line width
r13 = ??? (Look into what exactly this is)
- 0 = Line gets drawn
- 1 = Line does not get drawn
OUTPUT: N/A
IMPLEMENTATION:
--------------------------------------------------
FBDrawLineH:
pushw rr6
mov r7,#27h
br System_Call
--------------------------------------------------
0x2E - FBFillColorRect
FUNCTION: Draws a block of a filled color on-screen
INPUT:
r10 = Horizontal block size
r11 = Vertical block size
r12 = Color to fill block with
OUTPUT: N/A
--------------------------------------------------
FBFillColorRect:
pushw rr6
mov r7,#2Eh
br System_Call
--------------------------------------------------
0x2F - IOInputScan
FUNCTION: Gets the player's input
INPUT: N/A
OUTPUT:
r0 = Player's inputted keys (document how this works better)
- 0x83 = Up
- 0x84 = Down
- 0x85 = Left
- 0x86 = Right
- 0x8B = A
- 0x8C = B
- 0x8D = C
- 0x8E = D
--------------------------------------------------
IOInputScan:
pushw rr6
mov r7,#2Fh
br System_Call
--------------------------------------------------
0x54 - FBPageB
FUNCTION: Switches to framebuffer B
INPUT: N/A
OUTPUT: N/A
--------------------------------------------------
FBSwapPage:
pushw rr6
mov r7,#54h
br System_Call
--------------------------------------------------
0x55 - FBPageA
FUNCTION: Switches to framebuffer A
INPUT: N/A
OUTPUT: N/A
--------------------------------------------------
FBSwapPage:
pushw rr6
mov r7,#55h
br System_Call
--------------------------------------------------
0x57 - FBSwapPage
FUNCTION: Switches the current, on-screen framebuffer page to render (A or B)
INPUT: N/A
OUTPUT: N/A
--------------------------------------------------
FBSwapPage:
pushw rr6
mov r7,#57h
br System_Call
--------------------------------------------------