2014-08-29 12:19:19 -07:00
|
|
|
;
|
|
|
|
; views.s
|
|
|
|
; Management routines for GUI views
|
|
|
|
;
|
|
|
|
; Created by Quinn Dunki on 8/15/14.
|
|
|
|
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGCreateView
|
2014-09-05 20:32:16 -07:00
|
|
|
; Creates and selects a new view
|
2014-09-16 08:41:48 -07:00
|
|
|
; PARAM0: Pointer to configuration struct (LSB)
|
|
|
|
; PARAM1: Pointer to configuration struct (MSB)
|
2014-08-29 12:19:19 -07:00
|
|
|
;
|
2014-09-16 08:41:48 -07:00
|
|
|
; Configuration struct:
|
2014-09-16 14:04:05 -07:00
|
|
|
; ID: View ID (0-f)
|
|
|
|
; ST: Style
|
2014-08-29 12:19:19 -07:00
|
|
|
; XX: Screen X origin
|
|
|
|
; YY: Screen Y origin
|
|
|
|
; SW: Screen width
|
|
|
|
; SH: Screen height
|
|
|
|
; VW: View Width
|
|
|
|
; VH: View Height
|
|
|
|
;
|
|
|
|
WGCreateView:
|
|
|
|
SAVE_AXY
|
|
|
|
SAVE_ZPS
|
2014-09-11 14:04:30 -07:00
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
ldy #0
|
2014-09-16 18:01:08 -07:00
|
|
|
lda (PARAM0),y ; Find our new view record
|
|
|
|
pha ; Cache view ID so we can select when we're done
|
2014-08-29 12:19:19 -07:00
|
|
|
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl ; Records are 8 bytes wide
|
|
|
|
tax
|
|
|
|
|
2014-09-16 14:04:05 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
|
|
|
pha ; Cache style byte for later
|
2014-08-29 12:19:19 -07:00
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen X
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen Y
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen Width
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen Height
|
|
|
|
inx
|
|
|
|
|
|
|
|
pla
|
|
|
|
sta WG_VIEWRECORDS,x ; Style
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #0 ; Initialize scrolling
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; View Width
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; View Height
|
|
|
|
|
2014-09-16 14:04:05 -07:00
|
|
|
lda #0
|
|
|
|
inx ; Initialize state
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize callback
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize title
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
|
2014-09-16 18:01:08 -07:00
|
|
|
pla
|
|
|
|
jsr WGSelectView ; Leave this as the active view
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
WGCreateView_done:
|
|
|
|
RESTORE_ZPS
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGCreateCheckbox
|
|
|
|
; Creates a new checkbox
|
2014-09-16 08:41:48 -07:00
|
|
|
; PARAM0: Pointer to configuration struct (LSB)
|
|
|
|
; PARAM1: Pointer to configuration struct (MSB)
|
2014-09-05 16:31:33 -07:00
|
|
|
;
|
2014-09-16 08:41:48 -07:00
|
|
|
; Configuration struct:
|
2014-09-16 14:04:05 -07:00
|
|
|
; ID: View ID (0-f)
|
2014-09-05 16:31:33 -07:00
|
|
|
; XX: Screen X origin
|
|
|
|
; YY: Screen Y origin
|
2014-09-21 13:46:41 -07:00
|
|
|
; SL: String pointer (LSB)
|
|
|
|
; SH: String pointer (MSB)
|
2014-09-05 16:31:33 -07:00
|
|
|
;
|
|
|
|
WGCreateCheckbox:
|
|
|
|
SAVE_AXY
|
|
|
|
SAVE_ZPS
|
|
|
|
|
|
|
|
ldy #0
|
2014-09-16 18:01:08 -07:00
|
|
|
lda (PARAM0),y ; Find our new view record
|
|
|
|
pha ; Cache view ID so we can select when we're done
|
2014-09-05 16:31:33 -07:00
|
|
|
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2014-09-05 20:32:16 -07:00
|
|
|
asl ; Records are 16 bytes wide
|
2014-09-05 16:31:33 -07:00
|
|
|
tax
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen X
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen Y
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #1
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize screen width
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize screen height
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #VIEW_STYLE_CHECK
|
|
|
|
sta WG_VIEWRECORDS,x ; Style
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #0 ; Initialize scrolling
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize view width
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize view height
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #%00000000 ; Initialize state
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize callback
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x
|
2014-09-21 13:46:41 -07:00
|
|
|
inx
|
|
|
|
|
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
|
|
|
sta WG_VIEWRECORDS,x ; Title
|
|
|
|
inx
|
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
2014-09-05 16:31:33 -07:00
|
|
|
|
2014-09-16 18:01:08 -07:00
|
|
|
pla
|
|
|
|
jsr WGSelectView ; Leave this as the active view
|
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
WGCreateCheckbox_done:
|
|
|
|
RESTORE_ZPS
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGCreateButton
|
|
|
|
; Creates a new button
|
2014-09-16 08:41:48 -07:00
|
|
|
; PARAM0: Pointer to configuration struct (LSB)
|
|
|
|
; PARAM1: Pointer to configuration struct (MSB)
|
2014-09-05 16:31:33 -07:00
|
|
|
;
|
2014-09-16 08:41:48 -07:00
|
|
|
; Configuration struct:
|
2014-09-16 14:04:05 -07:00
|
|
|
; ID: View ID (0-f)
|
2014-09-05 16:31:33 -07:00
|
|
|
; XX: Screen X origin
|
|
|
|
; YY: Screen Y origin
|
|
|
|
; BW: Button width
|
2014-09-20 18:20:44 -07:00
|
|
|
; PL: Action callback (LSB)
|
|
|
|
; PH: Action callback (MSB)
|
2014-09-21 13:46:41 -07:00
|
|
|
; SL: Title string pointer (LSB)
|
|
|
|
; SH: Title string pointer (MSB)
|
2014-09-05 16:31:33 -07:00
|
|
|
WGCreateButton:
|
|
|
|
SAVE_AXY
|
|
|
|
SAVE_ZPS
|
|
|
|
|
|
|
|
ldy #0
|
2014-09-16 18:01:08 -07:00
|
|
|
lda (PARAM0),y ; Find our new view record
|
|
|
|
pha ; Cache view ID so we can select when we're done
|
2014-09-05 16:31:33 -07:00
|
|
|
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2014-09-05 20:32:16 -07:00
|
|
|
asl ; Records are 16 bytes wide
|
2014-09-05 16:31:33 -07:00
|
|
|
tax
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen X
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen Y
|
|
|
|
inx
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_VIEWRECORDS,x ; Screen width
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #1
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize screen height
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #VIEW_STYLE_BUTTON
|
|
|
|
sta WG_VIEWRECORDS,x ; Style
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #0 ; Initialize scrolling
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize view width
|
|
|
|
inx
|
|
|
|
sta WG_VIEWRECORDS,x ; Initialize view height
|
|
|
|
inx
|
|
|
|
|
|
|
|
lda #%00000000 ; Initialize state
|
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
2014-09-20 18:20:44 -07:00
|
|
|
|
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
|
|
|
sta WG_VIEWRECORDS,x ; Callback
|
2014-09-05 16:31:33 -07:00
|
|
|
inx
|
2014-09-20 18:20:44 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_VIEWRECORDS,x
|
|
|
|
inx
|
|
|
|
|
2014-09-21 13:46:41 -07:00
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
|
|
|
sta WG_VIEWRECORDS,x ; Title
|
|
|
|
inx
|
|
|
|
iny
|
|
|
|
lda (PARAM0),y
|
|
|
|
sta WG_VIEWRECORDS,x
|
2014-09-05 16:31:33 -07:00
|
|
|
inx
|
|
|
|
|
2014-09-16 18:01:08 -07:00
|
|
|
pla
|
|
|
|
jsr WGSelectView ; Leave this as the active view
|
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
WGCreateButton_done:
|
|
|
|
RESTORE_ZPS
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGPaintView
|
|
|
|
; Paints the current view
|
|
|
|
;
|
|
|
|
WGPaintView:
|
|
|
|
SAVE_AY
|
|
|
|
SAVE_ZPP
|
2014-09-05 16:31:33 -07:00
|
|
|
SAVE_ZPS
|
2014-08-29 12:19:19 -07:00
|
|
|
|
|
|
|
LDY_ACTIVEVIEW
|
2014-09-05 20:32:16 -07:00
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
lda WG_VIEWRECORDS+4,y ; Cache style information
|
2014-09-20 18:20:44 -07:00
|
|
|
and #$f ; Mask off flag bits
|
2014-09-05 16:31:33 -07:00
|
|
|
sta SCRATCH0
|
2014-08-29 12:19:19 -07:00
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
lda WG_VIEWRECORDS+0,y ; Fetch the geometry
|
2014-08-29 12:19:19 -07:00
|
|
|
sta PARAM0
|
2014-09-05 16:31:33 -07:00
|
|
|
lda WG_VIEWRECORDS+1,y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta PARAM1
|
2014-09-05 16:31:33 -07:00
|
|
|
lda WG_VIEWRECORDS+2,y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta PARAM2
|
2014-09-05 16:31:33 -07:00
|
|
|
lda WG_VIEWRECORDS+3,y
|
2014-08-29 12:19:19 -07:00
|
|
|
sta PARAM3
|
|
|
|
|
2014-09-07 16:06:25 -07:00
|
|
|
lda SCRATCH0 ; Draw outline
|
|
|
|
cmp #VIEW_STYLE_FANCY
|
|
|
|
beq WGPaintView_decorated
|
|
|
|
|
|
|
|
jsr WGStrokeRect
|
2014-09-05 16:31:33 -07:00
|
|
|
|
|
|
|
lda SCRATCH0
|
|
|
|
cmp #VIEW_STYLE_CHECK
|
|
|
|
beq WGPaintView_check
|
|
|
|
cmp #VIEW_STYLE_BUTTON
|
|
|
|
beq WGPaintView_button
|
|
|
|
bra WGPaintView_done
|
|
|
|
|
2014-09-07 16:06:25 -07:00
|
|
|
WGPaintView_decorated:
|
|
|
|
jsr WGFancyRect
|
|
|
|
jsr paintWindowTitle
|
|
|
|
bra WGPaintView_done
|
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
WGPaintView_check:
|
2014-09-05 20:32:16 -07:00
|
|
|
jsr paintCheck
|
|
|
|
bra WGPaintView_done
|
|
|
|
|
|
|
|
WGPaintView_button:
|
|
|
|
jsr paintButton
|
|
|
|
|
|
|
|
WGPaintView_done:
|
|
|
|
RESTORE_ZPS
|
|
|
|
RESTORE_ZPP
|
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; paintCheck
|
|
|
|
; Paints the contents of a checkbox
|
|
|
|
; Y: Index into view records of checkbox to paint
|
2014-09-21 13:46:41 -07:00
|
|
|
; Side effects: Clobbers S0,P0,P1, all registers
|
2014-09-05 20:32:16 -07:00
|
|
|
paintCheck:
|
|
|
|
lda WG_VIEWRECORDS+0,y ; Position cursor
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_CURSORX
|
|
|
|
lda WG_VIEWRECORDS+1,y
|
|
|
|
sta WG_CURSORY
|
2014-09-05 20:32:16 -07:00
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+9,y ; Determine our visual state
|
2014-09-05 16:31:33 -07:00
|
|
|
and #$80
|
2014-09-05 20:32:16 -07:00
|
|
|
bne paintCheck_selected
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+9,y
|
|
|
|
and #$01
|
|
|
|
beq paintCheck_unselectedUnchecked
|
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
lda #'D'
|
2014-09-05 20:32:16 -07:00
|
|
|
bra paintCheck_plot
|
2014-09-05 16:31:33 -07:00
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
paintCheck_unselectedUnchecked:
|
|
|
|
lda #' '+$80
|
|
|
|
bra paintCheck_plot
|
2014-09-05 16:31:33 -07:00
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
paintCheck_selected:
|
|
|
|
lda WG_VIEWRECORDS+9,y
|
|
|
|
and #$01
|
|
|
|
beq paintCheck_selectedUnchecked
|
2014-09-05 16:31:33 -07:00
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
lda #'E'
|
|
|
|
bra paintCheck_plot
|
2014-09-05 17:14:37 -07:00
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
paintCheck_selectedUnchecked:
|
|
|
|
lda #' '
|
|
|
|
|
|
|
|
paintCheck_plot: ; Paint our state
|
|
|
|
jsr WGPlot
|
2014-09-21 13:46:41 -07:00
|
|
|
|
|
|
|
inc WG_CURSORX ; Prepare for title
|
|
|
|
inc WG_CURSORX
|
|
|
|
jsr WGNormal
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+12,y
|
|
|
|
sta PARAM0
|
|
|
|
lda WG_VIEWRECORDS+13,y
|
|
|
|
sta PARAM1
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
paintCheck_titleLoop:
|
|
|
|
lda (PARAM0),y
|
|
|
|
beq paintCheck_done
|
|
|
|
ora #$80
|
|
|
|
jsr WGPlot
|
|
|
|
inc WG_CURSORX
|
|
|
|
iny
|
|
|
|
bra paintCheck_titleLoop
|
|
|
|
|
|
|
|
paintCheck_done:
|
2014-09-05 17:14:37 -07:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; paintButton
|
|
|
|
; Paints the contents of a button
|
|
|
|
; Y: Index into view records of button to paint
|
|
|
|
;
|
|
|
|
paintButton:
|
|
|
|
SAVE_AX
|
|
|
|
SAVE_ZPS
|
|
|
|
|
2014-09-21 13:46:41 -07:00
|
|
|
lda WG_VIEWRECORDS+12,y ; Prep the title string
|
2014-09-05 16:31:33 -07:00
|
|
|
sta PARAM0
|
2014-09-21 13:46:41 -07:00
|
|
|
lda WG_VIEWRECORDS+13,y
|
2014-09-05 16:31:33 -07:00
|
|
|
sta PARAM1
|
|
|
|
|
|
|
|
jsr WGStrLen ; Compute centering offset for title
|
|
|
|
lsr
|
|
|
|
sta SCRATCH1
|
|
|
|
lda WG_VIEWRECORDS+2,y
|
|
|
|
lsr
|
|
|
|
sec
|
|
|
|
sbc SCRATCH1
|
2014-09-05 17:14:37 -07:00
|
|
|
sta SCRATCH1 ; Cache this for left margin rendering
|
2014-09-05 16:31:33 -07:00
|
|
|
|
|
|
|
lda #0 ; Position and print title
|
2014-09-05 17:14:37 -07:00
|
|
|
sta WG_LOCALCURSORX
|
|
|
|
lda #0
|
2014-09-05 16:31:33 -07:00
|
|
|
sta WG_LOCALCURSORY
|
2014-09-05 17:14:37 -07:00
|
|
|
jsr WGSyncGlobalCursor
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+9,y ; Is button highlighted?
|
|
|
|
and #$80
|
|
|
|
bne paintButton_titleSelected
|
|
|
|
jsr WGNormal
|
|
|
|
lda #' '+$80
|
|
|
|
bra paintButton_titleMarginLeft
|
|
|
|
|
|
|
|
paintButton_titleSelected:
|
|
|
|
jsr WGInverse
|
|
|
|
lda #' '
|
|
|
|
|
|
|
|
paintButton_titleMarginLeft:
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
paintButton_titleMarginLeftLoop:
|
|
|
|
cpx SCRATCH1
|
|
|
|
bcs paintButton_title ; Left margin finished
|
|
|
|
jsr WGPlot
|
|
|
|
inc WG_CURSORX
|
|
|
|
inc WG_LOCALCURSORX
|
|
|
|
inx
|
|
|
|
jmp paintButton_titleMarginLeftLoop
|
|
|
|
|
|
|
|
paintButton_title:
|
2014-09-05 16:31:33 -07:00
|
|
|
jsr WGPrint
|
2014-09-05 17:14:37 -07:00
|
|
|
ldx WG_VIEWRECORDS+2,y
|
|
|
|
stx SCRATCH1 ; Loop until right edge of button is reached
|
|
|
|
ldx WG_LOCALCURSORX
|
2014-08-29 12:19:19 -07:00
|
|
|
|
2014-09-05 17:14:37 -07:00
|
|
|
paintButton_titleMarginRightLoop:
|
|
|
|
cpx SCRATCH1
|
|
|
|
bcs paintButton_done ; Right margin finished
|
|
|
|
jsr WGPlot
|
|
|
|
inc WG_CURSORX
|
|
|
|
inc WG_LOCALCURSORX
|
|
|
|
inx
|
|
|
|
jmp paintButton_titleMarginRightLoop
|
|
|
|
|
|
|
|
paintButton_done:
|
2014-09-05 16:31:33 -07:00
|
|
|
RESTORE_ZPS
|
2014-09-05 17:14:37 -07:00
|
|
|
RESTORE_AX
|
2014-08-29 12:19:19 -07:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-07 16:06:25 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; paintWindowTitle
|
|
|
|
; Paints the title of a fancy window
|
|
|
|
; Y: Index into view records of view title to paint
|
|
|
|
;
|
|
|
|
paintWindowTitle:
|
|
|
|
SAVE_AX
|
|
|
|
SAVE_ZPS
|
|
|
|
|
2014-09-23 15:33:51 -07:00
|
|
|
lda WG_VIEWRECORDS+12,y ; Prep the title string
|
2014-09-07 16:06:25 -07:00
|
|
|
sta PARAM0
|
2014-09-23 15:33:51 -07:00
|
|
|
lda WG_VIEWRECORDS+13,y
|
2014-09-07 16:06:25 -07:00
|
|
|
sta PARAM1
|
2014-09-16 14:04:05 -07:00
|
|
|
bne paintWindowTitle_compute
|
|
|
|
|
|
|
|
paintWindowTitle_checkNull:
|
|
|
|
lda PARAM0
|
|
|
|
beq paintWindowTitle_done
|
2014-09-07 16:06:25 -07:00
|
|
|
|
2014-09-16 14:04:05 -07:00
|
|
|
paintWindowTitle_compute:
|
2014-09-07 16:06:25 -07:00
|
|
|
jsr WGStrLen ; Compute centering offset for title
|
|
|
|
lsr
|
|
|
|
sta SCRATCH1
|
|
|
|
lda WG_VIEWRECORDS+2,y
|
|
|
|
lsr
|
|
|
|
sec
|
|
|
|
sbc SCRATCH1
|
2014-09-16 08:41:48 -07:00
|
|
|
sta WG_LOCALCURSORX ; Position cursor
|
2014-09-07 16:06:25 -07:00
|
|
|
lda #-1
|
|
|
|
sta WG_LOCALCURSORY
|
2014-09-16 08:41:48 -07:00
|
|
|
jsr WGSyncGlobalCursor
|
2014-09-07 16:06:25 -07:00
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
ldy #0
|
|
|
|
paintWindowTitleLoop:
|
|
|
|
lda (PARAM0),y
|
|
|
|
beq paintWindowTitle_done
|
|
|
|
ora #%10000000
|
|
|
|
jsr WGPlot ; Draw the character
|
|
|
|
iny
|
|
|
|
inc WG_CURSORX ; Advance cursors
|
|
|
|
bra paintWindowTitleLoop
|
2014-09-07 16:06:25 -07:00
|
|
|
|
|
|
|
paintWindowTitle_done:
|
|
|
|
RESTORE_ZPS
|
|
|
|
RESTORE_AX
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-02 17:43:09 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGEraseView
|
|
|
|
; Erases the current view (including decoration)
|
|
|
|
;
|
|
|
|
WGEraseView:
|
2014-09-07 16:25:26 -07:00
|
|
|
SAVE_AXY
|
2014-09-02 17:43:09 -07:00
|
|
|
SAVE_ZPP
|
|
|
|
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
|
2014-09-24 17:03:37 -07:00
|
|
|
lda WG_VIEWRECORDS+0,y
|
2014-09-02 17:43:09 -07:00
|
|
|
dec
|
|
|
|
sta PARAM0
|
2014-09-24 17:03:37 -07:00
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+1,y
|
2014-09-02 17:43:09 -07:00
|
|
|
dec
|
|
|
|
sta PARAM1
|
2014-09-24 17:03:37 -07:00
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+2,y
|
2014-09-02 17:43:09 -07:00
|
|
|
inc
|
|
|
|
inc
|
|
|
|
sta PARAM2
|
2014-09-24 17:03:37 -07:00
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+3,y
|
2014-09-02 17:43:09 -07:00
|
|
|
inc
|
|
|
|
inc
|
|
|
|
sta PARAM3
|
|
|
|
|
|
|
|
ldx #' '+$80
|
|
|
|
jsr WGFillRect
|
|
|
|
|
|
|
|
WGEraseView_done:
|
|
|
|
RESTORE_ZPP
|
2014-09-07 16:25:26 -07:00
|
|
|
RESTORE_AXY
|
2014-09-02 17:43:09 -07:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGEraseViewContents
|
|
|
|
; Erases the contents of the current view (interior contents only)
|
|
|
|
;
|
|
|
|
WGEraseViewContents:
|
|
|
|
SAVE_AXY
|
|
|
|
SAVE_ZPP
|
|
|
|
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS,y ; Fetch the record
|
|
|
|
sta PARAM0
|
|
|
|
iny
|
|
|
|
lda WG_VIEWRECORDS,y
|
|
|
|
sta PARAM1
|
|
|
|
iny
|
|
|
|
lda WG_VIEWRECORDS,y
|
|
|
|
sta PARAM2
|
|
|
|
iny
|
|
|
|
lda WG_VIEWRECORDS,y
|
|
|
|
sta PARAM3
|
|
|
|
|
|
|
|
ldx #' '+$80
|
|
|
|
jsr WGFillRect
|
|
|
|
|
|
|
|
WGEraseViewContents_done:
|
|
|
|
RESTORE_ZPP
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGSelectView
|
|
|
|
; Selects the active view
|
|
|
|
; A: ID
|
|
|
|
;
|
|
|
|
WGSelectView:
|
|
|
|
sta WG_ACTIVEVIEW
|
2014-09-05 20:32:16 -07:00
|
|
|
pha
|
2014-08-29 12:19:19 -07:00
|
|
|
|
|
|
|
; Initialize cursor to local origin
|
|
|
|
lda #0
|
|
|
|
sta WG_LOCALCURSORX
|
|
|
|
sta WG_LOCALCURSORY
|
|
|
|
|
2014-09-01 11:18:36 -07:00
|
|
|
jsr cacheClipPlanes ; View changed, so clipping cache is stale
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
WGSelectView_done:
|
2014-09-05 20:32:16 -07:00
|
|
|
pla
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-07 11:22:32 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGViewFocus
|
|
|
|
; Shifts focus to the selected view
|
|
|
|
; Side effects: Changes selected view, repaints some views
|
|
|
|
;
|
|
|
|
WGViewFocus:
|
|
|
|
SAVE_AY
|
|
|
|
|
|
|
|
lda WG_ACTIVEVIEW ; Stash current selection
|
|
|
|
pha
|
|
|
|
|
|
|
|
LDY_FOCUSVIEW ; Unfocus current view
|
|
|
|
lda WG_VIEWRECORDS+9,y
|
|
|
|
and #%01111111
|
|
|
|
sta WG_VIEWRECORDS+9,y
|
|
|
|
|
|
|
|
lda WG_FOCUSVIEW
|
|
|
|
jsr WGSelectView
|
|
|
|
jsr WGPaintView
|
|
|
|
|
|
|
|
pla
|
|
|
|
sta WG_FOCUSVIEW ; Focus on our original selection
|
|
|
|
jsr WGSelectView
|
|
|
|
|
|
|
|
LDY_FOCUSVIEW
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+9,y ; Change state and repaint to reflect it
|
|
|
|
ora #%10000000
|
|
|
|
sta WG_VIEWRECORDS+9,y
|
|
|
|
|
|
|
|
jsr WGPaintView
|
|
|
|
|
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; 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
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
WGViewFocusNext_loop:
|
2014-09-05 20:32:16 -07:00
|
|
|
inc WG_FOCUSVIEW ; Increment and wrap
|
|
|
|
LDY_FOCUSVIEW
|
|
|
|
lda WG_VIEWRECORDS+2,y
|
2014-09-16 08:41:48 -07:00
|
|
|
bne WGViewFocusNext_wantFocus
|
2014-09-05 20:32:16 -07:00
|
|
|
lda #0
|
|
|
|
sta WG_FOCUSVIEW
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
WGViewFocusNext_wantFocus: ; Does this view accept focus?
|
|
|
|
LDY_FOCUSVIEW
|
|
|
|
lda WG_VIEWRECORDS+4,y
|
2014-09-20 18:20:44 -07:00
|
|
|
and #$f ; Mask off flag bits
|
2014-09-16 08:41:48 -07:00
|
|
|
cmp #VIEW_STYLE_TAKESFOCUS
|
|
|
|
bcc WGViewFocusNext_loop
|
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
WGViewFocusNext_focus:
|
2014-09-07 11:22:32 -07:00
|
|
|
lda WG_FOCUSVIEW ; Change state and repaint to reflect it
|
2014-09-05 20:32:16 -07:00
|
|
|
jsr WGSelectView
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+9,y
|
|
|
|
ora #%10000000
|
|
|
|
sta WG_VIEWRECORDS+9,y
|
|
|
|
|
|
|
|
jsr WGPaintView
|
|
|
|
|
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-07 11:15:59 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; 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
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
WGViewFocusPrev_loop:
|
2014-09-07 11:15:59 -07:00
|
|
|
dec WG_FOCUSVIEW ; Decrement and wrap
|
2014-09-16 08:41:48 -07:00
|
|
|
bpl WGViewFocusPrev_wantFocus
|
2014-09-07 11:15:59 -07:00
|
|
|
|
|
|
|
ldx #$f
|
|
|
|
WGViewFocusPrev_findEndLoop:
|
|
|
|
stx WG_FOCUSVIEW
|
|
|
|
LDY_FOCUSVIEW
|
|
|
|
lda WG_VIEWRECORDS+2,y
|
2014-09-16 08:41:48 -07:00
|
|
|
bne WGViewFocusPrev_wantFocus
|
2014-09-07 11:15:59 -07:00
|
|
|
dex
|
|
|
|
bra WGViewFocusPrev_findEndLoop
|
|
|
|
|
2014-09-16 08:41:48 -07:00
|
|
|
WGViewFocusPrev_wantFocus: ; Does this view accept focus?
|
|
|
|
LDY_FOCUSVIEW
|
|
|
|
lda WG_VIEWRECORDS+4,y
|
2014-09-20 18:20:44 -07:00
|
|
|
and #$f ; Mask off flag bits
|
2014-09-16 08:41:48 -07:00
|
|
|
cmp #VIEW_STYLE_TAKESFOCUS
|
|
|
|
bcc WGViewFocusPrev_loop
|
|
|
|
|
2014-09-07 11:15:59 -07:00
|
|
|
WGViewFocusPrev_focus:
|
2014-09-07 11:22:32 -07:00
|
|
|
lda WG_FOCUSVIEW ; Change state and repaint to reflect it
|
2014-09-07 11:15:59 -07:00
|
|
|
jsr WGSelectView
|
|
|
|
|
|
|
|
LDY_FOCUSVIEW
|
2014-09-07 11:22:32 -07:00
|
|
|
|
2014-09-07 11:15:59 -07:00
|
|
|
lda WG_VIEWRECORDS+9,y
|
|
|
|
ora #%10000000
|
|
|
|
sta WG_VIEWRECORDS+9,y
|
|
|
|
|
|
|
|
jsr WGPaintView
|
|
|
|
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGViewFocusAction
|
|
|
|
; Performs the action of the focused view
|
2014-09-20 18:20:44 -07:00
|
|
|
; OUT V : Set if the caller should perform an Applesoft GOSUB
|
2014-09-05 20:32:16 -07:00
|
|
|
; Side effects: Changes selected view, Repaints some views
|
|
|
|
;
|
|
|
|
WGViewFocusAction:
|
|
|
|
SAVE_AY
|
|
|
|
|
|
|
|
LDY_FOCUSVIEW
|
|
|
|
lda WG_VIEWRECORDS+4,y ; What kind of view is it?
|
2014-09-20 18:20:44 -07:00
|
|
|
and #$f ; Mask off flag bits
|
2014-09-05 20:32:16 -07:00
|
|
|
|
|
|
|
cmp #VIEW_STYLE_CHECK
|
|
|
|
beq WGViewFocusAction_toggleCheckbox
|
|
|
|
cmp #VIEW_STYLE_BUTTON
|
|
|
|
beq WGViewFocusAction_buttonClick
|
|
|
|
|
|
|
|
bra WGViewFocusAction_done
|
|
|
|
|
|
|
|
WGViewFocusAction_toggleCheckbox:
|
2014-09-07 11:15:59 -07:00
|
|
|
lda WG_VIEWRECORDS+9,y ; Change the checkbox's state and redraw
|
2014-09-05 20:32:16 -07:00
|
|
|
eor #%00000001
|
|
|
|
sta WG_VIEWRECORDS+9,y
|
|
|
|
lda WG_FOCUSVIEW
|
|
|
|
jsr WGSelectView
|
|
|
|
jsr WGPaintView
|
2014-09-07 11:15:59 -07:00
|
|
|
; Fall through so checkboxes can have callbacks too
|
2014-09-05 20:32:16 -07:00
|
|
|
|
2014-09-07 11:15:59 -07:00
|
|
|
; NOTE: Self-modifying code ahead!
|
2014-09-05 20:32:16 -07:00
|
|
|
WGViewFocusAction_buttonClick:
|
2014-09-20 18:20:44 -07:00
|
|
|
lda WG_VIEWRECORDS+4,y ; Are we an Applesoft button?
|
|
|
|
and #VIEW_STYLE_APPLESOFT
|
2014-09-21 13:08:41 -07:00
|
|
|
bne WGViewFocusAction_buttonClickApplesoft
|
2014-09-20 18:20:44 -07:00
|
|
|
|
2014-09-21 13:46:41 -07:00
|
|
|
lda WG_VIEWRECORDS+11,y ; Do we have a callback?
|
2014-09-07 11:15:59 -07:00
|
|
|
beq WGViewFocusAction_done
|
|
|
|
sta WGViewFocusAction_userJSR+2 ; Modify code below so we can JSR to user's code
|
2014-09-21 13:46:41 -07:00
|
|
|
lda WG_VIEWRECORDS+10,y
|
2014-09-07 11:15:59 -07:00
|
|
|
sta WGViewFocusAction_userJSR+1
|
|
|
|
|
|
|
|
WGViewFocusAction_userJSR:
|
2014-09-20 18:20:44 -07:00
|
|
|
jsr WGViewFocusAction_knownRTS ; Overwritten with user's function pointer
|
|
|
|
bra WGViewFocusAction_done
|
|
|
|
|
|
|
|
WGViewFocusAction_buttonClickApplesoft:
|
|
|
|
clv
|
|
|
|
lda WG_VIEWRECORDS+10,y ; Do we have a callback?
|
|
|
|
beq WGViewFocusAction_mightBeZero
|
|
|
|
|
|
|
|
WGViewFocusAction_buttonClickApplesoftNotZero:
|
|
|
|
sta PARAM0
|
|
|
|
lda WG_VIEWRECORDS+11,y
|
|
|
|
sta PARAM1
|
|
|
|
|
|
|
|
WGViewFocusAction_buttonClickApplesoftGosub:
|
|
|
|
; Caller needs to handle Applesoft Gosub, so signal with a flag and return
|
|
|
|
lda #%01000000
|
|
|
|
bit WGViewFocusAction_knownRTS ; Set V by BITting an RTS instruction
|
|
|
|
bra WGViewFocusAction_done
|
|
|
|
|
|
|
|
WGViewFocusAction_mightBeZero:
|
|
|
|
lda WG_VIEWRECORDS+11,y
|
|
|
|
beq WGViewFocusAction_done
|
|
|
|
lda WG_VIEWRECORDS+10,y
|
|
|
|
bra WGViewFocusAction_buttonClickApplesoftNotZero
|
2014-09-05 20:32:16 -07:00
|
|
|
|
|
|
|
WGViewFocusAction_done:
|
|
|
|
RESTORE_AY
|
2014-09-20 18:20:44 -07:00
|
|
|
WGViewFocusAction_knownRTS:
|
2014-08-29 12:19:19 -07:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-05 16:31:33 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGViewSetTitle
|
|
|
|
; Sets the title of the active view
|
|
|
|
; PARAM0: Null-terminated string pointer (LSB)
|
|
|
|
; PARAM1: Null-terminated string pointer (MSB)
|
|
|
|
WGViewSetTitle:
|
|
|
|
SAVE_AXY
|
|
|
|
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
lda PARAM0
|
|
|
|
sta WG_VIEWRECORDS+12,y
|
2014-09-21 14:16:12 -07:00
|
|
|
lda PARAM1
|
|
|
|
sta WG_VIEWRECORDS+13,y
|
2014-09-05 16:31:33 -07:00
|
|
|
|
|
|
|
WGViewSetTitle_done:
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-07 11:15:59 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; 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+10,y
|
2014-09-21 14:16:12 -07:00
|
|
|
lda PARAM1
|
|
|
|
sta WG_VIEWRECORDS+11,y
|
2014-09-07 11:15:59 -07:00
|
|
|
|
|
|
|
WGViewSetAction_done:
|
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGSetCursor
|
|
|
|
; Sets the current local view cursor
|
|
|
|
; X: X
|
|
|
|
; Y: Y
|
|
|
|
;
|
|
|
|
WGSetCursor:
|
|
|
|
stx WG_LOCALCURSORX
|
|
|
|
sty WG_LOCALCURSORY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGSyncGlobalCursor
|
|
|
|
; Synchronizes the global cursor with the current local view's
|
|
|
|
; cursor
|
|
|
|
;
|
|
|
|
WGSyncGlobalCursor:
|
|
|
|
SAVE_AY
|
|
|
|
|
|
|
|
; X
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
|
|
|
|
clc ; Transform to viewspace
|
|
|
|
lda WG_LOCALCURSORX
|
|
|
|
adc WG_VIEWRECORDS,y
|
|
|
|
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
clc
|
|
|
|
adc WG_VIEWRECORDS,y ; Transform to scrollspace
|
|
|
|
sta WG_CURSORX
|
|
|
|
|
|
|
|
; Y
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
iny
|
|
|
|
|
|
|
|
clc ; Transform to viewspace
|
|
|
|
lda WG_LOCALCURSORY
|
|
|
|
adc WG_VIEWRECORDS,y
|
|
|
|
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
clc
|
|
|
|
adc WG_VIEWRECORDS,y ; Transform to scrollspace
|
|
|
|
sta WG_CURSORY
|
|
|
|
|
|
|
|
WGSyncGlobalCursor_done:
|
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGScrollX
|
|
|
|
; Scrolls the current view horizontally
|
2014-09-02 17:43:09 -07:00
|
|
|
; A: New scroll amount
|
2014-08-29 12:19:19 -07:00
|
|
|
; Side effects: Clobbers A
|
|
|
|
;
|
|
|
|
WGScrollX:
|
|
|
|
phy
|
|
|
|
pha
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
2014-09-02 17:43:09 -07:00
|
|
|
pla
|
2014-08-29 12:19:19 -07:00
|
|
|
sta WG_VIEWRECORDS,y
|
2014-09-01 11:18:36 -07:00
|
|
|
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
WGScrollX_done:
|
|
|
|
ply
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-08 18:00:40 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGScrollXBy
|
|
|
|
; Scrolls the current view horizontally by a delta
|
|
|
|
; A: Scroll delta
|
|
|
|
; Side effects: Clobbers A
|
|
|
|
;
|
|
|
|
WGScrollXBy:
|
|
|
|
phy
|
|
|
|
phx
|
|
|
|
tax
|
|
|
|
|
|
|
|
SAVE_ZPS
|
|
|
|
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
|
|
|
|
txa
|
|
|
|
bpl WGScrollXBy_contentRight
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+2,y ; Compute left limit
|
|
|
|
sec
|
|
|
|
sbc WG_VIEWRECORDS+7,y
|
|
|
|
sta SCRATCH0
|
|
|
|
|
|
|
|
txa ; Compute new scroll value
|
|
|
|
clc
|
|
|
|
adc WG_VIEWRECORDS+5,y
|
|
|
|
cmp SCRATCH0 ; Clamp if needed
|
|
|
|
bmi WGScrollXBy_clampLeft
|
|
|
|
sta WG_VIEWRECORDS+5,y
|
|
|
|
bra WGScrollXBy_done
|
|
|
|
|
|
|
|
WGScrollXBy_clampLeft:
|
|
|
|
lda SCRATCH0
|
|
|
|
sta WG_VIEWRECORDS+5,y
|
|
|
|
bra WGScrollXBy_done
|
|
|
|
|
|
|
|
WGScrollXBy_contentRight:
|
|
|
|
clc ; Compute new scroll value
|
|
|
|
adc WG_VIEWRECORDS+5,y
|
|
|
|
cmp #0 ; Clamp if needed
|
|
|
|
beq @0
|
|
|
|
bpl WGScrollXBy_clampRight
|
|
|
|
@0: sta WG_VIEWRECORDS+5,y
|
|
|
|
bra WGScrollXBy_done
|
|
|
|
|
|
|
|
WGScrollXBy_clampRight:
|
|
|
|
lda #0
|
|
|
|
sta WG_VIEWRECORDS+5,y
|
|
|
|
|
|
|
|
WGScrollXBy_done:
|
|
|
|
RESTORE_ZPS
|
|
|
|
plx
|
|
|
|
ply
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGScrollY
|
|
|
|
; Scrolls the current view vertically
|
2014-09-02 17:43:09 -07:00
|
|
|
; A: New scroll amount
|
2014-08-29 12:19:19 -07:00
|
|
|
; Side effects: Clobbers A
|
|
|
|
;
|
|
|
|
WGScrollY:
|
|
|
|
phy
|
|
|
|
pha
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
pla
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
sta WG_VIEWRECORDS,y
|
|
|
|
|
2014-09-01 11:18:36 -07:00
|
|
|
jsr cacheClipPlanes ; Scroll offset changed, so clipping cache is stale
|
|
|
|
|
2014-08-29 12:19:19 -07:00
|
|
|
WGScrollY_done:
|
|
|
|
ply
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-01 11:18:36 -07:00
|
|
|
|
2014-09-08 18:00:40 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGScrollYBy
|
|
|
|
; Scrolls the current view horizontally by a delta
|
|
|
|
; A: Scroll delta
|
|
|
|
; Side effects: Clobbers A
|
|
|
|
;
|
|
|
|
WGScrollYBy:
|
|
|
|
phy
|
|
|
|
phx
|
|
|
|
tax
|
|
|
|
|
|
|
|
SAVE_ZPS
|
|
|
|
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
|
|
|
|
txa
|
|
|
|
bpl WGScrollYBy_contentDown
|
|
|
|
|
|
|
|
lda WG_VIEWRECORDS+3,y ; Compute bottom limit
|
|
|
|
sec
|
|
|
|
sbc WG_VIEWRECORDS+8,y
|
|
|
|
sta SCRATCH0
|
|
|
|
|
|
|
|
txa ; Compute new scroll value
|
|
|
|
clc
|
|
|
|
adc WG_VIEWRECORDS+6,y
|
|
|
|
cmp SCRATCH0 ; Clamp if needed
|
|
|
|
bmi WGScrollYBy_clampTop
|
|
|
|
sta WG_VIEWRECORDS+6,y
|
|
|
|
bra WGScrollYBy_done
|
|
|
|
|
|
|
|
WGScrollYBy_clampTop:
|
|
|
|
lda SCRATCH0
|
|
|
|
sta WG_VIEWRECORDS+6,y
|
|
|
|
bra WGScrollYBy_done
|
|
|
|
|
|
|
|
WGScrollYBy_contentDown:
|
|
|
|
clc ; Compute new scroll value
|
|
|
|
adc WG_VIEWRECORDS+6,y
|
|
|
|
cmp #0 ; Clamp if needed
|
|
|
|
beq @0
|
|
|
|
bpl WGScrollYBy_clampBottom
|
|
|
|
@0: sta WG_VIEWRECORDS+6,y
|
|
|
|
bra WGScrollYBy_done
|
|
|
|
|
|
|
|
WGScrollYBy_clampBottom:
|
|
|
|
lda #0
|
|
|
|
sta WG_VIEWRECORDS+6,y
|
|
|
|
|
|
|
|
WGScrollYBy_done:
|
|
|
|
RESTORE_ZPS
|
|
|
|
plx
|
|
|
|
ply
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-05 20:32:16 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; 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
|
|
|
|
|
2014-09-07 16:25:26 -07:00
|
|
|
jsr WGEraseViewContents
|
2014-09-05 20:32:16 -07:00
|
|
|
jsr WGPaintView
|
|
|
|
inx
|
|
|
|
bra WGViewPaintAll_loop
|
|
|
|
|
|
|
|
WGViewPaintAll_done:
|
|
|
|
RESTORE_AXY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-01 11:18:36 -07:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; cacheClipPlanes
|
|
|
|
; Internal routine to cache the clipping planes for the view
|
|
|
|
;
|
|
|
|
cacheClipPlanes:
|
|
|
|
SAVE_AY
|
|
|
|
|
|
|
|
; Compute clip planes in view space
|
|
|
|
LDY_ACTIVEVIEW
|
|
|
|
|
|
|
|
iny ; Left edge
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
lda WG_VIEWRECORDS,y
|
|
|
|
eor #$ff
|
|
|
|
inc
|
|
|
|
sta WG_VIEWCLIP+0
|
|
|
|
|
|
|
|
dey ; Right edge
|
|
|
|
dey
|
|
|
|
dey
|
|
|
|
clc
|
|
|
|
adc WG_VIEWRECORDS,y
|
|
|
|
sta WG_VIEWCLIP+2
|
|
|
|
|
|
|
|
iny ; Right span (distance from window edge to view edge, in viewspace
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
iny
|
|
|
|
lda WG_VIEWRECORDS,y
|
|
|
|
sec
|
|
|
|
sbc WG_VIEWCLIP+2
|
|
|
|
sta WG_VIEWCLIP+4
|
|
|
|
|
|
|
|
dey ; Top edge
|
|
|
|
lda WG_VIEWRECORDS,y
|
|
|
|
eor #$ff
|
|
|
|
inc
|
|
|
|
sta WG_VIEWCLIP+1
|
|
|
|
|
|
|
|
dey ; Bottom edge
|
|
|
|
dey
|
|
|
|
dey
|
|
|
|
clc
|
|
|
|
adc WG_VIEWRECORDS,y
|
|
|
|
sta WG_VIEWCLIP+3
|
|
|
|
|
|
|
|
RESTORE_AY
|
|
|
|
rts
|
|
|
|
|
|
|
|
|