update file device and fix padding lengths

This commit is contained in:
Iris Lightshard 2021-12-01 13:04:51 -07:00
parent abf36856d9
commit 614c886436
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
2 changed files with 218 additions and 227 deletions

View file

@ -29,7 +29,7 @@
|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|a0 @File [ &vector $2 &success $2 &offset-hs $2 &offset-ls $2 &name $2 &length $2 &load $2 &save $2 ] |a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables ) ( variables )
@ -71,7 +71,6 @@
#0200 .Screen/width DEO2 #0200 .Screen/width DEO2
#0110 .Screen/height DEO2 #0110 .Screen/height DEO2
( initialize state ) ( initialize state )
#00 .ticker STZ #00 .ticker STZ
#00 .state STZ #00 .state STZ
@ -82,7 +81,7 @@
;carts-file .File/name DEO2 ;carts-file .File/name DEO2
#2000 .File/length DEO2 #2000 .File/length DEO2
;list-buf .File/load DEO2 ;list-buf .File/read DEO2
.File/success DEI2 .list-len STZ2 .File/success DEI2 .list-len STZ2
CENTER-X .logo-coords/x STZ2 CENTER-X .logo-coords/x STZ2
@ -182,6 +181,10 @@ BRK
POP POP
BRK BRK
&state6 &state6
[ ;load-cmd
CENTER-X OVR2 ;strlen JSR2 #20 SFT2 SUB2
CENTER-Y #0004 SUB
#02 ] ;draw-string JSR2
POP POP
BRK BRK
@ -832,117 +835,111 @@ RTN
@load-cart ( -> ) @load-cart ( -> )
.state LDZ INC .state STZ .state LDZ INC .state STZ
;cart ;load-rom JSR2 ;cart ;load-rom JSR2
RTN RTN
@load-rom ( filename* -- ) @load-rom ( filename* -- )
( (
Attempts to load the ROM from filename* and executes it. If the file exists Attempts to load the ROM from filename* and executes it. If the file exists
and has non-zero length, this function does not return, because the new ROM and has non-zero length, this function does not return, because the new ROM
is executing in its place. is executing in its place.
The screen and both stacks are cleared and all the device vectors are The screen and both stacks are cleared and all the device vectors are
written to zero as a convenience. All other device bytes are left written to zero as a convenience. All other device bytes are left
untouched, so they could introduce a device state to the next ROM that untouched, so they could introduce a device state to the next ROM that
it's not expecting. it's not expecting.
) )
.File/name DEO2 .File/name DEO2
#0000 .File/offset-hs DEO2
#0000 .File/offset-ls DEO2 ( clear wst )
#ab
( return if file can't be found, or zero length ) &wst-loop
#0001 .File/length DEO2 POP
;&tmp .File/load DEO2 .System/wst STH DEIr STHr ,&wst-loop JCN
.File/success DEI2 ORA JMP JMP2r
( clear rst )
( clear wst ) LITr ab
#ab &rst-loop
&wst-loop POPr
POP .System/rst DEI ,&rst-loop JCN
.System/wst STH DEIr STHr ,&wst-loop JCN
( clear screen )
( clear rst ) #01 .Screen/auto DEO
LITr ab #0000 .Screen/y DEO2
&rst-loop .Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2
POPr &screen-yloop
.System/rst DEI ,&rst-loop JCN #0000 .Screen/x DEO2
STH2kr
( clear screen ) &screen-xloop-bg
#01 .Screen/auto DEO #00 .Screen/sprite DEO
#0000 .Screen/y DEO2 INC2
.Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2 ORAk ,&screen-xloop-bg JCN
&screen-yloop POP2
#0000 .Screen/x DEO2 #0000 .Screen/x DEO2
STH2kr STH2kr
&screen-xloop-bg &screen-xloop-fg
#00 .Screen/sprite DEO #40 .Screen/sprite DEO
INC2 INC2
ORAk ,&screen-xloop-bg JCN ORAk ,&screen-xloop-fg JCN
POP2 POP2
#0000 .Screen/x DEO2 .Screen/y DEI2 #0008 ADD2
STH2kr DUP2 .Screen/y DEO2
&screen-xloop-fg .Screen/height DEI2 LTH2 ,&screen-yloop JCN
#40 .Screen/sprite DEO POP2r
INC2 #00 .Screen/auto DEO
ORAk ,&screen-xloop-fg JCN
POP2 ( reset device vectors )
.Screen/y DEI2 #0008 ADD2 LIT2r 0000 #00
DUP2 .Screen/y DEO2 &device-vector-loop
.Screen/height DEI2 LTH2 ,&screen-yloop JCN DUP2r STHk DEO2r
POP2r #10 ADD
#00 .Screen/auto DEO DUP ,&device-vector-loop JCN
POP POP2r
( reset device vectors )
LIT2r 0000 #00 ( copy the zero-page-loader into f0-ff )
&device-vector-loop ;&zero-page-loader LITr f0
DUP2r STHk DEO2r &copy-loop
#10 ADD LDAk STHkr STZ
DUP ,&device-vector-loop JCN INC2 INCr
POP POP2r STHkr ,&copy-loop JCN
POP2 ( leave 00 on return stack )
( copy the zero-page-loader into f0-ff )
;&zero-page-loader LITr f0 ( prepare the stack for the zero-page-loader )
&copy-loop ( the more we prepare here in advance, the less we'll have to overwrite )
LDAk STHkr STZ STHkr #00fe ( arguments for STZ2 at ff )
INC2 INCr STHkr ( argument for JMP at fe (carry on) )
STHkr ,&copy-loop JCN DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) )
POP2 ( leave 00 on return stack ) OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) )
( prepare the stack for the zero-page-loader ) OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
( the more we prepare here in advance, the less we'll have to overwrite ) OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 )
STHkr #00fe ( arguments for STZ2 at ff ) STHkr ( first argument for ADD2 )
STHkr ( argument for JMP at fe (carry on) ) .File/success ( argument for DEI2 )
DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) ) #0100 .File/read ( arguments for DEO2 )
OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) ) #ff00 .File/length DEO2
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) ) #00f0 JMP2
OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 ) &zero-page-loader
STHkr ( first argument for ADD2 ) ( f0 ) DEO2
.File/success ( argument for DEI2 ) ( f1 ) DEI2
#0100 .File/load ( arguments for DEO2 ) ( f2 ) ADD2
#ff00 .File/length DEO2 ( f3 ) &loop DUPr
#00f0 JMP2 ( f4 ) STH2k
( f5 ) STAr
&zero-page-loader ( f6 ) INC2
( f0 ) DEO2 ( f7 ) NEQ2k
( f1 ) DEI2 ( f8 ) ,&loop
( f2 ) ADD2 ( f9 )
( f3 ) &loop DUPr ( fa ) JCN
( f4 ) STH2k ( fb ) POPr
( f5 ) STAr ( fc ) POP2
( f6 ) INC2 ( fd ) STZ2 ( deletes f4-fd through looping )
( f7 ) NEQ2k ( fe ) JMP
( f8 ) ,&loop ( ff ) STZ2 ( deletes fe-ff )
( f9 )
( fa ) JCN &tmp $1
( fb ) POPr
( fc ) POP2
( fd ) STZ2 ( deletes f4-fd through looping )
( fe ) JMP
( ff ) STZ2 ( deletes fe-ff )
&tmp $1
@capture-input ( -> ) @capture-input ( -> )
@ -956,14 +953,15 @@ RTN
( constants ) ( constants )
@carts-file "index 00 @carts-file "index 00
@title-loadCart "Select 20 "A 20 "ROM 00 @title-loadCart "Select 20 "A 20 "Cartridge 00
@title-confirmCart "Load 20 "This 20 "ROM? 00 @title-confirmCart "Load 20 "This 20 "Cartridge? 00
@cart $32 @load-cmd "load 20
@cart $20
@dot-rom ".rom 00 @dot-rom ".rom 00
( sprites ) ( sprites )
@blank $16 @blank $10
@uxn-logo [ @uxn-logo [
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 1b 3f 1e 18 18 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 1b 3f 1e 18 18 18
00 00 00 00 00 00 00 00 00 e0 f0 38 1c 0c 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 e0 f0 38 1c 0c 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

View file

@ -29,7 +29,7 @@
|60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |60 @Audio3 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ]
|80 @Controller [ &vector $2 &button $1 &key $1 ] |80 @Controller [ &vector $2 &button $1 &key $1 ]
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ]
|a0 @File [ &vector $2 &success $2 &offset-hs $2 &offset-ls $2 &name $2 &length $2 &load $2 &save $2 ] |a0 @File [ &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 ]
|b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] |b0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
( variables ) ( variables )
@ -81,7 +81,7 @@
;carts-file .File/name DEO2 ;carts-file .File/name DEO2
#2000 .File/length DEO2 #2000 .File/length DEO2
;list-buf .File/load DEO2 ;list-buf .File/read DEO2
.File/success DEI2 .list-len STZ2 .File/success DEI2 .list-len STZ2
CENTER-X .logo-coords/x STZ2 CENTER-X .logo-coords/x STZ2
@ -825,121 +825,114 @@ RTN
( send it! ) ( send it! )
#0020 .File/length DEO2 #0020 .File/length DEO2
#0001 .File/offset-ls DEO2 #01 .File/append DEO2
;ctl-file .File/name DEO2 ;ctl-file .File/name DEO2
;load-cmd .File/save DEO2 ;load-cmd .File/write DEO2
;slot-file ;load-rom JSR2 ;slot-file ;load-rom JSR2
RTN RTN
@load-rom ( filename* -- ) @load-rom ( filename* -- )
( (
Attempts to load the ROM from filename* and executes it. If the file exists Attempts to load the ROM from filename* and executes it. If the file exists
and has non-zero length, this function does not return, because the new ROM and has non-zero length, this function does not return, because the new ROM
is executing in its place. is executing in its place.
The screen and both stacks are cleared and all the device vectors are The screen and both stacks are cleared and all the device vectors are
written to zero as a convenience. All other device bytes are left written to zero as a convenience. All other device bytes are left
untouched, so they could introduce a device state to the next ROM that untouched, so they could introduce a device state to the next ROM that
it's not expecting. it's not expecting.
) )
.File/name DEO2 .File/name DEO2
#0000 .File/offset-hs DEO2
#0000 .File/offset-ls DEO2 ( clear wst )
#ab
( return if file can't be found, or zero length ) &wst-loop
#0001 .File/length DEO2 POP
;&tmp .File/load DEO2 .System/wst STH DEIr STHr ,&wst-loop JCN
.File/success DEI2 ORA JMP JMP2r
( clear rst )
( clear wst ) LITr ab
#ab &rst-loop
&wst-loop POPr
POP .System/rst DEI ,&rst-loop JCN
.System/wst STH DEIr STHr ,&wst-loop JCN
( clear screen )
( clear rst ) #01 .Screen/auto DEO
LITr ab #0000 .Screen/y DEO2
&rst-loop .Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2
POPr &screen-yloop
.System/rst DEI ,&rst-loop JCN #0000 .Screen/x DEO2
STH2kr
( clear screen ) &screen-xloop-bg
#01 .Screen/auto DEO #00 .Screen/sprite DEO
#0000 .Screen/y DEO2 INC2
.Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2 ORAk ,&screen-xloop-bg JCN
&screen-yloop POP2
#0000 .Screen/x DEO2 #0000 .Screen/x DEO2
STH2kr STH2kr
&screen-xloop-bg &screen-xloop-fg
#00 .Screen/sprite DEO #40 .Screen/sprite DEO
INC2 INC2
ORAk ,&screen-xloop-bg JCN ORAk ,&screen-xloop-fg JCN
POP2 POP2
#0000 .Screen/x DEO2 .Screen/y DEI2 #0008 ADD2
STH2kr DUP2 .Screen/y DEO2
&screen-xloop-fg .Screen/height DEI2 LTH2 ,&screen-yloop JCN
#40 .Screen/sprite DEO POP2r
INC2 #00 .Screen/auto DEO
ORAk ,&screen-xloop-fg JCN
POP2 ( reset device vectors )
.Screen/y DEI2 #0008 ADD2 LIT2r 0000 #00
DUP2 .Screen/y DEO2 &device-vector-loop
.Screen/height DEI2 LTH2 ,&screen-yloop JCN DUP2r STHk DEO2r
POP2r #10 ADD
#00 .Screen/auto DEO DUP ,&device-vector-loop JCN
POP POP2r
( reset device vectors )
LIT2r 0000 #00 ( copy the zero-page-loader into f0-ff )
&device-vector-loop ;&zero-page-loader LITr f0
DUP2r STHk DEO2r &copy-loop
#10 ADD LDAk STHkr STZ
DUP ,&device-vector-loop JCN INC2 INCr
POP POP2r STHkr ,&copy-loop JCN
POP2 ( leave 00 on return stack )
( copy the zero-page-loader into f0-ff )
;&zero-page-loader LITr f0 ( prepare the stack for the zero-page-loader )
&copy-loop ( the more we prepare here in advance, the less we'll have to overwrite )
LDAk STHkr STZ STHkr #00fe ( arguments for STZ2 at ff )
INC2 INCr STHkr ( argument for JMP at fe (carry on) )
STHkr ,&copy-loop JCN DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) )
POP2 ( leave 00 on return stack ) OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) )
( prepare the stack for the zero-page-loader ) OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
( the more we prepare here in advance, the less we'll have to overwrite ) OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 )
STHkr #00fe ( arguments for STZ2 at ff ) STHkr ( first argument for ADD2 )
STHkr ( argument for JMP at fe (carry on) ) .File/success ( argument for DEI2 )
DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) ) #0100 .File/read ( arguments for DEO2 )
OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) ) #ff00 .File/length DEO2
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) ) #00f0 JMP2
OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 ) &zero-page-loader
STHkr ( first argument for ADD2 ) ( f0 ) DEO2
.File/success ( argument for DEI2 ) ( f1 ) DEI2
#0100 .File/load ( arguments for DEO2 ) ( f2 ) ADD2
#ff00 .File/length DEO2 ( f3 ) &loop DUPr
#00f0 JMP2 ( f4 ) STH2k
( f5 ) STAr
&zero-page-loader ( f6 ) INC2
( f0 ) DEO2 ( f7 ) NEQ2k
( f1 ) DEI2 ( f8 ) ,&loop
( f2 ) ADD2 ( f9 )
( f3 ) &loop DUPr ( fa ) JCN
( f4 ) STH2k ( fb ) POPr
( f5 ) STAr ( fc ) POP2
( f6 ) INC2 ( fd ) STZ2 ( deletes f4-fd through looping )
( f7 ) NEQ2k ( fe ) JMP
( f8 ) ,&loop ( ff ) STZ2 ( deletes fe-ff )
( f9 )
( fa ) JCN &tmp $1
( fb ) POPr
( fc ) POP2
( fd ) STZ2 ( deletes f4-fd through looping )
( fe ) JMP
( ff ) STZ2 ( deletes fe-ff )
&tmp $1
@capture-input ( -> ) @capture-input ( -> )
@ -959,10 +952,10 @@ RTN
@title-confirmCart "Load 20 "This 20 "Cartridge? 00 @title-confirmCart "Load 20 "This 20 "Cartridge? 00
@load-cmd "load 20 @load-cmd "load 20
@cart $32 @cart $20
( sprites ) ( sprites )
@blank $16 @blank $10
@uxn-logo [ @uxn-logo [
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 1b 3f 1e 18 18 18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 09 1b 3f 1e 18 18 18
00 00 00 00 00 00 00 00 00 e0 f0 38 1c 0c 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 e0 f0 38 1c 0c 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00