Skip to content

Commit

Permalink
docs, comments, macro constant names
Browse files Browse the repository at this point in the history
  • Loading branch information
bkw777 committed Feb 1, 2024
1 parent bb78fa1 commit 6ff3a80
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 33 deletions.
8 changes: 5 additions & 3 deletions constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@
#define SMT_OFFSET 1240
#define PDD1_SMT 0x80
#define PDD2_SMT 0xC0
#define PDD2_ID_ADDR 0x8004
#define RAM_ADDR 0x8000
#define RAM_LEN 0x1000
#define PDD2_ID_ADDR (RAM_ADDR+0x0004)
#define PDD2_MEM_READ_MAX 252 // real drive absolute limit
#define PDD2_MEM_WRITE_MAX 127 // real drive absolute limit

Expand All @@ -191,8 +193,8 @@
// TPDD2 sysinfo data: 80 13 05 00 10 E1
#define SECTOR_CACHE_START_MSB 0x80
#define SECTOR_CACHE_START_LSB 0x13
#define SECTOR_CACHE_LEN_MSB 0x05
#define SECTOR_CACHE_LEN_LSB 0x00
//#define SECTOR_CACHE_LEN_MSB 0x05 // SECTOR_SIZE_MSB
//#define SECTOR_CACHE_LEN_LSB 0x00 // SECTOR_SIZE_LSB
#define SYSINFO_CPU 0x10 // 0x10 = HD6301
//#define MODEL 0xE1

Expand Down
37 changes: 7 additions & 30 deletions dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,10 @@ char bootstrap_fname[PATH_MAX] = {0x00};
int opr_mode = 1;
uint8_t dme = 0;
bool dme_disabled = false;
char ch[2] = {0xFF}; // 0x00 is a valid OPR command, so init to 0xFF
//uint8_t img_header_len = SECTOR_HEADER_LEN;
char ch[2] = {0xFF}; // 0x00 is a valid Operation-mode command, so init to 0xFF
const uint16_t fdc_logical_size_codes[] = FDC_LOGICAL_SIZE_CODES;
const char fdc_cmds[] = FDC_CMDS;
uint8_t rb[2048] = {0x00}; // disk image record buffer / virtual pdd2 ram
uint8_t rb[RAM_LEN] = {0x00}; // disk image record buffer / virtual pdd2 ram

FILE_ENTRY* cur_file;
int dir_depth=0;
Expand Down Expand Up @@ -302,9 +301,8 @@ int check_disk_image () {
if (disk_img_fname[0]) {
struct stat info;
stat(disk_img_fname, &info);
// allow missing or zero-byte file,
// we will create it if client issues format command
// but if file exists, sanity check based on size
// If file exists >0 bytes, sanity check based on size,
// otherwise allow missing/empty, & format command will create as needed
if (info.st_size) {
if (model==1 && info.st_size != PDD1_IMG_LEN) {
dbg(0,"Expected TPDD1 disk image file size %u\n",PDD1_IMG_LEN);
Expand All @@ -316,32 +314,11 @@ int check_disk_image () {
dbg(0,"\"%s\" is %u\n",disk_img_fname,info.st_size);
return 1;
}
//printf("%s: size=%ld\n", disk_img_fname, info.st_size);
//if (model==2 && info.st_size == PDD2_TRACKS*PDD2_SECTORS*(OLD_PDD2_HEADER_LEN+SECTOR_DATA_LEN)) {
// img_header_len = OLD_PDD2_HEADER_LEN;
// dbg(0,"Detected OLD TPDD2 disk image file format\n");
//}
}
}
return 0;
}

// TODO - search for likely TTY(s) automatically
/*
void guess_client_tty () {
struct dirent *files;
char path[] = "/dev/";
DIR *dir = opendir(path);
if (dir == NULL){dbg(0,"Cannot open \"%s\"",path); return;}
int i;
while ((files = readdir(dir)) != NULL) {
for (i=strlen(files->d_name);files->d_name[i]!='/';i--);
if (!strcmp(files->d_name+i+1,match)) dbg(0," %s",files->d_name);
}
closedir(dir);
}
*/

void resolve_client_tty_name () {
dbg(3,"%s()\n",__func__);
switch (client_tty_name[0]) {
Expand Down Expand Up @@ -685,7 +662,7 @@ void req_fdc_read_sector(uint8_t tp,uint8_t tl) {
ret_fdc_std(ERR_FDC_SUCCESS,tp,l); // 1st stage response
char t=0x00;
read_client_tty(&t,1); // read 1 byte from client
if (t==0x0D) write_client_tty(rb,l); // if it's \r send data
if (t==0x0D) write_client_tty(rb,l); // if it's \r send data, else silently abort
}

// ref/search_id_section.txt
Expand Down Expand Up @@ -1644,8 +1621,8 @@ void ret_sysinfo() {
gb[1]=0x06;
gb[2]=SECTOR_CACHE_START_MSB;
gb[3]=SECTOR_CACHE_START_LSB;
gb[4]=SECTOR_CACHE_LEN_MSB;
gb[5]=SECTOR_CACHE_LEN_LSB;
gb[4]=SECTOR_SIZE_MSB;
gb[5]=SECTOR_SIZE_LSB;
gb[6]=SYSINFO_CPU;
gb[7]=MODEL;
gb[8]=checksum(gb);
Expand Down
Binary file added junk.pdd2
Binary file not shown.

0 comments on commit 6ff3a80

Please sign in to comment.