mirror of
https://github.com/blondie7575/WeeGUI.git
synced 2024-12-13 15:30:04 +00:00
- Added Pending View, so app run loops can handle mouse actions
- Added XY saving macro - Tightened up view macros a bit - Views can now be found and acted on by the mouse - Mouse rendering now handles missing mouse - Added the concept of "no focus", so that one view doesn't always have to be highlighted - Added View finding by screenspace point
This commit is contained in:
parent
6111a30559
commit
b1cefa96c0
6
gui.s
6
gui.s
@ -54,6 +54,8 @@ main:
|
|||||||
jsr WGEnableMouse
|
jsr WGEnableMouse
|
||||||
|
|
||||||
keyLoop:
|
keyLoop:
|
||||||
|
jsr WGPendingViewAction
|
||||||
|
|
||||||
lda KBD
|
lda KBD
|
||||||
bpl keyLoop
|
bpl keyLoop
|
||||||
sta KBDSTRB
|
sta KBDSTRB
|
||||||
@ -193,6 +195,10 @@ WGInit_clearMemLoop:
|
|||||||
dey
|
dey
|
||||||
bpl WGInit_clearMemLoop
|
bpl WGInit_clearMemLoop
|
||||||
|
|
||||||
|
lda #$ff
|
||||||
|
sta WG_PENDINGACTIONVIEW
|
||||||
|
sta WG_FOCUSVIEW
|
||||||
|
|
||||||
RESTORE_AXY
|
RESTORE_AXY
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
BIN
guidemo.dsk
BIN
guidemo.dsk
Binary file not shown.
30
macros.s
30
macros.s
@ -60,6 +60,18 @@
|
|||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
.macro SAVE_XY ; Saves X and Y index
|
||||||
|
phx
|
||||||
|
phy
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
.macro RESTORE_XY ; Restores X and Y index
|
||||||
|
ply
|
||||||
|
plx
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
.macro SAVE_ZPP ; Saves Zero Page locations we use for parameters
|
.macro SAVE_ZPP ; Saves Zero Page locations we use for parameters
|
||||||
lda PARAM0
|
lda PARAM0
|
||||||
pha
|
pha
|
||||||
@ -134,9 +146,9 @@
|
|||||||
; Rendering macros
|
; Rendering macros
|
||||||
;
|
;
|
||||||
|
|
||||||
.macro LDY_ACTIVEVIEW
|
|
||||||
lda WG_ACTIVEVIEW ; Find our new view record
|
.macro LDY_AVIEW
|
||||||
asl
|
asl ; Find our new view record
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl ; Records are 16 bytes wide
|
asl ; Records are 16 bytes wide
|
||||||
@ -144,6 +156,12 @@
|
|||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
.macro LDY_ACTIVEVIEW
|
||||||
|
lda WG_ACTIVEVIEW ; Find our new view record
|
||||||
|
LDY_AVIEW
|
||||||
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
.macro LDX_ACTIVEVIEW
|
.macro LDX_ACTIVEVIEW
|
||||||
lda WG_ACTIVEVIEW ; Find our new view record
|
lda WG_ACTIVEVIEW ; Find our new view record
|
||||||
asl
|
asl
|
||||||
@ -156,11 +174,7 @@
|
|||||||
|
|
||||||
.macro LDY_FOCUSVIEW
|
.macro LDY_FOCUSVIEW
|
||||||
lda WG_FOCUSVIEW ; Find our new view record
|
lda WG_FOCUSVIEW ; Find our new view record
|
||||||
asl
|
LDY_AVIEW
|
||||||
asl
|
|
||||||
asl
|
|
||||||
asl ; Records are 16 bytes wide
|
|
||||||
tay
|
|
||||||
.endmacro
|
.endmacro
|
||||||
|
|
||||||
|
|
||||||
|
3
memory.s
3
memory.s
@ -54,6 +54,9 @@ WG_ACTIVEVIEW:
|
|||||||
WG_FOCUSVIEW:
|
WG_FOCUSVIEW:
|
||||||
.byte 0
|
.byte 0
|
||||||
|
|
||||||
|
WG_PENDINGACTIONVIEW:
|
||||||
|
.byte 0
|
||||||
|
|
||||||
WG_VIEWCLIP:
|
WG_VIEWCLIP:
|
||||||
; X0,Y0,X1,Y1. Edges of current window, in view space, right span
|
; X0,Y0,X1,Y1. Edges of current window, in view space, right span
|
||||||
.byte 0,0,0,0,0
|
.byte 0,0,0,0,0
|
||||||
|
13
mouse.s
13
mouse.s
@ -323,7 +323,15 @@ WGMouseInterruptHandler:
|
|||||||
bne WGMouseInterruptHandler_intDone
|
bne WGMouseInterruptHandler_intDone
|
||||||
|
|
||||||
WGMouseInterruptHandler_button:
|
WGMouseInterruptHandler_button:
|
||||||
|
lda WG_MOUSEPOS_X
|
||||||
|
sta PARAM0
|
||||||
|
lda WG_MOUSEPOS_Y
|
||||||
|
sta PARAM1
|
||||||
|
jsr WGViewFromPoint
|
||||||
|
bmi WGMouseInterruptHandler_intDone
|
||||||
|
|
||||||
|
; Button was clicked in a view, so make a note of it
|
||||||
|
sta WG_PENDINGACTIONVIEW
|
||||||
|
|
||||||
WGMouseInterruptHandler_intDone:
|
WGMouseInterruptHandler_intDone:
|
||||||
jsr WGDrawPointer ; Redraw the pointer
|
jsr WGDrawPointer ; Redraw the pointer
|
||||||
@ -348,6 +356,8 @@ WGMouseInterruptHandler_disregard:
|
|||||||
WGUndrawPointer:
|
WGUndrawPointer:
|
||||||
SAVE_AXY
|
SAVE_AXY
|
||||||
|
|
||||||
|
lda WG_MOUSEACTIVE
|
||||||
|
beq WGUndrawPointer_done ; Mouse not enabled
|
||||||
lda WG_MOUSEBG
|
lda WG_MOUSEBG
|
||||||
beq WGUndrawPointer_done ; Mouse pointer has never rendered
|
beq WGUndrawPointer_done ; Mouse pointer has never rendered
|
||||||
|
|
||||||
@ -403,6 +413,9 @@ WGUndrawPointer_done:
|
|||||||
WGDrawPointer:
|
WGDrawPointer:
|
||||||
SAVE_AXY
|
SAVE_AXY
|
||||||
|
|
||||||
|
lda WG_MOUSEACTIVE
|
||||||
|
beq WGDrawPointer_done ; Mouse not enabled
|
||||||
|
|
||||||
ldx WG_MOUSEPOS_Y
|
ldx WG_MOUSEPOS_Y
|
||||||
cpx #24
|
cpx #24
|
||||||
bcs WGDrawPointer_done
|
bcs WGDrawPointer_done
|
||||||
|
137
views.s
137
views.s
@ -627,6 +627,9 @@ WGViewFocus:
|
|||||||
lda WG_ACTIVEVIEW ; Stash current selection
|
lda WG_ACTIVEVIEW ; Stash current selection
|
||||||
pha
|
pha
|
||||||
|
|
||||||
|
lda WG_FOCUSVIEW
|
||||||
|
bmi WGViewFocus_noCurrent
|
||||||
|
|
||||||
LDY_FOCUSVIEW ; Unfocus current view
|
LDY_FOCUSVIEW ; Unfocus current view
|
||||||
lda WG_VIEWRECORDS+9,y
|
lda WG_VIEWRECORDS+9,y
|
||||||
and #%01111111
|
and #%01111111
|
||||||
@ -636,6 +639,7 @@ WGViewFocus:
|
|||||||
jsr WGSelectView
|
jsr WGSelectView
|
||||||
jsr WGPaintView
|
jsr WGPaintView
|
||||||
|
|
||||||
|
WGViewFocus_noCurrent:
|
||||||
pla
|
pla
|
||||||
sta WG_FOCUSVIEW ; Focus on our original selection
|
sta WG_FOCUSVIEW ; Focus on our original selection
|
||||||
jsr WGSelectView
|
jsr WGSelectView
|
||||||
@ -652,6 +656,34 @@ WGViewFocus:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; WGViewUnfocus
|
||||||
|
; Unfocuses all views
|
||||||
|
; Side effects: Changes selected view, repaints some views
|
||||||
|
;
|
||||||
|
WGViewUnfocus:
|
||||||
|
pha
|
||||||
|
|
||||||
|
lda WG_FOCUSVIEW
|
||||||
|
bmi WGViewUnfocus_done
|
||||||
|
|
||||||
|
LDY_FOCUSVIEW ; Unfocus current view
|
||||||
|
lda WG_VIEWRECORDS+9,y
|
||||||
|
and #%01111111
|
||||||
|
sta WG_VIEWRECORDS+9,y
|
||||||
|
|
||||||
|
lda WG_FOCUSVIEW
|
||||||
|
jsr WGSelectView
|
||||||
|
jsr WGPaintView
|
||||||
|
|
||||||
|
lda #$ff
|
||||||
|
sta WG_FOCUSVIEW
|
||||||
|
|
||||||
|
WGViewUnfocus_done:
|
||||||
|
pla
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; WGViewFocusNext
|
; WGViewFocusNext
|
||||||
; Shifts focus to the next view
|
; Shifts focus to the next view
|
||||||
@ -660,6 +692,9 @@ WGViewFocus:
|
|||||||
WGViewFocusNext:
|
WGViewFocusNext:
|
||||||
SAVE_AY
|
SAVE_AY
|
||||||
|
|
||||||
|
lda WG_FOCUSVIEW
|
||||||
|
bmi WGViewFocusNext_loop
|
||||||
|
|
||||||
LDY_FOCUSVIEW ; Unfocus current view
|
LDY_FOCUSVIEW ; Unfocus current view
|
||||||
lda WG_VIEWRECORDS+9,y
|
lda WG_VIEWRECORDS+9,y
|
||||||
and #%01111111
|
and #%01111111
|
||||||
@ -706,6 +741,9 @@ WGViewFocusNext_focus:
|
|||||||
WGViewFocusPrev:
|
WGViewFocusPrev:
|
||||||
SAVE_AXY
|
SAVE_AXY
|
||||||
|
|
||||||
|
lda WG_FOCUSVIEW
|
||||||
|
bmi WGViewFocusPrev_hadNone
|
||||||
|
|
||||||
LDY_FOCUSVIEW ; Unfocus current view
|
LDY_FOCUSVIEW ; Unfocus current view
|
||||||
lda WG_VIEWRECORDS+9,y
|
lda WG_VIEWRECORDS+9,y
|
||||||
and #%01111111
|
and #%01111111
|
||||||
@ -719,6 +757,7 @@ WGViewFocusPrev_loop:
|
|||||||
dec WG_FOCUSVIEW ; Decrement and wrap
|
dec WG_FOCUSVIEW ; Decrement and wrap
|
||||||
bpl WGViewFocusPrev_wantFocus
|
bpl WGViewFocusPrev_wantFocus
|
||||||
|
|
||||||
|
WGViewFocusPrev_hadNone:
|
||||||
ldx #$f
|
ldx #$f
|
||||||
WGViewFocusPrev_findEndLoop:
|
WGViewFocusPrev_findEndLoop:
|
||||||
stx WG_FOCUSVIEW
|
stx WG_FOCUSVIEW
|
||||||
@ -760,6 +799,9 @@ WGViewFocusPrev_focus:
|
|||||||
WGViewFocusAction:
|
WGViewFocusAction:
|
||||||
SAVE_AY
|
SAVE_AY
|
||||||
|
|
||||||
|
lda WG_FOCUSVIEW
|
||||||
|
bmi WGViewFocusAction_done
|
||||||
|
|
||||||
LDY_FOCUSVIEW
|
LDY_FOCUSVIEW
|
||||||
lda WG_VIEWRECORDS+4,y ; What kind of view is it?
|
lda WG_VIEWRECORDS+4,y ; What kind of view is it?
|
||||||
and #$f ; Mask off flag bits
|
and #$f ; Mask off flag bits
|
||||||
@ -824,6 +866,46 @@ WGViewFocusAction_knownRTS:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; WGPendingViewAction
|
||||||
|
; Performs the action of the pending view, if any
|
||||||
|
; OUT V : Set if the caller should perform an Applesoft GOSUB
|
||||||
|
; Side effects: Changes selected view, Repaints some views
|
||||||
|
;
|
||||||
|
WGPendingViewAction:
|
||||||
|
pha
|
||||||
|
|
||||||
|
lda WG_PENDINGACTIONVIEW
|
||||||
|
bmi WGPendingViewAction_done
|
||||||
|
|
||||||
|
jsr WGUndrawPointer
|
||||||
|
|
||||||
|
jsr WGSelectView
|
||||||
|
jsr WGViewFocus
|
||||||
|
jsr WGViewFocusAction
|
||||||
|
jsr WGViewUnfocus
|
||||||
|
|
||||||
|
jsr WGDrawPointer ; Leave pointer hidden, but ensure
|
||||||
|
jsr WGUndrawPointer ; Background is correct when it moves next
|
||||||
|
|
||||||
|
lda #$ff
|
||||||
|
sta WG_PENDINGACTIONVIEW
|
||||||
|
|
||||||
|
WGPendingViewAction_done:
|
||||||
|
pla
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; WGPendingView
|
||||||
|
; Returns the view that is currently pending
|
||||||
|
; OUT A : Pending view ID, or $ff if none
|
||||||
|
;
|
||||||
|
WGPendingView:
|
||||||
|
lda WG_PENDINGACTIONVIEW
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; WGViewSetTitle
|
; WGViewSetTitle
|
||||||
; Sets the title of the active view
|
; Sets the title of the active view
|
||||||
@ -1114,6 +1196,61 @@ WGViewPaintAll_done:
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
; WGViewFromPoint
|
||||||
|
; Finds a view containing the given point
|
||||||
|
; PARAM0:X
|
||||||
|
; PARAM1:Y
|
||||||
|
; OUT A: View ID (or $ff if no match)
|
||||||
|
WGViewFromPoint:
|
||||||
|
SAVE_XY
|
||||||
|
|
||||||
|
ldx #$f ; Scan views backwards, because controls are usually at the end
|
||||||
|
|
||||||
|
WGViewFromPoint_loop:
|
||||||
|
txa
|
||||||
|
LDY_AVIEW
|
||||||
|
|
||||||
|
lda WG_VIEWRECORDS+2,y
|
||||||
|
beq WGViewFromPoint_loopNext ; Not an allocated view
|
||||||
|
|
||||||
|
lda PARAM0 ; Check left edge
|
||||||
|
cmp WG_VIEWRECORDS+0,y
|
||||||
|
bcc WGViewFromPoint_loopNext
|
||||||
|
|
||||||
|
lda PARAM1 ; Check top edge
|
||||||
|
cmp WG_VIEWRECORDS+1,y
|
||||||
|
bcc WGViewFromPoint_loopNext
|
||||||
|
|
||||||
|
lda WG_VIEWRECORDS+0,y ; Check right edge
|
||||||
|
clc
|
||||||
|
adc WG_VIEWRECORDS+2,y
|
||||||
|
cmp PARAM0
|
||||||
|
bcc WGViewFromPoint_loopNext
|
||||||
|
beq WGViewFromPoint_loopNext
|
||||||
|
|
||||||
|
lda WG_VIEWRECORDS+1,y ; Check bottom edge
|
||||||
|
clc
|
||||||
|
adc WG_VIEWRECORDS+3,y
|
||||||
|
cmp PARAM1
|
||||||
|
bcc WGViewFromPoint_loopNext
|
||||||
|
beq WGViewFromPoint_loopNext
|
||||||
|
|
||||||
|
txa ; Found a match
|
||||||
|
RESTORE_XY
|
||||||
|
rts
|
||||||
|
|
||||||
|
WGViewFromPoint_loopNext:
|
||||||
|
dex
|
||||||
|
bmi WGViewFromPoint_noMatch
|
||||||
|
bra WGViewFromPoint_loop
|
||||||
|
|
||||||
|
WGViewFromPoint_noMatch:
|
||||||
|
lda #$ff
|
||||||
|
RESTORE_XY
|
||||||
|
rts
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
; cacheClipPlanes
|
; cacheClipPlanes
|
||||||
; Internal routine to cache the clipping planes for the view
|
; Internal routine to cache the clipping planes for the view
|
||||||
|
Loading…
Reference in New Issue
Block a user