Merge pull request #15 from a2-4am/master

refactor WGCreateRadio, add WGReset, refactor raw/non-raw paint loops, various documentation fixes
This commit is contained in:
blondie7575 2018-03-04 11:40:41 -08:00 committed by GitHub
commit 66f2674d28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 92 additions and 116 deletions

View File

@ -728,12 +728,12 @@ Not available
</table>
####WGSetValue
Sets the currently selected view's value. For progress bar views, this is the progress value. For checkboxes, 1 is checked and 0 is unchecked.
####WGSetState
Sets the currently selected view's value. For progress bar views, this is the progress value. For checkboxes and radio buttons, 1 is checked and 0 is unchecked.
<table width="100%">
<tr><th>Assembly</th><th>Applesoft</th></tr><tr><td><pre>
X: WGSetValue
X: WGSetState
A: new value
</td><td>
&SETV(value)
@ -1121,6 +1121,20 @@ X: WGExit
</table>
<br><br>
####WGReset
Deallocate all WeeGUI views and strings. This is called automatically during WeeGUI startup, but you can call it yourself at any time if you want to "start over" with no views. This does not clear the screen or repaint anything.
<table width="100%">
<tr><th>Assembly</th><th>Applesoft</th></tr><tr><td><pre>
X: WGReset
</pre></td><td><pre>
Not available
</pre></td></tr>
</table>
<br><br>
- - -
@ -1172,7 +1186,7 @@ Appendix C: Sample Code
Here is the source code to the BASICDEMO program, included in the WeeGUI disk image. It shows how a few simple lines of code can create a complex, sophisticated interface, thanks to WeeGUI.
1 PRINT CHR$ (4)"brun weegui"
10 & DESK
10 & HOME(1)
20 & WINDW(0,2,2,15,76,7,76,40)
21 & TITLE("Help")
22 & STACT(2500)

View File

@ -73,4 +73,5 @@ WGSetContentWidth = 78
WGSetContentHeight = 80
WGStrokeRoundRect = 82
WGCreateRadio = 84
WGReset = 86

152
views.s
View File

@ -105,56 +105,9 @@ WGCreateView_done:
; SH: String pointer (MSB)
;
WGCreateCheckbox:
SAVE_AXY
ldy #0
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done
asl
asl
asl
asl ; Records are 16 bytes wide
tax
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
lda #1
sta WG_VIEWRECORDS+2,x ; Initialize screen width
sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+7,x ; Initialize view width
sta WG_VIEWRECORDS+8,x ; Initialize view height
lda #VIEW_STYLE_CHECK
sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state
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
sta WG_VIEWRECORDS+13,x
pla
jsr WGSelectView ; Leave this as the active view
WGCreateCheckbox_done:
RESTORE_AXY
rts
pha
lda #VIEW_STYLE_CHECK
bra WGCreate1x1_common
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateRadio
@ -170,59 +123,63 @@ WGCreateCheckbox_done:
; SH: String pointer (MSB)
;
WGCreateRadio:
SAVE_AXY
pha
lda #VIEW_STYLE_RADIO
WGCreate1x1_common:
sta WGCreate1x1_style+1
SAVE_XY
ldy #0
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done
ldy #0
lda (PARAM0),y ; Find our new view record
pha ; Cache view ID so we can select when we're done
asl
asl
asl
asl ; Records are 16 bytes wide
asl ; Records are 16 bytes wide
tax
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
lda (PARAM0),y
sta WG_VIEWRECORDS+0,x ; Screen X
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
lda (PARAM0),y
sta WG_VIEWRECORDS+1,x ; Screen Y
lda #1
sta WG_VIEWRECORDS+2,x ; Initialize screen width
sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+7,x ; Initialize view width
sta WG_VIEWRECORDS+8,x ; Initialize view height
lda #1
sta WG_VIEWRECORDS+2,x ; Initialize screen width
sta WG_VIEWRECORDS+3,x ; Initialize screen height
sta WG_VIEWRECORDS+7,x ; Initialize view width
sta WG_VIEWRECORDS+8,x ; Initialize view height
lda #VIEW_STYLE_RADIO
sta WG_VIEWRECORDS+4,x ; Style
WGCreate1x1_style:
lda #$FF ; Self-modifying code!
sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+5,x ; Initialize scrolling
stz WG_VIEWRECORDS+6,x
stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback
stz WG_VIEWRECORDS+11,x
stz WG_VIEWRECORDS+9,x ; Initialize state
stz WG_VIEWRECORDS+10,x ; Initialize callback
stz WG_VIEWRECORDS+11,x
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
lda (PARAM0),y
sta WG_VIEWRECORDS+12,x ; Title
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+13,x
lda (PARAM0),y
sta WG_VIEWRECORDS+13,x
pla
jsr WGSelectView ; Leave this as the active view
jsr WGSelectView ; Leave this as the active view
WGCreateRadio_done:
RESTORE_AXY
RESTORE_XY
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateProgress
; Creates a new progress bar
@ -530,28 +487,23 @@ paintCheck_plot: ; Paint our state
lda WG_VIEWRECORDS+13,y
sta PARAM1
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
ldy #0
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
and #VIEW_STYLE_RAWTITLE
bne paintCheck_titleRawLoop
asl
eor #$80 ; becomes #$80 for Apple format, 0 for raw
sta paintCheck_mask+1
ldy #0
paintCheck_titleLoop:
lda (PARAM0),y
beq paintCheck_done
ora #$80
paintCheck_mask:
ora #$FF ; Self-modifying code!
jsr WGPlot
inc WG_CURSORX
iny
bra paintCheck_titleLoop
paintCheck_titleRawLoop:
lda (PARAM0),y
beq paintCheck_done
jsr WGPlot
inc WG_CURSORX
iny
bra paintCheck_titleRawLoop
paintCheck_done:
rts
@ -714,29 +666,23 @@ paintWindowTitle_compute:
dec
sta WG_CURSORY
ldy #0
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
and #VIEW_STYLE_RAWTITLE
bne paintWindowTitleRawLoop
asl
eor #$80 ; becomes #$80 for Apple format, 0 for raw
sta paintWindowTitle_mask
ldy #0
paintWindowTitleLoop:
lda (PARAM0),y
beq paintWindowTitle_done
ora #$80
paintWindowTitle_mask:
ora #$FF ; Self-modifying code!
jsr WGPlot ; Draw the character
iny
inc WG_CURSORX ; Advance cursors
bra paintWindowTitleLoop
paintWindowTitleRawLoop:
lda (PARAM0),y
beq paintWindowTitle_done
jsr WGPlot ; Draw the character
iny
inc WG_CURSORX ; Advance cursors
bra paintWindowTitleRawLoop
paintWindowTitle_done:
rts

Binary file not shown.

View File

@ -76,6 +76,7 @@ WGEntryPointTable:
.addr WGSetContentHeight
.addr WGStrokeRoundRect
.addr WGCreateRadio
.addr WGReset
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -91,10 +92,24 @@ WGInit:
; sta LINNUML
; jsr SETHI
jsr WG80 ; Enter 80-col text mode
jsr WGInitApplesoft ; Set up Applesoft API
jsr WG80 ; Enter 80-col text mode
jsr WGInitApplesoft ; Set up Applesoft API
ldy #15 ; Clear our block allocators
RESTORE_AXY
jmp WGReset
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGReset
; Reset views and strings. Called from WGInit during app startup.
; Can also be called at any time to "start over" with no views.
; (Does not clear screen or repaint.)
;
WGReset:
SAVE_AXY
ldy #15 ; Clear our block allocators
WGInit_clearMemLoop:
tya
asl
@ -103,18 +118,18 @@ WGInit_clearMemLoop:
asl
tax
lda #0
sta WG_STRINGS,x
sta WG_VIEWRECORDS+2,x
sta WG_STRINGS,x
dey
bpl WGInit_clearMemLoop
lda #$ff
sta WG_PENDINGACTIONVIEW
sta WG_FOCUSVIEW
lda #$ff
sta WG_PENDINGACTIONVIEW
sta WG_FOCUSVIEW
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGExit
; Cleanup Should be called once at app shutdown