-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunk.z80
More file actions
291 lines (263 loc) · 6.94 KB
/
funk.z80
File metadata and controls
291 lines (263 loc) · 6.94 KB
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
.nolist
#ifndef funk
#define funk
;
; funk include file
; by Robert Kuhfss
;
;#define FUNK_DEBUG
;#define FUNK_DEBUG_BEGIN
;============================================
; > .funkinclude
;============================================
; Includes files from the funk directory
; using FUNK_PATH
;--------------------------------------------
#ifndef FUNK_PATH
#define FUNK_PATH "funk/"
#endif
#macro _funk_include(_include_file)
.echo > _funk_include.z80 "#include \"", FUNK_PATH, _include_file, "\""
#include _funk_include.z80
; .parse "#include \"", FUNK_PATH, _include_file, "\""
; parse macro doesn't work with include
#endmacro
#define .funkinclude _funk_include(
;============================================
; > primary includes
;============================================
.funkinclude "header/defines.z80"
.funkinclude "macros/funk_macros_logging.z80"
;============================================
; > .parse macro
;============================================
#macro _parse(_parse_1, _parse_2, _parse_3, _parse_4, _parse_5, _parse_6, _parse_7, _parse_8, _parse_9)
clr()
wr(_parse_1, _parse_2, _parse_3, _parse_4, _parse_5, _parse_6, _parse_7, _parse_8, _parse_9)
run()
#endmacro
#define .parse _parse(
;============================================
; > funk main definition
;============================================
; .funk ["NAME"="DEFAULT"], [TYPE=*nostub/mirageos/ion/app], [CALC=*ti83p/ti83]
#macro _funkdef(_funkdef_name, _funkdef_type, _funkdef_calc)
.debug "Entering '.funk'"
#ifdef funkdef_success
.err "Duplicate '.funk' found!"
#else
#ifdef _funkdef_name
#define funk_name concat("\"", _funkdef_name, "\"")
#else
; if not given, default to "DEFAULT"
#define funk_name "DEFAULT"
#endif
#ifdef _funkdef_type
#define funk_type eval(_funkdef_type)
#else
; if not given, default to nostub
.nostub
#endif
#ifdef _funkdef_calc
#define funk_calcmodel eval(_funkdef_calc)
#else
; if not given, default to ti83p
.ti83p
#endif
#if funk_calcmodel = ti83
#define _start_calcname "TI83"
.funkinclude "header/ti83.z80"
#define funk_ramStart saveSScreen
#endif
#if funk_calcmodel = ti83p
#define _start_calcname "TI83+"
.funkinclude "header/ti83p.z80"
#define funk_ramStart saveSScreen
#endif
.funkinclude "macros/funk_macros.z80"
#if funk_type = nostub
#define _start_option "Nostub"
.nostub
.progstart
bcall _runIndicOff
#endif
#if funk_type = app
#define _start_option "Application"
#if funk_calcmodel = ti83
.err "Calc model doesn't support apps"
#endif
.defpage 0, funk_name
.setup_funksetup
#endif
#if funk_type = custom
#define _start_option "Custom"
#endif
#if funk_type = ion
#define _start_option "ION"
.progstart
ret
jr nc, funk_start
#define funk_name_ptr eval($)
.str funk_name
#endif
#if funk_type = mirageos
#define _start_option "MirageOS"
#if funk_calcmodel = ti83
.err "Calc model doesn't support MirageOS"
#endif
.progstart
ret
.db 1
#include icon.z80 ; 15x15 icon
#define funk_name_ptr eval($)
.str funk_name
#endif
.echo "# FunkLibrary by Robert Kuhfss"
.echo "# Compiling \"", funk_name, "\" (", _start_option, ") for ", _start_calcname, " ..."
.varloc funk_ramStart, 768
#if funk_type != custom
funk_start
#endif
#ifdef FUNK_DEBUG_BEGIN
debug
#endif
#if funksetup_setup
.debug "Will call 'funk_setup' after start up"
call funk_setup
#endif
#define funkdef_success
#undef _start_option
#undef _start_calcname
#endif
#endmacro
#define .funk _funkdef(
;============================================
; > progstart
;============================================
#macro .progstart
#if funk_calcmodel = ti83
.org $9D95
#else
; default
.org $9D95 -2
.db $BB, $6D
#endif
#endmacro
;============================================
; > funk data
;============================================
#macro .setup_funkdata
#ifndef funkdata_setup
.echo > _funk_data.z80 ";* funk data include file\n\n"
#define funkdata_setup
#endif
#endmacro
#macro .include_funkdata
#ifdef funkdata_setup
#include _funk_data.z80
#undef funkdata_setup ; must be setup again
#endif
#endmacro
;============================================
; > funk setup
;============================================
#macro .setup_funksetup
#ifndef funksetup_setup
.echo > _funk_setup.z80 "; * funk setup include file\n"
.echo >> _funk_setup.z80 "funk_setup\n"
#define funksetup_setup
#endif
#endmacro
#macro .include_once_funksetup
#ifndef funksetup_included
#ifdef funksetup_setup
#include _funk_setup.z80
ret
#endif
#define funksetup_included
#endif
#endmacro
#macro _funkSetup(_setup_call)
.setup_funksetup
.echo >> _funk_setup.z80 " call ", _setup_call, "\n"
#endmacro
#define .funkSetup _funkSetup(
#define .setup _funkSetup(
;============================================
; > funk functions
;============================================
#macro .include_once_funkfunctions
#ifndef funkfunctions_included
.funkinclude "functions/funk_functions.z80"
#define funkfunctions_included
#endif
#endmacro
#macro .include_once_funkfunctions2
#ifndef funkfunctions2_included
.funkinclude "functions/funk_functions2.z80"
#define funkfunctions2_included
#endif
#endmacro
;============================================
; > funk delayed action
;============================================
#macro .setup_funkdelayed
#ifndef funkdelayed_setup
.echo > _funk_delayed.z80 ";* funk delayed include file\n\n"
#define funkdelayed_setup
#endif
#endmacro
#macro .include_once_funkdelayed
#ifndef funkdelayed_included
#ifdef funkdelayed_setup
#include _funk_delayed.z80
#endif
#define funkdelayed_included
#endif
#endmacro
#macro _funk_delay(_delay_1, _delay_2, _delay_3, _delay_4, _delay_5, _delay_6, _delay_7)
.setup_funkdelayed
.echo >> _funk_delayed.z80 _delay_1, _delay_2, _delay_3, _delay_4, _delay_5, _delay_6, _delay_7
#endmacro
#define .delay _funk_delay(
;============================================
; > funk end
;============================================
#macro .funkend
.debug "Entering '.funkend'"
#ifdef funkend_success
.err "Duplicate \".funkend\" found!"
#else
.include_once_funkfunctions
.include_once_funkfunctions2
.include_once_funksetup
#ifdef funkmake_graphics_success
.debug "Including '_funk_graphics.z80'"
#include funk_graphics/_funk_graphics.z80
#endif
.include_funkdata
.include_once_funkdelayed
#if funk_type = app
.validate
#else
#if funk_type != custom
.info "Program size: ", $ - funk_start, " bytes"
#if funk_type != app && $ >= $C000 ; ram limit
.warn "Ram execution limit reached (", $ - $C000, " overflow)"
#endif
#endif
#endif
#ifdef funk_test
#if Test.Errors = 1
.echo "# There was ", Test.Errors, " error."
#elif Test.Errors > 1
.echo "# There where ", Test.Errors, " errors."
#else
.echo "# There where no errors."
#endif
#endif
#define funkend_success
#endif
#endmacro
#endif ; funk
.list