Merge pull request #20 from peterferrie/smaller

a bit smaller code
This commit is contained in:
blondie7575 2018-03-08 15:02:59 -08:00 committed by GitHub
commit cf32f7f8c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 595 additions and 676 deletions

View File

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

View File

@ -13,10 +13,10 @@
;
WGDesktop:
pha
lda #'W'
sta WGClearScreen_charPage1+1
lda #'V'
bra WGClearScreen_common
lda #'W'
sta WGClearScreen_charPage1+1
lda #'V'
bra WGClearScreen_common
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGClearScreen
@ -24,38 +24,38 @@ WGDesktop:
;
WGClearScreen:
pha
lda #' ' + $80
sta WGClearScreen_charPage1+1
lda #' ' + $80
sta WGClearScreen_charPage1+1
WGClearScreen_common:
sta WGClearScreen_charPage2+1
sta WGClearScreen_charPage2+1
SAVE_XY
SETSWITCH PAGE2OFF
ldx #23
ldx #23
WGClearScreen_lineLoop:
lda TEXTLINES_L,x ; Compute video memory address of line
sta WGClearScreen_charLoop1+1
sta WGClearScreen_charLoop2+1
lda TEXTLINES_H,x
sta WGClearScreen_charLoop1+2
sta WGClearScreen_charLoop2+2
ldy #39
lda TEXTLINES_L,x ; Compute video memory address of line
sta WGClearScreen_charLoop1+1
sta WGClearScreen_charLoop2+1
lda TEXTLINES_H,x
sta WGClearScreen_charLoop1+2
sta WGClearScreen_charLoop2+2
ldy #39
WGClearScreen_charPage1:
lda #$FF ; Self-modifying code!
lda #$FF ; Self-modifying code!
WGClearScreen_charLoop1:
sta $FFFF,y ; Self-modifying code!
sta $FFFF,y ; Self-modifying code!
dey
bpl WGClearScreen_charLoop1
bpl WGClearScreen_charLoop1
SETSWITCH PAGE2ON
ldy #39
ldy #39
WGClearScreen_charPage2:
lda #$FF ; Self-modifying code!
lda #$FF ; Self-modifying code!
WGClearScreen_charLoop2:
sta $FFFF,y ; Self-modifying code!
sta $FFFF,y ; Self-modifying code!
dey
bpl WGClearScreen_charLoop2
bpl WGClearScreen_charLoop2
SETSWITCH PAGE2OFF
dex
bpl WGClearScreen_lineLoop
bpl WGClearScreen_lineLoop
RESTORE_XY
pla
rts
@ -71,37 +71,37 @@ WGPlot:
SAVE_XY
pha
ldx WG_CURSORY
ldx WG_CURSORY
lda TEXTLINES_L,x ; Compute video memory address of point
sta BASL
lda TEXTLINES_H,x
sta BASH
lda WG_CURSORX
lda WG_CURSORX
lsr
clc
adc BASL
adc BASL
sta BASL
lda #$0
adc BASH
sta BASH
bcc WGPlot_SkipInc
inc BASH
WGPlot_SkipInc:
lda WG_CURSORX ; X even?
lda WG_CURSORX ; X even?
ror
bcs WGPlot_xOdd
bcs WGPlot_xOdd
SETSWITCH PAGE2ON ; Plot the character
SETSWITCH PAGE2ON ; Plot the character
pla
sta (BASL)
sta (BASL)
jmp WGPlot_done
WGPlot_xOdd:
SETSWITCH PAGE2OFF ; Plot the character
SETSWITCH PAGE2OFF ; Plot the character
pla
sta (BASL)
sta (BASL)
WGPlot_done:
SETSWITCH PAGE2OFF
SETSWITCH PAGE2OFF
RESTORE_XY
rts
@ -132,11 +132,11 @@ WGPrint_setupMask:
; Start checking clipping boundaries
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+3
bcs WGPrint_leapDone ; Entire string is below the clip box
cmp WG_VIEWCLIP+3
bcs WGPrint_leapDone ; Entire string is below the clip box
jsr WGStrLen ; We'll need the length of the string
sta SCRATCH1
jsr WGStrLen ; We'll need the length of the string
sta SCRATCH1
LDX_ACTIVEVIEW ; Cache view width for later
lda WG_VIEWRECORDS+7,x
@ -145,20 +145,20 @@ WGPrint_setupMask:
ldy #0
WGPrint_lineLoopFirst: ; Calculating start of first line is slightly different
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+1
bcc WGPrint_skipToEndFirst ; This line is above the clip box
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+1
bcc WGPrint_skipToEndFirst ; This line is above the clip box
lda WG_LOCALCURSORX ; Find start of line within clip box
lda WG_LOCALCURSORX ; Find start of line within clip box
cmp WG_VIEWCLIP+0
bcs WGPrint_visibleChars
lda WG_VIEWCLIP+0 ; Line begins before left clip plane
lda WG_VIEWCLIP+0 ; Line begins before left clip plane
sec ; Advance string index and advance cursor into clip box
sbc WG_LOCALCURSORX
tay
lda WG_VIEWCLIP+0
sta WG_LOCALCURSORX
sta WG_LOCALCURSORX
bra WGPrint_visibleChars
WGPrint_leapDone:
@ -168,11 +168,11 @@ WGPrint_skipToEndFirst:
lda WG_SCRATCHA ; Skip string index ahead by distance to EOL
sec
sbc WG_LOCALCURSORX
cmp SCRATCH1
bcs WGPrint_done ; EOL is past the end of the string, so we're done
cmp SCRATCH1
bcs WGPrint_done ; EOL is past the end of the string, so we're done
tay
lda WG_SCRATCHA ; Skip cursor ahead to EOL
lda WG_SCRATCHA ; Skip cursor ahead to EOL
sta WG_LOCALCURSORX
bra WGPrint_nextLine
@ -184,49 +184,49 @@ WGPrint_skipToEnd:
bcs WGPrint_done ; EOL is past the end of the string, so we're done
tay
lda WG_SCRATCHA ; Skip cursor ahead to EOL
lda WG_SCRATCHA ; Skip cursor ahead to EOL
sta WG_LOCALCURSORX
bra WGPrint_nextLine
WGPrint_lineLoop:
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+1
bcc WGPrint_skipToEnd ; This line is above the clip box
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+1
bcc WGPrint_skipToEnd ; This line is above the clip box
lda WG_LOCALCURSORX ; Find start of line within clip box
lda WG_LOCALCURSORX ; Find start of line within clip box
cmp WG_VIEWCLIP+0
bcs WGPrint_visibleChars
tya
clc
adc WG_VIEWCLIP+0 ; Jump ahead by left span
adc WG_VIEWCLIP+0 ; Jump ahead by left span
tay
lda WG_VIEWCLIP+0 ; Set cursor to left edge of visible area
sta WG_LOCALCURSORX
sta WG_LOCALCURSORX
WGPrint_visibleChars:
jsr WGSyncGlobalCursor
jsr WGSyncGlobalCursor
lda INVERSE
cmp #CHAR_INVERSE
beq WGPrint_charLoopInverse
WGPrint_charLoopNormal:
lda (PARAM0),y ; Draw current character
lda (PARAM0),y ; Draw current character
beq WGPrint_done
ora WGPrint_specialMask
jsr WGPlot
jsr WGPlot
iny
inc WG_CURSORX ; Advance cursors
inc WG_LOCALCURSORX
lda WG_LOCALCURSORX
cmp WG_SCRATCHA ; Check for wrap boundary
beq WGPrint_nextLine
cmp WG_VIEWCLIP+2 ; Check for right clip plane
beq WGPrint_endVisible
cmp WG_SCRATCHA ; Check for wrap boundary
beq WGPrint_nextLine
cmp WG_VIEWCLIP+2 ; Check for right clip plane
beq WGPrint_endVisible
bra WGPrint_charLoopNormal
WGPrint_done: ; This is in the middle here to keep local branches in range
@ -237,27 +237,26 @@ WGPrint_done: ; This is in the middle here to keep local branches in range
WGPrint_endVisible:
tya
clc
adc WG_VIEWCLIP+4 ; Advance string index by right span
cmp SCRATCH1
bcs WGPrint_done
adc WG_VIEWCLIP+4 ; Advance string index by right span
cmp SCRATCH1
bcs WGPrint_done
tay
WGPrint_nextLine:
inc WG_LOCALCURSORY ; Advance cursor
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+3 ; Check for bottom clip plane
beq WGPrint_done
cmp WG_VIEWRECORDS+8,x ; Check for bottom of view
beq WGPrint_done
lda (PARAM0),y ; Check for end string landing exactly at line end
beq WGPrint_done
inc WG_LOCALCURSORY ; Advance cursor
lda WG_LOCALCURSORY
cmp WG_VIEWCLIP+3 ; Check for bottom clip plane
beq WGPrint_done
cmp WG_VIEWRECORDS+8,x ; Check for bottom of view
beq WGPrint_done
lda (PARAM0),y ; Check for end string landing exactly at line end
beq WGPrint_done
lda #0 ; Wrap to next line
sta WG_LOCALCURSORX
stz WG_LOCALCURSORX
bra WGPrint_lineLoop
WGPrint_charLoopInverse:
lda (PARAM0),y ; Draw current character
lda (PARAM0),y ; Draw current character
beq WGPrint_done
cmp #$60
bcc WGPrint_charLoopInverseLow
@ -268,17 +267,17 @@ WGPrint_charLoopInverseLow:
and WGPrint_setupMaskInverse ; Normal inverse
WGPrint_charLoopInversePlot:
jsr WGPlot
jsr WGPlot
iny
inc WG_CURSORX ; Advance cursors
inc WG_LOCALCURSORX
lda WG_LOCALCURSORX
cmp WG_SCRATCHA ; Check for wrap boundary
beq WGPrint_nextLine
cmp WG_VIEWCLIP+2 ; Check for right clip plane
beq WGPrint_endVisible
cmp WG_SCRATCHA ; Check for wrap boundary
beq WGPrint_nextLine
cmp WG_VIEWCLIP+2 ; Check for right clip plane
beq WGPrint_endVisible
bra WGPrint_charLoopInverse
WGPrint_specialMask:

504
rects.s
View File

@ -19,10 +19,10 @@
;
WGFillRect:
SAVE_AX
sty SCRATCH0
sty SCRATCH0
clc ; Compute bottom edge
lda PARAM1
lda PARAM1
adc PARAM3
dec
tax
@ -35,70 +35,69 @@ WGFillRect_vertLoop:
lda TEXTLINES_H,x
sta BASH
lda PARAM0
lda PARAM0
lsr
clc
adc BASL
adc BASL
sta BASL
lda #$0
adc BASH
sta BASH
bcc WGFillRect_SkipInc
inc BASH
lda PARAM0 ; Left edge even?
WGFillRect_SkipInc:
lda PARAM0 ; Left edge even?
ror
bcs WGFillRect_horzLoopOdd
bcs WGFillRect_horzLoopOdd
lda PARAM2
cmp #1 ; Width==1 is a special case
bne WGFillRect_horzLoopEvenAlignedNormalWidth
jmp WGFillRect_horzLoopEvenAlignedOneWidth
WGFillRect_horzLoopEvenAlignedOneWidth:
SETSWITCH PAGE2ON
SETSWITCH PAGE2ON
bra WGFillRect_horzLoopEvenAlignedOddWidth
WGFillRect_horzLoopEvenAlignedNormalWidth:
; CASE 1: Left edge even-aligned, even width
SETSWITCH PAGE2OFF
lda PARAM2
SETSWITCH PAGE2OFF
lda PARAM2
lsr
tay ; Iterate w/2
dey
phy ; We'll reuse this calculation for the odd columns
lda SCRATCH0 ; Prepare to plot
lda SCRATCH0 ; Prepare to plot
WGFillRect_horzLoopEvenAligned0: ; Draw even columns
sta (BASL),y ; Plot the character
sta (BASL),y ; Plot the character
dey
bpl WGFillRect_horzLoopEvenAligned0 ; Loop for w/2
bpl WGFillRect_horzLoopEvenAligned0 ; Loop for w/2
SETSWITCH PAGE2ON ; Prepare for odd columns
SETSWITCH PAGE2ON ; Prepare for odd columns
ply ; Iterate w/2 again
WGFillRect_horzLoopEvenAligned1: ; Draw odd columns
sta (BASL),y ; Plot the character
sta (BASL),y ; Plot the character
dey
bpl WGFillRect_horzLoopEvenAligned1 ; Loop for w/2
bpl WGFillRect_horzLoopEvenAligned1 ; Loop for w/2
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
ror
bcc WGFillRect_horzLoopEvenAlignedEvenWidth
bcc WGFillRect_horzLoopEvenAlignedEvenWidth
WGFillRect_horzLoopEvenAlignedOddWidth:
; CASE 1a: Left edge even aligned, odd width
lda PARAM2 ; Fill in extra last column
lda PARAM2 ; Fill in extra last column
lsr
tay
lda SCRATCH0 ; Plot the character
sta (BASL),y
lda SCRATCH0 ; Plot the character
sta (BASL),y
WGFillRect_horzLoopEvenAlignedEvenWidth:
plx ; Prepare for next row
dex
bmi WGFillRect_done ; If we were at zero, we'll wrap dangerously
cpx PARAM1
bcs WGFillRect_vertLoop
bra WGFillRect_done
cpx PARAM1
bcs WGFillRect_vertLoop
bra WGFillRect_done
WGFillRect_horzLoopOdd:
; CASE 2: Left edge odd-aligned, even width
@ -107,54 +106,54 @@ WGFillRect_horzLoopOdd:
cmp #1 ; Width==1 is a special case
beq WGFillRect_horzLoopOddAlignedOneWidth
SETSWITCH PAGE2ON
lda PARAM2
SETSWITCH PAGE2ON
lda PARAM2
lsr
tay ; Iterate w/2
phy ; We'll reuse this calculation for the even columns
lda SCRATCH0 ; Prepare to plot
lda SCRATCH0 ; Prepare to plot
WGFillRect_horzLoopOddAligned0: ; Draw even columns
sta (BASL),y ; Plot the character
sta (BASL),y ; Plot the character
dey
bne WGFillRect_horzLoopOddAligned0 ; Loop for w/2
bne WGFillRect_horzLoopOddAligned0 ; Loop for w/2
SETSWITCH PAGE2OFF ; Prepare for odd columns
SETSWITCH PAGE2OFF ; Prepare for odd columns
ply ; Iterate w/2 again, shift left 1
dey
WGFillRect_horzLoopOddAligned1: ; Draw even columns
sta (BASL),y ; Plot the character
sta (BASL),y ; Plot the character
dey
bpl WGFillRect_horzLoopOddAligned1 ; Loop for w/2
bpl WGFillRect_horzLoopOddAligned1 ; Loop for w/2
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
ror
bcc WGFillRect_horzLoopOddAlignedEvenWidth
bcc WGFillRect_horzLoopOddAlignedEvenWidth
WGFillRect_horzLoopOddAlignedOddWidth:
; CASE 2a: Left edge odd aligned, odd width
lda PARAM2 ; Fill in extra last column
lda PARAM2 ; Fill in extra last column
lsr
tay
lda SCRATCH0 ; Plot the character
sta (BASL),y
lda SCRATCH0 ; Plot the character
sta (BASL),y
WGFillRect_horzLoopOddAlignedEvenWidth:
plx ; Prepare for next row
dex
bmi WGFillRect_done ; If we were at zero, we'll wrap dangerously
cpx PARAM1
cpx PARAM1
bcc WGFillRect_done
jmp WGFillRect_vertLoop
WGFillRect_done:
SETSWITCH PAGE2OFF
SETSWITCH PAGE2OFF
RESTORE_AX
rts
WGFillRect_horzLoopOddAlignedOneWidth:
SETSWITCH PAGE2OFF
SETSWITCH PAGE2OFF
bra WGFillRect_horzLoopOddAlignedOddWidth
@ -196,28 +195,28 @@ CH_DOUBLE = '\'
WGStrokeRect:
pha
lda #CH_LEFT
sta SCRATCH1
lda #CH_RIGHT
bra WGStrokeRect_common
pha
lda #CH_LEFT
sta SCRATCH1
lda #CH_RIGHT
bra WGStrokeRect_common
WGStrokeRoundRect:
pha
lda #CH_ROUND_LEFT
sta SCRATCH1
lda #CH_ROUND_RIGHT
pha
lda #CH_ROUND_LEFT
sta SCRATCH1
lda #CH_ROUND_RIGHT
WGStrokeRect_common:
sta SCRATCH2
pla
SAVE_AXY
SAVE_ZPS
sta SCRATCH2
pla
SAVE_AXY
SAVE_ZPS
; Top and bottom edges
;
ldx PARAM1 ; Start with top edge
ldx PARAM1 ; Start with top edge
dex
lda #CH_TOP
sta SCRATCH0
lda #CH_TOP
sta SCRATCH0
WGStrokeRect_horzEdge:
lda TEXTLINES_L,x ; Compute video memory address of left edge of rect
@ -225,30 +224,29 @@ WGStrokeRect_horzEdge:
lda TEXTLINES_H,x
sta BASH
lda PARAM0
lda PARAM0
lsr
clc
adc BASL
adc BASL
sta BASL
lda #$0
adc BASH
sta BASH
bcc WGStrokeRect_SkipInc1
inc BASH
lda PARAM0 ; Left edge even?
WGStrokeRect_SkipInc1:
lda PARAM0 ; Left edge even?
ror
bcc WGStrokeRect_horzEdgeEven
bcc WGStrokeRect_horzEdgeEven
jmp WGStrokeRect_horzLoopOdd
WGStrokeRect_horzEdgeEven:
lda PARAM2
lda PARAM2
cmp #1 ; Width==1 is a special case
bne WGStrokeRect_horzLoopEvenAlignedNormalWidth
jmp WGStrokeRect_horzLoopEvenAlignedOneWidth
beq WGStrokeRect_horzLoopEvenAlignedOneWidth
WGStrokeRect_horzLoopEvenAlignedNormalWidth:
; CASE 1: Left edge even-aligned, even width
SETSWITCH PAGE2OFF
lda PARAM2
SETSWITCH PAGE2OFF
lda PARAM2
lsr
tay ; Start at right edge
dey
@ -257,30 +255,30 @@ WGStrokeRect_horzLoopEvenAlignedNormalWidth:
WGStrokeRect_horzLoopEvenAligned0: ; Draw even columns
PLOTHLINE ; Plot the character
dey
bpl WGStrokeRect_horzLoopEvenAligned0 ; Loop for w/2
bpl WGStrokeRect_horzLoopEvenAligned0 ; Loop for w/2
SETSWITCH PAGE2ON ; Prepare for odd columns
SETSWITCH PAGE2ON ; Prepare for odd columns
ply ; Start at right edge again
WGStrokeRect_horzLoopEvenAligned1: ; Draw odd columns
PLOTHLINE ; Plot the character
dey
bpl WGStrokeRect_horzLoopEvenAligned1 ; Loop for w/2
bpl WGStrokeRect_horzLoopEvenAligned1 ; Loop for w/2
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
ror
bcc WGStrokeRect_horzLoopEvenAlignedEvenWidth
bcc WGStrokeRect_horzLoopEvenAlignedEvenWidth
WGStrokeRect_horzLoopEvenAlignedOddWidth:
; CASE 1a: Left edge even aligned, odd width
lda PARAM2 ; Fill in extra last column
lda PARAM2 ; Fill in extra last column
lsr
tay
PLOTHLINE ; Plot the character
WGStrokeRect_horzLoopEvenAlignedEvenWidth:
inx
cpx PARAM1
cpx PARAM1
beq WGStrokeRect_horzLoopEvenAlignedEvenWidthBottom
jmp WGStrokeRect_vertEdge
@ -289,23 +287,23 @@ WGStrokeRect_horzLoopEvenAlignedEvenWidthBottom:
lda PARAM1
adc PARAM3
tax
lda #CH_BOTTOM
lda #CH_BOTTOM
sta SCRATCH0
jmp WGStrokeRect_horzEdge
jmp WGStrokeRect_horzEdge
WGStrokeRect_horzLoopEvenAlignedOneWidth:
SETSWITCH PAGE2ON
SETSWITCH PAGE2ON
bra WGStrokeRect_horzLoopEvenAlignedOddWidth
WGStrokeRect_horzLoopOdd:
; CASE 2: Left edge odd-aligned, even width
lda PARAM2
lda PARAM2
cmp #1 ; Width==1 is a special case
beq WGStrokeRect_horzLoopOddAlignedOneWidth
SETSWITCH PAGE2ON
lda PARAM2
SETSWITCH PAGE2ON
lda PARAM2
lsr
tay ; Iterate w/2
phy ; We'll reuse this calculation for the even columns
@ -313,24 +311,24 @@ WGStrokeRect_horzLoopOdd:
WGStrokeRect_horzLoopOddAligned0: ; Draw even columns
PLOTHLINE ; Plot the character
dey
bne WGStrokeRect_horzLoopOddAligned0 ; Loop for w/2
bne WGStrokeRect_horzLoopOddAligned0 ; Loop for w/2
SETSWITCH PAGE2OFF ; Prepare for odd columns
SETSWITCH PAGE2OFF ; Prepare for odd columns
ply ; Iterate w/2 again, shift left 1
dey
WGStrokeRect_horzLoopOddAligned1: ; Draw even columns
PLOTHLINE ; Plot the character
dey
bpl WGStrokeRect_horzLoopOddAligned1 ; Loop for w/2
bpl WGStrokeRect_horzLoopOddAligned1 ; Loop for w/2
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
ror
bcc WGStrokeRect_horzLoopOddAlignedEvenWidth
bcc WGStrokeRect_horzLoopOddAlignedEvenWidth
WGStrokeRect_horzLoopOddAlignedOddWidth:
; CASE 2a: Left edge odd aligned, odd width
lda PARAM2 ; Fill in extra last column
lda PARAM2 ; Fill in extra last column
dec
lsr
tay
@ -338,7 +336,7 @@ WGStrokeRect_horzLoopOddAlignedOddWidth:
WGStrokeRect_horzLoopOddAlignedEvenWidth:
inx
cpx PARAM1
cpx PARAM1
bne WGStrokeRect_vertEdge
clc ; Prepare for bottom edge
lda PARAM1
@ -346,21 +344,21 @@ WGStrokeRect_horzLoopOddAlignedEvenWidth:
tax
lda #CH_BOTTOM
sta SCRATCH0
jmp WGStrokeRect_horzEdge
jmp WGStrokeRect_horzEdge
WGStrokeRect_horzLoopOddAlignedOneWidth:
SETSWITCH PAGE2OFF
SETSWITCH PAGE2OFF
bra WGStrokeRect_horzLoopOddAlignedOddWidth
WGStrokeRect_vertEdge:
; Left and right edges
;
clc
lda PARAM1 ; Compute bottom edge
lda PARAM1 ; Compute bottom edge
adc PARAM3
sta SCRATCH0
sta SCRATCH0
ldx PARAM1 ; Start with top edge
ldx PARAM1 ; Start with top edge
WGStrokeRect_vertLoop:
@ -371,32 +369,31 @@ WGStrokeRect_vertLoop:
lda TEXTLINES_H,x
sta BASH
lda PARAM0
lda PARAM0
dec
lsr
clc
adc BASL
adc BASL
sta BASL
lda #$0
adc BASH
sta BASH
bcc WGStrokeRect_SkipInc2
inc BASH
lda PARAM0 ; Left edge even?
WGStrokeRect_SkipInc2:
lda PARAM0 ; Left edge even?
dec
ror
bcs WGStrokeRect_vertLoopOdd
bcs WGStrokeRect_vertLoopOdd
; CASE 1: Left edge even-aligned, even width
SETSWITCH PAGE2ON
ldy #$0
lda SCRATCH1 ; Plot the left edge
sta (BASL),y
SETSWITCH PAGE2ON
lda SCRATCH1 ; Plot the left edge
sta (BASL)
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
inc
inc
ror
bcs WGStrokeRect_vertLoopEvenAlignedOddWidth
bcs WGStrokeRect_vertLoopEvenAlignedOddWidth
lda PARAM2 ; Calculate right edge
inc
@ -404,75 +401,73 @@ WGStrokeRect_vertLoop:
lsr
dec
tay
SETSWITCH PAGE2OFF
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
jmp WGStrokeRect_vertLoopEvenAlignedNextRow
SETSWITCH PAGE2OFF
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
jmp WGStrokeRect_vertLoopEvenAlignedNextRow
WGStrokeRect_vertLoopEvenAlignedOddWidth:
; CASE 1a: Left edge even-aligned, odd width
SETSWITCH PAGE2ON
SETSWITCH PAGE2ON
lda PARAM2 ; Calculate right edge
inc
inc
lsr
tay
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
WGStrokeRect_vertLoopEvenAlignedNextRow:
plx ; Prepare for next row
inx
cpx SCRATCH0
bne WGStrokeRect_vertLoop
jmp WGStrokeRect_done
cpx SCRATCH0
bne WGStrokeRect_vertLoop
jmp WGStrokeRect_done
WGStrokeRect_vertLoopOdd:
; CASE 2: Left edge odd-aligned, even width
SETSWITCH PAGE2OFF
ldy #$0
lda SCRATCH1 ; Plot the left edge
sta (BASL),y
SETSWITCH PAGE2OFF
lda SCRATCH1 ; Plot the left edge
sta (BASL)
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
inc
inc
ror
bcs WGStrokeRect_vertLoopOddAlignedOddWidth
bcs WGStrokeRect_vertLoopOddAlignedOddWidth
lda PARAM2 ; Calculate right edge
inc
inc
lsr
tay
SETSWITCH PAGE2ON
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
jmp WGStrokeRect_vertLoopOddAlignedNextRow
SETSWITCH PAGE2ON
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
jmp WGStrokeRect_vertLoopOddAlignedNextRow
WGStrokeRect_vertLoopOddAlignedOddWidth:
; CASE 2a: Left edge odd-aligned, odd width
SETSWITCH PAGE2OFF
SETSWITCH PAGE2OFF
lda PARAM2 ; Calculate right edge
inc
inc
lsr
tay
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
lda SCRATCH2 ; Plot the right edge
sta (BASL),y
WGStrokeRect_vertLoopOddAlignedNextRow:
plx ; Prepare for next row
inx
cpx SCRATCH0
bne WGStrokeRect_vertLoopJmp
jmp WGStrokeRect_done
cpx SCRATCH0
beq WGStrokeRect_done
WGStrokeRect_vertLoopJmp:
jmp WGStrokeRect_vertLoop
WGStrokeRect_done:
SETSWITCH PAGE2OFF
SETSWITCH PAGE2OFF
RESTORE_ZPS
RESTORE_AXY
rts
@ -506,10 +501,10 @@ WGFancyRect:
; Top and bottom edges
;
ldx PARAM1 ; Start with top edge
ldx PARAM1 ; Start with top edge
dex
lda #FR_TOP
sta SCRATCH0
lda #FR_TOP
sta SCRATCH0
WGFancyRect_horzEdge:
lda TEXTLINES_L,x ; Compute video memory address of left edge of rect
@ -517,107 +512,57 @@ WGFancyRect_horzEdge:
lda TEXTLINES_H,x
sta BASH
lda PARAM0
lda PARAM0
lsr
clc
adc BASL
adc BASL
sta BASL
lda #$0
adc BASH
sta BASH
bcc WGFancyRect_SkipInc1
inc BASH
lda PARAM0 ; Left edge even?
WGFancyRect_SkipInc1:
lda PARAM0 ; Left edge even?
ror
bcs WGFancyRect_horzLoopOdd
bcs WGFancyRect_horzLoopOdd
; CASE 1: Left edge even-aligned, even width
SETSWITCH PAGE2OFF
lda PARAM2
SETSWITCH PAGE2OFF
lda PARAM2
lsr
tay ; Start at right edge
dey
phy ; We'll reuse this calculation for the odd columns
WGFancyRect_horzLoopEvenAligned0: ; Draw even columns
lda SCRATCH0 ; Plot the character
sta (BASL),y
lda SCRATCH0 ; Plot the character
sta (BASL),y
dey
bpl WGFancyRect_horzLoopEvenAligned0 ; Loop for w/2
bpl WGFancyRect_horzLoopEvenAligned0 ; Loop for w/2
SETSWITCH PAGE2ON ; Prepare for odd columns
SETSWITCH PAGE2ON ; Prepare for odd columns
ply ; Start at right edge again
WGFancyRect_horzLoopEvenAligned1: ; Draw odd columns
lda SCRATCH0 ; Plot the character
sta (BASL),y
lda SCRATCH0 ; Plot the character
sta (BASL),y
dey
bpl WGFancyRect_horzLoopEvenAligned1 ; Loop for w/2
bpl WGFancyRect_horzLoopEvenAligned1 ; Loop for w/2
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
ror
bcc WGFancyRect_horzLoopEvenAlignedEvenWidth
bcc WGFancyRect_horzLoopEvenAlignedEvenWidth
WGFancyRect_horzLoopEvenAlignedOddWidth:
; CASE 1a: Left edge even aligned, odd width
lda PARAM2 ; Fill in extra last column
lda PARAM2 ; Fill in extra last column
lsr
tay
lda SCRATCH0 ; Plot the character
sta (BASL),y
lda SCRATCH0 ; Plot the character
sta (BASL),y
WGFancyRect_horzLoopEvenAlignedEvenWidth:
inx
cpx PARAM1
bne WGFancyRect_vertEdge
clc ; Prepare for bottom edge
lda PARAM1
adc PARAM3
tax
lda #FR_BOTTOM
sta SCRATCH0
jmp WGFancyRect_horzEdge
WGFancyRect_horzLoopOdd:
; CASE 2: Left edge odd-aligned, even width
SETSWITCH PAGE2ON
lda PARAM2
lsr
tay ; Iterate w/2
phy ; We'll reuse this calculation for the even columns
WGFancyRect_horzLoopOddAligned0: ; Draw even columns
lda SCRATCH0 ; Plot the character
sta (BASL),y
dey
bne WGFancyRect_horzLoopOddAligned0 ; Loop for w/2
SETSWITCH PAGE2OFF ; Prepare for odd columns
ply ; Iterate w/2 again, shift left 1
dey
WGFancyRect_horzLoopOddAligned1: ; Draw even columns
lda SCRATCH0 ; Plot the character
sta (BASL),y
dey
bpl WGFancyRect_horzLoopOddAligned1 ; Loop for w/2
lda PARAM2 ; Is width even?
ror
bcc WGFancyRect_horzLoopOddAlignedEvenWidth
WGFancyRect_horzLoopOddAlignedOddWidth:
; CASE 2a: Left edge odd aligned, odd width
lda PARAM2 ; Fill in extra last column
dec
lsr
tay
lda SCRATCH0 ; Plot the character
sta (BASL),y
WGFancyRect_horzLoopOddAlignedEvenWidth:
inx
cpx PARAM1
cpx PARAM1
bne WGFancyRect_vertEdge
clc ; Prepare for bottom edge
lda PARAM1
@ -625,17 +570,67 @@ WGFancyRect_horzLoopOddAlignedEvenWidth:
tax
lda #FR_BOTTOM
sta SCRATCH0
jmp WGFancyRect_horzEdge
jmp WGFancyRect_horzEdge
WGFancyRect_horzLoopOdd:
; CASE 2: Left edge odd-aligned, even width
SETSWITCH PAGE2ON
lda PARAM2
lsr
tay ; Iterate w/2
phy ; We'll reuse this calculation for the even columns
WGFancyRect_horzLoopOddAligned0: ; Draw even columns
lda SCRATCH0 ; Plot the character
sta (BASL),y
dey
bne WGFancyRect_horzLoopOddAligned0 ; Loop for w/2
SETSWITCH PAGE2OFF ; Prepare for odd columns
ply ; Iterate w/2 again, shift left 1
dey
WGFancyRect_horzLoopOddAligned1: ; Draw even columns
lda SCRATCH0 ; Plot the character
sta (BASL),y
dey
bpl WGFancyRect_horzLoopOddAligned1 ; Loop for w/2
lda PARAM2 ; Is width even?
ror
bcc WGFancyRect_horzLoopOddAlignedEvenWidth
WGFancyRect_horzLoopOddAlignedOddWidth:
; CASE 2a: Left edge odd aligned, odd width
lda PARAM2 ; Fill in extra last column
dec
lsr
tay
lda SCRATCH0 ; Plot the character
sta (BASL),y
WGFancyRect_horzLoopOddAlignedEvenWidth:
inx
cpx PARAM1
bne WGFancyRect_vertEdge
clc ; Prepare for bottom edge
lda PARAM1
adc PARAM3
tax
lda #FR_BOTTOM
sta SCRATCH0
jmp WGFancyRect_horzEdge
WGFancyRect_vertEdge:
; Left and right edges
;
clc
lda PARAM1 ; Compute bottom edge
lda PARAM1 ; Compute bottom edge
adc PARAM3
sta SCRATCH0
sta SCRATCH0
ldx PARAM1 ; Start with top edge
ldx PARAM1 ; Start with top edge
WGFancyRect_vertLoop:
@ -646,32 +641,31 @@ WGFancyRect_vertLoop:
lda TEXTLINES_H,x
sta BASH
lda PARAM0
lda PARAM0
dec
lsr
clc
adc BASL
adc BASL
sta BASL
lda #$0
adc BASH
sta BASH
bcc WGFancyRect_SkipInc2
inc BASH
lda PARAM0 ; Left edge even?
WGFancyRect_SkipInc2:
lda PARAM0 ; Left edge even?
dec
ror
bcs WGFancyRect_vertLoopOdd
bcs WGFancyRect_vertLoopOdd
; CASE 1: Left edge even-aligned, even width
SETSWITCH PAGE2ON
ldy #$0
lda #FR_LEFT ; Plot the left edge
sta (BASL),y
SETSWITCH PAGE2ON
lda #FR_LEFT ; Plot the left edge
sta (BASL)
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
inc
inc
ror
bcs WGFancyRect_vertLoopEvenAlignedOddWidth
bcs WGFancyRect_vertLoopEvenAlignedOddWidth
lda PARAM2 ; Calculate right edge
inc
@ -679,75 +673,73 @@ WGFancyRect_vertLoop:
lsr
dec
tay
SETSWITCH PAGE2OFF
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
jmp WGFancyRect_vertLoopEvenAlignedNextRow
SETSWITCH PAGE2OFF
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
jmp WGFancyRect_vertLoopEvenAlignedNextRow
WGFancyRect_vertLoopEvenAlignedOddWidth:
; CASE 1a: Left edge even-aligned, odd width
SETSWITCH PAGE2ON
SETSWITCH PAGE2ON
lda PARAM2 ; Calculate right edge
inc
inc
lsr
tay
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
WGFancyRect_vertLoopEvenAlignedNextRow:
plx ; Prepare for next row
inx
cpx SCRATCH0
bne WGFancyRect_vertLoop
jmp WGFancyRect_corners
cpx SCRATCH0
bne WGFancyRect_vertLoop
jmp WGFancyRect_corners
WGFancyRect_vertLoopOdd:
; CASE 2: Left edge odd-aligned, even width
SETSWITCH PAGE2OFF
ldy #$0
lda #FR_LEFT ; Plot the left edge
sta (BASL),y
SETSWITCH PAGE2OFF
lda #FR_LEFT ; Plot the left edge
sta (BASL)
lda PARAM2 ; Is width even?
lda PARAM2 ; Is width even?
inc
inc
ror
bcs WGFancyRect_vertLoopOddAlignedOddWidth
bcs WGFancyRect_vertLoopOddAlignedOddWidth
lda PARAM2 ; Calculate right edge
inc
inc
lsr
tay
SETSWITCH PAGE2ON
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
jmp WGFancyRect_vertLoopOddAlignedNextRow
SETSWITCH PAGE2ON
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
jmp WGFancyRect_vertLoopOddAlignedNextRow
WGFancyRect_vertLoopOddAlignedOddWidth:
; CASE 2a: Left edge odd-aligned, odd width
SETSWITCH PAGE2OFF
SETSWITCH PAGE2OFF
lda PARAM2 ; Calculate right edge
inc
inc
lsr
tay
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
lda #FR_RIGHT ; Plot the right edge
sta (BASL),y
WGFancyRect_vertLoopOddAlignedNextRow:
plx ; Prepare for next row
inx
cpx SCRATCH0
bne WGFancyRect_vertLoopJmp
jmp WGFancyRect_corners
cpx SCRATCH0
beq WGFancyRect_corners
WGFancyRect_vertLoopJmp:
jmp WGFancyRect_vertLoop
WGFancyRect_corners:
lda PARAM0 ; Top left corner
lda PARAM0 ; Top left corner
dec
sta WG_CURSORX
lda PARAM1
@ -756,7 +748,7 @@ WGFancyRect_corners:
lda #FR_TOPLEFT
jsr WGPlot
lda PARAM0 ; Top right corner
lda PARAM0 ; Top right corner
clc
adc PARAM2
sta WG_CURSORX

View File

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

338
views.s
View File

@ -32,8 +32,7 @@ WG_FEATURE_RT = %01000000
WGCreateView:
SAVE_AXY
ldy #0
lda (PARAM0),y ; Find our new view record
lda (PARAM0) ; Find our new view record
pha ; Cache view ID so we can select when we're done
asl
@ -42,39 +41,39 @@ WGCreateView:
asl ; Records are 8 bytes wide
tax
iny
ldy #1
lda (PARAM0),y
pha ; Cache style byte for later
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
sta WG_VIEWRECORDS+1,x ; Screen Y
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+2,x ; Screen Width
sta WG_VIEWRECORDS+2,x ; Screen Width
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+3,x ; Screen Height
sta WG_VIEWRECORDS+3,x ; Screen Height
pla
sta WG_VIEWRECORDS+4,x ; Style
sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+7,x ; View Width
sta WG_VIEWRECORDS+7,x ; View Width
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+8,x ; View Height
sta WG_VIEWRECORDS+8,x ; View Height
stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback
@ -106,8 +105,8 @@ WGCreateView_done:
;
WGCreateCheckbox:
pha
lda #VIEW_STYLE_CHECK
bra WGCreate1x1_common
lda #VIEW_STYLE_CHECK
bra WGCreate1x1_common
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateRadio
@ -124,13 +123,12 @@ WGCreateCheckbox:
;
WGCreateRadio:
pha
lda #VIEW_STYLE_RADIO
lda #VIEW_STYLE_RADIO
WGCreate1x1_common:
sta WGCreate1x1_style+1
sta WGCreate1x1_style+1
SAVE_XY
ldy #0
lda (PARAM0),y ; Find our new view record
lda (PARAM0) ; Find our new view record
pha ; Cache view ID so we can select when we're done
asl
@ -139,40 +137,40 @@ WGCreate1x1_common:
asl ; Records are 16 bytes wide
tax
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
ldy #1
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
lda #1
sta WG_VIEWRECORDS+2,x ; Initialize screen width
sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+7,x ; Initialize view width
sta WG_VIEWRECORDS+8,x ; Initialize view height
lda #1
sta WG_VIEWRECORDS+2,x ; Initialize screen width
sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+7,x ; Initialize view width
sta WG_VIEWRECORDS+8,x ; Initialize view height
WGCreate1x1_style:
lda #$FF ; Self-modifying code!
sta WG_VIEWRECORDS+4,x ; Style
lda #$FF ; Self-modifying code!
sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback
stz WG_VIEWRECORDS+11,x
stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback
stz WG_VIEWRECORDS+11,x
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+13,x
lda (PARAM0),y
sta WG_VIEWRECORDS+13,x
pla
jsr WGSelectView ; Leave this as the active view
jsr WGSelectView ; Leave this as the active view
RESTORE_XY
pla
@ -195,8 +193,7 @@ WGCreate1x1_style:
WGCreateProgress:
SAVE_AXY
ldy #0
lda (PARAM0),y ; Find our new view record
lda (PARAM0) ; Find our new view record
pha ; Cache view ID so we can select when we're done
asl
@ -205,28 +202,28 @@ WGCreateProgress:
asl ; Records are 16 bytes wide
tax
iny
ldy #1
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
sta WG_VIEWRECORDS+1,x ; Screen Y
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width
sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width
lda #1
sta WG_VIEWRECORDS+3,x ; Screen height
sta WG_VIEWRECORDS+8,x ; View height
lda #1
sta WG_VIEWRECORDS+3,x ; Screen height
sta WG_VIEWRECORDS+8,x ; View height
lda #VIEW_STYLE_PROGRESS
sta WG_VIEWRECORDS+4,x ; Style
sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback
@ -234,10 +231,10 @@ WGCreateProgress:
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
sta WG_VIEWRECORDS+12,x ; Title
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+13,x
sta WG_VIEWRECORDS+13,x
pla
jsr WGSelectView ; Leave this as the active view
@ -254,20 +251,21 @@ WGCreateProgress_done:
; PARAM0: Value
;
WGSetState:
SAVE_AXY
SAVE_AY
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+9,y
and #$80
sta SCRATCH0
asl
php
lda PARAM0
and #$7F
ora SCRATCH0
sta WG_VIEWRECORDS+9,y ; State (preserving bit 7)
asl
plp
ror
sta WG_VIEWRECORDS+9,y ; State (preserving bit 7)
WGSetState_done:
RESTORE_AXY
RESTORE_AY
rts
@ -290,8 +288,7 @@ WGSetState_done:
WGCreateButton:
SAVE_AXY
ldy #0
lda (PARAM0),y ; Find our new view record
lda (PARAM0) ; Find our new view record
pha ; Cache view ID so we can select when we're done
asl
@ -300,43 +297,43 @@ WGCreateButton:
asl ; Records are 16 bytes wide
tax
iny
ldy #1
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
sta WG_VIEWRECORDS+1,x ; Screen Y
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width
sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width
lda #1
sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+8,x ; Initialize view height
sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+8,x ; Initialize view height
lda #VIEW_STYLE_BUTTON
sta WG_VIEWRECORDS+4,x ; Style
sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+10,x ; Callback
sta WG_VIEWRECORDS+10,x ; Callback
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+11,x
sta WG_VIEWRECORDS+11,x
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
sta WG_VIEWRECORDS+12,x ; Title
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+13,x
sta WG_VIEWRECORDS+13,x
pla
jsr WGSelectView ; Leave this as the active view
@ -385,13 +382,13 @@ WGPaintView:
beq WGPaintView_done ; If it's a stealth view, we're done
pha
lda WG_VIEWRECORDS+0,y ; Fetch the geometry
lda WG_VIEWRECORDS+0,y ; Fetch the geometry
sta PARAM0
lda WG_VIEWRECORDS+1,y
lda WG_VIEWRECORDS+1,y
sta PARAM1
lda WG_VIEWRECORDS+2,y
lda WG_VIEWRECORDS+2,y
sta PARAM2
lda WG_VIEWRECORDS+3,y
lda WG_VIEWRECORDS+3,y
sta PARAM3
pla ; Draw outline
@ -405,7 +402,7 @@ WGPaintView:
cmp #VIEW_STYLE_CHECK
beq WGPaintView_check
cmp #VIEW_STYLE_BUTTON
beq WGPaintView_button
beq WGPaintView_button
cmp #VIEW_STYLE_PROGRESS
beq WGPaintView_progress
bra WGPaintView_done
@ -427,7 +424,7 @@ WGPaintView_progress:
bra WGPaintView_done
WGPaintView_button:
jsr paintButton
jsr paintButton
WGPaintView_done:
jsr WGPointerDirty ; The pointer BG may now be stale
@ -444,15 +441,13 @@ WGPaintView_done:
; Side effects: Clobbers all registers,P0,P1
paintCheck:
lda WG_VIEWRECORDS+0,y ; Position cursor
sta WG_CURSORX
sta WG_CURSORX
lda WG_VIEWRECORDS+1,y
sta WG_CURSORY
sta WG_CURSORY
lda WG_VIEWRECORDS+9,y ; Determine our visual state
and #$80
bne paintCheck_selected
lda WG_VIEWRECORDS+9,y ; Determine our visual state
bmi paintCheck_selected
lda WG_VIEWRECORDS+9,y
ror
bcc paintCheck_unselectedUnchecked
@ -464,7 +459,6 @@ paintCheck_unselectedUnchecked:
bra paintCheck_plot
paintCheck_selected:
lda WG_VIEWRECORDS+9,y
ror
bcc paintCheck_selectedUnchecked
@ -490,7 +484,7 @@ paintCheck_plot: ; Paint our state
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
and #VIEW_STYLE_RAWTITLE
asl
eor #$80 ; becomes #$80 for Apple format, 0 for raw
eor #$80 ; becomes #$80 for Apple format, 0 for raw
sta paintCheck_mask+1
ldy #0
@ -515,12 +509,12 @@ paintCheck_done:
; Side effects: Clobbers all registers,P0,P1
paintProgress:
lda WG_VIEWRECORDS+1,y ; Top edge
sta PARAM1
sta PARAM1
lda #1
sta PARAM3
lda WG_VIEWRECORDS+9,y ; Progress value as width
lda WG_VIEWRECORDS+9,y ; Progress value as width
sta PARAM2
beq paintProgress_noFill ; skip if nothing to draw
@ -573,10 +567,8 @@ paintButton:
sbc SCRATCH1
sta SCRATCH1 ; Cache this for left margin rendering
lda #0 ; Position and print title
sta WG_LOCALCURSORX
lda #0
sta WG_LOCALCURSORY
stz WG_LOCALCURSORX ; Position and print title
stz WG_LOCALCURSORY
jsr WGSyncGlobalCursor
lda WG_VIEWRECORDS+9,y ; Is button highlighted?
@ -596,7 +588,7 @@ paintButton_titleMarginLeft:
ldx #0
paintButton_titleMarginLeftLoop:
cpx SCRATCH1
cpx SCRATCH1
bcs paintButton_title ; Left margin finished
jsr WGPlot
inc WG_CURSORX
@ -619,7 +611,7 @@ paintButton_titleApple:
ldx WG_LOCALCURSORX
paintButton_titleMarginRightLoop:
cpx SCRATCH1
cpx SCRATCH1
bcs paintButton_done ; Right margin finished
jsr WGPlot
inc WG_CURSORX
@ -661,7 +653,7 @@ paintWindowTitle_compute:
sbc SCRATCH1
clc
adc WG_VIEWRECORDS+0,y
sta WG_CURSORX ; Position cursor
sta WG_CURSORX ; Position cursor
lda WG_VIEWRECORDS+1,y
dec
sta WG_CURSORY
@ -669,7 +661,7 @@ paintWindowTitle_compute:
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
and #VIEW_STYLE_RAWTITLE
asl
eor #$80 ; becomes #$80 for Apple format, 0 for raw
eor #$80 ; becomes #$80 for Apple format, 0 for raw
sta paintWindowTitle_mask+1
ldy #0
@ -678,7 +670,7 @@ paintWindowTitleLoop:
beq paintWindowTitle_done
paintWindowTitle_mask:
ora #$FF ; Self-modifying code!
jsr WGPlot ; Draw the character
jsr WGPlot ; Draw the character
iny
inc WG_CURSORX ; Advance cursors
bra paintWindowTitleLoop
@ -697,25 +689,25 @@ WGEraseView:
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+0,y
lda WG_VIEWRECORDS+0,y
dec
sta PARAM0
lda WG_VIEWRECORDS+1,y
lda WG_VIEWRECORDS+1,y
dec
sta PARAM1
lda WG_VIEWRECORDS+2,y
lda WG_VIEWRECORDS+2,y
inc
inc
sta PARAM2
lda WG_VIEWRECORDS+3,y
lda WG_VIEWRECORDS+3,y
inc
inc
sta PARAM3
ldy #' '+$80
ldy #' '+$80
jsr WGFillRect
WGEraseView_done:
@ -734,19 +726,19 @@ WGEraseViewContents:
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS,y ; Fetch the record
lda WG_VIEWRECORDS,y ; Fetch the record
sta PARAM0
iny
lda WG_VIEWRECORDS,y
lda WG_VIEWRECORDS,y
sta PARAM1
iny
lda WG_VIEWRECORDS,y
lda WG_VIEWRECORDS,y
sta PARAM2
iny
lda WG_VIEWRECORDS,y
lda WG_VIEWRECORDS,y
sta PARAM3
ldy #' '+$80
ldy #' '+$80
jsr WGFillRect
WGEraseViewContents_done:
@ -762,13 +754,13 @@ WGEraseViewContents_done:
; A: ID
;
WGSelectView:
sta WG_ACTIVEVIEW
sta WG_ACTIVEVIEW
; Initialize cursor to local origin
stz WG_LOCALCURSORX
stz WG_LOCALCURSORY
jsr cacheClipPlanes ; View changed, so clipping cache is stale
jsr cacheClipPlanes ; View changed, so clipping cache is stale
WGSelectView_done:
rts
@ -839,12 +831,13 @@ WGViewFocusNext:
jsr unfocusCurrent
WGViewFocusNext_loop:
lda WG_FOCUSVIEW ; Increment and wrap
lda WG_FOCUSVIEW ; Increment and wrap
inc
cmp #16
beq WGViewFocusNext_wrap
sta WG_FOCUSVIEW
WGViewFocusNext_findLoop:
sta WG_FOCUSVIEW
LDY_FOCUSVIEW
lda WG_VIEWRECORDS+2,y
beq WGViewFocusNext_loop
@ -863,8 +856,8 @@ WGViewFocusNext_focus:
rts
WGViewFocusNext_wrap:
stz WG_FOCUSVIEW
bra WGViewFocusNext_loop
lda #1
bra WGViewFocusNext_findLoop
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -873,17 +866,17 @@ WGViewFocusNext_wrap:
; Side effects: Changes selected view, repaints some views
;
WGViewFocusPrev:
SAVE_AXY
SAVE_AY
jsr unfocusCurrent
WGViewFocusPrev_loop:
ldx WG_FOCUSVIEW ; Decrement and wrap
dex
lda WG_FOCUSVIEW ; Decrement and wrap
dec
bmi WGViewFocusPrev_wrap
WGViewFocusPrev_findLoop:
stx WG_FOCUSVIEW
sta WG_FOCUSVIEW
LDY_FOCUSVIEW
lda WG_VIEWRECORDS+2,y
beq WGViewFocusPrev_loop
@ -898,11 +891,11 @@ WGViewFocusPrev_wantFocus: ; Does this view accept focus?
WGViewFocusPrev_focus:
jsr focusCurrent
RESTORE_AXY
RESTORE_AY
rts
WGViewFocusPrev_wrap:
ldx #$f
lda #$f
bra WGViewFocusPrev_findLoop
@ -934,7 +927,7 @@ unfocusCurrentDone:
; Sets focus to desired view, and repaints
; Side effects: Clobbers A
focusCurrent:
lda WG_FOCUSVIEW
lda WG_FOCUSVIEW
jsr WGSelectView
LDY_ACTIVEVIEW
@ -964,7 +957,7 @@ WGViewFocusAction:
SAVE_AXY
lda WG_FOCUSVIEW
bpl WGViewFocusAction_do
bpl WGViewFocusAction_do
jmp WGViewFocusAction_done
WGViewFocusAction_do:
@ -974,7 +967,7 @@ WGViewFocusAction_do:
cmp #VIEW_STYLE_CHECK
beq WGViewFocusAction_toggleCheckbox
cmp #VIEW_STYLE_RADIO
cmp #VIEW_STYLE_RADIO
beq WGViewFocusAction_toggleRadio
bra WGViewFocusAction_buttonClick ; Everything else treated like a button
@ -982,21 +975,21 @@ WGViewFocusAction_toggleRadio:
lda #15
WGViewFocusAction_toggleRadioLoop:
pha
cmp WG_FOCUSVIEW
cmp WG_FOCUSVIEW
beq WGViewFocusAction_toggleRadioLoopNext
LDY_AVIEW
lda WG_VIEWRECORDS+4,y
and #$f
cmp #VIEW_STYLE_RADIO
bne WGViewFocusAction_toggleRadioLoopNext
lda WG_VIEWRECORDS+9,y ; check if this radio button is selected
lda WG_VIEWRECORDS+4,y
and #$f
cmp #VIEW_STYLE_RADIO
bne WGViewFocusAction_toggleRadioLoopNext
lda WG_VIEWRECORDS+9,y ; check if this radio button is selected
beq WGViewFocusAction_toggleRadioLoopNext
lda #0
sta WG_VIEWRECORDS+9,y ; if so, deselect it and repaint
lda #0
sta WG_VIEWRECORDS+9,y ; if so, deselect it and repaint
pla
pha
jsr WGSelectView
jsr WGPaintView
jsr WGSelectView
jsr WGPaintView
WGViewFocusAction_toggleRadioLoopNext:
pla
dec
@ -1021,17 +1014,16 @@ WGViewFocusAction_buttonClick:
lda WG_VIEWRECORDS+11,y ; Do we have a callback?
beq WGViewFocusAction_done
sta WGViewFocusAction_userJSR+2 ; Modify code below so we can JSR to user's code
lda WG_VIEWRECORDS+10,y
sta WGViewFocusAction_userJSR+1
WGViewFocusAction_userJSR:
jsr WGViewFocusAction_done ; Overwritten with user's function pointer
tya
tax
jsr WGViewFocusAction_userJMP
bra WGViewFocusAction_done
WGViewFocusAction_userJMP:
jmp (WG_VIEWRECORDS+10,x)
WGViewFocusAction_buttonClickApplesoft:
lda #0
sta WG_GOSUB
stz WG_GOSUB
lda WG_VIEWRECORDS+10,y ; Do we have a callback?
beq WGViewFocusAction_mightBeZero
@ -1250,13 +1242,13 @@ WGSetCursor:
lda #0 ; Prevent negatives
WGSetCursor_StoreX:
sta WG_LOCALCURSORX
sta WG_LOCALCURSORX
lda PARAM1
bpl WGSetCursor_StoreY
lda #0 ; Prevent negatives
WGSetCursor_StoreY:
sta WG_LOCALCURSORY
sta WG_LOCALCURSORY
pla
rts
@ -1272,9 +1264,9 @@ WGSetGlobalCursor:
pha
lda PARAM0
sta WG_CURSORX
sta WG_CURSORX
lda PARAM1
sta WG_CURSORY
sta WG_CURSORY
pla
rts
@ -1294,19 +1286,19 @@ WGSyncGlobalCursor:
; Sync X
clc ; Transform to viewspace
lda WG_LOCALCURSORX
adc WG_VIEWRECORDS+0,y
adc WG_VIEWRECORDS+0,y
clc
adc WG_VIEWRECORDS+5,y ; Transform to scrollspace
adc WG_VIEWRECORDS+5,y ; Transform to scrollspace
sta WG_CURSORX
; Sync Y
clc ; Transform to viewspace
lda WG_LOCALCURSORY
adc WG_VIEWRECORDS+1,y
adc WG_VIEWRECORDS+1,y
clc
adc WG_VIEWRECORDS+6,y ; Transform to scrollspace
adc WG_VIEWRECORDS+6,y ; Transform to scrollspace
sta WG_CURSORY
WGSyncGlobalCursor_done:
@ -1331,8 +1323,8 @@ WGScrollX:
lda #0 ; Prevent positive scroll values
WGScrollX_Store:
sta WG_VIEWRECORDS+5,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
sta WG_VIEWRECORDS+5,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
WGScrollX_done:
ply
@ -1405,8 +1397,8 @@ WGScrollY:
lda #0 ; Prevent positive scroll values
WGScrollY_Store:
sta WG_VIEWRECORDS+6,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
sta WG_VIEWRECORDS+6,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
WGScrollY_done:
ply
@ -1476,8 +1468,8 @@ WGSetContentWidth:
LDY_ACTIVEVIEW
pla
sta WG_VIEWRECORDS+7,y
jsr cacheClipPlanes ; Content width changed, so clipping cache is stale
sta WG_VIEWRECORDS+7,y
jsr cacheClipPlanes ; Content width changed, so clipping cache is stale
ply
rts
@ -1495,8 +1487,8 @@ WGSetContentHeight:
LDY_ACTIVEVIEW
pla
sta WG_VIEWRECORDS+8,y
jsr cacheClipPlanes ; Content height changed, so clipping cache is stale
sta WG_VIEWRECORDS+8,y
jsr cacheClipPlanes ; Content height changed, so clipping cache is stale
ply
rts
@ -1692,28 +1684,28 @@ cacheClipPlanes:
; Compute clip planes in view space
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+5,y ; Left edge
lda WG_VIEWRECORDS+5,y ; Left edge
eor #$ff
inc
sta WG_VIEWCLIP+0
sta WG_VIEWCLIP+0
clc
adc WG_VIEWRECORDS+2,y ; Right edge
sta WG_VIEWCLIP+2
adc WG_VIEWRECORDS+2,y ; Right edge
sta WG_VIEWCLIP+2
lda WG_VIEWRECORDS+7,y ; Right span (distance from window edge to view edge, in viewspace
lda WG_VIEWRECORDS+7,y ; Right span (distance from window edge to view edge, in viewspace
sec
sbc WG_VIEWCLIP+2
sta WG_VIEWCLIP+4
sbc WG_VIEWCLIP+2
sta WG_VIEWCLIP+4
lda WG_VIEWRECORDS+6,y ; Top edge
lda WG_VIEWRECORDS+6,y ; Top edge
eor #$ff
inc
sta WG_VIEWCLIP+1
sta WG_VIEWCLIP+1
clc
adc WG_VIEWRECORDS+3,y ; Bottom edge
sta WG_VIEWCLIP+3
adc WG_VIEWRECORDS+3,y ; Bottom edge
sta WG_VIEWCLIP+3
RESTORE_AY
rts

View File

@ -92,12 +92,12 @@ WGInit:
; sta LINNUML
; jsr SETHI
jsr WG80 ; Enter 80-col text mode
jsr WGInitApplesoft ; Set up Applesoft API
jsr WG80 ; Enter 80-col text mode
jsr WGInitApplesoft ; Set up Applesoft API
RESTORE_AXY
jmp WGReset
jmp WGReset
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -109,7 +109,7 @@ WGInit:
WGReset:
SAVE_AXY
ldy #15 ; Clear our block allocators
ldy #15 ; Clear our block allocators
WGInit_clearMemLoop:
tya
asl
@ -117,15 +117,14 @@ WGInit_clearMemLoop:
asl
asl
tax
lda #0
sta WG_VIEWRECORDS+2,x
sta WG_STRINGS,x
stz WG_VIEWRECORDS+2,x
stz WG_STRINGS,x
dey
bpl WGInit_clearMemLoop
lda #$ff
sta WG_PENDINGACTIONVIEW
sta WG_FOCUSVIEW
lda #$ff
sta WG_PENDINGACTIONVIEW
sta WG_FOCUSVIEW
RESTORE_AXY
rts
@ -147,12 +146,12 @@ WGExit:
; Remove ourselves from ProDOS memory map
; lda #%00001111
; trb MEMBITMAP + $0f
; trb MEMBITMAP + $0f
; lda #$ff
; trb MEMBITMAP + $10
; trb MEMBITMAP + $11
; trb MEMBITMAP + $10
; trb MEMBITMAP + $11
; lda #%11111100
; trb MEMBITMAP + $12
; trb MEMBITMAP + $12
pla
rts
@ -164,13 +163,13 @@ WGExit:
WG80:
pha
lda #$a0
jsr $c300
lda #$a0
jsr $c300
SETSWITCH TEXTON
SETSWITCH PAGE2OFF
SETSWITCH COL80ON
SETSWITCH STORE80ON
SETSWITCH TEXTON
SETSWITCH PAGE2OFF
SETSWITCH COL80ON
SETSWITCH STORE80ON
pla
rts