mirror of
https://github.com/blondie7575/WeeGUI.git
synced 2025-01-25 06:31:26 +00:00
- Added reverse focus selection
- Added support for button callbacks
This commit is contained in:
parent
25e24282b3
commit
d9aaa8144a
16
gui.s
16
gui.s
@ -50,6 +50,12 @@ main:
|
||||
sta PARAM1
|
||||
jsr WGViewSetTitle
|
||||
|
||||
lda #<testCallback
|
||||
sta PARAM0
|
||||
lda #>testCallback
|
||||
sta PARAM1
|
||||
jsr WGViewSetAction
|
||||
|
||||
lda #<testButton2
|
||||
sta PARAM0
|
||||
lda #>testButton2
|
||||
@ -133,6 +139,8 @@ keyLoop:
|
||||
and #%01111111
|
||||
cmp #9
|
||||
beq keyLoop_focusNext
|
||||
cmp #27
|
||||
beq keyLoop_focusPrev
|
||||
cmp #13
|
||||
beq keyLoop_toggle
|
||||
cmp #32
|
||||
@ -144,6 +152,10 @@ keyLoop_focusNext:
|
||||
jsr WGViewFocusNext
|
||||
jmp keyLoop
|
||||
|
||||
keyLoop_focusPrev:
|
||||
jsr WGViewFocusPrev
|
||||
jmp keyLoop
|
||||
|
||||
keyLoop_toggle:
|
||||
jsr WGViewFocusAction
|
||||
jmp keyLoop
|
||||
@ -151,6 +163,10 @@ keyLoop_toggle:
|
||||
rts ; This seems to work for returning to BASIC.SYSTEM, but I don't think it's right
|
||||
|
||||
|
||||
testCallback:
|
||||
jsr $ff3a
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGInit
|
||||
|
BIN
guidemo.dsk
BIN
guidemo.dsk
Binary file not shown.
78
views.s
78
views.s
@ -524,6 +524,51 @@ WGViewFocusNext_focus:
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGViewFocusPrev
|
||||
; Shifts focus to the prev view
|
||||
; Side effects: Changes selected view, repaints some views
|
||||
;
|
||||
WGViewFocusPrev:
|
||||
SAVE_AXY
|
||||
|
||||
LDY_FOCUSVIEW ; Unfocus current view
|
||||
lda WG_VIEWRECORDS+9,y
|
||||
and #%01111111
|
||||
sta WG_VIEWRECORDS+9,y
|
||||
|
||||
lda WG_FOCUSVIEW
|
||||
jsr WGSelectView
|
||||
jsr WGPaintView
|
||||
|
||||
dec WG_FOCUSVIEW ; Decrement and wrap
|
||||
bpl WGViewFocusPrev_focus
|
||||
|
||||
ldx #$f
|
||||
WGViewFocusPrev_findEndLoop:
|
||||
stx WG_FOCUSVIEW
|
||||
LDY_FOCUSVIEW
|
||||
lda WG_VIEWRECORDS+2,y
|
||||
bne WGViewFocusPrev_focus
|
||||
dex
|
||||
bra WGViewFocusPrev_findEndLoop
|
||||
|
||||
WGViewFocusPrev_focus:
|
||||
lda WG_FOCUSVIEW
|
||||
jsr WGSelectView
|
||||
|
||||
LDY_FOCUSVIEW
|
||||
|
||||
lda WG_VIEWRECORDS+9,y
|
||||
ora #%10000000
|
||||
sta WG_VIEWRECORDS+9,y
|
||||
|
||||
jsr WGPaintView
|
||||
|
||||
RESTORE_AXY
|
||||
rts
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGViewFocusAction
|
||||
; Performs the action of the focused view
|
||||
@ -543,17 +588,28 @@ WGViewFocusAction:
|
||||
bra WGViewFocusAction_done
|
||||
|
||||
WGViewFocusAction_toggleCheckbox:
|
||||
lda WG_VIEWRECORDS+9,y
|
||||
lda WG_VIEWRECORDS+9,y ; Change the checkbox's state and redraw
|
||||
eor #%00000001
|
||||
sta WG_VIEWRECORDS+9,y
|
||||
lda WG_FOCUSVIEW
|
||||
jsr WGSelectView
|
||||
jsr WGPaintView
|
||||
; Fall through so checkboxes can have callbacks too
|
||||
|
||||
; NOTE: Self-modifying code ahead!
|
||||
WGViewFocusAction_buttonClick:
|
||||
lda WG_VIEWRECORDS+10,y ; Do we have a callback?
|
||||
beq WGViewFocusAction_done
|
||||
sta WGViewFocusAction_userJSR+2 ; Modify code below so we can JSR to user's code
|
||||
lda WG_VIEWRECORDS+11,y
|
||||
sta WGViewFocusAction_userJSR+1
|
||||
|
||||
WGViewFocusAction_userJSR:
|
||||
jsr WGViewFocusAction_placeholder ; Overwritten with user's function pointer
|
||||
|
||||
WGViewFocusAction_done:
|
||||
RESTORE_AY
|
||||
WGViewFocusAction_placeholder:
|
||||
rts
|
||||
|
||||
|
||||
@ -577,6 +633,26 @@ WGViewSetTitle_done:
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGViewSetAction
|
||||
; Sets the callback action of the active view
|
||||
; PARAM0: Null-terminated function pointer (LSB)
|
||||
; PARAM1: Null-terminated function pointer (MSB)
|
||||
WGViewSetAction:
|
||||
SAVE_AY
|
||||
|
||||
LDY_ACTIVEVIEW
|
||||
lda PARAM0
|
||||
sta WG_VIEWRECORDS+11,y
|
||||
lda PARAM1
|
||||
sta WG_VIEWRECORDS+10,y
|
||||
|
||||
WGViewSetAction_done:
|
||||
RESTORE_AY
|
||||
rts
|
||||
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
; WGSetCursor
|
||||
; Sets the current local view cursor
|
||||
|
Loading…
x
Reference in New Issue
Block a user