uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 7f0119599e77ebb26a95947e7c3a78a2e32d8b46
parent 4988b2214edd2b06135ddc8649d6a46507264235
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Mon,  8 Nov 2021 18:31:33 +0000

Check ROM is valid before loading.

Diffstat:
Aprojects/library/check-rom.tal | 15+++++++++++++++
Mprojects/library/load-rom.tal | 8--------
Mprojects/software/boot.tal | 6++++++
3 files changed, 21 insertions(+), 8 deletions(-)

diff --git a/projects/library/check-rom.tal b/projects/library/check-rom.tal @@ -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 + diff --git a/projects/library/load-rom.tal b/projects/library/load-rom.tal @@ -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 diff --git a/projects/software/boot.tal b/projects/software/boot.tal @@ -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