2014-08-29 19:19:19 +00:00
|
|
|
;
|
|
|
|
; gui.s
|
2014-09-10 03:34:14 +00:00
|
|
|
; Top level management routines
|
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.
|
|
|
|
;
|
|
|
|
|
|
|
|
|
2017-12-22 22:57:55 +00:00
|
|
|
.org $7800
|
2014-08-29 19:19:19 +00:00
|
|
|
|
|
|
|
; Common definitions
|
|
|
|
|
2014-09-07 23:06:25 +00:00
|
|
|
.include "zeropage.s"
|
2014-08-29 19:19:19 +00:00
|
|
|
.include "switches.s"
|
|
|
|
.include "macros.s"
|
|
|
|
|
|
|
|
|
2014-10-03 19:22:19 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; Main entry point. BRUN will land here.
|
2014-08-29 19:19:19 +00:00
|
|
|
main:
|
2014-09-06 03:32:16 +00:00
|
|
|
jsr WGInit
|
2014-10-03 19:22:19 +00:00
|
|
|
rts ; Don't add any bytes here!
|
|
|
|
|
|
|
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WGDispatch
|
|
|
|
; The dispatcher for calling the assembly-language API from assembly programs
|
|
|
|
; X: API call number
|
|
|
|
; P0-3,Y: Parameters to call, as needed
|
|
|
|
WGDispatch:
|
|
|
|
jmp (WGEntryPointTable,x)
|
|
|
|
|
|
|
|
; Entry point jump table
|
|
|
|
WGEntryPointTable:
|
|
|
|
.addr WGClearScreen
|
|
|
|
.addr WGDesktop
|
|
|
|
.addr WGSetCursor
|
|
|
|
.addr WGSetGlobalCursor
|
2014-10-11 23:12:15 +00:00
|
|
|
.addr WGSyncGlobalCursor
|
|
|
|
.addr WGPlot
|
|
|
|
.addr WGPrint
|
|
|
|
.addr WGFillRect
|
|
|
|
.addr WGStrokeRect
|
|
|
|
.addr WGFancyRect
|
|
|
|
.addr WGPaintView
|
|
|
|
.addr WGViewPaintAll
|
|
|
|
.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
|
2015-02-03 21:11:22 +00:00
|
|
|
.addr WGPendingClick
|
2014-10-11 23:12:15 +00:00
|
|
|
.addr WGScrollX
|
|
|
|
.addr WGScrollXBy
|
|
|
|
.addr WGScrollY
|
|
|
|
.addr WGScrollYBy
|
|
|
|
.addr WGEnableMouse
|
|
|
|
.addr WGDisableMouse
|
2015-01-25 01:17:38 +00:00
|
|
|
.addr WGDeleteView
|
|
|
|
.addr WGEraseView
|
2015-01-16 16:18:19 +00:00
|
|
|
.addr WGExit
|
2015-07-18 04:38:48 +00:00
|
|
|
.addr WGCreateProgress
|
2015-07-18 14:51:47 +00:00
|
|
|
.addr WGSetState
|
2017-12-21 23:50:50 +00:00
|
|
|
.addr WGViewSetRawTitle
|
|
|
|
|
2015-01-25 01:17:38 +00:00
|
|
|
|
2014-08-29 19:19:19 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2014-09-06 03:32:16 +00:00
|
|
|
; WGInit
|
|
|
|
; Initialization. Should be called once at app startup
|
|
|
|
WGInit:
|
2014-09-18 23:24:17 +00:00
|
|
|
SAVE_AXY
|
2014-09-06 03:32:16 +00:00
|
|
|
|
2015-01-03 00:01:38 +00:00
|
|
|
; Reserve our memory in the ProDOS allocator bitmap
|
|
|
|
;
|
|
|
|
; See section 5.1.4 in the ProDOS 8 Technical Reference Manual
|
|
|
|
; for an explanation of these values. We're reserving memory
|
2017-12-22 22:57:55 +00:00
|
|
|
; pages $78-$94 so that ProDOS won't use our memory for file
|
2015-01-03 00:01:38 +00:00
|
|
|
; buffers, or allow Applesoft to step on us
|
|
|
|
;
|
|
|
|
; Byte in System Bitmap : Bit within byte
|
2015-07-18 04:38:48 +00:00
|
|
|
; 0f:100
|
|
|
|
; 0f:011
|
|
|
|
; 0f:010
|
2015-01-03 00:01:38 +00:00
|
|
|
; 0f:001
|
|
|
|
; 0f:000
|
|
|
|
; 10:111 .. 10:000
|
|
|
|
; 11:111 .. 11:000
|
|
|
|
; 12:111
|
|
|
|
; 12:110
|
|
|
|
; 12:101
|
|
|
|
; 12:100
|
|
|
|
; 12:011
|
|
|
|
; 12:010
|
2017-12-22 22:57:55 +00:00
|
|
|
; lda #%00001111
|
|
|
|
; tsb MEMBITMAP + $0f
|
|
|
|
; lda #%11111111
|
|
|
|
; tsb MEMBITMAP + $10
|
|
|
|
; tsb MEMBITMAP + $11
|
|
|
|
; lda #%11111100
|
|
|
|
; tsb MEMBITMAP + $12
|
2015-01-03 00:01:38 +00:00
|
|
|
|
2015-02-13 16:10:54 +00:00
|
|
|
; Protect us from Applesoft by setting up HIMEM
|
2017-12-22 22:57:55 +00:00
|
|
|
; lda #$77 ; 7800 (really 77ff)
|
|
|
|
; sta LINNUMH
|
|
|
|
; lda #$ff
|
|
|
|
; sta LINNUML
|
|
|
|
; jsr SETHI
|
2015-02-13 16:10:54 +00:00
|
|
|
|
2015-01-03 00:01:38 +00:00
|
|
|
jsr WG80 ; Enter 80-col text mode
|
|
|
|
jsr WGInitApplesoft ; Set up Applesoft API
|
2014-09-06 03:32:16 +00:00
|
|
|
|
2014-09-18 23:24:17 +00:00
|
|
|
ldy #15 ; Clear our block allocators
|
|
|
|
WGInit_clearMemLoop:
|
|
|
|
tya
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
lda #0
|
|
|
|
sta WG_STRINGS,x
|
|
|
|
dey
|
|
|
|
bpl WGInit_clearMemLoop
|
|
|
|
|
2014-09-29 20:45:46 +00:00
|
|
|
lda #$ff
|
|
|
|
sta WG_PENDINGACTIONVIEW
|
|
|
|
sta WG_FOCUSVIEW
|
|
|
|
|
2014-09-18 23:24:17 +00:00
|
|
|
RESTORE_AXY
|
2014-09-06 03:32:16 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
2015-01-16 16:18:19 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
2015-02-13 16:10:54 +00:00
|
|
|
; WGExit
|
2015-01-16 16:18:19 +00:00
|
|
|
; Cleanup Should be called once at app shutdown
|
|
|
|
WGExit:
|
|
|
|
pha
|
|
|
|
|
|
|
|
lda #CHAR_NORMAL
|
|
|
|
sta INVERSE
|
|
|
|
|
2015-02-13 16:10:54 +00:00
|
|
|
; Restore HIMEM to ProDOS default
|
2017-12-22 22:57:55 +00:00
|
|
|
; lda #$96
|
|
|
|
; sta LINNUMH
|
|
|
|
; stz LINNUML
|
|
|
|
; jsr SETHI
|
2015-02-13 16:10:54 +00:00
|
|
|
|
2015-01-16 16:18:19 +00:00
|
|
|
; Remove ourselves from ProDOS memory map
|
2017-12-22 22:57:55 +00:00
|
|
|
; lda #%00001111
|
|
|
|
; trb MEMBITMAP + $0f
|
|
|
|
; lda #$ff
|
|
|
|
; trb MEMBITMAP + $10
|
|
|
|
; trb MEMBITMAP + $11
|
|
|
|
; lda #%11111100
|
|
|
|
; trb MEMBITMAP + $12
|
2015-01-16 16:18:19 +00:00
|
|
|
|
|
|
|
pla
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
2014-09-06 03:32:16 +00:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
; WG80
|
2014-08-29 19:19:19 +00:00
|
|
|
; Enables 80 column mode (and enhanced video firmware)
|
2014-09-06 03:32:16 +00:00
|
|
|
WG80:
|
2014-09-19 23:04:36 +00:00
|
|
|
pha
|
|
|
|
|
2014-08-29 19:19:19 +00:00
|
|
|
lda #$a0
|
|
|
|
jsr $c300
|
2014-09-19 23:04:36 +00:00
|
|
|
|
2014-08-29 19:19:19 +00:00
|
|
|
SETSWITCH TEXTON
|
|
|
|
SETSWITCH PAGE2OFF
|
|
|
|
SETSWITCH COL80ON
|
|
|
|
SETSWITCH STORE80ON
|
2014-09-19 23:04:36 +00:00
|
|
|
|
|
|
|
pla
|
2014-08-29 19:19:19 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
; Code modules
|
|
|
|
.include "utility.s"
|
|
|
|
.include "painting.s"
|
2014-09-07 23:06:25 +00:00
|
|
|
.include "rects.s"
|
2014-08-29 19:19:19 +00:00
|
|
|
.include "views.s"
|
2014-09-28 00:52:57 +00:00
|
|
|
.include "mouse.s"
|
2014-10-17 18:08:14 +00:00
|
|
|
.include "applesoft.s"
|
2014-08-29 19:19:19 +00:00
|
|
|
.include "memory.s"
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|