mirror of
https://github.com/hsoft/collapseos.git
synced 2025-04-02 04:38:40 +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:
parent
57e20f0532
commit
eefa8e6de5
@ -12,8 +12,9 @@
|
|||||||
// failing, send a non-zero value to RET_PORT to indicate failure
|
// failing, send a non-zero value to RET_PORT to indicate failure
|
||||||
#define RET_PORT 0x01
|
#define RET_PORT 0x01
|
||||||
// Port for block reads. Write 2 bytes, MSB first, on that port and then
|
// 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 BLK_PORT 0x03
|
||||||
|
#define BLKDATA_PORT 0x04
|
||||||
|
|
||||||
static int running;
|
static int running;
|
||||||
static FILE *fp;
|
static FILE *fp;
|
||||||
@ -44,7 +45,16 @@ static void iowr_ret(uint8_t val)
|
|||||||
retcode = 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;
|
uint8_t res = 0;
|
||||||
if (blkfp != NULL) {
|
if (blkfp != NULL) {
|
||||||
@ -56,12 +66,10 @@ static uint8_t iord_blk()
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void iowr_blk(uint8_t val)
|
static void iowr_blkdata(uint8_t val)
|
||||||
{
|
{
|
||||||
blkid <<= 8;
|
|
||||||
blkid |= val;
|
|
||||||
if (blkfp != NULL) {
|
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->iord[STDIO_PORT] = iord_stdio;
|
||||||
m->iowr[STDIO_PORT] = iowr_stdio;
|
m->iowr[STDIO_PORT] = iowr_stdio;
|
||||||
m->iowr[RET_PORT] = iowr_ret;
|
m->iowr[RET_PORT] = iowr_ret;
|
||||||
m->iord[BLK_PORT] = iord_blk;
|
|
||||||
m->iowr[BLK_PORT] = iowr_blk;
|
m->iowr[BLK_PORT] = iowr_blk;
|
||||||
|
m->iord[BLKDATA_PORT] = iord_blkdata;
|
||||||
|
m->iowr[BLKDATA_PORT] = iowr_blkdata;
|
||||||
// initialize memory
|
// initialize memory
|
||||||
for (int i=0; i<sizeof(KERNEL); i++) {
|
for (int i=0; i<sizeof(KERNEL); i++) {
|
||||||
m->mem[i] = KERNEL[i];
|
m->mem[i] = KERNEL[i];
|
||||||
|
@ -1,14 +1,22 @@
|
|||||||
: EFS@
|
: EFS@
|
||||||
256 /MOD 3 PC! 3 PC!
|
256 /MOD 3 PC! 3 PC!
|
||||||
1024 0 DO
|
1024 0 DO
|
||||||
3 PC@
|
4 PC@
|
||||||
BLK( I + C!
|
BLK( I + C!
|
||||||
LOOP
|
LOOP
|
||||||
;
|
;
|
||||||
|
: EFS!
|
||||||
|
256 /MOD 3 PC! 3 PC!
|
||||||
|
1024 0 DO
|
||||||
|
BLK( I + C@ 4 PC!
|
||||||
|
LOOP
|
||||||
|
;
|
||||||
|
|
||||||
: INIT
|
: INIT
|
||||||
CURRENT @ HERE !
|
CURRENT @ HERE !
|
||||||
BLK$
|
BLK$
|
||||||
['] EFS@ BLK@* !
|
['] EFS@ BLK@* !
|
||||||
|
['] EFS! BLK!* !
|
||||||
RDLN$
|
RDLN$
|
||||||
Z80A$
|
Z80A$
|
||||||
LIT< _sys [entry]
|
LIT< _sys [entry]
|
||||||
|
@ -19,11 +19,15 @@
|
|||||||
-1 BLK> !
|
-1 BLK> !
|
||||||
;
|
;
|
||||||
|
|
||||||
|
( n -- )
|
||||||
: BLK@
|
: BLK@
|
||||||
DUP BLK> @ = IF DROP EXIT THEN
|
DUP BLK> @ = IF DROP EXIT THEN
|
||||||
DUP BLK> ! BLK@* @ EXECUTE
|
DUP BLK> ! BLK@* @ EXECUTE
|
||||||
;
|
;
|
||||||
|
|
||||||
|
( -- )
|
||||||
|
: BLK! BLK> @ BLK!* @ EXECUTE ;
|
||||||
|
|
||||||
: .2 DUP 10 < IF SPC THEN . ;
|
: .2 DUP 10 < IF SPC THEN . ;
|
||||||
|
|
||||||
: LIST
|
: LIST
|
||||||
|
Loading…
Reference in New Issue
Block a user