mirror of https://git.cro.wtf/kip.git
kip-sdl: add disk creation to command line
-z 2 -0 meow.disk for example will create a 2kb disk in the file meow.disk in slot 0 no changes to IO
This commit is contained in:
parent
b4b6d214a2
commit
a10a16848c
|
@ -3,13 +3,10 @@
|
|||
#define BLK 0x200
|
||||
|
||||
typedef struct{FILE*f;W z,s;}Disk;
|
||||
Disk ds[3]; B w; W a;
|
||||
|
||||
Disk ds[3];
|
||||
B w;
|
||||
W a;
|
||||
|
||||
V disk_open(B i,IM C*n){FILE*f;f=xopen(n,"r+b"),fseek(f,0,SEEK_END),ds[i].z=ftell(f),fseek(f,0,SEEK_SET),ds[i].s=0,ds[i].f=f;}
|
||||
V disk_create(B i,IM C*n,W z){ds[i].f=xopen(n,"w+b"),ds[i].z=z,ds[i].s=0;}
|
||||
V disk_open(B i,IM C*n){FILE*f=xopen(n,"r+b");fseek(f,0,SEEK_END),ds[i].z=ftell(f),fseek(f,0,SEEK_SET),ds[i].s=0,ds[i].f=f;}
|
||||
V disk_create(B i,IM C*n,W z){FILE*f=xopen(n,"w+b");fseek(f,1024*z-1,SEEK_SET),fputc(0,f),ds[i].z=z,fseek(ds[i].f=f,0,SEEK_SET),ds[i].s=0;}
|
||||
V disk_close(B i){Disk d=ds[i];Q(d.f,d.z=0,fclose(d.f))}
|
||||
V disk_closeall(V){disk_close(1),disk_close(2),disk_close(3);}
|
||||
|
||||
|
|
19
kip.c
19
kip.c
|
@ -4,18 +4,15 @@
|
|||
#include"kip.h"
|
||||
IoDevice*ios;
|
||||
|
||||
#define x optarg
|
||||
IM C*help=
|
||||
"kip -h\n"
|
||||
" -f filename.rom\n"
|
||||
" -0 disk0.disk\n"
|
||||
" -1 disk1.disk\n"
|
||||
" -2 disk2.disk";
|
||||
|
||||
I main(I ac,C*av[]){B*b;W l;I o;C*fn=0;FILE*f;
|
||||
WH(-1!=(o=getopt(ac,av,"h0:1:2:f:")),
|
||||
Q('0'==o,disk_open(0,optarg))OR
|
||||
Q('1'==o,disk_open(1,optarg))OR
|
||||
Q('2'==o,disk_open(2,optarg))OR
|
||||
"kip -h -f filename.rom [[-z size] -N diskN.disk ...]";
|
||||
I main(I ac,C*av[]){B*b;W l,z=0;I o;C*fn=0;FILE*f;
|
||||
WH(-1!=(o=getopt(ac,av,"h0:1:2:f:z:")),
|
||||
Q('0'==o,Q(0!=z,disk_create(2,x,z),z=0)OR disk_open(0,x))OR
|
||||
Q('1'==o,Q(0!=z,disk_create(1,x,z),z=0)OR disk_open(1,x))OR
|
||||
Q('2'==o,Q(0!=z,disk_create(2,x,z),z=0)OR disk_open(2,x))OR
|
||||
Q('z'==o,Q((W)-1==(z=atoi(optarg)),die("not a number: %s",optarg)))OR
|
||||
Q('f'==o,fn=optarg)OR
|
||||
Q('h'==o,die("%s",help))OR
|
||||
Q(':'==o,die("option needs a value"))OR
|
||||
|
|
Loading…
Reference in New Issue