Polish to sample code and docs

This commit is contained in:
Quinn Dunki 2015-02-07 17:39:18 -08:00
parent 2b4a194df3
commit b84ca22261
3 changed files with 210 additions and 181 deletions

View File

@ -108,6 +108,8 @@ Simple calls may use a register or two for parameters. For example, the call to
ldx #WGSelectView ; Followed by a typical WeeGUI call
jsr WeeGUI
Registers that you use to pass a parameter to WeeGUI may contain different values upon return.
#####Zero Page Passing:
@ -456,7 +458,7 @@ Returns the currently pending click, if any. This is a way to peek into the stat
<tr><th>Assembly</th><th>Applesoft</th></tr><tr><td><pre>
X: WGPendingClick
Returns in X: X coordinate of click, or $ff if none
Returns in X: X coordinate of click, or $FF if none
Returns in Y: Y coordinate of click, if any
</td><td>
Not available

387
asmdemo.s
View File

@ -34,7 +34,7 @@ main:
; BRUN the GUI library
ldx #0
ldy #0
@0: lda bloadCmdLine,x
@0: lda brunCmdLine,x
beq @1
sta INBUF,y
inx
@ -46,33 +46,11 @@ main:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Show off some WeeGUI features
;jmp tortureTestPrint
jmp tortureTestRects
jmp animateRects
ldx #WGClearScreen
jsr WeeGUI
ldx #WGEnableMouse
jsr WeeGUI
ldx #WGDesktop
jsr WeeGUI
WGCALL16 WGCreateView,testView
WGCALL16 WGViewSetAction,testPaintContentsClick
WGCALL16 WGViewSetTitle,testTitle0
WGCALL16 WGCreateCheckbox,testCheck
WGCALL16 WGCreateButton,testButton1
WGCALL16 WGCreateButton,testButton2
ldx #WGViewPaintAll
jsr WeeGUI
lda #0
ldx #WGSelectView
jsr WeeGUI
; jsr testPaintContents
keyLoop:
ldx #WGPendingViewAction
jsr WeeGUI
@ -82,181 +60,230 @@ keyLoop:
sta KBDSTRB
and #%01111111
cmp #9
beq keyLoop_focusNext
cmp #27
beq keyLoop_focusPrev
cmp #13
beq keyLoop_toggle
cmp #32
beq keyLoop_toggle
cmp #'o'
beq keyLoop_focusOkay
cmp #8
beq keyLoop_leftArrow
cmp #21
beq keyLoop_rightArrow
cmp #11
beq keyLoop_upArrow
cmp #10
beq keyLoop_downArrow
cmp #113
beq keyLoop_quit
jmp keyLoop
keyLoop_focusNext:
ldx #WGViewFocusNext
jsr WeeGUI
jmp keyLoop
keyLoop_focusPrev:
ldx #WGViewFocusPrev
jsr WeeGUI
jmp keyLoop
keyLoop_toggle:
ldx #WGViewFocusAction
jsr WeeGUI
jmp keyLoop
keyLoop_leftArrow:
lda #1
ldx #WGScrollXBy
jsr WeeGUI
jsr testPaintContents
jmp keyLoop
keyLoop_rightArrow:
lda #-1
ldx #WGScrollXBy
jsr WeeGUI
jsr testPaintContents
jmp keyLoop
keyLoop_upArrow:
lda #1
ldx #WGScrollYBy
jsr WeeGUI
jsr testPaintContents
jmp keyLoop
keyLoop_downArrow:
lda #-1
ldx #WGScrollYBy
jsr WeeGUI
jsr testPaintContents
jmp keyLoop
keyLoop_focusOkay:
lda #2
ldx #WGSelectView
jsr WeeGUI
ldx #WGViewFocus
jsr WeeGUI
jmp keyLoop
keyLoop_quit:
ldx #WGDisableMouse
jsr WeeGUI
ldx #WGExit
jsr WeeGUI
rts
testPaintContentsClick:
; brk
testPaintContents:
lda #0
ldx #WGSelectView
jsr WeeGUI
ldx #WGEraseViewContents
jsr WeeGUI
stz PARAM0
stz PARAM1
ldx #WGSetCursor
jsr WeeGUI
; ldy #0
;testPaintContents_loop:
; ldx #0
; stx PARAM0
; sty PARAM1
; ldx #WGSetCursor
; jsr WeeGUI
; tya
; clc
; adc #'A'
; sta testStr3
;
; WGCALL16 WGPrint,testStr3
;
; iny
; cpy #25
; bne testPaintContents_loop
WGCALL16 WGPrint,testStr
testPaintContents_done:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; animateRects
; Strokes and paints rectangles of many different geometries
;
; Stack:
; Curr X
; Curr Y
; Curr Width
; Curr Height
animateRects:
ldx #WGClearScreen
jsr WeeGUI
testCallback:
jsr $ff3a ; boop!
animateRectsEven:
lda #38 ; Initialize
pha
lda #11
pha
lda #2
pha
lda #2
pha
animateRectsEvenLoop:
@0: lda $C019 ; Sync to VBL
bmi @0
ldx #WGClearScreen
jsr WeeGUI
tsx
inx
lda $0100,x ; Load Height, then modify
sta PARAM3
inc
inc
sta $0100,x
cmp #25
bcs animateRectsEvenDone
inx ; Load Width, then modify
lda $0100,x
sta PARAM2
inc
inc
inc
inc
inc
inc
sta $0100,x
inx ; Load Y, then modify
lda $0100,x
sta PARAM1
dec
sta $0100,x
inx ; Load X, then modify
lda $0100,x
sta PARAM0
dec
dec
dec
sta $0100,x
ldy #'Q'+$80
ldx #WGFillRect
jsr WeeGUI
ldx #WGStrokeRect
jsr WeeGUI
jsr delayShort
jsr delayShort
jsr delayShort
jmp animateRectsEvenLoop
animateRectsEvenDone:
pla
pla
pla
pla
animateRectsOdd:
lda #37 ; Initialize
pha
lda #11
pha
lda #2
pha
lda #2
pha
animateRectsOddLoop:
ldx #WGClearScreen
jsr WeeGUI
tsx
inx
lda $0100,x ; Load Height, then modify
sta PARAM3
inc
inc
sta $0100,x
cmp #25
bcs animateRectsOddDone
inx ; Load Width, then modify
lda $0100,x
sta PARAM2
inc
inc
inc
inc
inc
inc
sta $0100,x
inx ; Load Y, then modify
lda $0100,x
sta PARAM1
dec
sta $0100,x
inx ; Load X, then modify
lda $0100,x
sta PARAM0
dec
dec
dec
sta $0100,x
ldy #'Q'+$80
ldx #WGFillRect
jsr WeeGUI
ldx #WGStrokeRect
jsr WeeGUI
jsr delayShort
jsr delayShort
jsr delayShort
jmp animateRectsOddLoop
animateRectsOddDone:
pla
pla
pla
pla
jmp animateRectsEven
delayShort: ; ~1/30 sec
pha
phx
phy
ldy #$06 ; Loop a bit
delayShortOuter:
ldx #$ff
delayShortInner:
nop
nop
nop
nop
nop
nop
nop
dex
bne delayShortInner
dey
bne delayShortOuter
ply
plx
pla
rts
delay: ; ~1 sec
pha
phx
phy
ldy #$ce ; Loop a bunch
delayOuter:
ldx #$ff
delayInner:
nop
nop
nop
nop
nop
nop
nop
dex
bne delayInner
dey
bne delayOuter
ply
plx
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bloadCmdLine:
brunCmdLine:
.byte "BRUN weegui",$8d,0
testView:
.byte 0,1,7,3,62,18,62,40
testCheck:
.byte 1,16,4
.addr testTitle3
testButton1:
.byte 2,35,10,15
.addr testCallback
.addr testTitle1
testButton2:
.byte 3,35,13,15
.addr 0
.addr testTitle2
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 "@ABCDEFGHIJKLMNOPQ",13,"RSTUVWXYZ[\]^_ !",34,"#$%&'()*+,-./0123456789:;<=>?`abcdefghijklmno"
testStr2:
.byte "pqrstuvwxyz",0;//{|}~",$ff,0
testStr3:
.byte "x",0
testTitle0:
.byte "Nifty Window",0
testTitle1:
.byte "Okay",0
testTitle2:
.byte "Cancel",0
testTitle3:
.byte "More Magic",0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.include "unit_test.s"
; Suppress some linker warnings - Must be the last thing in the file
.SEGMENT "ZPSAVE"

Binary file not shown.