WeeGUI/asmdemo.s

294 lines
3.2 KiB
ArmAsm
Raw Normal View History

2014-08-29 19:19:19 +00:00
;
; guidemo.s
; 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.
;
.include "WeeGUI_MLI.s"
2014-08-29 19:19:19 +00:00
.org $6000
2014-08-29 19:19:19 +00:00
INBUF = $0200
DOSCMD = $be03
KBD = $c000
KBDSTRB = $c010
2014-08-29 19:19:19 +00:00
.macro WGCALL16 func,addr
lda #<addr
sta PARAM0
lda #>addr
sta PARAM1
ldx #func
jsr WeeGUI
.endmacro
2014-08-29 19:19:19 +00:00
; Sample code
main:
2014-10-02 21:59:13 +00:00
; BRUN the GUI library
ldx #0
ldy #0
2015-02-08 01:39:18 +00:00
@0: lda brunCmdLine,x
beq @1
sta INBUF,y
inx
iny
bra @0
@1: jsr DOSCMD
2014-10-02 21:59:13 +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-02-08 01:39:18 +00:00
ldx #WGClearScreen
jsr WeeGUI
2014-10-02 21:59:13 +00:00
keyLoop:
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
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
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
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
jsr WeeGUI
2015-02-08 01:39:18 +00:00
ldx #WGStrokeRect
jsr WeeGUI
2014-10-02 21:59:13 +00:00
2015-02-08 01:39:18 +00:00
jsr delayShort
jsr delayShort
jsr delayShort
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
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
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-02 21:59:13 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2015-02-08 01:39:18 +00:00
brunCmdLine:
.byte "BRUN weegui",$8d,0
; Suppress some linker warnings - Must be the last thing in the file
.SEGMENT "ZPSAVE"
.SEGMENT "EXEHDR"
.SEGMENT "STARTUP"
.SEGMENT "INIT"
.SEGMENT "LOWCODE"