Skip to content

Commit

Permalink
(vector06c) Allow creation of bootable disc
Browse files Browse the repository at this point in the history
Works for up-to 16k or so.
  • Loading branch information
suborb committed Feb 17, 2020
1 parent f5469f8 commit 26d64a6
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/config/vector06c.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ OPTIONS -O2 -SO2 -iquote. -DZ80 -M -subtype=default -clib=default -Ca-IDESTDI
CLIB default -Cc-standard-escape-chars -lvector06c_clib -lndos

SUBTYPE default -Cz+rom
SUBTYPE disk -Cz+vector06c -startup=2


INCLUDE alias.inc
17 changes: 17 additions & 0 deletions lib/target/vector06c/classic/vector06c_crt0.asm
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,26 @@
defc CONSOLE_COLUMNS = 32
INCLUDE "crt/classic/crt_rules.inc"

IF startup = 2
defc CRT_ORG_CODE = 0x80
org CRT_ORG_CODE

defb $00, $00, $00, $00, $10, $00, $00, $01, $01, $01, $03, $01, $05, $00, $50, $00
defb $28, $00, $04, $0f, $00, $87, $01, $7f, $00, $c0, $00, $20, $00, $08, $00, $fc
defb $00, $00, $00, $00, $00, $00, $00, $00 ,$00, $00, $00, $00, $00, $00, $00, $00
defb $00, $00, $00, $00, $00, $00, $00, $00 ,$00, $00, $00, $00, $00, $00, $00, $00
defb $00, $00, $00, $00, $00, $00, $00, $00 ,$00, $00, $00, $00, $00, $00, $00, $00
defb $00, $00, $00, $00, $00, $00, $00, $00 ,$00, $00, $00, $00, $00, $00, $00, $00
defb $00, $00, $00, $00, $00, $00, $00, $00 ,$00, $00, $00, $00, $00, $00, $00, $00
defb $00, $00, $00, $00, $00, $00, $00, $00 ,$00, $00, $00, $00, $00, $00, $00, $00

ELSE
defc CRT_ORG_CODE = 0x0100

org CRT_ORG_CODE
ENDIF



program:
di
Expand Down
7 changes: 7 additions & 0 deletions src/appmake/appmake.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ extern option_t tixx_options;
extern int trs80_exec(char *target);
extern option_t trs80_options;

extern int vector06c_exec(char *target);
extern option_t vector06c_options;

extern int vg5k_exec(char *target);
extern option_t vg5k_options;

Expand Down Expand Up @@ -458,6 +461,10 @@ struct {
"Creates a CMD file for the TRS 80",
NULL,
trs80_exec, &trs80_options },
{ "bin2fdd", "vector06c", "(C) 2020 z88dk",
"Create a bootable vector06c disk",
NULL,
vector06c_exec, &vector06c_options },
{ "vg5k2k7", "vg5k", "(C) 2014 Stefano Bodrato",
"Convert to Philips VG-5000 .k7 format, optionally to WAV",
NULL,
Expand Down
86 changes: 86 additions & 0 deletions src/appmake/vector06c.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* Vector06c disc generator
*
*/

#include "appmake.h"


static char *binname = NULL;
static char *crtfile = NULL;
static char *outfile = NULL;
static char help = 0;


/* Options that are available for this module */
option_t vector06c_options[] = {
{ 'h', "help", "Display this help", OPT_BOOL, &help},
{ 'b', "binfile", "Linked binary file", OPT_STR, &binname },
{ 'c', "crt0file", "crt0 file used in linking", OPT_STR, &crtfile },
{ 'o', "output", "Name of output file", OPT_STR, &outfile },
{ 0 , NULL, NULL, OPT_NONE, NULL }
};



int vector06c_exec(char *target)
{
char *buf = NULL;
char filename[FILENAME_MAX+1];
FILE *fpin;
disc_handle *h;
long pos;
int t,s,head = 0;
int offs;

if ( help )
return -1;

if ( binname == NULL ) {
return -1;
}

strcpy(filename, binname);
if ( ( fpin = fopen_bin(binname, crtfile) ) == NULL ) {
exit_log(1,"Cannot open binary file <%s>\n",binname);
}

if (fseek(fpin, 0, SEEK_END)) {
fclose(fpin);
exit_log(1,"Couldn't determine size of file\n");
}

pos = ftell(fpin);
fseek(fpin, 0L, SEEK_SET);
buf = must_malloc(pos);
fread(buf, 1, pos, fpin);
fclose(fpin);

h = cpm_create_with_format("vector06c");

disc_write_boot_track(h, buf, 512);

offs = 512;
head = t = 0;
s = 1;
while ( offs < pos ) {
disc_write_sector(h,t,s,head,&buf[offs]);
offs += 512;
s++;
if ( s == 10 ) {
head ^= 1;
if ( head == 0 ) {
t++;
}
s = 0;
}
}


suffix_change(filename, ".fdd");
disc_write_raw(h, filename);
free(buf);

return 0;
}

0 comments on commit 26d64a6

Please sign in to comment.