Browse code

Add source code of the ROM

Pawel Jablonski authored on 14/12/2022 19:10:08
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,216 @@
1
+; Author: Pawel Jablonski
2
+; E-mail: pj@xirx.net
3
+; WWW: xirx.net
4
+; GIT: git.xirx.net
5
+;
6
+; License: You can use this code however you like
7
+; but leave information about the original author.
8
+; Code is free for non-commercial and commercial use.
9
+
10
+include io.asm
11
+
12
+; Arguments:
13
+; 	X - low address
14
+;	Y - high address
15
+; No return
16
+external .xFSSetName:
17
+	push A
18
+	push B
19
+	push X
20
+	push Y
21
+	mov 0, B
22
+.xFSSetName_loop:
23
+	; Check if it is a max length of name
24
+	; 11 < B
25
+	cmp 11, B
26
+	jl .xFSSetName_end
27
+	; Load char from RAM
28
+	ldr A
29
+	push A
30
+	; Select low address register
31
+	mov 2, A
32
+	call .xIOSetRegister
33
+	; Write offset of name
34
+	mov B, A
35
+	call .xIOWrite
36
+	; Select fs name register
37
+	mov 13, A
38
+	call .xIOSetRegister
39
+	; Write char of name
40
+	pop A
41
+	call .xIOWrite
42
+	; Check if it is end of string
43
+	cmp 0, A
44
+	je .xFSSetName_end
45
+	; Incrementing address
46
+	inc X
47
+	incc Y
48
+	; Increment offset of name
49
+	inc B
50
+	jmp .xFSSetName_loop
51
+.xFSSetName_end:
52
+	pop Y
53
+	pop X
54
+	pop B
55
+	pop A
56
+	ret
57
+
58
+; No arguments
59
+; Return:
60
+; 	A - success (0 - error, 1 - ok)
61
+global .xFSOpenApp:
62
+	; Select low address register
63
+	mov 2, A
64
+	call .xIOSetRegister
65
+	; Select open app command
66
+	mov 0, A
67
+	call .xIOWrite
68
+	; Select fs command register
69
+	mov 15, A
70
+	call .xIOSetRegister
71
+	; Clear value in A
72
+	mov 0, A
73
+	; Open app and get success status
74
+	call .xIOReadLowHalf
75
+	ret
76
+	
77
+; No arguments
78
+; Return:
79
+; 	A - success (0 - error, 1 - ok)
80
+external .xFSOpenFile:
81
+	; Select low address register
82
+	mov 2, A
83
+	call .xIOSetRegister
84
+	; Select open file command
85
+	mov 1, A
86
+	call .xIOWrite
87
+	; Select fs command register
88
+	mov 15, A
89
+	call .xIOSetRegister
90
+	; Clear value in A
91
+	mov 0, A
92
+	; Open app and get success status
93
+	call .xIOReadLowHalf
94
+	ret
95
+
96
+; No arguments
97
+; Return:
98
+; 	A - success (0 - error, 1 - ok)
99
+external .xFSListApp:
100
+	; Select low address register
101
+	mov 2, A
102
+	call .xIOSetRegister
103
+	; Select list app dir command
104
+	mov 2, A
105
+	call .xIOWrite
106
+	; Select fs command register
107
+	mov 15, A
108
+	call .xIOSetRegister
109
+	; Clear value in A
110
+	mov 0, A
111
+	; Open app and get success status
112
+	call .xIOReadLowHalf
113
+	ret
114
+
115
+; No arguments
116
+; Return:
117
+; 	A - success (0 - error, 1 - ok)
118
+external .xFSListFile:
119
+	; Select low address register
120
+	mov 2, A
121
+	call .xIOSetRegister
122
+	; Select list file dir command
123
+	mov 3, A
124
+	call .xIOWrite
125
+	; Select fs command register
126
+	mov 15, A
127
+	call .xIOSetRegister
128
+	; Clear value in A
129
+	mov 0, A
130
+	; Open app and get success status
131
+	call .xIOReadLowHalf
132
+	ret
133
+
134
+; No arguments
135
+; Return:
136
+; 	A - low byte
137
+;	B - high byte
138
+external .xFSSize:
139
+	; Select low address register
140
+	mov 2, A
141
+	call .xIOSetRegister
142
+	; Select size command
143
+	mov 4, A
144
+	call .xIOWrite
145
+	; Select high address register
146
+	mov 3, A
147
+	call .xIOSetRegister
148
+	; Select high byte of size
149
+	mov 1, A
150
+	call .xIOWrite
151
+	; Select fs command register
152
+	mov 15, A
153
+	call .xIOSetRegister
154
+	; Read high byte
155
+	call .xIORead
156
+	mov A, B
157
+	; Select high address register
158
+	mov 3, A
159
+	call .xIOSetRegister
160
+	; Select low byte of size
161
+	mov 0, A
162
+	call .xIOWrite
163
+	; Select fs command register
164
+	mov 15, A
165
+	call .xIOSetRegister
166
+	; Read low byte
167
+	call .xIORead
168
+	ret
169
+
170
+; Arguments:
171
+; 	A - block number
172
+;	X - low address
173
+;	Y - high address
174
+; No return
175
+external .xFSReadBlock:
176
+	push A
177
+	push B
178
+	push X
179
+	push Y
180
+	push A
181
+	; Select low address register
182
+	mov 2, A
183
+	call .xIOSetRegister
184
+	; Write block number
185
+	pop A
186
+	call .xIOWrite
187
+	; Select fs command register
188
+	mov 15, A
189
+	call .xIOSetRegister
190
+	; Write read block command
191
+	mov 5, A
192
+	call .xIOWriteLowHalf
193
+	; Select low address register
194
+	mov 2, A
195
+	call .xIOSetRegister
196
+	; Write byte number
197
+	clr A
198
+	call .xIOWrite
199
+	; Select fs data register
200
+	mov 14, A
201
+	call .xIOSetRegister
202
+	clr B
203
+.xFSReadBlock_loop:	
204
+	; Read byte from fs data
205
+	call .xIORead
206
+	; Copy byte to memory
207
+	str A
208
+	; Increment buffer address
209
+	inc X
210
+	incc Y
211
+	loope 255, B, .xFSReadBlock_loop
212
+	pop Y
213
+	pop X
214
+	pop B
215
+	pop A
216
+	ret