diff --git a/V2Make.scpt b/V2Make.scpt index 381b267..b190355 100644 Binary files a/V2Make.scpt and b/V2Make.scpt differ diff --git a/applesoft.s b/applesoft.s index 04739f7..f03d9cd 100644 --- a/applesoft.s +++ b/applesoft.s @@ -258,13 +258,13 @@ WGAmpersandStrArgument: ldy #0 lda #'"' ; Expect opening quote cmp (TXTPTRL),y ; Can't use SYNERR here because it skips whitespace - bne WGAmpersandStrArgument_error + bne WGAmpersandStr_NotLiteral inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) bne WGAmpersandStrArgument_loop_inc0 inc TXTPTRH -WGAmpersandStrArgument_loop_inc0: +WGAmpersandStrArgument_loop_inc0: lda TXTPTRL ; Allocate for, and copy the string at TXTPTR sta PARAM0 lda TXTPTRH @@ -276,6 +276,7 @@ WGAmpersandStrArgument_loop: inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) bne WGAmpersandStrArgument_loop_inc1 inc TXTPTRH + WGAmpersandStrArgument_loop_inc1: lda (TXTPTRL),y beq WGAmpersandStrArgument_done @@ -290,8 +291,8 @@ WGAmpersandStrArgument_done: inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) bne WGAmpersandStrArgument_loop_inc2 inc TXTPTRH -WGAmpersandStrArgument_loop_inc2: +WGAmpersandStrArgument_loop_inc2: ldx PARAM0 ldy PARAM1 rts @@ -299,6 +300,20 @@ WGAmpersandStrArgument_loop_inc2: WGAmpersandStrArgument_error: jmp SYNERR +WGAmpersandStr_NotLiteral: + jsr PTRGET ; Assume string variable + ldy #0 + lda (VARPNT),y ; Grab length + tax + iny + lda (VARPNT),y ; Get string pointer out of Applesoft record + sta PARAM0 ; Allocate for, and copy the string + iny + lda (VARPNT),y + sta PARAM1 + jsr WGStorePascalStr + bra WGAmpersandStrArgument_loop_inc2 + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGAmpersandTempStrArgument diff --git a/utility.s b/utility.s index 6e116a4..c247a1d 100644 --- a/utility.s +++ b/utility.s @@ -111,6 +111,37 @@ WGStrLen_done: rts +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGAllocStr +; Finds room in our block string allocator +; Return: PARAM0: Stored string, LSB +; PARAM1: Stored string, MSB +; Null if pool is full +; X: Pool index of free space +; Side Effects: Clobbers AX +; +WGAllocStr: + ldx #0 + +WGAllocStr_findEmptyLoop: + lda WG_STRINGS,x + beq WGAllocStr_done + txa + clc + adc #16 ; String blocks are 16 bytes wide + bcs WGAllocStr_noRoom + tax + bra WGAllocStr_findEmptyLoop + +WGAllocStr_noRoom: + lda #0 + sta PARAM0 + sta PARAM1 + +WGAllocStr_done: + rts + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; WGStoreStr ; Finds room in our block allocator and copies the given string. @@ -125,26 +156,11 @@ WGStoreStr: sta WG_SCRATCHA SAVE_AXY - ldx #0 + jsr WGAllocStr + lda PARAM1 + beq WGStoreStr_done 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: @@ -172,3 +188,51 @@ WGStoreStr_terminate: WGStoreStr_done: RESTORE_AXY rts + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; WGStorePascalStr +; Finds room in our block allocator and copies the given string. +; X: Length +; PARAM0: String pointer, LSB +; PARAM1: String pointer, MSB +; Return: PARAM0: Stored string, LSB +; PARAM1: Stored string, MSB +; Side Effects: Clobbers SA +; +WGStorePascalStr: + stx WG_SCRATCHA + SAVE_AXY + + jsr WGAllocStr + lda PARAM1 + beq WGStorePascalStr_done + ldy #0 + + phx ; Remember the start of our string + +WGStorePascalStr_copyLoop: + cpy WG_SCRATCHA + beq WGStorePascalStr_terminate + lda (PARAM0),y + sta WG_STRINGS,x + inx + iny + cpy #15 ; Clip string to maximum block size + bne WGStorePascalStr_copyLoop + +WGStorePascalStr_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 PARAM1 + +WGStorePascalStr_done: + RESTORE_AXY + rts diff --git a/weegui.dsk b/weegui.dsk index aede2c6..6f4c5bd 100644 Binary files a/weegui.dsk and b/weegui.dsk differ