Experimental AUX memory branch

- Moved primary library code to AUX memory
- Factored mouse driver out into separate loadable module, living at the top of main memory
- Pending actions now handled by caching click location instead of View ID, so interrupt handler doesn't have to call AUX memory code
This commit is contained in:
Quinn Dunki 2015-01-01 15:44:46 -08:00
parent 99095e297d
commit 5ff05105fb
16 changed files with 516 additions and 193 deletions

8
.gitignore vendored
View File

@ -1,13 +1,9 @@
/WeeGUI.xcodeproj/project.xcworkspace/xcuserdata/
/WeeGUI.xcodeproj/xcuserdata/
/gui.lst
/guidemo.lst
/gui
/guidemo
/guidemo.o
.DS_Store
mouse.lst

View File

@ -11,14 +11,16 @@
CL65=cl65
AC=AppleCommander.jar
ADDR=4000
ADDR=7a00
ADDRDEMO=6000
ADDRMOUSE=9344
PGM=gui
DEMO=guidemo
MOUSE=mouse
all: $(DEMO) $(PGM)
#all: $(PGM)
all: $(DEMO) $(MOUSE) $(PGM)
$(DEMO):
@PATH=$(PATH):/usr/local/bin; $(CL65) -t apple2enh --start-addr $(ADDRDEMO) -l$(DEMO).lst $(DEMO).s
@ -27,8 +29,15 @@ $(DEMO):
rm -f $(DEMO)
rm -f $(DEMO).o
$(MOUSE):
@PATH=$(PATH):/usr/local/bin; $(CL65) -t apple2enh --start-addr $(ADDRMOUSE) -l$(MOUSE).lst $(MOUSE).s
java -jar $(AC) -d $(DEMO).dsk $(MOUSE)
java -jar $(AC) -p $(DEMO).dsk $(MOUSE) BIN 0x$(ADDRMOUSE) < $(MOUSE)
rm -f $(MOUSE)
rm -f $(MOUSE).o
$(PGM):
@PATH=$(PATH):/usr/local/bin; $(CL65) -t apple2enh --start-addr $(ADDR) -l$(PGM).lst $(PGM).s
@PATH=$(PATH):/usr/local/bin; $(CL65) -t apple2enh --start-addr 0x$(ADDR) -l$(PGM).lst $(PGM).s
java -jar $(AC) -d $(DEMO).dsk $(PGM)
java -jar $(AC) -p $(DEMO).dsk $(PGM) BIN 0x$(ADDR) < $(PGM)
rm -f $(PGM)
@ -38,6 +47,8 @@ $(PGM):
clean:
rm -f $(DEMO)
rm -f $(DEMO).o
rm -f $(MOUSE)
rm -f $(MOUSE).o
rm -f $(PGM)
rm -f $(PGM).o

View File

@ -8,9 +8,10 @@ Known issues
- Mashing a button with mouse in Applesoft will cause Undefined Statement error
- Repainting a view while the mouse cursor is on it will cause artifacts when mouse moves
- Quitting sometimes leaves BASIC in inverted text mode
- Quitting with button highlighted leaves us in inverted text mode
To Do:
------
- Make WGFillRect support 1 height and 1 width
- If called in inverse mode, clear screen clears inverse

Binary file not shown.

View File

@ -20,7 +20,7 @@ PARAM3 = $09
; WeeGUI entry point
; Set up your call, then do a JSR to this address.
;
WeeGUI = $4004
WeeGUI = $300
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -55,10 +55,10 @@ WGViewFocusNext = 44
WGViewFocusPrev = 46
WGViewFocusAction = 48
WGPendingViewAction = 50
WGPendingView = 52
WGScrollX = 54
WGScrollXBy = 56
WGScrollY = 58
WGScrollYBy = 60
WGEnableMouse = 62
WGDisableMouse = 64
WGPointerDirty = 66

View File

@ -846,19 +846,19 @@ WGAmpersand_PLOT:
; Enable or disable the mouse
; &MOUSE(enable)
WGAmpersand_MOUSE:
jsr WGAmpersandBeginArguments
jsr WGAmpersandIntArgument
; jsr WGAmpersandBeginArguments
; jsr WGAmpersandIntArgument
pha
jsr WGAmpersandEndArguments
; pha
; jsr WGAmpersandEndArguments
pla
beq WGAmpersand_MOUSEoff
jsr WGEnableMouse
rts
; pla
; beq WGAmpersand_MOUSEoff
; jsr WGEnableMouse
; rts
WGAmpersand_MOUSEoff:
jsr WGDisableMouse
;WGAmpersand_MOUSEoff:
; jsr WGDisableMouse
rts
@ -868,7 +868,7 @@ WGAmpersand_MOUSEoff:
; Performs any pending view action
; &PDACT
WGAmpersand_PDACT:
lda WG_PENDINGACTIONVIEW
lda WG_PENDINGACTIONCLICKX
bmi WGAmpersand_PDACTdone
jsr WGPendingViewAction

185
gui.s
View File

@ -7,7 +7,7 @@
;
.org $4000
.org $7a00
; Common definitions
@ -16,27 +16,119 @@
.include "macros.s"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Main entry point. BRUN will land here.
main:
jsr WGInit
rts ; Don't add any bytes here!
; Copy ourselves into AUX Memory
;
lda #<main
sta A1L
lda #>main
sta A1H
lda #<WG_END
sta A2L
lda #>WG_END
sta A2H
lda #<main
sta A4L
lda #>main
sta A4H
sec
jsr AUXMOVE
tsx ; Firmware convention requires saving the stack pointer before any XFERs
stx $0100
ldx #$ff
stx $0101
rts
; This is the non-negotiable entry point used by applications Don't move it!
; $4004
WeeGUI = $300
WeeGUIMouse = $9344
WGDISPATCH = WeeGUI + (WGEntryPointTable-WGDispatch)
WGDISPATCHRETURN = WeeGUI + (WGDispatchMAIN-WGDispatch)
WGCALLBACKRETURN = WeeGUI + (WGCallbackReturn-WGDispatch)
WGFirstMouseDispatch = 62 ; Special cases for the dispatcher above this value
WGEnableMouseDispatch = 62
WGDisableMouseDispatch = 64
WGPointerDirtyDispatch = 66
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGDispatch
; The dispatcher for calling the assembly-language API from assembly programs
; The dispatcher for calling the assembly-language API from assembly programs.
; This routine gets copied into $300 for use by main bank programs and Applesoft
; X: API call number
; P0-3,Y: Parameters to call, as needed
;
WGDispatch:
jmp (WGEntryPointTable,x)
; Check some special cases
cpx #WGFirstMouseDispatch
bcs WGDispatch_mouse
; Entry point jump table
lda WGDISPATCH,x ; Set up to transfer control into AUX memory
sta XFERL
lda WGDISPATCH+1,x
sta XFERH
tsx ; Firmware convention requires saving the stack pointer before XFER
stx $0100
lda #>WGDispatchReturn ; Give our routine somewhere to come back to
pha
lda #<WGDispatchReturn
pha
sec ; Transfer control to the routine in AUX memory
clv
jmp XFER
WGDispatch_mouse:
lda WG_MOUSELOADED
beq WGDispatch_mouseLoadDriver
WGDispatch_mouseDispatch:
txa ; Transfer control to mouse driver
sec
sbc #WGFirstMouseDispatch
tax
jsr WeeGUIMouse
WGDispatch_done:
rts
WGDispatch_mouseLoadDriver:
phx
lda #1
sta WG_MOUSELOADED
; BLOAD the mouse driver
ldx #0
ldy #0
@0: lda bloadCmdLine,x
beq @1
sta INBUF,y
inx
iny
bra @0
@1: jsr DOSCMD
plx
bra WGDispatch_mouseDispatch
bloadCmdLine:
.byte "BLOAD mouse",$8d,0
WGDispatchMAIN:
rts
; Entry point jump table - WGDISPATCH points here after this is copied to $300
WGEntryPointTable:
.addr WGClearScreen
.addr WGDesktop
@ -64,20 +156,85 @@ WGEntryPointTable:
.addr WGViewFocusPrev
.addr WGViewFocusAction
.addr WGPendingViewAction
.addr WGPendingView
.addr WGScrollX
.addr WGScrollXBy
.addr WGScrollY
.addr WGScrollYBy
.addr WGEnableMouse
.addr WGDisableMouse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCallbackReturn
; This is an anchor point in MAIN memory that user callbacks
; RTS back to. From here, we transfer control safely back to aux
; memory so that WeeGUI can resume.
;
WGCallbackReturn:
nop ; Needed because RTS will skip one instruction, per usual
lda #<WGCallbackAUX ; Set up to transfer control into AUX memory
sta XFERL
lda #>WGCallbackAUX
sta XFERH
sec ; Transfer control to the routine in AUX memory
clv
jmp XFER
; This is the end of what is copied into $300 in MAIN memory
WGDispatchEnd:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGDispatchReturn
; This is an anchor point in AUX memory that WeeGUI subroutines
; RTS back to. From here, we transfer control safely back to main
; memory so the caller can resume.
;
WGDispatchReturn:
nop ; Needed because RTS will skip one instruction, per usual
lda #<WGDISPATCHRETURN ; Set up to transfer control into MAIN memory
sta XFERL
lda #>WGDISPATCHRETURN
sta XFERH
clc ; Transfer control to the routine in MAIN memory
clv
jmp XFER
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCallback
; Calls a user's routine in MAIN memory
; XFERL: Pointer in main memory (LSB)
; XFERH: Pointer in main memory (MSB)
WGCallback:
lda #>WGCALLBACKRETURN ; Give user's routine somewhere to come back to
pha
lda #<WGCALLBACKRETURN
pha
clc ; Transfer control to the user's routine in MAIN memory
clv
jmp XFER
WGCallbackAUX:
nop
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGInit
; Initialization. Should be called once at app startup
; Side effects: Clobbers all registers
;
WGInit:
SAVE_AXY
; Copy dispatcher to $300
;
ldx #WGDispatchEnd-WGDispatch
WGInit_copyLoop:
lda WGDispatch-1,x
sta WeeGUI-1,x
dex
bne WGInit_copyLoop
jsr WG80
jsr WGInitApplesoft
@ -96,16 +253,16 @@ WGInit_clearMemLoop:
bpl WGInit_clearMemLoop
lda #$ff
sta WG_PENDINGACTIONVIEW
sta WG_PENDINGACTIONCLICKX
sta WG_FOCUSVIEW
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WG80
; Enables 80 column mode (and enhanced video firmware)
;
WG80:
pha
@ -126,10 +283,10 @@ WG80:
.include "painting.s"
.include "rects.s"
.include "views.s"
.include "mouse.s"
.include "applesoft.s"
.include "memory.s"
WG_END: ; The absolute end of our memory footprint. Nothing past this point!
; Suppress some linker warnings - Must be the last thing in the file

Binary file not shown.

View File

@ -42,25 +42,28 @@ main:
bra @0
@1: jsr DOSCMD
jsr $7a00 ; HACK: Temp, until we figure out to BRUN from here
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Show off some WeeGUI features
;jmp tortureTestPrint
;jmp tortureTestRects
ldx #WGClearScreen
jsr WeeGUI
ldx #WGEnableMouse
jsr WeeGUI
ldx #WGDesktop
jsr WeeGUI
WGCALL16 WGCreateView,testView
WGCALL16 WGViewSetAction,testPaintContentsClick
; WGCALL16 WGViewSetTitle,testTitle0
; WGCALL16 WGCreateCheckbox,testCheck
; WGCALL16 WGCreateButton,testButton1
; WGCALL16 WGCreateButton,testButton2
WGCALL16 WGViewSetTitle,testTitle0
WGCALL16 WGCreateCheckbox,testCheck
WGCALL16 WGCreateButton,testButton1
WGCALL16 WGCreateButton,testButton2
ldx #WGViewPaintAll
jsr WeeGUI
@ -69,10 +72,7 @@ main:
ldx #WGSelectView
jsr WeeGUI
ldx #WGEnableMouse
jsr WeeGUI
jsr testPaintContents
; jsr testPaintContents
keyLoop:
ldx #WGPendingViewAction

View File

@ -9,31 +9,37 @@
; Constants
CHAR_NORMAL = $ff
CHAR_INVERSE = $3f
CHAR_FLASH = $7f
CHAR_NORMAL = $ff
CHAR_INVERSE = $3f
CHAR_FLASH = $7f
VIEW_STYLE_PLAIN = $00
VIEW_STYLE_FANCY = $01
VIEW_STYLE_CHECK = $02
VIEW_STYLE_BUTTON = $03
VIEW_STYLE_PLAIN = $00
VIEW_STYLE_FANCY = $01
VIEW_STYLE_CHECK = $02
VIEW_STYLE_BUTTON = $03
VIEW_STYLE_TAKESFOCUS = $02 ; Styles >= this one are selectable
VIEW_STYLE_TAKESFOCUS= $02 ; Styles >= this one are selectable
VIEW_STYLE_APPLESOFT = $80 ; High nybble flag bit for views created from Applesoft
IRQVECTORL = $03fe
IRQVECTORH = $03ff
INBUF = $0200
; Page 3 Contants
IRQVECTORL = $03fe
IRQVECTORH = $03ff
XFERL = $03ed
XFERH = $03ee
; ROM entry points
AUXMOVE = $c311
XFER = $c314
COUT = $fded
BASCALC = $fbc1
PRBYTE = $fdda
RDKEY = $fd0c
BELL = $fbdd
DOSCMD = $be03
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; System state
@ -54,10 +60,10 @@ WG_ACTIVEVIEW:
WG_FOCUSVIEW:
.byte 0
WG_PENDINGACTIONVIEW:
WG_GOSUB: ; Set if an Applesoft gosub was generated by a view action
.byte 0
WG_GOSUB: ; Set if an Applesoft gosub was generated by a view action
WG_MOUSELOADED: ; Set if the mouse driver has been loaded
.byte 0
WG_VIEWCLIP:
@ -105,6 +111,12 @@ WG_STRINGS: ; Fixed-size block allocator for strings (view titles, mainly)
WG_SCRATCHA:
.byte 0
WG_AUXPARAM: ; An aux memory area to cache pass-by-reference parameters
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
.byte 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Lookup tables

165
mouse.s
View File

@ -1,19 +1,18 @@
;
; mouse.s
; Routines for handling the mouse
; Standalone mouse driver for WeeGUI. Copied in to the top
; of main memory
;
; Created by Quinn Dunki on 8/15/14.
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; ProDOS ROM entry points and constants
;
PRODOS_MLI = $bf00
.org $9344
ALLOC_INTERRUPT = $40
DEALLOC_INTERRUPT = $41
.include "macros.s"
.include "zeropage.s"
.include "switches.s"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -22,34 +21,34 @@ DEALLOC_INTERRUPT = $41
; These mouse firmware entry points are offsets from the firmware
; entry point of the slot, and also indirect.
SETMOUSE = $12
SERVEMOUSE = $13
READMOUSE = $14
CLEARMOUSE = $15
POSMOUSE = $16
CLAMPMOUSE = $17
HOMEMOUSE = $18
INITMOUSE = $19
SETMOUSE = $12
SERVEMOUSE = $13
READMOUSE = $14
CLEARMOUSE = $15
POSMOUSE = $16
CLAMPMOUSE = $17
HOMEMOUSE = $18
INITMOUSE = $19
MOUSTAT = $0778 ; + Slot Num
MOUSE_XL = $0478 ; + Slot Num
MOUSE_XH = $0578 ; + Slot Num
MOUSE_YL = $04f8 ; + Slot Num
MOUSE_YH = $05f8 ; + Slot Num
MOUSE_CLAMPL = $04f8
MOUSE_CLAMPH = $05f8
MOUSTAT = $0778 ; + Slot Num
MOUSE_XL = $0478 ; + Slot Num
MOUSE_XH = $0578 ; + Slot Num
MOUSE_YL = $04f8 ; + Slot Num
MOUSE_YH = $05f8 ; + Slot Num
MOUSE_CLAMPL = $04f8
MOUSE_CLAMPH = $05f8
MOUSTAT_MASK_BUTTONINT = %00000100
MOUSTAT_MASK_MOVEINT = %00000010
MOUSTAT_MASK_DOWN = %10000000
MOUSTAT_MASK_WASDOWN = %01000000
MOUSTAT_MASK_MOVED = %00100000
MOUSTAT_MASK_BUTTONINT = %00000100
MOUSTAT_MASK_MOVEINT = %00000010
MOUSTAT_MASK_DOWN = %10000000
MOUSTAT_MASK_WASDOWN = %01000000
MOUSTAT_MASK_MOVED = %00100000
MOUSEMODE_OFF = $00 ; Mouse off
MOUSEMODE_PASSIVE = $01 ; Passive mode (polling only)
MOUSEMODE_MOVEINT = $03 ; Interrupts on movement
MOUSEMODE_BUTINT = $05 ; Interrupts on button
MOUSEMODE_COMBINT = $07 ; Interrupts on movement and button
MOUSEMODE_OFF = $00 ; Mouse off
MOUSEMODE_PASSIVE = $01 ; Passive mode (polling only)
MOUSEMODE_MOVEINT = $03 ; Interrupts on movement
MOUSEMODE_BUTINT = $05 ; Interrupts on button
MOUSEMODE_COMBINT = $07 ; Interrupts on movement and button
; Mouse firmware is all indirectly called, because
@ -64,6 +63,34 @@ MOUSEMODE_COMBINT = $07 ; Interrupts on movement and button
CH_MOUSEPOINTER = 'B'
; WeeGUI constants
WeeGUI = $300
WGViewFromPointDispatch = 38
; ProDOS Constants
ALLOC_INTERRUPT = $40
DEALLOC_INTERRUPT = $41
PRODOS_MLI = $bf00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGMouseDispatch
; The dispatcher for calling mouse routines from assembly programs.
; X: API call number
; P0-3,Y: Parameters to call, as needed
;
WGMouseDispatch:
jmp (WGMouseEntryPointTable,x)
; Entry point jump table - WGDISPATCH points here after this is copied to $300
WGMouseEntryPointTable:
.addr WGEnableMouse
.addr WGDisableMouse
.addr WGPointerDirty
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGEnableMouse
; Prepares the mouse for use
@ -89,7 +116,7 @@ WGEnableMouse:
stz WG_MOUSEBG
CALLMOUSE INITMOUSE
bcs WGEnableMouse_Error ; Firmware sets carry if mouse is not available
bcs WGEnableMouse_Error ; Firmware sets carry if mouse is not available
CALLMOUSE CLEARMOUSE
@ -269,7 +296,6 @@ WGFindMouse_done:
; added.
;
WGMouseInterruptHandler:
cld ; ProDOS interrupt handlers must open with this
SAVE_AXY
CALLMOUSE SERVEMOUSE
@ -336,18 +362,13 @@ WGMouseInterruptHandler_button:
lda MOUSTAT,x ; Movement/button status bits are now valid
sta WG_MOUSE_STAT
bit WG_MOUSE_STAT ; Check for rising edge of button state
bit WG_MOUSE_STAT ; Check for rising edge of button state
bpl WGMouseInterruptHandler_intDone
lda WG_MOUSEPOS_X ; Where did we click?
sta PARAM0
lda WG_MOUSEPOS_X ; Store click location for handler
sta WG_PENDINGACTIONCLICKX
lda WG_MOUSEPOS_Y
sta PARAM1
jsr WGViewFromPoint
bmi WGMouseInterruptHandler_intDone
; Button was clicked in a view, so make a note of it for later
sta WG_PENDINGACTIONVIEW
sta WG_PENDINGACTIONCLICKY
WGMouseInterruptHandler_intDone:
pla ; Restore text bank
@ -556,3 +577,61 @@ WG_PRODOS_DEALLOC:
.byte 0 ; To be filled with ProDOS ID number
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Lookup tables
;
; Video memory
TEXTLINES_H:
.byte $04 ;0
.byte $04 ;1
.byte $05 ;2
.byte $05 ;3
.byte $06 ;4
.byte $06 ;5
.byte $07 ;6
.byte $07 ;7
.byte $04 ;8
.byte $04 ;9
.byte $05 ;10
.byte $05 ;11
.byte $06 ;12
.byte $06 ;13
.byte $07 ;14
.byte $07 ;15
.byte $04 ;16
.byte $04 ;17
.byte $05 ;18
.byte $05 ;19
.byte $06 ;20
.byte $06 ;21
.byte $07 ;22
.byte $07 ;23
TEXTLINES_L:
.byte $00 ;0
.byte $80 ;1
.byte $00 ;2
.byte $80 ;3
.byte $00 ;4
.byte $80 ;5
.byte $00 ;6
.byte $80 ;7
.byte $28 ;8
.byte $a8 ;9
.byte $28 ;10
.byte $a8 ;11
.byte $28 ;12
.byte $a8 ;13
.byte $28 ;14
.byte $a8 ;15
.byte $50 ;16
.byte $d0 ;17
.byte $50 ;18
.byte $d0 ;19
.byte $50 ;20
.byte $d0 ;21
.byte $50 ;22
.byte $d0 ;23

View File

@ -78,8 +78,6 @@ WGDesktop_charLoop:
RESTORE_AXY
rts
WGTest:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGPlot

View File

@ -30,3 +30,10 @@ RDVBLBAR = $C019 ; Read bit 7 (active low)
OURCH = $057b ; 80 col cursor position (H)
OURCV = $05fb ; 80 col cursor position (V)
RAMRDOFF = $c002 ; Write (Read from main RAM)
RAMRDON = $c003 ; Write (Read from aux RAM)
TRAMRD = $c013 ; Read bit 7 (state of RAMRD)
RAMWRTOFF = $c004 ; Write (Write to main RAM)
RAMWRTON = $c005 ; Write (Write to aux RAM)
TRAMWRT = $c014 ; Read bit 7 (state of RAMWRT)

View File

@ -125,6 +125,9 @@ WGStoreStr:
sta WG_SCRATCHA
SAVE_AXY
ldx #15 ; Cache the string (and whatever is near it) in a scratch area
jsr cacheParamBlock
ldx #0
ldy #0
@ -139,16 +142,15 @@ WGStoreStr_findEmptyLoop:
bra WGStoreStr_findEmptyLoop
WGStoreStr_noRoom:
lda #0
sta PARAM0
sta PARAM1
stz PARAM0
stz PARAM1
bra WGStoreStr_done
WGStoreStr_copy:
phx ; Remember the start of our string
WGStoreStr_copyLoop:
lda (PARAM0),y
lda WG_AUXPARAM,y
cmp WG_SCRATCHA
beq WGStoreStr_terminate
sta WG_STRINGS,x
@ -172,3 +174,44 @@ WGStoreStr_terminate:
WGStoreStr_done:
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; cacheParamBlock
; Copies a parameter block pointed to by P0/P1 into AUX
; memory.
; X: Number of bytes to copy
;
cacheParamBlock:
pha
SAVE_ZPS
stx SCRATCH0
lda PARAM0
sta A1L
lda PARAM1
sta A1H
clc
lda PARAM0
adc SCRATCH0
sta A2L
lda PARAM1
adc #0
sta A2H
lda #<WG_AUXPARAM
sta A4L
lda #>WG_AUXPARAM
sta A4H
sec
jsr AUXMOVE
RESTORE_ZPS
pla
rts

174
views.s
View File

@ -30,50 +30,40 @@ WG_FEATURE_RT = %01000000
; VH: View Height
;
WGCreateView:
SAVE_AXY
SAVE_AX
ldy #0
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done
ldx #8 ; Copy caller's struct into AUX memory
jsr cacheParamBlock
lda WG_AUXPARAM+0 ; Find our new view record
asl
asl
asl
asl ; Records are 8 bytes wide
tax
iny
lda (PARAM0),y
pha ; Cache style byte for later
iny
lda (PARAM0),y
lda WG_AUXPARAM+2
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
lda WG_AUXPARAM+3
sta WG_VIEWRECORDS+1,x ; Screen Y
iny
lda (PARAM0),y
lda WG_AUXPARAM+4
sta WG_VIEWRECORDS+2,x ; Screen Width
iny
lda (PARAM0),y
lda WG_AUXPARAM+5
sta WG_VIEWRECORDS+3,x ; Screen Height
pla
lda WG_AUXPARAM+1
sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
iny
lda (PARAM0),y
lda WG_AUXPARAM+6
sta WG_VIEWRECORDS+7,x ; View Width
iny
lda (PARAM0),y
lda WG_AUXPARAM+7
sta WG_VIEWRECORDS+8,x ; View Height
stz WG_VIEWRECORDS+9,x ; Initialize state
@ -82,11 +72,11 @@ WGCreateView:
stz WG_VIEWRECORDS+12,x ; Initialize title
stz WG_VIEWRECORDS+13,x
pla
lda WG_AUXPARAM+0
jsr WGSelectView ; Leave this as the active view
WGCreateView_done:
RESTORE_AXY
RESTORE_AX
rts
@ -105,24 +95,23 @@ WGCreateView_done:
; SH: String pointer (MSB)
;
WGCreateCheckbox:
SAVE_AXY
SAVE_AX
SAVE_ZPP
ldy #0
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done
ldx #5 ; Copy caller's struct into AUX memory
jsr cacheParamBlock
lda WG_AUXPARAM+0 ; Find our new view record
asl
asl
asl
asl ; Records are 16 bytes wide
tax
iny
lda (PARAM0),y
lda WG_AUXPARAM+1
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
lda WG_AUXPARAM+2
sta WG_VIEWRECORDS+1,x ; Screen Y
lda #1
@ -141,18 +130,24 @@ WGCreateCheckbox:
stz WG_VIEWRECORDS+10,x ; Initialize callback
stz WG_VIEWRECORDS+11,x
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
iny
lda (PARAM0),y
lda WG_AUXPARAM+3 ; Copy title into aux memory
sta PARAM0
lda WG_AUXPARAM+4
sta PARAM1
lda #0
jsr WGStoreStr
lda PARAM0 ; Store allocated pointer to title
sta WG_VIEWRECORDS+12,x
lda PARAM1
sta WG_VIEWRECORDS+13,x
pla
lda WG_AUXPARAM+0
jsr WGSelectView ; Leave this as the active view
WGCreateCheckbox_done:
RESTORE_AXY
RESTORE_ZPP
RESTORE_AX
rts
@ -173,28 +168,26 @@ WGCreateCheckbox_done:
; SL: Title string pointer (LSB)
; SH: Title string pointer (MSB)
WGCreateButton:
SAVE_AXY
SAVE_AX
SAVE_ZPP
ldy #0
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done
ldx #8 ; Copy caller's struct into AUX memory
jsr cacheParamBlock
lda WG_AUXPARAM+0 ; Find our new view record
asl
asl
asl
asl ; Records are 16 bytes wide
tax
iny
lda (PARAM0),y
lda WG_AUXPARAM+1
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
lda WG_AUXPARAM+2
sta WG_VIEWRECORDS+1,x ; Screen Y
iny
lda (PARAM0),y
lda WG_AUXPARAM+3
sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width
@ -209,25 +202,29 @@ WGCreateButton:
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state
iny
lda (PARAM0),y
lda WG_AUXPARAM+4
sta WG_VIEWRECORDS+10,x ; Callback
iny
lda (PARAM0),y
lda WG_AUXPARAM+5
sta WG_VIEWRECORDS+11,x
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
iny
lda (PARAM0),y
lda WG_AUXPARAM+6 ; Copy title into aux memory
sta PARAM0
lda WG_AUXPARAM+7
sta PARAM1
lda #0
jsr WGStoreStr
lda PARAM0 ; Store allocated pointer to title
sta WG_VIEWRECORDS+12,x
lda PARAM1
sta WG_VIEWRECORDS+13,x
pla
lda WG_AUXPARAM+0
jsr WGSelectView ; Leave this as the active view
WGCreateButton_done:
RESTORE_AXY
RESTORE_ZPP
RESTORE_AX
rts
@ -698,20 +695,19 @@ WGViewFocusAction_toggleCheckbox:
jsr WGPaintView
; Fall through so checkboxes can have callbacks too
; NOTE: Self-modifying code ahead!
WGViewFocusAction_buttonClick:
lda WG_VIEWRECORDS+4,y ; Are we an Applesoft button?
and #VIEW_STYLE_APPLESOFT
bne WGViewFocusAction_buttonClickApplesoft
; Call user's routine in MAIN memory
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
sta XFERH
lda WG_VIEWRECORDS+10,y
sta WGViewFocusAction_userJSR+1
sta XFERL
jsr WGCallback
WGViewFocusAction_userJSR:
jsr WGViewFocusAction_done ; Overwritten with user's function pointer
bra WGViewFocusAction_done
WGViewFocusAction_buttonClickApplesoft:
@ -751,30 +747,43 @@ WGViewFocusAction_knownRTS:
;
WGPendingViewAction:
SAVE_AY
SAVE_ZPP
SAVE_ZPS
lda WG_PENDINGACTIONVIEW
lda WG_PENDINGACTIONCLICKX
bmi WGPendingViewAction_done
sta PARAM0 ; Where did we click?
lda WG_PENDINGACTIONCLICKY
sta PARAM1
jsr WGViewFromPoint
cmp #0
bmi WGPendingViewAction_done
sta SCRATCH0 ; Stash view for later
and #$f ; Select view in question
jsr WGSelectView
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+4,y
and #$f
cmp #VIEW_STYLE_FANCY ; Filter out fancy views with high-nybble of 0
bne WGPendingViewAction_chkCallback ; This prevents unnecessary redraws when clicking
lda WG_PENDINGACTIONVIEW ; in the content area
lda SCRATCH0 ; in the content area
and #$f0
beq WGPendingViewAction_done
WGPendingViewAction_chkCallback:
lda WG_VIEWRECORDS+10,y ; Optimization- only process things that can be clicked
bne WGPendingViewAction_hasCallback
lda WG_VIEWRECORDS+11,y
beq WGPendingViewAction_done
; lda WG_VIEWRECORDS+10,y ; Optimization- only process things that can be clicked
; bne WGPendingViewAction_hasCallback
; lda WG_VIEWRECORDS+11,y
; beq WGPendingViewAction_done
WGPendingViewAction_hasCallback:
lda WG_PENDINGACTIONVIEW
lda SCRATCH0
and #$f0 ; Check for window features
beq WGPendingViewAction_content
@ -794,8 +803,10 @@ WGPendingViewAction_hasCallback:
WGPendingViewAction_done: ; Centralized for branch range
lda #$ff
sta WG_PENDINGACTIONVIEW
sta WG_PENDINGACTIONCLICKX
RESTORE_ZPS
RESTORE_ZPP
RESTORE_AY
rts
@ -826,22 +837,14 @@ WGPendingViewAction_content:
jsr delayShort
jsr WGViewUnfocus
jsr WGPointerDirty ; If we redrew anything, the pointer BG will be stale
; If we redrew anything, the pointer BG will be stale
ldx #WGPointerDirtyDispatch
jsr WeeGUI
bra WGPendingViewAction_done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGPendingView
; Returns the view that is currently pending
; OUT A : Pending view ID, or $ff if none
;
WGPendingView:
lda WG_PENDINGACTIONVIEW
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGViewSetTitle
; Sets the title of the active view
@ -849,6 +852,10 @@ WGPendingView:
; PARAM1: Null-terminated string pointer (MSB)
WGViewSetTitle:
SAVE_AY
SAVE_ZPP
lda #0 ; Copy the string into our aux memory buffer
jsr WGStoreStr
LDY_ACTIVEVIEW
lda PARAM0
@ -857,6 +864,7 @@ WGViewSetTitle:
sta WG_VIEWRECORDS+13,y
WGViewSetTitle_done:
RESTORE_ZPP
RESTORE_AY
rts

View File

@ -14,6 +14,12 @@ CH = $24 ; Cursor X pos
CV = $25 ; Cursor Y pos
BASL = $28 ; Current video memory line
BASH = $29 ; Current video memory line
A1L = $3c ; AUXMOVE source address start LSB
A1H = $3d ; AUXMOVE source address start MSB
A2L = $3e ; AUXMOVE source address end LSB
A2H = $3f ; AUXMOVE source address end MSB
A4L = $42 ; AUXMOVE dest address LSB
A4H = $43 ; AUXMOVE dest address MSB
; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS)
PARAM0 = $06
@ -22,3 +28,8 @@ PARAM2 = $08
PARAM3 = $09
SCRATCH0 = $19
SCRATCH1 = $1a
; Special shared memory location
; Harded coded to here so that mouse driver can share it from main bank
WG_PENDINGACTIONCLICKX = $1b
WG_PENDINGACTIONCLICKY = $1c