Browse code

Check ROM is valid before loading.

Andrew Alderwick authored on 08/11/2021 18:31:33
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,15 @@
1
+@check-rom ( filename* -- 00 if the file doesn't exist or not a valid ROM
2
+                       OR 01 if the ROM seems to be valid )
3
+	.File/name DEO2
4
+	#0001 .File/length DEO2
5
+	;&first-char .File/read DEO2
6
+
7
+	( did the file read okay? )
8
+	.File/success DEI2 ORA
9
+
10
+	( is the first character a LIT, LIT2, LITk or LIT2k? )
11
+	LIT &first-char $1 #9f AND #80 EQU
12
+
13
+	AND
14
+	JMP2r
15
+
... ...
@@ -12,14 +12,6 @@
12 12
 
13 13
 	.File/name DEO2
14 14
 
15
-	( return if file can't be found, or zero length )
16
-	#0001 .File/length DEO2
17
-	;&tmp .File/read DEO2
18
-	.File/success DEI2 ORA JMP JMP2r
19
-
20
-	( close the file so the next read starts at the beginning )
21
-	.File/name DEI2k ROT DEO2
22
-
23 15
 	( clear wst )
24 16
 	#ab
25 17
 	&wst-loop
... ...
@@ -182,6 +182,11 @@ RTN
182 182
 	DUP2 INC2 ;close-path JSR2
183 183
 	#0006 ++ DUP2 ;print-string JSR2
184 184
 	#0a .Console/write DEO
185
+
186
+	DUP2 ;check-rom JSR2 ,&valid JCN
187
+	POP2 RTN
188
+
189
+	&valid
185 190
 	;load-rom JSR2
186 191
 
187 192
 RTN
... ...
@@ -394,6 +399,7 @@ RTN
394 399
 	2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
395 400
 	5053 5659 5c5f 6265 686b 6e71 7477 7a7d
396 401
 
402
+include projects/library/check-rom.tal
397 403
 include projects/library/load-rom.tal
398 404
 
399 405
 include projects/assets/logo05x05.tal