1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-26 17:18:05 +11:00

Compare commits

..

No commits in common. "496826cdc4539e83c077169f72f92bab141afff4" and "d7f002df98e60cabf2d590670f829b58198ef1ac" have entirely different histories.

5 changed files with 41 additions and 50 deletions

View File

@ -5,13 +5,10 @@ They all run on the same kind of virtual machine: A z80 CPU, 64K of RAM/ROM.
#include <string.h> #include <string.h>
#include "emul.h" #include "emul.h"
// Port for block reads. Each read or write has to be done in 5 IO writes: // Port for block reads. Write 2 bytes, MSB first, on that port and then
// 1 - r/w. 1 for read, 2 for write. // read 1024 bytes from the DATA port.
// 2 - blkid MSB
// 3 - blkid LSB
// 4 - dest addr MSB
// 5 - dest addr LSB
#define BLK_PORT 0x03 #define BLK_PORT 0x03
#define BLKDATA_PORT 0x04
#ifndef BLKFS_PATH #ifndef BLKFS_PATH
#error BLKFS_PATH needed #error BLKFS_PATH needed
@ -22,7 +19,7 @@ They all run on the same kind of virtual machine: A z80 CPU, 64K of RAM/ROM.
static Machine m; static Machine m;
static ushort traceval = 0; static ushort traceval = 0;
static uint64_t blkop = 0; // 5 bytes static uint16_t blkid = 0;
static FILE *blkfp; static FILE *blkfp;
static uint8_t io_read(int unused, uint16_t addr) static uint8_t io_read(int unused, uint16_t addr)
@ -50,20 +47,19 @@ static void io_write(int unused, uint16_t addr, uint8_t val)
static void iowr_blk(uint8_t val) static void iowr_blk(uint8_t val)
{ {
blkop <<= 8; blkid <<= 8;
blkop |= val; blkid |= val;
uint8_t rw = blkop >> 32;
if (rw) {
uint16_t blkid = (blkop >> 16);
uint16_t dest = blkop & 0xffff;
blkop = 0;
fseek(blkfp, blkid*1024, SEEK_SET); fseek(blkfp, blkid*1024, SEEK_SET);
if (rw==2) { // write }
fwrite(&m.mem[dest], 1024, 1, blkfp);
} else { // read static uint8_t iord_blkdata()
fread(&m.mem[dest], 1024, 1, blkfp); {
} return getc(blkfp);
} }
static void iowr_blkdata(uint8_t val)
{
putc(val, blkfp);
} }
static uint8_t mem_read(int unused, uint16_t addr) static uint8_t mem_read(int unused, uint16_t addr)
@ -124,6 +120,8 @@ Machine* emul_init()
m.cpu.ioRead = io_read; m.cpu.ioRead = io_read;
m.cpu.ioWrite = io_write; m.cpu.ioWrite = io_write;
m.iowr[BLK_PORT] = iowr_blk; m.iowr[BLK_PORT] = iowr_blk;
m.iord[BLKDATA_PORT] = iord_blkdata;
m.iowr[BLKDATA_PORT] = iowr_blkdata;
return &m; return &m;
} }

Binary file not shown.

View File

@ -13,6 +13,10 @@
// This binary is also used for automated tests and those tests, when // This binary is also used for automated tests and those tests, when
// 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
// read 1024 bytes from the DATA port.
#define BLK_PORT 0x03
#define BLKDATA_PORT 0x04
#define SETX_PORT 0x05 #define SETX_PORT 0x05
#define SETY_PORT 0x06 #define SETY_PORT 0x06

View File

@ -10,14 +10,17 @@
: (emit) 0 PC! ; : (emit) 0 PC! ;
: (key) 0 PC@ ; : (key) 0 PC@ ;
: EFS@ : EFS@
1 3 PC! ( read ) 256 /MOD 3 PC! 3 PC!
256 /MOD 3 PC! 3 PC! ( blkid ) 1024 0 DO
BLK( 256 /MOD 3 PC! 3 PC! ( dest ) 4 PC@
BLK( I + C!
LOOP
; ;
: EFS! : EFS!
2 3 PC! ( write ) 256 /MOD 3 PC! 3 PC!
256 /MOD 3 PC! 3 PC! ( blkid ) 1024 0 DO
BLK( 256 /MOD 3 PC! 3 PC! ( dest ) BLK( I + C@ 4 PC!
LOOP
; ;
: COLS 80 ; : LINES 32 ; : COLS 80 ; : LINES 32 ;
: AT-XY 6 PC! ( y ) 5 PC! ( x ) ; : AT-XY 6 PC! ( y ) 5 PC! ( x ) ;

View File

@ -12,11 +12,10 @@ CODE (emit) 1 chkPS,
CODE (key) CODE (key)
AH AH XORrr, 0x16 INT, AH AH XORrr, AX PUSHx, AH AH XORrr, 0x16 INT, AH AH XORrr, AX PUSHx,
;CODE ;CODE
CODE 13H08H ( driveno -- cx dx ) CODE 13H08H ( driveno -- cx )
DI POPx, DX PUSHx, ( protect ) DX DI MOVxx, AX 0x800 MOVxI, DI POPx, DX PUSHx, ( protect ) DX DI MOVxx, AX 0x800 MOVxI,
DI DI XORxx, ES DI MOVsx, DI DI XORxx, ES DI MOVsx,
0x13 INT, DI DX MOVxx, DX POPx, ( unprotect ) 0x13 INT, DX POPx, ( unprotect ) CX PUSHx,
CX PUSHx, DI PUSHx,
DI 0x800 MOVxI, ES DI MOVsx, DI 0x800 MOVxI, ES DI MOVsx,
;CODE ;CODE
CODE 13H ( ax bx cx dx -- ax bx cx dx ) CODE 13H ( ax bx cx dx -- ax bx cx dx )
@ -26,37 +25,24 @@ CODE 13H ( ax bx cx dx -- ax bx cx dx )
AX PUSHx, BX PUSHx, CX PUSHx, SI PUSHx, AX PUSHx, BX PUSHx, CX PUSHx, SI PUSHx,
;CODE ;CODE
: FDSPT 0x70 RAM+ ; : FDSPT 0x70 RAM+ ;
: FDHEADS 0x71 RAM+ ; : _ ( dest secno )
: _ ( AX BX sec )
( AH=read sectors, AL=1 sector, BX=dest, ( AH=read sectors, AL=1 sector, BX=dest,
CH=trackno CL=secno DH=head DL=drive ) CH=trackno CL=secno DH=head DL=drive )
FDSPT C@ /MOD ( AX BX sec trk ) 0x0201 ROT ROT ( AX BX sec )
FDHEADS C@ /MOD ( AX BX sec head trk ) FDSPT @ /MOD ( AX BX sec trk )
2 /MOD ( AX BX sec head trk )
8 LSHIFT ROT OR 1+ ( AX BX head CX ) 8 LSHIFT ROT OR 1+ ( AX BX head CX )
SWAP 8 LSHIFT 0x03 C@ ( boot drive ) OR ( AX BX CX DX ) SWAP 8 LSHIFT 0x03 C@ ( boot drive ) OR ( AX BX CX DX )
13H 2DROP 2DROP 13H 2DROP 2DROP
; ;
: FD@ : FD@
2 * 16 + ( blkfs starts at sector 16 ) 2 * 16 + ( blkfs starts at sector 16 )
0x0201 BLK( 2 PICK _ BLK( OVER _ BLK( 0x200 + SWAP 1+ _ ;
0x0201 BLK( 0x200 + ROT 1+ _ ; : FD! DROP ;
: FD!
2 * 16 + ( blkfs starts at sector 16 )
0x0301 BLK( 2 PICK _
0x0301 BLK( 0x200 + ROT 1+ _ ;
: FD$ : FD$
( get number of sectors per track with command 08H. ) ( get number of sectors per track with command 08H. )
0x03 ( boot drive ) C@ 13H08H 0x03 ( boot drive ) C@ 13H08H 0x3f AND FDSPT !
8 RSHIFT 1+ FDHEADS C!
0x3f AND FDSPT C!
; ;
: COLS 80 ; : LINES 25 ;
CODE AT-XY ( x y )
( DH=row DL=col BH=page )
AX POPx, BX POPx, DX PUSHx, ( protect )
DH AL MOVrr, DL BL MOVrr, BX BX XORxx, AH 2 MOVri,
0x10 INT, DX POPx, ( unprotect )
;CODE
380 LOAD ( xcomp core high ) 380 LOAD ( xcomp core high )
(entry) _ (entry) _
( Update LATEST ) ( Update LATEST )