Merge pull request #1 from a2mark/master

Add progress bar view
This commit is contained in:
blondie7575 2015-07-18 14:29:06 -05:00
commit 45f044b9ef
9 changed files with 262 additions and 12 deletions

View File

@ -425,6 +425,29 @@ Configuration block consists of five bytes:
</table>
####WGCreateProgress
Creates a new WeeGUI progress bar view. This is a specialized version of WGCreateView, and its parameters are similar.
<table width="100%">
<tr><th>Assembly</th><th>Applesoft</th></tr><tr><td><pre>
X: WGCreateProgress
PARAM0: Pointer to configuration block (LSB)
PARAM1: Pointer to configuration block (MSB)
Configuration block consists of five bytes:
0: View ID (0-15)
1: Left edge of progress bar
2: Top edge of progress bar
3: Width of progress bar
</pre></td><td><pre>
&PROG( View ID,
Left edge,
Top edge,
Width)
</pre></td></tr>
</table>
####WGCreateButton
Creates a new WeeGUI button view. This is a specialized version of WGCreateView, and its parameters are similar.
@ -667,6 +690,19 @@ Not available
</table>
####WGSetValue
Sets the currently selected view's value. Currently only useful for progress bar views.
<table width="100%">
<tr><th>Assembly</th><th>Applesoft</th></tr><tr><td><pre>
X: WGSetState
A: new value
</td><td>
&SETV(value)
</td></tr>
</table>
<br>
Cursor Routines

View File

@ -11,7 +11,7 @@
CL65=cl65
AC=AppleCommander.jar
ADDR=7d00
ADDR=7b00
ADDRDEMO=6000
PGM=weegui

Binary file not shown.

View File

@ -21,7 +21,7 @@ PARAM3 = $09
; WeeGUI entry point
; Set up your call, then do a JSR to this address.
;
WeeGUI = $7d04 ; 7d00
WeeGUI = $7b04 ; 7c00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -66,4 +66,7 @@ WGDisableMouse = 64
WGDeleteView = 66
WGEraseView = 68
WGExit = 70
WGCreateProgress = 72
WGSetState = 74

View File

@ -435,6 +435,65 @@ WGAmpersand_CHKBX:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_PROG
; Create a progress bar
; &PROG(id,x,y,width)
WGAmpersand_PROG:
jsr WGAmpersandBeginArguments
jsr WGAmpersandIntArgument
sta WGAmpersandCommandBuffer+0
jsr WGAmpersandNextArgument
jsr WGAmpersandIntArgument
sta WGAmpersandCommandBuffer+1
jsr WGAmpersandNextArgument
jsr WGAmpersandIntArgument
sta WGAmpersandCommandBuffer+2
jsr WGAmpersandNextArgument
jsr WGAmpersandIntArgument
sta WGAmpersandCommandBuffer+3
jsr WGAmpersandEndArguments
CALL16 WGCreateProgress,WGAmpersandCommandBuffer
LDY_ACTIVEVIEW ; Flag this as an Applesoft-created view
lda #VIEW_STYLE_APPLESOFT
ora WG_VIEWRECORDS+4,y
sta WG_VIEWRECORDS+4,y
jsr WGPaintView
jsr WGBottomCursor
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_SETV
; Set the 'value' field of the selected view
; &SETV(v)
WGAmpersand_SETV:
jsr WGAmpersandBeginArguments
jsr WGAmpersandIntArgument
pha
jsr WGAmpersandEndArguments
pla
sta PARAM0
jsr WGSetState
jsr WGPaintView
jsr WGBottomCursor
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGAmpersand_BUTTN
; Create a button
@ -1149,6 +1208,12 @@ WGAmpersandCommandTable:
.byte "EXIT",0,0
.addr WGAmpersand_EXIT
.byte "PROG",0,0
.addr WGAmpersand_PROG
.byte "SETV",0,0
.addr WGAmpersand_SETV
;.byte TOKEN_GOSUB,0,0,0,0,0,0,0,0,0,0,0,0,0 ; For internal testing of the procedural gosub
;.addr WGAmpersand_GOSUB

View File

@ -16,11 +16,12 @@ CHAR_FLASH = $7f
VIEW_STYLE_STEALTH = $00
VIEW_STYLE_PLAIN = $01
VIEW_STYLE_FANCY = $02
VIEW_STYLE_CHECK = $03
VIEW_STYLE_BUTTON = $04
VIEW_STYLE_PROGRESS = $03
VIEW_STYLE_CHECK = $04
VIEW_STYLE_BUTTON = $05
VIEW_STYLE_TAKESFOCUS = $03 ; Styles >= this one are selectable
VIEW_STYLE_TAKESFOCUS = $04 ; Styles >= this one are selectable
VIEW_STYLE_APPLESOFT = $80 ; High nybble flag bit for views created from Applesoft

141
views.s
View File

@ -157,6 +157,98 @@ WGCreateCheckbox_done:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateProgress
; Creates a new progress bar
; PARAM0: Pointer to configuration struct (LSB)
; PARAM1: Pointer to configuration struct (MSB)
;
; Configuration struct:
; ID: View ID (0-f)
; XX: Screen X origin
; YY: Screen Y origin
; PW: Progress width
;
WGCreateProgress:
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
iny
lda (PARAM0),y
sta WG_VIEWRECORDS+2,x ; Screen width
sta WG_VIEWRECORDS+7,x ; View width
lda #1
sta WG_VIEWRECORDS+3,x ; Screen height
sta WG_VIEWRECORDS+8,x ; View height
lda #VIEW_STYLE_PROGRESS
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
WGCreateProgress_done:
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGSetState
; Sets state field in view record
; PARAM0: Value
;
WGSetState:
SAVE_AXY
LDY_ACTIVEVIEW
lda WG_VIEWRECORDS+9,y
and #$80
sta SCRATCH0
lda PARAM0
and #$7F
ora SCRATCH0
sta WG_VIEWRECORDS+9,y ; State (preserving bit 7)
WGSetState_done:
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGCreateButton
; Creates a new button
@ -286,6 +378,8 @@ WGPaintView:
beq WGPaintView_check
cmp #VIEW_STYLE_BUTTON
beq WGPaintView_button
cmp #VIEW_STYLE_PROGRESS
beq WGPaintView_progress
bra WGPaintView_done
WGPaintView_decorated:
@ -297,6 +391,10 @@ WGPaintView_check:
jsr paintCheck
bra WGPaintView_done
WGPaintView_progress:
jsr paintProgress
bra WGPaintView_done
WGPaintView_button:
jsr paintButton
@ -372,6 +470,49 @@ paintCheck_done:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; paintProgress
; Paints the contents of a progress bar
; Y: Index into view records of progress bar to paint
; Side effects: Clobbers all registers,P0,P1
paintProgress:
lda WG_VIEWRECORDS+1,y ; Top edge
sta PARAM1
lda #1
sta PARAM3
lda WG_VIEWRECORDS+9,y ; Progress value as width
sta PARAM2
beq paintProgress_noFill ; skip if nothing to draw
lda WG_VIEWRECORDS+0,y ; Left edge
sta PARAM0
phy
ldy #$20 ; inverse space
jsr WGFillRect
ply
paintProgress_noFill:
lda WG_VIEWRECORDS+2,y ; full width
sec
sbc WG_VIEWRECORDS+9,y ; Progress value
beq paintProgress_done ; skip if nothing to draw
sta PARAM2
lda WG_VIEWRECORDS+0,y ; left edge
clc
adc WG_VIEWRECORDS+9,y ; Progress value
sta PARAM0
ldy #$A0 ; space
jsr WGFillRect
paintProgress_done:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; paintButton
; Paints the contents of a button

Binary file not shown.

View File

@ -7,7 +7,7 @@
;
.org $7d00
.org $7b00
; Common definitions
@ -74,7 +74,8 @@ WGEntryPointTable:
.addr WGDeleteView
.addr WGEraseView
.addr WGExit
.addr WGCreateProgress
.addr WGSetState
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGInit
@ -86,10 +87,13 @@ WGInit:
;
; See section 5.1.4 in the ProDOS 8 Technical Reference Manual
; for an explanation of these values. We're reserving memory
; pages $7e-$95 so that ProDOS won't use our memory for file
; pages $7b-$95 so that ProDOS won't use our memory for file
; buffers, or allow Applesoft to step on us
;
; Byte in System Bitmap : Bit within byte
; 0f:100
; 0f:011
; 0f:010
; 0f:001
; 0f:000
; 10:111 .. 10:000
@ -100,16 +104,16 @@ WGInit:
; 12:100
; 12:011
; 12:010
lda #%00000011
lda #%00001111
tsb MEMBITMAP + $0f
lda #$ff
lda #%11111111
tsb MEMBITMAP + $10
tsb MEMBITMAP + $11
lda #%11111100
tsb MEMBITMAP + $12
; Protect us from Applesoft by setting up HIMEM
lda #$7c ; 7d00 (really 7cff)
lda #$7a ; 7b00 (really 7aff)
sta LINNUMH
lda #$ff
sta LINNUML
@ -155,7 +159,7 @@ WGExit:
jsr SETHI
; Remove ourselves from ProDOS memory map
lda #%00000011
lda #%00001111
trb MEMBITMAP + $0f
lda #$ff
trb MEMBITMAP + $10