Changes to logging - nothing (other than some parts of pc.c) uses the global pclog anymore (and logs will be almost empty (until the base set logging flags is agreed upon);

Fixes to various hard disk controllers;
Added the Packard Bell PB640;
Fixed the InPort mouse emulation - now it works correctly on Windows NT 3.1;
Removed the status window and the associated variables;
Completely removed the Green B 486 machine;
Fixed the MDSI Genius;
Fixed the single-sided 5.25" floppy drive;
Ported a CPU-related commit from VARCem.
This commit is contained in:
OBattler
2018-05-21 19:04:05 +02:00
parent 534ed6ea32
commit 5d8deea63b
130 changed files with 5062 additions and 3262 deletions

View File

@@ -5,11 +5,13 @@
Pentium - 45kHz*/
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <wchar.h>
#define HAVE_STDARG_H
#include "../86box.h"
#include "../io.h"
#include "../pic.h"
@@ -29,17 +31,6 @@
void pollsb(void *p);
void sb_poll_i(void *p);
//#define SB_DSP_RECORD_DEBUG
//#define SB_TEST_RECORDING_SAW
#ifdef SB_DSP_RECORD_DEBUG
FILE* soundf = 0/*NULL*/;
#endif
#ifdef SB_TEST_RECORDING_SAW
int counttest;
#endif
static int sbe2dat[4][9] = {
{ 0x01, -0x02, -0x04, 0x08, -0x10, 0x20, 0x40, -0x80, -106 },
{ -0x01, 0x02, -0x04, 0x08, 0x10, -0x20, 0x40, -0x80, 165 },
@@ -119,6 +110,27 @@ uint16_t sb_dsp_versions[] = {0, 0, 0x105, 0x200, 0x201, 0x300, 0x302, 0x405, 0x
float low_fir_sb16_coef[SB16_NCoef];
#ifdef ENABLE_SB_DSP_LOG
int sb_dsp_do_log = ENABLE_SB_DSP_LOG;
#endif
static void
sb_dsp_log(const char *fmt, ...)
{
#ifdef ENABLE_SB_DSP_LOG
va_list ap;
if (sb_dsp_do_log) {
va_start(ap, fmt);
pclog_ex(fmt, ap);
va_end(ap);
}
#endif
}
static inline double sinc(double x)
{
return sin(M_PI * x) / (M_PI * x);
@@ -156,7 +168,7 @@ static void recalc_sb16_filter(int playback_freq)
void sb_irq(sb_dsp_t *dsp, int irq8)
{
// pclog("IRQ %i %02X\n",irq8,pic.mask);
sb_dsp_log("IRQ %i %02X\n",irq8,pic.mask);
if (irq8) dsp->sb_irq8 = 1;
else dsp->sb_irq16 = 1;
picint(1 << dsp->sb_irqnum);
@@ -195,14 +207,6 @@ void sb_dsp_reset(sb_dsp_t *dsp)
picintc(1 << dsp->sb_irqnum);
dsp->asp_data_len = 0;
#ifdef SB_DSP_RECORD_DEBUG
if (soundf != 0)
{
fclose(soundf);
soundf=0;
}
#endif
}
void sb_doreset(sb_dsp_t *dsp)
@@ -260,7 +264,6 @@ void sb_start_dma(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int len
timer_update_outstanding();
dsp->sbleftright = 0;
dsp->sbdacpos = 0;
// pclog("Start 8-bit DMA addr %06X len %04X\n",dma.ac[1]+(dma.page[1]<<16),len);
}
else
{
@@ -274,7 +277,6 @@ void sb_start_dma(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int len
timer_process();
dsp->sbenable = dsp->sb_16_enable;
timer_update_outstanding();
// pclog("Start 16-bit DMA addr %06X len %04X\n",dma16.ac[1]+(dma16.page[1]<<16),len);
}
}
@@ -282,13 +284,6 @@ void sb_start_dma_i(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int l
{
if (dma8)
{
#ifdef SB_TEST_RECORDING_SAW
switch (dsp->sb_8_format)
{
case 00:case 20:counttest=0x80;break;
case 10:case 30:counttest=0;break;
}
#endif
dsp->sb_8_length = len;
dsp->sb_8_format = format;
dsp->sb_8_autoinit = autoinit;
@@ -299,17 +294,9 @@ void sb_start_dma_i(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int l
timer_process();
dsp->sb_enable_i = dsp->sb_8_enable;
timer_update_outstanding();
// pclog("Start 8-bit input DMA addr %06X len %04X\n",dma.ac[1]+(dma.page[1]<<16),len);
}
else
{
#ifdef SB_TEST_RECORDING_SAW
switch (dsp->sb_16_format)
{
case 00:case 20:counttest=0x8000;break;
case 10:case 30:counttest=0;break;
}
#endif
dsp->sb_16_length = len;
dsp->sb_16_format = format;
dsp->sb_16_autoinit = autoinit;
@@ -320,18 +307,8 @@ void sb_start_dma_i(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int l
timer_process();
dsp->sb_enable_i = dsp->sb_16_enable;
timer_update_outstanding();
// pclog("Start 16-bit input DMA addr %06X len %04X\n",dma.ac[1]+(dma.page[1]<<16),len);
}
memset(dsp->record_buffer,0,sizeof(dsp->record_buffer));
#ifdef SB_DSP_RECORD_DEBUG
if (soundf != 0)
{
fclose(soundf);
soundf=0;
}
#endif
}
int sb_8_read_dma(sb_dsp_t *dsp)
@@ -341,10 +318,6 @@ int sb_8_read_dma(sb_dsp_t *dsp)
void sb_8_write_dma(sb_dsp_t *dsp, uint8_t val)
{
dma_channel_write(dsp->sb_8_dmanum, val);
#ifdef SB_DSP_RECORD_DEBUG
if (!soundf) soundf=fopen("sound_dsp.pcm","wb");
fwrite(&val,1,1,soundf);
#endif
}
int sb_16_read_dma(sb_dsp_t *dsp)
{
@@ -353,10 +326,6 @@ int sb_16_read_dma(sb_dsp_t *dsp)
int sb_16_write_dma(sb_dsp_t *dsp, uint16_t val)
{
int ret = dma_channel_write(dsp->sb_16_dmanum, val);
#ifdef SB_DSP_RECORD_DEBUG
if (!soundf) soundf=fopen("sound_dsp.pcm","wb");
fwrite(&val,2,1,soundf);
#endif
return (ret == DMA_NODATA);
}
@@ -377,7 +346,7 @@ void sb_dsp_setdma16(sb_dsp_t *dsp, int dma)
void sb_exec_command(sb_dsp_t *dsp)
{
int temp,c;
// pclog("sb_exec_command : SB command %02X\n", dsp->sb_command);
sb_dsp_log("sb_exec_command : SB command %02X\n", dsp->sb_command);
switch (dsp->sb_command)
{
case 0x01: /*???*/
@@ -397,7 +366,6 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0x17: /*2-bit ADPCM output with reference*/
dsp->sbref = sb_8_read_dma(dsp);
dsp->sbstep = 0;
// pclog("Ref byte 2 %02X\n",sbref);
case 0x16: /*2-bit ADPCM output*/
sb_start_dma(dsp, 1, 0, ADPCM_2, dsp->sb_data[0] + (dsp->sb_data[1] << 8));
dsp->sbdat2 = sb_8_read_dma(dsp);
@@ -459,7 +427,7 @@ void sb_exec_command(sb_dsp_t *dsp)
dsp->sblatcho = dsp->sblatchi = TIMER_USEC * (256 - dsp->sb_data[0]);
temp = 256 - dsp->sb_data[0];
temp = 1000000 / temp;
// pclog("Sample rate - %ihz (%i)\n",temp, dsp->sblatcho);
sb_dsp_log("Sample rate - %ihz (%i)\n",temp, dsp->sblatcho);
if (dsp->sb_freq != temp && dsp->sb_type >= SB16)
recalc_sb16_filter(temp);
dsp->sb_freq = temp;
@@ -468,7 +436,7 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0x42: /*Set input sampling rate*/
if (dsp->sb_type < SB16) break;
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);
sb_dsp_log("Sample rate - %ihz (%i)\n",dsp->sb_data[1]+(dsp->sb_data[0]<<8), dsp->sblatcho);
temp = dsp->sb_freq;
dsp->sb_freq = dsp->sb_data[1] + (dsp->sb_data[0] << 8);
dsp->sb_timeo = 256LL + dsp->sb_freq;
@@ -483,7 +451,6 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0x75: /*4-bit ADPCM output with reference*/
dsp->sbref = sb_8_read_dma(dsp);
dsp->sbstep = 0;
// pclog("Ref byte 4 %02X\n",sbref);
case 0x74: /*4-bit ADPCM output*/
sb_start_dma(dsp, 1, 0, ADPCM_4, dsp->sb_data[0] + (dsp->sb_data[1] << 8));
dsp->sbdat2 = sb_8_read_dma(dsp);
@@ -494,7 +461,6 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0x77: /*2.6-bit ADPCM output with reference*/
dsp->sbref = sb_8_read_dma(dsp);
dsp->sbstep = 0;
// pclog("Ref byte 26 %02X\n",sbref);
case 0x76: /*2.6-bit ADPCM output*/
sb_start_dma(dsp, 1, 0, ADPCM_26, dsp->sb_data[0] + (dsp->sb_data[1] << 8));
dsp->sbdat2 = sb_8_read_dma(dsp);
@@ -516,7 +482,6 @@ void sb_exec_command(sb_dsp_t *dsp)
break;
case 0x80: /*Pause DAC*/
dsp->sb_pausetime = dsp->sb_data[0] + (dsp->sb_data[1] << 8);
// pclog("SB pause %04X\n",sb_pausetime);
timer_process();
dsp->sbenable = 1;
timer_update_outstanding();
@@ -540,7 +505,7 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0xA0: /*Set input mode to mono*/
case 0xA8: /*Set input mode to stereo*/
if (dsp->sb_type < SB2 || dsp->sb_type > SBPRO2) break;
//TODO: Implement. 3.xx-only command.
/* TODO: Implement. 3.xx-only command. */
break;
case 0xB0: case 0xB1: case 0xB2: case 0xB3:
case 0xB4: case 0xB5: case 0xB6: case 0xB7: /*16-bit DMA output*/
@@ -632,11 +597,11 @@ void sb_exec_command(sb_dsp_t *dsp)
sb_add_data(dsp, dsp->sb_test);
break;
case 0xF2: /*Trigger 8-bit IRQ*/
// pclog("Trigger IRQ\n");
sb_dsp_log("Trigger IRQ\n");
sb_irq(dsp, 1);
break;
case 0xF3: /*Trigger 16-bit IRQ*/
// pclog("Trigger IRQ\n");
sb_dsp_log("Trigger IRQ\n");
sb_irq(dsp, 0);
break;
case 0xE7: /*???*/
@@ -652,13 +617,10 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0x0E: /*ASP set register*/
if (dsp->sb_type < SB16) break;
dsp->sb_asp_regs[dsp->sb_data[0]] = dsp->sb_data[1];
// pclog("ASP write reg %02X %02X\n", sb_data[0], sb_data[1]);
break;
case 0x0F: /*ASP get register*/
if (dsp->sb_type < SB16) break;
// sb_add_data(0);
sb_add_data(dsp, dsp->sb_asp_regs[dsp->sb_data[0]]);
// pclog("ASP read reg %02X %02X\n", sb_data[0], sb_asp_regs[sb_data[0]]);
break;
case 0xF8:
if (dsp->sb_type >= SB16) break;
@@ -673,10 +635,7 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0x04:
case 0x05:
break;
// default:
// fatal("Exec bad SB command %02X\n",sb_command);
/*TODO: Some more data about the DSP registeres
* http://the.earth.li/~tfm/oldpage/sb_dsp.html
* http://www.synchrondata.com/pheaven/www/area19.htm
@@ -697,7 +656,6 @@ void sb_exec_command(sb_dsp_t *dsp)
void sb_write(uint16_t a, uint8_t v, void *priv)
{
sb_dsp_t *dsp = (sb_dsp_t *)priv;
// pclog("sb_write : Write soundblaster %04X %02X %04X:%04X %02X\n",a,v,CS,pc,dsp->sb_command);
switch (a&0xF)
{
case 6: /*Reset*/
@@ -721,7 +679,7 @@ void sb_write(uint16_t a, uint8_t v, void *priv)
timer_update_outstanding();
if (dsp->asp_data_len)
{
// pclog("ASP data %i\n", dsp->asp_data_len);
sb_dsp_log("ASP data %i\n", dsp->asp_data_len);
dsp->asp_data_len--;
if (!dsp->asp_data_len)
sb_add_data(dsp, 0);
@@ -732,8 +690,6 @@ void sb_write(uint16_t a, uint8_t v, void *priv)
dsp->sb_command = v;
if (v == 0x01)
sb_add_data(dsp, 0);
// if (sb_commands[v]==-1)
// fatal("Bad SB command %02X\n",v);
dsp->sb_data_stat++;
}
else
@@ -750,7 +706,6 @@ void sb_write(uint16_t a, uint8_t v, void *priv)
uint8_t sb_read(uint16_t a, void *priv)
{
sb_dsp_t *dsp = (sb_dsp_t *)priv;
// pclog("sb_read : Read soundblaster %04X %04X:%04X\n",a,CS,pc);
switch (a & 0xf)
{
case 0xA: /*Read data*/
@@ -764,7 +719,6 @@ uint8_t sb_read(uint16_t a, void *priv)
dsp->sb_read_rp++;
dsp->sb_read_rp &= 0xFF;
}
// pclog("SB read %02X\n",sbreaddat);
return dsp->sbreaddat;
case 0xC: /*Write data ready*/
if (dsp->sb_8_enable || dsp->sb_type >= SB16)
@@ -823,7 +777,7 @@ void sb_dsp_init(sb_dsp_t *dsp, int type)
void sb_dsp_setaddr(sb_dsp_t *dsp, uint16_t addr)
{
// pclog("sb_dsp_setaddr : %04X\n", addr);
sb_dsp_log("sb_dsp_setaddr : %04X\n", addr);
if (dsp->sb_addr != 0) {
io_removehandler(dsp->sb_addr + 6, 0x0002, sb_read, NULL, NULL, sb_write, NULL, NULL, dsp);
io_removehandler(dsp->sb_addr + 0xa, 0x0006, sb_read, NULL, NULL, sb_write, NULL, NULL, dsp);
@@ -846,13 +800,11 @@ void pollsb(void *p)
int tempi,ref;
dsp->sbcount += dsp->sblatcho;
// pclog("PollSB %i %i %i %i\n",sb_8_enable,sb_8_pause,sb_pausetime,sb_8_output);
if (dsp->sb_8_enable && !dsp->sb_8_pause && dsp->sb_pausetime < 0 && dsp->sb_8_output)
{
int data[2];
sb_dsp_update(dsp);
// pclog("Dopoll %i %02X %i\n", sb_8_length, sb_8_format, sblatcho);
switch (dsp->sb_8_format)
{
case 0x00: /*Mono unsigned*/
@@ -1054,13 +1006,11 @@ void pollsb(void *p)
dsp->sbdatr = data[1];
dsp->sb_16_length -= 2;
break;
// default:
// fatal("Unrecognised SB 16-bit format %02X\n",sb_16_format);
}
if (dsp->sb_16_length < 0)
{
// pclog("16DMA over %i\n",dsp->sb_16_autoinit);
sb_dsp_log("16DMA over %i\n",dsp->sb_16_autoinit);
if (dsp->sb_16_autoinit) dsp->sb_16_length = dsp->sb_16_autolen;
else dsp->sb_16_enable = dsp->sbenable = 0;
sb_irq(dsp, 0);
@@ -1073,7 +1023,7 @@ void pollsb(void *p)
{
sb_irq(dsp, 1);
dsp->sbenable = dsp->sb_8_enable;
// pclog("SB pause over\n");
sb_dsp_log("SB pause over\n");
}
}
}
@@ -1083,28 +1033,10 @@ void sb_poll_i(void *p)
sb_dsp_t *dsp = (sb_dsp_t *)p;
int processed=0;
dsp->sb_count_i += dsp->sblatchi;
// pclog("PollSBi %i %i %i %i\n",sb_8_enable,sb_8_pause,sb_pausetime,sb_8_output);
if (dsp->sb_8_enable && !dsp->sb_8_pause && dsp->sb_pausetime < 0 && !dsp->sb_8_output)
{
switch (dsp->sb_8_format)
{
#ifdef SB_TEST_RECORDING_SAW
case 0x00: /*Unsigned mono. As the manual says, only the left channel is recorded*/
case 0x10: /*Signed mono. As the manual says, only the left channel is recorded*/
sb_8_write_dma(dsp, counttest);
counttest+=0x10;
counttest&=0xFF;
dsp->sb_8_length--;
break;
case 0x20: /*Unsigned stereo*/
case 0x30: /*Signed stereo*/
sb_8_write_dma(dsp, counttest);
sb_8_write_dma(dsp, counttest);
counttest+=0x10;
counttest&=0xFF;
dsp->sb_8_length -= 2;
break;
#else
case 0x00: /*Mono unsigned As the manual says, only the left channel is recorded*/
sb_8_write_dma(dsp, (dsp->record_buffer[dsp->record_pos_read]>>8) ^0x80);
dsp->sb_8_length--;
@@ -1131,14 +1063,10 @@ void sb_poll_i(void *p)
dsp->record_pos_read+=2;
dsp->record_pos_read&=0xFFFF;
break;
#endif
// default:
// fatal("Unrecognised SB 8-bit input format %02X\n",sb_8_format);
}
if (dsp->sb_8_length < 0)
{
// pclog("Input DMA over %i\n",sb_8_autoinit);
if (dsp->sb_8_autoinit) dsp->sb_8_length = dsp->sb_8_autolen;
else dsp->sb_8_enable = dsp->sb_enable_i = 0;
sb_irq(dsp, 1);
@@ -1149,25 +1077,6 @@ void sb_poll_i(void *p)
{
switch (dsp->sb_16_format)
{
#ifdef SB_TEST_RECORDING_SAW
case 0x00: /*Unsigned mono. As the manual says, only the left channel is recorded*/
case 0x10: /*Signed mono. As the manual says, only the left channel is recorded*/
if (sb_16_write_dma(dsp, counttest))
return;
counttest+=0x1000;
counttest&=0xFFFF;
dsp->sb_16_length--;
break;
case 0x20: /*Unsigned stereo*/
case 0x30: /*Signed stereo*/
if (sb_16_write_dma(dsp, counttest))
return;
sb_16_write_dma(dsp, counttest);
counttest+=0x1000;
counttest&=0xFFFF;
dsp->sb_16_length -= 2;
break;
#else
case 0x00: /*Unsigned mono. As the manual says, only the left channel is recorded*/
if (sb_16_write_dma(dsp, dsp->record_buffer[dsp->record_pos_read]^0x8000))
return;
@@ -1198,21 +1107,17 @@ void sb_poll_i(void *p)
dsp->record_pos_read+=2;
dsp->record_pos_read&=0xFFFF;
break;
#endif
// default:
// fatal("Unrecognised SB 16-bit input format %02X\n",sb_16_format);
}
if (dsp->sb_16_length < 0)
{
// pclog("16iDMA over %i\n",sb_16_autoinit);
if (dsp->sb_16_autoinit) dsp->sb_16_length = dsp->sb_16_autolen;
else dsp->sb_16_enable = dsp->sb_enable_i = 0;
sb_irq(dsp, 0);
}
processed=1;
}
//Assume this is direct mode
/* Assume this is direct mode */
if (!processed)
{
dsp->record_pos_read+=2;
@@ -1233,13 +1138,7 @@ void sb_dsp_update(sb_dsp_t *dsp)
dsp->buffer[dsp->pos*2 + 1] = dsp->sbdatr;
}
}
void sb_dsp_close(sb_dsp_t *dsp)
{
#ifdef SB_DSP_RECORD_DEBUG
if (soundf != 0)
{
fclose(soundf);
soundf=0;
}
#endif
}