mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-14 13:33:48 +00:00
dos33_raw: update to put things in dos order by default
This commit is contained in:
parent
f8eb0fd058
commit
acbf9cb7c2
@ -8,25 +8,45 @@
|
|||||||
/* usage: dos33_raw track sector file */
|
/* usage: dos33_raw track sector file */
|
||||||
static void usage(char *exe_name) {
|
static void usage(char *exe_name) {
|
||||||
printf("Usage:\n");
|
printf("Usage:\n");
|
||||||
printf("\t%s disk_image track sector file\n\n",exe_name);
|
printf("\t%s disk_image track sector file start count\n\n",exe_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int dos33_sector_map[16]={
|
||||||
|
0, 7, 14, 6, 13, 5, 12, 4, 11, 3, 10, 2, 9, 1, 8, 15
|
||||||
|
};
|
||||||
|
|
||||||
|
static int goto_dos_track_sector(int fd, int track, int sector) {
|
||||||
|
|
||||||
|
int result,translated_sector;
|
||||||
|
|
||||||
|
translated_sector=dos33_sector_map[sector%16];
|
||||||
|
|
||||||
|
result=lseek(fd,(translated_sector*256)+(track*16*256),SEEK_SET);
|
||||||
|
|
||||||
|
printf("going to: T=%d S=%d (%d)\n",track,sector,translated_sector);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
unsigned int track,sector;
|
unsigned int track,sector,start,count,total;
|
||||||
int disk_image_fd;
|
int disk_image_fd;
|
||||||
int file_fd;
|
int file_fd;
|
||||||
unsigned char buffer[256];
|
unsigned char buffer[256];
|
||||||
int result;
|
int result,read_result;
|
||||||
|
|
||||||
if (argc<4) {
|
if (argc<6) {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
track=atoi(argv[2]);
|
track=atoi(argv[2]);
|
||||||
sector=atoi(argv[3]);
|
sector=atoi(argv[3]);
|
||||||
|
start=atoi(argv[5]);
|
||||||
|
count=atoi(argv[6]);
|
||||||
|
|
||||||
|
/* FIXME: check limits based on stat of file */
|
||||||
|
|
||||||
if (track>34) {
|
if (track>34) {
|
||||||
fprintf(stderr,"Warning! Unusual track number %d\n",track);
|
fprintf(stderr,"Warning! Unusual track number %d\n",track);
|
||||||
@ -50,23 +70,40 @@ int main(int argc, char **argv) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
result=lseek(disk_image_fd,(sector*256)+(track*16*256),SEEK_SET);
|
result=lseek(file_fd,(start*256),SEEK_SET);
|
||||||
|
if (result<0) {
|
||||||
|
fprintf(stderr,"Error skipping: %s\n",strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
total=0;
|
||||||
|
/* write until out of space */
|
||||||
|
while(1) {
|
||||||
|
if (total>=count) break;
|
||||||
|
|
||||||
|
read_result=read(file_fd,buffer,256);
|
||||||
|
if (read_result<0) break; /* error */
|
||||||
|
if (read_result==0) break; /* done */
|
||||||
|
|
||||||
|
result=goto_dos_track_sector(disk_image_fd,track,sector);
|
||||||
if (result<0) {
|
if (result<0) {
|
||||||
fprintf(stderr,"Error seeking: %s\n",strerror(errno));
|
fprintf(stderr,"Error seeking: %s\n",strerror(errno));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write until out of space */
|
result=write(disk_image_fd,buffer,read_result);
|
||||||
while(1) {
|
|
||||||
result=read(file_fd,buffer,256);
|
|
||||||
if (result<0) break; /* error */
|
|
||||||
if (result==0) break; /* done */
|
|
||||||
result=write(disk_image_fd,buffer,result);
|
|
||||||
if (result<0) {
|
if (result<0) {
|
||||||
fprintf(stderr,"Error writing image: %s\n",
|
fprintf(stderr,"Error writing image: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
total++;
|
||||||
|
sector++;
|
||||||
|
if (sector==16) {
|
||||||
|
sector=0;
|
||||||
|
track++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
close(file_fd);
|
close(file_fd);
|
||||||
|
12
linker_scripts/apple2_1f00.inc
Normal file
12
linker_scripts/apple2_1f00.inc
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
MEMORY {
|
||||||
|
ZP: start = $00, size = $1A, type = rw;
|
||||||
|
RAM: start = $1f00, size = $A000, file = %O;
|
||||||
|
}
|
||||||
|
|
||||||
|
SEGMENTS {
|
||||||
|
CODE: load = RAM, type = ro, align=$100;
|
||||||
|
RODATA: load = RAM, type = ro;
|
||||||
|
DATA: load = RAM, type = rw;
|
||||||
|
BSS: load = RAM, type = bss, define = yes;
|
||||||
|
ZEROPAGE: load = ZP, type = zp;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user