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 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
@ -478,13 +455,14 @@ WGAmpersand_CHKBX:
jsr WGAmpersandNextArgument jsr WGAmpersandNextArgument
jsr WGAmpersandStrArgument jsr WGAmpersandStrArgument
stx WGAmpersandCommandBuffer+3 stx WGAmpersandCommandBuffer+3
sty WGAmpersandCommandBuffer+4 sty WGAmpersandCommandBuffer+4
jsr WGAmpersandEndArguments jsr WGAmpersandEndArguments
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -640,27 +601,19 @@ WGAmpersand_BUTTN:
jsr WGAmpersandNextArgument jsr WGAmpersandNextArgument
jsr WGAmpersandAddrArgument jsr WGAmpersandAddrArgument
stx WGAmpersandCommandBuffer+4 stx WGAmpersandCommandBuffer+4
sty WGAmpersandCommandBuffer+5 sty WGAmpersandCommandBuffer+5
jsr WGAmpersandNextArgument jsr WGAmpersandNextArgument
jsr WGAmpersandStrArgument jsr WGAmpersandStrArgument
stx WGAmpersandCommandBuffer+6 stx WGAmpersandCommandBuffer+6
sty WGAmpersandCommandBuffer+7 sty WGAmpersandCommandBuffer+7
jsr WGAmpersandEndArguments jsr WGAmpersandEndArguments
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
@ -736,7 +689,7 @@ WGAmpersand_STACT:
jsr WGAmpersandBeginArguments jsr WGAmpersandBeginArguments
jsr WGAmpersandAddrArgument jsr WGAmpersandAddrArgument
stx PARAM0 stx PARAM0
sty PARAM1 sty PARAM1
jsr WGAmpersandEndArguments jsr WGAmpersandEndArguments
@ -753,7 +706,7 @@ WGAmpersand_TITLE:
jsr WGAmpersandBeginArguments jsr WGAmpersandBeginArguments
jsr WGAmpersandStrArgument jsr WGAmpersandStrArgument
stx PARAM0 stx PARAM0
sty PARAM1 sty PARAM1
jsr WGAmpersandEndArguments jsr WGAmpersandEndArguments
@ -798,7 +751,7 @@ WGAmpersand_PRINT:
bne WGAmpersand_NotLiteral bne WGAmpersand_NotLiteral
jsr WGAmpersandTempStrArgument jsr WGAmpersandTempStrArgument
stx PARAM0 stx PARAM0
sty PARAM1 sty PARAM1
pha pha
@ -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

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

504
rects.s
View File

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

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
@ -164,7 +163,7 @@ WGStoreStr:
phx ; Remember the start of our string phx ; Remember the start of our string
WGStoreStr_copyLoop: WGStoreStr_copyLoop:
lda (PARAM0),y lda (PARAM0),y
cmp WG_SCRATCHA cmp WG_SCRATCHA
beq WGStoreStr_terminate beq WGStoreStr_terminate
sta WG_STRINGS,x sta WG_STRINGS,x
@ -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
@ -214,7 +212,7 @@ WGStorePascalStr:
WGStorePascalStr_copyLoop: WGStorePascalStr_copyLoop:
cpy WG_SCRATCHA cpy WG_SCRATCHA
beq WGStorePascalStr_terminate beq WGStorePascalStr_terminate
lda (PARAM0),y lda (PARAM0),y
sta WG_STRINGS,x sta WG_STRINGS,x
inx inx
iny iny
@ -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

338
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,39 +41,39 @@ 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
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X sta WG_VIEWRECORDS+0,x ; Screen X
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y sta WG_VIEWRECORDS+1,x ; Screen Y
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+2,x ; Screen Width sta WG_VIEWRECORDS+2,x ; Screen Width
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+3,x ; Screen Height sta WG_VIEWRECORDS+3,x ; Screen Height
pla pla
sta WG_VIEWRECORDS+4,x ; Style sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x stz WG_VIEWRECORDS+6,x
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+7,x ; View Width sta WG_VIEWRECORDS+7,x ; View Width
iny iny
lda (PARAM0),y 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+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback stz WG_VIEWRECORDS+10,x ; Initialize callback
@ -106,8 +105,8 @@ WGCreateView_done:
; ;
WGCreateCheckbox: WGCreateCheckbox:
pha pha
lda #VIEW_STYLE_CHECK lda #VIEW_STYLE_CHECK
bra WGCreate1x1_common bra WGCreate1x1_common
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateRadio ; WGCreateRadio
@ -124,13 +123,12 @@ WGCreateCheckbox:
; ;
WGCreateRadio: WGCreateRadio:
pha pha
lda #VIEW_STYLE_RADIO lda #VIEW_STYLE_RADIO
WGCreate1x1_common: 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,40 +137,40 @@ 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
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y sta WG_VIEWRECORDS+1,x ; Screen Y
lda #1 lda #1
sta WG_VIEWRECORDS+2,x ; Initialize screen width sta WG_VIEWRECORDS+2,x ; Initialize screen width
sta WG_VIEWRECORDS+3,x ; Initialize screen height sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+7,x ; Initialize view width sta WG_VIEWRECORDS+7,x ; Initialize view width
sta WG_VIEWRECORDS+8,x ; Initialize view height sta WG_VIEWRECORDS+8,x ; Initialize view height
WGCreate1x1_style: WGCreate1x1_style:
lda #$FF ; Self-modifying code! lda #$FF ; Self-modifying code!
sta WG_VIEWRECORDS+4,x ; Style sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback stz WG_VIEWRECORDS+10,x ; Initialize callback
stz WG_VIEWRECORDS+11,x stz WG_VIEWRECORDS+11,x
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title sta WG_VIEWRECORDS+12,x ; Title
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+13,x sta WG_VIEWRECORDS+13,x
pla pla
jsr WGSelectView ; Leave this as the active view jsr WGSelectView ; Leave this as the active view
RESTORE_XY RESTORE_XY
pla pla
@ -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,28 +202,28 @@ 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
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y sta WG_VIEWRECORDS+1,x ; Screen Y
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+2,x ; Screen width sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width sta WG_VIEWRECORDS+7,x ; View width
lda #1 lda #1
sta WG_VIEWRECORDS+3,x ; Screen height sta WG_VIEWRECORDS+3,x ; Screen height
sta WG_VIEWRECORDS+8,x ; View height sta WG_VIEWRECORDS+8,x ; View height
lda #VIEW_STYLE_PROGRESS 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+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback stz WG_VIEWRECORDS+10,x ; Initialize callback
@ -234,10 +231,10 @@ WGCreateProgress:
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title sta WG_VIEWRECORDS+12,x ; Title
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+13,x sta WG_VIEWRECORDS+13,x
pla pla
jsr WGSelectView ; Leave this as the active view jsr WGSelectView ; Leave this as the active view
@ -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
sta WG_VIEWRECORDS+9,y ; State (preserving bit 7) ror
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,43 +297,43 @@ 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
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y sta WG_VIEWRECORDS+1,x ; Screen Y
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+2,x ; Screen width sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width sta WG_VIEWRECORDS+7,x ; View width
lda #1 lda #1
sta WG_VIEWRECORDS+3,x ; Initialize screen height sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+8,x ; Initialize view height sta WG_VIEWRECORDS+8,x ; Initialize view height
lda #VIEW_STYLE_BUTTON 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+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state stz WG_VIEWRECORDS+9,x ; Initialize state
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+10,x ; Callback sta WG_VIEWRECORDS+10,x ; Callback
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+11,x sta WG_VIEWRECORDS+11,x
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title sta WG_VIEWRECORDS+12,x ; Title
iny iny
lda (PARAM0),y lda (PARAM0),y
sta WG_VIEWRECORDS+13,x sta WG_VIEWRECORDS+13,x
pla pla
jsr WGSelectView ; Leave this as the active view 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 beq WGPaintView_done ; If it's a stealth view, we're done
pha pha
lda WG_VIEWRECORDS+0,y ; Fetch the geometry lda WG_VIEWRECORDS+0,y ; Fetch the geometry
sta PARAM0 sta PARAM0
lda WG_VIEWRECORDS+1,y lda WG_VIEWRECORDS+1,y
sta PARAM1 sta PARAM1
lda WG_VIEWRECORDS+2,y lda WG_VIEWRECORDS+2,y
sta PARAM2 sta PARAM2
lda WG_VIEWRECORDS+3,y lda WG_VIEWRECORDS+3,y
sta PARAM3 sta PARAM3
pla ; Draw outline pla ; Draw outline
@ -405,7 +402,7 @@ WGPaintView:
cmp #VIEW_STYLE_CHECK cmp #VIEW_STYLE_CHECK
beq WGPaintView_check beq WGPaintView_check
cmp #VIEW_STYLE_BUTTON cmp #VIEW_STYLE_BUTTON
beq WGPaintView_button beq WGPaintView_button
cmp #VIEW_STYLE_PROGRESS cmp #VIEW_STYLE_PROGRESS
beq WGPaintView_progress beq WGPaintView_progress
bra WGPaintView_done bra WGPaintView_done
@ -427,7 +424,7 @@ WGPaintView_progress:
bra WGPaintView_done bra WGPaintView_done
WGPaintView_button: WGPaintView_button:
jsr paintButton jsr paintButton
WGPaintView_done: WGPaintView_done:
jsr WGPointerDirty ; The pointer BG may now be stale jsr WGPointerDirty ; The pointer BG may now be stale
@ -444,15 +441,13 @@ WGPaintView_done:
; Side effects: Clobbers all registers,P0,P1 ; Side effects: Clobbers all registers,P0,P1
paintCheck: paintCheck:
lda WG_VIEWRECORDS+0,y ; Position cursor lda WG_VIEWRECORDS+0,y ; Position cursor
sta WG_CURSORX sta WG_CURSORX
lda WG_VIEWRECORDS+1,y lda WG_VIEWRECORDS+1,y
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
@ -490,7 +484,7 @@ paintCheck_plot: ; Paint our state
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title? lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
and #VIEW_STYLE_RAWTITLE and #VIEW_STYLE_RAWTITLE
asl 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 sta paintCheck_mask+1
ldy #0 ldy #0
@ -515,12 +509,12 @@ paintCheck_done:
; Side effects: Clobbers all registers,P0,P1 ; Side effects: Clobbers all registers,P0,P1
paintProgress: paintProgress:
lda WG_VIEWRECORDS+1,y ; Top edge lda WG_VIEWRECORDS+1,y ; Top edge
sta PARAM1 sta PARAM1
lda #1 lda #1
sta PARAM3 sta PARAM3
lda WG_VIEWRECORDS+9,y ; Progress value as width lda WG_VIEWRECORDS+9,y ; Progress value as width
sta PARAM2 sta PARAM2
beq paintProgress_noFill ; skip if nothing to draw beq paintProgress_noFill ; skip if nothing to draw
@ -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?
@ -596,7 +588,7 @@ paintButton_titleMarginLeft:
ldx #0 ldx #0
paintButton_titleMarginLeftLoop: paintButton_titleMarginLeftLoop:
cpx SCRATCH1 cpx SCRATCH1
bcs paintButton_title ; Left margin finished bcs paintButton_title ; Left margin finished
jsr WGPlot jsr WGPlot
inc WG_CURSORX inc WG_CURSORX
@ -619,7 +611,7 @@ paintButton_titleApple:
ldx WG_LOCALCURSORX ldx WG_LOCALCURSORX
paintButton_titleMarginRightLoop: paintButton_titleMarginRightLoop:
cpx SCRATCH1 cpx SCRATCH1
bcs paintButton_done ; Right margin finished bcs paintButton_done ; Right margin finished
jsr WGPlot jsr WGPlot
inc WG_CURSORX inc WG_CURSORX
@ -661,7 +653,7 @@ paintWindowTitle_compute:
sbc SCRATCH1 sbc SCRATCH1
clc clc
adc WG_VIEWRECORDS+0,y adc WG_VIEWRECORDS+0,y
sta WG_CURSORX ; Position cursor sta WG_CURSORX ; Position cursor
lda WG_VIEWRECORDS+1,y lda WG_VIEWRECORDS+1,y
dec dec
sta WG_CURSORY sta WG_CURSORY
@ -669,7 +661,7 @@ paintWindowTitle_compute:
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title? lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
and #VIEW_STYLE_RAWTITLE and #VIEW_STYLE_RAWTITLE
asl 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 sta paintWindowTitle_mask+1
ldy #0 ldy #0
@ -678,7 +670,7 @@ paintWindowTitleLoop:
beq paintWindowTitle_done beq paintWindowTitle_done
paintWindowTitle_mask: paintWindowTitle_mask:
ora #$FF ; Self-modifying code! ora #$FF ; Self-modifying code!
jsr WGPlot ; Draw the character jsr WGPlot ; Draw the character
iny iny
inc WG_CURSORX ; Advance cursors inc WG_CURSORX ; Advance cursors
bra paintWindowTitleLoop bra paintWindowTitleLoop
@ -697,25 +689,25 @@ WGEraseView:
LDY_ACTIVEVIEW LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+0,y lda WG_VIEWRECORDS+0,y
dec dec
sta PARAM0 sta PARAM0
lda WG_VIEWRECORDS+1,y lda WG_VIEWRECORDS+1,y
dec dec
sta PARAM1 sta PARAM1
lda WG_VIEWRECORDS+2,y lda WG_VIEWRECORDS+2,y
inc inc
inc inc
sta PARAM2 sta PARAM2
lda WG_VIEWRECORDS+3,y lda WG_VIEWRECORDS+3,y
inc inc
inc inc
sta PARAM3 sta PARAM3
ldy #' '+$80 ldy #' '+$80
jsr WGFillRect jsr WGFillRect
WGEraseView_done: WGEraseView_done:
@ -734,19 +726,19 @@ WGEraseViewContents:
LDY_ACTIVEVIEW LDY_ACTIVEVIEW
lda WG_VIEWRECORDS,y ; Fetch the record lda WG_VIEWRECORDS,y ; Fetch the record
sta PARAM0 sta PARAM0
iny iny
lda WG_VIEWRECORDS,y lda WG_VIEWRECORDS,y
sta PARAM1 sta PARAM1
iny iny
lda WG_VIEWRECORDS,y lda WG_VIEWRECORDS,y
sta PARAM2 sta PARAM2
iny iny
lda WG_VIEWRECORDS,y lda WG_VIEWRECORDS,y
sta PARAM3 sta PARAM3
ldy #' '+$80 ldy #' '+$80
jsr WGFillRect jsr WGFillRect
WGEraseViewContents_done: WGEraseViewContents_done:
@ -762,13 +754,13 @@ WGEraseViewContents_done:
; A: ID ; A: ID
; ;
WGSelectView: WGSelectView:
sta WG_ACTIVEVIEW sta WG_ACTIVEVIEW
; Initialize cursor to local origin ; Initialize cursor to local origin
stz WG_LOCALCURSORX stz WG_LOCALCURSORX
stz WG_LOCALCURSORY stz WG_LOCALCURSORY
jsr cacheClipPlanes ; View changed, so clipping cache is stale jsr cacheClipPlanes ; View changed, so clipping cache is stale
WGSelectView_done: WGSelectView_done:
rts rts
@ -839,12 +831,13 @@ WGViewFocusNext:
jsr unfocusCurrent jsr unfocusCurrent
WGViewFocusNext_loop: WGViewFocusNext_loop:
lda WG_FOCUSVIEW ; Increment and wrap lda WG_FOCUSVIEW ; Increment and wrap
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
@ -934,7 +927,7 @@ unfocusCurrentDone:
; Sets focus to desired view, and repaints ; Sets focus to desired view, and repaints
; Side effects: Clobbers A ; Side effects: Clobbers A
focusCurrent: focusCurrent:
lda WG_FOCUSVIEW lda WG_FOCUSVIEW
jsr WGSelectView jsr WGSelectView
LDY_ACTIVEVIEW LDY_ACTIVEVIEW
@ -964,7 +957,7 @@ WGViewFocusAction:
SAVE_AXY SAVE_AXY
lda WG_FOCUSVIEW lda WG_FOCUSVIEW
bpl WGViewFocusAction_do bpl WGViewFocusAction_do
jmp WGViewFocusAction_done jmp WGViewFocusAction_done
WGViewFocusAction_do: WGViewFocusAction_do:
@ -974,7 +967,7 @@ WGViewFocusAction_do:
cmp #VIEW_STYLE_CHECK cmp #VIEW_STYLE_CHECK
beq WGViewFocusAction_toggleCheckbox beq WGViewFocusAction_toggleCheckbox
cmp #VIEW_STYLE_RADIO cmp #VIEW_STYLE_RADIO
beq WGViewFocusAction_toggleRadio beq WGViewFocusAction_toggleRadio
bra WGViewFocusAction_buttonClick ; Everything else treated like a button bra WGViewFocusAction_buttonClick ; Everything else treated like a button
@ -982,21 +975,21 @@ WGViewFocusAction_toggleRadio:
lda #15 lda #15
WGViewFocusAction_toggleRadioLoop: WGViewFocusAction_toggleRadioLoop:
pha pha
cmp WG_FOCUSVIEW cmp WG_FOCUSVIEW
beq WGViewFocusAction_toggleRadioLoopNext beq WGViewFocusAction_toggleRadioLoopNext
LDY_AVIEW LDY_AVIEW
lda WG_VIEWRECORDS+4,y lda WG_VIEWRECORDS+4,y
and #$f and #$f
cmp #VIEW_STYLE_RADIO cmp #VIEW_STYLE_RADIO
bne WGViewFocusAction_toggleRadioLoopNext bne WGViewFocusAction_toggleRadioLoopNext
lda WG_VIEWRECORDS+9,y ; check if this radio button is selected lda WG_VIEWRECORDS+9,y ; check if this radio button is selected
beq WGViewFocusAction_toggleRadioLoopNext beq WGViewFocusAction_toggleRadioLoopNext
lda #0 lda #0
sta WG_VIEWRECORDS+9,y ; if so, deselect it and repaint sta WG_VIEWRECORDS+9,y ; if so, deselect it and repaint
pla pla
pha pha
jsr WGSelectView jsr WGSelectView
jsr WGPaintView jsr WGPaintView
WGViewFocusAction_toggleRadioLoopNext: WGViewFocusAction_toggleRadioLoopNext:
pla pla
dec dec
@ -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
@ -1250,13 +1242,13 @@ WGSetCursor:
lda #0 ; Prevent negatives lda #0 ; Prevent negatives
WGSetCursor_StoreX: WGSetCursor_StoreX:
sta WG_LOCALCURSORX sta WG_LOCALCURSORX
lda PARAM1 lda PARAM1
bpl WGSetCursor_StoreY bpl WGSetCursor_StoreY
lda #0 ; Prevent negatives lda #0 ; Prevent negatives
WGSetCursor_StoreY: WGSetCursor_StoreY:
sta WG_LOCALCURSORY sta WG_LOCALCURSORY
pla pla
rts rts
@ -1272,9 +1264,9 @@ WGSetGlobalCursor:
pha pha
lda PARAM0 lda PARAM0
sta WG_CURSORX sta WG_CURSORX
lda PARAM1 lda PARAM1
sta WG_CURSORY sta WG_CURSORY
pla pla
rts rts
@ -1294,19 +1286,19 @@ WGSyncGlobalCursor:
; Sync X ; Sync X
clc ; Transform to viewspace clc ; Transform to viewspace
lda WG_LOCALCURSORX lda WG_LOCALCURSORX
adc WG_VIEWRECORDS+0,y adc WG_VIEWRECORDS+0,y
clc clc
adc WG_VIEWRECORDS+5,y ; Transform to scrollspace adc WG_VIEWRECORDS+5,y ; Transform to scrollspace
sta WG_CURSORX sta WG_CURSORX
; Sync Y ; Sync Y
clc ; Transform to viewspace clc ; Transform to viewspace
lda WG_LOCALCURSORY lda WG_LOCALCURSORY
adc WG_VIEWRECORDS+1,y adc WG_VIEWRECORDS+1,y
clc clc
adc WG_VIEWRECORDS+6,y ; Transform to scrollspace adc WG_VIEWRECORDS+6,y ; Transform to scrollspace
sta WG_CURSORY sta WG_CURSORY
WGSyncGlobalCursor_done: WGSyncGlobalCursor_done:
@ -1331,8 +1323,8 @@ WGScrollX:
lda #0 ; Prevent positive scroll values lda #0 ; Prevent positive scroll values
WGScrollX_Store: WGScrollX_Store:
sta WG_VIEWRECORDS+5,y sta WG_VIEWRECORDS+5,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
WGScrollX_done: WGScrollX_done:
ply ply
@ -1405,8 +1397,8 @@ WGScrollY:
lda #0 ; Prevent positive scroll values lda #0 ; Prevent positive scroll values
WGScrollY_Store: WGScrollY_Store:
sta WG_VIEWRECORDS+6,y sta WG_VIEWRECORDS+6,y
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
WGScrollY_done: WGScrollY_done:
ply ply
@ -1476,8 +1468,8 @@ WGSetContentWidth:
LDY_ACTIVEVIEW LDY_ACTIVEVIEW
pla pla
sta WG_VIEWRECORDS+7,y sta WG_VIEWRECORDS+7,y
jsr cacheClipPlanes ; Content width changed, so clipping cache is stale jsr cacheClipPlanes ; Content width changed, so clipping cache is stale
ply ply
rts rts
@ -1495,8 +1487,8 @@ WGSetContentHeight:
LDY_ACTIVEVIEW LDY_ACTIVEVIEW
pla pla
sta WG_VIEWRECORDS+8,y sta WG_VIEWRECORDS+8,y
jsr cacheClipPlanes ; Content height changed, so clipping cache is stale jsr cacheClipPlanes ; Content height changed, so clipping cache is stale
ply ply
rts rts
@ -1692,28 +1684,28 @@ cacheClipPlanes:
; Compute clip planes in view space ; Compute clip planes in view space
LDY_ACTIVEVIEW LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+5,y ; Left edge lda WG_VIEWRECORDS+5,y ; Left edge
eor #$ff eor #$ff
inc inc
sta WG_VIEWCLIP+0 sta WG_VIEWCLIP+0
clc clc
adc WG_VIEWRECORDS+2,y ; Right edge adc WG_VIEWRECORDS+2,y ; Right edge
sta WG_VIEWCLIP+2 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 sec
sbc WG_VIEWCLIP+2 sbc WG_VIEWCLIP+2
sta WG_VIEWCLIP+4 sta WG_VIEWCLIP+4
lda WG_VIEWRECORDS+6,y ; Top edge lda WG_VIEWRECORDS+6,y ; Top edge
eor #$ff eor #$ff
inc inc
sta WG_VIEWCLIP+1 sta WG_VIEWCLIP+1
clc clc
adc WG_VIEWRECORDS+3,y ; Bottom edge adc WG_VIEWRECORDS+3,y ; Bottom edge
sta WG_VIEWCLIP+3 sta WG_VIEWCLIP+3
RESTORE_AY RESTORE_AY
rts rts

View File

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