Annotation of uae/amiga/transdisk.c, revision 1.1

1.1     ! root        1: 
        !             2: /*
        !             3:  * Transdisk V3
        !             4:  * Copyright 1995,1996 Bernd Schmidt, Marcus Sundberg
        !             5:  *
        !             6:  * Use DICE and 2.0 includes or above to compile
        !             7:  */
        !             8: 
        !             9: #include <stdio.h>
        !            10: 
        !            11: #include <exec/devices.h>
        !            12: #include <exec/io.h>
        !            13: #include <exec/memory.h>
        !            14: #include <devices/trackdisk.h>
        !            15: 
        !            16: #include <clib/alib_protos.h>
        !            17: #include <clib/exec_protos.h>
        !            18: 
        !            19: static void usage()
        !            20: {
        !            21:     fprintf(stderr, "Usage: transdisk options\n");
        !            22:     fprintf(stderr, "Recognized options:\n");
        !            23:     fprintf(stderr, "-d device unit: Use this device instead of DF0:\n");
        !            24:     fprintf(stderr, "-s n: Begin transfer at track n\n");
        !            25:     fprintf(stderr, "-e n: End transfer at track n\n");
        !            26:     fprintf(stderr, "Example:\n");
        !            27:     fprintf(stderr, "transdisk >RAM:df1.adf.1 -d trackdisk 1 -s 0 -e 39\n");
        !            28:     fprintf(stderr, "transfers the first half of the floppy in DF1: into\n");
        !            29:     fprintf(stderr, "a file in the RAM disk.\n");
        !            30: }
        !            31: 
        !            32: int main(int argc, char **argv)
        !            33: {
        !            34:     struct IOStdReq *ioreq;
        !            35:     int signal;
        !            36:     struct MsgPort *port;
        !            37: 
        !            38:     UBYTE *buffer;
        !            39:     char devicebuf[256];
        !            40:     char *devicename = "trackdisk.device";
        !            41:     char devicenum = 0;
        !            42:     int i;
        !            43:     int starttr = 0, endtr = 79;
        !            44: 
        !            45:     for (i = 1; i < argc;) {
        !            46:        if (argv[i][0] != '-' || argv[i][2] != 0) {
        !            47:            usage();
        !            48:            exit(1);
        !            49:        }
        !            50:        switch (argv[i][1]) {
        !            51:        case 'd':
        !            52:            if (i+2 >= argc) {
        !            53:                usage();
        !            54:                exit(1);
        !            55:            }
        !            56:            devicenum = atoi(argv[i+2]);
        !            57:            sprintf(devicebuf, "%s.device", argv[i+1]);
        !            58:            devicename = devicebuf;
        !            59:            i += 3;
        !            60:            break;
        !            61:        case 's':
        !            62:            if (i+1 >= argc) {
        !            63:                usage();
        !            64:                exit(1);
        !            65:            }
        !            66:            starttr = atoi(argv[i+1]);
        !            67:            i += 2;
        !            68:            break;
        !            69:        case 'e':
        !            70:            if (i+1 >= argc) {
        !            71:                usage();
        !            72:                exit(1);
        !            73:            }
        !            74:            endtr = atoi(argv[i+1]);
        !            75:            i += 2;
        !            76:            break;
        !            77:        default:
        !            78:            usage();
        !            79:            exit(1);
        !            80:        }
        !            81:     }
        !            82:     fprintf(stderr,"Using %s unit %d\n", devicename, devicenum);
        !            83:     fprintf(stderr,"First track %d, last track %d\n", starttr, endtr);
        !            84:     buffer = AllocMem(512, MEMF_CHIP);
        !            85:     port = CreatePort(0, 0);
        !            86:     if (port) {
        !            87:        ioreq = CreateStdIO(port);
        !            88:        if (ioreq) {
        !            89:            if (OpenDevice(devicename, devicenum, ioreq, 0) == 0) {
        !            90:                int tr, sec;
        !            91:                ioreq->io_Command = CMD_READ;
        !            92:                ioreq->io_Length = 512;
        !            93:                ioreq->io_Data = buffer;
        !            94:                for (tr = starttr*2; tr < (endtr+1)*2; tr++) {
        !            95:                    for (sec = 0; sec < 11; sec++) {
        !            96:                        ioreq->io_Offset = 512 * (tr * 11 + sec);
        !            97:                        DoIO(ioreq);
        !            98:                        fwrite(buffer, sizeof(UBYTE), 512, stdout);
        !            99:                    }
        !           100:                }
        !           101:                CloseDevice(ioreq);
        !           102:            } else
        !           103:                fprintf(stderr,"Unable to open %s unit %d\n", devicename, devicenum);
        !           104:            DeleteStdIO(ioreq);
        !           105:        }
        !           106:     }
        !           107:     FreeMem(buffer, 512);
        !           108: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.