Media history implementation for the remaining devices: Part 1.

This commit is contained in:
OBattler
2024-08-27 03:15:54 +02:00
parent 208b213aac
commit c0037eaa2f
4 changed files with 53 additions and 11 deletions

View File

@@ -21,7 +21,10 @@
extern "C" { extern "C" {
#endif #endif
#define CART_IMAGE_HISTORY 4
extern char cart_fns[2][512]; extern char cart_fns[2][512];
extern char *cart_image_history[2][CART_IMAGE_HISTORY];
extern void cart_load(int drive, char *fn); extern void cart_load(int drive, char *fn);
extern void cart_close(int drive); extern void cart_close(int drive);

View File

@@ -153,10 +153,13 @@ void pc_cas_print_state(const pc_cassette_t *cas);
void pc_cas_clock(pc_cassette_t *cas, unsigned long cnt); void pc_cas_clock(pc_cassette_t *cas, unsigned long cnt);
void pc_cas_advance(pc_cassette_t *cas); void pc_cas_advance(pc_cassette_t *cas);
#define CASSETTE_IMAGE_HISTORY 4
extern pc_cassette_t *cassette; extern pc_cassette_t *cassette;
extern char cassette_fname[512]; extern char cassette_fname[512];
extern char cassette_mode[512]; extern char cassette_mode[512];
extern char * cassette_image_history[CASSETTE_IMAGE_HISTORY];
extern unsigned long cassette_pos; extern unsigned long cassette_pos;
extern unsigned long cassette_srate; extern unsigned long cassette_srate;
extern int cassette_enable; extern int cassette_enable;

View File

@@ -24,8 +24,12 @@
extern "C" { extern "C" {
#include <86box/timer.h> #include <86box/timer.h>
#include <86box/cdrom.h> #include <86box/cassette.h>
#include <86box/cartridge.h>
#include <86box/fdd.h> #include <86box/fdd.h>
#include <86box/cdrom.h>
#include <86box/zip.h>
#include <86box/mo.h>
#include <86box/path.h> #include <86box/path.h>
} }
@@ -101,7 +105,14 @@ MediaHistoryManager::getImageForSlot(int index, int slot, ui::MediaType type)
int int
MediaHistoryManager::maxDevicesSupported(ui::MediaType type) MediaHistoryManager::maxDevicesSupported(ui::MediaType type)
{ {
return type == ui::MediaType::Cassette ? 1 : 4; switch (type) {
default:
return 4;
case ui::MediaType::Cassette:
return 1;
case ui::MediaType::Cartridge:
return 2;
}
} }
void void
@@ -164,14 +175,26 @@ MediaHistoryManager::initialDeduplication()
for (int device_index = 0; device_index < maxDevicesSupported(device_type); device_index++) { for (int device_index = 0; device_index < maxDevicesSupported(device_type); device_index++) {
device_index_list_t device_history = getHistoryListForDeviceIndex(device_index, device_type); device_index_list_t device_history = getHistoryListForDeviceIndex(device_index, device_type);
switch (device_type) { switch (device_type) {
case ui::MediaType::Optical: default:
current_image = cdrom[device_index].image_path; continue;
break;
case ui::MediaType::Cassette:
current_image = cassette_fname;
break;
case ui::MediaType::Cartridge:
current_image = cart_fns[device_index];
break; break;
case ui::MediaType::Floppy: case ui::MediaType::Floppy:
current_image = floppyfns[device_index]; current_image = floppyfns[device_index];
break; break;
default: case ui::MediaType::Optical:
continue; current_image = cdrom[device_index].image_path;
break;
case ui::MediaType::Zip:
current_image = zip[device_index].image_path;
break;
case ui::MediaType::Mo:
current_image = mo[device_index].image_path;
break; break;
} }
deduplicateList(device_history, QVector<QString>(1, current_image)); deduplicateList(device_history, QVector<QString>(1, current_image));
@@ -191,12 +214,20 @@ char **
MediaHistoryManager::getEmuHistoryVarForType(ui::MediaType type, int index) MediaHistoryManager::getEmuHistoryVarForType(ui::MediaType type, int index)
{ {
switch (type) { switch (type) {
case ui::MediaType::Optical:
return &cdrom[index].image_history[0];
case ui::MediaType::Floppy:
return &fdd_image_history[index][0];
default: default:
return nullptr; return nullptr;
case ui::MediaType::Cassette:
return &cassette_image_history[0];
case ui::MediaType::Cartridge:
return &cart_image_history[index][0];
case ui::MediaType::Floppy:
return &fdd_image_history[index][0];
case ui::MediaType::Optical:
return &cdrom[index].image_history[0];
case ui::MediaType::Zip:
return &zip[index].image_history[0];
case ui::MediaType::Mo:
return &mo[index].image_history[0];
} }
} }

View File

@@ -47,7 +47,8 @@ enum class MediaType {
Optical, Optical,
Zip, Zip,
Mo, Mo,
Cassette Cassette,
Cartridge
}; };
// This macro allows us to do a reverse lookup of the enum with `QMetaEnum` // This macro allows us to do a reverse lookup of the enum with `QMetaEnum`
Q_ENUM_NS(MediaType) Q_ENUM_NS(MediaType)
@@ -61,6 +62,10 @@ typedef QHash<ui::MediaType, device_media_history_t> master_list_t;
static const MediaType AllSupportedMediaHistoryTypes[] = { static const MediaType AllSupportedMediaHistoryTypes[] = {
MediaType::Optical, MediaType::Optical,
MediaType::Floppy, MediaType::Floppy,
MediaType::Zip,
MediaType::Mo,
MediaType::Cassette,
MediaType::Cartridge,
}; };
class MediaHistoryManager { class MediaHistoryManager {