A dynamic recompiler block's validity is now separate from its starting code address, should fix most of the known recompiler fatals;

The CD-ROM buffer is now dynamically malloc'd;
Did a lot of bugfixing in cdrom.c and scsi_disk.c, Debian 8's modprobe aha1542 and the NT 3.10.404.1 Trantor 310b driver now work;
Fixed the IDE IRQ/MIRQ mess and ATAPI DMA transfer length;
Fixed the operation of mmutranslate() a bit;
Commented out several instances of excess logging;
Applied the mainline PCem commit prefetch commit;
Readded missing Sound Blaster DSP MIDI behavior and gave it the correct MPU struct;
All non-IBM 486 machines now correctly have the VLB flag set.
This commit is contained in:
OBattler
2017-10-16 06:19:18 +02:00
parent 89a98e34fd
commit ed865610e9
23 changed files with 456 additions and 402 deletions

View File

@@ -1,3 +1,4 @@
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@@ -123,6 +124,24 @@ const int32_t codec_attn[]=
static void es1371_fetch(es1371_t *es1371, int dac_nr);
static void update_legacy(es1371_t *es1371);
#ifdef ENABLE_AUDIOPCI_LOG
int audiopci_do_log = ENABLE_AUDIOPCI_LOG;
#endif
void audiopci_log(const char *format, ...)
{
#ifdef ENABLE_AUDIOPCI_LOG
if (emu8k_audiopci_log)
{
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
fflush(stdout);
}
#endif
}
static void es1371_update_irqs(es1371_t *es1371)
{
int irq = 0;
@@ -143,12 +162,12 @@ static void es1371_update_irqs(es1371_t *es1371)
if (irq)
{
pci_set_irq(es1371->card, PCI_INTA);
// pclog("Raise IRQ\n");
// audiopci_log("Raise IRQ\n");
}
else
{
pci_clear_irq(es1371->card, PCI_INTA);
// pclog("Drop IRQ\n");
// audiopci_log("Drop IRQ\n");
}
}
@@ -215,10 +234,10 @@ static uint8_t es1371_inb(uint16_t port, void *p)
break;
default:
pclog("Bad es1371_inb: port=%04x\n", port);
audiopci_log("Bad es1371_inb: port=%04x\n", port);
}
// pclog("es1371_inb: port=%04x ret=%02x\n", port, ret);
// audiopci_log("es1371_inb: port=%04x ret=%02x\n", port, ret);
// output = 3;
return ret;
}
@@ -238,7 +257,7 @@ static uint16_t es1371_inw(uint16_t port, void *p)
case 0x18:
ret = es1371->legacy_ctrl & 0xffff;
// pclog("Read legacy ctrl %04x\n", ret);
// audiopci_log("Read legacy ctrl %04x\n", ret);
break;
case 0x26:
@@ -257,7 +276,7 @@ static uint16_t es1371_inw(uint16_t port, void *p)
break;
default:
pclog("Bad es1371_inw: mem_page=%x port=%04x\n", es1371->mem_page, port);
audiopci_log("Bad es1371_inw: mem_page=%x port=%04x\n", es1371->mem_page, port);
}
break;
@@ -269,15 +288,15 @@ static uint16_t es1371_inw(uint16_t port, void *p)
break;
default:
pclog("Bad es1371_inw: mem_page=%x port=%04x\n", es1371->mem_page, port);
audiopci_log("Bad es1371_inw: mem_page=%x port=%04x\n", es1371->mem_page, port);
}
break;
default:
pclog("Bad es1371_inw: port=%04x\n", port);
audiopci_log("Bad es1371_inw: port=%04x\n", port);
}
// pclog("es1371_inw: port=%04x ret=%04x %04x:%08x\n", port, ret, CS,cpu_state.pc);
// audiopci_log("es1371_inw: port=%04x ret=%04x %04x:%08x\n", port, ret, CS,cpu_state.pc);
return ret;
}
static uint32_t es1371_inl(uint16_t port, void *p)
@@ -319,7 +338,7 @@ static uint32_t es1371_inl(uint16_t port, void *p)
break;
default:
pclog("Bad es1371_inl: mem_page=%x port=%04x\n", es1371->mem_page, port);
audiopci_log("Bad es1371_inl: mem_page=%x port=%04x\n", es1371->mem_page, port);
}
break;
@@ -331,15 +350,15 @@ static uint32_t es1371_inl(uint16_t port, void *p)
break;
default:
pclog("Bad es1371_inl: mem_page=%x port=%04x\n", es1371->mem_page, port);
audiopci_log("Bad es1371_inl: mem_page=%x port=%04x\n", es1371->mem_page, port);
}
break;
default:
pclog("Bad es1371_inl: port=%04x\n", port);
audiopci_log("Bad es1371_inl: port=%04x\n", port);
}
// pclog("es1371_inl: port=%04x ret=%08x %08x\n", port, ret, cpu_state.pc);
// audiopci_log("es1371_inl: port=%04x ret=%08x %08x\n", port, ret, cpu_state.pc);
return ret;
}
@@ -347,7 +366,7 @@ static void es1371_outb(uint16_t port, uint8_t val, void *p)
{
es1371_t *es1371 = (es1371_t *)p;
// pclog("es1371_outb: port=%04x val=%02x %04x:%08x\n", port, val, cs, cpu_state.pc);
// audiopci_log("es1371_outb: port=%04x val=%02x %04x:%08x\n", port, val, cs, cpu_state.pc);
switch (port & 0x3f)
{
case 0x00:
@@ -416,14 +435,14 @@ static void es1371_outb(uint16_t port, uint8_t val, void *p)
break;
default:
pclog("Bad es1371_outb: port=%04x val=%02x\n", port, val);
audiopci_log("Bad es1371_outb: port=%04x val=%02x\n", port, val);
}
}
static void es1371_outw(uint16_t port, uint16_t val, void *p)
{
es1371_t *es1371 = (es1371_t *)p;
// pclog("es1371_outw: port=%04x val=%04x\n", port, val);
// audiopci_log("es1371_outw: port=%04x val=%04x\n", port, val);
switch (port & 0x3f)
{
case 0x0c:
@@ -439,14 +458,14 @@ static void es1371_outw(uint16_t port, uint16_t val, void *p)
break;
default:
pclog("Bad es1371_outw: port=%04x val=%04x\n", port, val);
audiopci_log("Bad es1371_outw: port=%04x val=%04x\n", port, val);
}
}
static void es1371_outl(uint16_t port, uint32_t val, void *p)
{
es1371_t *es1371 = (es1371_t *)p;
// pclog("es1371_outl: port=%04x val=%08x %04x:%08x\n", port, val, CS, cpu_state.pc);
// audiopci_log("es1371_outl: port=%04x val=%08x %04x:%08x\n", port, val, CS, cpu_state.pc);
switch (port & 0x3f)
{
case 0x04:
@@ -460,7 +479,7 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p)
es1371->sr_cir = val;
if (es1371->sr_cir & SRC_RAM_WE)
{
// pclog("Write SR RAM %02x %04x\n", es1371->sr_cir >> 25, val & 0xffff);
// audiopci_log("Write SR RAM %02x %04x\n", es1371->sr_cir >> 25, val & 0xffff);
es1371->sr_ram[es1371->sr_cir >> 25] = val & 0xffff;
switch (es1371->sr_cir >> 25)
{
@@ -506,7 +525,7 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p)
es1371->codec_ctrl = val;
if (!(val & CODEC_READ))
{
// pclog("Write codec %02x %04x\n", (val >> 16) & 0x3f, val & 0xffff);
// audiopci_log("Write codec %02x %04x\n", (val >> 16) & 0x3f, val & 0xffff);
es1371->codec_regs[(val >> 16) & 0x3f] = val & 0xffff;
switch ((val >> 16) & 0x3f)
{
@@ -553,11 +572,11 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p)
case 0xc:
es1371->dac[0].addr_latch = val;
// pclog("DAC1 addr %08x\n", val);
// audiopci_log("DAC1 addr %08x\n", val);
break;
default:
pclog("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
audiopci_log("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
}
break;
case 0x34:
@@ -581,7 +600,7 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p)
break;
default:
pclog("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
audiopci_log("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
}
break;
case 0x38:
@@ -600,7 +619,7 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p)
break;
default:
pclog("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
audiopci_log("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
}
break;
case 0x3c:
@@ -617,12 +636,12 @@ static void es1371_outl(uint16_t port, uint32_t val, void *p)
break;
default:
pclog("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
audiopci_log("Bad es1371_outl: mem_page=%x port=%04x val=%08x\n", es1371->mem_page, port, val);
}
break;
default:
pclog("Bad es1371_outl: port=%04x val=%08x\n", port, val);
audiopci_log("Bad es1371_outl: port=%04x val=%08x\n", port, val);
}
}
@@ -637,7 +656,7 @@ static void capture_event(es1371_t *es1371, int type, int rw, uint16_t port)
es1371->legacy_ctrl |= ((port << LEGACY_EVENT_ADDR_SHIFT) & LEGACY_EVENT_ADDR_MASK);
es1371->legacy_ctrl &= ~LEGACY_INT;
nmi = 1;
// pclog("Event! %s %04x\n", rw ? "write" : "read", port);
// audiopci_log("Event! %s %04x\n", rw ? "write" : "read", port);
}
static void capture_write_sscape(uint16_t port, uint8_t val, void *p)
@@ -781,7 +800,7 @@ static uint8_t es1371_pci_read(int func, int addr, void *p)
if (func)
return 0;
//pclog("ES1371 PCI read %08X PC=%08x\n", addr, cpu_state.pc);
//audiopci_log("ES1371 PCI read %08X PC=%08x\n", addr, cpu_state.pc);
switch (addr)
{
@@ -838,7 +857,7 @@ static void es1371_pci_write(int func, int addr, uint8_t val, void *p)
if (func)
return;
// pclog("ES1371 PCI write %04X %02X PC=%08x\n", addr, val, cpu_state.pc);
// audiopci_log("ES1371 PCI write %04X %02X PC=%08x\n", addr, val, cpu_state.pc);
switch (addr)
{
@@ -885,7 +904,7 @@ static void es1371_pci_write(int func, int addr, uint8_t val, void *p)
es1371->pmcsr = (es1371->pmcsr & 0x00ff) | ((val & 0x01) << 8);
break;
}
// pclog("es1371->base_addr %08x\n", es1371->base_addr);
// audiopci_log("es1371->base_addr %08x\n", es1371->base_addr);
}
static void es1371_fetch(es1371_t *es1371, int dac_nr)
@@ -894,7 +913,7 @@ static void es1371_fetch(es1371_t *es1371, int dac_nr)
int pos = es1371->dac[dac_nr].buffer_pos & 63;
int c;
//pclog("Fetch format=%i %08x %08x %08x %08x %08x\n", format, es1371->dac[dac_nr].count, es1371->dac[dac_nr].size, es1371->dac[dac_nr].curr_samp_ct,es1371->dac[dac_nr].samp_ct, es1371->dac[dac_nr].addr);
//audiopci_log("Fetch format=%i %08x %08x %08x %08x %08x\n", format, es1371->dac[dac_nr].count, es1371->dac[dac_nr].size, es1371->dac[dac_nr].curr_samp_ct,es1371->dac[dac_nr].samp_ct, es1371->dac[dac_nr].addr);
switch (format)
{
case FORMAT_MONO_8:
@@ -957,7 +976,7 @@ static void es1371_fetch(es1371_t *es1371, int dac_nr)
{
es1371->dac[dac_nr].buffer_l[(pos+c) & 63] = mem_readw_phys(es1371->dac[dac_nr].addr);
es1371->dac[dac_nr].buffer_r[(pos+c) & 63] = mem_readw_phys(es1371->dac[dac_nr].addr + 2);
// pclog("Fetch %02x %08x %04x %04x\n", (pos+c) & 63, es1371->dac[dac_nr].addr, es1371->dac[dac_nr].buffer_l[(pos+c) & 63], es1371->dac[dac_nr].buffer_r[(pos+c) & 63]);
// audiopci_log("Fetch %02x %08x %04x %04x\n", (pos+c) & 63, es1371->dac[dac_nr].addr, es1371->dac[dac_nr].buffer_l[(pos+c) & 63], es1371->dac[dac_nr].buffer_r[(pos+c) & 63]);
es1371->dac[dac_nr].addr += 4;
es1371->dac[dac_nr].buffer_pos_end++;
@@ -982,10 +1001,10 @@ static void es1371_next_sample(es1371_t *es1371, int dac_nr)
es1371->dac[dac_nr].out_l = es1371->dac[dac_nr].buffer_l[es1371->dac[dac_nr].buffer_pos & 63];
es1371->dac[dac_nr].out_r = es1371->dac[dac_nr].buffer_r[es1371->dac[dac_nr].buffer_pos & 63];
// pclog("Use %02x %04x %04x\n", es1371->dac[dac_nr].buffer_pos & 63, es1371->dac[dac_nr].out_l, es1371->dac[dac_nr].out_r);
// audiopci_log("Use %02x %04x %04x\n", es1371->dac[dac_nr].buffer_pos & 63, es1371->dac[dac_nr].out_l, es1371->dac[dac_nr].out_r);
es1371->dac[dac_nr].buffer_pos++;
// pclog("Next sample %08x %08x %08x\n", es1371->dac[dac_nr].buffer_pos, es1371->dac[dac_nr].buffer_pos_end, es1371->dac[dac_nr].curr_samp_ct);
// audiopci_log("Next sample %08x %08x %08x\n", es1371->dac[dac_nr].buffer_pos, es1371->dac[dac_nr].buffer_pos_end, es1371->dac[dac_nr].curr_samp_ct);
}
//static FILE *es1371_f;//,*es1371_f2;
@@ -997,7 +1016,7 @@ static void es1371_poll(void *p)
if (es1371->int_ctrl & INT_DAC1_EN)
{
// pclog("1Samp %i %i %08x\n", es1371->dac[0].curr_samp_ct, es1371->dac[0].samp_ct, es1371->dac[0].ac);
// audiopci_log("1Samp %i %i %08x\n", es1371->dac[0].curr_samp_ct, es1371->dac[0].samp_ct, es1371->dac[0].ac);
es1371->dac[0].ac += es1371->dac[0].vf;
if (es1371->dac[0].ac & (~0 << (15+4)))
{
@@ -1007,7 +1026,7 @@ static void es1371_poll(void *p)
es1371->dac[0].curr_samp_ct++;
if (es1371->dac[0].curr_samp_ct == es1371->dac[0].samp_ct)
{
// pclog("DAC1 IRQ\n");
// audiopci_log("DAC1 IRQ\n");
es1371->int_status |= INT_STATUS_DAC1;
es1371_update_irqs(es1371);
}
@@ -1020,7 +1039,7 @@ static void es1371_poll(void *p)
if (es1371->int_ctrl & INT_DAC2_EN)
{
// pclog("2Samp %i %i %08x\n", es1371->dac[1].curr_samp_ct, es1371->dac[1].samp_ct, es1371->dac[1].ac);
// audiopci_log("2Samp %i %i %08x\n", es1371->dac[1].curr_samp_ct, es1371->dac[1].samp_ct, es1371->dac[1].ac);
es1371->dac[1].ac += es1371->dac[1].vf;
if (es1371->dac[1].ac & (~0 << (15+4)))
{
@@ -1031,7 +1050,7 @@ static void es1371_poll(void *p)
if (es1371->dac[1].curr_samp_ct > es1371->dac[1].samp_ct)
{
es1371->dac[1].curr_samp_ct = 0;
// pclog("DAC2 IRQ\n");
// audiopci_log("DAC2 IRQ\n");
es1371->int_status |= INT_STATUS_DAC2;
es1371_update_irqs(es1371);
}

View File

@@ -1,4 +1,5 @@
#include <inttypes.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
@@ -252,11 +253,11 @@ uint32_t rep_count_w = 0;
} \
if (name == 0) \
{ \
/*pclog("EMU8K READ %04X-%02X(%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_voice,ret);*/ \
/*emu8k_log("EMU8K READ %04X-%02X(%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_voice,ret);*/ \
} \
else \
{ \
pclog("EMU8K READ %s(%d) (%d): %04X\n",name, (addr&0x2), emu8k->cur_voice, ret); \
emu8k_log("EMU8K READ %s(%d) (%d): %04X\n",name, (addr&0x2), emu8k->cur_voice, ret); \
}\
}
# define WRITE16(addr, var, val) WRITE16_SWITCH(addr, var, val) \
@@ -276,11 +277,11 @@ uint32_t rep_count_w = 0;
} \
if (name == 0) \
{ \
/*pclog("EMU8K WRITE %04X-%02X(%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_voice, val);*/ \
/*emu8k_log("EMU8K WRITE %04X-%02X(%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_voice, val);*/ \
} \
else \
{ \
pclog("EMU8K WRITE %s(%d) (%d): %04X\n",name, (addr&0x2), emu8k->cur_voice,val); \
emu8k_log("EMU8K WRITE %s(%d) (%d): %04X\n",name, (addr&0x2), emu8k->cur_voice,val); \
}\
}
@@ -290,6 +291,24 @@ uint32_t rep_count_w = 0;
#endif //EMU8K_DEBUG_REGISTERS
#ifdef ENABLE_EMU8K_LOG
int emu8k_do_log = ENABLE_EMU8K_LOG;
#endif
void emu8k_log(const char *format, ...)
{
#ifdef ENABLE_EMU8K_LOG
if (emu8k_do_log)
{
va_list ap;
va_start(ap, format);
vprintf(format, ap);
va_end(ap);
fflush(stdout);
}
#endif
}
static inline int16_t EMU8K_READ(emu8k_t *emu8k, uint32_t addr)
{
const register emu8k_mem_pointers_t addrmem = {{addr}};
@@ -360,7 +379,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p)
#ifdef EMU8K_DEBUG_REGISTERS
if (addr == 0xE22)
{
pclog("EMU8K READ POINTER: %d\n",
emu8k_log("EMU8K READ POINTER: %d\n",
((0x80 | ((random_helper + 1) & 0x1F)) << 8) | (emu8k->cur_reg << 5) | emu8k->cur_voice);
}
else if ((addr&0xF00) == 0x600)
@@ -368,7 +387,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p)
/* These are automatically reported by READ16 */
if (rep_count_r>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_r);
emu8k_log("EMU8K ...... for %d times\n", rep_count_r);
rep_count_r=0;
}
last_read=0;
@@ -378,7 +397,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p)
/* These are automatically reported by READ16 */
if (rep_count_r>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_r);
emu8k_log("EMU8K ...... for %d times\n", rep_count_r);
rep_count_r=0;
}
last_read=0;
@@ -390,13 +409,13 @@ uint16_t emu8k_inw(uint16_t addr, void *p)
{
if (rep_count_r>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_r);
emu8k_log("EMU8K ...... for %d times\n", rep_count_r);
rep_count_r=0;
}
last_read=tmpz;
pclog("EMU8K READ RAM I/O or configuration or clock \n");
emu8k_log("EMU8K READ RAM I/O or configuration or clock \n");
}
//pclog("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice);
//emu8k_log("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice);
}
else if ((addr&0xF00) == 0xA00 && (emu8k->cur_reg == 2 || emu8k->cur_reg == 3))
{
@@ -405,13 +424,13 @@ uint16_t emu8k_inw(uint16_t addr, void *p)
{
if (rep_count_r>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_r);
emu8k_log("EMU8K ...... for %d times\n", rep_count_r);
rep_count_r=0;
}
last_read=tmpz;
pclog("EMU8K READ INIT \n");
emu8k_log("EMU8K READ INIT \n");
}
//pclog("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice);
//emu8k_log("EMU8K READ %04X-%02X(%d/%d)\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice);
}
else
{
@@ -463,15 +482,15 @@ uint16_t emu8k_inw(uint16_t addr, void *p)
}
if (rep_count_r>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_r);
emu8k_log("EMU8K ...... for %d times\n", rep_count_r);
}
if (name == 0)
{
pclog("EMU8K READ %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice,val);
emu8k_log("EMU8K READ %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice,val);
}
else
{
pclog("EMU8K READ %s (%d): %04X\n",name,emu8k->cur_voice, val);
emu8k_log("EMU8K READ %s (%d): %04X\n",name,emu8k->cur_voice, val);
}
rep_count_r=0;
@@ -716,7 +735,7 @@ uint16_t emu8k_inw(uint16_t addr, void *p)
random_helper = (random_helper + 1) & 0x1F;
return ((0x80 | random_helper) << 8) | (emu8k->cur_reg << 5) | emu8k->cur_voice;
}
pclog("EMU8K READ : Unknown register read: %04X-%02X(%d/%d) \n", addr, (emu8k->cur_reg << 5) | emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice);
emu8k_log("EMU8K READ : Unknown register read: %04X-%02X(%d/%d) \n", addr, (emu8k->cur_reg << 5) | emu8k->cur_voice, emu8k->cur_reg, emu8k->cur_voice);
return 0xffff;
}
@@ -731,14 +750,14 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p)
#ifdef EMU8K_DEBUG_REGISTERS
if (addr == 0xE22)
{
//pclog("EMU8K WRITE POINTER: %d\n", val);
//emu8k_log("EMU8K WRITE POINTER: %d\n", val);
}
else if ((addr&0xF00) == 0x600)
{
/* These are automatically reported by WRITE16 */
if (rep_count_w>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_w);
emu8k_log("EMU8K ...... for %d times\n", rep_count_w);
rep_count_w=0;
}
last_write=0;
@@ -748,7 +767,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p)
/* These are automatically reported by WRITE16 */
if (rep_count_w>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_w);
emu8k_log("EMU8K ...... for %d times\n", rep_count_w);
rep_count_w=0;
}
last_write=0;
@@ -760,13 +779,13 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p)
{
if (rep_count_w>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_w);
emu8k_log("EMU8K ...... for %d times\n", rep_count_w);
rep_count_w=0;
}
last_write=tmpz;
pclog("EMU8K WRITE RAM I/O or configuration \n");
emu8k_log("EMU8K WRITE RAM I/O or configuration \n");
}
//pclog("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val);
//emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val);
}
else if ((addr&0xF00) == 0xA00 && (emu8k->cur_reg == 2 || emu8k->cur_reg == 3))
{
@@ -775,13 +794,13 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p)
{
if (rep_count_w>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_w);
emu8k_log("EMU8K ...... for %d times\n", rep_count_w);
rep_count_w=0;
}
last_write=tmpz;
pclog("EMU8K WRITE INIT \n");
emu8k_log("EMU8K WRITE INIT \n");
}
//pclog("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val);
//emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val);
}
else if (addr != 0xE22)
{
@@ -805,15 +824,15 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p)
if (rep_count_w>1)
{
pclog("EMU8K ...... for %d times\n", rep_count_w);
emu8k_log("EMU8K ...... for %d times\n", rep_count_w);
}
if (name == 0)
{
pclog("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val);
emu8k_log("EMU8K WRITE %04X-%02X(%d/%d): %04X\n",addr,(emu8k->cur_reg)<<5|emu8k->cur_voice,emu8k->cur_reg,emu8k->cur_voice, val);
}
else
{
pclog("EMU8K WRITE %s (%d): %04X\n",name,emu8k->cur_voice, val);
emu8k_log("EMU8K WRITE %s (%d): %04X\n",name,emu8k->cur_voice, val);
}
rep_count_w=0;
@@ -1481,7 +1500,7 @@ void emu8k_outw(uint16_t addr, uint16_t val, void *p)
emu8k->cur_reg = ((val >> 5) & 7);
return;
}
pclog("EMU8K WRITE: Unknown register write: %04X-%02X(%d/%d): %04X \n", addr, (emu8k->cur_reg)<<5|emu8k->cur_voice,
emu8k_log("EMU8K WRITE: Unknown register write: %04X-%02X(%d/%d): %04X \n", addr, (emu8k->cur_reg)<<5|emu8k->cur_voice,
emu8k->cur_reg,emu8k->cur_voice, val);
}
@@ -2072,10 +2091,10 @@ I've recopilated these sentences to get an idea of how to loop
emu_voice->cpf_curr_frac_addr = emu_voice->addr.fract_address;
//if ( emu_voice->cvcf_curr_volume != old_vol[c]) {
// pclog("EMUVOL (%d):%d\n", c, emu_voice->cvcf_curr_volume);
// emu8k_log("EMUVOL (%d):%d\n", c, emu_voice->cvcf_curr_volume);
// old_vol[c]=emu_voice->cvcf_curr_volume;
//}
//pclog("EMUFILT :%d\n", emu_voice->cvcf_curr_filt_ctoff);
//emu8k_log("EMUFILT :%d\n", emu_voice->cvcf_curr_filt_ctoff);
}

View File

@@ -473,7 +473,7 @@ void sb_ct1335_mixer_write(uint16_t addr, uint8_t val, void *p)
break;
default:
pclog("sb_ct1335: Unknown register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
/* pclog("sb_ct1335: Unknown register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]); */
break;
}
}
@@ -500,7 +500,7 @@ uint8_t sb_ct1335_mixer_read(uint16_t addr, void *p)
case 0x00: case 0x02: case 0x06: case 0x08: case 0x0A:
return mixer->regs[mixer->index];
default:
pclog("sb_ct1335: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
/* pclog("sb_ct1335: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]); */
break;
}
@@ -564,7 +564,7 @@ void sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p)
default:
pclog("sb_ct1345: Unknown register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
/* pclog("sb_ct1345: Unknown register WRITE: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]); */
break;
}
}
@@ -624,7 +624,7 @@ uint8_t sb_ct1345_mixer_read(uint16_t addr, void *p)
return mixer->regs[mixer->index];
default:
pclog("sb_ct1345: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
/* pclog("sb_ct1345: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]); */
break;
}
@@ -850,7 +850,7 @@ uint8_t sb_ct1745_mixer_read(uint16_t addr, void *p)
default:
pclog("sb_ct1745: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]);
/* pclog("sb_ct1745: Unknown register READ: %02X\t%02X\n", mixer->index, mixer->regs[mixer->index]); */
break;
}
@@ -869,8 +869,8 @@ static uint16_t sb_mcv_addr[8] = {0x200, 0x210, 0x220, 0x230, 0x240, 0x250, 0x26
uint8_t sb_mcv_read(int port, void *p)
{
sb_t *sb = (sb_t *)p;
pclog("sb_mcv_read: port=%04x\n", port);
/* pclog("sb_mcv_read: port=%04x\n", port); */
return sb->pos_regs[port & 7];
}
@@ -883,7 +883,7 @@ void sb_mcv_write(int port, uint8_t val, void *p)
if (port < 0x102)
return;
pclog("sb_mcv_write: port=%04x val=%02x\n", port, val);
/* pclog("sb_mcv_write: port=%04x val=%02x\n", port, val); */
addr = sb_mcv_addr[sb->pos_regs[4] & 7];
io_removehandler(addr+8, 0x0002, opl2_read, NULL, NULL, opl2_write, NULL, NULL, &sb->opl);
@@ -909,8 +909,8 @@ static int sb_pro_mcv_irqs[4] = {7, 5, 3, 3};
uint8_t sb_pro_mcv_read(int port, void *p)
{
sb_t *sb = (sb_t *)p;
pclog("sb_pro_mcv_read: port=%04x\n", port);
/* pclog("sb_pro_mcv_read: port=%04x\n", port); */
return sb->pos_regs[port & 7];
}
@@ -922,8 +922,8 @@ void sb_pro_mcv_write(int port, uint8_t val, void *p)
if (port < 0x102)
return;
pclog("sb_pro_mcv_write: port=%04x val=%02x\n", port, val);
/* pclog("sb_pro_mcv_write: port=%04x val=%02x\n", port, val); */
addr = (sb->pos_regs[2] & 0x20) ? 0x220 : 0x240;
io_removehandler(addr+0, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
@@ -965,6 +965,7 @@ void *sb_1_init()
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_set_mpu(&sb->mpu);
/* CMS I/O handler is activated on the dedicated sound_cms module
DSP I/O handler is activated in sb_dsp_setaddr */
io_sethandler(addr+8, 0x0002, opl2_read, NULL, NULL, opl2_write, NULL, NULL, &sb->opl);
@@ -1008,6 +1009,7 @@ void *sb_mcv_init()
sb_dsp_setaddr(&sb->dsp, 0);//addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_set_mpu(&sb->mpu);
sound_add_handler(sb_get_buffer_sb2, sb);
/* I/O handlers activated in sb_mcv_write */
mca_add(sb_mcv_read, sb_mcv_write, sb);
@@ -1033,6 +1035,7 @@ void *sb_2_init()
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_set_mpu(&sb->mpu);
sb_ct1335_mixer_reset(sb);
/* CMS I/O handler is activated on the dedicated sound_cms module
DSP I/O handler is activated in sb_dsp_setaddr */
@@ -1068,6 +1071,7 @@ void *sb_pro_v1_init()
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_set_mpu(&sb->mpu);
sb_ct1345_mixer_reset(sb);
/* DSP I/O handler is activated in sb_dsp_setaddr */
io_sethandler(addr+0, 0x0002, opl2_l_read, NULL, NULL, opl2_l_write, NULL, NULL, &sb->opl);
@@ -1097,6 +1101,7 @@ void *sb_pro_v2_init()
sb_dsp_setaddr(&sb->dsp, addr);
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_set_mpu(&sb->mpu);
sb_ct1345_mixer_reset(sb);
/* DSP I/O handler is activated in sb_dsp_setaddr */
io_sethandler(addr+0, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
@@ -1151,7 +1156,7 @@ void *sb_16_init()
io_sethandler(addr+4, 0x0002, sb_ct1745_mixer_read, NULL, NULL, sb_ct1745_mixer_write, NULL, NULL, sb);
sound_add_handler(sb_get_buffer_sb16, sb);
mpu401_init(&sb->mpu, device_get_config_hex16("base401"), device_get_config_int("irq401"), device_get_config_int("mode401"));
sb_dsp_set_mpu(&sb->mpu);
return sb;
}
@@ -1176,6 +1181,7 @@ void *sb_awe32_init()
sb_dsp_setirq(&sb->dsp, device_get_config_int("irq"));
sb_dsp_setdma8(&sb->dsp, device_get_config_int("dma"));
sb_dsp_setdma16(&sb->dsp, device_get_config_int("dma16"));
sb_dsp_set_mpu(&sb->mpu);
sb_ct1745_mixer_reset(sb);
io_sethandler(addr, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
io_sethandler(addr+8, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
@@ -1183,6 +1189,7 @@ void *sb_awe32_init()
io_sethandler(addr+4, 0x0002, sb_ct1745_mixer_read, NULL, NULL, sb_ct1745_mixer_write, NULL, NULL, sb);
sound_add_handler(sb_get_buffer_emu8k, sb);
mpu401_init(&sb->mpu, device_get_config_hex16("base401"), device_get_config_int("irq401"), device_get_config_int("mode401"));
sb_dsp_set_mpu(&sb->mpu);
emu8k_init(&sb->emu8k, emu_addr, onboard_ram);
return sb;

View File

@@ -44,6 +44,8 @@ static int sbe2dat[4][9] = {
{ 0x01, -0x02, 0x04, -0x08, -0x10, 0x20, -0x40, 0x80, 90 }
};
static mpu_t *mpu;
static int sb_commands[256]=
{
-1, 2,-1,-1, 1, 2,-1, 0, 1,-1,-1,-1,-1,-1, 2, 1,
@@ -142,7 +144,7 @@ void sb_dsp_reset(sb_dsp_t *dsp)
dsp->sb_read_wp = dsp->sb_read_rp = 0;
dsp->sb_data_stat = -1;
dsp->sb_speaker = 0;
dsp->sb_pausetime = -1;
dsp->sb_pausetime = -1LL;
dsp->sbe2 = 0xAA;
dsp->sbe2count = 0;
@@ -182,15 +184,15 @@ void sb_doreset(sb_dsp_t *dsp)
void sb_dsp_speed_changed(sb_dsp_t *dsp)
{
if (dsp->sb_timeo < 256)
dsp->sblatcho = TIMER_USEC * (256 - dsp->sb_timeo);
if (dsp->sb_timeo < 256LL)
dsp->sblatcho = TIMER_USEC * (256LL - dsp->sb_timeo);
else
dsp->sblatcho = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timeo - 256)));
dsp->sblatcho = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timeo - 256LL)));
if (dsp->sb_timei < 256)
dsp->sblatchi = TIMER_USEC * (256 - dsp->sb_timei);
if (dsp->sb_timei < 256LL)
dsp->sblatchi = TIMER_USEC * (256LL - dsp->sb_timei);
else
dsp->sblatchi = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timei - 256)));
dsp->sblatchi = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timei - 256LL)));
}
void sb_add_data(sb_dsp_t *dsp, uint8_t v)
@@ -205,7 +207,7 @@ void sb_add_data(sb_dsp_t *dsp, uint8_t v)
void sb_start_dma(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int len)
{
dsp->sb_pausetime = -1;
dsp->sb_pausetime = -1LL;
if (dma8)
{
dsp->sb_8_length = len;
@@ -379,8 +381,8 @@ void sb_exec_command(sb_dsp_t *dsp)
* mode does not imply such samplerate. Position is increased in sb_poll_i*/
if (dsp->sb_enable_i==0)
{
dsp->sb_timei = 256 - 22;
dsp->sblatchi = TIMER_USEC * 22;
dsp->sb_timei = 256LL - 22LL;
dsp->sblatchi = TIMER_USEC * 22LL;
temp = 1000000 / 22;
dsp->sb_freq = temp;
timer_process();
@@ -426,7 +428,7 @@ void sb_exec_command(sb_dsp_t *dsp)
dsp->sblatcho = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_data[1] + (dsp->sb_data[0] << 8))));
// pclog("Sample rate - %ihz (%i)\n",dsp->sb_data[1]+(dsp->sb_data[0]<<8), dsp->sblatcho);
dsp->sb_freq = dsp->sb_data[1] + (dsp->sb_data[0] << 8);
dsp->sb_timeo = 256 + dsp->sb_freq;
dsp->sb_timeo = 256LL + dsp->sb_freq;
dsp->sblatchi = dsp->sblatcho;
dsp->sb_timei = dsp->sb_timeo;
break;
@@ -659,8 +661,8 @@ void sb_write(uint16_t a, uint8_t v, void *priv)
return;
case 0xC: /*Command/data write*/
timer_process();
dsp->wb_time = TIMER_USEC * 1;
dsp->wb_full = 1;
dsp->wb_time = TIMER_USEC * 1LL;
dsp->wb_full = 1LL;
timer_update_outstanding();
if (dsp->asp_data_len)
{
@@ -697,6 +699,10 @@ uint8_t sb_read(uint16_t a, void *priv)
switch (a & 0xf)
{
case 0xA: /*Read data*/
if (dsp->uart_midi)
{
return MPU401_ReadData(mpu);
}
dsp->sbreaddat = dsp->sb_read_data[dsp->sb_read_rp];
if (dsp->sb_read_rp != dsp->sb_read_wp)
{
@@ -728,7 +734,12 @@ static void sb_wb_clear(void *p)
{
sb_dsp_t *dsp = (sb_dsp_t *)p;
dsp->wb_time = 0;
dsp->wb_time = 0LL;
}
void sb_dsp_set_mpu(mpu_t *src_mpu)
{
mpu = src_mpu;
}
void sb_dsp_init(sb_dsp_t *dsp, int type)
@@ -939,7 +950,7 @@ void pollsb(void *p)
sb_irq(dsp, 1);
}
}
if (dsp->sb_16_enable && !dsp->sb_16_pause && dsp->sb_pausetime < 0 && dsp->sb_16_output)
if (dsp->sb_16_enable && !dsp->sb_16_pause && dsp->sb_pausetime < 0LL && dsp->sb_16_output)
{
sb_dsp_update(dsp);
@@ -975,10 +986,10 @@ void pollsb(void *p)
sb_irq(dsp, 0);
}
}
if (dsp->sb_pausetime > -1)
if (dsp->sb_pausetime > -1LL)
{
dsp->sb_pausetime--;
if (dsp->sb_pausetime < 0)
if (dsp->sb_pausetime < 0LL)
{
sb_irq(dsp, 1);
dsp->sbenable = dsp->sb_8_enable;
@@ -1054,7 +1065,7 @@ void sb_poll_i(void *p)
}
processed=1;
}
if (dsp->sb_16_enable && !dsp->sb_16_pause && dsp->sb_pausetime < 0 && !dsp->sb_16_output)
if (dsp->sb_16_enable && !dsp->sb_16_pause && dsp->sb_pausetime < 0LL && !dsp->sb_16_output)
{
switch (dsp->sb_16_format)
{
@@ -1159,10 +1170,10 @@ void sb_dsp_add_status_info(char *s, int max_len, sb_dsp_t *dsp)
char temps[128];
int freq;
if (dsp->sb_timeo < 256)
freq = 1000000 / (256 - dsp->sb_timeo);
if (dsp->sb_timeo < 256LL)
freq = 1000000 / (256LL - dsp->sb_timeo);
else
freq = dsp->sb_timeo - 256;
freq = dsp->sb_timeo - 256LL;
if (dsp->sb_8_enable && dsp->sb_8_output)
{

View File

@@ -6,7 +6,7 @@ typedef struct sb_dsp_t
int sb_8_dmanum;
int sb_16_length, sb_16_format, sb_16_autoinit, sb_16_pause, sb_16_enable, sb_16_autolen, sb_16_output;
int sb_16_dmanum;
int sb_pausetime;
int64_t sb_pausetime;
uint8_t sb_read_data[256];
int sb_read_wp, sb_read_rp;
@@ -69,6 +69,8 @@ typedef struct sb_dsp_t
int pos;
} sb_dsp_t;
void sb_dsp_set_mpu(mpu_t *src_mpu);
void sb_dsp_init(sb_dsp_t *dsp, int type);
void sb_dsp_close(sb_dsp_t *dsp);

View File

@@ -32,6 +32,7 @@
#include "snd_adlib.h"
#include "snd_adlibgold.h"
#include "snd_audiopci.h"
#include "snd_mpu401.h"
#if defined(DEV_BRANCH) && defined(USE_PAS16)
# include "snd_pas16.h"
#endif