2014-08-29 19:19:19 +00:00
|
|
|
;
|
2014-09-07 23:06:25 +00:00
|
|
|
; guidemo.s
|
2014-10-11 23:12:15 +00:00
|
|
|
; WeeGUI sample application
|
2014-08-29 19:19:19 +00:00
|
|
|
;
|
|
|
|
; Created by Quinn Dunki on 8/15/14.
|
|
|
|
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2014-10-11 23:12:15 +00:00
|
|
|
.include "WeeGUI_MLI.s"
|
2014-08-29 19:19:19 +00:00
|
|
|
|
|
|
|
|
2014-10-11 23:12:15 +00:00
|
|
|
.org $6000
|
2014-08-29 19:19:19 +00:00
|
|
|
|
2014-10-11 23:12:15 +00:00
|
|
|
INBUF = $0200
|
|
|
|
DOSCMD = $be03
|
|
|
|
KBD = $c000
|
|
|
|
KBDSTRB = $c010
|
2014-08-29 19:19:19 +00:00
|
|
|
|
|
|
|
|
2014-10-11 23:12:15 +00:00
|
|
|
.macro WGCALL16 func,addr
|
|
|
|
lda #<addr
|
2014-10-03 19:22:19 +00:00
|
|
|
sta PARAM0
|
2014-10-11 23:12:15 +00:00
|
|
|
lda #>addr
|
2014-10-03 19:22:19 +00:00
|
|
|
sta PARAM1
|
2014-10-11 23:12:15 +00:00
|
|
|
ldx #func
|
2014-10-03 19:22:19 +00:00
|
|
|
jsr WeeGUI
|
2014-10-11 23:12:15 +00:00
|
|
|
.endmacro
|
2014-08-29 19:19:19 +00:00
|
|
|
|
|
|
|
|
2014-10-11 23:12:15 +00:00
|
|
|
; Sample code
|
|
|
|
main:
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-01-03 00:01:38 +00:00
|
|
|
; BRUN the GUI library
|
2014-10-11 23:12:15 +00:00
|
|
|
ldx #0
|
|
|
|
ldy #0
|
2015-02-08 01:39:18 +00:00
|
|
|
@0: lda brunCmdLine,x
|
2014-10-11 23:12:15 +00:00
|
|
|
beq @1
|
|
|
|
sta INBUF,y
|
|
|
|
inx
|
|
|
|
iny
|
|
|
|
bra @0
|
|
|
|
@1: jsr DOSCMD
|
2014-10-02 21:59:13 +00:00
|
|
|
|
|
|
|
|
2014-10-11 23:12:15 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; Show off some WeeGUI features
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
jmp animateRects
|
2015-01-01 23:56:32 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
ldx #WGClearScreen
|
2014-10-11 23:12:15 +00:00
|
|
|
jsr WeeGUI
|
2014-10-02 21:59:13 +00:00
|
|
|
|
|
|
|
keyLoop:
|
2014-10-11 23:12:15 +00:00
|
|
|
ldx #WGPendingViewAction
|
|
|
|
jsr WeeGUI
|
2014-10-02 21:59:13 +00:00
|
|
|
|
|
|
|
lda KBD
|
|
|
|
bpl keyLoop
|
|
|
|
sta KBDSTRB
|
|
|
|
|
|
|
|
and #%01111111
|
|
|
|
cmp #113
|
|
|
|
beq keyLoop_quit
|
|
|
|
|
|
|
|
jmp keyLoop
|
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
keyLoop_quit:
|
|
|
|
ldx #WGExit
|
2014-10-11 23:12:15 +00:00
|
|
|
jsr WeeGUI
|
2015-02-08 01:39:18 +00:00
|
|
|
rts
|
2014-10-02 21:59:13 +00:00
|
|
|
|
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; animateRects
|
|
|
|
; Strokes and paints rectangles of many different geometries
|
|
|
|
;
|
|
|
|
; Stack:
|
|
|
|
; Curr X
|
|
|
|
; Curr Y
|
|
|
|
; Curr Width
|
|
|
|
; Curr Height
|
|
|
|
animateRects:
|
|
|
|
ldx #WGClearScreen
|
2014-10-11 23:12:15 +00:00
|
|
|
jsr WeeGUI
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
animateRectsEven:
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
lda #38 ; Initialize
|
|
|
|
pha
|
|
|
|
lda #11
|
|
|
|
pha
|
|
|
|
lda #2
|
|
|
|
pha
|
|
|
|
lda #2
|
|
|
|
pha
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
animateRectsEvenLoop:
|
|
|
|
@0: lda $C019 ; Sync to VBL
|
|
|
|
bmi @0
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
ldx #WGClearScreen
|
2014-10-11 23:12:15 +00:00
|
|
|
jsr WeeGUI
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
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
|
2014-10-11 23:12:15 +00:00
|
|
|
jsr WeeGUI
|
2015-02-08 01:39:18 +00:00
|
|
|
ldx #WGStrokeRect
|
2015-01-16 16:18:19 +00:00
|
|
|
jsr WeeGUI
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
jsr delayShort
|
|
|
|
jsr delayShort
|
|
|
|
jsr delayShort
|
2014-10-25 19:01:14 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
jmp animateRectsEvenLoop
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
animateRectsEvenDone:
|
|
|
|
pla
|
|
|
|
pla
|
|
|
|
pla
|
|
|
|
pla
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
animateRectsOdd:
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
lda #37 ; Initialize
|
|
|
|
pha
|
|
|
|
lda #11
|
|
|
|
pha
|
|
|
|
lda #2
|
|
|
|
pha
|
|
|
|
lda #2
|
|
|
|
pha
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
animateRectsOddLoop:
|
|
|
|
ldx #WGClearScreen
|
|
|
|
jsr WeeGUI
|
2014-10-02 21:59:13 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
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
|
2014-10-11 23:12:15 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
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
|
2014-10-11 23:12:15 +00:00
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
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
|
2014-10-02 21:59:13 +00:00
|
|
|
rts
|
|
|
|
|
2014-10-11 23:12:15 +00:00
|
|
|
|
|
|
|
|
2014-10-02 21:59:13 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
2015-02-08 01:39:18 +00:00
|
|
|
brunCmdLine:
|
2015-01-03 00:01:38 +00:00
|
|
|
.byte "BRUN weegui",$8d,0
|
2014-10-11 23:12:15 +00:00
|
|
|
|
|
|
|
|
2014-09-07 23:06:25 +00:00
|
|
|
; Suppress some linker warnings - Must be the last thing in the file
|
|
|
|
.SEGMENT "ZPSAVE"
|
|
|
|
.SEGMENT "EXEHDR"
|
|
|
|
.SEGMENT "STARTUP"
|
|
|
|
.SEGMENT "INIT"
|
|
|
|
.SEGMENT "LOWCODE"
|