[a06aa8b] | 1 | /*
|
---|
| 2 | * Copyright (C) 2017 The Contributors
|
---|
| 3 | *
|
---|
| 4 | * This program is free software: you can redistribute it and/or modify
|
---|
| 5 | * it under the terms of the GNU General Public License as published by
|
---|
| 6 | * the Free Software Foundation, either version 3 of the License, or (at
|
---|
| 7 | * your option) any later version.
|
---|
| 8 | *
|
---|
| 9 | * This program is distributed in the hope that it will be useful, but
|
---|
| 10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
| 12 | * General Public License for more details.
|
---|
| 13 | *
|
---|
| 14 | * A copy of the GNU General Public License can be found in the file
|
---|
[2147e53] | 15 | * "gpl.txt" in the top directory of this repository.
|
---|
[a06aa8b] | 16 | */
|
---|
| 17 |
|
---|
| 18 | #include <all.h>
|
---|
| 19 |
|
---|
[4c71d39] | 20 | #define ver(...) _ver(fdd_verbose, 0, __VA_ARGS__)
|
---|
| 21 | #define ver2(...) _ver(fdd_verbose, 1, __VA_ARGS__)
|
---|
| 22 | #define ver3(...) _ver(fdd_verbose, 2, __VA_ARGS__)
|
---|
[a06aa8b] | 23 |
|
---|
[4c71d39] | 24 | int32_t fdd_verbose = 0;
|
---|
[a06aa8b] | 25 |
|
---|
[1efc42c] | 26 | #define N_CYL 80
|
---|
| 27 | #define N_SID 2
|
---|
| 28 | #define N_SEC 18
|
---|
| 29 | #define SZ_SEC 512
|
---|
| 30 |
|
---|
| 31 | #define SZ_DISK (N_CYL * N_SID * N_SEC * SZ_SEC)
|
---|
| 32 |
|
---|
| 33 | static uint8_t image[SZ_DISK];
|
---|
| 34 |
|
---|
[a06aa8b] | 35 | void fdd_init(void)
|
---|
| 36 | {
|
---|
| 37 | ver("fdd init");
|
---|
[1efc42c] | 38 | inf("loading disk image file %s", disk);
|
---|
| 39 |
|
---|
| 40 | SDL_RWops *ops = SDL_RWFromFile(disk, "rb");
|
---|
| 41 |
|
---|
| 42 | if (ops == NULL) {
|
---|
| 43 | fail("error while opening disk image file %s", disk);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | size_t loaded = 0;
|
---|
| 47 |
|
---|
| 48 | while (loaded < SZ_DISK) {
|
---|
| 49 | size_t n_rd = SDL_RWread(ops, image + loaded, 1, SZ_DISK - loaded);
|
---|
| 50 |
|
---|
| 51 | if (n_rd == 0) {
|
---|
| 52 | fail("error while reading disk image file %s", disk);
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | loaded += n_rd;
|
---|
| 56 | }
|
---|
| 57 |
|
---|
| 58 | SDL_RWclose(ops);
|
---|
[a06aa8b] | 59 | }
|
---|
| 60 |
|
---|
| 61 | void fdd_quit(void)
|
---|
| 62 | {
|
---|
| 63 | ver("fdd quit");
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[3c30832] | 66 | bool fdd_exec(void)
|
---|
[a06aa8b] | 67 | {
|
---|
[4c71d39] | 68 | ver3("fdd exec");
|
---|
[3c30832] | 69 | return false;
|
---|
[a06aa8b] | 70 | }
|
---|
| 71 |
|
---|
| 72 | uint32_t fdd_read(uint32_t off, int32_t sz)
|
---|
| 73 | {
|
---|
[4c71d39] | 74 | ver2("fdd rd %u:%d", off, sz * 8);
|
---|
[a06aa8b] | 75 | return 0;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | void fdd_write(uint32_t off, int32_t sz, uint32_t val)
|
---|
| 79 | {
|
---|
[4c71d39] | 80 | ver2("fdd wr %u:%d 0x%0*x", off, sz * 8, sz * 2, val);
|
---|
[a06aa8b] | 81 | }
|
---|