diff options
author | 2021-03-04 10:49:33 +0100 | |
---|---|---|
committer | 2021-03-05 10:17:20 +0100 | |
commit | 92326e47afea2dd65ec6b5ec842454fc74f046cc (patch) | |
tree | 515de40cefa3c48bf30869f9031fbf78e4ba45d4 /src/lib/formats/fsmgr.h | |
parent | f7011c21e11e988ec26d095f48b9070760c72bc3 (diff) |
floppy: Beginning of the support for preformatted floppy images.
What's missing:
- parameters (like the disk name when it exists)
- possibly a cleanup of ram_open and friends (but not sure of the appropriate direction in which to go)
Diffstat (limited to 'src/lib/formats/fsmgr.h')
-rw-r--r-- | src/lib/formats/fsmgr.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/lib/formats/fsmgr.h b/src/lib/formats/fsmgr.h new file mode 100644 index 00000000000..0c69cef2e60 --- /dev/null +++ b/src/lib/formats/fsmgr.h @@ -0,0 +1,57 @@ +// license:BSD-3-Clause +// copyright-holders:Olivier Galibert + +// Filesystem management code for floppy and hd images + +// Currently limited to floppies and creation of preformatted images + +#ifndef MAME_FORMATS_FSMGR_H +#define MAME_FORMATS_FSMGR_H + +#pragma once + +#include "flopimg.h" + +class filesystem_manager_t { +public: + struct floppy_enumerator { + virtual ~floppy_enumerator() = default; + + virtual void add(const filesystem_manager_t *manager, floppy_format_type type, u32 image_size, const char *name, u32 key, const char *description) = 0; + virtual void add_raw(const filesystem_manager_t *manager, const char *name, u32 key, const char *description) = 0; + }; + + virtual void enumerate(floppy_enumerator &fe, uint32_t form_factor, const std::vector<uint32_t> &variants) const; + + // Floppy image initialization + virtual void floppy_instantiate(u32 key, std::vector<u8> &image) const; + + // Floppy image initialization for add_raw + virtual void floppy_instantiate_raw(u32 key, floppy_image *image) const; + +protected: + filesystem_manager_t() = default; + + static bool has_variant(const std::vector<uint32_t> &variants, uint32_t variant); + + static void copy(std::vector<u8> &image, u32 offset, const u8 *src, u32 size); + static void fill(std::vector<u8> &image, u32 offset, u8 data, u32 size); + static void wstr(std::vector<u8> &image, u32 offset, const char *str); + static void w8(std::vector<u8> &image, u32 offset, u8 data); + static void w16b(std::vector<u8> &image, u32 offset, u16 data); + static void w32b(std::vector<u8> &image, u32 offset, u32 data); + static void w16l(std::vector<u8> &image, u32 offset, u16 data); + static void w32l(std::vector<u8> &image, u32 offset, u32 data); +}; + + +typedef filesystem_manager_t *(*filesystem_manager_type)(); + +// this template function creates a stub which constructs a filesystem manager +template<class _FormatClass> +filesystem_manager_t *filesystem_manager_creator() +{ + return new _FormatClass(); +} + +#endif |