- Added view selection and focus states

- Added some API for focus selection
- Fixed a bug in selected view table lookup
- View creation now selects new view
- Refactored and fixed bugs in checkbox rendering
- Checkboxes can now be toggled
- Basic API for view actions
- Convenience routine for painting all views
This commit is contained in:
Quinn Dunki 2014-09-05 20:32:16 -07:00
parent 9924d41080
commit 25e24282b3
5 changed files with 245 additions and 51 deletions

99
gui.s
View File

@ -19,7 +19,8 @@
; Main
main:
jsr begin80cols
jsr WGInit
jsr WG80
;jmp tortureTestPrint
;jmp tortureTestRects
@ -29,18 +30,39 @@ main:
sta PARAM0
lda #>testView
sta PARAM1
jsr WGCreateView
lda #<testCheck
sta PARAM0
lda #>testCheck
sta PARAM1
jsr WGCreateCheckbox
lda #<testButton1
sta PARAM0
lda #>testButton1
sta PARAM1
jsr WGCreateButton
lda #0
jsr WGSelectView
lda #<testTitle
lda #<testTitle1
sta PARAM0
lda #>testTitle
lda #>testTitle1
sta PARAM1
jsr WGViewSetTitle
jsr WGPaintView
lda #<testButton2
sta PARAM0
lda #>testButton2
sta PARAM1
jsr WGCreateButton
lda #<testTitle2
sta PARAM0
lda #>testTitle2
sta PARAM1
jsr WGViewSetTitle
jsr WGViewPaintAll
; ldx #5
; ldy #0
@ -103,18 +125,50 @@ main:
; jmp tortureTestRects
loop:
; lda #'Q' + $80
; jsr COUT
jmp loop
keyLoop:
lda KBD
bpl keyLoop
sta KBDSTRB
and #%01111111
cmp #9
beq keyLoop_focusNext
cmp #13
beq keyLoop_toggle
cmp #32
beq keyLoop_toggle
jmp keyLoop
keyLoop_focusNext:
jsr WGViewFocusNext
jmp keyLoop
keyLoop_toggle:
jsr WGViewFocusAction
jmp keyLoop
rts ; This seems to work for returning to BASIC.SYSTEM, but I don't think it's right
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; begin80cols
; WGInit
; Initialization. Should be called once at app startup
WGInit:
pha
lda #0
sta WG_FOCUSVIEW
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WG80
; Enables 80 column mode (and enhanced video firmware)
begin80cols:
WG80:
lda #$a0
jsr $c300
SETSWITCH TEXTON
@ -158,16 +212,25 @@ read80ColSwitch_40:
testView:
; .byte "0007033e13207e" ; 0, 7,3,62,19,126,126
; .byte "00230a"
.byte "00230a0f"
.byte "0007033e133e7e" ; 0, 7,3,62,19,62,126
testCheck:
.byte "011004"
testButton1:
.byte "02230a0f"
testButton2:
.byte "03230d0f"
testStr:
; .byte "This is a test of the emergency broadcast system.",0; If this had been a real emergency, you would be dead now.",0 ; 107 chars
.byte "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ !",34,"#$%&'()*+,-./0123456789:;<=>?`abcdefghijklmno",0
testStr2:
.byte "pqrstuvwxyz{|}~",$ff,0
testTitle:
testTitle1:
.byte "Okay",0
testTitle2:
.byte "Cancel",0

Binary file not shown.

View File

@ -106,11 +106,6 @@
.macro LDY_ACTIVEVIEW
lda WG_ACTIVEVIEW ; Find our new view record
and #%00001111
asl
asl
asl
asl
asl
asl
asl
@ -121,11 +116,6 @@
.macro LDX_ACTIVEVIEW
lda WG_ACTIVEVIEW ; Find our new view record
and #%00001111
asl
asl
asl
asl
asl
asl
asl
@ -134,6 +124,16 @@
.endmacro
.macro LDY_FOCUSVIEW
lda WG_FOCUSVIEW ; Find our new view record
asl
asl
asl
asl ; Records are 16 bytes wide
tay
.endmacro
.macro VBL_SYNC ; Synchronize with vertical blanking
lda #$80
macroWaitVBLToFinish:

View File

@ -39,6 +39,7 @@ VIEW_STYLE_BUTTON = $03
COUT = $fded
BASCALC = $fbc1
PRBYTE = $fdda
RDKEY = $fd0c
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -57,6 +58,9 @@ WG_LOCALCURSORY:
WG_ACTIVEVIEW:
.byte 0
WG_FOCUSVIEW:
.byte 0
WG_VIEWCLIP:
; X0,Y0,X1,Y1. Edges of current window, in view space, right span
.byte 0,0,0,0,0

173
views.s
View File

@ -10,7 +10,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateView
; Creates a new view
; Creates and selects a new view
; PARAM0: Pointer to ASCII configuration string (LSB)
; PARAM1: Pointer to ASCII configuration string (MSB)
;
@ -32,6 +32,7 @@ WGCreateView:
pha
and #%00001111 ; Find our new view record
jsr WGSelectView
asl
asl
asl
@ -104,10 +105,11 @@ WGCreateCheckbox:
jsr scanHex8
and #%00001111 ; Find our new view record
jsr WGSelectView
asl
asl
asl
asl ; Records are 8 bytes wide
asl ; Records are 16 bytes wide
tax
jsr scanHex8
@ -173,10 +175,11 @@ WGCreateButton:
jsr scanHex8
and #%00001111 ; Find our new view record
jsr WGSelectView
asl
asl
asl
asl ; Records are 8 bytes wide
asl ; Records are 16 bytes wide
tax
jsr scanHex8
@ -241,6 +244,7 @@ WGPaintView:
SAVE_ZPS
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+4,y ; Cache style information
sta SCRATCH0
@ -263,24 +267,7 @@ WGPaintView:
bra WGPaintView_done
WGPaintView_check:
lda WG_VIEWRECORDS+9,y ; Render checkbox state
beq WGPaintView_done
lda WG_VIEWRECORDS+0,y
sta WG_CURSORX
lda WG_VIEWRECORDS+1,y
sta WG_CURSORY
lda WG_VIEWRECORDS+9,y
and #$80
bne WGPaintView_checkSelected
lda #'D'
bra WGPaintView_checkPlot
WGPaintView_checkSelected:
lda #'E'
WGPaintView_checkPlot:
jsr WGPlot
jsr paintCheck
bra WGPaintView_done
WGPaintView_button:
@ -293,6 +280,48 @@ WGPaintView_done:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; paintCheck
; Paints the contents of a checkbox
; Y: Index into view records of checkbox to paint
; Side effects: Clobbers A, S0
paintCheck:
lda WG_VIEWRECORDS+0,y ; Position cursor
sta WG_CURSORX
lda WG_VIEWRECORDS+1,y
sta WG_CURSORY
lda WG_VIEWRECORDS+9,y ; Determine our visual state
and #$80
bne paintCheck_selected
lda WG_VIEWRECORDS+9,y
and #$01
beq paintCheck_unselectedUnchecked
lda #'D'
bra paintCheck_plot
paintCheck_unselectedUnchecked:
lda #' '+$80
bra paintCheck_plot
paintCheck_selected:
lda WG_VIEWRECORDS+9,y
and #$01
beq paintCheck_selectedUnchecked
lda #'E'
bra paintCheck_plot
paintCheck_selectedUnchecked:
lda #' '
paintCheck_plot: ; Paint our state
jsr WGPlot
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; paintButton
; Paints the contents of a button
@ -442,8 +471,8 @@ WGEraseViewContents_done:
; A: ID
;
WGSelectView:
SAVE_AXY
sta WG_ACTIVEVIEW
pha
; Initialize cursor to local origin
lda #0
@ -453,7 +482,78 @@ WGSelectView:
jsr cacheClipPlanes ; View changed, so clipping cache is stale
WGSelectView_done:
RESTORE_AXY
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGViewFocusNext
; Shifts focus to the next view
; Side effects: Changes selected view, repaints some views
;
WGViewFocusNext:
SAVE_AY
LDY_FOCUSVIEW ; Unfocus current view
lda WG_VIEWRECORDS+9,y
and #%01111111
sta WG_VIEWRECORDS+9,y
lda WG_FOCUSVIEW
jsr WGSelectView
jsr WGPaintView
inc WG_FOCUSVIEW ; Increment and wrap
LDY_FOCUSVIEW
lda WG_VIEWRECORDS+2,y
bne WGViewFocusNext_focus
lda #0
sta WG_FOCUSVIEW
WGViewFocusNext_focus:
lda WG_FOCUSVIEW
jsr WGSelectView
lda WG_VIEWRECORDS+9,y
ora #%10000000
sta WG_VIEWRECORDS+9,y
jsr WGPaintView
RESTORE_AY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGViewFocusAction
; Performs the action of the focused view
; Side effects: Changes selected view, Repaints some views
;
WGViewFocusAction:
SAVE_AY
LDY_FOCUSVIEW
lda WG_VIEWRECORDS+4,y ; What kind of view is it?
cmp #VIEW_STYLE_CHECK
beq WGViewFocusAction_toggleCheckbox
cmp #VIEW_STYLE_BUTTON
beq WGViewFocusAction_buttonClick
bra WGViewFocusAction_done
WGViewFocusAction_toggleCheckbox:
lda WG_VIEWRECORDS+9,y
eor #%00000001
sta WG_VIEWRECORDS+9,y
lda WG_FOCUSVIEW
jsr WGSelectView
jsr WGPaintView
WGViewFocusAction_buttonClick:
WGViewFocusAction_done:
RESTORE_AY
rts
@ -587,6 +687,33 @@ WGScrollY_done:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGViewPaintAll
; Repaints all views
; Side effects: Changes selected view
;
WGViewPaintAll:
SAVE_AXY
ldx #0
WGViewPaintAll_loop:
txa
jsr WGSelectView
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+2,y ; Last view?
beq WGViewPaintAll_done
jsr WGPaintView
inx
bra WGViewPaintAll_loop
WGViewPaintAll_done:
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; cacheClipPlanes
; Internal routine to cache the clipping planes for the view