summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/alto2/a2roms.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/devices/cpu/alto2/a2roms.cpp')
-rw-r--r--src/devices/cpu/alto2/a2roms.cpp84
1 files changed, 39 insertions, 45 deletions
diff --git a/src/devices/cpu/alto2/a2roms.cpp b/src/devices/cpu/alto2/a2roms.cpp
index 53decc730a0..fe55ef21f8b 100644
--- a/src/devices/cpu/alto2/a2roms.cpp
+++ b/src/devices/cpu/alto2/a2roms.cpp
@@ -104,17 +104,20 @@ static void write_type_and_xor(void *base, int type, uint32_t addr, uint32_t dan
* @param segments number of segments in one page of the result
* @return pointer to the newly allocated memory filled with source bits
*/
-std::unique_ptr<uint8_t[]> prom_load(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages, int segments)
+template <typename T>
+std::unique_ptr<T []> prom_load(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages, int segments)
{
- size_t type = prom->type;
- size_t size = prom->size;
+ assert(sizeof(T) == prom->type);
+
+ size_t const size = prom->size;
#if DEBUG_PROM_LOAD
- uint8_t width = prom->width;
+ size_t const type = prom->type;
+ uint8_t const width = prom->width;
#endif
- std::unique_ptr<uint8_t[]> array = std::make_unique<uint8_t[]>(pages * size * type);
+ std::unique_ptr<T []> array = std::make_unique<T []>(pages * size);
- uint8_t* base = array.get();
+ uint8_t* base = reinterpret_cast<uint8_t *>(array.get());
for (int page = 0; page < pages; page++)
{
uint8_t* dst = base + (prom->type * prom->size * page);
@@ -140,47 +143,38 @@ std::unique_ptr<uint8_t[]> prom_load(running_machine& machine, const prom_load_t
}
#if DEBUG_PROM_LOAD
- switch (type) {
- case sizeof(uint8_t):
- {
- uint8_t* data = reinterpret_cast<uint8_t*>(array.get());
- for (int addr = 0; addr < pages*size; addr++) {
- if (0 == (addr % 16))
- printf("%04x:", addr);
- if (width <= 4)
- printf(" %x", data[addr]);
- else
- printf(" %02x", data[addr]);
- if (15 == (addr % 16))
- printf("\n");
- }
+ for (int addr = 0; addr < pages*size; addr++) {
+ switch (type) {
+ case sizeof(uint8_t):
+ if (0 == (addr % 16))
+ printf("%04x:", addr);
+ if (width <= 4)
+ printf(" %x", array[addr]);
+ else
+ printf(" %02x", array[addr]);
+ if (15 == (addr % 16))
+ printf("\n");
+ break;
+ case sizeof(uint16_t):
+ if (0 == (addr % 8))
+ printf("%04x:", addr);
+ printf(" %04x", array[addr]);
+ if (7 == (addr % 8))
+ printf("\n");
+ break;
+ case sizeof(uint32_t):
+ if (0 == (addr % 4))
+ printf("%04x:", addr);
+ printf(" %08x", array[addr]);
+ if (3 == (addr % 4))
+ printf("\n");
+ break;
}
- break;
- case sizeof(uint16_t):
- {
- uint16_t* data = reinterpret_cast<uint16_t*>(array.get());
- for (int addr = 0; addr < pages*size; addr++) {
- if (0 == (addr % 8))
- printf("%04x:", addr);
- printf(" %04x", data[addr]);
- if (7 == (addr % 8))
- printf("\n");
- }
- }
- break;
- case sizeof(uint32_t):
- {
- uint32_t* data = reinterpret_cast<uint32_t*>(array.get());
- for (int addr = 0; addr < pages*size; addr++) {
- if (0 == (addr % 4))
- printf("%04x:", addr);
- printf(" %08x", data[addr]);
- if (3 == (addr % 4))
- printf("\n");
- }
- }
- break;
}
#endif
return array;
}
+
+template std::unique_ptr<uint8_t []> prom_load<uint8_t>(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages, int segments);
+template std::unique_ptr<uint16_t []> prom_load<uint16_t>(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages, int segments);
+template std::unique_ptr<uint32_t []> prom_load<uint32_t>(running_machine& machine, const prom_load_t* prom, const uint8_t* src, int pages, int segments);