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 ]
|80 @Controller [ &vector $2 &button $1 &key $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 ]
( variables )
@ -71,7 +71,6 @@
#0200 .Screen/width DEO2
#0110 .Screen/height DEO2
( initialize state )
#00 .ticker STZ
#00 .state STZ
@ -82,7 +81,7 @@
;carts-file .File/name DEO2
#2000 .File/length DEO2
;list-buf .File/load DEO2
;list-buf .File/read DEO2
.File/success DEI2 .list-len STZ2
CENTER-X .logo-coords/x STZ2
@ -182,6 +181,10 @@ BRK
POP
BRK
&state6
[ ;load-cmd
CENTER-X OVR2 ;strlen JSR2 #20 SFT2 SUB2
CENTER-Y #0004 SUB
#02 ] ;draw-string JSR2
POP
BRK
@ -832,117 +835,111 @@ RTN
@load-cart ( -> )
.state LDZ INC .state STZ
;cart ;load-rom JSR2
RTN
@load-rom ( filename* -- )
(
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
is executing in its place.
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
untouched, so they could introduce a device state to the next ROM that
it's not expecting.
)
.File/name DEO2
#0000 .File/offset-hs DEO2
#0000 .File/offset-ls DEO2
( return if file can't be found, or zero length )
#0001 .File/length DEO2
;&tmp .File/load DEO2
.File/success DEI2 ORA JMP JMP2r
( clear wst )
#ab
&wst-loop
POP
.System/wst STH DEIr STHr ,&wst-loop JCN
( clear rst )
LITr ab
&rst-loop
POPr
.System/rst DEI ,&rst-loop JCN
( clear screen )
#01 .Screen/auto DEO
#0000 .Screen/y DEO2
.Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2
&screen-yloop
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-bg
#00 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-bg JCN
POP2
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-fg
#40 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-fg JCN
POP2
.Screen/y DEI2 #0008 ADD2
DUP2 .Screen/y DEO2
.Screen/height DEI2 LTH2 ,&screen-yloop JCN
POP2r
#00 .Screen/auto DEO
( reset device vectors )
LIT2r 0000 #00
&device-vector-loop
DUP2r STHk DEO2r
#10 ADD
DUP ,&device-vector-loop JCN
POP POP2r
( copy the zero-page-loader into f0-ff )
;&zero-page-loader LITr f0
&copy-loop
LDAk STHkr STZ
INC2 INCr
STHkr ,&copy-loop JCN
POP2 ( leave 00 on return stack )
( prepare the stack for the zero-page-loader )
( the more we prepare here in advance, the less we'll have to overwrite )
STHkr #00fe ( arguments for STZ2 at ff )
STHkr ( argument for JMP at fe (carry on) )
DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 )
STHkr ( first argument for ADD2 )
.File/success ( argument for DEI2 )
#0100 .File/load ( arguments for DEO2 )
#ff00 .File/length DEO2
#00f0 JMP2
&zero-page-loader
( f0 ) DEO2
( f1 ) DEI2
( f2 ) ADD2
( f3 ) &loop DUPr
( f4 ) STH2k
( f5 ) STAr
( f6 ) INC2
( f7 ) NEQ2k
( f8 ) ,&loop
( f9 )
( fa ) JCN
( fb ) POPr
( fc ) POP2
( fd ) STZ2 ( deletes f4-fd through looping )
( fe ) JMP
( ff ) STZ2 ( deletes fe-ff )
&tmp $1
(
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
is executing in its place.
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
untouched, so they could introduce a device state to the next ROM that
it's not expecting.
)
.File/name DEO2
( clear wst )
#ab
&wst-loop
POP
.System/wst STH DEIr STHr ,&wst-loop JCN
( clear rst )
LITr ab
&rst-loop
POPr
.System/rst DEI ,&rst-loop JCN
( clear screen )
#01 .Screen/auto DEO
#0000 .Screen/y DEO2
.Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2
&screen-yloop
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-bg
#00 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-bg JCN
POP2
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-fg
#40 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-fg JCN
POP2
.Screen/y DEI2 #0008 ADD2
DUP2 .Screen/y DEO2
.Screen/height DEI2 LTH2 ,&screen-yloop JCN
POP2r
#00 .Screen/auto DEO
( reset device vectors )
LIT2r 0000 #00
&device-vector-loop
DUP2r STHk DEO2r
#10 ADD
DUP ,&device-vector-loop JCN
POP POP2r
( copy the zero-page-loader into f0-ff )
;&zero-page-loader LITr f0
&copy-loop
LDAk STHkr STZ
INC2 INCr
STHkr ,&copy-loop JCN
POP2 ( leave 00 on return stack )
( prepare the stack for the zero-page-loader )
( the more we prepare here in advance, the less we'll have to overwrite )
STHkr #00fe ( arguments for STZ2 at ff )
STHkr ( argument for JMP at fe (carry on) )
DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 )
STHkr ( first argument for ADD2 )
.File/success ( argument for DEI2 )
#0100 .File/read ( arguments for DEO2 )
#ff00 .File/length DEO2
#00f0 JMP2
&zero-page-loader
( f0 ) DEO2
( f1 ) DEI2
( f2 ) ADD2
( f3 ) &loop DUPr
( f4 ) STH2k
( f5 ) STAr
( f6 ) INC2
( f7 ) NEQ2k
( f8 ) ,&loop
( f9 )
( fa ) JCN
( fb ) POPr
( fc ) POP2
( fd ) STZ2 ( deletes f4-fd through looping )
( fe ) JMP
( ff ) STZ2 ( deletes fe-ff )
&tmp $1
@capture-input ( -> )
@ -956,14 +953,15 @@ RTN
( constants )
@carts-file "index 00
@title-loadCart "Select 20 "A 20 "ROM 00
@title-confirmCart "Load 20 "This 20 "ROM? 00
@title-loadCart "Select 20 "A 20 "Cartridge 00
@title-confirmCart "Load 20 "This 20 "Cartridge? 00
@cart $32
@load-cmd "load 20
@cart $20
@dot-rom ".rom 00
( sprites )
@blank $16
@blank $10
@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 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 ]
|80 @Controller [ &vector $2 &button $1 &key $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 ]
( variables )
@ -81,7 +81,7 @@
;carts-file .File/name DEO2
#2000 .File/length DEO2
;list-buf .File/load DEO2
;list-buf .File/read DEO2
.File/success DEI2 .list-len STZ2
CENTER-X .logo-coords/x STZ2
@ -825,121 +825,114 @@ RTN
( send it! )
#0020 .File/length DEO2
#0001 .File/offset-ls DEO2
#01 .File/append DEO2
;ctl-file .File/name DEO2
;load-cmd .File/save DEO2
;load-cmd .File/write DEO2
;slot-file ;load-rom JSR2
RTN
@load-rom ( filename* -- )
(
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
is executing in its place.
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
untouched, so they could introduce a device state to the next ROM that
it's not expecting.
)
.File/name DEO2
#0000 .File/offset-hs DEO2
#0000 .File/offset-ls DEO2
( return if file can't be found, or zero length )
#0001 .File/length DEO2
;&tmp .File/load DEO2
.File/success DEI2 ORA JMP JMP2r
( clear wst )
#ab
&wst-loop
POP
.System/wst STH DEIr STHr ,&wst-loop JCN
( clear rst )
LITr ab
&rst-loop
POPr
.System/rst DEI ,&rst-loop JCN
( clear screen )
#01 .Screen/auto DEO
#0000 .Screen/y DEO2
.Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2
&screen-yloop
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-bg
#00 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-bg JCN
POP2
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-fg
#40 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-fg JCN
POP2
.Screen/y DEI2 #0008 ADD2
DUP2 .Screen/y DEO2
.Screen/height DEI2 LTH2 ,&screen-yloop JCN
POP2r
#00 .Screen/auto DEO
( reset device vectors )
LIT2r 0000 #00
&device-vector-loop
DUP2r STHk DEO2r
#10 ADD
DUP ,&device-vector-loop JCN
POP POP2r
( copy the zero-page-loader into f0-ff )
;&zero-page-loader LITr f0
&copy-loop
LDAk STHkr STZ
INC2 INCr
STHkr ,&copy-loop JCN
POP2 ( leave 00 on return stack )
( prepare the stack for the zero-page-loader )
( the more we prepare here in advance, the less we'll have to overwrite )
STHkr #00fe ( arguments for STZ2 at ff )
STHkr ( argument for JMP at fe (carry on) )
DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 )
STHkr ( first argument for ADD2 )
.File/success ( argument for DEI2 )
#0100 .File/load ( arguments for DEO2 )
#ff00 .File/length DEO2
#00f0 JMP2
&zero-page-loader
( f0 ) DEO2
( f1 ) DEI2
( f2 ) ADD2
( f3 ) &loop DUPr
( f4 ) STH2k
( f5 ) STAr
( f6 ) INC2
( f7 ) NEQ2k
( f8 ) ,&loop
( f9 )
( fa ) JCN
( fb ) POPr
( fc ) POP2
( fd ) STZ2 ( deletes f4-fd through looping )
( fe ) JMP
( ff ) STZ2 ( deletes fe-ff )
&tmp $1
(
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
is executing in its place.
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
untouched, so they could introduce a device state to the next ROM that
it's not expecting.
)
.File/name DEO2
( clear wst )
#ab
&wst-loop
POP
.System/wst STH DEIr STHr ,&wst-loop JCN
( clear rst )
LITr ab
&rst-loop
POPr
.System/rst DEI ,&rst-loop JCN
( clear screen )
#01 .Screen/auto DEO
#0000 .Screen/y DEO2
.Screen/width DEI2 #0007 ADD2 #03 SFT2 #ffff MUL2 STH2
&screen-yloop
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-bg
#00 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-bg JCN
POP2
#0000 .Screen/x DEO2
STH2kr
&screen-xloop-fg
#40 .Screen/sprite DEO
INC2
ORAk ,&screen-xloop-fg JCN
POP2
.Screen/y DEI2 #0008 ADD2
DUP2 .Screen/y DEO2
.Screen/height DEI2 LTH2 ,&screen-yloop JCN
POP2r
#00 .Screen/auto DEO
( reset device vectors )
LIT2r 0000 #00
&device-vector-loop
DUP2r STHk DEO2r
#10 ADD
DUP ,&device-vector-loop JCN
POP POP2r
( copy the zero-page-loader into f0-ff )
;&zero-page-loader LITr f0
&copy-loop
LDAk STHkr STZ
INC2 INCr
STHkr ,&copy-loop JCN
POP2 ( leave 00 on return stack )
( prepare the stack for the zero-page-loader )
( the more we prepare here in advance, the less we'll have to overwrite )
STHkr #00fe ( arguments for STZ2 at ff )
STHkr ( argument for JMP at fe (carry on) )
DUPk #fcfe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #fafe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f8fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f6fe ( arguments for STZ2 at fd and JMP (repeat) )
OVR2 #f401 ( arguments for STZ2 at fd, plus an extra 01 )
STHkr ( first argument for ADD2 )
.File/success ( argument for DEI2 )
#0100 .File/read ( arguments for DEO2 )
#ff00 .File/length DEO2
#00f0 JMP2
&zero-page-loader
( f0 ) DEO2
( f1 ) DEI2
( f2 ) ADD2
( f3 ) &loop DUPr
( f4 ) STH2k
( f5 ) STAr
( f6 ) INC2
( f7 ) NEQ2k
( f8 ) ,&loop
( f9 )
( fa ) JCN
( fb ) POPr
( fc ) POP2
( fd ) STZ2 ( deletes f4-fd through looping )
( fe ) JMP
( ff ) STZ2 ( deletes fe-ff )
&tmp $1
@capture-input ( -> )
@ -959,10 +952,10 @@ RTN
@title-confirmCart "Load 20 "This 20 "Cartridge? 00
@load-cmd "load 20
@cart $32
@cart $20
( sprites )
@blank $16
@blank $10
@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 e0 f0 38 1c 0c 0c 0c 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00