Skip to content

Commit

Permalink
BETA-3
Browse files Browse the repository at this point in the history
 - Fixed V-sync in FUNCS
 - Added additional drawing functions
 - Added system calls, constants, and docs
 - Fixed PNG imports
 - Added limited emulator support
 - Improved Assembler gfx bank importer
  • Loading branch information
Tpot-SSL committed Mar 7, 2018
1 parent 6ab1988 commit 91b95dc
Show file tree
Hide file tree
Showing 9 changed files with 490 additions and 47 deletions.
161 changes: 160 additions & 1 deletion TpotSSL.GameComSuite/GCHDK/ASM/project/FUNCS.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,180 @@ ReadInput:
; Subroutine to wait for a vertical interrupt
; ===========================================================================
WaitForVInt:
pushw rr2 ; store rr2 onto the stack
push r0 ; store r0 onto the stack
push r1 ; store r1 onto the stack

mov r0, 0112h ; load the DMG_timer into rr2
movw rr2,#0112h ; load the DMG_timer into rr2
mov r1, prevVtick ; load the previous V-Int tick into r1
WaitForVInt_Wait:
mov r0, 0(rr2) ; load the value of the timer into r0
cmp r0, r1 ; is the timer on the same tick as before?
br eq, WaitForVInt_Wait ; if so, loop and wait
mov prevVtick,r0 ; store the new V-Int tick

pop r1 ; restore r1 from the stack
pop r0 ; restore r0 from the stack
popw rr2 ; restore rr2 from the stack
ret ; return
StrCharY equ 224
StrCharBank equ 39
StrCharWid equ 6
StrCharHgt equ 6

; ===========================================================================
; Subroutine to write a character on screen.
; Input:
; rr0 = String's address
; r8 = String's X-position
; r9 = String's Y-position
; ===========================================================================
FBDrawChar:
mov r11, r10
mov r10, #0
mult rr10, #StrCharWid
mov r10, r11
mov r11, #StrCharY
mov r12, #StrCharWid
mov r13, #StrCharHgt
mov r14, #StrCharBank
mov r15, #01h
cmp currPage,#1
call FBDrawGraphic
ret

; ===========================================================================
; Subroutine to write a character on screen with XOR-mode
; Input:
; rr0 = String's address
; r8 = String's X-position
; r9 = String's Y-position
; ===========================================================================
FBDrawCharX:
mov r11, r10
mov r10, #0
mult rr10, #StrCharWid
mov r10, r11
mov r11, #StrCharY
mov r12, #StrCharWid
mov r13, #StrCharHgt
mov r14, #StrCharBank
mov r15, #01h
cmp currPage,#1
br eq, FBDrawCharX_1
add r15, #02h
FBDrawCharX_1:
call FBDrawGraphic
cmp r0, #36 ; is the character a space?
br eq, FBDrawCharX_END ; if so, don't do the extra XORing
add r11, #12
mov r15, #09h
cmp currPage,#1
br eq, FBDrawCharX_2
add r15, #02h
FBDrawCharX_2:
call FBDrawGraphic
FBDrawCharX_END:
ret
; ===========================================================================
; Subroutine to write a string on screen
; Input:
; rr0 = String's address
; r8 = String's X-position
; r9 = String's Y-position
; ===========================================================================
FBDrawString:
DrwStr_Chr:
mov r0, (rr2)+
cmp r0, #0FFh ; is the character a terminator?
br eq, DrwStr_END ; if so, branch
cmp r0, #020h ; is the character a space?
br eq, DrwStr_Spc ; if so, branch
cmp r0, #041h ; is the character from the alphabet?
br uge,DrwStr_Alph ; if so, branch
cmp r0, #030h ; is the character numeric?
br uge,DrwStr_Num ; if so, branch
jmp DrwStr_END ; otherwise, panic and leave
DrwStr_Spc:
mov r0, #36
br DrwStr_Do
DrwStr_Num:
cmp r0, #039h ; is the character numeric? (checking for 9)
br ugt,DrwStr_END ; if not, panic and leave
sub r0, #030h
br DrwStr_Do
DrwStr_Alph:
cmp r0, #05Ah ; is the character from the alphabet? (checking for Z)
br ugt,DrwStr_END ; if not, panic and leave
sub r0, #037h
br DrwStr_Do

DrwStr_Do:
mov r10,r0
call FBDrawChar ; otherwise, draw the character

DrwStr_NxtChr:
add r8, #6 ; increase the X-position for the next character
br DrwStr_Chr
DrwStr_END:
ret
; ===========================================================================
; Subroutine to write a string on screen using XOR-mode for 4-colors + alpha.
; Input:
; rr0 = String's address
; r8 = String's X-position
; r9 = String's Y-position
; ===========================================================================
FBDrawStringX:
DrwStrX_Chr:
mov r0, (rr2)+
cmp r0, #0FFh ; is the character a terminator?
br eq, DrwStrX_END ; if so, branch
cmp r0, #020h ; is the character a space?
br eq, DrwStrX_Spc ; if so, branch
cmp r0, #041h ; is the character from the alphabet?
br uge,DrwStrX_Alph ; if so, branch
cmp r0, #030h ; is the character numeric?
br uge,DrwStrX_Num ; if so, branch
jmp DrwStrX_END ; otherwise, panic and leave
DrwStrX_Spc:
mov r0, #36
br DrwStrX_Do
DrwStrX_Num:
cmp r0, #039h ; is the character numeric? (checking for 9)
br ugt,DrwStrX_END ; if not, panic and leave
sub r0, #030h
br DrwStrX_Do
DrwStrX_Alph:
cmp r0, #05Ah ; is the character from the alphabet? (checking for Z)
br ugt,DrwStrX_END ; if not, panic and leave
sub r0, #037h
br DrwStrX_Do

DrwStrX_Do:
mov r10,r0
call FBDrawCharX ; otherwise, draw the character

DrwStrX_NxtChr:
add r8, #6 ; increase the X-position for the next character
br DrwStrX_Chr
DrwStrX_END:
ret
; ===========================================================================
end
; ===========================================================================
72 changes: 58 additions & 14 deletions TpotSSL.GameComSuite/GCHDK/ASM/project/SYSCALL.ASM
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,19 @@ SystemCall equ 20f1h
global FBDrawLineH
global FBFillColorRect
global IOInputScan

global FBSwapBuffer
global FBBufferA
global FBBufferB
; FBDrawGraphic flag constants
FBConDGAbs equ 00h ; Draw Absolute / Override
FBConDGTrans equ 01h ; Draw with white as Transparency
FBConDGPageB equ 02h ; Draw to Page B
FBConDGPageCur equ 04h ; Draw to Current Page
FBConDGXor equ 08h ; Draw in XOR mode
FBConDGFlipV equ 40h ; Draw Vertical flipped
FBConDGFlipH equ 80h ; Draw Horizontal flipped
; Extended System Calls
global FBDrawGraphicF
Expand Down Expand Up @@ -53,12 +65,16 @@ FBFillColor:
; r10 = Horizontal graphic offset displacement
; r11 = Vertical graphic offset displacement
; r12 = Horizontal graphic size
; r13 = Verical graphic size
; r13 = Vertical graphic size
; r14 = Bank #
; r15 = Drawing behavior
; - 0 = Completely overwrite
; - 1 = Pixel color 0 is transparent (lightest grey)
; - 8 = XOR mode (???)
; 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
; ===========================================================================
FBDrawGraphic:
Expand Down Expand Up @@ -124,26 +140,54 @@ IOInputScan:
mov r7,#2fh
jmp SystemCall
; ===========================================================================
; 0x54 - FBPageB
; FUNCTION: Switches to framebuffer B
; INPUT: N/A
; OUTPUT: N/A
; ===========================================================================
FBPageB:
pushw rr6
mov r7,#54h
jmp SystemCall
; ===========================================================================
; 0x55 - FBPageA
; FUNCTION: Switches to framebuffer A
; INPUT: N/A
; OUTPUT: N/A
; ===========================================================================
FBPageA:
pushw rr6
mov r7,#55h
jmp SystemCall
; ===========================================================================
; 0x57 - FBSwapPage
; FUNCTION: Switches the current, on-screen framebuffer page to render (A or B)
; INPUT: N/A
; OUTPUT: N/A
; ===========================================================================
FBDrawGraphic2:
FBSwapPage:
pushw rr6
mov r7,#56h
mov r7,#57h
jmp SystemCall
; ===========================================================================
; 0x1D - FBDrawGraphicf
; Extra - FBDrawGraphicF
; FUNCTION: Draws specified graphics to the framebuffer using the fadeStep
; INPUT:
; r8 = Horizontal framebuffer displacement
; r9 = Vertical framebuffer displacement
; r10 = Horizontal graphic offset displacement
; r11 = Vertical graphic offset displacement
; r12 = Horizontal graphic size
; r13 = Verical graphic size
; r13 = Vertical graphic size
; r14 = Bank #
; r15 = Drawing behavior
; - 0 = Completely overwrite
; - 1 = Pixel color 0 is transparent (lightest grey)
; - 8 = XOR mode (???)
; 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
; ===========================================================================
FBDrawGraphicF:
Expand Down
12 changes: 12 additions & 0 deletions TpotSSL.GameComSuite/GCHDK/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="TpotSSL.GameComTools.GCHDK.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<userSettings>
<TpotSSL.GameComTools.GCHDK.Properties.Settings>
<setting name="EmulatorLocation" serializeAs="String">
<value />
</setting>
</TpotSSL.GameComTools.GCHDK.Properties.Settings>
</userSettings>
</configuration>
Loading

0 comments on commit 91b95dc

Please sign in to comment.