21 static unsigned char dskfrmt[] = {
22 #include "cbmformat.inc"
28 "Usage: cbmformat [OPTION]... DRIVE NAME,ID\n"
29 "Fast CBM-1541 disk formatter\n"
31 " -h, --help display this help and exit\n"
32 " -V, --version display version information and exit\n"
33 " -@, --adapter=plugin:bus tell OpenCBM which backend plugin and bus to use\n"
35 " -n, --no-bump do not bump drive head\n"
36 " -x, --extended format 40 track disk\n"
37 " -c, --clear clear (demagnetize) this disk.\n"
38 " this is highly recommended if this disk\n"
39 " is used for the first time.\n"
40 " -v, --verify verify each track after it is written\n"
41 " -o, --original fill sectors with the original pattern\n"
42 " (0x4b, 0x01...) instead of zeroes\n"
43 " -s, --status display drive status after formatting\n"
44 " -p, --progress display progress indicator\n"
49 static void hint(
char *s)
51 fprintf(stderr,
"Try `%s' -h for more information.\n", s);
54 int ARCH_MAINDECL
main(
int argc,
char *argv[])
56 int status = 0, id_ofs = 0, name_len, i;
58 unsigned char drive, tracks = 35, bump = 1, orig = 0, show_progress = 0;
59 unsigned char verify = 0;
60 unsigned char demagnetize = 0;
61 char cmd[40], name[20], *arg;
66 struct option longopts[] =
68 {
"help" , no_argument , NULL,
'h' },
69 {
"version" , no_argument , NULL,
'V' },
70 {
"adapter" , required_argument, NULL,
'@' },
71 {
"no-bump" , no_argument , NULL,
'n' },
72 {
"extended" , no_argument , NULL,
'x' },
73 {
"original" , no_argument , NULL,
'o' },
74 {
"status" , no_argument , NULL,
's' },
75 {
"progress" , no_argument , NULL,
'p' },
76 {
"verify" , no_argument , NULL,
'v' },
77 {
"clear" , no_argument , NULL,
'c' },
80 {
"end-track" , required_argument, NULL,
't' },
81 { NULL , 0 , NULL, 0 }
84 const char shortopts[] =
"hVnxospvct:@:";
85 while((option = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1)
95 case 'x': tracks = 40;
99 case 'V': printf(
"cbmformat %s\n", OPENCBM_VERSION);
101 case 'p': show_progress = 1;
103 case 'v': verify = 1;
105 case 'c': demagnetize = 1;
107 case 't': tracks = arch_atoc(optarg);
109 case '@':
if (adapter == NULL)
113 fprintf(stderr,
"--adapter/-@ given more than once.");
118 default : hint(argv[0]);
123 if(optind + 2 != argc)
125 fprintf(stderr,
"Usage: %s [OPTION]... DRIVE NAME,ID\n", argv[0]);
130 arg = argv[optind++];
131 drive = arch_atoc(arg);
132 if(drive < 8 || drive > 11)
134 fprintf(stderr,
"Invalid drive number (%s)\n", arg);
138 arg = argv[optind++];
143 c = (
unsigned char) toupper(*arg);
148 fprintf(stderr,
"More than one `,' in disk name\n");
153 name[name_len++] = c;
156 fprintf(stderr,
"Disk name too long\n");
165 cbm_upload(fd, drive, 0x0500, dskfrmt,
sizeof(dskfrmt));
166 sprintf(cmd,
"M-E%c%c%c%c%c%c%c%c0:%s", 3, 5, tracks + 1,
167 orig, bump, show_progress, demagnetize, verify, name);
174 for(i = 1; i <= tracks; i++)
194 if(!err && (tracks > 35))
char * cbmlibmisc_strdup(const char *const OldString)
Duplicate a given string.
int CBMAPIDECL cbm_listen(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Send a LISTEN on the IEC serial bus.
void cbmlibmisc_strfree(const char *String)
Free a string.
int CBMAPIDECL cbm_device_status(CBM_FILE HandleDevice, unsigned char DeviceAddress, void *Buffer, size_t BufferLength)
Read the drive status from a floppy.
int CBMAPIDECL cbm_close(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress)
Close a file on the IEC serial bus.
const char *CBMAPIDECL cbm_get_driver_name_ex(char *Adapter)
Get the name of the driver for a specific parallel port, extended version.
int ARCH_MAINDECL main(int argc, char **argv)
Initialize the xum1541 device This function tries to find and identify the xum1541 device...
int CBMAPIDECL cbm_driver_open_ex(CBM_FILE *HandleDevice, char *Adapter)
Opens the driver, extended version.
void CBMAPIDECL cbm_iec_set(CBM_FILE HandleDevice, int Line)
Activate a line on the IEC serial bus.
int CBMAPIDECL cbm_raw_write(CBM_FILE HandleDevice, const void *Buffer, size_t Count)
Write data to the IEC serial bus.
void CBMAPIDECL cbm_driver_close(CBM_FILE HandleDevice)
Closes the driver.
int CBMAPIDECL cbm_unlisten(CBM_FILE HandleDevice)
Send an UNLISTEN on the IEC serial bus.
void CBMAPIDECL cbm_iec_release(CBM_FILE HandleDevice, int Line)
Deactivate a line on the IEC serial bus.
int CBMAPIDECL cbm_open(CBM_FILE HandleDevice, unsigned char DeviceAddress, unsigned char SecondaryAddress, const void *Filename, size_t FilenameLength)
Open a file on the IEC serial bus.
int CBMAPIDECL cbm_iec_wait(CBM_FILE HandleDevice, int Line, int State)
Wait for a line to have a specific state.
int CBMAPIDECL cbm_exec_command(CBM_FILE HandleDevice, unsigned char DeviceAddress, const void *Command, size_t Size)
Executes a command in the floppy drive.
DLL interface for accessing the driver.
Define makros and functions which account for differences between the different architectures.
int CBMAPIDECL cbm_upload(CBM_FILE HandleDevice, unsigned char DeviceAddress, int DriveMemAddress, const void *Program, size_t Size)
Upload a program into a floppy's drive memory.
Some functions for string handling.