-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathweegui.s
199 lines (165 loc) · 3.58 KB
/
weegui.s
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
;
; gui.s
; Top level management routines
;
; Created by Quinn Dunki on 8/15/14.
; Copyright (c) 2014 One Girl, One Laptop Productions. All rights reserved.
;
.org $4000
; Common definitions
.include "zeropage.s"
.include "switches.s"
.include "macros.s"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Main entry point. BRUN will land here.
main:
jsr WGInit
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
.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
.addr WGPendingClick
.addr WGScrollX
.addr WGScrollXBy
.addr WGScrollY
.addr WGScrollYBy
.addr WGEnableMouse
.addr WGDisableMouse
.addr WGDeleteView
.addr WGEraseView
.addr WGExit
.addr WGCreateProgress
.addr WGSetState
.addr WGViewSetRawTitle
.addr WGSetContentWidth
.addr WGSetContentHeight
.addr WGStrokeRoundRect
.addr WGCreateRadio
.addr WGResetAll
.addr WGGetState
.addr WGPendingClick
.addr WGClearPendingClick
.addr WGResetView
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGInit
; Initialization. Should be called once at app startup
WGInit:
SAVE_AXY
; Protect us from Applesoft by setting up HIMEM
; lda #$3f ; 4000 (really 3fff)
; sta LINNUMH
; lda #$ff
; sta LINNUML
; jsr SETHI
jsr WG80 ; Enter 80-col text mode
jsr WGInitApplesoft ; Set up Applesoft API
RESTORE_AXY
jmp WGResetAll
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGResetAll
; Reset all views and strings. Called from WGInit during app startup.
; Can also be called at any time to "start over" with no views.
; (Does not clear screen or repaint.)
;
WGResetAll:
SAVE_AXY
ldy #15 ; Clear our block allocators
WGInit_clearMemLoop:
tya
asl
asl
asl
asl
tax
stz WG_VIEWRECORDS+2,x
stz WG_STRINGS,x
dey
bpl WGInit_clearMemLoop
lda #$ff
sta WG_PENDINGACTIONVIEW
sta WG_FOCUSVIEW
RESTORE_AXY
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WGExit
; Cleanup Should be called once at app shutdown
WGExit:
pha
lda #CHAR_NORMAL
sta INVERSE
; Restore HIMEM to ProDOS default
; lda #$96
; sta LINNUMH
; stz LINNUML
; jsr SETHI
; Remove ourselves from ProDOS memory map
; lda #%00001111
; trb MEMBITMAP + $0f
; lda #$ff
; trb MEMBITMAP + $10
; trb MEMBITMAP + $11
; lda #%11111100
; trb MEMBITMAP + $12
pla
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; WG80
; Enables 80 column mode (and enhanced video firmware)
WG80:
pha
lda #$a0
jsr $c300
SETSWITCH TEXTON
SETSWITCH PAGE2OFF
SETSWITCH COL80ON
SETSWITCH STORE80ON
pla
rts
; Code modules
.include "utility.s"
.include "painting.s"
.include "rects.s"
.include "views.s"
.include "mouse.s"
.include "mouse_gs.s"
.include "applesoft.s"
.include "memory.s"
; Suppress some linker warnings - Must be the last thing in the file
.SEGMENT "ZPSAVE"
.SEGMENT "EXEHDR"
.SEGMENT "STARTUP"
.SEGMENT "INIT"
.SEGMENT "LOWCODE"
.SEGMENT "ONCE"