copy all local files to repo

cp/m files, sprites, circuit design
This commit is contained in:
Amber
2020-05-15 09:07:45 -04:00
parent 8353edd599
commit 783d32a495
461 changed files with 80153 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
CFLAGS= -O -s
all: format putsys bin2hex send receive bios.bin boot.bin
@echo "done"
format: format.c
cc $(CFLAGS) -o format format.c
cp format ..
putsys: putsys.c
cc $(CFLAGS) -o putsys putsys.c
bin2hex: bin2hex.c
cc $(CFLAGS) -o bin2hex bin2hex.c
cp bin2hex ..
send: send.c
cc $(CFLAGS) -o send send.c
cp send ..
receive: receive.c
cc $(CFLAGS) -o receive receive.c
cp receive ..
bios.bin: bios.asm
z80asm -vl -sn -x bios.asm
boot.bin: boot.asm
z80asm -vl -sn boot.asm
clean:
rm -f *.lis bios.bin boot.bin format putsys bin2hex receive send

View File

@@ -0,0 +1,161 @@
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/stat.h>
void help(char *name)
{
printf("%s - BINARY to Intel HEX file convertor version 1.00\n"\
"(c)BCL Vysoke Myto 2001 (benedikt@lphard.cz)\n\n",name);
printf("Usage: %s [-option] binfile hexfile\n"\
" -l Bytes to read from binary file\n"\
" -i Binary file starting offset\n"\
" -o Output file offset (where HEX data starts)\n"\
" -t Exclude EOF record\n"\
" -a Append to end of existing HEX file\n"\
" -q Quiet mode (no statistics are printed)\n", name);
}
int main(int argc,char *argv[])/*Main routine*/
{
char *ifile = NULL;
char *ofile = NULL;
char c;
FILE *inp, *outp;
int ch,csum;
int ofsa = 0;
int cnt = 0;
struct stat statbuf;
long int foffset = 0;
long int fsize = 0;
long int fsub;
long int fpoint = 0;
long int adrs = 0;
unsigned char quiet = 0;
unsigned char eofrec = 0;
unsigned char append = 0;
opterr = 0; //print error message if unknown option
while ((c = getopt (argc, argv, "l:i:o:taqv")) != -1)
switch (c) {
case 'l':
fsize = atol(optarg);
break;
case 'i':
foffset = atol(optarg);
break;
case 'o':
adrs = atol(optarg);
break;
case 't':
eofrec = 1;
break;
case 'a':
append = 1;
break;
case 'q':
quiet = 1;
break;
case 'v':
printf("%s - BINARY to Intel HEX file convertor version 1.00\n"\
"(c)BCL Vysoke Myto 2001 (benedikt@lphard.cz)\n",argv[0]);
return 0;
case '?':
help (argv[0]);
return 1;
}
if ((argc - optind) != 2) {
printf("ERROR: Missing input/output file.\n");
help(argv[0]);
return 1;
}
ifile = argv[optind];
ofile = argv[optind+1];
/*Open file check*/
if((inp = fopen(ifile, "rb")) == NULL){
printf("ERROR: Cannot open input file.\n");
return 1;
}
fseek (inp, foffset, SEEK_SET);
if (append == 0) {
if((outp = fopen(ofile, "wt")) == NULL){
printf("ERROR: Cannot open output file.\n");
return 1;
}
} else {
if((outp = fopen(ofile, "at")) == NULL){
printf("ERROR: Cannot re-open output file.\n");
return 1;
}
fseek (outp, 0, SEEK_END);
}
fstat(fileno(inp), &statbuf);
if (quiet == 0) printf("Input file size=%ld\n",statbuf.st_size);
if (foffset > statbuf.st_size) {
printf("ERROR: Input offset > input file length\n");
}
if ((fsize == 0) || (fsize > (statbuf.st_size - foffset)))
fsize = statbuf.st_size - foffset;
// fprintf(outp,":020000020000FC\n");/*Start Header*/
fsub = fsize - fpoint;
if (fsub > 0x20) {
fprintf(outp,":20%04X00",adrs);/*Hex line Header*/
csum = 0x20 + (adrs>>8) + (adrs & 0xFF);
adrs += 0x20;
}
else {
fprintf(outp, ":%02X%04X00", fsub,adrs);/*Hex line Header*/
csum = fsub + (adrs>>8) + (adrs & 0xFF);
adrs += fsub;
}
while (fsub > 0){
ch = fgetc(inp);
fprintf(outp,"%02X",ch);/*Put data*/
cnt++; fpoint++;
fsub = fsize - fpoint;
csum = ch + csum;
if((fsub == 0)||(cnt == 0x20)){
cnt = 0; csum = 0xFF & (~csum + 1);
fprintf(outp,"%02X\n",csum);/*Put checksum*/
if(fsub == 0) break;
if(adrs > 0xFFFF){
ofsa = 0x1000 + ofsa;
adrs = 0;
fprintf(outp,":02000002%04X",ofsa);/*Change offset address*/
csum = 0x02 + 0x02 + (ofsa>>8) + (ofsa & 0xFF);
csum = 0xFF & (~csum + 1);
fprintf(outp,"%02X\n", csum);
}
adrs = 0xFFFF & adrs;
if (fsub > 0x20) {
fprintf(outp,":20%04X00",adrs);/*Next Hex line Header*/
csum = 0x20 + (adrs>>8) + (adrs & 0xFF);
adrs += 0x20;
}
else {
if(fsub > 0){
fprintf(outp, ":%02X%04X00", fsub,adrs);/*Next Hex line Header*/
csum = fsub + (adrs>>8) + (adrs & 0xFF);
adrs += fsub;
}
}
}
}
if (eofrec == 0) fprintf(outp,":00000001FF\n");/*End footer*/
fflush (outp);
fstat(fileno(outp), &statbuf);
if (quiet == 0) printf("Output file size=%ld\n",statbuf.st_size);
fclose(inp);
fclose(outp);
return 0;
}

View File

@@ -0,0 +1,375 @@
; CBIOS for Z80-Simulator
;
; Copyright (C) 1988-2006 by Udo Munk
;
MSIZE EQU 64 ;cp/m version memory size in kilobytes
;
; "bias" is address offset from 3400H for memory systems
; than 16K (referred to as "b" throughout the text).
;
BIAS EQU (MSIZE-20)*1024
CCP EQU 3400H+BIAS ;base of ccp
BDOS EQU CCP+806H ;base of bdos
BIOS EQU CCP+1600H ;base of bios
CDISK EQU 0004H ;current disk number 0=A,...,15=P
IOBYTE EQU 0003H ;intel i/o byte
;
; I/O ports
;
CONSTA EQU 0 ;console status port
CONDAT EQU 1 ;console data port
PRTSTA EQU 2 ;printer status port
PRTDAT EQU 3 ;printer data port
AUXDAT EQU 5 ;auxiliary data port
FDCD EQU 10 ;fdc-port: # of drive
FDCT EQU 11 ;fdc-port: # of track
FDCS EQU 12 ;fdc-port: # of sector
FDCOP EQU 13 ;fdc-port: command
FDCST EQU 14 ;fdc-port: status
DMAL EQU 15 ;dma-port: dma address low
DMAH EQU 16 ;dma-port: dma address high
;
ORG BIOS ;origin of this program
NSECTS EQU (BIOS-CCP)/128 ;warm start sector count
;
; jump vector for individual subroutines
;
JP BOOT ;cold start
WBOOTE: JP WBOOT ;warm start
JP CONST ;console status
JP CONIN ;console character in
JP CONOUT ;console character out
JP LIST ;list character out
JP PUNCH ;punch character out
JP READER ;reader character out
JP HOME ;move head to home position
JP SELDSK ;select disk
JP SETTRK ;set track number
JP SETSEC ;set sector number
JP SETDMA ;set dma address
JP READ ;read disk
JP WRITE ;write disk
JP LISTST ;return list status
JP SECTRAN ;sector translate
;
; fixed data tables for four-drive standard
; IBM-compatible 8" disks
;
; disk parameter header for disk 00
DPBASE: DEFW TRANS,0000H
DEFW 0000H,0000H
DEFW DIRBF,DPBLK
DEFW CHK00,ALL00
; disk parameter header for disk 01
DEFW TRANS,0000H
DEFW 0000H,0000H
DEFW DIRBF,DPBLK
DEFW CHK01,ALL01
; disk parameter header for disk 02
DEFW TRANS,0000H
DEFW 0000H,0000H
DEFW DIRBF,DPBLK
DEFW CHK02,ALL02
; disk parameter header for disk 03
DEFW TRANS,0000H
DEFW 0000H,0000H
DEFW DIRBF,DPBLK
DEFW CHK03,ALL03
;
; sector translate vector for the IBM 8" disks
;
TRANS: DEFB 1,7,13,19 ;sectors 1,2,3,4
DEFB 25,5,11,17 ;sectors 5,6,7,8
DEFB 23,3,9,15 ;sectors 9,10,11,12
DEFB 21,2,8,14 ;sectors 13,14,15,16
DEFB 20,26,6,12 ;sectors 17,18,19,20
DEFB 18,24,4,10 ;sectors 21,22,23,24
DEFB 16,22 ;sectors 25,26
;
; disk parameter block, common to all IBM 8" disks
;
DPBLK: DEFW 26 ;sectors per track
DEFB 3 ;block shift factor
DEFB 7 ;block mask
DEFB 0 ;extent mask
DEFW 242 ;disk size-1
DEFW 63 ;directory max
DEFB 192 ;alloc 0
DEFB 0 ;alloc 1
DEFW 16 ;check size
DEFW 2 ;track offset
;
; fixed data tables for 4MB harddisk
;
; disk parameter header
HDBASE: DEFW HDTRA,0000H
DEFW 0000H,0000H
DEFW DIRBF,HDBLK
DEFW CHKHD,ALLHD
;
; sector translate vector for the hardisk
;
HDTRA: DEFB 1,2,3,4,5,6,7,8,9,10
DEFB 11,12,13,14,15,16,17,18,19,20
DEFB 21,22,23,24,25,26,27,28,29,30
DEFB 31,32,33,34,35,36,37,38,39,40
DEFB 41,42,43,44,45,46,47,48,49,50
DEFB 51,52,53,54,55,56,57,58,59,60
DEFB 61,62,63,64,65,66,67,68,69,70
DEFB 71,72,73,74,75,76,77,78,79,80
DEFB 81,82,83,84,85,86,87,88,89,90
DEFB 91,92,93,94,95,96,97,98,99,100
DEFB 101,102,103,104,105,106,107,108,109,110
DEFB 111,112,113,114,115,116,117,118,119,120
DEFB 121,122,123,124,125,126,127,128
;
; disk parameter block for harddisk
;
HDBLK: DEFW 128 ;sectors per track
DEFB 4 ;block shift factor
DEFB 15 ;block mask
DEFB 0 ;extent mask
DEFW 2039 ;disk size-1
DEFW 1023 ;directory max
DEFB 255 ;alloc 0
DEFB 255 ;alloc 1
DEFW 0 ;check size
DEFW 0 ;track offset
;
; signon message
;
SIGNON: DEFM '64K CP/M Vers. 2.2 (CBIOS V1.1 for Z80SIM, '
DEFM 'Copyright 1988-2006 by Udo Munk)'
DEFB 13,10,0
;
; end of fixed tables
;
; individual subroutines to perform each function
; simplest case is to just perform parameter initialization
;
BOOT: LD SP,80H ;use space below buffer for stack
LD HL,SIGNON ;print message
BOOTL: LD A,(HL)
OR A
JP Z,BOOTC
LD C,A
CALL CONOUT
INC HL
JP BOOTL
BOOTC: XOR A ;zero in the accum
LD (IOBYTE),A ;clear the iobyte
LD (CDISK),A ;select disk zero
JP GOCPM ;initialize and go to cp/m
;
; simplest case is to read the disk until all sectors loaded
;
WBOOT: LD SP,80H ;use space below buffer for stack
LD C,0 ;select disk 0
CALL SELDSK
CALL HOME ;go to track 00
;
LD B,NSECTS ;b counts # of sectors to load
LD C,0 ;c has the current track number
LD D,2 ;d has the next sector to read
; note that we begin by reading track 0, sector 2 since sector 1
; contains the cold start loader, which is skipped in a warm start
LD HL,CCP ;base of cp/m (initial load point)
LOAD1: ;load one more sector
PUSH BC ;save sector count, current track
PUSH DE ;save next sector to read
PUSH HL ;save dma address
LD C,D ;get sector address to register c
CALL SETSEC ;set sector address from register c
POP BC ;recall dma address to b,c
PUSH BC ;replace on stack for later recall
CALL SETDMA ;set dma address from b,c
; drive set to 0, track set, sector set, dma address set
CALL READ
CP 00H ;any errors?
JP NZ,WBOOT ;retry the entire boot if an error occurs
; no error, move to next sector
POP HL ;recall dma address
LD DE,128 ;dma=dma+128
ADD HL,DE ;new dma address is in h,l
POP DE ;recall sector address
POP BC ;recall number of sectors remaining, and current trk
DEC B ;sectors=sectors-1
JP Z,GOCPM ;transfer to cp/m if all have been loaded
; more sectors remain to load, check for track change
INC D
LD A,D ;sector=27?, if so, change tracks
CP 27
JP C,LOAD1 ;carry generated if sector<27
; end of current track, go to next track
LD D,1 ;begin with first sector of next track
INC C ;track=track+1
; save register state, and change tracks
CALL SETTRK ;track address set from register c
JP LOAD1 ;for another sector
; end of load operation, set parameters and go to cp/m
GOCPM:
LD A,0C3H ;c3 is a jmp instruction
LD (0),A ;for jmp to wboot
LD HL,WBOOTE ;wboot entry point
LD (1),HL ;set address field for jmp at 0
;
LD (5),A ;for jmp to bdos
LD HL,BDOS ;bdos entry point
LD (6),HL ;address field of jump at 5 to bdos
;
LD BC,80H ;default dma address is 80h
CALL SETDMA
;
EI ;enable the interrupt system
LD A,(CDISK) ;get current disk number
LD C,A ;send to the ccp
JP CCP ;go to cp/m for further processing
;
;
; simple i/o handlers
;
; console status, return 0ffh if character ready, 00h if not
;
CONST: IN A,(CONSTA) ;get console status
RET
;
; console character into register a
;
CONIN: IN A,(CONDAT) ;get character from console
RET
;
; console character output from register c
;
CONOUT: LD A,C ;get to accumulator
OUT (CONDAT),A ;send character to console
RET
;
; list character from register c
;
LIST: LD A,C ;character to register a
OUT (PRTDAT),A
RET
;
; return list status (0 if not ready, 0xff if ready)
;
LISTST: IN A,(PRTSTA)
RET
;
; punch character from register c
;
PUNCH: LD A,C ;character to register a
OUT (AUXDAT),A
RET
;
; read character into register a from reader device
;
READER: IN A,(AUXDAT)
RET
;
;
; i/o drivers for the disk follow
;
; move to the track 00 position of current drive
; translate this call into a settrk call with parameter 00
;
HOME: LD C,0 ;select track 0
JP SETTRK ;we will move to 00 on first read/write
;
; select disk given by register C
;
SELDSK: LD HL,0000H ;error return code
LD A,C
CP 4 ;must be between 0 and 3
JR NC,SELHD ;no carry if 4,5,...
; disk number is in the proper range
; compute proper disk parameter header address
OUT (FDCD),A ;selekt disk drive
LD L,A ;L=disk number 0,1,2,3
ADD HL,HL ;*2
ADD HL,HL ;*4
ADD HL,HL ;*8
ADD HL,HL ;*16 (size of each header)
LD DE,DPBASE
ADD HL,DE ;HL=.dpbase(diskno*16)
RET
SELHD: CP 8 ;select the harddisk?
RET NZ ;no, error
OUT (FDCD),A ;select disk drive
LD HL,HDBASE ;HL=hdbase for harddisk
RET
;
; set track given by register c
;
SETTRK: LD A,C
OUT (FDCT),A
RET
;
; set sector given by register c
;
SETSEC: LD A,C
OUT (FDCS),A
RET
;
; translate the sector given by BC using the
; translate table given by DE
;
SECTRAN:
EX DE,HL ;HL=.trans
ADD HL,BC ;HL=.trans(sector)
LD L,(HL) ;L = trans(sector)
LD H,0 ;HL= trans(sector)
RET ;with value in HL
;
; set dma address given by registers b and c
;
SETDMA: LD A,C ;low order address
OUT (DMAL),A
LD A,B ;high order address
OUT (DMAH),A ;in dma
RET
;
; perform read operation
;
READ: XOR A ;read command -> A
JP WAITIO ;to perform the actual i/o
;
; perform a write operation
;
WRITE: LD A,1 ;write command -> A
;
; enter here from read and write to perform the actual i/o
; operation. return a 00h in register a if the operation completes
; properly, and 01h if an error occurs during the read or write
;
; in this case, we have saved the disk number in 'diskno' (0-3)
; the track number in 'track' (0-76)
; the sector number in 'sector' (1-26)
; the dma address in 'dmaad' (0-65535)
;
WAITIO: OUT (FDCOP),A ;start i/o operation
IN A,(FDCST) ;status of i/o operation -> A
RET
;
; the remainder of the CBIOS is reserved uninitialized
; data area, and does not need to be a part of the
; system memory image (the space must be available,
; however, between "begdat" and "enddat").
;
; scratch ram area for BDOS use
;
BEGDAT EQU $ ;beginning of data area
DIRBF: DEFS 128 ;scratch directory area
ALL00: DEFS 31 ;allocation vector 0
ALL01: DEFS 31 ;allocation vector 1
ALL02: DEFS 31 ;allocation vector 2
ALL03: DEFS 31 ;allocation vector 3
ALLHD: DEFS 255 ;allocation vector harddisk
CHK00: DEFS 16 ;check vector 0
CHK01: DEFS 16 ;check vector 1
CHK02: DEFS 16 ;check vector 2
CHK03: DEFS 16 ;check vector 3
CHKHD: DEFS 0 ;check vector harddisk
;
ENDDAT EQU $ ;end of data area
DATSIZ EQU $-BEGDAT ;size of data area
END ;of BIOS

View File

@@ -0,0 +1,74 @@
; CP/M 2.2 boot-loader for Z80-Simulator
;
; Copyright (C) 1988 by Udo Munk
;
ORG 0 ; mem base of boot
;
MSIZE EQU 64 ; mem size in kbytes
;
BIAS EQU (MSIZE-20)*1024 ; offset from 20k system
CCP EQU 3400H+BIAS ; base of the ccp
BIOS EQU CCP+1600H ; base of the bios
BIOSL EQU 0300H ; length of the bios
BOOT EQU BIOS
SIZE EQU BIOS+BIOSL-CCP ; size of cp/m system
SECTS EQU SIZE/128 ; # of sectors to load
;
; I/O ports
;
DRIVE EQU 10 ; fdc-port: # of drive
TRACK EQU 11 ; fdc-port: # of track
SECTOR EQU 12 ; fdc-port: # of sector
FDCOP EQU 13 ; fdc-port: command
FDCST EQU 14 ; fdc-port: status
DMAL EQU 15 ; dma-port: dma address low
DMAH EQU 16 ; dma-port: dma address high
;
; begin the load operation
;
COLD: LD BC,2 ; b=track 0, c=sector 2
LD D,SECTS ; d=# sectors to load
LD HL,CCP ; base transfer address
LD A,0 ; select drive A
OUT (DRIVE),A
;
; load the next sector
;
LSECT: LD A,B ; set track
OUT (TRACK),A
LD A,C ; set sector
OUT (SECTOR),A
LD A,L ; set dma address low
OUT (DMAL),A
LD A,H ; set dma adress high
OUT (DMAH),A
XOR A ; read sector
OUT (FDCOP),A
IN A,(FDCST) ; get status of fdc
CP 0 ; read successful ?
JP Z,CONT ; yes, continue
HALT ; no, halt cpu
CONT:
; go to next sector if load is incomplete
DEC D ; sects=sects-1
JP Z,BOOT ; head for the bios
;
; more sectors to load
;
; we aren't using a stack, so use <sp> as scratch register
; to hold the load address increment
;
LD SP,128 ; 128 bytes per sector
ADD HL,SP ; <hl> = <hl> + 128
;
INC C ; sector = sector + 1
LD A,C
CP 27 ; last sector of track ?
JP C,LSECT ; no, go read another
;
; end of track, increment to next track
;
LD C,1 ; sector = 1
INC B ; track = track + 1
JP LSECT ; for another group
END ; of boot loader

Binary file not shown.

View File

@@ -0,0 +1,69 @@
/*
* CP/M 2.2 Formats a simulated Disk Drive
*
* Copyright (C) 1988-2006 by Udo Munk
*
* History:
* 29-APR-88 Development on TARGON/35 with AT&T Unix System V.3
* 11-MAR-93 comments in english
* 01-OCT-06 modified to compile on modern POSIX OS's
* 18-NOV-06 added a second harddisk
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <memory.h>
#include <fcntl.h>
#define TRACK 77
#define SECTOR 26
#define HDTRACK 255
#define HDSECTOR 128
/*
* This program is able to format the following disk formats:
*
* drive A: 8" IBM SS,SD
* drive B: 8" IBM SS,SD
* drive C: 8" IBM SS,SD
* drive D: 8" IBM SS,SD
* drive I: 4MB harddisk
* drive J: 4MB harddisk
*/
int main(int argc, char *argv[])
{
register int i;
int fd;
char drive;
static unsigned char sector[128];
static char fn[] = "disks/drive?.cpm";
static char usage[] = "usage: format a | b | c | d | i | j";
if (argc != 2) {
puts(usage);
exit(1);
}
i = *argv[1];
if (argc != 2 ||
(i != 'a' && i != 'b' && i != 'c' && i != 'd' && i != 'i'
&& i != 'j')) {
puts(usage);
exit(1);
}
fn[11] = drive = (char) i;
memset((char *) sector, 0xe5, 128);
if ((fd = creat(fn, 0644)) == -1) {
perror("disk file");
exit(1);
}
if (drive != 'i' && drive != 'j') {
for (i = 0; i < TRACK * SECTOR; i++)
write(fd, (char *) sector, 128);
} else {
for (i = 0; i < HDTRACK * HDSECTOR; i++)
write(fd, (char *) sector, 128);
}
close(fd);
return(0);
}

View File

@@ -0,0 +1,106 @@
/*
* Write the CP/M systemfiles to system tracks of drive A
*
* Copyright (C) 1988-2006 by Udo Munk
*
* History:
* 29-APR-88 Development on TARGON/35 with AT&T Unix System V.3
* 11-MAR-93 comments in english and ported to COHERENT 4.0
* 02-OCT-06 modified to compile on modern POSIX OS's
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <memory.h>
/*
* This program writes the CP/M 2.2 OS from the following files
* onto the system tracks of the boot disk (drivea.cpm):
*
* boot loader boot.bin (Mostek binary format)
* CCP cpm.bin (binary format)
* BDOS cpm.bin (binary format)
* BIOS bios.bin (Mostek binary format)
*/
int main(void)
{
unsigned char header[3];
unsigned char sector[128];
register int i;
int fd, drivea, readed;
/* open drive A for writing */
if ((drivea = open("../disks/drivea.cpm", O_WRONLY)) == -1) {
perror("file ../disks/drivea.cpm");
exit(1);
}
/* open boot loader (boot.bin) for reading */
if ((fd = open("boot.bin", O_RDONLY)) == -1) {
perror("file boot.bin");
exit(1);
}
/* read and check 3 byte header */
if ((readed = read(fd, (char *) header, 3)) != 3) {
perror("file boot.bin");
exit(1);
}
if (header[0] != 0xff || header[1] != 0 || header[2] != 0) {
puts("start adress of boot.bin <> 0");
exit(0);
}
/* read boot loader */
memset((char *) sector, 0, 128);
read(fd, (char *) sector, 128);
close(fd);
/* and write it to disk in drive A */
write(drivea, (char *) sector, 128);
/* open CP/M system file (cpm.bin) for reading */
if ((fd = open("cpm.bin", O_RDONLY)) == -1) {
perror("file cpm.bin");
exit(1);
}
/* position to CCP in cpm.bin, needed if created with SAVE or similar */
lseek(fd, (long) 17 * 128, 0);
/* read CCP and BDOS from cpm.bin and write them to disk in drive A */
for (i = 0; i < 44; i++) {
if ((readed = read(fd, (char *) sector, 128)) != 128) {
perror("file cpm.bin");
exit(1);
}
write(drivea, (char *) sector, 128);
}
close(fd);
/* open BIOS (bios.bin) for reading */
if ((fd = open("bios.bin", O_RDONLY)) == -1) {
perror("file bios.bin");
exit(1);
}
/* read and check 3 byte header */
if ((readed = read(fd, (char *) header, 3)) != 3) {
perror("file bios.bin");
exit(1);
}
if (header[0] != 0xff) {
puts("unknown format of bios.bin");
exit(0);
}
/* read BIOS from bios.bin and write it to disk in drive A */
i = 0;
while ((readed = read(fd, (char *) sector, 128)) == 128) {
write(drivea, (char *) sector, 128);
i++;
if (i == 6) {
puts("6 sectors written, can't write any more!");
goto stop;
}
}
if (readed > 0) {
write(drivea, (char *) sector, 128);
}
stop:
close(fd);
close(drivea);
return(0);
}

View File

@@ -0,0 +1,56 @@
/*
* Receive a file out of the named pipe "auxout" from CP/M simulation
*
* Copyright (C) 1988-2006 by Udo Munk
*
* History:
* 05-OKT-88 Development on TARGON/35 with AT&T Unix System V.3
* 11-MAR-93 comments in english and ported to COHERENT 4.0
* 01-OCT-06 modified to compile on modern POSIX OS's
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <fcntl.h>
int fdin, fdout;
int main(int argc, char *argv[])
{
char c;
void int_handler(void);
if (argc != 2) {
puts("usage: receive filname &");
exit(1);
}
if ((fdin = open("auxout", O_RDONLY)) == -1) {
perror("pipe auxout");
exit(1);
}
if ((fdout = creat(argv[1], 0644)) == -1) {
perror(argv[1]);
exit(1);
}
signal(SIGINT, SIG_IGN);
signal(SIGQUIT, SIG_IGN);
signal(SIGHUP, int_handler);
for (;;) {
if (read(fdin, &c, 1) == 1)
if (c != '\r')
write(fdout, &c, 1);
}
return(0);
}
void int_handler(void)
{
close(fdin);
close(fdout);
exit(0);
}

View File

@@ -0,0 +1,57 @@
/*
* Sends a file through named pipe "auxin" to the CP/M simulation
*
* Copyright (C) 1988-2006 by Udo Munk
*
* History:
* 05-OKT-88 Development on TARGON/35 with AT&T Unix System V.3
* 11-MAR-93 comments in english and ported to COHERENT 4.0
* 01-OCT-06 modified to compile on modern POSIX OS's
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
void sendbuf(int);
char buf[BUFSIZ];
char cr = '\r';
int fdout, fdin;
int main(int argc,char *argv[])
{
register int readed;
if (argc != 2) {
puts("usage: send filname &");
exit(1);
}
if ((fdin = open(argv[1], O_RDONLY)) == -1) {
perror(argv[1]);
exit(1);
}
if ((fdout = open("auxin", O_WRONLY)) == -1) {
perror("pipe auxin");
exit(1);
}
while ((readed = read(fdin, buf, BUFSIZ)) == BUFSIZ)
sendbuf(BUFSIZ);
if (readed)
sendbuf(readed);
close(fdin);
close(fdout);
return(0);
}
void sendbuf(int size)
{
register char *s = buf;
while (s - buf < size) {
if (*s == '\n')
write(fdout, (char *) &cr, 1);
write(fdout, s++, 1);
}
}