1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-12-25 04:38:05 +11:00

Add word "BLK!"

as well as emulator support for it. We can now write an edited
block back to "blkfs".
This commit is contained in:
Virgil Dupras 2020-04-16 17:22:18 -04:00
parent 57e20f0532
commit eefa8e6de5
3 changed files with 29 additions and 8 deletions

View File

@ -12,8 +12,9 @@
// failing, send a non-zero value to RET_PORT to indicate failure
#define RET_PORT 0x01
// Port for block reads. Write 2 bytes, MSB first, on that port and then
// read 1024 bytes from the same port.
// read 1024 bytes from the DATA port.
#define BLK_PORT 0x03
#define BLKDATA_PORT 0x04
static int running;
static FILE *fp;
@ -44,7 +45,16 @@ static void iowr_ret(uint8_t val)
retcode = val;
}
static uint8_t iord_blk()
static void iowr_blk(uint8_t val)
{
blkid <<= 8;
blkid |= val;
if (blkfp != NULL) {
fseek(blkfp, blkid*1024, SEEK_SET);
}
}
static uint8_t iord_blkdata()
{
uint8_t res = 0;
if (blkfp != NULL) {
@ -56,12 +66,10 @@ static uint8_t iord_blk()
return res;
}
static void iowr_blk(uint8_t val)
static void iowr_blkdata(uint8_t val)
{
blkid <<= 8;
blkid |= val;
if (blkfp != NULL) {
fseek(blkfp, blkid*1024, SEEK_SET);
putc(val, blkfp);
}
}
@ -99,8 +107,9 @@ int main(int argc, char *argv[])
m->iord[STDIO_PORT] = iord_stdio;
m->iowr[STDIO_PORT] = iowr_stdio;
m->iowr[RET_PORT] = iowr_ret;
m->iord[BLK_PORT] = iord_blk;
m->iowr[BLK_PORT] = iowr_blk;
m->iord[BLKDATA_PORT] = iord_blkdata;
m->iowr[BLKDATA_PORT] = iowr_blkdata;
// initialize memory
for (int i=0; i<sizeof(KERNEL); i++) {
m->mem[i] = KERNEL[i];

View File

@ -1,14 +1,22 @@
: EFS@
256 /MOD 3 PC! 3 PC!
1024 0 DO
3 PC@
4 PC@
BLK( I + C!
LOOP
;
: EFS!
256 /MOD 3 PC! 3 PC!
1024 0 DO
BLK( I + C@ 4 PC!
LOOP
;
: INIT
CURRENT @ HERE !
BLK$
['] EFS@ BLK@* !
['] EFS! BLK!* !
RDLN$
Z80A$
LIT< _sys [entry]

View File

@ -19,11 +19,15 @@
-1 BLK> !
;
( n -- )
: BLK@
DUP BLK> @ = IF DROP EXIT THEN
DUP BLK> ! BLK@* @ EXECUTE
;
( -- )
: BLK! BLK> @ BLK!* @ EXECUTE ;
: .2 DUP 10 < IF SPC THEN . ;
: LIST