Changeset 9b204fa in buchla-emu for emu/fdd.c


Ignore:
Timestamp:
12/31/2017 02:32:29 PM (6 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
a2b296e
Parents:
8270a1b
Message:

Persist disk image.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • emu/fdd.c

    r8270a1b r9b204fa  
    4444#define COM_WR_SEC 0xa2
    4545#define COM_INT 0xd0
    46 #define COM_WR_TRA 0xf0
     46#define COM_WR_TRA_WP 0xf0
     47#define COM_WR_TRA 0xf2
    4748
    4849#define COM_LAT_CYC 5
     
    9899                return "COM_WR_SEC";
    99100
     101        case COM_WR_TRA_WP:
     102                return "COM_WR_TRA_WP";
     103
    100104        case COM_WR_TRA:
    101105                return "COM_WR_TRA";
     
    140144{
    141145        ver("fdd init");
    142         inf("loading disk image file %s", disk);
     146        inf("reading disk image file %s", disk);
    143147
    144148        SDL_RWops *ops = SDL_RWFromFile(disk, "rb");
    145149
    146150        if (ops == NULL) {
    147                 fail("error while opening disk image file %s", disk);
     151                fail("error while opening disk image file %s for reading", disk);
    148152        }
    149153
     
    166170{
    167171        ver("fdd quit");
     172        inf("writing disk image file %s", disk);
     173
     174        SDL_RWops *ops = SDL_RWFromFile(disk, "wb");
     175
     176        if (ops == NULL) {
     177                fail("error while opening disk image file %s for writing", disk);
     178        }
     179
     180        size_t stored = 0;
     181
     182        while (stored < SZ_DISK) {
     183                size_t n_wr = SDL_RWwrite(ops, image + stored, 1, SZ_DISK - stored);
     184
     185                if (n_wr == 0) {
     186                        fail("error while writing disk image file %s", disk);
     187                }
     188
     189                stored += n_wr;
     190        }
     191
     192        SDL_RWclose(ops);
    168193}
    169194
     
    338363
    339364                case COM_WR_TRA:
     365                case COM_WR_TRA_WP:
    340366                        state.tra_0 = false;
    341367                        fail("format not yet supported");
Note: See TracChangeset for help on using the changeset viewer.