diff --git a/applesoft.s b/applesoft.s index b35add0..4906717 100644 --- a/applesoft.s +++ b/applesoft.s @@ -14,7 +14,8 @@ WG_AMPVECTOR = $03f5 CHRGET = $00b1 ; Advances text point and gets character in A CHRGOT = $00b7 ; Returns character at text pointer in A SYNCHR = $dec0 ; Validates current character is what's in A -TXTPTR = $00b8 ; (and $b9) ; Current location in BASIC listing +TXTPTRL = $00b8 ; Current location in BASIC listing (LSB) +TXTPTRH = $00b9 ; Current location in BASIC listing (MSB) ERROR = $d412 ; Reports error in X CHKCOM = $debe ; Validates current character is a ',', then gets it GETBYT = $e6f8 ; Gets an integer at text pointer, stores in X @@ -206,12 +207,17 @@ WGAmpersandStructArgument: jsr SYNCHR ; Expect opening parenthesis WGAmpersandStructArguments_loop: + jsr CHRGOT + cmp #'"' ; Check for string pointer + beq WGAmpersandStructArguments_string + jsr GETBYT txa ply sta WGAmpersandCommandBuffer,y phy +WGAmpersandStructArguments_nextParam: jsr CHRGOT cmp #')' ; All done! beq WGAmpersandStructArguments_cleanup @@ -228,8 +234,37 @@ WGAmpersandStructArguments_fail: jsr ERROR bra WGAmpersandStructArguments_done +WGAmpersandStructArguments_string: + jsr CHRGET ; Consume opening quote + lda TXTPTRL ; Allocate for, and copy the string at TXTPTR + sta PARAM0 + lda TXTPTRH + sta PARAM1 + lda #'"' ; Specify quote as our terminator + jsr WGStoreStr + + ply ; Store returned string pointer in our struct + lda PARAM1 + sta WGAmpersandCommandBuffer,y + iny + lda PARAM0 + sta WGAmpersandCommandBuffer,y + iny + phy + +WGAmpersandStructArguments_stringLoop: + jsr CHRGET ; Consume the rest of the string + beq WGAmpersandStructArguments_stringLoopDone + cmp #'"' ; Check for closing quote + beq WGAmpersandStructArguments_stringLoopDone + bra WGAmpersandStructArguments_stringLoop + +WGAmpersandStructArguments_stringLoopDone: + jsr CHRGET ; Consume closing quote + bra WGAmpersandStructArguments_nextParam + WGAmpersandStructArguments_cleanup: - jsr CHRGET ; Consume closing parenthesis + jsr CHRGET ; Consume closing parenthesis WGAmpersandStructArguments_done: ply @@ -341,6 +376,39 @@ WGAmpersand_WINDOW: rts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGAmpersand_CHECKBOX +; Create a checkbox +; &CHECKBOX(id,x,y) +WGAmpersand_CHECKBOX: + jsr WGAmpersandStructArgument + jsr WGCreateCheckbox + jsr WGPaintView + jsr WGBottomCursor + + rts + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGAmpersand_BUTTON +; Create a button +; &BUTTON(id,x,y,width,"title") +WGAmpersand_BUTTON: + jsr WGAmpersandStructArgument + jsr WGCreateButton + + lda WGAmpersandCommandBuffer+4 + sta PARAM0 + lda WGAmpersandCommandBuffer+5 + sta PARAM1 + jsr WGViewSetTitle + + jsr WGPaintView + jsr WGBottomCursor + + rts + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGBottomCursor @@ -379,6 +447,11 @@ WGAmpersandCommandBufferEnd: ; Jump table for ampersand commands. ; Each row is 16 bytes (14 for name, 2 for address) +; +; Note the strange byte values amidst some strings- this is because +; all text is tokenized before we receive it, so reserved words may +; be compressed +; WGAmpersandCommandTable: .byte $97,0,0,0,0,0,0,0,0,0,0,0,0,0 ; HOME @@ -390,6 +463,12 @@ WGAmpersandCommandTable: .byte "WINDOW",0,0,0,0,0,0,0,0 .addr WGAmpersand_WINDOW +.byte "CHECKBOX",0,0,0,0,0,0 +.addr WGAmpersand_CHECKBOX + +.byte "BUT",$c1,"N",0,0,0,0,0,0,0,0,0 ; BUTTON +.addr WGAmpersand_BUTTON + WGAmpersandCommandTableEnd: diff --git a/gui.s b/gui.s index bcea203..b14c465 100644 --- a/gui.s +++ b/gui.s @@ -21,7 +21,7 @@ main: jsr WGInit jsr WG80 - ;rts + rts ;jmp tortureTestPrint ;jmp tortureTestRects diff --git a/guidemo.dsk b/guidemo.dsk index 13c72c9..da24691 100644 Binary files a/guidemo.dsk and b/guidemo.dsk differ diff --git a/memory.s b/memory.s index d310bb1..6763c31 100644 --- a/memory.s +++ b/memory.s @@ -71,6 +71,24 @@ WG_VIEWRECORDS: .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 .byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +WG_STRINGS: ; Fixed-size block allocator for strings (view titles, mainly) +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 +.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 + WG_SCRATCHA: .byte 0 diff --git a/utility.s b/utility.s index d151ea0..9d2bf7b 100644 --- a/utility.s +++ b/utility.s @@ -125,7 +125,7 @@ scanHex8: WGStrLen: phy - ldy #$0 + ldy #0 WGStrLen_loop: lda (PARAM0),y beq WGStrLen_done @@ -138,3 +138,64 @@ WGStrLen_done: rts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGStoreStr +; Finds room in our block allocator and copies the given string. +; A: Terminator character +; PARAM0: String pointer, LSB +; PARAM1: String pointer, MSB +; Return: PARAM0: Stored string, LSB +; PARAM1: Stored string, MSB +; Side Effects: Clobbers SA +; +WGStoreStr: + sta WG_SCRATCHA + SAVE_AXY + + ldx #0 + ldy #0 + +WGStoreStr_findEmptyLoop: + lda WG_STRINGS,x + beq WGStoreStr_copy + txa + clc + adc #16 ; String blocks are 16 bytes wide + bcs WGStoreStr_noRoom + tax + bra WGStoreStr_findEmptyLoop + +WGStoreStr_noRoom: + lda #0 + sta PARAM0 + sta PARAM1 + bra WGStoreStr_done + +WGStoreStr_copy: + phx ; Remember the start of our string + +WGStoreStr_copyLoop: + lda (PARAM0),y + cmp WG_SCRATCHA + beq WGStoreStr_terminate + sta WG_STRINGS,x + inx + iny + cpy #15 ; Clip string to maximum block size + bne WGStoreStr_copyLoop + +WGStoreStr_terminate: + lda #0 ; Terminate the stored string + sta WG_STRINGS,x + + pla ; Return pointer to the start of the block + clc + adc #>WG_STRINGS + sta PARAM0 + lda #0 + adc #