_startAddress_ EQU 0x0200 ; Internal Variables serialRawPrev EQU 0x0081 register0 EQU 0x0082 register1 EQU register0 + 0x02 register2 EQU register0 + 0x04 register3 EQU register0 + 0x06 register4 EQU register0 + 0x08 register5 EQU register0 + 0x0A register6 EQU register0 + 0x0C register7 EQU register0 + 0x0E register8 EQU register0 + 0x10 register9 EQU register0 + 0x12 register10 EQU register0 + 0x14 register11 EQU register0 + 0x16 register12 EQU register0 + 0x18 register13 EQU register0 + 0x1A register14 EQU register0 + 0x1C register15 EQU register0 + 0x1E fgbgColour EQU register0 + 0x20 cursorXY EQU register0 + 0x22 midiStream EQU register0 + 0x24 midiDelay EQU register0 + 0x26 miscFlags EQU register0 + 0x28 timerTick EQU register0 + 0x2A timerPrev EQU register0 + 0x2C ; Internal Constants ENABLE_SCROLL_BIT EQU 0x0001 ON_BOTTOM_ROW_BIT EQU 0x0002 DISABLE_CLIP_BIT EQU 0x0004 ENABLE_SCROLL_MSK EQU 0xfffe ON_BOTTOM_ROW_MSK EQU 0xfffd DISABLE_CLIP_MSK EQU 0xfffb ; Internal Buffers regsWorkArea EQU 0x0000 textWorkArea EQU 0x7fa0 ; Includes %includePath "../../at67/gbas/runtime" %include util.i %include gigatron.i %include macros.i ; Labels _entryPoint_ EQU 0x0200 _loop EQU 0x028f _handleInput EQU 0x02aa _comeOutPhase EQU 0x0478 _pointPhase EQU 0x0cbc _win EQU 0x11e3 _gameOverInput EQU 0x12a4 _displayGameOver EQU 0x12ec _playSndAlert EQU 0x14c7 _playSndRollDice EQU 0x15b8 _playSndLose EQU 0x16a9 _playSndBet EQU 0x16ef _playSndWin EQU 0x17c9 _getRomNote EQU 0x18eb _drawBetText EQU 0x19ac _drawTable EQU 0x19ef _drawDice EQU 0x1bba _displayBalance EQU 0x2df7 _updateBalance EQU 0x31bd _displayBet EQU 0x32f2 _else_0x02aa EQU 0x02a3 _endif_0x02af EQU 0x02a8 _endif_0x02f4 EQU 0x02dd _endif_0x0307 EQU 0x02f0 _page_0x0300 EQU 0x0300 _endif_0x0343 EQU 0x032e _endif_0x0356 EQU 0x0341 _endif_0x03d4 EQU 0x03b3 _endif_0x0410 EQU 0x03e3 _page_0x0400 EQU 0x0400 _endif_0x0457 EQU 0x0429 _endif_0x0472 EQU 0x0442 _endif_0x04b2 EQU 0x0476 _page_0x0500 EQU 0x0500 _elseif_0x05f6 EQU 0x05b8 _page_0x0600 EQU 0x0600 _elseif_0x0686 EQU 0x064e _elseif_0x0717 EQU 0x06db _page_0x08a0 EQU 0x08a0 _page_0x09a0 EQU 0x09a0 _elseif_0x07a8 EQU 0x09bf _page_0x0aa0 EQU 0x0aa0 _page_0x0ba0 EQU 0x0ba0 _else_0x0839 EQU 0x0ba2 _page_0x0ca0 EQU 0x0ca0 _endif_0x08a6 EQU 0x0cba _page_0x0da0 EQU 0x0da0 _page_0x0ea0 EQU 0x0ea0 _page_0x0fa0 EQU 0x0fa0 _elseif_0x09ad EQU 0x0fba _page_0x10a0 EQU 0x10a0 _else_0x0a3e EQU 0x10f1 _page_0x11a0 EQU 0x11a0 _endif_0x0a83 EQU 0x11e1 _page_0x12a0 EQU 0x12a0 _endif_0x0aee EQU 0x12ea _page_0x13a0 EQU 0x13a0 _page_0x14a0 EQU 0x14a0 _page_0x15a0 EQU 0x15a0 _page_0x16a0 EQU 0x16a0 _page_0x17a0 EQU 0x17a0 _page_0x18a0 EQU 0x18a0 _page_0x19a0 EQU 0x19a0 _page_0x1aa0 EQU 0x1aa0 _page_0x1ba0 EQU 0x1ba0 _page_0x1ca0 EQU 0x1ca0 _elseif_0x0e8a EQU 0x1cf1 _page_0x1da0 EQU 0x1da0 _elseif_0x0efb EQU 0x1de9 _page_0x1ea0 EQU 0x1ea0 _page_0x1fa0 EQU 0x1fa0 _elseif_0x0f99 EQU 0x1fac _page_0x20a0 EQU 0x20a0 _elseif_0x1064 EQU 0x20dd _page_0x21a0 EQU 0x21a0 _page_0x22a0 EQU 0x22a0 _else_0x115c EQU 0x22d7 _page_0x23a0 EQU 0x23a0 _page_0x24a0 EQU 0x24a0 _endif_0x126a EQU 0x24da _page_0x25a0 EQU 0x25a0 _page_0x26a0 EQU 0x26a0 _elseif_0x1326 EQU 0x26ba _page_0x27a0 EQU 0x27a0 _elseif_0x1397 EQU 0x27b2 _page_0x28a0 EQU 0x28a0 _elseif_0x1435 EQU 0x28c9 _page_0x29a0 EQU 0x29a0 _page_0x2aa0 EQU 0x2aa0 _elseif_0x1500 EQU 0x2aa4 _page_0x2ba0 EQU 0x2ba0 _else_0x15f8 EQU 0x2bf2 _page_0x2ca0 EQU 0x2ca0 _page_0x2da0 EQU 0x2da0 _endif_0x1706 EQU 0x2df5 _page_0x2ea0 EQU 0x2ea0 _elseif_0x175d EQU 0x2ef2 _page_0x2fa0 EQU 0x2fa0 _elseif_0x17a9 EQU 0x2fe6 _page_0x30a0 EQU 0x30a0 _else_0x17f6 EQU 0x30da _page_0x31a0 EQU 0x31a0 _endif_0x182d EQU 0x31bb _page_0x32a0 EQU 0x32a0 _endif_0x189d EQU 0x32cd _endif_0x18ab EQU 0x32db _endif_0x18c4 EQU 0x32f0 _page_0x33a0 EQU 0x33a0 _elseif_0x191b EQU 0x33ee _page_0x34a0 EQU 0x34a0 _else_0x1967 EQU 0x34e6 _page_0x35a0 EQU 0x35a0 _endif_0x199e EQU 0x35cc ; Constants _GAMEOVER EQU 0x0000 _BET EQU 0x0001 _COMEOUT EQU 0x0002 _POINT EQU 0x0003 _NEWGAME EQU 0x0004 _NEXTROUND EQU 0x0005 _tableX EQU 0x0003 _tableY EQU 0x0028 ; Global Variables _dice1Value EQU 0x0030 _dice1X EQU 0x0032 _dice1Y EQU 0x0034 _dice2Value EQU 0x0036 _dice2X EQU 0x0038 _dice2Y EQU 0x003a _balance EQU 0x003c _betAmount EQU 0x003e _winAmount EQU 0x0040 _currentRound EQU 0x0042 _rollPoint EQU 0x0044 _tempRoll EQU 0x0046 _inputDevice EQU 0x0048 _note EQU 0x004a _notes EQU 0x004c _index EQU 0x004e ; Local Variables ; Arrays ; Strings ; Constant Strings _str_0x7df5 EQU 0x7df5 _str_0x7df5 DB 9 ' ' 0 _str_0x7de8 EQU 0x7de8 _str_0x7de8 DB 11 'You rolled:' 0 _str_0x7dda EQU 0x7dda _str_0x7dda DB 12 'Lucky Seven!' 0 _str_0x7dc7 EQU 0x7dc7 _str_0x7dc7 DB 17 'You won the roll!' 0 _str_0x7db0 EQU 0x7db0 _str_0x7db0 DB 21 'Play again (A) or (B)' 0 _str_0x7da5 EQU 0x7da5 _str_0x7da5 DB 9 'Yo-leven!' 0 _str_0x7cf3 EQU 0x7cf3 _str_0x7cf3 DB 11 'Snake Eyes!' 0 _str_0x7cdf EQU 0x7cdf _str_0x7cdf DB 18 'You lost the roll!' 0 _str_0x7cd1 EQU 0x7cd1 _str_0x7cd1 DB 12 'Craps Three!' 0 _str_0x7cc7 EQU 0x7cc7 _str_0x7cc7 DB 8 'Boxcars!' 0 _str_0x7cb7 EQU 0x7cb7 _str_0x7cb7 DB 14 'The point is: ' 0 _str_0x7ca1 EQU 0x7ca1 _str_0x7ca1 DB 20 'Roll Dice (A) or (B)' 0 _str_0x7be8 EQU 0x7be8 _str_0x7be8 DB 22 ' ' 0 _str_0x7bdc EQU 0x7bdc _str_0x7bdc DB 10 'Seven Out!' 0 _str_0x7bcd EQU 0x7bcd _str_0x7bcd DB 13 'You\'re broke!' 0 _str_0x7bbb EQU 0x7bbb _str_0x7bbb DB 16 'Press (A) or (B)' 0 _str_0x7ba6 EQU 0x7ba6 _str_0x7ba6 DB 19 'Enter Bet (Up/Down)' 0 _str_0x7af2 EQU 0x7af2 _str_0x7af2 DB 12 'Gigatron TTL' 0 _str_0x7ae9 EQU 0x7ae9 _str_0x7ae9 DB 7 'Bal:000' 0 _str_0x7ae1 EQU 0x7ae1 _str_0x7ae1 DB 6 'Bal:00' 0 _str_0x7ada EQU 0x7ada _str_0x7ada DB 5 'Bal:0' 0 _str_0x7ba0 EQU 0x7ba0 _str_0x7ba0 DB 4 'Bal:' 0 _str_0x7ad4 EQU 0x7ad4 _str_0x7ad4 DB 4 'Win:' 0 _str_0x7acc EQU 0x7acc _str_0x7acc DB 6 'Bet:00' 0 _str_0x7ac5 EQU 0x7ac5 _str_0x7ac5 DB 5 'Bet:0' 0 _str_0x7abf EQU 0x7abf _str_0x7abf DB 4 'Bet:' 0 ; Data ; Time ; Define Bytes ; Define Words ; Define Images ; Define Loader Image Chunks ; Define Midis ; Define Sprites ; Define Fonts ; Lookup Tables ; Code _entryPoint_ LDI 0x28 STW romType RomCheck Initialise InitEqOp ; INIT ClearVertBlinds LDI 2 STW graphicsMode ScanlineMode ; cls : mode 2 LD 0x21 ORI 0x0003 ST 33 ; poke &h21, peek(&h21) OR 3 SoundAllOff ; sound off ClearVertBlinds ; cls LDI 1 STW _dice1Value ; dice1Value = 1 LDI 20 STW _dice1X ; dice1X = 20 LDI 50 STW _dice1Y ; dice1Y = 50 LDI 1 STW _dice2Value ; dice2Value = 1 LDI 100 STW _dice2X ; dice2X = 100 LDI 65 STW _dice2Y ; dice2Y = 65 LDI 100 STW _balance ; balance = 100 LDI 25 STW _betAmount ; betAmount = 25 LDI 0 STW _winAmount ; winAmount = 0 LDI 1 STW _currentRound ; currentRound = BET LDI 6 STW _rollPoint ; rollPoint = 6 LDI 6 STW _tempRoll ; tempRoll = 6 LDI 255 STW _inputDevice ; inputDevice = 255 LDI 0 ST fgbgColour ; set BG_COLOUR, 0 ClearVertBlinds ; cls LDWI _drawTable CALL giga_vAC ; gosub drawTable LDWI _displayBalance CALL giga_vAC ; gosub displayBalance LDWI _displayBet CALL giga_vAC ; gosub displayBet LDWI _drawBetText CALL giga_vAC ; gosub drawBetText _loop LDW _currentRound JumpEQ _else_0x02aa 0 ; if currentRound &= GAMEOVER LDWI _gameOverInput CALL giga_vAC LDWI _endif_0x02af CALL giga_vAC ; gosub gameOverInput _else_0x02aa LDWI _handleInput CALL giga_vAC ; gosub handleInput _endif_0x02af BRA _loop ; goto &loop _handleInput PUSH LD giga_buttonState STW _inputDevice ; inputDevice = get("BUTTON_STATE") LDW _inputDevice XORI 247 CALL convertEqOpAddr STW 0xe8 LDW _currentRound XORI 1 CALL convertEqOpAddr ANDW 0xe8 JumpFalse _endif_0x0307 3 ; if (inputDevice = 247) AND (currentRound = BET) LDW _betAmount ADDI 25 STW _betAmount ; betAmount = betAmount + 25 LDW _betAmount SUBI 100 JumpGT _endif_0x02f4 2 ; if betAmount &> 100 LDI 25 STW _betAmount ; betAmount = 25 _endif_0x02f4 LDWI _displayBet CALL giga_vAC ; gosub displayBet LDWI _playSndBet CALL giga_vAC ; gosub playSndBet LDI 10 STW waitVBlankNum WaitVBlanks ; wait 10 _endif_0x0307 LDW _inputDevice STLW 0xFE LDWI _page_0x0300 CALL giga_vAC _page_0x0300 LDLW 0xFE XORI 251 CALL convertEqOpAddr STW 0xe8 LDW _currentRound XORI 1 CALL convertEqOpAddr ANDW 0xe8 JumpFalse _endif_0x0356 5 ; if (inputDevice = 251) AND (currentRound = BET) LDW _betAmount SUBI 25 STW _betAmount ; betAmount = betAmount - 25 LDW _betAmount SUBI 25 JumpLT _endif_0x0343 4 ; if betAmount &< 25 LDI 100 STW _betAmount ; betAmount = 100 _endif_0x0343 LDWI _displayBet CALL giga_vAC ; gosub displayBet LDWI _playSndBet CALL giga_vAC ; gosub playSndBet LDI 10 STW waitVBlankNum WaitVBlanks ; wait 10 _endif_0x0356 LDW _inputDevice XORI 191 CALL convertEqOpAddr STW 0xe8 LDW _inputDevice XORI 127 CALL convertEqOpAddr ORW 0xe8 STW 0xea LDW _currentRound XORI 5 CALL convertEqOpAddr ANDW 0xea JumpFalse _endif_0x03d4 6 ; if (inputDevice = 191 OR inputDevice = 127) AND (currentRound = NEXTROUND) LDWI _playSndAlert CALL giga_vAC ; gosub playSndAlert LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 0 ST fgbgColour + 1 ; set FG_COLOUR, 0 LDI 0 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7df5 NewLine ; at 0,110 : print " " LDI 10 STW drawRectF_x1 LDI 10 STW drawRectF_y1 LDI 140 STW drawRectF_x2 LDI 35 STW drawRectF_y2 DrawRectF ; rectf 10, 10, 140, 35 LDWI _drawBetText CALL giga_vAC ; gosub drawBetText LDI 4 STW _currentRound ; currentRound = NEWGAME LDI 10 STW waitVBlankNum WaitVBlanks ; wait 10 _endif_0x03d4 LDW _inputDevice XORI 191 CALL convertEqOpAddr STW 0xe8 LDW _inputDevice XORI 127 CALL convertEqOpAddr ORW 0xe8 STW 0xea LDW _currentRound XORI 3 CALL convertEqOpAddr ANDW 0xea JumpFalse _endif_0x0410 7 ; if (inputDevice = 191 OR inputDevice = 127) AND (currentRound = POINT) LDWI _pointPhase CALL giga_vAC ; gosub pointPhase LDI 10 STW waitVBlankNum WaitVBlanks ; wait 10 _endif_0x0410 LDW _inputDevice XORI 191 CALL convertEqOpAddr STW 0xe8 LDW _inputDevice XORI 127 CALL convertEqOpAddr ORW 0xe8 STLW 0xFE LDWI _page_0x0400 CALL giga_vAC _page_0x0400 LDLW 0xFE STW 0xea LDW _currentRound XORI 1 CALL convertEqOpAddr ANDW 0xea JumpFalse _endif_0x0472 9 ; if (inputDevice = 191 OR inputDevice = 127) AND (currentRound = BET) LDW _betAmount SUBW _balance JumpGT _endif_0x0457 8 ; if betAmount &> balance LDW _balance STW _betAmount ; betAmount = balance LDWI _displayBet CALL giga_vAC ; gosub displayBet _endif_0x0457 LDW _balance SUBW _betAmount STW _balance ; balance = balance - betAmount LDWI _displayBalance CALL giga_vAC ; gosub displayBalance LDWI _comeOutPhase CALL giga_vAC ; gosub comeOutPhase LDI 10 STW waitVBlankNum WaitVBlanks ; wait 10 _endif_0x0472 LDW _inputDevice XORI 191 CALL convertEqOpAddr STW 0xe8 LDW _inputDevice XORI 127 CALL convertEqOpAddr ORW 0xe8 STW 0xea LDW _currentRound XORI 4 CALL convertEqOpAddr ANDW 0xea JumpFalse _endif_0x04b2 10 ; if (inputDevice = 191 OR inputDevice = 127) AND (currentRound = NEWGAME) LDWI _drawTable CALL giga_vAC ; gosub drawTable LDI 1 STW _currentRound ; currentRound = BET LDI 10 STW waitVBlankNum WaitVBlanks ; wait 10 _endif_0x04b2 Return ; return _comeOutPhase PUSH LDWI _playSndRollDice CALL giga_vAC ; gosub playSndRollDice LDI 0x06 RandMod ADDI 1 STW _dice1Value ; dice1Value = rnd(6) + 1 LDI 0x06 RandMod ADDI 1 STW _dice2Value ; dice2Value = rnd(6) + 1 LDW _dice1Value ADDW _dice2Value STW _rollPoint ; rollPoint = (dice1Value + dice2Value) LDWI _drawTable CALL giga_vAC ; gosub drawTable LDWI _drawDice CALL giga_vAC ; gosub drawDice LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 0 ST fgbgColour + 1 ; set FG_COLOUR, 0 LDI 0 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7df5 NewLine ; at 0,110 : print " " LDI 10 STW drawRectF_x1 LDI 10 STW drawRectF_y1 LDI 140 STW drawRectF_x2 LDI 35 STW drawRectF_y2 DrawRectF ; rectf 10, 10, 140, 35 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 10 ST cursorXY + 1 AtTextCursor STLW 0xFE LDWI _page_0x0500 CALL giga_vAC _page_0x0500 LDLW 0xFE PrintString _str_0x7de8 NewLine ; at 10,10 : print "You rolled:" LDI 78 ST cursorXY LDI 10 ST cursorXY + 1 AtTextCursor LDW _rollPoint PrintAcInt16 NewLine ; at 78,10 : print rollPoint LDW _rollPoint XORI 7 JumpEQ _elseif_0x05f6 11 ; if rollPoint &= 7 LDI 12 ST fgbgColour + 1 ; set FG_COLOUR, 12 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7dda NewLine ; at 10,25 : print "Lucky Seven!" LDI 100 STW waitVBlankNum WaitVBlanks ; wait 100 LDWI _win CALL giga_vAC ; gosub win LDI 12 ST fgbgColour + 1 ; set FG_COLOUR, 12 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7dc7 NewLine ; at 10,25 : print "You won the roll!" LDI 200 STW waitVBlankNum WaitVBlanks ; wait 200 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7db0 NewLine ; at 10,25 : print "Play again (A) or (B)" LDI 5 STW _currentRound LDWI _endif_0x08a6 CALL giga_vAC ; currentRound = NEXTROUND _elseif_0x05f6 LDW _rollPoint XORI 11 JumpEQ _elseif_0x0686 12 ; elseif rollPoint &= 11 LDI 12 ST fgbgColour + 1 ; set FG_COLOUR, 12 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7da5 NewLine ; at 10,25 : print "Yo-leven!" LDI 100 STW waitVBlankNum WaitVBlanks ; wait 100 LDWI _win CALL giga_vAC ; gosub win LDI 12 ST fgbgColour + 1 ; set FG_COLOUR, 12 LDI 10 STLW 0xFE LDWI _page_0x0600 CALL giga_vAC _page_0x0600 LDLW 0xFE ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7dc7 NewLine ; at 10,25 : print "You won the roll!" LDI 200 STW waitVBlankNum WaitVBlanks ; wait 200 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7db0 NewLine ; at 10,25 : print "Play again (A) or (B)" LDI 5 STW _currentRound LDWI _endif_0x08a6 CALL giga_vAC ; currentRound = NEXTROUND _elseif_0x0686 LDW _rollPoint XORI 2 JumpEQ _elseif_0x0717 13 ; elseif rollPoint &= 2 LDI 3 ST fgbgColour + 1 ; set FG_COLOUR, 3 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7cf3 NewLine ; at 10,25 : print "Snake Eyes!" LDI 100 STW waitVBlankNum WaitVBlanks ; wait 100 LDWI _playSndLose CALL giga_vAC ; gosub playSndLose LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7cdf NewLine ; at 10,25 : print "You lost the roll!" LDI 200 STW waitVBlankNum WaitVBlanks ; wait 200 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7db0 NewLine ; at 10,25 : print "Play again (A) or (B)" LDI 5 STW _currentRound ; currentRound = NEXTROUND LDWI _updateBalance CALL giga_vAC LDWI _endif_0x08a6 CALL giga_vAC ; gosub updateBalance _elseif_0x0717 LDW _rollPoint XORI 3 JumpEQ _elseif_0x07a8 14 ; elseif rollPoint &= 3 LDI 3 ST fgbgColour + 1 ; set FG_COLOUR, 3 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor STLW 0xFE LDWI _page_0x08a0 CALL giga_vAC _page_0x08a0 LDLW 0xFE PrintString _str_0x7cd1 NewLine ; at 10,25 : print "Craps Three!" LDI 100 STW waitVBlankNum WaitVBlanks ; wait 100 LDWI _playSndLose CALL giga_vAC ; gosub playSndLose LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7cdf NewLine ; at 10,25 : print "You lost the roll!" LDI 200 STW waitVBlankNum WaitVBlanks ; wait 200 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor STLW 0xFE LDWI _page_0x09a0 CALL giga_vAC _page_0x09a0 LDLW 0xFE PrintString _str_0x7db0 NewLine ; at 10,25 : print "Play again (A) or (B)" LDI 5 STW _currentRound ; currentRound = NEXTROUND LDWI _updateBalance CALL giga_vAC LDWI _endif_0x08a6 CALL giga_vAC ; gosub updateBalance _elseif_0x07a8 LDW _rollPoint XORI 12 JumpEQ _else_0x0839 15 ; elseif rollPoint &= 12 LDI 3 ST fgbgColour + 1 ; set FG_COLOUR, 3 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7cc7 NewLine ; at 10,25 : print "Boxcars!" LDI 100 STW waitVBlankNum WaitVBlanks ; wait 100 LDWI _playSndLose STLW 0xFE LDWI _page_0x0aa0 CALL giga_vAC _page_0x0aa0 LDLW 0xFE CALL giga_vAC ; gosub playSndLose LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7cdf NewLine ; at 10,25 : print "You lost the roll!" LDI 200 STW waitVBlankNum WaitVBlanks ; wait 200 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7db0 NewLine ; at 10,25 : print "Play again (A) or (B)" LDI 5 STW _currentRound ; currentRound = NEXTROUND LDWI _updateBalance CALL giga_vAC LDWI _endif_0x08a6 CALL giga_vAC ; gosub updateBalance STLW 0xFE LDWI _page_0x0ba0 CALL giga_vAC _page_0x0ba0 LDLW 0xFE _else_0x0839 LDI 50 STW waitVBlankNum WaitVBlanks ; wait 50 LDWI _playSndAlert CALL giga_vAC ; gosub playSndAlert LDI 3 STW _currentRound ; currentRound = POINT LDI 15 ST fgbgColour + 1 ; set FG_COLOUR, 15 LDI 10 ST cursorXY LDI 10 ST cursorXY + 1 AtTextCursor PrintString _str_0x7cb7 NewLine ; at 10,10 : print "The point is: " LDI 90 ST cursorXY LDI 10 ST cursorXY + 1 AtTextCursor LDW _rollPoint PrintAcInt16 NewLine ; at 90,10 : print rollPoint LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY STLW 0xFE LDWI _page_0x0ca0 CALL giga_vAC _page_0x0ca0 LDLW 0xFE LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ca1 NewLine ; at 10,25 : print "Roll Dice (A) or (B)" _endif_0x08a6 Return ; return _pointPhase PUSH LDWI _playSndRollDice CALL giga_vAC ; gosub playSndRollDice LDI 0x06 RandMod ADDI 1 STW _dice1Value ; dice1Value = rnd(6) + 1 LDI 0x06 RandMod ADDI 1 STW _dice2Value ; dice2Value = rnd(6) + 1 LDW _dice1Value ADDW _dice2Value STW _tempRoll ; tempRoll = (dice1Value + dice2Value) LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor STLW 0xFE LDWI _page_0x0da0 CALL giga_vAC _page_0x0da0 LDLW 0xFE PrintString _str_0x7be8 NewLine ; at 10,25 : print " " LDWI _drawTable CALL giga_vAC ; gosub drawTable LDWI _drawDice CALL giga_vAC ; gosub drawDice LDW _tempRoll XORW _rollPoint JumpEQ _elseif_0x09ad 17 ; if tempRoll &= rollPoint LDI 12 ST fgbgColour + 1 ; set FG_COLOUR, 12 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7de8 NewLine ; at 10,25 : print "You rolled:" LDI 78 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor LDW _tempRoll STLW 0xFE LDWI _page_0x0ea0 CALL giga_vAC _page_0x0ea0 LDLW 0xFE PrintAcInt16 NewLine ; at 78,25 : print tempRoll LDI 100 STW waitVBlankNum WaitVBlanks ; wait 100 LDWI _win CALL giga_vAC ; gosub win LDI 12 ST fgbgColour + 1 ; set FG_COLOUR, 12 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7dc7 NewLine ; at 10,25 : print "You won the roll!" LDI 200 STW waitVBlankNum WaitVBlanks ; wait 200 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor STLW 0xFE LDWI _page_0x0fa0 CALL giga_vAC _page_0x0fa0 LDLW 0xFE PrintString _str_0x7db0 NewLine ; at 10,25 : print "Play again (A) or (B)" LDI 5 STW _currentRound LDWI _endif_0x0a83 CALL giga_vAC ; currentRound = NEXTROUND _elseif_0x09ad LDW _tempRoll XORI 7 JumpEQ _else_0x0a3e 18 ; elseif tempRoll &= 7 LDI 3 ST fgbgColour + 1 ; set FG_COLOUR, 3 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7bdc NewLine ; at 10,25 : print "Seven Out!" LDI 100 STW waitVBlankNum WaitVBlanks ; wait 100 LDWI _playSndLose CALL giga_vAC ; gosub playSndLose LDI 10 ST cursorXY STLW 0xFE LDWI _page_0x10a0 CALL giga_vAC _page_0x10a0 LDLW 0xFE LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7cdf NewLine ; at 10,25 : print "You lost the roll!" LDI 200 STW waitVBlankNum WaitVBlanks ; wait 200 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7db0 NewLine ; at 10,25 : print "Play again (A) or (B)" LDI 5 STW _currentRound ; currentRound = NEXTROUND LDWI _updateBalance CALL giga_vAC LDWI _endif_0x0a83 CALL giga_vAC ; gosub updateBalance _else_0x0a3e LDI 10 ST cursorXY LDI 25 STLW 0xFE LDWI _page_0x11a0 CALL giga_vAC _page_0x11a0 LDLW 0xFE ST cursorXY + 1 AtTextCursor PrintString _str_0x7de8 NewLine ; at 10,25 : print "You rolled:" LDI 78 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor LDW _tempRoll PrintAcInt16 NewLine ; at 78,25 : print tempRoll LDI 75 STW waitVBlankNum WaitVBlanks ; wait 75 LDWI _pointPhase CALL giga_vAC ; gosub pointPhase _endif_0x0a83 Return ; return _win PUSH LDI 2 STW mathX LDW _betAmount STW mathY LDWI multiply16bit CALL giga_vAC STW _winAmount ; winAmount = 2 * betAmount LDWI _updateBalance CALL giga_vAC ; gosub updateBalance STLW 0xFE LDWI _page_0x12a0 CALL giga_vAC _page_0x12a0 LDLW 0xFE Return ; return _gameOverInput PUSH LD giga_buttonState STW _inputDevice ; inputDevice = get("BUTTON_STATE") LDW _inputDevice XORI 191 CALL convertEqOpAddr STW 0xe8 LDW _inputDevice XORI 127 CALL convertEqOpAddr ORW 0xe8 JumpFalse _endif_0x0aee 20 ; if inputDevice = 191 OR inputDevice = 127 LDWI _playSndAlert CALL giga_vAC ; gosub playSndAlert LDI 100 STW _balance ; balance = 100 LDI 25 STW _betAmount ; betAmount = 25 LDI 0 STW _winAmount ; winAmount = 0 LDI 1 STW _currentRound ; currentRound = BET LDWI _drawTable CALL giga_vAC ; gosub drawTable LDWI _drawBetText CALL giga_vAC ; gosub drawBetText LDWI _displayBet CALL giga_vAC ; gosub displayBet LDWI _displayBalance CALL giga_vAC ; gosub displayBalance _endif_0x0aee Return ; return _displayGameOver PUSH LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 0 ST fgbgColour + 1 ; set FG_COLOUR, 0 LDI 0 STLW 0xFE LDWI _page_0x13a0 CALL giga_vAC _page_0x13a0 LDLW 0xFE ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7df5 NewLine ; at 0,110 : print " " LDI 10 STW drawRectF_x1 LDI 10 STW drawRectF_y1 LDI 140 STW drawRectF_x2 LDI 35 STW drawRectF_y2 DrawRectF ; rectf 10, 10, 140, 35 LDI 3 ST fgbgColour + 1 ; set FG_COLOUR, 3 LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 40 ST cursorXY LDI 10 ST cursorXY + 1 AtTextCursor PrintString _str_0x7bcd NewLine ; at 40,10 : print "You're broke!" LDI 63 STLW 0xFE LDWI _page_0x14a0 CALL giga_vAC _page_0x14a0 LDLW 0xFE ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 32 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7bbb NewLine ; at 32,25 : print "Press (A) or (B)" LDWI _playSndLose CALL giga_vAC ; gosub playSndLose Return ; return _playSndAlert PUSH LDI 0 STW _note STW _notes ; note = 0 : notes = note LDI 50 STW _index ; index = 50 LDI 2 ST giga_soundTimer ; set SOUND_TIMER, 2 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note LDI 3 STW waitVBlankNum WaitVBlanks ; WAIT 3 LDI 55 STW _index ; index = 55 LDI 2 STLW 0xFE LDWI _page_0x15a0 CALL giga_vAC _page_0x15a0 LDLW 0xFE ST giga_soundTimer ; set SOUND_TIMER, 2 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note Return ; return _playSndRollDice PUSH LDI 0 STW _note STW _notes ; note = 0 : notes = note LDI 40 STW _index ; index = 40 LDI 4 ST giga_soundTimer ; set SOUND_TIMER, 4 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note LDI 4 STW waitVBlankNum WaitVBlanks ; WAIT 4 LDI 45 STW _index ; index = 45 LDI 4 ST giga_soundTimer ; set SOUND_TIMER, 4 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency STLW 0xFE LDWI _page_0x16a0 CALL giga_vAC _page_0x16a0 LDLW 0xFE SoundOn ; sound on, 1, note Return ; return _playSndLose PUSH LDI 0 STW _note STW _notes ; note = 0 : notes = note LDI 45 STW _index ; index = 45 LDI 4 ST giga_soundTimer ; set SOUND_TIMER, 4 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note LDI 4 STW waitVBlankNum WaitVBlanks ; WAIT 4 LDI 40 STW _index ; index = 40 LDI 4 ST giga_soundTimer ; set SOUND_TIMER, 4 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note Return ; return _playSndBet PUSH LDI 0 STW _note STW _notes ; note = 0 : notes = note LDW _betAmount STLW 0xFE LDWI _page_0x17a0 CALL giga_vAC _page_0x17a0 LDLW 0xFE STW mathX LDI 25 STW mathY LDWI divide16bit CALL giga_vAC ADDI 60 STW _index ; index = betAmount/25 + 60 LDI 5 ST giga_soundTimer ; set SOUND_TIMER, 5 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note Return ; return _playSndWin PUSH LDI 10 STW waitVBlankNum WaitVBlanks ; WAIT 10 LDI 0 STW _note STW _notes ; note = 0 : notes = note LDI 60 STW _index ; index = 60 LDI 4 ST giga_soundTimer ; set SOUND_TIMER, 4 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note LDI 8 STW waitVBlankNum STLW 0xFE LDWI _page_0x18a0 CALL giga_vAC _page_0x18a0 LDLW 0xFE WaitVBlanks ; WAIT 8 LDI 2 ST giga_soundTimer ; set SOUND_TIMER, 2 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note LDI 4 STW waitVBlankNum WaitVBlanks ; WAIT 4 LDI 65 STW _index ; index = 65 LDI 20 ST giga_soundTimer ; set SOUND_TIMER, 20 LDWI _getRomNote CALL giga_vAC ; gosub getRomNote LDI 1 ST sndChannel + 1 LDW _note STW sndFrequency SoundOn ; sound on, 1, note LDI 20 STW waitVBlankNum WaitVBlanks ; WAIT 20 Return ; return _getRomNote PUSH ; asm LDWI 0x0900 ; LDWI 0x0900 ADDW _index ; ADDW _index ADDW _index ; ADDW _index STW _notes ; STW _notes LUP 0 ; LUP 0 STLW 0xFE LDWI _page_0x19a0 CALL giga_vAC _page_0x19a0 LDLW 0xFE ST _note ; ST _note LDW _notes ; LDW _notes LUP 1 ; LUP 1 ST _note+1 ; ST _note + 1 Return ; return _drawBetText PUSH LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDI 10 ST cursorXY LDI 10 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ba6 NewLine ; at 10,10 : print "Enter Bet (Up/Down)" LDI 10 ST cursorXY LDI 25 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ca1 NewLine ; at 10,25 : print "Roll Dice (A) or (B)" Return ; return _drawTable PUSH LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 8 ST fgbgColour + 1 ; set FG_COLOUR, 8 STLW 0xFE LDWI _page_0x1aa0 CALL giga_vAC _page_0x1aa0 LDLW 0xFE LDI 5 STW drawRectF_x1 LDI 42 STW drawRectF_y1 LDI 154 STW drawRectF_x2 LDI 98 STW drawRectF_y2 DrawRectF ; rectf tableX+2, tableY+2, 154, tableY+58 LDI 6 ST fgbgColour + 1 ; set FG_COLOUR, 6 LDI 3 STW drawRect_x1 LDI 40 STW drawRect_y1 LDI 156 STW drawRect_x2 LDI 100 STW drawRect_y2 DrawRect ; rect tableX, tableY, 156, tableY+60 LDI 11 ST fgbgColour + 1 ; set FG_COLOUR, 11 LDI 4 STW drawRect_x1 LDI 41 STW drawRect_y1 LDI 155 STW drawRect_x2 LDI 99 STW drawRect_y2 DrawRect ; rect tableX+1, tableY+1, 155, tableY+59 LDI 8 ST fgbgColour ; set BG_COLOUR, 8 LDI 12 ST fgbgColour + 1 ; set FG_COLOUR, 12 LDI 42 ST cursorXY LDI 67 STLW 0xFE LDWI _page_0x1ba0 CALL giga_vAC _page_0x1ba0 LDLW 0xFE ST cursorXY + 1 AtTextCursor PrintString _str_0x7af2 NewLine ; at tableX+39,tableY+27 : print "Gigatron TTL" Return ; return _drawDice PUSH LDI 0x32 RandMod ADDI 6 STW _dice1X ; dice1X = rnd(50) + 6 LDI 0x1e RandMod ADDI 48 STW _dice1Y ; dice1Y = rnd(30) + 48 LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 2 ST fgbgColour + 1 ; set FG_COLOUR, 2 LDW _dice1X STW drawRectF_x1 LDW _dice1Y STW drawRectF_y1 LDW _dice1X ADDI 20 STW drawRectF_x2 LDW _dice1Y ADDI 20 STW drawRectF_y2 DrawRectF ; rectf dice1X, dice1Y, dice1X+20, dice1Y+20 LDI 0 STLW 0xFE LDWI _page_0x1ca0 CALL giga_vAC _page_0x1ca0 LDLW 0xFE ST fgbgColour + 1 ; set FG_COLOUR, 0 LDW _dice1X STW drawRect_x1 LDW _dice1Y STW drawRect_y1 LDW _dice1X ADDI 20 STW drawRect_x2 LDW _dice1Y ADDI 20 STW drawRect_y2 DrawRect ; rect dice1X, dice1Y, dice1X+20, dice1Y+20 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDW _dice1Value XORI 1 CALL convertEqOpAddr JumpFalse _elseif_0x0e8a 21 ; if dice1Value = 1 LDW _dice1X ADDI 9 STW drawRectF_x1 LDW _dice1Y ADDI 9 STW drawRectF_y1 LDW _dice1X ADDI 11 STW drawRectF_x2 LDW _dice1Y ADDI 11 STW drawRectF_y2 DrawRectF LDWI _endif_0x126a CALL giga_vAC ; rectf dice1X+9, dice1Y+9, dice1X+11, dice1Y+11 _elseif_0x0e8a LDW _dice1Value XORI 2 CALL convertEqOpAddr STLW 0xFE LDWI _page_0x1da0 CALL giga_vAC _page_0x1da0 LDLW 0xFE JumpFalse _elseif_0x0efb 22 ; elseif dice1Value = 2 LDW _dice1X ADDI 5 STW drawRectF_x1 LDW _dice1Y ADDI 5 STW drawRectF_y1 LDW _dice1X ADDI 7 STW drawRectF_x2 LDW _dice1Y ADDI 7 STW drawRectF_y2 DrawRectF ; rectf dice1X+5, dice1Y+5, dice1X+7, dice1Y+7 LDW _dice1X ADDI 13 STW drawRectF_x1 LDW _dice1Y ADDI 13 STW drawRectF_y1 LDW _dice1X ADDI 15 STW drawRectF_x2 LDW _dice1Y ADDI 15 STW drawRectF_y2 DrawRectF LDWI _endif_0x126a CALL giga_vAC ; rectf dice1X+13, dice1Y+13, dice1X+15, dice1Y+15 _elseif_0x0efb LDW _dice1Value XORI 3 CALL convertEqOpAddr JumpFalse _elseif_0x0f99 23 ; elseif dice1Value = 3 STLW 0xFE LDWI _page_0x1ea0 CALL giga_vAC _page_0x1ea0 LDLW 0xFE LDW _dice1X ADDI 3 STW drawRectF_x1 LDW _dice1Y ADDI 3 STW drawRectF_y1 LDW _dice1X ADDI 5 STW drawRectF_x2 LDW _dice1Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice1X+3, dice1Y+3, dice1X+5, dice1Y+5 LDW _dice1X ADDI 9 STW drawRectF_x1 LDW _dice1Y ADDI 9 STW drawRectF_y1 LDW _dice1X ADDI 11 STW drawRectF_x2 LDW _dice1Y ADDI 11 STW drawRectF_y2 DrawRectF ; rectf dice1X+9, dice1Y+9, dice1X+11, dice1Y+11 LDW _dice1X ADDI 15 STW drawRectF_x1 LDW _dice1Y ADDI 15 STW drawRectF_y1 LDW _dice1X ADDI 17 STW drawRectF_x2 LDW _dice1Y ADDI 17 STW drawRectF_y2 STLW 0xFE LDWI _page_0x1fa0 CALL giga_vAC _page_0x1fa0 LDLW 0xFE DrawRectF LDWI _endif_0x126a CALL giga_vAC ; rectf dice1X+15, dice1Y+15, dice1X+17, dice1Y+17 _elseif_0x0f99 LDW _dice1Value XORI 4 CALL convertEqOpAddr JumpFalse _elseif_0x1064 24 ; elseif dice1Value = 4 LDW _dice1X ADDI 5 STW drawRectF_x1 LDW _dice1Y ADDI 5 STW drawRectF_y1 LDW _dice1X ADDI 7 STW drawRectF_x2 LDW _dice1Y ADDI 7 STW drawRectF_y2 DrawRectF ; rectf dice1X+5, dice1Y+5, dice1X+7, dice1Y+7 LDW _dice1X ADDI 5 STW drawRectF_x1 LDW _dice1Y ADDI 13 STW drawRectF_y1 LDW _dice1X ADDI 7 STW drawRectF_x2 LDW _dice1Y ADDI 15 STW drawRectF_y2 DrawRectF ; rectf dice1X+5, dice1Y+13, dice1X+7, dice1Y+15 LDW _dice1X ADDI 13 STLW 0xFE LDWI _page_0x20a0 CALL giga_vAC _page_0x20a0 LDLW 0xFE STW drawRectF_x1 LDW _dice1Y ADDI 5 STW drawRectF_y1 LDW _dice1X ADDI 15 STW drawRectF_x2 LDW _dice1Y ADDI 7 STW drawRectF_y2 DrawRectF ; rectf dice1X+13, dice1Y+5, dice1X+15, dice1Y+7 LDW _dice1X ADDI 13 STW drawRectF_x1 LDW _dice1Y ADDI 13 STW drawRectF_y1 LDW _dice1X ADDI 15 STW drawRectF_x2 LDW _dice1Y ADDI 15 STW drawRectF_y2 DrawRectF LDWI _endif_0x126a CALL giga_vAC ; rectf dice1X+13, dice1Y+13, dice1X+15, dice1Y+15 _elseif_0x1064 LDW _dice1Value XORI 5 CALL convertEqOpAddr JumpFalse _else_0x115c 25 ; elseif dice1Value = 5 LDW _dice1X ADDI 3 STW drawRectF_x1 LDW _dice1Y ADDI 3 STW drawRectF_y1 STLW 0xFE LDWI _page_0x21a0 CALL giga_vAC _page_0x21a0 LDLW 0xFE LDW _dice1X ADDI 5 STW drawRectF_x2 LDW _dice1Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice1X+3, dice1Y+3, dice1X+5, dice1Y+5 LDW _dice1X ADDI 15 STW drawRectF_x1 LDW _dice1Y ADDI 3 STW drawRectF_y1 LDW _dice1X ADDI 17 STW drawRectF_x2 LDW _dice1Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice1X+15, dice1Y+3, dice1X+17, dice1Y+5 LDW _dice1X ADDI 9 STW drawRectF_x1 LDW _dice1Y ADDI 9 STW drawRectF_y1 LDW _dice1X ADDI 11 STW drawRectF_x2 LDW _dice1Y ADDI 11 STW drawRectF_y2 DrawRectF ; rectf dice1X+9, dice1Y+9, dice1X+11, dice1Y+11 LDW _dice1X ADDI 3 STW drawRectF_x1 LDW _dice1Y ADDI 15 STLW 0xFE LDWI _page_0x22a0 CALL giga_vAC _page_0x22a0 LDLW 0xFE STW drawRectF_y1 LDW _dice1X ADDI 5 STW drawRectF_x2 LDW _dice1Y ADDI 17 STW drawRectF_y2 DrawRectF ; rectf dice1X+3, dice1Y+15, dice1X+5, dice1Y+17 LDW _dice1X ADDI 15 STW drawRectF_x1 LDW _dice1Y ADDI 15 STW drawRectF_y1 LDW _dice1X ADDI 17 STW drawRectF_x2 LDW _dice1Y ADDI 17 STW drawRectF_y2 DrawRectF LDWI _endif_0x126a CALL giga_vAC ; rectf dice1X+15, dice1Y+15, dice1X+17, dice1Y+17 _else_0x115c LDW _dice1X ADDI 5 STW drawRectF_x1 LDW _dice1Y ADDI 3 STW drawRectF_y1 LDW _dice1X ADDI 7 STW drawRectF_x2 LDW _dice1Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice1X+5, dice1Y+3, dice1X+7, dice1Y+5 LDW _dice1X ADDI 5 STLW 0xFE LDWI _page_0x23a0 CALL giga_vAC _page_0x23a0 LDLW 0xFE STW drawRectF_x1 LDW _dice1Y ADDI 9 STW drawRectF_y1 LDW _dice1X ADDI 7 STW drawRectF_x2 LDW _dice1Y ADDI 11 STW drawRectF_y2 DrawRectF ; rectf dice1X+5, dice1Y+9, dice1X+7, dice1Y+11 LDW _dice1X ADDI 5 STW drawRectF_x1 LDW _dice1Y ADDI 15 STW drawRectF_y1 LDW _dice1X ADDI 7 STW drawRectF_x2 LDW _dice1Y ADDI 17 STW drawRectF_y2 DrawRectF ; rectf dice1X+5, dice1Y+15, dice1X+7, dice1Y+17 LDW _dice1X ADDI 13 STW drawRectF_x1 LDW _dice1Y ADDI 3 STW drawRectF_y1 LDW _dice1X ADDI 15 STW drawRectF_x2 LDW _dice1Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice1X+13, dice1Y+3, dice1X+15, dice1Y+5 LDW _dice1X STLW 0xFE LDWI _page_0x24a0 CALL giga_vAC _page_0x24a0 LDLW 0xFE ADDI 13 STW drawRectF_x1 LDW _dice1Y ADDI 9 STW drawRectF_y1 LDW _dice1X ADDI 15 STW drawRectF_x2 LDW _dice1Y ADDI 11 STW drawRectF_y2 DrawRectF ; rectf dice1X+13, dice1Y+9, dice1X+15, dice1Y+11 LDW _dice1X ADDI 13 STW drawRectF_x1 LDW _dice1Y ADDI 15 STW drawRectF_y1 LDW _dice1X ADDI 15 STW drawRectF_x2 LDW _dice1Y ADDI 17 STW drawRectF_y2 DrawRectF ; rectf dice1X+13, dice1Y+15, dice1X+15, dice1Y+17 _endif_0x126a LDI 0x32 RandMod ADDI 84 STW _dice2X ; dice2X = rnd(50) + 84 LDI 0x1e RandMod ADDI 48 STW _dice2Y ; dice2Y = rnd(30) + 48 LDI 0 ST fgbgColour ; set BG_COLOUR, 0 STLW 0xFE LDWI _page_0x25a0 CALL giga_vAC _page_0x25a0 LDLW 0xFE LDI 2 ST fgbgColour + 1 ; set FG_COLOUR, 2 LDW _dice2X STW drawRectF_x1 LDW _dice2Y STW drawRectF_y1 LDW _dice2X ADDI 20 STW drawRectF_x2 LDW _dice2Y ADDI 20 STW drawRectF_y2 DrawRectF ; rectf dice2X, dice2Y, dice2X+20, dice2Y+20 LDI 0 ST fgbgColour + 1 ; set FG_COLOUR, 0 LDW _dice2X STW drawRect_x1 LDW _dice2Y STW drawRect_y1 LDW _dice2X ADDI 20 STW drawRect_x2 LDW _dice2Y ADDI 20 STW drawRect_y2 DrawRect ; rect dice2X, dice2Y, dice2X+20, dice2Y+20 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDW _dice2Value XORI 1 CALL convertEqOpAddr JumpFalse _elseif_0x1326 27 ; if dice2Value = 1 LDW _dice2X ADDI 9 STW drawRectF_x1 LDW _dice2Y ADDI 9 STLW 0xFE LDWI _page_0x26a0 CALL giga_vAC _page_0x26a0 LDLW 0xFE STW drawRectF_y1 LDW _dice2X ADDI 11 STW drawRectF_x2 LDW _dice2Y ADDI 11 STW drawRectF_y2 DrawRectF LDWI _endif_0x1706 CALL giga_vAC ; rectf dice2X+9, dice2Y+9, dice2X+11, dice2Y+11 _elseif_0x1326 LDW _dice2Value XORI 2 CALL convertEqOpAddr JumpFalse _elseif_0x1397 28 ; elseif dice2Value = 2 LDW _dice2X ADDI 5 STW drawRectF_x1 LDW _dice2Y ADDI 5 STW drawRectF_y1 LDW _dice2X ADDI 7 STW drawRectF_x2 LDW _dice2Y ADDI 7 STW drawRectF_y2 DrawRectF ; rectf dice2X+5, dice2Y+5, dice2X+7, dice2Y+7 LDW _dice2X ADDI 13 STW drawRectF_x1 LDW _dice2Y ADDI 13 STW drawRectF_y1 LDW _dice2X ADDI 15 STW drawRectF_x2 STLW 0xFE LDWI _page_0x27a0 CALL giga_vAC _page_0x27a0 LDLW 0xFE LDW _dice2Y ADDI 15 STW drawRectF_y2 DrawRectF LDWI _endif_0x1706 CALL giga_vAC ; rectf dice2X+13, dice2Y+13, dice2X+15, dice2Y+15 _elseif_0x1397 LDW _dice2Value XORI 3 CALL convertEqOpAddr JumpFalse _elseif_0x1435 29 ; elseif dice2Value = 3 LDW _dice2X ADDI 3 STW drawRectF_x1 LDW _dice2Y ADDI 3 STW drawRectF_y1 LDW _dice2X ADDI 5 STW drawRectF_x2 LDW _dice2Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice2X+3, dice2Y+3, dice2X+5, dice2Y+5 LDW _dice2X ADDI 9 STW drawRectF_x1 LDW _dice2Y ADDI 9 STW drawRectF_y1 LDW _dice2X ADDI 11 STW drawRectF_x2 LDW _dice2Y ADDI 11 STW drawRectF_y2 STLW 0xFE LDWI _page_0x28a0 CALL giga_vAC _page_0x28a0 LDLW 0xFE DrawRectF ; rectf dice2X+9, dice2Y+9, dice2X+11, dice2Y+11 LDW _dice2X ADDI 15 STW drawRectF_x1 LDW _dice2Y ADDI 15 STW drawRectF_y1 LDW _dice2X ADDI 17 STW drawRectF_x2 LDW _dice2Y ADDI 17 STW drawRectF_y2 DrawRectF LDWI _endif_0x1706 CALL giga_vAC ; rectf dice2X+15, dice2Y+15, dice2X+17, dice2Y+17 _elseif_0x1435 LDW _dice2Value XORI 4 CALL convertEqOpAddr JumpFalse _elseif_0x1500 30 ; elseif dice2Value = 4 LDW _dice2X ADDI 5 STW drawRectF_x1 LDW _dice2Y ADDI 5 STW drawRectF_y1 LDW _dice2X ADDI 7 STW drawRectF_x2 LDW _dice2Y ADDI 7 STW drawRectF_y2 DrawRectF ; rectf dice2X+5, dice2Y+5, dice2X+7, dice2Y+7 LDW _dice2X ADDI 5 STLW 0xFE LDWI _page_0x29a0 CALL giga_vAC _page_0x29a0 LDLW 0xFE STW drawRectF_x1 LDW _dice2Y ADDI 13 STW drawRectF_y1 LDW _dice2X ADDI 7 STW drawRectF_x2 LDW _dice2Y ADDI 15 STW drawRectF_y2 DrawRectF ; rectf dice2X+5, dice2Y+13, dice2X+7, dice2Y+15 LDW _dice2X ADDI 13 STW drawRectF_x1 LDW _dice2Y ADDI 5 STW drawRectF_y1 LDW _dice2X ADDI 15 STW drawRectF_x2 LDW _dice2Y ADDI 7 STW drawRectF_y2 DrawRectF ; rectf dice2X+13, dice2Y+5, dice2X+15, dice2Y+7 LDW _dice2X ADDI 13 STW drawRectF_x1 LDW _dice2Y ADDI 13 STW drawRectF_y1 LDW _dice2X ADDI 15 STW drawRectF_x2 LDW _dice2Y ADDI 15 STW drawRectF_y2 DrawRectF LDWI _endif_0x1706 STLW 0xFE LDWI _page_0x2aa0 CALL giga_vAC _page_0x2aa0 LDLW 0xFE CALL giga_vAC ; rectf dice2X+13, dice2Y+13, dice2X+15, dice2Y+15 _elseif_0x1500 LDW _dice2Value XORI 5 CALL convertEqOpAddr JumpFalse _else_0x15f8 31 ; elseif dice2Value = 5 LDW _dice2X ADDI 3 STW drawRectF_x1 LDW _dice2Y ADDI 3 STW drawRectF_y1 LDW _dice2X ADDI 5 STW drawRectF_x2 LDW _dice2Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice2X+3, dice2Y+3, dice2X+5, dice2Y+5 LDW _dice2X ADDI 15 STW drawRectF_x1 LDW _dice2Y ADDI 3 STW drawRectF_y1 LDW _dice2X ADDI 17 STW drawRectF_x2 LDW _dice2Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice2X+15, dice2Y+3, dice2X+17, dice2Y+5 LDW _dice2X ADDI 9 STW drawRectF_x1 LDW _dice2Y ADDI 9 STW drawRectF_y1 STLW 0xFE LDWI _page_0x2ba0 CALL giga_vAC _page_0x2ba0 LDLW 0xFE LDW _dice2X ADDI 11 STW drawRectF_x2 LDW _dice2Y ADDI 11 STW drawRectF_y2 DrawRectF ; rectf dice2X+9, dice2Y+9, dice2X+11, dice2Y+11 LDW _dice2X ADDI 3 STW drawRectF_x1 LDW _dice2Y ADDI 15 STW drawRectF_y1 LDW _dice2X ADDI 5 STW drawRectF_x2 LDW _dice2Y ADDI 17 STW drawRectF_y2 DrawRectF ; rectf dice2X+3, dice2Y+15, dice2X+5, dice2Y+17 LDW _dice2X ADDI 15 STW drawRectF_x1 LDW _dice2Y ADDI 15 STW drawRectF_y1 LDW _dice2X ADDI 17 STW drawRectF_x2 LDW _dice2Y ADDI 17 STW drawRectF_y2 DrawRectF LDWI _endif_0x1706 CALL giga_vAC ; rectf dice2X+15, dice2Y+15, dice2X+17, dice2Y+17 _else_0x15f8 LDW _dice2X ADDI 5 STW drawRectF_x1 STLW 0xFE LDWI _page_0x2ca0 CALL giga_vAC _page_0x2ca0 LDLW 0xFE LDW _dice2Y ADDI 3 STW drawRectF_y1 LDW _dice2X ADDI 7 STW drawRectF_x2 LDW _dice2Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice2X+5, dice2Y+3, dice2X+7, dice2Y+5 LDW _dice2X ADDI 5 STW drawRectF_x1 LDW _dice2Y ADDI 9 STW drawRectF_y1 LDW _dice2X ADDI 7 STW drawRectF_x2 LDW _dice2Y ADDI 11 STW drawRectF_y2 DrawRectF ; rectf dice2X+5, dice2Y+9, dice2X+7, dice2Y+11 LDW _dice2X ADDI 5 STW drawRectF_x1 LDW _dice2Y ADDI 15 STW drawRectF_y1 LDW _dice2X ADDI 7 STW drawRectF_x2 LDW _dice2Y ADDI 17 STW drawRectF_y2 DrawRectF ; rectf dice2X+5, dice2Y+15, dice2X+7, dice2Y+17 LDW _dice2X ADDI 13 STLW 0xFE LDWI _page_0x2da0 CALL giga_vAC _page_0x2da0 LDLW 0xFE STW drawRectF_x1 LDW _dice2Y ADDI 3 STW drawRectF_y1 LDW _dice2X ADDI 15 STW drawRectF_x2 LDW _dice2Y ADDI 5 STW drawRectF_y2 DrawRectF ; rectf dice2X+13, dice2Y+3, dice2X+15, dice2Y+5 LDW _dice2X ADDI 13 STW drawRectF_x1 LDW _dice2Y ADDI 9 STW drawRectF_y1 LDW _dice2X ADDI 15 STW drawRectF_x2 LDW _dice2Y ADDI 11 STW drawRectF_y2 DrawRectF ; rectf dice2X+13, dice2Y+9, dice2X+15, dice2Y+11 LDW _dice2X ADDI 13 STW drawRectF_x1 LDW _dice2Y ADDI 15 STW drawRectF_y1 LDW _dice2X ADDI 15 STW drawRectF_x2 LDW _dice2Y ADDI 17 STW drawRectF_y2 DrawRectF ; rectf dice2X+13, dice2Y+15, dice2X+15, dice2Y+17 _endif_0x1706 Return ; return _displayBalance PUSH STLW 0xFE LDWI _page_0x2ea0 CALL giga_vAC _page_0x2ea0 LDLW 0xFE LDI 0 ST fgbgColour ; set BG_COLOUR, 0 LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDW _balance SUBI 10 JumpLT _elseif_0x175d 33 ; if balance &< 10 LDI 106 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ae9 NewLine ; at 106,110 : print "Bal:000" LDI 148 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor LDW _balance PrintAcInt16 NewLine LDWI _endif_0x182d CALL giga_vAC ; at 148,110 : print balance _elseif_0x175d LDW _balance SUBI 100 STLW 0xFE LDWI _page_0x2fa0 CALL giga_vAC _page_0x2fa0 LDLW 0xFE JumpLT _elseif_0x17a9 34 ; elseif balance &< 100 LDI 106 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ae1 NewLine ; at 106,110 : print "Bal:00" LDI 142 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor LDW _balance PrintAcInt16 NewLine LDWI _endif_0x182d CALL giga_vAC ; at 142,110 : print balance _elseif_0x17a9 LDWI 999 SUBW _balance JumpGE _else_0x17f6 35 ; elseif balance &< 999 LDI 106 ST cursorXY STLW 0xFE LDWI _page_0x30a0 CALL giga_vAC _page_0x30a0 LDLW 0xFE LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ada NewLine ; at 106,110 : print "Bal:0" LDI 136 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor LDW _balance PrintAcInt16 NewLine LDWI _endif_0x182d CALL giga_vAC ; at 136,110 : print balance _else_0x17f6 LDI 106 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ba0 NewLine ; at 106,110 : print "Bal:" LDI 130 STLW 0xFE LDWI _page_0x31a0 CALL giga_vAC _page_0x31a0 LDLW 0xFE ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor LDW _balance PrintAcInt16 NewLine ; at 130,110 : print balance _endif_0x182d Return ; return _updateBalance PUSH LDW _winAmount JumpGT _endif_0x18ab 38 ; if winAmount &> 0 LDI 3 ST fgbgColour ; set BG_COLOUR, 3 LDI 15 ST fgbgColour + 1 ; set FG_COLOUR, 15 LDI 3 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ad4 NewLine ; at 3,110 : print "Win:" LDI 26 ST cursorXY LDI 110 ST cursorXY + 1 STLW 0xFE LDWI _page_0x32a0 CALL giga_vAC _page_0x32a0 LDLW 0xFE AtTextCursor LDW _winAmount PrintAcInt16 NewLine ; at 26,110 : print winAmount LDW _balance ADDW _winAmount STW _balance ; balance = balance + winAmount LDWI 9999 SUBW _balance JumpLE _endif_0x189d 37 ; if balance &> 9999 LDWI 9999 STW _balance ; balance = 9999 _endif_0x189d LDI 0 STW _winAmount ; winAmount = 0 LDWI _displayBalance CALL giga_vAC ; gosub displayBalance LDWI _playSndWin CALL giga_vAC ; gosub playSndWin _endif_0x18ab LDW _balance SUBI 1 JumpLT _endif_0x18c4 39 ; if balance &< 1 LDI 0 STW _currentRound ; currentRound = GAMEOVER LDWI _displayGameOver CALL giga_vAC ; gosub displayGameOver _endif_0x18c4 Return ; return _displayBet PUSH LDI 0 ST fgbgColour ; set BG_COLOUR, 0 STLW 0xFE LDWI _page_0x33a0 CALL giga_vAC _page_0x33a0 LDLW 0xFE LDI 63 ST fgbgColour + 1 ; set FG_COLOUR, 63 LDW _betAmount SUBI 10 JumpLT _elseif_0x191b 40 ; if betAmount &< 10 LDI 56 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7acc NewLine ; at 56,110 : print "Bet:00" LDI 92 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor LDW _betAmount PrintAcInt16 NewLine LDWI _endif_0x199e CALL giga_vAC ; at 92,110 : print betAmount _elseif_0x191b LDW _betAmount SUBI 100 STLW 0xFE LDWI _page_0x34a0 CALL giga_vAC _page_0x34a0 LDLW 0xFE JumpLT _else_0x1967 41 ; elseif betAmount &< 100 LDI 56 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor PrintString _str_0x7ac5 NewLine ; at 56,110 : print "Bet:0" LDI 86 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor LDW _betAmount PrintAcInt16 NewLine LDWI _endif_0x199e CALL giga_vAC ; at 86,110 : print betAmount _else_0x1967 LDI 56 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor STLW 0xFE LDWI _page_0x35a0 CALL giga_vAC _page_0x35a0 LDLW 0xFE PrintString _str_0x7abf NewLine ; at 56,110 : print "Bet:" LDI 80 ST cursorXY LDI 110 ST cursorXY + 1 AtTextCursor LDW _betAmount PrintAcInt16 NewLine ; at 80,110 : print betAmount _endif_0x199e Return ; return HALT ; END ;**************************************************************************************************************************************** ;**************************************************************************************************************************************** ;* Internal runtime, DO NOT MODIFY PAST THIS POINT, modifications must be made in the original include files * ;**************************************************************************************************************************************** ;**************************************************************************************************************************************** romCheck EQU 0x70c6 convertEqOp EQU 0x6ef6 multiply16bit EQU 0x72cb divide16bit EQU 0x77a8 randMod16bit EQU 0x6fc2 scanlineMode EQU 0x6fa5 waitVBlank EQU 0x76a2 waitVBlanks EQU 0x6faf resetVideoFlags EQU 0x70a4 initClearFuncs EQU 0x75a1 clearVertBlinds EQU 0x73c9 clearCursorRow EQU 0x71cf drawHLine EQU 0x71a2 drawVLine EQU 0x79a1 drawRect EQU 0x74c0 drawRectF EQU 0x73a1 soundAllOff EQU 0x70b0 soundOn EQU 0x6fd5 printInit EQU 0x6fe9 printText EQU 0x74a7 printDigit EQU 0x70dd printInt16 EQU 0x76ae printChar EQU 0x75b2 printClip EQU 0x7aa5 atTextCursor EQU 0x72a6 newLineScroll EQU 0x78a2 convertEqOpAddr EQU 0x00c0 convertNeOpAddr EQU 0x00c2 convertLeOpAddr EQU 0x00c4 convertGeOpAddr EQU 0x00c6 convertLtOpAddr EQU 0x00c8 convertGtOpAddr EQU 0x00ca convert8Arr2dAddr EQU 0x00cc convert8Arr3dAddr EQU 0x00ce convert16Arr2dAddr EQU 0x00d0 convert16Arr3dAddr EQU 0x00d2 realTimeStubAddr EQU 0x00d4 ; do *NOT* use register4 to register7 during time slicing realTimeAddr EQU register0 realTimeProc0 EQU register1 realTimeProc1 EQU register2 realTimeProc2 EQU register3 numericLabel EQU register0 defaultLabel EQU register1 lutLabs EQU register2 lutAddrs EQU register3 lutIndex EQU register8 romType EQU register0 romErrAddr EQU register1 romErrPixel EQU register2 romExec_vLR EQU register0 romReadAddr EQU register0 romCheck LD giga_romType ANDI 0xFC SUBW romType BGE romC_return LDWI giga_vram + giga_yres/2*256 + giga_xres/2 STW romErrAddr romC_loop LD romErrPixel POKE romErrAddr INC romErrPixel BRA romC_loop ; flash center pixel indicating rom error romC_return RET ; convert equal to into a boolean convertEqOp BEQ convertEq_1 LDI 0 RET convertEq_1 LDI 1 RET ; do *NOT* use register4 to register7 during time slicing mathX EQU register8 mathY EQU register9 mathSum EQU register12 mathRem EQU register12 mathMask EQU register13 mathSign EQU register14 mathQuot EQU register15 mathShift EQU register15 mathBase EQU register10 mathPow EQU register11 mathResult EQU register14 ; accumulator = mathX * mathY, (result 16bit) multiply16bit LDI 0 STW mathSum LDW mathX BEQ multiply16_exit ; if x=0 then return 0 LDWI SYS_LSRW1_48 STW giga_sysFn LDW mathY multiply16_loop BEQ multiply16_exit ; if y=0 then return ANDI 1 BEQ multiply16_skip LDW mathSum ADDW mathX STW mathSum ; mathSum += mathX multiply16_skip LDW mathX LSLW STW mathX ; mathX = mathX <<1 LDW mathY SYS 48 STW mathY ; mathY = mathY >>1 BRA multiply16_loop %if TIME_SLICING multiply16_exit PUSH CALL realTimeStubAddr POP LDW mathSum %else multiply16_exit LDW mathSum %endif RET ; accumulator:mathRem = mathX / mathY, (results 16bit) divide16bit LDW mathX XORW mathY STW mathSign LDW mathX BGE divide16_pos0 LDI 0 SUBW mathX STW mathX divide16_pos0 LDW mathY BGE divide16_pos1 LDI 0 SUBW mathY STW mathY divide16_pos1 LDI 0 STW mathRem LDI 1 divide16_loop STW mathMask LDW mathRem LSLW STW mathRem LDW mathX BGE divide16_incr INC mathRem divide16_incr LDW mathX LSLW STW mathX LDW mathRem SUBW mathY BLT divide16_incx STW mathRem INC mathX divide16_incx LDW mathMask LSLW BNE divide16_loop %if TIME_SLICING PUSH CALL realTimeStubAddr POP %endif LDW mathSign BGE divide16_exit LDI 0 SUBW mathX RET divide16_exit LDW mathX RET randMod16bit PUSH LDWI SYS_Random_34 STW giga_sysFn SYS 34 STW mathX LDWI divide16bit CALL giga_vAC LDW mathRem POP RET ; do *NOT* use register4 to register7 during time slicing graphicsMode EQU register0 waitVBlankNum EQU register0 drawHLine_x1 EQU register0 drawHLine_y1 EQU register1 drawHLine_x2 EQU register2 drawHLine_x4 EQU register3 drawVLine_x1 EQU register0 drawVLine_y1 EQU register1 drawVLine_y2 EQU register2 drawVLine_y8 EQU register3 drawLine_x1 EQU register0 drawLine_y1 EQU register1 drawLine_x2 EQU register2 drawLine_y2 EQU register3 drawLine_xy1 EQU register0 drawLine_xy2 EQU register1 drawLine_dxy1 EQU register2 drawLine_dxy2 EQU register3 drawLine_dx1 EQU register4 ; register4 to register7 used for temp values, state will be invalidated during time slicing drawLine_dy1 EQU register5 drawLine_dx2 EQU register6 drawLine_dy2 EQU register7 drawLine_sx EQU register8 drawLine_sy EQU register9 drawLine_h EQU register10 drawLine_num EQU register11 drawLine_count EQU register12 drawLine_tmp EQU register13 drawLine_dx EQU register2 drawLine_dy EQU register3 drawLine_u EQU register8 drawLine_v EQU register9 drawLine_addr EQU register10 drawPixel_xy EQU register15 readPixel_xy EQU register15 drawCircle_cx EQU register0 drawCircle_cy EQU register1 drawCircle_r EQU register2 drawCircle_a EQU register3 drawCircle_d EQU register8 drawCircle_x EQU register9 drawCircle_y EQU register10 drawCircle_ch0 EQU register11 drawCircle_ch1 EQU register12 drawCircle_ch2 EQU register13 drawCircle_ch3 EQU register14 drawCircleF_x1 EQU register0 drawCircleF_y1 EQU register1 drawCircleF_x2 EQU register2 drawCircleF_cx EQU register15 drawCircleF_cy EQU register10 drawCircleF_r EQU register11 drawCircleF_v EQU register8 drawCircleF_w EQU register9 drawRect_x1 EQU register7 drawRect_y1 EQU register10 drawRect_x2 EQU register11 drawRect_y2 EQU register15 drawRectF_x1 EQU register0 drawRectF_y1 EQU register1 drawRectF_x2 EQU register2 drawRectF_y2 EQU register7 drawPoly_mode EQU register14 drawPoly_addr EQU register15 scanlineMode LDWI SYS_SetMode_v2_80 STW giga_sysFn LDW graphicsMode SYS 80 RET waitVBlank LD giga_videoY XORI 179 BNE waitVBlank %if TIME_SLICING PUSH CALL realTimeStubAddr POP %endif RET waitVBlanks PUSH waitVB_loop LDW waitVBlankNum SUBI 0x01 STW waitVBlankNum BGE waitVB_vblank POP RET waitVB_vblank LDWI waitVBlank CALL giga_vAC BRA waitVB_loop ; do *NOT* use register4 to register7 during time slicing xreset EQU register0 xcount EQU register1 ycount EQU register2 treset EQU register3 breset EQU register8 top EQU register9 bot EQU register10 vramAddr EQU register11 evenAddr EQU register12 clsAddress EQU register13 clsLines EQU register14 varAddress EQU register13 clrAddress EQU register13 clrLines EQU register14 clrWidth EQU register15 resetVideoFlags LDI giga_CursorX ; cursor x start STW cursorXY LDWI ON_BOTTOM_ROW_MSK ANDW miscFlags STW miscFlags ; reset on bottom row flag RET initClearFuncs PUSH LDWI resetVideoFlags CALL giga_vAC LDWI SYS_SetMemory_v2_54 ; setup fill memory SYS routine STW giga_sysFn LD fgbgColour ST giga_sysArg1 ; fill value POP RET ; clears the viewable screen using a vertical blinds effect clearVertBlinds PUSH LDWI initClearFuncs CALL giga_vAC LDI giga_vram >> 8 STW top clearVB_loopy LDI giga_xres ST giga_sysArg0 LDI 0 ST giga_sysArg2 ; low start address LD top ST giga_sysArg3 ; top line SYS 54 ; fill memory LDI giga_xres ST giga_sysArg0 LDI 0 ST giga_sysArg2 ; low start address LDWI giga_yres - 1 + 16 SUBW top ST giga_sysArg3 ; bottom line SYS 54 ; fill memory INC top ; next top line %if TIME_SLICING CALL realTimeStubAddr %endif LD top SUBI giga_yres / 2 + 8 BLT clearVB_loopy POP RET drawHLine PUSH LD drawHLine_x1 ST giga_sysArg2 ; low start address LD drawHLine_x2 SUBW drawHLine_x1 BGE drawHL_cont LD drawHLine_x2 ST giga_sysArg2 ; low start address LD drawHLine_x1 SUBW drawHLine_x2 drawHL_cont ADDI 1 ST giga_sysArg0 ; count LD fgbgColour + 1 ST giga_sysArg1 ; fill value LD drawHLine_y1 ADDI 8 ST giga_sysArg3 ; high start address LDWI SYS_SetMemory_v2_54 STW giga_sysFn SYS 54 ; fill memory %if TIME_SLICING CALL realTimeStubAddr %endif POP RET drawVLine PUSH LDW drawVLine_y2 SUBW drawVLine_y1 BGE drawVL_cont LDW drawVLine_y2 STW drawLine_tmp LDW drawVLine_y1 STW drawVLine_y2 LDW drawLine_tmp STW drawVLine_y1 ; if y2 < y1 then swap y2 with y1 drawVL_cont LD drawVLine_x1 ST giga_sysArg4 LD drawVLine_y1 ADDI 8 ST drawVLine_y1 ST giga_sysArg5 LDW drawVLine_y2 ADDI 8 ST drawVLine_y2 SUBW drawVLine_y1 SUBI 8 BLT drawVL_loop1 LDW fgbgColour STW giga_sysArg0 LDWI SYS_VDrawBits_134 STW giga_sysFn ; setup 8 pixel SYS routine LDW drawVLine_y2 SUBI 7 STW drawVLine_y8 ; 8 pixel chunks limit drawVL_loop0 LDI 0xFF ST giga_sysArg2 ; 8 pixels of fg and bg colour SYS 134 ; SYS_VDrawBits_134, 270 - 134/2 = 0xCB %if TIME_SLICING CALL realTimeStubAddr %endif LD giga_sysArg5 ADDI 8 ST giga_sysArg5 SUBW drawVLine_y8 BLT drawVL_loop0 ; all 8 pixel chunks drawVL_loop1 LD fgbgColour + 1 POKE giga_sysArg4 INC giga_sysArg5 LD giga_sysArg5 SUBW drawVLine_y2 BLE drawVL_loop1 ; remaining pixels POP RET drawRect PUSH LDW drawRect_x1 STW drawHLine_x1 LDW drawRect_y1 STW drawHLine_y1 LDW drawRect_x2 STW drawHLine_x2 LDWI drawHLine CALL giga_vAC LDW drawRect_y2 STW drawHLine_y1 LDWI drawHLine CALL giga_vAC LDW drawRect_x1 STW drawVLine_x1 LDW drawRect_y1 STW drawVLine_y1 LDW drawRect_y2 STW drawVLine_y2 LDWI drawVLine CALL giga_vAC LDW drawRect_x2 STW drawVLine_x1 LDW drawRect_y1 STW drawVLine_y1 LDW drawRect_y2 STW drawVLine_y2 LDWI drawVLine CALL giga_vAC POP RET drawRectF PUSH LDW drawRectF_y2 SUBW drawRectF_y1 BGE drawRF_loop LDW drawRectF_y2 STW drawLine_tmp LDW drawRectF_y1 STW drawRectF_y2 LDW drawLine_tmp STW drawRectF_y1 ;if y2 < y1 then swap y2 with y1 drawRF_loop LDW drawRectF_y1 STW drawHLine_y1 LDWI drawHLine CALL giga_vAC INC drawRectF_y1 LDW drawRectF_y1 SUBW drawRectF_y2 BLE drawRF_loop POP RET midiId EQU register0 audioAddr EQU register1 waveType EQU register2 midiNote EQU register4 ; register4 to register7 are the only free registers during time slicing midiCommand EQU register5 midiPtr EQU register6 sndChannel EQU register8 sndFrequency EQU register9 sndVolume EQU register10 sndWaveType EQU register11 musicStream EQU register8 musicNote EQU register9 musicCommand EQU register10 musicPtr EQU register11 soundAllOff LDWI 0x01FC STW sndChannel LDI 0 DOKE sndChannel ; turn off channel 0 INC sndChannel + 1 DOKE sndChannel ; turn off channel 1 INC sndChannel + 1 DOKE sndChannel ; turn off channel 2 INC sndChannel + 1 DOKE sndChannel ; turn off channel 3 RET soundOn LDWI SYS_LSRW1_48 STW giga_sysFn LDI 0xFC ST sndChannel LD sndFrequency SYS 48 ST sndFrequency ; right shift low byte of sndFrequency by 1 LDW sndFrequency ; format = high:8 low:07, (bit 7 of low byte = 0) DOKE sndChannel ; turn on channel RET ; do *NOT* use register4 to register7 during time slicing textStr EQU register0 textNum EQU register0 textBak EQU register0 textHex EQU register1 textSpc EQU register1 textLen EQU register2 textOfs EQU register3 textChr EQU register8 textFont EQU register9 textSlice EQU register10 scanLine EQU register11 digitMult EQU register12 digitIndex EQU register13 clearLoop EQU register14 printInit LDWI SYS_VDrawBits_134 STW giga_sysFn LDW fgbgColour STW giga_sysArg0 LD cursorXY + 1 ; xy = peek(256+2*y)*256 + x LSLW INC giga_vAC + 1 PEEK ST giga_sysArg4 + 1 LD cursorXY ST giga_sysArg4 ; xy position RET ; prints text string pointed to by textStr printText PUSH LDWI printInit CALL giga_vAC ; first byte is length printT_char INC textStr ; next char LDW textStr PEEK BEQ printT_exit ; check for delimiting zero ST textChr LDWI printChar CALL giga_vAC BRA printT_char printT_exit POP RET ; prints single digit in textNum printDigit PUSH LDW textNum printD_index SUBW digitMult BLT printD_cont STW textNum INC digitIndex BRA printD_index printD_cont LD digitIndex BEQ printD_exit ORI 0x30 ST textChr LDWI printChar CALL giga_vAC LDI 0x30 ST digitIndex printD_exit POP RET ; prints 16bit int in textNum printInt16 PUSH LDWI printInit CALL giga_vAC LDI 0 ST digitIndex LDW textNum BGE printI16_pos LDI 0x2D ST textChr LDWI printChar CALL giga_vAC LDI 0 SUBW textNum STW textNum printI16_pos LDWI 10000 STW digitMult LDWI printDigit CALL giga_vAC LDWI 1000 STW digitMult LDWI printDigit CALL giga_vAC LDI 100 STW digitMult LDWI printDigit CALL giga_vAC LDI 10 STW digitMult LDWI printDigit CALL giga_vAC LD textNum ORI 0x30 ST textChr LDWI printChar CALL giga_vAC POP RET ; prints char in textChr printChar LD textChr ANDI 0x7F ; char can't be bigger than 127 SUBI 82 BGE printC_text82 ADDI 50 BLT printC_exit ; char<32 exit STW textChr ; char-32 LDWI giga_text32 ; text font slice base address for chars 32-81 BRA printC_font printC_text82 STW textChr ; char-82 LDWI giga_text82 ; text font slice base address for chars 82+ printC_font STW textFont LD textChr LSLW LSLW ADDW textChr ADDW textFont STW textFont ; char*5 + textFont LDI 0x05 printC_slice ST textSlice LDW textFont ; text font slice base address LUP 0x00 ; get ROM slice ST giga_sysArg2 SYS 134 ; draw vertical slice, SYS_VDrawBits_134, 270 - 134/2 = 0xCB INC textFont ; next vertical slice INC giga_sysArg4 ; next x LD textSlice SUBI 1 BNE printC_slice ST giga_sysArg2 ; result of printC_slice is 0 SYS 134 ; draw last blank slice INC giga_sysArg4 ; using sysArg4 as a temporary cursor address for multiple char prints PUSH %if TIME_SLICING CALL realTimeStubAddr %endif LDWI printClip CALL giga_vAC POP printC_exit RET printClip LD cursorXY ADDI giga_xfont ST cursorXY SUBI giga_xres - giga_xfont ; last possible char on line BLE printCl_exit LDI DISABLE_CLIP_BIT ANDW miscFlags ; is text clipping disabled? BNE printCl_exit PUSH LDWI newLineScroll ; next row, scroll at bottom CALL giga_vAC POP printCl_exit RET atTextCursor LD cursorXY SUBI giga_xres - giga_xfont BLE atTC_checkY LDI 0 ST cursorXY atTC_checkY LD cursorXY + 1 SUBI giga_yres - giga_yfont BLT atTC_resbot LDI giga_yres - giga_yfont ST cursorXY + 1 LDI ON_BOTTOM_ROW_BIT ORW miscFlags STW miscFlags ; set on bottom row flag RET atTC_resbot LDWI ON_BOTTOM_ROW_MSK ANDW miscFlags STW miscFlags ; reset on bottom row flag RET ; clears the top giga_yfont lines of pixels in preparation of text scrolling clearCursorRow PUSH LDWI SYS_SetMemory_v2_54 STW giga_sysFn ; setup fill memory SYS routine LD fgbgColour ST giga_sysArg1 ; fill value LDWI giga_videoTable PEEK ST giga_sysArg3 ; row0 high byte address LDI giga_yfont clearCR_loopy ST clearLoop LDI giga_xres ST giga_sysArg0 LDI 0 ST giga_sysArg2 ; low start address SYS 54 ; fill memory INC giga_sysArg3 ; next line LD clearLoop SUBI 1 BNE clearCR_loopy %if TIME_SLICING CALL realTimeStubAddr %endif LDWI printInit CALL giga_vAC ; re-initialise the SYS registers POP RET ; print from top row to bottom row, then start scrolling newLineScroll LDI giga_CursorX ; cursor x start ST cursorXY ST giga_sysArg4 LDI ENABLE_SCROLL_BIT ANDW miscFlags BNE newLS_cont0 ; is scroll on or off? RET newLS_cont0 PUSH LDI ON_BOTTOM_ROW_BIT ANDW miscFlags ; is on bottom row flag? BNE newLS_cont1 LD cursorXY + 1 ADDI giga_yfont ST cursorXY + 1 SUBI giga_yres BLT newLS_exit LDI giga_yres - giga_yfont ST cursorXY + 1 newLS_cont1 LDWI clearCursorRow CALL giga_vAC LDWI giga_videoTable STW scanLine %if TIME_SLICING newLS_scroll CALL realTimeStubAddr LDW scanLine %else newLS_scroll LDW scanLine %endif PEEK ADDI giga_yfont ANDI 0x7F SUBI giga_yfont BGE newLS_adjust ADDI giga_yfont newLS_adjust ADDI giga_yfont POKE scanLine INC scanLine ; scanline pointers are 16bits INC scanLine LD scanLine SUBI 0xF0 ; scanline pointers end at 0x01EE BLT newLS_scroll LDI ON_BOTTOM_ROW_BIT ORW miscFlags STW miscFlags ; set on bottom row flag newLS_exit LDWI printInit CALL giga_vAC ; re-initialise the SYS registers POP RET