{-----------------------------------------------------------------------+ | | | Application menu | | | +-----------------------------------------------------------------------} gcl0x { Fall into Easter Egg if [Start] is pressed for >4 seconds } \buttonState; {Fetch buttonState and resetTimer} [if>0 {If resetTimer positive} 16& [if=0 {And [Start] pressed} \Egg \sysArgs0: 88!!]] {Start program. SYS_Exec_88 still in sysFn} { Print a 5x8 character on screen with the built-in font Char must be in the 32-127 range (this is not checked) } [def {PrintChar} {Map ASCII code to offset in font table} Char 82- [if<0 50+ i= \font32up else i= \font82up] fontData= {Select low or high page} i 2<< i+ {Multiply by 5} fontData+ fontData= {Add to page address to reach bitmap data for Char} {Draw 5 vertical slices: 5 using font data} 32 \sysArgs0. {Blue} Color \sysArgs1. Pos \sysArgs4: 6+ Pos= \SYS_VDrawBits_134 \sysFn: $fb i= [do fontData 0? fontData<++ \sysArgs2. 134!! \sysArgs4<++ i<++ i if<>0loop] ret ] PrintChar= [def {PrintText} push Text= [do Text, if<>0 Char= Text<++ {while((Char=*Text++)!=0)...} 9^ [if=0 Pos 18+ Pos= loop] {Horizontal tab} 3^ [if=0 Newline! loop] {Newline 9^10=3} PrintChar! {Regular character} loop] pop ret ] PrintText= { Print 26 dashes } [def push $2d {'-'} Char= 26 [do j= PrintChar! j 1- if>0loop] Newline! pop ret ] PrintDivider= [def push Item 6- [if<0 $2006 else $f054] Pos= Item [do j= $800 Pos+ Pos= j 1- if>=0loop] $2d {'-'} Char= PrintChar! $3e {'>'} Char= PrintChar! pop ret ] PrintArrow= {-----------------------------------------------------------------------+ |}\vLR>++ ret{ RAM page 3 | +-----------------------------------------------------------------------} $0300: { Operate menu } [def push 0 Item= [do \frameCount, Color= PrintArrow! { Handle each stroke of Up/Down and A controller buttons } {buttonRight} \buttonState, 254^ [if=0 WipeOutArrow! Item 4- [if<=0 10+ Item=] \buttonState, 1| \buttonState.] {buttonLeft} \buttonState, 253^ [if=0 WipeOutArrow! Item 6- [if>=0 Item=] \buttonState, 2| \buttonState.] {buttonDown} \buttonState, 251^ [if=0 WipeOutArrow! Item 5- [if<>0 5- if<>0 Item<++] \buttonState, 4| \buttonState.] {buttonUp} \buttonState, 247^ [if=0 WipeOutArrow! Item [if<>0 6- if<>0 Item 1- Item=] \buttonState, 8| \buttonState.] {buttonA} \buttonState, 127^ if<>0loop 42 {Gray} Color= PrintArrow! { Map menu item to program } Item [if=0 \Snake else 1- [if=0 \Racer else 1- [if=0 \Mandelbrot else 1- [if=0 \Pictures else 1- [if=0 \Credits else 1- [if=0 \Loader else 1- [if=0 \Tetronis else 1- [if=0 \Bricks else 2- [if<=0 \TinyBASIC else {TicTacToe and stand-alone BASIC} 1- [if=0 \WozMon else loop]]]]]]]]]] Program= ] pop ret ] SelectMenu= {-----------------------------------------------------------------------+ |}\vLR>++ ret{ RAM page 4 | +-----------------------------------------------------------------------} $0400: [def {Newline} Pos>, 8+ Pos>. 2 Pos<. ret ] Newline= [def #9 `Snake #9 ``` #9 `Tetronis #10 #9 `Racer #9 ``` #9 `Bricks #10 #9 `Mandelbrot #9 `TicTacToe #10 #9 `Pictures ``` #9 `BASIC #10 #9 `Credits #9 #9 `WozMon #10 #9 `Loader #10 #0 ] MainMenu= [def `Use` #91 `Arrows #93 ``to`select #10 `Press` #91 `A #93 ``to`start`program #10 #10 `Hold` #91 `Start #93 ``for`reset #0 ] HelpText= [def push Pos 12- Pos= $20 {space} Char= PrintChar! PrintChar! pop ret ] WipeOutArrow= {-----------------------------------------------------------------------+ |}\vLR>++ ret{ RAM page 5 | +-----------------------------------------------------------------------} $0500: [def {PrintMenu} push 42 {Gray} Color= PrintDivider! 15 {Yellow} Color= MainMenu PrintText! 42 {Gray} Color= PrintDivider! HelpText PrintText! pop ret ] PrintMenu= 120 \soundTimer. $2002 Pos= PrintMenu! SelectMenu! { Wipe out everything but the selected and bottom line } $800 \sysArgs4: {Pointer in screen memory} $8801 i= {Offset to next stripe} $ff80 j= {Mask for keeping the selected item} Pos 48+ j& q= {Box of current cursor} \SYS_VDrawBits_134 \sysFn: {SYS function} 32 \sysArgs0. \sysArgs1. {Colors} [do \sysArgs4; [do 48+ j& q^ [if<>0 {Don't clear selected item} p>, $78^ if<>0 {Also don't clear the bottom row} 134!!] {Clears 8 pixels vertically} $800 \ADDW# \sysArgs4# {Inline assembly} \sysArgs4: if>0loop] {Step down} i+ \sysArgs4: 255& 160^ if<>0loop] {Next stripe} { Load and start the selected program } \SYS_Exec_88 \sysFn: {ROM loader} Program \sysArgs0: {ROM image} $200 \vLR: {Start of execution address} Item 6^ [if=0 {Tetronis workaround} $80 \vSP. { 1. Zero-page conflict: move stack} $6f9 \vLR:] { 2. Stack must be restored with patch} Item 7^ [if=0 {Bricks workaround} $80 \vSP.] { 1. Zero-page conflict: move stack} Item 8^ [if=0 {TicTacToe needs special launcher} $7fa0 call] 88!! {Load from ROM and execute} {-----------------------------------------------------------------------+ | Tetronis patch | +-----------------------------------------------------------------------} $6f9: $200 \vSP. call {Restore stack pointer and go to entry_point} {-----------------------------------------------------------------------+ | Tic Tac Toe launcher | +-----------------------------------------------------------------------} $7fa0: 11+ \vLR: {Return to this program after SYS} \TinyBASIC \sysArgs0: 88!! {Load only, SYS_Exec_88 still in sysFn} {Return here} $200 \vLR: \TicTac \sysArgs0: 88!! {Load Tic-Tac-Toe and execute BASIC} {-----------------------------------------------------------------------+ | | +-----------------------------------------------------------------------}