New 'available' function in device API, to determine whether required ROMs are available. Currently used when building soundcard menu, to remove AWE32 when required ROM dump is not present.

This commit is contained in:
TomW 2013-11-04 18:23:15 +00:00
commit bd873de9ac
35 changed files with 92 additions and 39 deletions

View file

@ -3,6 +3,7 @@ typedef struct device_t
char name[50]; char name[50];
void *(*init)(); void *(*init)();
void (*close)(void *p); void (*close)(void *p);
int (*available)();
void (*speed_changed)(void *p); void (*speed_changed)(void *p);
void (*force_redraw)(void *p); void (*force_redraw)(void *p);
int (*add_status_info)(char *s, int max_len, void *p); int (*add_status_info)(char *s, int max_len, void *p);

View file

@ -14,6 +14,7 @@
#include "video.h" #include "video.h"
#include "x86.h" #include "x86.h"
#include "cpu.h" #include "cpu.h"
#include "rom.h"
static uint8_t (*_mem_read_b[0x40000])(uint32_t addr, void *priv); static uint8_t (*_mem_read_b[0x40000])(uint32_t addr, void *priv);
static uint16_t (*_mem_read_w[0x40000])(uint32_t addr, void *priv); static uint16_t (*_mem_read_w[0x40000])(uint32_t addr, void *priv);
@ -44,20 +45,6 @@ int cachesize=256;
uint8_t *ram,*rom,*vram,*vrom; uint8_t *ram,*rom,*vram,*vrom;
uint8_t romext[32768]; uint8_t romext[32768];
FILE *romfopen(char *fn, char *mode)
{
char s[512];
// pclog("romfopen %s\n", fn);
strcpy(s,pcempath);
// pclog("s = %s\n", s);
put_backslash(s);
// pclog("s = %s\n", s);
// pclog("strcat %s %s\n", s, fn);
strcat(s,fn);
// pclog("s = %s\n", s);
return fopen(s,mode);
}
static void mem_load_xtide_bios() static void mem_load_xtide_bios()
{ {
FILE *f; FILE *f;

View file

@ -134,5 +134,6 @@ device_t sis496_device =
sis496_close, sis496_close,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View file

@ -43,6 +43,16 @@ static SOUND_CARD sound_cards[] =
{"", NULL} {"", NULL}
}; };
int sound_card_available(int card)
{
if (sound_cards[card].device)
{
if (sound_cards[card].device->available)
return sound_cards[card].device->available();
}
return 1;
}
char *sound_card_getname(int card) char *sound_card_getname(int card)
{ {
return sound_cards[card].name; return sound_cards[card].name;

View file

@ -5,5 +5,6 @@ extern int sbtype;
extern int sound_card_current; extern int sound_card_current;
int sound_card_available(int card);
char *sound_card_getname(int card); char *sound_card_getname(int card);
void sound_card_init(); void sound_card_init();

View file

@ -60,5 +60,6 @@ device_t adlib_device =
adlib_close, adlib_close,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View file

@ -595,5 +595,6 @@ device_t adgold_device =
adgold_close, adgold_close,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View file

@ -177,5 +177,6 @@ device_t cms_device =
cms_close, cms_close,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View file

@ -1105,6 +1105,7 @@ device_t gus_device =
"Gravis UltraSound", "Gravis UltraSound",
gus_init, gus_init,
gus_close, gus_close,
NULL,
gus_speed_changed, gus_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -751,5 +751,6 @@ device_t pas16_device =
pas16_close, pas16_close,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View file

@ -376,6 +376,11 @@ void *sb_16_init()
return sb; return sb;
} }
int sb_awe32_available()
{
return rom_present("roms/awe32.raw");
}
void *sb_awe32_init() void *sb_awe32_init()
{ {
sb_t *sb = malloc(sizeof(sb_t)); sb_t *sb = malloc(sizeof(sb_t));
@ -429,6 +434,7 @@ device_t sb_1_device =
"Sound Blaster v1.0", "Sound Blaster v1.0",
sb_1_init, sb_1_init,
sb_close, sb_close,
NULL,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
NULL NULL
@ -438,6 +444,7 @@ device_t sb_15_device =
"Sound Blaster v1.5", "Sound Blaster v1.5",
sb_15_init, sb_15_init,
sb_close, sb_close,
NULL,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
NULL NULL
@ -447,6 +454,7 @@ device_t sb_2_device =
"Sound Blaster v2.0", "Sound Blaster v2.0",
sb_2_init, sb_2_init,
sb_close, sb_close,
NULL,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
NULL NULL
@ -456,6 +464,7 @@ device_t sb_pro_v1_device =
"Sound Blaster Pro v1", "Sound Blaster Pro v1",
sb_pro_v1_init, sb_pro_v1_init,
sb_close, sb_close,
NULL,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
NULL NULL
@ -465,6 +474,7 @@ device_t sb_pro_v2_device =
"Sound Blaster Pro v2", "Sound Blaster Pro v2",
sb_pro_v2_init, sb_pro_v2_init,
sb_close, sb_close,
NULL,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
NULL NULL
@ -474,6 +484,7 @@ device_t sb_16_device =
"Sound Blaster 16", "Sound Blaster 16",
sb_16_init, sb_16_init,
sb_close, sb_close,
NULL,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
NULL NULL
@ -483,6 +494,7 @@ device_t sb_awe32_device =
"Sound Blaster AWE32", "Sound Blaster AWE32",
sb_awe32_init, sb_awe32_init,
sb_close, sb_close,
sb_awe32_available,
sb_speed_changed, sb_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -196,5 +196,6 @@ device_t sn76489_device =
sn76489_close, sn76489_close,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View file

@ -305,5 +305,6 @@ device_t wss_device =
wss_close, wss_close,
NULL, NULL,
NULL, NULL,
NULL,
NULL NULL
}; };

View file

@ -165,6 +165,7 @@ device_t ati18800_device =
"ATI-18800", "ATI-18800",
ati18800_init, ati18800_init,
ati18800_close, ati18800_close,
NULL,
ati18800_speed_changed, ati18800_speed_changed,
ati18800_force_redraw, ati18800_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -186,6 +186,7 @@ device_t ati28800_device =
"ATI-28800", "ATI-28800",
ati28800_init, ati28800_init,
ati28800_close, ati28800_close,
NULL,
ati28800_speed_changed, ati28800_speed_changed,
ati28800_force_redraw, ati28800_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -2084,6 +2084,7 @@ device_t mach64gx_device =
"ATI Mach64GX", "ATI Mach64GX",
mach64gx_init, mach64gx_init,
mach64_close, mach64_close,
NULL,
mach64_speed_changed, mach64_speed_changed,
mach64_force_redraw, mach64_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -522,6 +522,7 @@ device_t cga_device =
"CGA", "CGA",
cga_standalone_init, cga_standalone_init,
cga_close, cga_close,
NULL,
cga_speed_changed, cga_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -855,6 +855,7 @@ device_t gd5429_device =
"Cirrus Logic GD5429", "Cirrus Logic GD5429",
gd5429_init, gd5429_init,
gd5429_close, gd5429_close,
NULL,
gd5429_speed_changed, gd5429_speed_changed,
gd5429_force_redraw, gd5429_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -839,6 +839,7 @@ device_t ega_device =
"EGA", "EGA",
ega_standalone_init, ega_standalone_init,
ega_close, ega_close,
NULL,
ega_speed_changed, ega_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -159,6 +159,7 @@ device_t et4000_device =
"Tseng Labs ET4000AX", "Tseng Labs ET4000AX",
et4000_init, et4000_init,
et4000_close, et4000_close,
NULL,
et4000_speed_changed, et4000_speed_changed,
et4000_force_redraw, et4000_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -988,6 +988,7 @@ device_t et4000w32p_device =
"Tseng Labs ET4000/w32p", "Tseng Labs ET4000/w32p",
et4000w32p_init, et4000w32p_init,
et4000w32p_close, et4000w32p_close,
NULL,
et4000w32p_speed_changed, et4000w32p_speed_changed,
et4000w32p_force_redraw, et4000w32p_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -356,6 +356,7 @@ device_t hercules_device =
"Hercules", "Hercules",
hercules_init, hercules_init,
hercules_close, hercules_close,
NULL,
hercules_speed_changed, hercules_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -313,6 +313,7 @@ device_t mda_device =
"MDA", "MDA",
mda_init, mda_init,
mda_close, mda_close,
NULL,
mda_speed_changed, mda_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -484,6 +484,7 @@ device_t m24_device =
"Olivetti M24 (video)", "Olivetti M24 (video)",
m24_init, m24_init,
m24_close, m24_close,
NULL,
m24_speed_changed, m24_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -154,6 +154,7 @@ device_t oti067_device =
"Oak OTI-067", "Oak OTI-067",
oti067_init, oti067_init,
oti067_close, oti067_close,
NULL,
oti067_speed_changed, oti067_speed_changed,
oti067_force_redraw, oti067_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -336,6 +336,7 @@ device_t paradise_pvga1a_device =
"Paradise PVGA1A", "Paradise PVGA1A",
paradise_pvga1a_init, paradise_pvga1a_init,
paradise_close, paradise_close,
NULL,
paradise_speed_changed, paradise_speed_changed,
paradise_force_redraw, paradise_force_redraw,
svga_add_status_info svga_add_status_info
@ -345,6 +346,7 @@ device_t paradise_wd90c11_device =
"Paradise WD90C11", "Paradise WD90C11",
paradise_wd90c11_init, paradise_wd90c11_init,
paradise_close, paradise_close,
NULL,
paradise_speed_changed, paradise_speed_changed,
paradise_force_redraw, paradise_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -483,6 +483,7 @@ device_t pc1512_device =
"Amstrad PC1512 (video)", "Amstrad PC1512 (video)",
pc1512_init, pc1512_init,
pc1512_close, pc1512_close,
NULL,
pc1512_speed_changed, pc1512_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -146,6 +146,7 @@ device_t pc1640_device =
"Amstrad PC1640 (video)", "Amstrad PC1640 (video)",
pc1640_init, pc1640_init,
pc1640_close, pc1640_close,
NULL,
pc1640_speed_changed, pc1640_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -136,6 +136,7 @@ device_t pc200_device =
"Amstrad PC200 (video)", "Amstrad PC200 (video)",
pc200_init, pc200_init,
pc200_close, pc200_close,
NULL,
pc200_speed_changed, pc200_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -1629,6 +1629,7 @@ device_t s3_bahamas64_device =
"Paradise Bahamas 64 (S3 Vision864)", "Paradise Bahamas 64 (S3 Vision864)",
s3_bahamas64_init, s3_bahamas64_init,
s3_close, s3_close,
NULL,
s3_speed_changed, s3_speed_changed,
s3_force_redraw, s3_force_redraw,
svga_add_status_info svga_add_status_info
@ -1639,6 +1640,7 @@ device_t s3_9fx_device =
"Number 9 9FX (S3 Trio64)", "Number 9 9FX (S3 Trio64)",
s3_9fx_init, s3_9fx_init,
s3_close, s3_close,
NULL,
s3_speed_changed, s3_speed_changed,
s3_force_redraw, s3_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -508,6 +508,7 @@ device_t s3_virge_device =
"Diamond Stealth 3D 2000 (S3 VIRGE)", "Diamond Stealth 3D 2000 (S3 VIRGE)",
s3_virge_init, s3_virge_init,
s3_virge_close, s3_virge_close,
NULL,
s3_virge_speed_changed, s3_virge_speed_changed,
s3_virge_force_redraw, s3_virge_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -693,6 +693,7 @@ device_t tandy_device =
"Tandy 1000 (video)", "Tandy 1000 (video)",
tandy_init, tandy_init,
tandy_close, tandy_close,
NULL,
tandy_speed_changed, tandy_speed_changed,
NULL, NULL,
NULL NULL

View file

@ -513,25 +513,6 @@ void tvga_force_redraw(void *p)
tvga->svga.fullchange = changeframecount; tvga->svga.fullchange = changeframecount;
} }
device_t tvga8900d_device =
{
"Trident TVGA 8900D",
tvga8900d_init,
tvga_close,
tvga_speed_changed,
tvga_force_redraw,
svga_add_status_info
};
device_t tgui9440_device =
{
"Trident TGUI 9440",
tgui9440_init,
tvga_close,
tvga_speed_changed,
tvga_force_redraw,
svga_add_status_info
};
enum enum
{ {
TGUI_BITBLT = 1 TGUI_BITBLT = 1
@ -1119,3 +1100,25 @@ void tvga_accel_write_fb_l(uint32_t addr, uint32_t val, void *p)
// pclog("tvga_accel_write_fb_l %08X %08X\n", addr, val); // pclog("tvga_accel_write_fb_l %08X %08X\n", addr, val);
tvga_accel_command(32, ((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24), tvga); tvga_accel_command(32, ((val & 0xff000000) >> 24) | ((val & 0x00ff0000) >> 8) | ((val & 0x0000ff00) << 8) | ((val & 0x000000ff) << 24), tvga);
} }
device_t tvga8900d_device =
{
"Trident TVGA 8900D",
tvga8900d_init,
tvga_close,
NULL,
tvga_speed_changed,
tvga_force_redraw,
svga_add_status_info
};
device_t tgui9440_device =
{
"Trident TGUI 9440",
tgui9440_init,
tvga_close,
NULL,
tvga_speed_changed,
tvga_force_redraw,
svga_add_status_info
};

View file

@ -119,6 +119,7 @@ device_t vga_device =
"VGA", "VGA",
vga_init, vga_init,
vga_close, vga_close,
NULL,
vga_speed_changed, vga_speed_changed,
vga_force_redraw, vga_force_redraw,
svga_add_status_info svga_add_status_info

View file

@ -561,6 +561,7 @@ int getsfile(HWND hwnd, char *f, char *fn)
extern int is486; extern int is486;
int romstolist[26], listtomodel[26], romstomodel[26], modeltolist[26]; int romstolist[26], listtomodel[26], romstomodel[26], modeltolist[26];
int vidtolist[20],listtovid[20]; int vidtolist[20],listtovid[20];
static int settings_sound_to_list[20], settings_list_to_sound[20];
int mem_list_to_size[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,32,48,64,256}; int mem_list_to_size[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,32,48,64,256};
int mem_size_to_list[]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16, int mem_size_to_list[]={0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,11,12,13,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,
@ -607,7 +608,7 @@ BOOL CALLBACK configdlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPara
SendMessage(h, CB_SETCURSEL, modeltolist[model], 0); SendMessage(h, CB_SETCURSEL, modeltolist[model], 0);
h=GetDlgItem(hdlg,IDC_COMBO2); h=GetDlgItem(hdlg,IDC_COMBO2);
for (c=0;c<6;c++) vidtolist[c]=0; memset(vidtolist, 0, sizeof(vidtolist));
c=4; c=4;
SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)"CGA"); vidtolist[GFX_CGA]=0; listtovid[0]=0; SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)"CGA"); vidtolist[GFX_CGA]=0; listtovid[0]=0;
SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)"MDA"); vidtolist[GFX_MDA]=1; listtovid[1]=1; SendMessage(h,CB_ADDSTRING,0,(LPARAM)(LPCSTR)"MDA"); vidtolist[GFX_MDA]=1; listtovid[1]=1;
@ -652,18 +653,26 @@ BOOL CALLBACK configdlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPara
SendMessage(h, CB_SETCURSEL, cpu, 0); SendMessage(h, CB_SETCURSEL, cpu, 0);
h=GetDlgItem(hdlg,IDC_COMBOSND); h=GetDlgItem(hdlg,IDC_COMBOSND);
c = 0; c = d = 0;
while (1) while (1)
{ {
char *s = sound_card_getname(c); char *s = sound_card_getname(c);
if (!s[0]) if (!s[0])
break; break;
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s); settings_sound_to_list[c] = d;
if (sound_card_available(c))
{
SendMessage(h, CB_ADDSTRING, 0, (LPARAM)(LPCSTR)s);
settings_list_to_sound[d] = c;
d++;
}
c++; c++;
} }
SendMessage(h, CB_SETCURSEL, sound_card_current, 0); SendMessage(h, CB_SETCURSEL, settings_sound_to_list[sound_card_current], 0);
h=GetDlgItem(hdlg, IDC_CHECK3); h=GetDlgItem(hdlg, IDC_CHECK3);
SendMessage(h, BM_SETCHECK, GAMEBLASTER, 0); SendMessage(h, BM_SETCHECK, GAMEBLASTER, 0);
@ -747,7 +756,7 @@ BOOL CALLBACK configdlgproc(HWND hdlg, UINT message, WPARAM wParam, LPARAM lPara
temp_GUS = SendMessage(h, BM_GETCHECK, 0, 0); temp_GUS = SendMessage(h, BM_GETCHECK, 0, 0);
h = GetDlgItem(hdlg, IDC_COMBOSND); h = GetDlgItem(hdlg, IDC_COMBOSND);
temp_sound_card_current = SendMessage(h, CB_GETCURSEL, 0, 0); temp_sound_card_current = settings_list_to_sound[SendMessage(h, CB_GETCURSEL, 0, 0)];
if (temp_model != model || gfx != gfxcard || mem != mem_size || fpu != hasfpu || temp_GAMEBLASTER != GAMEBLASTER || temp_GUS != GUS || temp_sound_card_current != sound_card_current) if (temp_model != model || gfx != gfxcard || mem != mem_size || fpu != hasfpu || temp_GAMEBLASTER != GAMEBLASTER || temp_GUS != GUS || temp_sound_card_current != sound_card_current)
{ {