mirror of https://github.com/wwarthen/RomWBW.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
253 lines
4.9 KiB
253 lines
4.9 KiB
/* meta.c 6/7/2012 dwg - view and edit the metadata */
|
|
|
|
#include "stdio.h"
|
|
#include "portab.h"
|
|
#include "globals.h"
|
|
#include "cpmbios.h"
|
|
#include "bioscall.h"
|
|
#include "cpmbdos.h"
|
|
#include "bdoscall.h"
|
|
#include "sectorio.h"
|
|
#include "diagnose.h"
|
|
#include "ctermcap.h"
|
|
#include "clogical.h"
|
|
#include "metadata.h"
|
|
#include "applvers.h"
|
|
#include "cnfgdata.h"
|
|
#include "syscfg.h"
|
|
|
|
|
|
#define BDOS 5 /* memory address of BDOS invocation */
|
|
#define HIGHSEG 0x0C000 /* memory address of system config */
|
|
|
|
#define GETSYSCFG 0x0F000 /* HBIOS function for Get System Configuration */
|
|
|
|
#define METALINE 7
|
|
#define METACOL 0
|
|
|
|
/* Application Globals */
|
|
|
|
int bRunning;
|
|
int deflu;
|
|
int drive;
|
|
int logunit;
|
|
int numlu;
|
|
|
|
struct SYSCFG * pSYSCFG = HIGHSEG;
|
|
|
|
char hexchar(val, bitoff)
|
|
{
|
|
static char hexmap[] = "0123456789ABCDEF";
|
|
|
|
return hexmap[(val >> bitoff) & 0xF];
|
|
}
|
|
|
|
char * fmthexbyte(val, buf)
|
|
unsigned char val;
|
|
char * buf;
|
|
{
|
|
buf[0] = hexchar(val, 4);
|
|
buf[1] = hexchar(val, 0);
|
|
buf[2] = '\0';
|
|
|
|
return buf;
|
|
}
|
|
|
|
char * fmthexword(val, buf)
|
|
unsigned int val;
|
|
char * buf;
|
|
{
|
|
buf[0] = hexchar(val, 12);
|
|
buf[1] = hexchar(val, 8);
|
|
fmthexbyte(val, buf + 2);
|
|
|
|
return buf;
|
|
}
|
|
|
|
display()
|
|
{
|
|
int i;
|
|
char buf[5];
|
|
|
|
/* Set Current Logical Unit */
|
|
luscur(drive,logunit);
|
|
|
|
/* Read the Prefix Sector */
|
|
rdsector(drive,0,11,&metadata);
|
|
|
|
crtlc(METALINE+0,METACOL);
|
|
printf("metadata.signature = 0x%s", fmthexword(metadata.signature, buf));
|
|
|
|
crtlc(METALINE+1,METACOL);
|
|
printf("metadata.platform = 0x%s", fmthexbyte(metadata.platform, buf));
|
|
|
|
crtlc(METALINE+2,METACOL);
|
|
printf("metadata.formatter = \"");
|
|
for(i=0;i<8;i++) {
|
|
printf("%c",metadata.formatter[i]);
|
|
}
|
|
printf("\"");
|
|
|
|
crtlc(METALINE+3,METACOL);
|
|
printf("metadata.drive = %c:",metadata.drive+'A');
|
|
|
|
if(metadata.logunit != logunit) {
|
|
metadata.logunit = logunit;
|
|
metadata.update++;
|
|
wrsector(drive,0,11,&metadata);
|
|
}
|
|
|
|
crtlc(METALINE+4,METACOL);
|
|
printf("metadata.logunit = %d(rel0) of %d ",metadata.logunit,numlu);
|
|
|
|
crtlc(METALINE+5,METACOL);
|
|
printf("metadata.writeprot = ");
|
|
switch(metadata.writeprot) {
|
|
case TRUE: printf("TRUE "); break;
|
|
case FALSE: printf("FALSE"); break;
|
|
default: printf("Unk!!"); break;
|
|
}
|
|
|
|
crtlc(METALINE+6,METACOL);
|
|
printf("metadata.update = %d",metadata.update);
|
|
|
|
crtlc(METALINE+7,METACOL);
|
|
printf("metadata.{ver} = %d.%d.%d.%d",
|
|
metadata.rmj,metadata.rmn,metadata.rup,metadata.rup);
|
|
|
|
crtlc(METALINE+8,METACOL);
|
|
printf("metadata.label = \"");
|
|
for(i=0;i<16;i++) {
|
|
printf("%c",metadata.label[i]);
|
|
}
|
|
printf("\"");
|
|
crtlc(METALINE+9,METACOL);
|
|
printf("metadata.infloc = 0x%s", fmthexword(metadata.infloc, buf));
|
|
|
|
crtlc(METALINE+10,METACOL);
|
|
printf("metadata.cpmloc = 0x%s", fmthexword(metadata.cpmloc, buf));
|
|
|
|
crtlc(METALINE+11,METACOL);
|
|
printf("metadata.cpmend = 0x%s", fmthexword(metadata.cpmend, buf));
|
|
|
|
crtlc(METALINE+12,METACOL);
|
|
printf("metadata.cpment = 0x%s", fmthexword(metadata.cpment, buf));
|
|
|
|
}
|
|
|
|
int menu(state)
|
|
int state;
|
|
{
|
|
int retcode;
|
|
|
|
crtlc(METALINE+14,METACOL);
|
|
printf(" ");
|
|
printf(" ");
|
|
|
|
crtlc(METALINE+14,METACOL);
|
|
|
|
printf("Options( ");
|
|
|
|
if(0 < logunit) {
|
|
printf(" -{prev lu}");
|
|
}
|
|
|
|
|
|
if(logunit < (numlu-1)) {
|
|
printf(" +{next lu}");
|
|
}
|
|
|
|
if(TRUE == metadata.writeprot) {
|
|
printf(" u{nprotect}");
|
|
}
|
|
|
|
if(FALSE == metadata.writeprot) {
|
|
printf(" p{rotect}");
|
|
}
|
|
|
|
printf(" x{quit} ): ");
|
|
|
|
dregbc = 1;
|
|
bdoscall();
|
|
|
|
retcode = TRUE;
|
|
|
|
switch(drega) {
|
|
case 'X':
|
|
case 'x':
|
|
retcode = FALSE; break;
|
|
|
|
case '+':
|
|
if(logunit < (numlu-1)) {
|
|
logunit++;
|
|
} else {
|
|
printf("%c",7);
|
|
}
|
|
break;
|
|
|
|
case '-':
|
|
if(0 < logunit) {
|
|
logunit--;
|
|
} else {
|
|
printf("%c",7);
|
|
}
|
|
break;
|
|
|
|
case 'p':
|
|
metadata.writeprot = TRUE;
|
|
metadata.update++;
|
|
wrsector(drive,0,11,&metadata);
|
|
break;
|
|
|
|
case 'u':
|
|
metadata.writeprot = FALSE;
|
|
metadata.update++;
|
|
wrsector(drive,0,11,&metadata);
|
|
break;
|
|
|
|
default: printf("%c",7); break;
|
|
}
|
|
|
|
return retcode;
|
|
}
|
|
|
|
main(argc,argv)
|
|
int argc;
|
|
char *argv[];
|
|
{
|
|
hregbc = GETSYSCFG; /* function = Get System Config */
|
|
hregde = HIGHSEG; /* addr of dest (must be high) */
|
|
diagnose(); /* invoke the NBIOS function */
|
|
|
|
/* printf("TT is %d\n",pSYSCFG->cnfgdata.termtype); */
|
|
|
|
pSYSCFG = HIGHSEG;
|
|
crtinit(pSYSCFG->cnfgdata.termtype);
|
|
crtclr();
|
|
crtlc(0,0);
|
|
|
|
banner("META");
|
|
|
|
dregbc = RETCURRDISK;
|
|
bdoscall();
|
|
drive = drega;
|
|
|
|
numlu = lugnum(drive);
|
|
|
|
|
|
deflu = lugcur(drive);
|
|
logunit = deflu;
|
|
|
|
bRunning = TRUE;
|
|
while(TRUE == bRunning) {
|
|
display();
|
|
bRunning = menu(1);
|
|
}
|
|
|
|
luscur(drive,deflu);
|
|
crtlc(23,0);
|
|
}
|
|
|
|
|
|
|
|
|