- Implemented most of MLI

- Code cleanup
- GUIDEMO is now the demo for the MLI
This commit is contained in:
Quinn Dunki 2014-10-11 16:12:15 -07:00
parent 38da3a2c8e
commit fd53a53a85
7 changed files with 324 additions and 140 deletions

View File

@ -22,6 +22,7 @@
70F1DB4B19A56D6300321637 /* switches.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = switches.s; sourceTree = "<group>"; }; 70F1DB4B19A56D6300321637 /* switches.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = switches.s; sourceTree = "<group>"; };
70F1DB5619A6B02900321637 /* painting.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = painting.s; sourceTree = "<group>"; }; 70F1DB5619A6B02900321637 /* painting.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = painting.s; sourceTree = "<group>"; };
70F1DB5D19A7FF8700321637 /* memory.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = memory.s; sourceTree = "<group>"; }; 70F1DB5D19A7FF8700321637 /* memory.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = memory.s; sourceTree = "<group>"; };
70FB05F119DF5B0900573690 /* WeeGUI_MLI.s */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = WeeGUI_MLI.s; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXGroup section */ /* Begin PBXGroup section */
@ -39,6 +40,7 @@
70868EE019BD150C00E4B4CB /* rects.s */, 70868EE019BD150C00E4B4CB /* rects.s */,
709E88E319AC0A5F0069DB55 /* views.s */, 709E88E319AC0A5F0069DB55 /* views.s */,
70A3A2C219BFE2C3006A2EC4 /* applesoft.s */, 70A3A2C219BFE2C3006A2EC4 /* applesoft.s */,
70FB05F119DF5B0900573690 /* WeeGUI_MLI.s */,
70427F2219D648730031D960 /* mouse.s */, 70427F2219D648730031D960 /* mouse.s */,
70D435B219A013AF001BFD9B /* gui.s */, 70D435B219A013AF001BFD9B /* gui.s */,
709E88E419AC0DC20069DB55 /* unit_test.s */, 709E88E419AC0DC20069DB55 /* unit_test.s */,

65
WeeGUI_MLI.s Normal file
View File

@ -0,0 +1,65 @@
;
; WeeGUI_MLI.s
; Machine Language API for WeeGUI
;
; Created by Quinn Dunki on 8/15/14.
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Reserved zero page locations
;
PARAM0 = $06
PARAM1 = $07
PARAM2 = $08
PARAM3 = $09
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WeeGUI entry point
; Set up your call, then do a JSR to this address.
;
WeeGUI = $4004
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; API call names, to be passed to WeeGUI via X register
; e.g.
; ldx #WGDesktop
; jsr WeeGUI
;
WGClearScreen = 0
WGDesktop = 2
WGSetCursor = 4
WGSetGlobalCursor = 6
WGSyncGlobalCursor = 8
WGPlot = 10
WGPrint = 12
WGFillRect = 14
WGStrokeRect = 16
WGFancyRect = 18
WGPaintView = 20
WGViewPaintAll = 22
WGEraseView = 24
WGEraseViewContents = 26
WGCreateView = 28
WGCreateCheckbox = 30
WGCreateButton = 32
WGViewSetTitle = 34
WGViewSetAction = 36
WGSelectView = 38
WGViewFromPoint = 40
WGViewFocus = 42
WGViewUnfocus = 44
WGViewFocusNext = 46
WGViewFocusPrev = 48
WGViewFocusAction = 50
WGPendingViewAction = 52
WGPendingView = 54
WGScrollX = 56
WGScrollXBy = 58
WGScrollY = 60
WGScrollYBy = 62
WGEnableMouse = 64
WGDisableMouse = 66

32
gui.s
View File

@ -40,9 +40,38 @@ WGDispatch:
WGEntryPointTable: WGEntryPointTable:
.addr WGClearScreen .addr WGClearScreen
.addr WGDesktop .addr WGDesktop
.addr WGPlot
.addr WGSetCursor .addr WGSetCursor
.addr WGSetGlobalCursor .addr WGSetGlobalCursor
.addr WGSyncGlobalCursor
.addr WGPlot
.addr WGPrint
.addr WGFillRect
.addr WGStrokeRect
.addr WGFancyRect
.addr WGPaintView
.addr WGViewPaintAll
.addr WGEraseView
.addr WGEraseViewContents
.addr WGCreateView
.addr WGCreateCheckbox
.addr WGCreateButton
.addr WGViewSetTitle
.addr WGViewSetAction
.addr WGSelectView
.addr WGViewFromPoint
.addr WGViewFocus
.addr WGViewUnfocus
.addr WGViewFocusNext
.addr WGViewFocusPrev
.addr WGViewFocusAction
.addr WGPendingViewAction
.addr WGPendingView
.addr WGScrollX
.addr WGScrollXBy
.addr WGScrollY
.addr WGScrollYBy
.addr WGEnableMouse
.addr WGDisableMouse
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -100,7 +129,6 @@ WG80:
.include "views.s" .include "views.s"
.include "mouse.s" .include "mouse.s"
.include "applesoft.s" .include "applesoft.s"
;.include "unit_test.s"
.include "memory.s" .include "memory.s"

Binary file not shown.

308
guidemo.s
View File

@ -1,52 +1,201 @@
; ;
; guidemo.s ; guidemo.s
; AssemblyTest ; WeeGUI sample application
; ;
; Created by Quinn Dunki on 8/15/14. ; Created by Quinn Dunki on 8/15/14.
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
; ;
.include "WeeGUI_MLI.s"
.org $6000 .org $6000
; Reserved locations INBUF = $0200
PARAM0 = $06 DOSCMD = $be03
PARAM1 = $07 KBD = $c000
PARAM2 = $08 KBDSTRB = $c010
PARAM3 = $09
; WeeGUI entry points .macro WGCALL16 func,addr
WeeGUI = $4004 lda #<addr
sta PARAM0
WGClearScreen = 0 lda #>addr
WGDesktop = 2 sta PARAM1
WGPlot = 4 ldx #func
WGSetCursor = 6 jsr WeeGUI
WGSetGlobalCursor = 8 .endmacro
; Sample code ; Sample code
main: main:
; BLOAD the GUI library
ldx #0
ldy #0
@0: lda bloadCmdLine,x
beq @1
sta INBUF,y
inx
iny
bra @0
@1: jsr DOSCMD
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Show off some WeeGUI features
ldx #WGClearScreen ldx #WGClearScreen
jsr WeeGUI jsr WeeGUI
ldx #WGDesktop ldx #WGDesktop
jsr WeeGUI jsr WeeGUI
lda #40 WGCALL16 WGCreateView,testView
sta PARAM0 WGCALL16 WGViewSetTitle,testTitle0
lda #12 WGCALL16 WGCreateCheckbox,testCheck
sta PARAM1 WGCALL16 WGCreateButton,testButton1
ldx #WGSetGlobalCursor WGCALL16 WGCreateButton,testButton2
ldx #WGViewPaintAll
jsr WeeGUI jsr WeeGUI
lda #'Q'+$80 lda #0
ldx #WGPlot ldx #WGSelectView
jsr WeeGUI jsr WeeGUI
ldx #WGEnableMouse
jsr WeeGUI
keyLoop:
ldx #WGPendingViewAction
jsr WeeGUI
lda KBD
bpl 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
rts rts
testPaintContents:
lda #0
ldx #WGSelectView
jsr WeeGUI
ldx #WGEraseViewContents
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
testPaintContents_done:
rts
testCallback:
jsr $ff3a ; boop!
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.if 0 .if 0
;jmp tortureTestPrint ;jmp tortureTestPrint
;jmp tortureTestRects ;jmp tortureTestRects
@ -78,90 +227,6 @@ main:
jsr WGEnableMouse jsr WGEnableMouse
keyLoop:
jsr WGPendingViewAction
lda KBD
bpl 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:
jsr WGViewFocusNext
jmp keyLoop
keyLoop_focusPrev:
jsr WGViewFocusPrev
jmp keyLoop
keyLoop_toggle:
jsr WGViewFocusAction
jmp keyLoop
keyLoop_leftArrow:
lda #1
jsr WGScrollXBy
jsr testPaintContents
jmp keyLoop
keyLoop_rightArrow:
lda #-1
jsr WGScrollXBy
jsr testPaintContents
jmp keyLoop
keyLoop_upArrow:
lda #1
jsr WGScrollYBy
jsr testPaintContents
jmp keyLoop
keyLoop_downArrow:
lda #-1
jsr WGScrollYBy
jsr testPaintContents
jmp keyLoop
keyLoop_focusOkay:
lda #2
jsr WGSelectView
jsr WGViewFocus
jmp keyLoop
keyLoop_quit:
jsr WGDisableMouse
rts ; This seems to work for returning to BASIC.SYSTEM, but I don't know if it's right
testPaintContents:
SAVE_AXY
lda #0
jsr WGSelectView
jsr WGEraseViewContents
;; ;;
jsr WGNormal jsr WGNormal
@ -176,38 +241,19 @@ testPaintContents:
;; ;;
ldy #0
testPaintContents_loop:
ldx #0
stx PARAM0
sty PARAM1
jsr WGSetCursor
tya
clc
adc #'A'
sta testStr3
CALL16 WGPrint,testStr3
iny
cpy #25
bne testPaintContents_loop
testPaintContents_done:
RESTORE_AXY
rts
testCallback: testCallback:
jsr $ff3a jsr $ff3a
rts rts
rts rts
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
bloadCmdLine:
.byte "BRUN gui",$8d,0
testView: testView:
.byte 0,1,7,3,62,18,62,40 .byte 0,1,7,3,62,18,62,40
@ -242,10 +288,14 @@ testTitle2:
testTitle3: testTitle3:
.byte "More Magic",0 .byte "More Magic",0
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.include "unit_test.s"
; Suppress some linker warnings - Must be the last thing in the file ; Suppress some linker warnings - Must be the last thing in the file
.SEGMENT "ZPSAVE" .SEGMENT "ZPSAVE"
.SEGMENT "EXEHDR" .SEGMENT "EXEHDR"

View File

@ -8,7 +8,7 @@
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved. ; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
; ;
.if 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; tortureTestPrint ; tortureTestPrint
; Prints strings in a range of positions and scrolling offsets ; Prints strings in a range of positions and scrolling offsets
@ -126,6 +126,7 @@ tortureTestPrint_reset:
tortureTestPrint_lock: tortureTestPrint_lock:
jmp tortureTestPrint_lock jmp tortureTestPrint_lock
.endif
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; tortureTestRects ; tortureTestRects
@ -137,7 +138,8 @@ tortureTestPrint_lock:
; Curr Width ; Curr Width
; Curr Height ; Curr Height
tortureTestRects: tortureTestRects:
jsr WGClearScreen ldx #WGClearScreen
jsr WeeGUI
tortureTestRectsEven: tortureTestRectsEven:
@ -151,7 +153,11 @@ tortureTestRectsEven:
pha pha
tortureTestRectsEvenLoop: tortureTestRectsEvenLoop:
jsr WGClearScreen @0: lda $C019 ; Sync to VBL
bmi @0
ldx #WGClearScreen
jsr WeeGUI
tsx tsx
inx inx
@ -189,8 +195,10 @@ tortureTestRectsEvenLoop:
sta $0100,x sta $0100,x
ldy #'Q'+$80 ldy #'Q'+$80
jsr WGFillRect ldx #WGFillRect
jsr WGStrokeRect jsr WeeGUI
ldx #WGStrokeRect
jsr WeeGUI
jsr delayShort jsr delayShort
jsr delayShort jsr delayShort
@ -216,7 +224,8 @@ tortureTestRectsOdd:
pha pha
tortureTestRectsOddLoop: tortureTestRectsOddLoop:
jsr WGClearScreen ldx #WGClearScreen
jsr WeeGUI
tsx tsx
inx inx
@ -254,8 +263,10 @@ tortureTestRectsOddLoop:
sta $0100,x sta $0100,x
ldy #'Q'+$80 ldy #'Q'+$80
jsr WGFillRect ldx #WGFillRect
jsr WGStrokeRect jsr WeeGUI
ldx #WGStrokeRect
jsr WeeGUI
jsr delayShort jsr delayShort
jsr delayShort jsr delayShort
@ -273,6 +284,34 @@ tortureTestRectsOddDone:
delayShort:
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
testPrintView: testPrintView:
.byte "000F061E0A287E" ; 0, 7,3,62,19,75,126 .byte "000F061E0A287E" ; 0, 7,3,62,19,75,126

View File

@ -873,7 +873,7 @@ WGViewFocusAction_knownRTS:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGPendingViewAction ; WGPendingViewAction
; Performs the action of the pending view, if any ; Performs the action of the pending view, if any
; OUT V : Set if the caller should perform an Applesoft GOSUB ; Global flag set if the caller should perform an Applesoft GOSUB
; Side effects: Changes selected view, Repaints some views ; Side effects: Changes selected view, Repaints some views
; ;
WGPendingViewAction: WGPendingViewAction: