Pretty much all timer counters are now 32-bit again;

Fixed FDI stream parameters passed to the 86F handler, FDI stream images now read correctly again;
The National Semiconductors PC87306 SuperI/O chip now supports enhanced FDC mode.
This commit is contained in:
OBattler
2016-11-07 06:39:20 +01:00
parent 67e5166cd4
commit 6e2b91c3d1
77 changed files with 216 additions and 832 deletions

View File

@@ -14,7 +14,7 @@
#include "fdd.h"
#include "timer.h"
int64_t disc_poll_time[2] = { 16, 16 };
int disc_poll_time[2] = { 16, 16 };
int disc_track[2];
int writeprot[2], fwriteprot[2];
@@ -39,7 +39,7 @@ int drive_empty[2] = {1, 1};
int disc_changed[2];
int motorspin;
int64_t motoron[2];
int motoron[2];
int fdc_indexcount = 52;
@@ -190,11 +190,11 @@ void disc_poll(int drive)
{
if (drive > 1)
{
disc_poll_time[drive] += (int64_t) (32.0 * TIMER_USEC);
disc_poll_time[drive] += (int) (32.0 * TIMER_USEC);
return;
}
disc_poll_time[drive] += (int64_t) disc_real_period(drive);
disc_poll_time[drive] += (int) disc_real_period(drive);
if (drives[drive].poll)
drives[drive].poll(drive);

View File

@@ -39,7 +39,7 @@ void disc_stop(int drive);
int disc_empty(int drive);
void disc_set_rate(int drive, int drvden, int rate);
extern int disc_time;
extern int64_t disc_poll_time[2];
extern int disc_poll_time[2];
void fdc_callback();
int fdc_data(uint8_t dat);
@@ -57,7 +57,7 @@ extern int fdc_ready;
extern int fdc_indexcount;*/
extern int motorspin;
extern int64_t motoron[2];
extern int motoron[2];
extern int swwp;
extern int disable_write;

View File

@@ -1986,6 +1986,11 @@ void d86f_poll(int drive)
{
if (!d86f_can_read_address(drive))
{
/* if (fdc_get_bitcell_period() != d86f_get_bitcell_period(drive)) pclog("Bitcell period mismatch\n");
if (!fdd_can_read_medium(drive ^ fdd_swap)) pclog("Drive can not read medium (hole = %01X)\n", d86f_hole(drive));
if (fdc_is_mfm() != d86f_is_mfm(drive)) pclog("Encoding mismatch\n");
if (d86f_get_encoding(drive) > 1) pclog("Image encoding (%s) not FM or MFM\n", (d86f_get_encoding(drive) == 2) ? "M2FM" : "GCR"); */
d86f[drive].state = STATE_SECTOR_NOT_FOUND;
}
}
@@ -2114,7 +2119,7 @@ void d86f_poll(int drive)
if ((d86f[drive].index_count == 2) && (d86f[drive].state != STATE_IDLE))
{
// pclog("[State: %02X] [Side %i] Sector not found (%i != %i?) (%02X) (%08X)\n", d86f[drive].state, side, fdc_get_bitcell_period(), d86f_get_bitcell_period(drive), d86f_handler[drive].side_flags(drive), d86f[drive].req_sector.dword);
// pclog("[State: %02X] [Side %i] Sector not found (%i != %i?) (%02X) (%08X) (%i)\n", d86f[drive].state, side, fdc_get_bitcell_period(), d86f_get_bitcell_period(drive), d86f_handler[drive].side_flags(drive), d86f[drive].req_sector.dword, d86f_handler[drive].get_raw_size(drive, side));
d86f[drive].state = STATE_IDLE;
fdc_notfound();
}

View File

@@ -34,11 +34,14 @@ uint16_t fdi_disk_flags(int drive)
{
case 500:
temp_disk_flags |= 2;
break;
case 300:
case 250:
temp_disk_flags |= 0;
break;
case 1000:
temp_disk_flags |= 4;
break;
default:
temp_disk_flags |= 0;
}
@@ -61,12 +64,16 @@ uint16_t fdi_side_flags(int drive)
{
case 500:
temp_side_flags = 0;
break;
case 300:
temp_side_flags = 1;
break;
case 250:
temp_side_flags = 2;
break;
case 1000:
temp_side_flags = 3;
break;
default:
temp_side_flags = 2;
}
@@ -81,30 +88,53 @@ uint16_t fdi_side_flags(int drive)
return temp_side_flags;
}
int fdi_density()
{
if (!fdc_is_mfm())
{
return 0;
}
switch (fdc_get_bit_rate())
{
case 0:
return 2;
case 1:
return 1;
case 2:
return 1;
case 3:
case 5:
return 3;
default:
return 1;
}
}
int32_t fdi_extra_bit_cells(int drive, int side)
{
int density = 0;
int raw_size = 0;
density = fdi_density();
switch (fdc_get_bit_rate())
{
case 0:
raw_size = (fdd_getrpm(drive ^ fdd_swap) == 300) ? 200000 : 166666;
density = 2;
break;
case 1:
raw_size = (fdd_getrpm(drive ^ fdd_swap) == 300) ? 120000 : 100000;
density = 1;
break;
case 2:
raw_size = (fdd_getrpm(drive ^ fdd_swap) == 300) ? 100000 : 83333;
density = 1;
case 3:
case 5:
raw_size = (fdd_getrpm(drive ^ fdd_swap) == 300) ? 400000 : 333333;
density = 3;
break;
default:
raw_size = (fdd_getrpm(drive ^ fdd_swap) == 300) ? 100000 : 83333;
density = 1;
}
return (fdi[drive].tracklen[side][density] - raw_size);
@@ -148,7 +178,7 @@ void fdi_read_revolution(int drive)
{
int c = fdi2raw_loadtrack(fdi[drive].h, (uint16_t *)fdi[drive].track_data[side][density],
(uint16_t *)fdi[drive].track_timing[side][density],
track * fdi[drive].sides,
(track * fdi[drive].sides) + side,
&fdi[drive].tracklen[side][density],
&fdi[drive].trackindex[side][density], NULL, density);
// pclog("Side 0 [%i]: len %i, index %i\n", density, fdi[drive].tracklen[side][density], fdi[drive].trackindex[side][density]);
@@ -168,20 +198,7 @@ uint32_t fdi_index_hole_pos(int drive, int side)
{
int density;
switch (fdc_get_bit_rate())
{
case 0:
density = 2;
case 1:
density = 1;
case 2:
density = 1;
case 3:
case 5:
density = 3;
default:
density = 1;
}
density = fdi_density();
return fdi[drive].trackindex[side][density];
}
@@ -190,20 +207,7 @@ uint32_t fdi_get_raw_size(int drive, int side)
{
int density;
switch (fdc_get_bit_rate())
{
case 0:
density = 2;
case 1:
density = 1;
case 2:
density = 1;
case 3:
case 5:
density = 3;
default:
density = 1;
}
density = fdi_density();
return fdi[drive].tracklen[side][density];
}
@@ -212,17 +216,7 @@ uint16_t* fdi_encoded_data(int drive, int side)
{
int density = 0;
if (fdc_get_bit_rate() == 2)
density = 1;
if (fdc_get_bit_rate() == 0)
density = 2;
if (fdc_get_bit_rate() == 3)
density = 3;
if (!fdc_is_mfm())
{
density = 0;
}
density = fdi_density();
return (uint16_t *)fdi[drive].track_data[side][density];
}
@@ -294,12 +288,12 @@ void fdi_seek(int drive, int track)
{
if (fdd_doublestep_40(drive))
{
if (fdi[drive].lasttrack < 43)
if (fdi2raw_get_tpi(fdi[drive].h) < 2)
{
track /= 2;
}
// pclog("fdi_seek(): %i %i\n", fdi[drive].lasttrack, track);
}
// pclog("fdi_seek(): %i %i (%i)\n", fdi[drive].lasttrack, track);
if (!fdi[drive].f)
return;

View File

@@ -12,7 +12,7 @@
#include "pic.h"
#include "timer.h"
extern int64_t motoron[2];
extern int motoron[2];
int ui_writeprot[2] = {0, 0};
@@ -57,7 +57,7 @@ typedef struct FDC
int pcjr, ps1;
int64_t watchdog_timer;
int watchdog_timer;
int watchdog_count;
int data_ready;

View File

@@ -1996,6 +1996,11 @@ int fdi2raw_get_write_protect (FDI *fdi)
return fdi->write_protect;
}
int fdi2raw_get_tpi (FDI *fdi)
{
return fdi->header[148];
}
FDI *fdi2raw_header(FILE *f)
{
int i, offset, oldseek;

View File

@@ -29,6 +29,7 @@ extern int fdi2raw_get_type (FDI *);
extern int fdi2raw_get_bit_rate (FDI *);
extern int fdi2raw_get_rotation (FDI *);
extern int fdi2raw_get_write_protect (FDI *);
extern int fdi2raw_get_tpi (FDI *);
#ifdef __cplusplus
}

View File

@@ -88,7 +88,7 @@ char *joystick_get_pov_name(int joystick, int id)
typedef struct gameport_axis_t
{
int64_t count;
int count;
int axis_nr;
struct gameport_t *gameport;
} gameport_axis_t;

View File

@@ -342,7 +342,7 @@ extern int pic_intpending;
int intcount;
int64_t disctime;
int disctime;
char discfns[2][256];
int driveempty[2];
@@ -502,14 +502,14 @@ void writeega_chain4(uint32_t addr, uint8_t val);
extern uint32_t svgarbank,svgawbank;
/*Serial*/
extern int64_t mousedelay;
extern int mousedelay;
/*Sound*/
uint8_t spkstat;
float spktime;
int64_t rtctime;
int rtctime;
int soundtime,gustime,gustime2,vidtime;
int ppispeakon;
float CGACONST;
@@ -563,13 +563,13 @@ uint64_t hdt[128][3];
int image_is_hdi(const char *s);
/*Keyboard*/
int64_t keybsenddelay;
int keybsenddelay;
/*CD-ROM*/
extern int cdrom_drive;
extern int old_cdrom_drive;
extern int64_t idecallback[3];
extern int idecallback[3];
extern int cdrom_enabled;
#define CD_STATUS_EMPTY 0

View File

@@ -355,7 +355,7 @@ static void callnonreadcd(IDE *ide);
static void callreadcd(IDE *ide);
static void atapicommand(int ide_board);
int64_t idecallback[3] = {0, 0, 0};
int idecallback[3] = {0, 0, 0};
int cur_ide[3];

View File

@@ -54,7 +54,7 @@ void atapi_insert_cdrom();
extern int ideboard;
extern int64_t idecallback[3];
extern int idecallback[3];
extern char ide_fn[4][512];

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdlib.h>
#include "ibm.h"
#include "device.h"

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern joystick_if_t joystick_ch_flightstick_pro;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdlib.h>
#include "ibm.h"
#include "device.h"

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern joystick_if_t joystick_standard;
extern joystick_if_t joystick_standard_4button;
extern joystick_if_t joystick_standard_6button;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
/*Sidewinder game pad notes :
- Write to 0x201 starts packet transfer (5*N or 15*N bits)
@@ -33,13 +30,13 @@
typedef struct
{
int64_t poll_time;
int poll_time;
int poll_left;
int poll_clock;
uint64_t poll_data;
int poll_mode;
int64_t trigger_time;
int trigger_time;
int data_mode;
} sw_data;

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern joystick_if_t joystick_sw_pad;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdlib.h>
#include "ibm.h"
#include "device.h"

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern joystick_if_t joystick_tm_fcs;

View File

@@ -488,7 +488,7 @@ void at_advanced_common_init()
pci_init(PCI_CONFIG_TYPE_1, 0xd, 0x10);
i430fx_init();
piix_init(7);
pc87306_init();
// pc87306_init();
intel_endeavor_init();
if (cdrom_channel >= 4) ide_ter_init();
}

View File

@@ -4,5 +4,5 @@
extern void (*mouse_poll)(int x, int y, int b);
extern int mousepos;
extern int64_t mousedelay;
extern int mousedelay;

View File

@@ -72,7 +72,7 @@ static struct
static int vlan_handlers_num;
static int64_t vlan_poller_time = 0;
static int vlan_poller_time = 0;
void vlan_handler(void (*poller)(void *p), void *p)
//void vlan_handler(int (*can_receive)(void *p), void (*receive)(void *p, const uint8_t *buf, int size), void *p)

View File

@@ -13,7 +13,7 @@ int nvraddr;
int nvr_dosave = 0;
static int64_t nvr_onesec_time = 0, nvr_onesec_cnt = 0;
static int nvr_onesec_time = 0, nvr_onesec_cnt = 0;
void getnvrtime()
{
@@ -59,7 +59,7 @@ int nvr_check_alarm(int nvraddr)
return (nvrram[nvraddr + 1] == nvrram[nvraddr] || (nvrram[nvraddr + 1] & ALARM_DONTCARE) == ALARM_DONTCARE);
}
int64_t nvr_update_end_count = 0;
int nvr_update_end_count = 0;
void nvr_update_end(void *p)
{

View File

@@ -251,6 +251,7 @@ process_value:
break;
case 9:
// pclog("Setting DENSEL polarity to: %i (before: %i)\n", (val & 0x40 ? 1 : 0), fdc_get_densel_polarity());
fdc_update_enh_mode((val & 4) ? 1 : 0);
fdc_update_densel_polarity((val & 0x40) ? 1 : 0);
break;
case 0xF:
@@ -309,6 +310,7 @@ void pc87306_init()
{
pc87306_regs[0] = 0xF;
pc87306_regs[1] = 0x11;
pc87306_regs[3] = 2;
pc87306_regs[5] = 0xD;
pc87306_regs[8] = 0x70;
pc87306_regs[9] = 0xFF;
@@ -321,6 +323,7 @@ void pc87306_init()
1 = Default, 300 rpm @ 500,300,250,1000 kbps for 3.5"
*/
fdc_update_is_nsc(1);
fdc_update_enh_mode(0);
fdc_update_densel_polarity(1);
fdc_update_max_track(85);
fdd_swap = 0;

View File

@@ -19,7 +19,7 @@ enum
SERIAL serial1, serial2;
int mousepos=-1;
int64_t mousedelay;
int mousedelay;
void serial_reset()
{

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker, Tenshi
see COPYING for more details
*/
#include <stdio.h>
#include <stdlib.h>
#include "ibm.h"
@@ -41,7 +38,6 @@ static SOUND_CARD sound_cards[] =
{"Sound Blaster Pro v2", &sb_pro_v2_device},
{"Sound Blaster 16", &sb_16_device},
{"Sound Blaster AWE32", &sb_awe32_device},
// {"Sound Blaster AWE64 PCI",&sb_awe64pci_device},
{"Adlib Gold", &adgold_device},
{"Windows Sound System", &wss_device},
{"Pro Audio Spectrum 16", &pas16_device},
@@ -88,7 +84,7 @@ static struct
static int sound_handlers_num;
static int64_t sound_poll_time = 0, sound_get_buffer_time = 0, sound_poll_latch;
static int sound_poll_time = 0, sound_get_buffer_time = 0, sound_poll_latch;
int sound_pos_global = 0;
int soundon = 1;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include "timer.h"
void sound_add_handler(void (*get_buffer)(int32_t *buffer, int len, void *p), void *p);

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
/*PCem v0.8 by Tom Walker
AD1848 CODEC emulation (Windows Sound System compatible)*/

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include "timer.h"
typedef struct ad1848_t
@@ -16,13 +13,13 @@ typedef struct ad1848_t
int16_t out_l, out_r;
int64_t enable;
int enable;
int irq, dma;
int freq;
int64_t timer_count, timer_latch;
int timer_count, timer_latch;
int16_t buffer[SOUNDBUFLEN * 2];
int pos;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdlib.h>
#include "ibm.h"
#include "device.h"

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t adlib_device;

View File

@@ -1,7 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "ibm.h"
@@ -39,16 +35,16 @@ typedef struct adgold_t
int16_t adgold_mma_out[2];
int adgold_mma_intpos[2];
int64_t adgold_mma_timer_count;
int adgold_mma_timer_count;
struct
{
int64_t timer0_latch, timer0_count;
int64_t timerbase_latch, timerbase_count;
int64_t timer1_latch, timer1_count;
int64_t timer2_latch, timer2_count, timer2_read;
int timer0_latch, timer0_count;
int timerbase_latch, timerbase_count;
int timer1_latch, timer1_count;
int timer2_latch, timer2_count, timer2_read;
int64_t voice_count[2], voice_latch[2];
int voice_count[2], voice_latch[2];
} adgold_mma;
opl_t opl;
@@ -790,7 +786,7 @@ void *adgold_init()
for (; c >= 0; c--)
attenuation[c] = 0;
f = romfopen(nvr_concat("adgold.bin"), "rb");
f = romfopen("nvr/adgold.bin", "rb");
if (f)
{
fread(adgold->adgold_eeprom, 0x18, 1, f);
@@ -830,7 +826,7 @@ void adgold_close(void *p)
FILE *f;
adgold_t *adgold = (adgold_t *)p;
f = romfopen(nvr_concat("adgold.bin"), "wb");
f = romfopen("nvr/adgold.bin", "wb");
if (f)
{
fwrite(adgold->adgold_eeprom, 0x18, 1, f);

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t adgold_device;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdio.h>
#include <stdlib.h>
#include "ibm.h"

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t cms_device;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
/*12log2(r) * 4096
freq = 2^((in - 0xe000) / 4096)*/

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
typedef struct emu8k_t
{
struct

View File

@@ -1,7 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -46,13 +42,13 @@ typedef struct gus_t
int16_t buffer[2][SOUNDBUFLEN];
int pos;
int64_t samp_timer, samp_latch;
int samp_timer, samp_latch;
uint8_t *ram;
int irqnext;
int64_t timer_1, timer_2;
int timer_1, timer_2;
int irq, dma, irq_midi;
int latch_enable;
@@ -531,7 +527,7 @@ gus->curx[gus->voice]=(gus->curx[gus->voice]&0xFFF8000)|((val&0x7F)<<8);
if (gus->latch_enable == 2)
{
gus->irq = gus_irqs[val & 7];
if (val & 0x40)
{
if (gus->irq == -1)
@@ -957,8 +953,8 @@ void gus_poll_wave(void *p)
{
gus->ctrl[d] |= 1;
gus->cur[d] = (gus->ctrl[d] & 0x40) ? gus->end[d] : gus->start[d];
}
}
if ((gus->ctrl[d] & 0x20) && !gus->waveirqs[d])
{
gus->waveirqs[d] = 1;
@@ -974,6 +970,7 @@ void gus_poll_wave(void *p)
if (gus->cur[d] >= gus->end[d])
{
int diff = gus->cur[d] - gus->end[d];
if (gus->ctrl[d]&8)
{
if (gus->ctrl[d]&0x10) gus->ctrl[d]^=0x40;
@@ -983,7 +980,8 @@ void gus_poll_wave(void *p)
{
gus->ctrl[d] |= 1;
gus->cur[d] = (gus->ctrl[d] & 0x40) ? gus->end[d] : gus->start[d];
}
}
if ((gus->ctrl[d] & 0x20) && !gus->waveirqs[d])
{
gus->waveirqs[d] = 1;

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t gus_device;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include "ibm.h"
#include "io.h"
#include "sound_mpu401_uart.h"
@@ -58,13 +55,3 @@ void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr)
io_sethandler(addr, 0x0002, mpu401_uart_read, NULL, NULL, mpu401_uart_write, NULL, NULL, mpu);
}
void mpu401_uart_set(mpu401_uart_t *mpu, uint16_t addr)
{
io_sethandler(addr, 0x0002, mpu401_uart_read, NULL, NULL, mpu401_uart_write, NULL, NULL, mpu);
}
void mpu401_uart_remove(mpu401_uart_t *mpu, uint16_t addr)
{
io_sethandler(addr, 0x0002, mpu401_uart_read, NULL, NULL, mpu401_uart_write, NULL, NULL, mpu);
}

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
typedef struct mpu401_uart_t
{
uint8_t status;
@@ -10,5 +7,3 @@ typedef struct mpu401_uart_t
} mpu401_uart_t;
void mpu401_uart_init(mpu401_uart_t *mpu, uint16_t addr);
void mpu401_uart_set(mpu401_uart_t *mpu, uint16_t addr);
void mpu401_uart_remove(mpu401_uart_t *mpu, uint16_t addr);

View File

@@ -5,8 +5,8 @@ typedef struct opl_t
{
int chip_nr[2];
int64_t timers[2][2];
int64_t timers_enable[2][2];
int timers[2][2];
int timers_enable[2][2];
int16_t filtbuf[2];

View File

@@ -1,7 +1,3 @@
/* Copyright holders: Sarah Walker, SA1988
see COPYING for more details
*/
#include <stdint.h>
#include <stdlib.h>
#include "ibm.h"
@@ -12,7 +8,6 @@
#include "pic.h"
#include "pit.h"
#include "sound.h"
#include "sound_mpu401_uart.h"
#include "sound_opl.h"
#include "sound_pas16.h"
#include "sound_sb_dsp.h"
@@ -122,8 +117,8 @@ typedef struct pas16_t
struct
{
uint64_t l[3];
int64_t c[3];
uint32_t l[3];
int c[3];
uint8_t m[3];
uint8_t ctrl, ctrls[2];
int wp, rm[3], wm[3];
@@ -131,11 +126,10 @@ typedef struct pas16_t
int thit[3];
int delay[3];
int rereadlatch[3];
int64_t enable[3];
int enable[3];
} pit;
opl_t opl;
mpu401_uart_t mpu;
sb_dsp_t dsp;
int16_t pcm_buffer[2][SOUNDBUFLEN];
@@ -147,7 +141,8 @@ static uint8_t pas16_pit_in(uint16_t port, void *priv);
static void pas16_pit_out(uint16_t port, uint8_t val, void *priv);
static void pas16_update(pas16_t *pas16);
static int pas16_dma = 0, pas16_irq = 0;
static int pas16_dmas[8] = {4, 1, 2, 3, 0, 5, 6, 7};
static int pas16_irqs[16] = {0, 2, 3, 4, 5, 6, 7, 10, 11, 12, 14, 15, 0, 0, 0, 0};
static int pas16_sb_irqs[8] = {0, 2, 3, 5, 7, 10, 11, 12};
static int pas16_sb_dmas[8] = {0, 1, 2, 3};
@@ -178,11 +173,12 @@ static uint8_t pas16_in(uint16_t port, void *p)
{
pas16_t *pas16 = (pas16_t *)p;
uint8_t temp;
switch (port)
/* if (CS == 0xCA53 && pc == 0x3AFC)
fatal("here");*/
switch ((port - pas16->base) + 0x388)
{
case 0x388: case 0x389: case 0x38a: case 0x38b:
temp = opl3_read(port, &pas16->opl);
temp = opl3_read((port - pas16->base) + 0x388, &pas16->opl);
break;
case 0xb88:
@@ -210,7 +206,7 @@ static uint8_t pas16_in(uint16_t port, void *p)
break;
case 0x2789: /*Board revision*/
temp = 1;
temp = 0;
break;
case 0x7f89:
@@ -259,23 +255,32 @@ static uint8_t pas16_in(uint16_t port, void *p)
break;
case 0xff88: /*Board model*/
temp = 3; /*PAS16*/
temp = 4; /*PAS16*/
break;
case 0xff8b: /*Master mode read*/
temp = 0x20 | 0x10 | 0x01; /*AT bus, XT/AT timing*/
break;
}
/* if (port != 0x388 && port != 0x389 && port != 0xb8b) */pclog("pas16_in : port %04X return %02X %04X:%04X\n", port, temp, CS,cpu_state.pc);
/* if (CS == 0x1FF4 && pc == 0x0585)
{
if (output)
fatal("here");
output = 3;
}*/
return temp;
}
static void pas16_out(uint16_t port, uint8_t val, void *p)
{
pas16_t *pas16 = (pas16_t *)p;
pclog("pas16_out : port %04X val %02X %04X:%04X\n", port, val, CS,cpu_state.pc);
switch (port)
/* if (port != 0x388 && port != 0x389) */pclog("pas16_out : port %04X val %02X %04X:%04X\n", port, val, CS,cpu_state.pc);
/* if (CS == 0x369 && pc == 0x2AC5)
fatal("here\n");*/
switch ((port - pas16->base) + 0x388)
{
case 0x388: case 0x389: case 0x38a: case 0x38b:
opl3_write(port, val, &pas16->opl);
opl3_write((port - pas16->base) + 0x388, val, &pas16->opl);
break;
case 0xb88:
@@ -283,8 +288,8 @@ static void pas16_out(uint16_t port, uint8_t val, void *p)
break;
case 0xb89:
pas16_update(pas16);
pas16->irq_stat &= ~val;
// pas16_update_irqs();
break;
case 0xb8a:
@@ -294,6 +299,7 @@ static void pas16_out(uint16_t port, uint8_t val, void *p)
case 0xb8b:
pas16->irq_ena = val;
// pas16_update_irqs();
break;
case 0xf88:
@@ -305,6 +311,8 @@ static void pas16_out(uint16_t port, uint8_t val, void *p)
pas16->pcm_dat = (pas16->pcm_dat & 0x00ff) | (val << 8);
break;
case 0xf8a:
if ((val & PAS16_PCM_ENA) && !(pas16->pcm_ctrl & PAS16_PCM_ENA)) /*Guess*/
pas16->stereo_lr = 0;
pas16->pcm_ctrl = val;
break;
@@ -334,11 +342,13 @@ static void pas16_out(uint16_t port, uint8_t val, void *p)
break;
case 0xf389:
pas16->io_conf_2 = val;
pas16->dma = pas16_dma;
pas16->dma = pas16_dmas[val & 0x7];
pclog("pas16_out : set PAS DMA %i\n", pas16->dma);
break;
case 0xf38a:
pas16->io_conf_3 = val;
pas16->irq = pas16_irq;
pas16->irq = pas16_irqs[val & 0xf];
pclog("pas16_out : set PAS IRQ %i\n", pas16->irq);
break;
case 0xf38b:
pas16->io_conf_4 = val;
@@ -361,18 +371,20 @@ static void pas16_out(uint16_t port, uint8_t val, void *p)
pas16->sb_irqdma = val;
sb_dsp_setirq(&pas16->dsp, pas16_sb_irqs[(val >> 3) & 7]);
sb_dsp_setdma8(&pas16->dsp, pas16_sb_dmas[(val >> 6) & 3]);
pclog("pas16_out : set SB IRQ %i DMA %i\n", pas16_sb_irqs[(val >> 3) & 7], pas16_sb_dmas[(val >> 6) & 3]);
pclog("pas16_out : set SB IRQ %i DMA %i\n", pas16_sb_irqs[(val >> 3) & 7], pas16_sb_dmas[(val >> 6) & 3]);
break;
case 0x9a01:
pas16->base = val << 2;
pclog("pas16_out : PAS16 base now at %04X\n", pas16->base);
break;
default:
pclog("pas16_out : unknown %04X\n", port);
break;
}
if (cpu_state.pc == 0x80048CF3)
{
if (output)
fatal("here\n");
output = 3;
}
/* if (CS == 0x1FF4 && pc == 0x0431)
output = 3;*/
}
static void pas16_pit_out(uint16_t port, uint8_t val, void *p)
@@ -480,7 +492,7 @@ static uint8_t pas16_pit_in(uint16_t port, void *p)
pas16_t *pas16 = (pas16_t *)p;
uint8_t temp;
int t = port & 3;
printf("Read PIT %04X ",port);
// printf("Read PIT %04X ",addr);
switch (port & 3)
{
case 0: case 1: case 2: /*Timers*/
@@ -623,58 +635,54 @@ static void pas16_pcm_poll(void *p)
pclog("pas16_pcm_poll : cause IRQ %i %02X\n", pas16->irq, 1 << pas16->irq);
picint(1 << pas16->irq);
}
else
picintc(1 << pas16->irq);
}
}
}
static void pas16_io_remove(pas16_t *pas16)
static void pas16_out_base(uint16_t port, uint8_t val, void *p)
{
io_removehandler(0x0388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x0788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x0b88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x0f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x1388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x1788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x2788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x7f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x8388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xbf88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xe388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xe788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xeb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xef88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xf388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xf788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xfb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0xff88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler(0x9a01, 0x0004, NULL, NULL, NULL, pas16_out, NULL, NULL, pas16);
}
pas16_t *pas16 = (pas16_t *)p;
static void pas16_io_set(pas16_t *pas16)
{
pas16_io_remove(pas16);
io_sethandler(0x0388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x0788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x0b88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x0f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x1388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x1788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x2788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x7f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x8388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xbf88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xe388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xe788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xeb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xef88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xf388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xf788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xfb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0xff88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler(0x9a01, 0x0004, NULL, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x0388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x0788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x0b88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x0f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x1388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x1788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x2788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x7f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0x8388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xbf88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xe388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xe788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xeb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xef88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xf388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xf788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xfb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_removehandler((pas16->base - 0x388) + 0xff88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
pas16->base = val << 2;
pclog("pas16_write_base : PAS16 base now at %04X\n", pas16->base);
io_sethandler((pas16->base - 0x388) + 0x0388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x0788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x0b88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x0f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x1388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x1788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x2788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x7f88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0x8388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xbf88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xe388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xe788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xeb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xef88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xf388, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xf788, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xfb88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
io_sethandler((pas16->base - 0x388) + 0xff88, 0x0004, pas16_in, NULL, NULL, pas16_out, NULL, NULL, pas16);
}
@@ -706,7 +714,6 @@ void pas16_get_buffer(int32_t *buffer, int len, void *p)
opl3_update2(&pas16->opl);
sb_dsp_update(&pas16->dsp);
pas16_update(pas16);
for (c = 0; c < len * 2; c++)
{
buffer[c] += pas16->opl.buffer[c];
@@ -726,16 +733,12 @@ void *pas16_init()
opl3_init(&pas16->opl);
sb_dsp_init(&pas16->dsp, SB2);
pas16_irq = device_get_config_int("irq");
pas16_dma = device_get_config_int("dma");
pas16_io_set(pas16);
io_sethandler(0x9a01, 0x0001, NULL, NULL, NULL, pas16_out_base, NULL, NULL, pas16);
timer_add(pas16_pcm_poll, &pas16->pit.c[0], &pas16->pit.enable[0], pas16);
sound_add_handler(pas16_get_buffer, pas16);
mpu401_uart_init(&pas16->mpu, 0x330);
return pas16;
}
@@ -747,94 +750,14 @@ void pas16_close(void *p)
free(pas16);
}
static device_config_t pas16_config[] =
{
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "IRQ 2",
.value = 2
},
{
.description = "IRQ 3",
.value = 3
},
{
.description = "IRQ 5",
.value = 5
},
{
.description = "IRQ 7",
.value = 7
},
{
.description = "IRQ 10",
.value = 10
},
{
.description = "IRQ 11",
.value = 11
},
{
.description = "IRQ 15",
.value = 15
},
{
.description = ""
}
},
.default_int = 5
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "DMA 0",
.value = 0
},
{
.description = "DMA 1",
.value = 1
},
{
.description = "DMA 3",
.value = 3
},
{
.description = "DMA 5",
.value = 5
},
{
.description = "DMA 7",
.value = 7
},
{
.description = ""
}
},
.default_int = 1
},
{
.type = -1
}
};
device_t pas16_device =
{
"Pro Audio Spectrum 16",
0,
DEVICE_NOT_WORKING,
pas16_init,
pas16_close,
NULL,
NULL,
NULL,
NULL,
pas16_config
NULL
};

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t pas16_device;

View File

@@ -1,7 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdint.h>
#include <stdlib.h>
#include "ibm.h"
#include "device.h"
@@ -16,7 +12,7 @@ typedef struct ps1_audio_t
uint8_t status, ctrl;
int64_t timer_latch, timer_count, timer_enable;
int timer_latch, timer_count, timer_enable;
uint8_t fifo[2048];
int fifo_read_idx, fifo_write_idx;

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t ps1_audio_device;

View File

@@ -1,7 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdint.h>
#include <stdlib.h>
#include "ibm.h"
#include "device.h"
@@ -25,8 +21,8 @@ typedef struct pssj_t
int amplitude;
int irq;
int64_t timer_count;
int64_t enable;
int timer_count;
int enable;
int wave_pos;
int pulse_width;

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t pssj_device;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdio.h>
#include <string.h>
#include <stdint.h>

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#ifdef __cplusplus
extern "C" {
#endif

View File

@@ -1,11 +1,6 @@
/* Copyright holders: Sarah Walker, Tenshi
see COPYING for more details
*/
#include <stdlib.h>
#include "ibm.h"
#include "device.h"
#include "io.h"
#include "pci.h"
#include "sound_emu8k.h"
#include "sound_mpu401_uart.h"
#include "sound_opl.h"
@@ -449,14 +444,11 @@ void *sb_pro_v2_init()
void *sb_16_init()
{
sb_t *sb = malloc(sizeof(sb_t));
uint16_t addr = device_get_config_int("addr");
memset(sb, 0, sizeof(sb_t));
opl3_init(&sb->opl);
sb_dsp_init(&sb->dsp, SB16);
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_setaddr(&sb->dsp, 0x0220);
sb_mixer_init(&sb->mixer);
io_sethandler(0x0220, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
io_sethandler(0x0228, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
@@ -490,15 +482,12 @@ int sb_awe32_available()
void *sb_awe32_init()
{
sb_t *sb = malloc(sizeof(sb_t));
uint16_t addr = device_get_config_int("addr");
int onboard_ram = device_get_config_int("onboard_ram");
memset(sb, 0, sizeof(sb_t));
opl3_init(&sb->opl);
sb_dsp_init(&sb->dsp, SB16 + 1);
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_setaddr(&sb->dsp, 0x0220);
sb_mixer_init(&sb->mixer);
io_sethandler(0x0220, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
io_sethandler(0x0228, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
@@ -525,175 +514,6 @@ void *sb_awe32_init()
return sb;
}
typedef union
{
uint16_t word;
uint8_t byte_regs[2];
} word_t;
typedef union
{
uint32_t addr;
uint8_t addr_regs[4];
} bar_t;
uint8_t sb_awe64_pci_regs[256];
word_t sb_awe64_pci_words[6];
bar_t sb_awe64_pci_bar[6];
uint8_t sb_awe64_pci_read(int func, int addr, void *p)
{
switch (addr)
{
case 0: case 1:
return sb_awe64_pci_words[0].byte_regs[addr & 1];
case 2: case 3:
return sb_awe64_pci_words[1].byte_regs[addr & 1];
case 8: case 9:
return sb_awe64_pci_words[2].byte_regs[addr & 1];
case 0xA: case 0xB:
return sb_awe64_pci_words[3].byte_regs[addr & 1];
case 0x10: case 0x11: case 0x12: case 0x13:
case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1A: case 0x1B:
case 0x1C: case 0x1D: case 0x1E: case 0x1F:
case 0x20: case 0x21: case 0x22: case 0x23:
case 0x24: case 0x25: case 0x26: case 0x27:
return sb_awe64_pci_bar[(addr - 0x10) >> 2].addr_regs[addr & 3];
case 0x2C: case 0x2D:
return sb_awe64_pci_words[4].byte_regs[addr & 1];
case 0x2E: case 0x2F:
return sb_awe64_pci_words[5].byte_regs[addr & 1];
default:
return sb_awe64_pci_regs[addr];
}
return 0;
}
uint32_t sb_base_addr, old_base_addr;
void sb_awe64_io_remove(uint32_t base_addr, sb_t *sb)
{
io_removehandler(base_addr, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
io_removehandler(base_addr + 4, 0x0002, sb_16_mixer_read, NULL, NULL, sb_16_mixer_write, NULL, NULL, sb);
io_removehandler(base_addr + 8, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
mpu401_uart_remove(&sb->mpu, base_addr + 8);
}
void sb_awe64_io_set(uint32_t base_addr, sb_t *sb)
{
sb_dsp_setaddr(&sb->dsp, base_addr);
io_sethandler(base_addr, 0x0004, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
io_sethandler(base_addr + 4, 0x0002, sb_16_mixer_read, NULL, NULL, sb_16_mixer_write, NULL, NULL, sb);
io_sethandler(base_addr + 8, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
mpu401_uart_set(&sb->mpu, base_addr + 8);
old_base_addr = base_addr;
}
void sb_awe64_pci_write(int func, int addr, uint8_t val, void *p)
{
sb_t *sb = (sb_t *) p;
switch (addr)
{
case 4:
if (val & PCI_COMMAND_IO)
{
sb_awe64_io_remove(sb_base_addr, sb);
sb_awe64_io_set(sb_base_addr, sb);
}
else
{
sb_awe64_io_remove(sb_base_addr, sb);
}
sb_awe64_pci_regs[addr] = val;
return;
case 0x10:
val &= 0xfc;
val |= 1;
case 0x11: case 0x12: case 0x13:
/* case 0x14: case 0x15: case 0x16: case 0x17:
case 0x18: case 0x19: case 0x1A: case 0x1B:
case 0x1C: case 0x1D: case 0x1E: case 0x1F:
case 0x20: case 0x21: case 0x22: case 0x23:
case 0x24: case 0x25: case 0x26: case 0x27: */
sb_awe64_pci_bar[(addr - 0x10) >> 2].addr_regs[addr & 3] = val;
sb_awe64_pci_bar[(addr - 0x10) >> 2].addr &= 0xffc0;
sb_awe64_pci_bar[(addr - 0x10) >> 2].addr |= 1;
if ((addr & 0x14) == 0x10)
{
sb_awe64_io_remove(sb_base_addr, sb);
sb_base_addr = sb_awe64_pci_bar[0].addr & 0xffc0;
pclog("SB AWE64 PCI: New I/O base %i is %04X\n" , ((addr - 0x10) >> 2), sb_base_addr);
}
return;
case 0x3C:
sb_awe64_pci_regs[addr] = val;
if (val != 0xFF)
{
pclog("SB AWE64 PCI IRQ now: %i\n", val);
sb_dsp_setirq(&sb->dsp, val);
}
return;
default:
return;
}
return 0;
}
void *sb_awe64pci_init()
{
sb_t *sb = malloc(sizeof(sb_t));
uint16_t i = 0;
int onboard_ram = device_get_config_int("onboard_ram");
memset(sb, 0, sizeof(sb_t));
opl3_init(&sb->opl);
sb_dsp_init(&sb->dsp, SB16 + 1);
sb_dsp_setirq(&sb->dsp, 5);
sb_dsp_setdma8(&sb->dsp, 1);
mpu401_uart_init(&sb->mpu, 0x228);
mpu401_uart_remove(&sb->mpu, 0x228);
sb_awe64_io_set(0x220, sb);
sb_mixer_init(&sb->mixer);
io_sethandler(0x0388, 0x0002, opl3_read, NULL, NULL, opl3_write, NULL, NULL, &sb->opl);
sound_add_handler(sb_get_buffer_emu8k, sb);
emu8k_init(&sb->emu8k, onboard_ram);
sb->mixer.regs[0x30] = 31 << 3;
sb->mixer.regs[0x31] = 31 << 3;
sb->mixer.regs[0x32] = 31 << 3;
sb->mixer.regs[0x33] = 31 << 3;
sb->mixer.regs[0x34] = 31 << 3;
sb->mixer.regs[0x35] = 31 << 3;
sb->mixer.regs[0x44] = 8 << 4;
sb->mixer.regs[0x45] = 8 << 4;
sb->mixer.regs[0x46] = 8 << 4;
sb->mixer.regs[0x47] = 8 << 4;
sb->mixer.regs[0x22] = (sb->mixer.regs[0x30] & 0xf0) | (sb->mixer.regs[0x31] >> 4);
sb->mixer.regs[0x04] = (sb->mixer.regs[0x32] & 0xf0) | (sb->mixer.regs[0x33] >> 4);
sb->mixer.regs[0x26] = (sb->mixer.regs[0x34] & 0xf0) | (sb->mixer.regs[0x35] >> 4);
pci_add(sb_awe64_pci_read, sb_awe64_pci_write, sb);
sb_awe64_pci_words[0].word = 0x1102; /* Creative Labs */
sb_awe64_pci_words[1].word = 0x0003; /* CT-8800-SAT chip (EMU8008) */
sb_awe64_pci_words[3].word = 0x0401; /* Multimedia device, audio device */
sb_awe64_pci_words[4].word = 0x1102; /* Creative Labs */
sb_awe64_pci_words[5].word = device_get_config_int("revision"); /* Revision */
sb_awe64_pci_bar[0].addr = 1;
sb_awe64_pci_regs[0x3C] = 5;
sb_awe64_pci_regs[0x3D] = 1;
sb_awe64_pci_regs[0x3E] = 0x0c;
sb_awe64_pci_regs[0x3F] = 0x80;
return sb;
}
void sb_close(void *p)
{
sb_t *sb = (sb_t *)p;
@@ -773,7 +593,7 @@ static device_config_t sb_config[] =
.description = ""
}
},
.default_int = 5
.default_int = 7
},
{
.name = "dma",
@@ -849,7 +669,7 @@ static device_config_t sb_pro_config[] =
.description = ""
}
},
.default_int = 5
.default_int = 7
},
{
.name = "dma",
@@ -878,75 +698,6 @@ static device_config_t sb_pro_config[] =
static device_config_t sb_16_config[] =
{
{
.name = "addr",
.description = "Address",
.type = CONFIG_BINARY,
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "0x220",
.value = 0x220
},
{
.description = "0x240",
.value = 0x240
},
{
.description = ""
}
},
.default_int = 0x220
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "IRQ 2",
.value = 2
},
{
.description = "IRQ 5",
.value = 5
},
{
.description = "IRQ 7",
.value = 7
},
{
.description = "IRQ 10",
.value = 10
},
{
.description = ""
}
},
.default_int = 5
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "DMA 1",
.value = 1
},
{
.description = "DMA 3",
.value = 3
},
{
.description = ""
}
},
.default_int = 1
},
{
.name = "midi",
.description = "MIDI out device",
@@ -960,141 +711,6 @@ static device_config_t sb_16_config[] =
static device_config_t sb_awe32_config[] =
{
{
.name = "addr",
.description = "Address",
.type = CONFIG_BINARY,
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "0x220",
.value = 0x220
},
{
.description = "0x240",
.value = 0x240
},
{
.description = ""
}
},
.default_int = 0x220
},
{
.name = "irq",
.description = "IRQ",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "IRQ 2",
.value = 2
},
{
.description = "IRQ 5",
.value = 5
},
{
.description = "IRQ 7",
.value = 7
},
{
.description = "IRQ 10",
.value = 10
},
{
.description = ""
}
},
.default_int = 5
},
{
.name = "dma",
.description = "DMA",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "DMA 1",
.value = 1
},
{
.description = "DMA 3",
.value = 3
},
{
.description = ""
}
},
.default_int = 1
},
{
.name = "midi",
.description = "MIDI out device",
.type = CONFIG_MIDI,
.default_int = 0
},
{
.name = "onboard_ram",
.description = "Onboard RAM",
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "None",
.value = 0
},
{
.description = "512 KB",
.value = 512
},
{
.description = "2 MB",
.value = 2048
},
{
.description = "8 MB",
.value = 8192
},
{
.description = "28 MB",
.value = 28*1024
},
{
.description = ""
}
},
.default_int = 512
},
{
.type = -1
}
};
static device_config_t sb_awe64pci_config[] =
{
{
.name = "revision",
.description = "Revision",
.type = CONFIG_BINARY,
.type = CONFIG_SELECTION,
.selection =
{
{
.description = "CT4600",
.value = 0x0010
},
{
.description = "CT4650",
.value = 0x0030
},
{
.description = ""
}
},
.default_int = 0x0010
},
{
.name = "midi",
.description = "MIDI out device",
@@ -1222,15 +838,3 @@ device_t sb_awe32_device =
sb_add_status_info,
sb_awe32_config
};
device_t sb_awe64pci_device =
{
"Sound Blaster AWE64 PCI",
0,
sb_awe64pci_init,
sb_close,
sb_awe32_available,
sb_speed_changed,
NULL,
sb_add_status_info,
sb_awe64pci_config
};

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker, Tenshi
see COPYING for more details
*/
extern device_t sb_1_device;
extern device_t sb_15_device;
extern device_t sb_2_device;
@@ -8,4 +5,3 @@ extern device_t sb_pro_v1_device;
extern device_t sb_pro_v2_device;
extern device_t sb_16_device;
extern device_t sb_awe32_device;
extern device_t sb_awe64pci_device;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
/*Jazz sample rates :
386-33 - 12kHz
486-33 - 20kHz
@@ -161,12 +158,12 @@ void sb_dsp_speed_changed(sb_dsp_t *dsp)
if (dsp->sb_timeo < 256)
dsp->sblatcho = TIMER_USEC * (256 - dsp->sb_timeo);
else
dsp->sblatcho = (int64_t)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timeo - 256)));
dsp->sblatcho = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timeo - 256)));
if (dsp->sb_timei < 256)
dsp->sblatchi = TIMER_USEC * (256 - dsp->sb_timei);
else
dsp->sblatchi = (int64_t)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timei - 256)));
dsp->sblatchi = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_timei - 256)));
}
void sb_add_data(sb_dsp_t *dsp, uint8_t v)
@@ -333,7 +330,7 @@ void sb_exec_command(sb_dsp_t *dsp)
case 0x41: /*Set output sampling rate*/
case 0x42: /*Set input sampling rate*/
if (dsp->sb_type < SB16) break;
dsp->sblatcho = (int64_t)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_data[1] + (dsp->sb_data[0] << 8))));
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;
@@ -612,7 +609,7 @@ void sb_dsp_init(sb_dsp_t *dsp, int type)
{
dsp->sb_type = type;
dsp->sb_irqnum = 5;
dsp->sb_irqnum = 7;
dsp->sb_8_dmanum = 1;
sb_doreset(dsp);

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
typedef struct sb_dsp_t
{
int sb_type;
@@ -46,11 +43,11 @@ typedef struct sb_dsp_t
uint8_t sb_asp_regs[256];
int64_t sbenable, sb_enable_i;
int sbenable, sb_enable_i;
int64_t sbcount, sb_count_i;
int sbcount, sb_count_i;
int64_t sblatcho, sblatchi;
int sblatcho, sblatchi;
uint16_t sb_addr;
@@ -58,7 +55,7 @@ typedef struct sb_dsp_t
int asp_data_len;
int64_t wb_time, wb_full;
int wb_time, wb_full;
int16_t buffer[SOUNDBUFLEN * 2];
int pos;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdlib.h>
#include "ibm.h"
#include "device.h"

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
enum
{
SN76496,
@@ -16,7 +13,7 @@ extern int sn76489_mute;
typedef struct sn76489_t
{
int stat[4];
int64_t latch[4], count[4];
int latch[4], count[4];
int freqlo[4], freqhi[4];
int vol[4];
uint32_t shift;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include "ibm.h"
#include "sound.h"
#include "sound_speaker.h"

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
void speaker_init();
extern int speaker_mute;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include <stdlib.h>
#include "ibm.h"
#include "device.h"

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t ssi2001_device;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
/*PCem v0.8 by Tom Walker
Windows Sound System emulation*/

View File

@@ -1,4 +1 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
extern device_t wss_device;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
#include "ibm.h"
#include "sound_ym7128.h"

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker
see COPYING for more details
*/
typedef struct ym7128_t
{
int a0, sci;

View File

@@ -1,6 +1,3 @@
/* Copyright holders: Sarah Walker, Tenshi
see COPYING for more details
*/
#define USE_OPENAL
#include <stdio.h>
#include <string.h>

View File

@@ -21,7 +21,7 @@ typedef struct cga_t
int oddeven;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;

View File

@@ -46,7 +46,7 @@ typedef struct ega_t
int vres;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
uint8_t scrblank;

View File

@@ -20,7 +20,7 @@ typedef struct hercules_t
uint8_t ctrl, ctrl2, stat;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;

View File

@@ -151,7 +151,7 @@ typedef struct incolor_t
uint8_t ctrl, ctrl2, stat;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;

View File

@@ -21,7 +21,7 @@ typedef struct mda_t
uint8_t ctrl, stat;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;

View File

@@ -37,7 +37,7 @@ typedef struct m24_t
int dispon;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;
} m24_t;

View File

@@ -39,7 +39,7 @@ typedef struct pc1512_t
int blink;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;
uint8_t *vram;

View File

@@ -27,7 +27,7 @@ typedef struct pc1640_t
int cga_enabled;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
} pc1640_t;
void pc1640_out(uint16_t addr, uint8_t val, void *p)

View File

@@ -37,7 +37,7 @@ typedef struct pcjr_t
uint16_t ma, maback;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;
} pcjr_t;

View File

@@ -56,7 +56,7 @@ typedef struct svga_t
int bpp;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
uint8_t scrblank;

View File

@@ -39,7 +39,7 @@ typedef struct tandy_t
uint16_t ma, maback;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;
} tandy_t;

View File

@@ -39,7 +39,7 @@ typedef struct tandysl_t
uint16_t ma, maback;
int dispontime, dispofftime;
int64_t vidtime;
int vidtime;
int firstline, lastline;
} tandysl_t;