a bit smaller code

This commit is contained in:
Peter Ferrie 2018-03-07 14:38:22 -08:00
parent a81df445d3
commit 258987b04f
6 changed files with 137 additions and 218 deletions

View File

@ -84,24 +84,22 @@ WGAmpersand:
sta SCRATCH0 sta SCRATCH0
ldy #0 ldx #0
ldx SCRATCH0
WGAmpersand_parseLoop: WGAmpersand_parseLoop:
txa tay
beq WGAmpersand_matchStart ; Check for end-of-statement (CHRGET handles : and EOL) beq WGAmpersand_matchStart ; Check for end-of-statement (CHRGET handles : and EOL)
cmp #'(' cmp #'('
beq WGAmpersand_matchStart beq WGAmpersand_matchStart
cmp #':' cmp #':'
beq WGAmpersand_matchStart beq WGAmpersand_matchStart
sta WGAmpersandCommandBuffer,y sta WGAmpersandCommandBuffer,x
jsr CHRGET jsr CHRGET
tax
iny inx
cpy #MAXCMDLEN+1 cpx #MAXCMDLEN+1
bne WGAmpersand_parseLoop bne WGAmpersand_parseLoop
WGAmpersand_parseFail: WGAmpersand_parseFail:
@ -110,27 +108,25 @@ WGAmpersand_parseFail:
bra WGAmpersand_done bra WGAmpersand_done
WGAmpersand_matchStart: WGAmpersand_matchStart:
lda #0 stz WGAmpersandCommandBuffer,x ; Null terminate the buffer for matching
sta WGAmpersandCommandBuffer,y ; Null terminate the buffer for matching
ldy #0
ldx #0 ; Command buffer now contains our API call ldx #0 ; Command buffer now contains our API call
phx ; We stash the current command number on the stack phx ; We stash the current command number on the stack
WGAmpersand_matchReset:
ldy #0
WGAmpersand_matchLoop: WGAmpersand_matchLoop:
lda WGAmpersandCommandBuffer,y lda WGAmpersandCommandBuffer,y
beq WGAmpersand_matchPossible
cmp WGAmpersandCommandTable,x cmp WGAmpersandCommandTable,x
bne WGAmpersand_matchNext ; Not this one bne WGAmpersand_matchNext ; Not this one
cmp #0
beq WGAmpersand_matchFound ; Got one!
iny iny
inx inx
bra WGAmpersand_matchLoop bra WGAmpersand_matchLoop
WGAmpersand_matchPossible:
lda WGAmpersandCommandTable,x
beq WGAmpersand_matchFound ; Got one!
WGAmpersand_matchNext: WGAmpersand_matchNext:
pla ; Advance index to next commmand in table pla ; Advance index to next commmand in table
inc inc
@ -141,27 +137,7 @@ WGAmpersand_matchNext:
tax tax
cpx #WGAmpersandCommandTableEnd-WGAmpersandCommandTable cpx #WGAmpersandCommandTableEnd-WGAmpersandCommandTable
beq WGAmpersand_matchFail ; Hit the end of the table bne WGAmpersand_matchReset ; Continue until hit the end of the table
ldy #0
bra WGAmpersand_matchLoop
WGAmpersand_matchFound:
pla ; This is now the matching command number
inc
asl
asl
asl
tay
lda WGAmpersandCommandTable-2,y ; Prepare an indirect JSR to our command
sta WGAmpersand_commandJSR+1 ; Self-modifying code!
lda WGAmpersandCommandTable-1,y
sta WGAmpersand_commandJSR+2
; Self-modifying code!
WGAmpersand_commandJSR:
jsr WGAmpersand_done ; Address here overwritten with command
bra WGAmpersand_done
WGAmpersand_matchFail: WGAmpersand_matchFail:
pla ; We left command number on the stack while matching pla ; We left command number on the stack while matching
@ -171,6 +147,19 @@ WGAmpersand_matchFail:
WGAmpersand_done: WGAmpersand_done:
rts rts
WGAmpersand_matchFound:
pla ; This is now the matching command number
inc
asl
asl
asl
tax
jsr WGAmpersand_commandJMP
bra WGAmpersand_done
WGAmpersand_commandJMP:
jmp (WGAmpersandCommandTable-2,x)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -249,6 +238,14 @@ WGAmpersandAddrArgument:
rts rts
WGIncTXTPTR:
inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues)
bne WGIncTXTPTRRet
inc TXTPTRH
WGIncTXTPTRRet:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersandStrArgument ; WGAmpersandStrArgument
; Reads a string argument for the current command in PARAM0/1. ; Reads a string argument for the current command in PARAM0/1.
@ -257,16 +254,12 @@ WGAmpersandAddrArgument:
; OUT Y : Pointer to a stored copy of the string (MSB) ; OUT Y : Pointer to a stored copy of the string (MSB)
; Side effects: Clobbers P0/P1 and all registers ; Side effects: Clobbers P0/P1 and all registers
WGAmpersandStrArgument: WGAmpersandStrArgument:
ldy #0
lda #'"' ; Expect opening quote lda #'"' ; Expect opening quote
cmp (TXTPTRL),y ; Can't use SYNERR here because it skips whitespace cmp (TXTPTRL) ; Can't use SYNERR here because it skips whitespace
bne WGAmpersandStr_NotLiteral bne WGAmpersandStr_NotLiteral
inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) jsr WGIncTXTPTR
bne WGAmpersandStrArgument_loop_inc0
inc TXTPTRH
WGAmpersandStrArgument_loop_inc0:
lda TXTPTRL ; Allocate for, and copy the string at TXTPTR lda TXTPTRL ; Allocate for, and copy the string at TXTPTR
sta PARAM0 sta PARAM0
lda TXTPTRH lda TXTPTRH
@ -275,26 +268,21 @@ WGAmpersandStrArgument_loop_inc0:
jsr WGStoreStr jsr WGStoreStr
WGAmpersandStrArgument_loop: WGAmpersandStrArgument_loop:
inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) jsr WGIncTXTPTR
bne WGAmpersandStrArgument_loop_inc1
inc TXTPTRH
WGAmpersandStrArgument_loop_inc1: lda (TXTPTRL)
lda (TXTPTRL),y
beq WGAmpersandStrArgument_done beq WGAmpersandStrArgument_done
cmp #'"' ; Check for closing quote cmp #'"' ; Check for closing quote
bne WGAmpersandStrArgument_loop bne WGAmpersandStrArgument_loop
WGAmpersandStrArgument_done: WGAmpersandStrArgument_done:
lda #'"' ; Expect closing quote lda #'"' ; Expect closing quote
cmp (TXTPTRL),y ; Can't use SYNERR here because it skips whitespace cmp (TXTPTRL) ; Can't use SYNERR here because it skips whitespace
bne WGAmpersandStrArgument_error bne WGAmpersandStrArgument_error
inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) jsr WGIncTXTPTR
bne WGAmpersandStrArgument_loop_inc2
inc TXTPTRH
WGAmpersandStrArgument_loop_inc2: WGAmpersandStrArgument_load:
ldx PARAM0 ldx PARAM0
ldy PARAM1 ldy PARAM1
rts rts
@ -304,17 +292,16 @@ WGAmpersandStrArgument_error:
WGAmpersandStr_NotLiteral: WGAmpersandStr_NotLiteral:
jsr PTRGET ; Assume string variable jsr PTRGET ; Assume string variable
ldy #0 lda (VARPNT) ; Grab length
lda (VARPNT),y ; Grab length
tax tax
iny ldy #1
lda (VARPNT),y ; Get string pointer out of Applesoft record lda (VARPNT),y ; Get string pointer out of Applesoft record
sta PARAM0 ; Allocate for, and copy the string sta PARAM0 ; Allocate for, and copy the string
iny iny
lda (VARPNT),y lda (VARPNT),y
sta PARAM1 sta PARAM1
jsr WGStorePascalStr jsr WGStorePascalStr
bra WGAmpersandStrArgument_loop_inc2 bra WGAmpersandStrArgument_load
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -326,15 +313,11 @@ WGAmpersandStr_NotLiteral:
; OUT A : String length ; OUT A : String length
; Side effects: Clobbers P0/P1 and all registers ; Side effects: Clobbers P0/P1 and all registers
WGAmpersandTempStrArgument: WGAmpersandTempStrArgument:
ldy #0
lda #'"' ; Expect opening quote lda #'"' ; Expect opening quote
cmp (TXTPTRL),y ; Can't use SYNERR here because it skips whitespace cmp (TXTPTRL) ; Can't use SYNERR here because it skips whitespace
bne WGAmpersandTempStrArgument_error bne WGAmpersandTempStrArgument_error
inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) jsr WGIncTXTPTR
bne WGAmpersandTempStrArgument_loop_inc0
inc TXTPTRH
WGAmpersandTempStrArgument_loop_inc0:
lda TXTPTRL ; Grab current TXTPTR lda TXTPTRL ; Grab current TXTPTR
sta PARAM0 sta PARAM0
@ -342,24 +325,18 @@ WGAmpersandTempStrArgument_loop_inc0:
sta PARAM1 sta PARAM1
WGAmpersandTempStrArgument_loop: WGAmpersandTempStrArgument_loop:
inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) jsr WGIncTXTPTR
bne WGAmpersandTempStrArgument_loop_inc1 lda (TXTPTRL)
inc TXTPTRH
WGAmpersandTempStrArgument_loop_inc1:
lda (TXTPTRL),y
beq WGAmpersandTempStrArgument_done beq WGAmpersandTempStrArgument_done
cmp #'"' ; Check for closing quote cmp #'"' ; Check for closing quote
bne WGAmpersandTempStrArgument_loop bne WGAmpersandTempStrArgument_loop
WGAmpersandTempStrArgument_done: WGAmpersandTempStrArgument_done:
lda #'"' ; Expect closing quote lda #'"' ; Expect closing quote
cmp (TXTPTRL),y ; Can't use SYNERR here because it skips whitespace cmp (TXTPTRL) ; Can't use SYNERR here because it skips whitespace
bne WGAmpersandTempStrArgument_error bne WGAmpersandTempStrArgument_error
inc TXTPTRL ; Can't use CHRGET here, because it skips leading whitespace (among other issues) jsr WGIncTXTPTR
bne WGAmpersandTempStrArgument_loop_inc2
inc TXTPTRH
WGAmpersandTempStrArgument_loop_inc2:
; Compute the 8-bit distance TXTPTR moved. Note that we can't simply ; Compute the 8-bit distance TXTPTR moved. Note that we can't simply
; count in the above loop, because CHRGET will skip ahead unpredictable ; count in the above loop, because CHRGET will skip ahead unpredictable
@ -485,6 +462,7 @@ WGAmpersand_CHKBX:
CALL16 WGCreateCheckbox,WGAmpersandCommandBuffer CALL16 WGCreateCheckbox,WGAmpersandCommandBuffer
WGFlagView:
LDY_ACTIVEVIEW ; Flag this as an Applesoft-created view LDY_ACTIVEVIEW ; Flag this as an Applesoft-created view
lda #VIEW_STYLE_APPLESOFT lda #VIEW_STYLE_APPLESOFT
ora WG_VIEWRECORDS+4,y ora WG_VIEWRECORDS+4,y
@ -523,16 +501,7 @@ WGAmpersand_RADIO:
CALL16 WGCreateRadio,WGAmpersandCommandBuffer CALL16 WGCreateRadio,WGAmpersandCommandBuffer
LDY_ACTIVEVIEW ; Flag this as an Applesoft-created view jmp WGFlagView
lda #VIEW_STYLE_APPLESOFT
ora WG_VIEWRECORDS+4,y
sta WG_VIEWRECORDS+4,y
jsr WGPaintView
jsr WGBottomCursor
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -561,15 +530,7 @@ WGAmpersand_PROG:
CALL16 WGCreateProgress,WGAmpersandCommandBuffer CALL16 WGCreateProgress,WGAmpersandCommandBuffer
LDY_ACTIVEVIEW ; Flag this as an Applesoft-created view jmp WGFlagView
lda #VIEW_STYLE_APPLESOFT
ora WG_VIEWRECORDS+4,y
sta WG_VIEWRECORDS+4,y
jsr WGPaintView
jsr WGBottomCursor
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -652,15 +613,7 @@ WGAmpersand_BUTTN:
CALL16 WGCreateButton,WGAmpersandCommandBuffer CALL16 WGCreateButton,WGAmpersandCommandBuffer
LDY_ACTIVEVIEW ; Flag this as an Applesoft-created view jmp WGFlagView
lda #VIEW_STYLE_APPLESOFT
ora WG_VIEWRECORDS+4,y
sta WG_VIEWRECORDS+4,y
jsr WGPaintView
jsr WGBottomCursor
rts
@ -809,8 +762,7 @@ WGAmpersand_PrintStrPtrAndLen:
; source, so we need to NULL-terminate it for printing. In ; source, so we need to NULL-terminate it for printing. In
; order to avoid copying the whole thing, we'll do something ; order to avoid copying the whole thing, we'll do something
; kinda dirty here. ; kinda dirty here.
pla ply
tay
lda (PARAM0),y ; Cache the byte at the end of the string lda (PARAM0),y ; Cache the byte at the end of the string
pha pha
@ -829,10 +781,9 @@ WGAmpersand_NotLiteral:
bmi WGAmpersand_PRINTint bmi WGAmpersand_PRINTint
jsr PTRGET ; Non-numeric, so assume string variable jsr PTRGET ; Non-numeric, so assume string variable
ldy #0 lda (VARPNT)
lda (VARPNT),y
pha ; Length goes on stack pha ; Length goes on stack
iny ldy #1
lda (VARPNT),y ; Get string pointer out of Applesoft record lda (VARPNT),y ; Get string pointer out of Applesoft record
sta PARAM0 sta PARAM0
iny iny
@ -1107,25 +1058,19 @@ WGAmpersand_GET:
jsr WGAmpersandBeginArguments jsr WGAmpersandBeginArguments
jsr PTRGET jsr PTRGET
lda #0
sta (VARPNT)
lda KBD lda KBD
bpl WGAmpersand_GETnone ; No key pending bpl WGAmpersand_GETnone ; No key pending
sta KBDSTRB ; Clear strobe and high bit sta KBDSTRB ; Clear strobe and high bit
and #%01111111 and #%01111111
pha .byte $2C ; Mask LDA
bra WGAmpersand_GETstore
WGAmpersand_GETnone: WGAmpersand_GETnone:
lda #0 lda #0
pha
WGAmpersand_GETstore: WGAmpersand_GETstore:
ldy #0 ldy #1
lda #0
sta (VARPNT),y
iny
pla
sta (VARPNT),y sta (VARPNT),y
; String version: ; String version:
@ -1168,11 +1113,10 @@ WGAmpersand_EXIT:
; Leave the cursor state in a place that Applesoft is happy with ; Leave the cursor state in a place that Applesoft is happy with
; ;
WGBottomCursor: WGBottomCursor:
SAVE_AY pha
lda #0 stz CH
sta CH stz OURCH
sta OURCH
lda #23 lda #23
sta CV sta CV
sta OURCV sta OURCV
@ -1182,7 +1126,7 @@ WGBottomCursor:
lda TEXTLINES_L+23 lda TEXTLINES_L+23
sta BASL sta BASL
RESTORE_AY pla
rts rts
@ -1197,14 +1141,11 @@ WGAmpersand_GTSEL:
jsr PTRGET jsr PTRGET
lda WG_ACTIVEVIEW
pha
ldy #0
lda #0 lda #0
sta (VARPNT),y sta (VARPNT)
iny lda WG_ACTIVEVIEW
pla
ldy #1
sta (VARPNT),y sta (VARPNT),y
jsr WGAmpersandEndArguments jsr WGAmpersandEndArguments
@ -1218,8 +1159,7 @@ WGAmpersand_GTSEL:
; WG_GOSUBLINE+1: Line number (MSB) ; WG_GOSUBLINE+1: Line number (MSB)
; ;
WGGosub: WGGosub:
lda #0 stz WG_GOSUB ; Clear the flag
sta WG_GOSUB ; Clear the flag
; Can't come back from what we're about to do, so cleanup from the ; Can't come back from what we're about to do, so cleanup from the
; original Ampersand entry point now! This is some seriously voodoo ; original Ampersand entry point now! This is some seriously voodoo

View File

@ -82,9 +82,9 @@ WGPlot:
clc clc
adc BASL adc BASL
sta BASL sta BASL
lda #$0 bcc WGPlot_SkipInc
adc BASH inc BASH
sta BASH WGPlot_SkipInc:
lda WG_CURSORX ; X even? lda WG_CURSORX ; X even?
ror ror
@ -252,8 +252,7 @@ WGPrint_nextLine:
lda (PARAM0),y ; Check for end string landing exactly at line end lda (PARAM0),y ; Check for end string landing exactly at line end
beq WGPrint_done beq WGPrint_done
lda #0 ; Wrap to next line stz WG_LOCALCURSORX
sta WG_LOCALCURSORX
bra WGPrint_lineLoop bra WGPrint_lineLoop
WGPrint_charLoopInverse: WGPrint_charLoopInverse:

52
rects.s
View File

@ -40,10 +40,10 @@ WGFillRect_vertLoop:
clc clc
adc BASL adc BASL
sta BASL sta BASL
lda #$0 bcc WGFillRect_SkipInc
adc BASH inc BASH
sta BASH
WGFillRect_SkipInc:
lda PARAM0 ; Left edge even? lda PARAM0 ; Left edge even?
ror ror
bcs WGFillRect_horzLoopOdd bcs WGFillRect_horzLoopOdd
@ -51,7 +51,6 @@ WGFillRect_vertLoop:
lda PARAM2 lda PARAM2
cmp #1 ; Width==1 is a special case cmp #1 ; Width==1 is a special case
bne WGFillRect_horzLoopEvenAlignedNormalWidth bne WGFillRect_horzLoopEvenAlignedNormalWidth
jmp WGFillRect_horzLoopEvenAlignedOneWidth
WGFillRect_horzLoopEvenAlignedOneWidth: WGFillRect_horzLoopEvenAlignedOneWidth:
SETSWITCH PAGE2ON SETSWITCH PAGE2ON
@ -230,10 +229,10 @@ WGStrokeRect_horzEdge:
clc clc
adc BASL adc BASL
sta BASL sta BASL
lda #$0 bcc WGStrokeRect_SkipInc1
adc BASH inc BASH
sta BASH
WGStrokeRect_SkipInc1:
lda PARAM0 ; Left edge even? lda PARAM0 ; Left edge even?
ror ror
bcc WGStrokeRect_horzEdgeEven bcc WGStrokeRect_horzEdgeEven
@ -242,8 +241,7 @@ WGStrokeRect_horzEdge:
WGStrokeRect_horzEdgeEven: WGStrokeRect_horzEdgeEven:
lda PARAM2 lda PARAM2
cmp #1 ; Width==1 is a special case cmp #1 ; Width==1 is a special case
bne WGStrokeRect_horzLoopEvenAlignedNormalWidth beq WGStrokeRect_horzLoopEvenAlignedOneWidth
jmp WGStrokeRect_horzLoopEvenAlignedOneWidth
WGStrokeRect_horzLoopEvenAlignedNormalWidth: WGStrokeRect_horzLoopEvenAlignedNormalWidth:
; CASE 1: Left edge even-aligned, even width ; CASE 1: Left edge even-aligned, even width
@ -377,10 +375,10 @@ WGStrokeRect_vertLoop:
clc clc
adc BASL adc BASL
sta BASL sta BASL
lda #$0 bcc WGStrokeRect_SkipInc2
adc BASH inc BASH
sta BASH
WGStrokeRect_SkipInc2:
lda PARAM0 ; Left edge even? lda PARAM0 ; Left edge even?
dec dec
ror ror
@ -388,9 +386,8 @@ WGStrokeRect_vertLoop:
; CASE 1: Left edge even-aligned, even width ; CASE 1: Left edge even-aligned, even width
SETSWITCH PAGE2ON SETSWITCH PAGE2ON
ldy #$0
lda SCRATCH1 ; Plot the left edge lda SCRATCH1 ; Plot the left edge
sta (BASL),y sta (BASL)
lda PARAM2 ; Is width even? lda PARAM2 ; Is width even?
inc inc
@ -431,9 +428,8 @@ WGStrokeRect_vertLoopEvenAlignedNextRow:
WGStrokeRect_vertLoopOdd: WGStrokeRect_vertLoopOdd:
; CASE 2: Left edge odd-aligned, even width ; CASE 2: Left edge odd-aligned, even width
SETSWITCH PAGE2OFF SETSWITCH PAGE2OFF
ldy #$0
lda SCRATCH1 ; Plot the left edge lda SCRATCH1 ; Plot the left edge
sta (BASL),y sta (BASL)
lda PARAM2 ; Is width even? lda PARAM2 ; Is width even?
inc inc
@ -466,8 +462,7 @@ WGStrokeRect_vertLoopOddAlignedNextRow:
plx ; Prepare for next row plx ; Prepare for next row
inx inx
cpx SCRATCH0 cpx SCRATCH0
bne WGStrokeRect_vertLoopJmp beq WGStrokeRect_done
jmp WGStrokeRect_done
WGStrokeRect_vertLoopJmp: WGStrokeRect_vertLoopJmp:
jmp WGStrokeRect_vertLoop jmp WGStrokeRect_vertLoop
@ -522,10 +517,10 @@ WGFancyRect_horzEdge:
clc clc
adc BASL adc BASL
sta BASL sta BASL
lda #$0 bcc WGFancyRect_SkipInc1
adc BASH inc BASH
sta BASH
WGFancyRect_SkipInc1:
lda PARAM0 ; Left edge even? lda PARAM0 ; Left edge even?
ror ror
bcs WGFancyRect_horzLoopOdd bcs WGFancyRect_horzLoopOdd
@ -652,10 +647,10 @@ WGFancyRect_vertLoop:
clc clc
adc BASL adc BASL
sta BASL sta BASL
lda #$0 bcc WGFancyRect_SkipInc2
adc BASH inc BASH
sta BASH
WGFancyRect_SkipInc2:
lda PARAM0 ; Left edge even? lda PARAM0 ; Left edge even?
dec dec
ror ror
@ -663,9 +658,8 @@ WGFancyRect_vertLoop:
; CASE 1: Left edge even-aligned, even width ; CASE 1: Left edge even-aligned, even width
SETSWITCH PAGE2ON SETSWITCH PAGE2ON
ldy #$0
lda #FR_LEFT ; Plot the left edge lda #FR_LEFT ; Plot the left edge
sta (BASL),y sta (BASL)
lda PARAM2 ; Is width even? lda PARAM2 ; Is width even?
inc inc
@ -706,9 +700,8 @@ WGFancyRect_vertLoopEvenAlignedNextRow:
WGFancyRect_vertLoopOdd: WGFancyRect_vertLoopOdd:
; CASE 2: Left edge odd-aligned, even width ; CASE 2: Left edge odd-aligned, even width
SETSWITCH PAGE2OFF SETSWITCH PAGE2OFF
ldy #$0
lda #FR_LEFT ; Plot the left edge lda #FR_LEFT ; Plot the left edge
sta (BASL),y sta (BASL)
lda PARAM2 ; Is width even? lda PARAM2 ; Is width even?
inc inc
@ -741,8 +734,7 @@ WGFancyRect_vertLoopOddAlignedNextRow:
plx ; Prepare for next row plx ; Prepare for next row
inx inx
cpx SCRATCH0 cpx SCRATCH0
bne WGFancyRect_vertLoopJmp beq WGFancyRect_corners
jmp WGFancyRect_corners
WGFancyRect_vertLoopJmp: WGFancyRect_vertLoopJmp:
jmp WGFancyRect_vertLoop jmp WGFancyRect_vertLoop

View File

@ -98,12 +98,11 @@ scanHex8:
WGStrLen: WGStrLen:
phy phy
ldy #0 ldy #$ff
WGStrLen_loop: WGStrLen_loop:
lda (PARAM0),y
beq WGStrLen_done
iny iny
bra WGStrLen_loop lda (PARAM0),y
bne WGStrLen_loop
WGStrLen_done: WGStrLen_done:
tya tya
@ -174,8 +173,7 @@ WGStoreStr_copyLoop:
bne WGStoreStr_copyLoop bne WGStoreStr_copyLoop
WGStoreStr_terminate: WGStoreStr_terminate:
lda #0 ; Terminate the stored string stz WG_STRINGS,x ; Terminate the stored string
sta WG_STRINGS,x
pla ; Return pointer to the start of the block pla ; Return pointer to the start of the block
clc clc
@ -222,8 +220,7 @@ WGStorePascalStr_copyLoop:
bne WGStorePascalStr_copyLoop bne WGStorePascalStr_copyLoop
WGStorePascalStr_terminate: WGStorePascalStr_terminate:
lda #0 ; Terminate the stored string stz WG_STRINGS,x ; Terminate the stored string
sta WG_STRINGS,x
pla ; Return pointer to the start of the block pla ; Return pointer to the start of the block
clc clc

78
views.s
View File

@ -32,8 +32,7 @@ WG_FEATURE_RT = %01000000
WGCreateView: WGCreateView:
SAVE_AXY SAVE_AXY
ldy #0 lda (PARAM0) ; Find our new view record
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done pha ; Cache view ID so we can select when we're done
asl asl
@ -42,7 +41,7 @@ WGCreateView:
asl ; Records are 8 bytes wide asl ; Records are 8 bytes wide
tax tax
iny ldy #1
lda (PARAM0),y lda (PARAM0),y
pha ; Cache style byte for later pha ; Cache style byte for later
@ -129,8 +128,7 @@ WGCreate1x1_common:
sta WGCreate1x1_style+1 sta WGCreate1x1_style+1
SAVE_XY SAVE_XY
ldy #0 lda (PARAM0) ; Find our new view record
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done pha ; Cache view ID so we can select when we're done
asl asl
@ -139,7 +137,7 @@ WGCreate1x1_common:
asl ; Records are 16 bytes wide asl ; Records are 16 bytes wide
tax tax
iny ldy #1
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X sta WG_VIEWRECORDS+0,x ; Screen X
@ -195,8 +193,7 @@ WGCreate1x1_style:
WGCreateProgress: WGCreateProgress:
SAVE_AXY SAVE_AXY
ldy #0 lda (PARAM0) ; Find our new view record
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done pha ; Cache view ID so we can select when we're done
asl asl
@ -205,7 +202,7 @@ WGCreateProgress:
asl ; Records are 16 bytes wide asl ; Records are 16 bytes wide
tax tax
iny ldy #1
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X sta WG_VIEWRECORDS+0,x ; Screen X
@ -254,20 +251,21 @@ WGCreateProgress_done:
; PARAM0: Value ; PARAM0: Value
; ;
WGSetState: WGSetState:
SAVE_AXY SAVE_AY
LDY_ACTIVEVIEW LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+9,y lda WG_VIEWRECORDS+9,y
and #$80 asl
sta SCRATCH0 php
lda PARAM0 lda PARAM0
and #$7F asl
ora SCRATCH0 plp
ror
sta WG_VIEWRECORDS+9,y ; State (preserving bit 7) sta WG_VIEWRECORDS+9,y ; State (preserving bit 7)
WGSetState_done: WGSetState_done:
RESTORE_AXY RESTORE_AY
rts rts
@ -290,8 +288,7 @@ WGSetState_done:
WGCreateButton: WGCreateButton:
SAVE_AXY SAVE_AXY
ldy #0 lda (PARAM0) ; Find our new view record
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done pha ; Cache view ID so we can select when we're done
asl asl
@ -300,7 +297,7 @@ WGCreateButton:
asl ; Records are 16 bytes wide asl ; Records are 16 bytes wide
tax tax
iny ldy #1
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X sta WG_VIEWRECORDS+0,x ; Screen X
@ -449,10 +446,8 @@ paintCheck:
sta WG_CURSORY sta WG_CURSORY
lda WG_VIEWRECORDS+9,y ; Determine our visual state lda WG_VIEWRECORDS+9,y ; Determine our visual state
and #$80 bmi paintCheck_selected
bne paintCheck_selected
lda WG_VIEWRECORDS+9,y
ror ror
bcc paintCheck_unselectedUnchecked bcc paintCheck_unselectedUnchecked
@ -464,7 +459,6 @@ paintCheck_unselectedUnchecked:
bra paintCheck_plot bra paintCheck_plot
paintCheck_selected: paintCheck_selected:
lda WG_VIEWRECORDS+9,y
ror ror
bcc paintCheck_selectedUnchecked bcc paintCheck_selectedUnchecked
@ -573,10 +567,8 @@ paintButton:
sbc SCRATCH1 sbc SCRATCH1
sta SCRATCH1 ; Cache this for left margin rendering sta SCRATCH1 ; Cache this for left margin rendering
lda #0 ; Position and print title stz WG_LOCALCURSORX ; Position and print title
sta WG_LOCALCURSORX stz WG_LOCALCURSORY
lda #0
sta WG_LOCALCURSORY
jsr WGSyncGlobalCursor jsr WGSyncGlobalCursor
lda WG_VIEWRECORDS+9,y ; Is button highlighted? lda WG_VIEWRECORDS+9,y ; Is button highlighted?
@ -843,8 +835,9 @@ WGViewFocusNext_loop:
inc inc
cmp #16 cmp #16
beq WGViewFocusNext_wrap beq WGViewFocusNext_wrap
sta WG_FOCUSVIEW
WGViewFocusNext_findLoop:
sta WG_FOCUSVIEW
LDY_FOCUSVIEW LDY_FOCUSVIEW
lda WG_VIEWRECORDS+2,y lda WG_VIEWRECORDS+2,y
beq WGViewFocusNext_loop beq WGViewFocusNext_loop
@ -863,8 +856,8 @@ WGViewFocusNext_focus:
rts rts
WGViewFocusNext_wrap: WGViewFocusNext_wrap:
stz WG_FOCUSVIEW lda #1
bra WGViewFocusNext_loop bra WGViewFocusNext_findLoop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -873,17 +866,17 @@ WGViewFocusNext_wrap:
; Side effects: Changes selected view, repaints some views ; Side effects: Changes selected view, repaints some views
; ;
WGViewFocusPrev: WGViewFocusPrev:
SAVE_AXY SAVE_AY
jsr unfocusCurrent jsr unfocusCurrent
WGViewFocusPrev_loop: WGViewFocusPrev_loop:
ldx WG_FOCUSVIEW ; Decrement and wrap lda WG_FOCUSVIEW ; Decrement and wrap
dex dec
bmi WGViewFocusPrev_wrap bmi WGViewFocusPrev_wrap
WGViewFocusPrev_findLoop: WGViewFocusPrev_findLoop:
stx WG_FOCUSVIEW sta WG_FOCUSVIEW
LDY_FOCUSVIEW LDY_FOCUSVIEW
lda WG_VIEWRECORDS+2,y lda WG_VIEWRECORDS+2,y
beq WGViewFocusPrev_loop beq WGViewFocusPrev_loop
@ -898,11 +891,11 @@ WGViewFocusPrev_wantFocus: ; Does this view accept focus?
WGViewFocusPrev_focus: WGViewFocusPrev_focus:
jsr focusCurrent jsr focusCurrent
RESTORE_AXY RESTORE_AY
rts rts
WGViewFocusPrev_wrap: WGViewFocusPrev_wrap:
ldx #$f lda #$f
bra WGViewFocusPrev_findLoop bra WGViewFocusPrev_findLoop
@ -1021,17 +1014,16 @@ WGViewFocusAction_buttonClick:
lda WG_VIEWRECORDS+11,y ; Do we have a callback? lda WG_VIEWRECORDS+11,y ; Do we have a callback?
beq WGViewFocusAction_done beq WGViewFocusAction_done
sta WGViewFocusAction_userJSR+2 ; Modify code below so we can JSR to user's code tya
lda WG_VIEWRECORDS+10,y tax
sta WGViewFocusAction_userJSR+1 jsr WGViewFocusAction_userJMP
WGViewFocusAction_userJSR:
jsr WGViewFocusAction_done ; Overwritten with user's function pointer
bra WGViewFocusAction_done bra WGViewFocusAction_done
WGViewFocusAction_userJMP:
jmp (WG_VIEWRECORDS+10,x)
WGViewFocusAction_buttonClickApplesoft: WGViewFocusAction_buttonClickApplesoft:
lda #0 stz WG_GOSUB
sta WG_GOSUB
lda WG_VIEWRECORDS+10,y ; Do we have a callback? lda WG_VIEWRECORDS+10,y ; Do we have a callback?
beq WGViewFocusAction_mightBeZero beq WGViewFocusAction_mightBeZero

View File

@ -117,9 +117,8 @@ WGInit_clearMemLoop:
asl asl
asl asl
tax tax
lda #0 stz WG_VIEWRECORDS+2,x
sta WG_VIEWRECORDS+2,x stz WG_STRINGS,x
sta WG_STRINGS,x
dey dey
bpl WGInit_clearMemLoop bpl WGInit_clearMemLoop