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> </table>
####WGSetValue ####WGSetState
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. 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%"> <table width="100%">
<tr><th>Assembly</th><th>Applesoft</th></tr><tr><td><pre> <tr><th>Assembly</th><th>Applesoft</th></tr><tr><td><pre>
X: WGSetValue X: WGSetState
A: new value A: new value
</td><td> </td><td>
&SETV(value) &SETV(value)
@ -1121,6 +1121,20 @@ X: WGExit
</table> </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> <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. 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" 1 PRINT CHR$ (4)"brun weegui"
10 & DESK 10 & HOME(1)
20 & WINDW(0,2,2,15,76,7,76,40) 20 & WINDW(0,2,2,15,76,7,76,40)
21 & TITLE("Help") 21 & TITLE("Help")
22 & STACT(2500) 22 & STACT(2500)

View File

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

100
views.s
View File

@ -105,56 +105,9 @@ WGCreateView_done:
; SH: String pointer (MSB) ; SH: String pointer (MSB)
; ;
WGCreateCheckbox: WGCreateCheckbox:
SAVE_AXY pha
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 lda #VIEW_STYLE_CHECK
sta WG_VIEWRECORDS+4,x ; Style bra WGCreate1x1_common
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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateRadio ; WGCreateRadio
@ -170,7 +123,11 @@ WGCreateCheckbox_done:
; SH: String pointer (MSB) ; SH: String pointer (MSB)
; ;
WGCreateRadio: WGCreateRadio:
SAVE_AXY pha
lda #VIEW_STYLE_RADIO
WGCreate1x1_common:
sta WGCreate1x1_style+1
SAVE_XY
ldy #0 ldy #0
lda (PARAM0),y ; Find our new view record lda (PARAM0),y ; Find our new view record
@ -196,7 +153,8 @@ WGCreateRadio:
sta WG_VIEWRECORDS+7,x ; Initialize view width sta WG_VIEWRECORDS+7,x ; Initialize view width
sta WG_VIEWRECORDS+8,x ; Initialize view height sta WG_VIEWRECORDS+8,x ; Initialize view height
lda #VIEW_STYLE_RADIO WGCreate1x1_style:
lda #$FF ; Self-modifying code!
sta WG_VIEWRECORDS+4,x ; Style sta WG_VIEWRECORDS+4,x ; Style
stz WG_VIEWRECORDS+5,x ; Initialize scrolling stz WG_VIEWRECORDS+5,x ; Initialize scrolling
@ -216,13 +174,12 @@ WGCreateRadio:
pla pla
jsr WGSelectView ; Leave this as the active view jsr WGSelectView ; Leave this as the active view
WGCreateRadio_done: RESTORE_XY
RESTORE_AXY pla
rts rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateProgress ; WGCreateProgress
; Creates a new progress bar ; Creates a new progress bar
@ -531,27 +488,22 @@ paintCheck_plot: ; Paint our state
sta PARAM1 sta PARAM1
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title? lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
ldy #0
and #VIEW_STYLE_RAWTITLE 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: paintCheck_titleLoop:
lda (PARAM0),y lda (PARAM0),y
beq paintCheck_done beq paintCheck_done
ora #$80 paintCheck_mask:
ora #$FF ; Self-modifying code!
jsr WGPlot jsr WGPlot
inc WG_CURSORX inc WG_CURSORX
iny iny
bra paintCheck_titleLoop bra paintCheck_titleLoop
paintCheck_titleRawLoop:
lda (PARAM0),y
beq paintCheck_done
jsr WGPlot
inc WG_CURSORX
iny
bra paintCheck_titleRawLoop
paintCheck_done: paintCheck_done:
rts rts
@ -714,29 +666,23 @@ paintWindowTitle_compute:
dec dec
sta WG_CURSORY sta WG_CURSORY
ldy #0
lda WG_VIEWRECORDS+4,y ; Raw or Apple format title? lda WG_VIEWRECORDS+4,y ; Raw or Apple format title?
and #VIEW_STYLE_RAWTITLE and #VIEW_STYLE_RAWTITLE
bne paintWindowTitleRawLoop asl
eor #$80 ; becomes #$80 for Apple format, 0 for raw
sta paintWindowTitle_mask
ldy #0
paintWindowTitleLoop: paintWindowTitleLoop:
lda (PARAM0),y lda (PARAM0),y
beq paintWindowTitle_done beq paintWindowTitle_done
ora #$80 paintWindowTitle_mask:
ora #$FF ; Self-modifying code!
jsr WGPlot ; Draw the character jsr WGPlot ; Draw the character
iny iny
inc WG_CURSORX ; Advance cursors inc WG_CURSORX ; Advance cursors
bra paintWindowTitleLoop bra paintWindowTitleLoop
paintWindowTitleRawLoop:
lda (PARAM0),y
beq paintWindowTitle_done
jsr WGPlot ; Draw the character
iny
inc WG_CURSORX ; Advance cursors
bra paintWindowTitleRawLoop
paintWindowTitle_done: paintWindowTitle_done:
rts rts

Binary file not shown.

View File

@ -76,6 +76,7 @@ WGEntryPointTable:
.addr WGSetContentHeight .addr WGSetContentHeight
.addr WGStrokeRoundRect .addr WGStrokeRoundRect
.addr WGCreateRadio .addr WGCreateRadio
.addr WGReset
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -94,6 +95,20 @@ WGInit:
jsr WG80 ; Enter 80-col text mode jsr WG80 ; Enter 80-col text mode
jsr WGInitApplesoft ; Set up Applesoft API jsr WGInitApplesoft ; Set up Applesoft API
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 ldy #15 ; Clear our block allocators
WGInit_clearMemLoop: WGInit_clearMemLoop:
tya tya
@ -103,6 +118,7 @@ WGInit_clearMemLoop:
asl asl
tax tax
lda #0 lda #0
sta WG_VIEWRECORDS+2,x
sta WG_STRINGS,x sta WG_STRINGS,x
dey dey
bpl WGInit_clearMemLoop bpl WGInit_clearMemLoop
@ -114,7 +130,6 @@ WGInit_clearMemLoop:
RESTORE_AXY RESTORE_AXY
rts rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGExit ; WGExit
; Cleanup Should be called once at app shutdown ; Cleanup Should be called once at app shutdown