From 7207675b352a9fae6fe3c162b47d983c3e1c76a1 Mon Sep 17 00:00:00 2001 From: Quinn Dunki Date: Tue, 16 Sep 2014 14:04:05 -0700 Subject: [PATCH] - Fixed parameter-less AppleSoft commands - Added support for struct parameters in AppleSoft - Added &HOME - Renamed &VIEW to &WINDOW - Separated style and ID bytes in view creation - View state, callbacks, and title pointers are now initialized - NULL pointers are handled in window titles - Added function to restore a valid cursor state for AppleSoft upon API exit --- applesoft.s | 115 +++++++++++++++++++++++++++++++++++++++++++++++----- gui.s | 2 +- guidemo.dsk | Bin 143360 -> 143360 bytes switches.s | 3 ++ views.s | 44 ++++++++++++-------- zeropage.s | 9 ++-- 6 files changed, 141 insertions(+), 32 deletions(-) diff --git a/applesoft.s b/applesoft.s index 9cc4e15..b35add0 100644 --- a/applesoft.s +++ b/applesoft.s @@ -22,6 +22,7 @@ GETNUM = $e746 ; Gets an 8-bit, stores it X, skips past a comma ERR_UNDEFINEDFUNC = 224 ERR_SYNTAX = 16 +ERR_ENDOFDATA = 5 ERR_TOOLONG = 176 MAXCMDLEN = 14 @@ -62,7 +63,7 @@ WGAmpersand: WGAmpersand_parseLoop: txa - beq WGAmpersand_parseFail ; Check for end-of-statement (CHRGET handles : and EOL) + beq WGAmpersand_matchStart ; Check for end-of-statement (CHRGET handles : and EOL) cmp #'(' beq WGAmpersand_matchStart @@ -190,6 +191,57 @@ WGAmpersandIntArguments_done: rts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGAmpersandStructArgument +; Buffers integer arguments for current command into a struct +; TXTPTR: Start of argument list (after opening parenthesis) +; OUT PARAM0/1 : Pointer to struct containing int values +WGAmpersandStructArgument: + SAVE_AXY + + ldy #0 + phy ; Can't rely on Applesoft routines to be register-safe + + lda #'(' + jsr SYNCHR ; Expect opening parenthesis + +WGAmpersandStructArguments_loop: + jsr GETBYT + txa + ply + sta WGAmpersandCommandBuffer,y + phy + + jsr CHRGOT + cmp #')' ; All done! + beq WGAmpersandStructArguments_cleanup + jsr CHKCOM ; Verify parameter separator + + ply + iny + phy + cpy #WGAmpersandCommandBufferEnd-WGAmpersandCommandBuffer ; Check for too many arguments + bne WGAmpersandStructArguments_loop + +WGAmpersandStructArguments_fail: + ldx #ERR_TOOLONG + jsr ERROR + bra WGAmpersandStructArguments_done + +WGAmpersandStructArguments_cleanup: + jsr CHRGET ; Consume closing parenthesis + +WGAmpersandStructArguments_done: + ply + + lda #WGAmpersandCommandBuffer + sta PARAM1 + + RESTORE_AXY + rts + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGAmpersandStrArgument @@ -256,25 +308,62 @@ WGAmpersandStrArguments_done: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -; WGAmpersand_VIEW -; Create a view -; -WGAmpersand_VIEW: - jsr WGAmpersandStrArguments +; WGAmpersand_HOME +; Clears the screen +; &HOME +WGAmpersand_HOME: + jsr WGClearScreen + jsr WGBottomCursor - jsr WGCreateView - jsr WGPaintView rts + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGAmpersand_DESK ; Render the desktop -; +; &DESK WGAmpersand_DESK: jsr WGDesktop + jsr WGBottomCursor rts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGAmpersand_WINDOW +; Create a view +; &WINDOW(id,style,x,y,width,height,canvas width,canvas height) +WGAmpersand_WINDOW: + jsr WGAmpersandStructArgument + jsr WGCreateView + jsr WGPaintView + jsr WGBottomCursor + + rts + + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGBottomCursor +; Leave the cursor state in a place that Applesoft is happy with +; +WGBottomCursor: + SAVE_AY + + lda #0 + sta CH + sta OURCH + lda #23 + sta CV + sta OURCV + + lda TEXTLINES_H+23 + sta BASH + lda TEXTLINES_L+23 + sta BASL + + RESTORE_AY + rts + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -291,12 +380,16 @@ WGAmpersandCommandBufferEnd: ; Jump table for ampersand commands. ; Each row is 16 bytes (14 for name, 2 for address) WGAmpersandCommandTable: -.byte "VIEW",0,0,0,0,0,0,0,0,0,0 -.addr WGAmpersand_VIEW + +.byte $97,0,0,0,0,0,0,0,0,0,0,0,0,0 ; HOME +.addr WGAmpersand_HOME .byte "DESK",0,0,0,0,0,0,0,0,0,0 .addr WGAmpersand_DESK +.byte "WINDOW",0,0,0,0,0,0,0,0 +.addr WGAmpersand_WINDOW + WGAmpersandCommandTableEnd: diff --git a/gui.s b/gui.s index add2d59..bcea203 100644 --- a/gui.s +++ b/gui.s @@ -271,7 +271,7 @@ read80ColSwitch_40: testView: - .byte $10,7,3,62,18,80,25 + .byte 0,1,7,3,62,18,80,25 testCheck: .byte 1,16,4 diff --git a/guidemo.dsk b/guidemo.dsk index b5c3612e9206a02bc35272f84b564a9dc5701c5e..13c72c999e993034ff72f6349b068d9a39e536c9 100644 GIT binary patch delta 2679 zcmai0eQZ-z6o0SVx(>z|Fx=WPb`_8{K}66<776>{<8AHM-YvLT6Ris5X<`%-W7vXy zemo_U=YW^V%7>If&E8^32Z^S};S@3363AkRX5BZGQ3e|i4G99vJokO9Ee3sm+;i?Z z_nvcp=bU@r88hG6fdDRA@+(yyKYVEi7-oSFhsr zQ;h&PIEZJ#*BTzfat1-)z{I#Q)iCVV)m`KZM{&ipo006oofN4_+<9P$C%3yuUI54eU|UybR_}yAn*iPXO7z!{u(0z*-iB9Jx@4tcbSPhhJDl-47nalUU9aI&9%v zSopz)ezL`*)Y>v&^xnpSbgxWGq}h(EZV}a_QoS$w@!kRKW}>*5HqoJ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%l!@v^Accjz)m_rEev=I3eN|S3n)-7kS_ox50-yJ zKbwy^yd=1)$U0JBzXDfyC_quaG}$T|`b?F3A@SrM$QzxnvkGSDN^A8EvtU-Th7Iz* zWdmJTU-{!!Jj>z~+th&C>c4EpN6mvQzHUw|MUT|are%l3uD-H$_jd{~Nb{=0Fg2u= zi}gHMj?P-eANw8#q||=#;2IUm8Wl@Gy`NF1hgexkpa7y78y(V~_TW_hA<={<6(~DJ z_Wz>t`0%0!PoR~V9CpF9kjK;}n*bTWM9?L7ii0OAUJNwwI&_WU3()cgbsqD+74Vq? zyMPsgVZep~XbV4CLJnFkl(z5>NMYWFB}@>5(+}q*E0$bvMzvrjInx|3oV_Q?8<W=3xM~0giIfx78u#l+jjeE*wTZVwiOjFrho>GCzdGq(c=f&?^5^-~%H^4U zA#DhgIpJ~3D<|AoUdI2lFr$9sOFQsIbK>`bSv!Ug^+Y3XU)8FY>N?jMAIXv!Em?CLm+-)XhxNyQ1cj4+877xG)W5U<+ZE=sA zaG;Ks0iX$&gUUSa%*~tjaWk&^SOQWPcqma^z|=-JjBS$f5c!u;6sF*x$6QJrIr9X) zTKwXSWnB+DJ}&WVOe5>>!e+P&Kim>@yz*n;Ru2=7Ua4d6IXI4;cCbgB;)?Jt&2gvr za@ebvog6H-!zq3jUfVm^b(S6~9_~Kpp~dU*ir#Z&v_X96+~MJ_!GpAD&~zP1e3YR1 Fe*gzY=Y#+N diff --git a/switches.s b/switches.s index ceeeb9d..81181c8 100644 --- a/switches.s +++ b/switches.s @@ -27,3 +27,6 @@ KBD = $c000 ; Read KBDSTRB = $c010 ; Read/Write RDVBLBAR = $C019 ; Read bit 7 (active low) + +OURCH = $057b ; 80 col cursor position (H) +OURCV = $05fb ; 80 col cursor position (V) diff --git a/views.s b/views.s index bef1f5f..72cc2db 100644 --- a/views.s +++ b/views.s @@ -15,7 +15,8 @@ ; PARAM1: Pointer to configuration struct (MSB) ; ; Configuration struct: -; ST: (4:4) Style:ID +; ID: View ID (0-f) +; ST: Style ; XX: Screen X origin ; YY: Screen Y origin ; SW: Screen width @@ -29,22 +30,17 @@ WGCreateView: ldy #0 lda (PARAM0),y - pha - and #%00001111 ; Find our new view record - jsr WGSelectView + jsr WGSelectView ; Find our new view record asl asl asl asl ; Records are 8 bytes wide tax - pla ; Cache style nybble for later - lsr - lsr - lsr - lsr - pha + iny + lda (PARAM0),y + pha ; Cache style byte for later iny lda (PARAM0),y @@ -85,6 +81,18 @@ WGCreateView: lda (PARAM0),y sta WG_VIEWRECORDS,x ; View Height + lda #0 + inx ; Initialize state + sta WG_VIEWRECORDS,x + inx + sta WG_VIEWRECORDS,x ; Initialize callback + inx + sta WG_VIEWRECORDS,x + inx + sta WG_VIEWRECORDS,x ; Initialize title + inx + sta WG_VIEWRECORDS,x + WGCreateView_done: RESTORE_ZPS RESTORE_AXY @@ -99,7 +107,7 @@ WGCreateView_done: ; PARAM1: Pointer to configuration struct (MSB) ; ; Configuration struct: -; ST: (4:4) Reserved:ID +; ID: View ID (0-f) ; XX: Screen X origin ; YY: Screen Y origin ; @@ -110,8 +118,7 @@ WGCreateCheckbox: ldy #0 lda (PARAM0),y - and #%00001111 ; Find our new view record - jsr WGSelectView + jsr WGSelectView ; Find our new view record asl asl asl @@ -171,7 +178,7 @@ WGCreateCheckbox_done: ; PARAM1: Pointer to configuration struct (MSB) ; ; Configuration struct: -; ST: (4:4) Reserved:ID +; ID: View ID (0-f) ; XX: Screen X origin ; YY: Screen Y origin ; BW: Button width @@ -182,8 +189,7 @@ WGCreateButton: ldy #0 lda (PARAM0),y - and #%00001111 ; Find our new view record - jsr WGSelectView + jsr WGSelectView ; Find our new view record asl asl asl @@ -428,7 +434,13 @@ paintWindowTitle: sta PARAM0 lda WG_VIEWRECORDS+12,y sta PARAM1 + bne paintWindowTitle_compute +paintWindowTitle_checkNull: + lda PARAM0 + beq paintWindowTitle_done + +paintWindowTitle_compute: jsr WGStrLen ; Compute centering offset for title lsr sta SCRATCH1 diff --git a/zeropage.s b/zeropage.s index b8c1632..57b6f83 100644 --- a/zeropage.s +++ b/zeropage.s @@ -9,10 +9,11 @@ ; Reserved locations -INVERSE = $32 -BASL = $28 -BASH = $29 - +INVERSE = $32 ; Text output state +CH = $24 ; Cursor X pos +CV = $25 ; Cursor Y pos +BASL = $28 ; Current video memory line +BASH = $29 ; Current video memory line ; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS) PARAM0 = $06