-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorix.mac
259 lines (231 loc) · 3.49 KB
/
orix.mac
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
.macro BRK_ORIX value
.byte $00,value
.endmacro
.macro RETURNVAL value
lda #value
sta KERNEL_ERRNO
.endmacro
.macro RETURN0
lda #$00
sta KERNEL_ERRNO
.endmacro
.macro PRINT_BINARY_TO_DECIMAL_16BITS justif
LDX #$20
STX DEFAFF
LDX #justif
BRK_ORIX XDECIM
;.byte $00,XDECIM
.endmacro
.macro CLS
lda #<SCREEN
ldy #>SCREEN
sta RES
sty RES+1
ldy #<(SCREEN+40+27*40)
ldx #>(SCREEN+40+27*40)
lda #' '
BRK_ORIX XFILLM
.endmacro
.macro SWITCH_ON_CURSOR
ldx #$00
BRK_ORIX XCSSCR
.endmacro
.macro SWITCH_OFF_CURSOR
ldx #$00
BRK_ORIX XCOSCR
.endmacro
.macro HIRES
BRK_ORIX XHIRES
.endmacro
;FIXME
.macro GET8_FROM_STRUCT offset, zpaddress
ldy #offset
lda (zpaddress),y
.endmacro
.macro PUT8_FROM_STRUCT offset, zpaddress
ldy #offset
sta (zpaddress),y
.endmacro
; O_WRONLY
; O_RDONLY
.macro FOPEN file, mode
lda #<file
ldx #>file
ldy #mode
.byte $00,XOPEN
.endmacro
.macro FOPEN_INTO_BANK7 file, mode
lda #<file
ldx #>file
ldy #mode
jsr XOPEN_ROUTINE
.endmacro
.macro MKDIR PATH
lda #<PATH
ldx #>PATH
.byte $00,XMKDIR
.endmacro
; size_t fread ( void * ptr, size_t size, FILE * stream);
.macro FREAD ptr, size, count, fp
lda #<fp
lda #>fp
lda #<ptr
sta PTR_READ_DEST
lda #>ptr
sta PTR_READ_DEST+1
lda #<size
ldy #>size
BRK_ORIX XFREAD
.endmacro
; This macro must be placed after MALLOC call
.macro TEST_OOM_AND_MAX_MALLOC
; Test if we reached the max number of malloc chunk
cpx #KERNEL_MAX_NUMBER_OF_MALLOC
bne @check_for_oom_TEST_OOM_AND_MAX_MALLOC
; We reachead max malloc available
PRINT str_max_malloc_reached
RETURN_LINE
rts
; check if malloc is null, if it's equal, displays Out of Memory
@check_for_oom_TEST_OOM_AND_MAX_MALLOC:
cmp #NULL
bne @TEST_OOM_AND_MAX_MALLOC
cpy #NULL
bne @TEST_OOM_AND_MAX_MALLOC
PRINT str_out_of_memory
RETURN_LINE
; We reached OOM
rts
@TEST_OOM_AND_MAX_MALLOC:
.endmacro
.macro CGETC
BRK_ORIX XRDW0
.endmacro
.macro MALLOC size
lda #<size
ldy #>size
BRK_ORIX XMALLOC
.endmacro
.macro FREE ptr
lda #<ptr
ldy #>ptr
BRK_ORIX XFREE
.endmacro
.macro CPUTC char
lda #char
BRK_ORIX XWR0
.endmacro
.macro PRINT_CHAR str
pha
sta TR6
txa
pha
tya
pha
lda TR6
BRK_TELEMON XWR0
pla
tay
pla
txa
pla
.endmacro
.macro PRINT str
pha
txa
pha
tya
pha
lda #<str
ldy #>str
BRK_TELEMON XWSTR0
pla
tay
pla
txa
pla
.endmacro
.macro PRINT_NOSAVE_REGISTER str
lda #<str
ldy #>str
BRK_TELEMON XWSTR0
.endmacro
.macro RETURN_LINE_INTO_TELEMON
pha
txa
pha
tya
pha
lda RES
pha
lda RES+1
pha
jsr XCRLF_ROUTINE
pla
sta RES+1
pla
sta RES
pla
tay
pla
txa
pla
.endmacro
.macro PRINT_INTO_TELEMON str
pha
txa
pha
tya
pha
lda RES
pha
lda RES+1
pha
lda #<str
ldy #>str
jsr XWSTR0_ROUTINE
pla
sta RES+1
pla
sta RES
pla
tay
pla
txa
pla
.endmacro
.macro RETURN_LINE
BRK_ORIX XCRLF
.endmacro
.macro STRCPY str1, str2
lda #<str1
sta RES
lda #>str1
sta RES+1
lda #<str2
sta RESB
lda #>str2
sta RESB+1
jsr _strcpy
.endmacro
.macro STRCAT str1, str2
lda #<str1
sta RES
lda #>str1
sta RES+1
lda #<str2
sta RESB
lda #>str2
sta RESB+1
jsr _strcat
.endmacro
; This macro copy AY address to str
.macro STRCPY_BY_AY_SRC str
sta RES
sty RES+1
lda #<str
sta RESB
lda #>str
sta RESB+1
jsr _strcpy
.endmacro