0
0
Fork 0
mirror of https://git.sr.ht/~rabbits/uxn synced 2024-11-25 15:25:12 +00:00

Check ROM is valid before loading.

This commit is contained in:
Andrew Alderwick 2021-11-08 18:31:33 +00:00
parent 4988b2214e
commit 7f0119599e
3 changed files with 21 additions and 8 deletions

View file

@ -0,0 +1,15 @@
@check-rom ( filename* -- 00 if the file doesn't exist or not a valid ROM
OR 01 if the ROM seems to be valid )
.File/name DEO2
#0001 .File/length DEO2
;&first-char .File/read DEO2
( did the file read okay? )
.File/success DEI2 ORA
( is the first character a LIT, LIT2, LITk or LIT2k? )
LIT &first-char $1 #9f AND #80 EQU
AND
JMP2r

View file

@ -12,14 +12,6 @@
.File/name DEO2
( return if file can't be found, or zero length )
#0001 .File/length DEO2
;&tmp .File/read DEO2
.File/success DEI2 ORA JMP JMP2r
( close the file so the next read starts at the beginning )
.File/name DEI2k ROT DEO2
( clear wst )
#ab
&wst-loop

View file

@ -182,6 +182,11 @@ RTN
DUP2 INC2 ;close-path JSR2
#0006 ++ DUP2 ;print-string JSR2
#0a .Console/write DEO
DUP2 ;check-rom JSR2 ,&valid JCN
POP2 RTN
&valid
;load-rom JSR2
RTN
@ -394,6 +399,7 @@ RTN
2729 2b2e 3032 3537 3a3d 3f42 4547 4a4d
5053 5659 5c5f 6265 686b 6e71 7477 7a7d
include projects/library/check-rom.tal
include projects/library/load-rom.tal
include projects/assets/logo05x05.tal