2017-10-19 21:08:34 -04:00
# include <stdio.h>
2017-10-14 07:03:19 +02:00
# include <stdint.h>
# include <stdlib.h>
# include <string.h>
2017-10-19 21:08:34 -04:00
# include <stdarg.h>
2020-04-04 12:45:47 +02:00
# define _USE_MATH_DEFINES
2018-03-15 23:15:33 +01:00
# include <math.h>
2017-12-10 02:53:10 -05:00
# define HAVE_STDARG_H
2020-03-29 14:24:42 +02:00
# include <86box/86box.h>
# include <86box/device.h>
2021-05-20 22:51:55 -03:00
# include <86box/gameport.h>
2020-03-29 14:24:42 +02:00
# include <86box/io.h>
# include <86box/nmi.h>
# include <86box/mem.h>
# include <86box/pci.h>
# include <86box/timer.h>
# include <86box/sound.h>
# include <86box/midi.h>
# include <86box/snd_mpu401.h>
2017-10-14 07:03:19 +02:00
2017-10-19 21:08:34 -04:00
2018-03-15 23:15:33 +01:00
# define N 16
# define ES1371_NCoef 91
static float low_fir_es1371_coef [ ES1371_NCoef ] ;
2017-11-24 02:23:00 -05:00
typedef struct {
2020-01-19 05:45:05 +01:00
mpu_t mpu ;
2020-01-01 20:20:16 +01:00
2017-11-24 02:23:00 -05:00
uint8_t pci_command , pci_serr ;
uint32_t base_addr ;
uint8_t int_line ;
uint16_t pmcsr ;
uint32_t int_ctrl ;
uint32_t int_status ;
uint32_t legacy_ctrl ;
int mem_page ;
uint32_t si_cr ;
uint32_t sr_cir ;
uint16_t sr_ram [ 128 ] ;
uint8_t uart_ctrl ;
uint8_t uart_status ;
2020-04-29 23:39:54 +02:00
uint16_t codec_regs [ 128 ] ;
2017-11-24 02:23:00 -05:00
uint32_t codec_ctrl ;
struct {
uint32_t addr , addr_latch ;
uint16_t count , size ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
uint16_t samp_ct ;
int curr_samp_ct ;
2017-11-24 02:23:00 -05:00
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
pc_timer_t timer ;
uint64_t latch ;
2017-11-24 02:23:00 -05:00
uint32_t vf , ac ;
int16_t buffer_l [ 64 ] , buffer_r [ 64 ] ;
int buffer_pos , buffer_pos_end ;
2018-03-15 23:15:33 +01:00
int filtered_l [ 32 ] , filtered_r [ 32 ] ;
int f_pos ;
2017-11-24 02:23:00 -05:00
int16_t out_l , out_r ;
int32_t vol_l , vol_r ;
} dac [ 2 ] , adc ;
int64_t dac_latch , dac_time ;
int master_vol_l , master_vol_r ;
2020-10-19 02:21:05 +02:00
int cd_vol_l , cd_vol_r ;
2017-11-24 02:23:00 -05:00
int card ;
int pos ;
int16_t buffer [ SOUNDBUFLEN * 2 ] ;
2020-01-19 05:45:05 +01:00
int type ;
2017-10-14 07:03:19 +02:00
} es1371_t ;
2017-11-24 02:23:00 -05:00
# define LEGACY_SB_ADDR (1<<29)
# define LEGACY_SSCAPE_ADDR_SHIFT 27
# define LEGACY_CODEC_ADDR_SHIFT 25
# define LEGACY_FORCE_IRQ (1<<24)
# define LEGACY_CAPTURE_SLAVE_DMA (1<<23)
# define LEGACY_CAPTURE_SLAVE_PIC (1<<22)
# define LEGACY_CAPTURE_MASTER_DMA (1<<21)
# define LEGACY_CAPTURE_MASTER_PIC (1<<20)
# define LEGACY_CAPTURE_ADLIB (1<<19)
# define LEGACY_CAPTURE_SB (1<<18)
# define LEGACY_CAPTURE_CODEC (1<<17)
# define LEGACY_CAPTURE_SSCAPE (1<<16)
# define LEGACY_EVENT_SSCAPE (0<<8)
# define LEGACY_EVENT_CODEC (1<<8)
# define LEGACY_EVENT_SB (2<<8)
# define LEGACY_EVENT_ADLIB (3<<8)
# define LEGACY_EVENT_MASTER_PIC (4<<8)
# define LEGACY_EVENT_MASTER_DMA (5<<8)
# define LEGACY_EVENT_SLAVE_PIC (6<<8)
# define LEGACY_EVENT_SLAVE_DMA (7<<8)
# define LEGACY_EVENT_MASK (7<<8)
# define LEGACY_EVENT_ADDR_SHIFT 3
# define LEGACY_EVENT_ADDR_MASK (0x1f<<3)
# define LEGACY_EVENT_TYPE_RW (1<<2)
# define LEGACY_INT (1<<0)
# define SRC_RAM_WE (1<<24)
# define CODEC_READ (1<<23)
# define CODEC_READY (1<<31)
# define INT_DAC1_EN (1<<6)
# define INT_DAC2_EN (1<<5)
2020-01-01 20:20:16 +01:00
# define INT_UART_EN (1<<3)
2017-11-24 02:23:00 -05:00
# define SI_P2_INTR_EN (1<<9)
# define SI_P1_INTR_EN (1<<8)
# define INT_STATUS_INTR (1<<31)
2020-01-01 20:20:16 +01:00
# define INT_STATUS_UART (1<<3)
2017-11-24 02:23:00 -05:00
# define INT_STATUS_DAC1 (1<<2)
# define INT_STATUS_DAC2 (1<<1)
2020-01-19 05:45:05 +01:00
# define UART_CTRL_RXINTEN (1<<7)
2020-01-01 20:20:16 +01:00
# define UART_CTRL_TXINTEN (1<<5)
2020-01-19 05:45:05 +01:00
# define UART_STATUS_RXINT (1<<7)
2020-01-01 20:20:16 +01:00
# define UART_STATUS_TXINT (1<<2)
# define UART_STATUS_TXRDY (1<<1)
2020-01-19 05:45:05 +01:00
# define UART_STATUS_RXRDY (1<<0)
2020-01-01 20:20:16 +01:00
2017-11-24 02:23:00 -05:00
# define FORMAT_MONO_8 0
# define FORMAT_STEREO_8 1
# define FORMAT_MONO_16 2
# define FORMAT_STEREO_16 3
const int32_t codec_attn [ ] = {
25 , 32 , 41 , 51 , 65 , 82 , 103 , 130 , 164 , 206 , 260 , 327 , 412 , 519 , 653 ,
822 , 1036 , 1304 , 1641 , 2067 , 2602 , 3276 , 4125 , 5192 , 6537 , 8230 , 10362 , 13044 ,
16422 , 20674 , 26027 , 32767
2017-10-14 07:03:19 +02:00
} ;
static void es1371_fetch ( es1371_t * es1371 , int dac_nr ) ;
2020-11-16 00:01:21 +01:00
static void update_legacy ( es1371_t * es1371 , uint32_t old_legacy_ctrl ) ;
2017-10-14 07:03:19 +02:00
2017-10-16 06:19:18 +02:00
# ifdef ENABLE_AUDIOPCI_LOG
int audiopci_do_log = ENABLE_AUDIOPCI_LOG ;
2017-11-24 02:23:00 -05:00
static void
2017-12-10 02:53:10 -05:00
audiopci_log ( const char * fmt , . . . )
2017-10-16 06:19:18 +02:00
{
2017-12-05 23:35:35 +01:00
va_list ap ;
2017-11-24 02:23:00 -05:00
if ( audiopci_do_log ) {
2017-12-10 02:53:10 -05:00
va_start ( ap , fmt ) ;
pclog_ex ( fmt , ap ) ;
2017-11-24 02:23:00 -05:00
va_end ( ap ) ;
}
2017-10-16 06:19:18 +02:00
}
2018-10-19 00:39:32 +02:00
# else
# define audiopci_log(fmt, ...)
# endif
2017-10-16 06:19:18 +02:00
2017-11-24 02:23:00 -05:00
2017-10-14 07:03:19 +02:00
static void es1371_update_irqs ( es1371_t * es1371 )
{
2017-11-24 02:23:00 -05:00
int irq = 0 ;
if ( ( es1371 - > int_status & INT_STATUS_DAC1 ) & & ( es1371 - > si_cr & SI_P1_INTR_EN ) )
irq = 1 ;
2020-01-01 20:20:16 +01:00
if ( ( es1371 - > int_status & INT_STATUS_DAC2 ) & & ( es1371 - > si_cr & SI_P2_INTR_EN ) ) {
2017-11-24 02:23:00 -05:00
irq = 1 ;
2020-01-01 20:20:16 +01:00
}
/*MIDI input is unsupported for now*/
if ( ( es1371 - > int_status & INT_STATUS_UART ) & & ( es1371 - > uart_status & UART_STATUS_TXINT ) ) {
irq = 1 ;
}
2017-11-24 02:23:00 -05:00
if ( irq )
es1371 - > int_status | = INT_STATUS_INTR ;
else
es1371 - > int_status & = ~ INT_STATUS_INTR ;
if ( es1371 - > legacy_ctrl & LEGACY_FORCE_IRQ )
irq = 1 ;
if ( irq )
{
pci_set_irq ( es1371 - > card , PCI_INTA ) ;
// audiopci_log("Raise IRQ\n");
}
else
{
pci_clear_irq ( es1371 - > card , PCI_INTA ) ;
// audiopci_log("Drop IRQ\n");
}
2017-10-14 07:03:19 +02:00
}
static uint8_t es1371_inb ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
uint8_t ret = 0 ;
switch ( port & 0x3f )
{
case 0x00 :
ret = es1371 - > int_ctrl & 0xff ;
break ;
case 0x01 :
ret = ( es1371 - > int_ctrl > > 8 ) & 0xff ;
break ;
case 0x02 :
ret = ( es1371 - > int_ctrl > > 16 ) & 0xff ;
break ;
case 0x03 :
ret = ( es1371 - > int_ctrl > > 24 ) & 0xff ;
break ;
case 0x04 :
ret = es1371 - > int_status & 0xff ;
break ;
case 0x05 :
ret = ( es1371 - > int_status > > 8 ) & 0xff ;
break ;
case 0x06 :
ret = ( es1371 - > int_status > > 16 ) & 0xff ;
break ;
case 0x07 :
ret = ( es1371 - > int_status > > 24 ) & 0xff ;
break ;
2020-01-01 20:20:16 +01:00
2017-11-24 02:23:00 -05:00
case 0x09 :
2020-01-01 20:20:16 +01:00
ret = es1371 - > uart_status & 0xc7 ;
audiopci_log ( " ES1371 UART Status = %02x \n " , es1371 - > uart_status ) ;
2017-11-24 02:23:00 -05:00
break ;
case 0x0c :
ret = es1371 - > mem_page ;
break ;
case 0x1a :
ret = es1371 - > legacy_ctrl > > 16 ;
break ;
case 0x1b :
ret = es1371 - > legacy_ctrl > > 24 ;
break ;
case 0x20 :
ret = es1371 - > si_cr & 0xff ;
break ;
case 0x21 :
ret = es1371 - > si_cr > > 8 ;
break ;
case 0x22 :
ret = ( es1371 - > si_cr > > 16 ) | 0x80 ;
break ;
case 0x23 :
ret = 0xff ;
break ;
default :
audiopci_log ( " Bad es1371_inb: port=%04x \n " , port ) ;
}
2020-01-01 20:20:16 +01:00
audiopci_log ( " es1371_inb: port=%04x ret=%02x \n " , port , ret ) ;
2017-11-24 02:23:00 -05:00
// output = 3;
return ret ;
2017-10-14 07:03:19 +02:00
}
static uint16_t es1371_inw ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
uint16_t ret = 0 ;
switch ( port & 0x3e )
{
case 0x00 :
ret = es1371 - > int_ctrl & 0xffff ;
break ;
case 0x02 :
ret = ( es1371 - > int_ctrl > > 16 ) & 0xffff ;
break ;
case 0x18 :
ret = es1371 - > legacy_ctrl & 0xffff ;
// audiopci_log("Read legacy ctrl %04x\n", ret);
break ;
case 0x26 :
ret = es1371 - > dac [ 0 ] . curr_samp_ct ;
break ;
case 0x2a :
ret = es1371 - > dac [ 1 ] . curr_samp_ct ;
break ;
case 0x36 :
switch ( es1371 - > mem_page )
{
case 0xc :
ret = es1371 - > dac [ 0 ] . count ;
break ;
default :
audiopci_log ( " Bad es1371_inw: mem_page=%x port=%04x \n " , es1371 - > mem_page , port ) ;
}
break ;
case 0x3e :
switch ( es1371 - > mem_page )
{
case 0xc :
ret = es1371 - > dac [ 1 ] . count ;
break ;
default :
audiopci_log ( " Bad es1371_inw: mem_page=%x port=%04x \n " , es1371 - > mem_page , port ) ;
}
break ;
default :
audiopci_log ( " Bad es1371_inw: port=%04x \n " , port ) ;
}
// audiopci_log("es1371_inw: port=%04x ret=%04x %04x:%08x\n", port, ret, CS,cpu_state.pc);
return ret ;
2017-10-14 07:03:19 +02:00
}
static uint32_t es1371_inl ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
uint32_t ret = 0 ;
switch ( port & 0x3c )
{
case 0x00 :
ret = es1371 - > int_ctrl ;
break ;
case 0x04 :
ret = es1371 - > int_status ;
break ;
case 0x10 :
ret = es1371 - > sr_cir & ~ 0xffff ;
ret | = es1371 - > sr_ram [ es1371 - > sr_cir > > 25 ] ;
break ;
case 0x14 :
ret = es1371 - > codec_ctrl & 0x00ff0000 ;
2020-04-29 23:39:54 +02:00
ret | = es1371 - > codec_regs [ ( es1371 - > codec_ctrl > > 16 ) & 0x7f ] ;
if ( ( ( es1371 - > codec_ctrl > > 16 ) & 0x7f ) = = 0x26 )
ret | = 0x0f ;
2017-11-24 02:23:00 -05:00
ret | = CODEC_READY ;
break ;
2020-01-01 20:20:16 +01:00
case 0x30 :
switch ( es1371 - > mem_page ) {
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x30 read UART FIFO: val = %02x \n " , ret & 0xff ) ;
break ;
}
break ;
2017-11-24 02:23:00 -05:00
2020-01-01 20:20:16 +01:00
case 0x34 :
switch ( es1371 - > mem_page ) {
2017-11-24 02:23:00 -05:00
case 0xc :
ret = es1371 - > dac [ 0 ] . size | ( es1371 - > dac [ 0 ] . count < < 16 ) ;
break ;
case 0xd :
ret = es1371 - > adc . size | ( es1371 - > adc . count < < 16 ) ;
break ;
2020-01-01 20:20:16 +01:00
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x34 read UART FIFO: val = %02x \n " , ret & 0xff ) ;
break ;
2017-11-24 02:23:00 -05:00
default :
audiopci_log ( " Bad es1371_inl: mem_page=%x port=%04x \n " , es1371 - > mem_page , port ) ;
}
break ;
2020-01-01 20:20:16 +01:00
case 0x38 :
switch ( es1371 - > mem_page ) {
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x38 read UART FIFO: val = %02x \n " , ret & 0xff ) ;
break ;
}
break ;
2017-11-24 02:23:00 -05:00
case 0x3c :
2020-01-01 20:20:16 +01:00
switch ( es1371 - > mem_page ) {
2017-11-24 02:23:00 -05:00
case 0xc :
ret = es1371 - > dac [ 1 ] . size | ( es1371 - > dac [ 1 ] . count < < 16 ) ;
break ;
2020-01-01 20:20:16 +01:00
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x3c read UART FIFO: val = %02x \n " , ret & 0xff ) ;
break ;
2017-11-24 02:23:00 -05:00
default :
audiopci_log ( " Bad es1371_inl: mem_page=%x port=%04x \n " , es1371 - > mem_page , port ) ;
}
break ;
default :
audiopci_log ( " Bad es1371_inl: port=%04x \n " , port ) ;
}
2020-01-01 20:20:16 +01:00
audiopci_log ( " es1371_inl: port=%04x ret=%08x \n " , port , ret ) ;
2017-11-24 02:23:00 -05:00
return ret ;
2017-10-14 07:03:19 +02:00
}
static void es1371_outb ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
2020-11-16 00:01:21 +01:00
uint32_t old_legacy_ctrl ;
2017-11-24 02:23:00 -05:00
2020-01-01 20:20:16 +01:00
audiopci_log ( " es1371_outb: port=%04x val=%02x \n " , port , val ) ;
2017-11-24 02:23:00 -05:00
switch ( port & 0x3f )
{
case 0x00 :
if ( ! ( es1371 - > int_ctrl & INT_DAC1_EN ) & & ( val & INT_DAC1_EN ) )
{
es1371 - > dac [ 0 ] . addr = es1371 - > dac [ 0 ] . addr_latch ;
es1371 - > dac [ 0 ] . buffer_pos = 0 ;
es1371 - > dac [ 0 ] . buffer_pos_end = 0 ;
es1371_fetch ( es1371 , 0 ) ;
}
if ( ! ( es1371 - > int_ctrl & INT_DAC2_EN ) & & ( val & INT_DAC2_EN ) )
{
es1371 - > dac [ 1 ] . addr = es1371 - > dac [ 1 ] . addr_latch ;
es1371 - > dac [ 1 ] . buffer_pos = 0 ;
es1371 - > dac [ 1 ] . buffer_pos_end = 0 ;
es1371_fetch ( es1371 , 1 ) ;
}
es1371 - > int_ctrl = ( es1371 - > int_ctrl & 0xffffff00 ) | val ;
break ;
case 0x01 :
es1371 - > int_ctrl = ( es1371 - > int_ctrl & 0xffff00ff ) | ( val < < 8 ) ;
break ;
case 0x02 :
es1371 - > int_ctrl = ( es1371 - > int_ctrl & 0xff00ffff ) | ( val < < 16 ) ;
break ;
case 0x03 :
es1371 - > int_ctrl = ( es1371 - > int_ctrl & 0x00ffffff ) | ( val < < 24 ) ;
break ;
2020-01-01 20:20:16 +01:00
case 0x08 :
midi_raw_out_byte ( val ) ;
break ;
2017-11-24 02:23:00 -05:00
case 0x09 :
2020-01-01 20:20:16 +01:00
es1371 - > uart_ctrl = val & 0xe3 ;
audiopci_log ( " ES1371 UART Cntrl = %02x \n " , es1371 - > uart_ctrl ) ;
2017-11-24 02:23:00 -05:00
break ;
case 0x0c :
es1371 - > mem_page = val & 0xf ;
break ;
case 0x18 :
es1371 - > legacy_ctrl | = LEGACY_INT ;
nmi = 0 ;
break ;
case 0x1a :
2020-11-16 00:01:21 +01:00
old_legacy_ctrl = es1371 - > legacy_ctrl ;
2017-11-24 02:23:00 -05:00
es1371 - > legacy_ctrl = ( es1371 - > legacy_ctrl & 0xff00ffff ) | ( val < < 16 ) ;
2020-11-16 00:01:21 +01:00
update_legacy ( es1371 , old_legacy_ctrl ) ;
2017-11-24 02:23:00 -05:00
break ;
case 0x1b :
2020-11-16 00:01:21 +01:00
old_legacy_ctrl = es1371 - > legacy_ctrl ;
2017-11-24 02:23:00 -05:00
es1371 - > legacy_ctrl = ( es1371 - > legacy_ctrl & 0x00ffffff ) | ( val < < 24 ) ;
es1371_update_irqs ( es1371 ) ;
// output = 3;
2020-11-16 00:01:21 +01:00
update_legacy ( es1371 , old_legacy_ctrl ) ;
2017-11-24 02:23:00 -05:00
break ;
case 0x20 :
es1371 - > si_cr = ( es1371 - > si_cr & 0xffff00 ) | val ;
break ;
case 0x21 :
es1371 - > si_cr = ( es1371 - > si_cr & 0xff00ff ) | ( val < < 8 ) ;
if ( ! ( es1371 - > si_cr & SI_P1_INTR_EN ) )
es1371 - > int_status & = ~ INT_STATUS_DAC1 ;
if ( ! ( es1371 - > si_cr & SI_P2_INTR_EN ) )
es1371 - > int_status & = ~ INT_STATUS_DAC2 ;
es1371_update_irqs ( es1371 ) ;
break ;
case 0x22 :
es1371 - > si_cr = ( es1371 - > si_cr & 0x00ffff ) | ( val < < 16 ) ;
break ;
default :
audiopci_log ( " Bad es1371_outb: port=%04x val=%02x \n " , port , val ) ;
}
2017-10-14 07:03:19 +02:00
}
static void es1371_outw ( uint16_t port , uint16_t val , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
// audiopci_log("es1371_outw: port=%04x val=%04x\n", port, val);
switch ( port & 0x3f )
{
case 0x0c :
es1371 - > mem_page = val & 0xf ;
break ;
case 0x24 :
es1371 - > dac [ 0 ] . samp_ct = val ;
break ;
case 0x28 :
es1371 - > dac [ 1 ] . samp_ct = val ;
break ;
default :
audiopci_log ( " Bad es1371_outw: port=%04x val=%04x \n " , port , val ) ;
}
2017-10-14 07:03:19 +02:00
}
static void es1371_outl ( uint16_t port , uint32_t val , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
2020-01-01 20:20:16 +01:00
audiopci_log ( " es1371_outl: port=%04x val=%08x \n " , port , val ) ;
2017-11-24 02:23:00 -05:00
switch ( port & 0x3f )
{
case 0x04 :
break ;
case 0x0c :
es1371 - > mem_page = val & 0xf ;
break ;
case 0x10 :
es1371 - > sr_cir = val ;
if ( es1371 - > sr_cir & SRC_RAM_WE )
{
// 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 )
{
case 0x71 :
es1371 - > dac [ 0 ] . vf = ( es1371 - > dac [ 0 ] . vf & ~ 0x1f8000 ) | ( ( val & 0xfc00 ) < < 5 ) ;
es1371 - > dac [ 0 ] . ac = ( es1371 - > dac [ 0 ] . ac & ~ 0x7f8000 ) | ( ( val & 0x00ff ) < < 15 ) ;
2018-03-15 23:15:33 +01:00
es1371 - > dac [ 0 ] . f_pos = 0 ;
2017-11-24 02:23:00 -05:00
break ;
case 0x72 :
es1371 - > dac [ 0 ] . ac = ( es1371 - > dac [ 0 ] . ac & ~ 0x7fff ) | ( val & 0x7fff ) ;
break ;
case 0x73 :
es1371 - > dac [ 0 ] . vf = ( es1371 - > dac [ 0 ] . vf & ~ 0x7fff ) | ( val & 0x7fff ) ;
break ;
case 0x75 :
es1371 - > dac [ 1 ] . vf = ( es1371 - > dac [ 1 ] . vf & ~ 0x1f8000 ) | ( ( val & 0xfc00 ) < < 5 ) ;
es1371 - > dac [ 1 ] . ac = ( es1371 - > dac [ 1 ] . ac & ~ 0x7f8000 ) | ( ( val & 0x00ff ) < < 15 ) ;
2018-03-15 23:15:33 +01:00
es1371 - > dac [ 1 ] . f_pos = 0 ;
2017-11-24 02:23:00 -05:00
break ;
case 0x76 :
es1371 - > dac [ 1 ] . ac = ( es1371 - > dac [ 1 ] . ac & ~ 0x7fff ) | ( val & 0x7fff ) ;
break ;
case 0x77 :
es1371 - > dac [ 1 ] . vf = ( es1371 - > dac [ 1 ] . vf & ~ 0x7fff ) | ( val & 0x7fff ) ;
break ;
case 0x7c :
es1371 - > dac [ 0 ] . vol_l = ( int32_t ) ( int16_t ) ( val & 0xffff ) ;
break ;
case 0x7d :
es1371 - > dac [ 0 ] . vol_r = ( int32_t ) ( int16_t ) ( val & 0xffff ) ;
break ;
case 0x7e :
es1371 - > dac [ 1 ] . vol_l = ( int32_t ) ( int16_t ) ( val & 0xffff ) ;
break ;
case 0x7f :
es1371 - > dac [ 1 ] . vol_r = ( int32_t ) ( int16_t ) ( val & 0xffff ) ;
break ;
}
}
break ;
case 0x14 :
es1371 - > codec_ctrl = val ;
if ( ! ( val & CODEC_READ ) )
{
2020-04-29 23:39:54 +02:00
// audiopci_log("Write codec %02x %04x\n", (val >> 16) & 0x7f, val & 0xffff);
2020-10-19 02:21:05 +02:00
if ( ( ( ( val > > 16 ) & 0x7f ) ! = 0x7c ) & & ( ( ( val > > 16 ) & 0x7f ) ! = 0x7e ) )
2020-04-29 23:39:54 +02:00
es1371 - > codec_regs [ ( val > > 16 ) & 0x7f ] = val & 0xffff ;
switch ( ( val > > 16 ) & 0x7f )
2017-11-24 02:23:00 -05:00
{
case 0x02 : /*Master volume*/
if ( val & 0x8000 )
es1371 - > master_vol_l = es1371 - > master_vol_r = 0 ;
else
{
if ( val & 0x2000 )
es1371 - > master_vol_l = codec_attn [ 0 ] ;
else
es1371 - > master_vol_l = codec_attn [ 0x1f - ( ( val > > 8 ) & 0x1f ) ] ;
if ( val & 0x20 )
es1371 - > master_vol_r = codec_attn [ 0 ] ;
else
es1371 - > master_vol_r = codec_attn [ 0x1f - ( val & 0x1f ) ] ;
}
break ;
2020-10-19 02:21:05 +02:00
case 0x12 : /*CD volume*/
if ( val & 0x8000 )
es1371 - > cd_vol_l = es1371 - > cd_vol_r = 0 ;
else
{
es1371 - > cd_vol_l = codec_attn [ 0x1f - ( ( val > > 8 ) & 0x1f ) ] ;
es1371 - > cd_vol_r = codec_attn [ 0x1f - ( val & 0x1f ) ] ;
}
break ;
2017-11-24 02:23:00 -05:00
}
}
break ;
case 0x24 :
es1371 - > dac [ 0 ] . samp_ct = val & 0xffff ;
break ;
case 0x28 :
es1371 - > dac [ 1 ] . samp_ct = val & 0xffff ;
break ;
case 0x30 :
switch ( es1371 - > mem_page )
{
case 0x0 : case 0x1 : case 0x2 : case 0x3 :
case 0x4 : case 0x5 : case 0x6 : case 0x7 :
case 0x8 : case 0x9 : case 0xa : case 0xb :
break ;
case 0xc :
es1371 - > dac [ 0 ] . addr_latch = val ;
// audiopci_log("DAC1 addr %08x\n", val);
break ;
2020-01-01 20:20:16 +01:00
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x30 write UART FIFO: val = %02x \n " , val & 0xff ) ;
break ;
2017-11-24 02:23:00 -05:00
default :
audiopci_log ( " Bad es1371_outl: mem_page=%x port=%04x val=%08x \n " , es1371 - > mem_page , port , val ) ;
}
break ;
case 0x34 :
switch ( es1371 - > mem_page )
{
case 0x0 : case 0x1 : case 0x2 : case 0x3 :
case 0x4 : case 0x5 : case 0x6 : case 0x7 :
case 0x8 : case 0x9 : case 0xa : case 0xb :
break ;
case 0xc :
es1371 - > dac [ 0 ] . size = val & 0xffff ;
es1371 - > dac [ 0 ] . count = val > > 16 ;
break ;
case 0xd :
es1371 - > adc . size = val & 0xffff ;
es1371 - > adc . count = val > > 16 ;
break ;
2020-01-01 20:20:16 +01:00
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x34 write UART FIFO: val = %02x \n " , val & 0xff ) ;
break ;
2017-11-24 02:23:00 -05:00
default :
audiopci_log ( " Bad es1371_outl: mem_page=%x port=%04x val=%08x \n " , es1371 - > mem_page , port , val ) ;
}
break ;
case 0x38 :
switch ( es1371 - > mem_page )
{
case 0x0 : case 0x1 : case 0x2 : case 0x3 :
case 0x4 : case 0x5 : case 0x6 : case 0x7 :
case 0x8 : case 0x9 : case 0xa : case 0xb :
break ;
case 0xc :
es1371 - > dac [ 1 ] . addr_latch = val ;
break ;
case 0xd :
break ;
2020-01-01 20:20:16 +01:00
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x38 write UART FIFO: val = %02x \n " , val & 0xff ) ;
break ;
2017-11-24 02:23:00 -05:00
default :
audiopci_log ( " Bad es1371_outl: mem_page=%x port=%04x val=%08x \n " , es1371 - > mem_page , port , val ) ;
}
break ;
case 0x3c :
switch ( es1371 - > mem_page )
{
case 0x0 : case 0x1 : case 0x2 : case 0x3 :
case 0x4 : case 0x5 : case 0x6 : case 0x7 :
case 0x8 : case 0x9 : case 0xa : case 0xb :
break ;
case 0xc :
es1371 - > dac [ 1 ] . size = val & 0xffff ;
es1371 - > dac [ 1 ] . count = val > > 16 ;
2020-01-01 20:20:16 +01:00
break ;
case 0xe : case 0xf :
audiopci_log ( " ES1371 0x3c write UART FIFO: val = %02x \n " , val & 0xff ) ;
2017-11-24 02:23:00 -05:00
break ;
default :
audiopci_log ( " Bad es1371_outl: mem_page=%x port=%04x val=%08x \n " , es1371 - > mem_page , port , val ) ;
}
break ;
default :
audiopci_log ( " Bad es1371_outl: port=%04x val=%08x \n " , port , val ) ;
}
2017-10-14 07:03:19 +02:00
}
static void capture_event ( es1371_t * es1371 , int type , int rw , uint16_t port )
{
2017-11-24 02:23:00 -05:00
es1371 - > legacy_ctrl & = ~ ( LEGACY_EVENT_MASK | LEGACY_EVENT_ADDR_MASK ) ;
es1371 - > legacy_ctrl | = type ;
if ( rw )
es1371 - > legacy_ctrl | = LEGACY_EVENT_TYPE_RW ;
else
es1371 - > legacy_ctrl & = ~ LEGACY_EVENT_TYPE_RW ;
es1371 - > legacy_ctrl | = ( ( port < < LEGACY_EVENT_ADDR_SHIFT ) & LEGACY_EVENT_ADDR_MASK ) ;
es1371 - > legacy_ctrl & = ~ LEGACY_INT ;
nmi = 1 ;
// audiopci_log("Event! %s %04x\n", rw ? "write" : "read", port);
2017-10-14 07:03:19 +02:00
}
static void capture_write_sscape ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SSCAPE , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static void capture_write_codec ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_CODEC , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static void capture_write_sb ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SB , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static void capture_write_adlib ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_ADLIB , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static void capture_write_master_pic ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_MASTER_PIC , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static void capture_write_master_dma ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_MASTER_DMA , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static void capture_write_slave_pic ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SLAVE_PIC , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static void capture_write_slave_dma ( uint16_t port , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SLAVE_DMA , 1 , port ) ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_sscape ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SSCAPE , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_codec ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_CODEC , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_sb ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SB , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_adlib ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_ADLIB , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_master_pic ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_MASTER_PIC , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_master_dma ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_MASTER_DMA , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_slave_pic ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SLAVE_PIC , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
static uint8_t capture_read_slave_dma ( uint16_t port , void * p )
{
2017-11-24 02:23:00 -05:00
capture_event ( p , LEGACY_EVENT_SLAVE_DMA , 0 , port ) ;
return 0xff ;
2017-10-14 07:03:19 +02:00
}
2020-11-16 00:01:21 +01:00
static void update_legacy ( es1371_t * es1371 , uint32_t old_legacy_ctrl )
2017-10-14 07:03:19 +02:00
{
2020-11-16 00:01:21 +01:00
if ( old_legacy_ctrl & LEGACY_CAPTURE_SSCAPE )
{
switch ( ( old_legacy_ctrl > > LEGACY_SSCAPE_ADDR_SHIFT ) & 3 )
{
case 0 : io_removehandler ( 0x0320 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
case 1 : io_removehandler ( 0x0330 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
case 2 : io_removehandler ( 0x0340 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
case 3 : io_removehandler ( 0x0350 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
}
}
if ( old_legacy_ctrl & LEGACY_CAPTURE_CODEC )
{
switch ( ( old_legacy_ctrl > > LEGACY_CODEC_ADDR_SHIFT ) & 3 )
{
case 0 : io_removehandler ( 0x5300 , 0x0080 , capture_read_codec , NULL , NULL , capture_write_codec , NULL , NULL , es1371 ) ; break ;
case 2 : io_removehandler ( 0xe800 , 0x0080 , capture_read_codec , NULL , NULL , capture_write_codec , NULL , NULL , es1371 ) ; break ;
case 3 : io_removehandler ( 0xf400 , 0x0080 , capture_read_codec , NULL , NULL , capture_write_codec , NULL , NULL , es1371 ) ; break ;
}
}
if ( old_legacy_ctrl & LEGACY_CAPTURE_SB )
{
if ( ! ( old_legacy_ctrl & LEGACY_SB_ADDR ) )
io_removehandler ( 0x0220 , 0x0010 , capture_read_sb , NULL , NULL , capture_write_sb , NULL , NULL , es1371 ) ;
else
io_removehandler ( 0x0240 , 0x0010 , capture_read_sb , NULL , NULL , capture_write_sb , NULL , NULL , es1371 ) ;
}
if ( old_legacy_ctrl & LEGACY_CAPTURE_ADLIB )
io_removehandler ( 0x0388 , 0x0004 , capture_read_adlib , NULL , NULL , capture_write_adlib , NULL , NULL , es1371 ) ;
if ( old_legacy_ctrl & LEGACY_CAPTURE_MASTER_PIC )
io_removehandler ( 0x0020 , 0x0002 , capture_read_master_pic , NULL , NULL , capture_write_master_pic , NULL , NULL , es1371 ) ;
if ( old_legacy_ctrl & LEGACY_CAPTURE_MASTER_DMA )
io_removehandler ( 0x0000 , 0x0010 , capture_read_master_dma , NULL , NULL , capture_write_master_dma , NULL , NULL , es1371 ) ;
if ( old_legacy_ctrl & LEGACY_CAPTURE_SLAVE_PIC )
io_removehandler ( 0x00a0 , 0x0002 , capture_read_slave_pic , NULL , NULL , capture_write_slave_pic , NULL , NULL , es1371 ) ;
if ( old_legacy_ctrl & LEGACY_CAPTURE_SLAVE_DMA )
io_removehandler ( 0x00c0 , 0x0020 , capture_read_slave_dma , NULL , NULL , capture_write_slave_dma , NULL , NULL , es1371 ) ;
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_SSCAPE )
{
switch ( ( es1371 - > legacy_ctrl > > LEGACY_SSCAPE_ADDR_SHIFT ) & 3 )
{
case 0 : io_sethandler ( 0x0320 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
case 1 : io_sethandler ( 0x0330 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
case 2 : io_sethandler ( 0x0340 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
case 3 : io_sethandler ( 0x0350 , 0x0008 , capture_read_sscape , NULL , NULL , capture_write_sscape , NULL , NULL , es1371 ) ; break ;
}
}
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_CODEC )
{
switch ( ( es1371 - > legacy_ctrl > > LEGACY_CODEC_ADDR_SHIFT ) & 3 )
{
case 0 : io_sethandler ( 0x5300 , 0x0080 , capture_read_codec , NULL , NULL , capture_write_codec , NULL , NULL , es1371 ) ; break ;
case 2 : io_sethandler ( 0xe800 , 0x0080 , capture_read_codec , NULL , NULL , capture_write_codec , NULL , NULL , es1371 ) ; break ;
case 3 : io_sethandler ( 0xf400 , 0x0080 , capture_read_codec , NULL , NULL , capture_write_codec , NULL , NULL , es1371 ) ; break ;
}
}
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_SB )
{
if ( ! ( es1371 - > legacy_ctrl & LEGACY_SB_ADDR ) )
io_sethandler ( 0x0220 , 0x0010 , capture_read_sb , NULL , NULL , capture_write_sb , NULL , NULL , es1371 ) ;
else
io_sethandler ( 0x0240 , 0x0010 , capture_read_sb , NULL , NULL , capture_write_sb , NULL , NULL , es1371 ) ;
}
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_ADLIB )
io_sethandler ( 0x0388 , 0x0004 , capture_read_adlib , NULL , NULL , capture_write_adlib , NULL , NULL , es1371 ) ;
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_MASTER_PIC )
io_sethandler ( 0x0020 , 0x0002 , capture_read_master_pic , NULL , NULL , capture_write_master_pic , NULL , NULL , es1371 ) ;
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_MASTER_DMA )
io_sethandler ( 0x0000 , 0x0010 , capture_read_master_dma , NULL , NULL , capture_write_master_dma , NULL , NULL , es1371 ) ;
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_SLAVE_PIC )
io_sethandler ( 0x00a0 , 0x0002 , capture_read_slave_pic , NULL , NULL , capture_write_slave_pic , NULL , NULL , es1371 ) ;
if ( es1371 - > legacy_ctrl & LEGACY_CAPTURE_SLAVE_DMA )
io_sethandler ( 0x00c0 , 0x0020 , capture_read_slave_dma , NULL , NULL , capture_write_slave_dma , NULL , NULL , es1371 ) ;
2017-10-14 07:03:19 +02:00
}
static uint8_t es1371_pci_read ( int func , int addr , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
if ( func )
return 0 ;
//audiopci_log("ES1371 PCI read %08X PC=%08x\n", addr, cpu_state.pc);
2020-01-19 05:45:05 +01:00
if ( addr > 0x3f )
return 0x00 ;
2017-11-24 02:23:00 -05:00
switch ( addr )
{
case 0x00 : return 0x74 ; /*Ensoniq*/
case 0x01 : return 0x12 ;
2020-01-19 05:45:05 +01:00
case 0x02 : return 0x71 ; /* ES1371 */
2017-11-24 02:23:00 -05:00
case 0x03 : return 0x13 ;
2020-01-19 05:45:05 +01:00
2017-11-24 02:23:00 -05:00
case 0x04 : return es1371 - > pci_command ;
case 0x05 : return es1371 - > pci_serr ;
2020-01-19 05:45:05 +01:00
case 0x06 : return 0x10 ; /* Supports support ACPI */
case 0x07 : return 0x00 ;
2017-11-24 02:23:00 -05:00
2020-01-19 05:45:05 +01:00
case 0x08 : return 0x02 ; /* Revision ID */
case 0x09 : return 0x00 ; /* Multimedia audio device */
2017-11-24 02:23:00 -05:00
case 0x0a : return 0x01 ;
case 0x0b : return 0x04 ;
2020-01-19 05:45:05 +01:00
case 0x10 : return 0x01 | ( es1371 - > base_addr & 0xc0 ) ; /* memBaseAddr */
2017-11-24 02:23:00 -05:00
case 0x11 : return es1371 - > base_addr > > 8 ;
case 0x12 : return es1371 - > base_addr > > 16 ;
case 0x13 : return es1371 - > base_addr > > 24 ;
2020-01-19 05:45:05 +01:00
case 0x2c : return 0x74 ; /* Subsystem vendor ID */
2017-11-24 02:23:00 -05:00
case 0x2d : return 0x12 ;
case 0x2e : return 0x71 ;
case 0x2f : return 0x13 ;
2020-01-19 05:45:05 +01:00
2017-11-24 02:23:00 -05:00
case 0x34 : return 0xdc ; /*Capabilites pointer*/
2020-01-19 05:45:05 +01:00
2017-11-24 02:23:00 -05:00
case 0x3c : return es1371 - > int_line ;
case 0x3d : return 0x01 ; /*INTA*/
2020-01-19 05:45:05 +01:00
2017-11-24 02:23:00 -05:00
case 0x3e : return 0xc ; /*Minimum grant*/
case 0x3f : return 0x80 ; /*Maximum latency*/
case 0xdc : return 0x01 ; /*Capabilities identifier*/
case 0xdd : return 0x00 ; /*Next item pointer*/
case 0xde : return 0x31 ; /*Power management capabilities*/
case 0xdf : return 0x6c ;
case 0xe0 : return es1371 - > pmcsr & 0xff ;
case 0xe1 : return es1371 - > pmcsr > > 8 ;
}
return 0 ;
2017-10-14 07:03:19 +02:00
}
static void es1371_pci_write ( int func , int addr , uint8_t val , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
if ( func )
return ;
// audiopci_log("ES1371 PCI write %04X %02X PC=%08x\n", addr, val, cpu_state.pc);
switch ( addr )
{
case 0x04 :
if ( es1371 - > pci_command & PCI_COMMAND_IO )
io_removehandler ( es1371 - > base_addr , 0x0040 , es1371_inb , es1371_inw , es1371_inl , es1371_outb , es1371_outw , es1371_outl , es1371 ) ;
es1371 - > pci_command = val & 0x05 ;
if ( es1371 - > pci_command & PCI_COMMAND_IO )
io_sethandler ( es1371 - > base_addr , 0x0040 , es1371_inb , es1371_inw , es1371_inl , es1371_outb , es1371_outw , es1371_outl , es1371 ) ;
break ;
case 0x05 :
es1371 - > pci_serr = val & 1 ;
break ;
case 0x10 :
if ( es1371 - > pci_command & PCI_COMMAND_IO )
io_removehandler ( es1371 - > base_addr , 0x0040 , es1371_inb , es1371_inw , es1371_inl , es1371_outb , es1371_outw , es1371_outl , es1371 ) ;
es1371 - > base_addr = ( es1371 - > base_addr & 0xffffff00 ) | ( val & 0xc0 ) ;
if ( es1371 - > pci_command & PCI_COMMAND_IO )
io_sethandler ( es1371 - > base_addr , 0x0040 , es1371_inb , es1371_inw , es1371_inl , es1371_outb , es1371_outw , es1371_outl , es1371 ) ;
break ;
case 0x11 :
if ( es1371 - > pci_command & PCI_COMMAND_IO )
io_removehandler ( es1371 - > base_addr , 0x0040 , es1371_inb , es1371_inw , es1371_inl , es1371_outb , es1371_outw , es1371_outl , es1371 ) ;
es1371 - > base_addr = ( es1371 - > base_addr & 0xffff00c0 ) | ( val < < 8 ) ;
if ( es1371 - > pci_command & PCI_COMMAND_IO )
io_sethandler ( es1371 - > base_addr , 0x0040 , es1371_inb , es1371_inw , es1371_inl , es1371_outb , es1371_outw , es1371_outl , es1371 ) ;
break ;
case 0x12 :
es1371 - > base_addr = ( es1371 - > base_addr & 0xff00ffc0 ) | ( val < < 16 ) ;
break ;
case 0x13 :
es1371 - > base_addr = ( es1371 - > base_addr & 0x00ffffc0 ) | ( val < < 24 ) ;
break ;
case 0x3c :
es1371 - > int_line = val ;
break ;
case 0xe0 :
es1371 - > pmcsr = ( es1371 - > pmcsr & 0xff00 ) | ( val & 0x03 ) ;
break ;
case 0xe1 :
es1371 - > pmcsr = ( es1371 - > pmcsr & 0x00ff ) | ( ( val & 0x01 ) < < 8 ) ;
break ;
}
// audiopci_log("es1371->base_addr %08x\n", es1371->base_addr);
2017-10-14 07:03:19 +02:00
}
static void es1371_fetch ( es1371_t * es1371 , int dac_nr )
{
2017-11-24 02:23:00 -05:00
int format = dac_nr ? ( ( es1371 - > si_cr > > 2 ) & 3 ) : ( es1371 - > si_cr & 3 ) ;
int pos = es1371 - > dac [ dac_nr ] . buffer_pos & 63 ;
int c ;
2017-10-14 07:03:19 +02:00
2017-10-16 06:19:18 +02:00
//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);
2017-11-24 02:23:00 -05:00
switch ( format )
{
case FORMAT_MONO_8 :
for ( c = 0 ; c < 32 ; c + = 4 )
{
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c ) & 63 ] = es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c + 1 ) & 63 ] = es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c + 1 ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr + 1 ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c + 2 ) & 63 ] = es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c + 2 ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr + 2 ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c + 3 ) & 63 ] = es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c + 3 ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr + 3 ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . addr + = 4 ;
es1371 - > dac [ dac_nr ] . buffer_pos_end + = 4 ;
es1371 - > dac [ dac_nr ] . count + + ;
if ( es1371 - > dac [ dac_nr ] . count > es1371 - > dac [ dac_nr ] . size )
{
es1371 - > dac [ dac_nr ] . count = 0 ;
es1371 - > dac [ dac_nr ] . addr = es1371 - > dac [ dac_nr ] . addr_latch ;
break ;
}
}
break ;
case FORMAT_STEREO_8 :
for ( c = 0 ; c < 16 ; c + = 2 )
{
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr + 1 ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c + 1 ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr + 2 ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c + 1 ) & 63 ] = ( mem_readb_phys ( es1371 - > dac [ dac_nr ] . addr + 3 ) ^ 0x80 ) < < 8 ;
es1371 - > dac [ dac_nr ] . addr + = 4 ;
es1371 - > dac [ dac_nr ] . buffer_pos_end + = 2 ;
es1371 - > dac [ dac_nr ] . count + + ;
if ( es1371 - > dac [ dac_nr ] . count > es1371 - > dac [ dac_nr ] . size )
{
es1371 - > dac [ dac_nr ] . count = 0 ;
es1371 - > dac [ dac_nr ] . addr = es1371 - > dac [ dac_nr ] . addr_latch ;
break ;
}
}
break ;
case FORMAT_MONO_16 :
for ( c = 0 ; c < 16 ; c + = 2 )
{
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c ) & 63 ] = es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c ) & 63 ] = mem_readw_phys ( es1371 - > dac [ dac_nr ] . addr ) ;
es1371 - > dac [ dac_nr ] . buffer_l [ ( pos + c + 1 ) & 63 ] = es1371 - > dac [ dac_nr ] . buffer_r [ ( pos + c + 1 ) & 63 ] = mem_readw_phys ( es1371 - > dac [ dac_nr ] . addr + 2 ) ;
es1371 - > dac [ dac_nr ] . addr + = 4 ;
es1371 - > dac [ dac_nr ] . buffer_pos_end + = 2 ;
es1371 - > dac [ dac_nr ] . count + + ;
if ( es1371 - > dac [ dac_nr ] . count > es1371 - > dac [ dac_nr ] . size )
{
es1371 - > dac [ dac_nr ] . count = 0 ;
es1371 - > dac [ dac_nr ] . addr = es1371 - > dac [ dac_nr ] . addr_latch ;
break ;
}
}
break ;
case FORMAT_STEREO_16 :
for ( c = 0 ; c < 4 ; c + + )
{
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 ) ;
// 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 + + ;
es1371 - > dac [ dac_nr ] . count + + ;
if ( es1371 - > dac [ dac_nr ] . count > es1371 - > dac [ dac_nr ] . size )
{
es1371 - > dac [ dac_nr ] . count = 0 ;
es1371 - > dac [ dac_nr ] . addr = es1371 - > dac [ dac_nr ] . addr_latch ;
break ;
}
}
break ;
}
2017-10-14 07:03:19 +02:00
}
2018-03-15 23:15:33 +01:00
static inline float low_fir_es1371 ( int dac_nr , int i , float NewSample )
2017-10-14 07:03:19 +02:00
{
2018-03-15 23:15:33 +01:00
static float x [ 2 ] [ 2 ] [ 128 ] ; //input samples
static int x_pos [ 2 ] = { 0 , 0 } ;
float out = 0.0 ;
int read_pos ;
int n_coef ;
int pos = x_pos [ dac_nr ] ;
x [ dac_nr ] [ i ] [ pos ] = NewSample ;
/*Since only 1/16th of input samples are non-zero, only filter those that
are valid . */
read_pos = ( pos + 15 ) & ( 127 & ~ 15 ) ;
n_coef = ( 16 - pos ) & 15 ;
while ( n_coef < ES1371_NCoef )
{
out + = low_fir_es1371_coef [ n_coef ] * x [ dac_nr ] [ i ] [ read_pos ] ;
read_pos = ( read_pos + 16 ) & ( 127 & ~ 15 ) ;
n_coef + = 16 ;
}
if ( i = = 1 )
{
x_pos [ dac_nr ] = ( x_pos [ dac_nr ] + 1 ) & 127 ;
if ( x_pos [ dac_nr ] > 127 )
x_pos [ dac_nr ] = 0 ;
}
return out ;
}
static void es1371_next_sample_filtered ( es1371_t * es1371 , int dac_nr , int out_idx )
{
int out_l , out_r ;
int c ;
2017-11-24 02:23:00 -05:00
if ( ( es1371 - > dac [ dac_nr ] . buffer_pos - es1371 - > dac [ dac_nr ] . buffer_pos_end ) > = 0 )
{
es1371_fetch ( es1371 , dac_nr ) ;
}
2018-03-15 23:15:33 +01:00
out_l = es1371 - > dac [ dac_nr ] . buffer_l [ es1371 - > dac [ dac_nr ] . buffer_pos & 63 ] ;
out_r = es1371 - > dac [ dac_nr ] . buffer_r [ es1371 - > dac [ dac_nr ] . buffer_pos & 63 ] ;
es1371 - > dac [ dac_nr ] . filtered_l [ out_idx ] = ( int ) low_fir_es1371 ( dac_nr , 0 , ( float ) out_l ) ;
es1371 - > dac [ dac_nr ] . filtered_r [ out_idx ] = ( int ) low_fir_es1371 ( dac_nr , 1 , ( float ) out_r ) ;
for ( c = 1 ; c < 16 ; c + + )
{
es1371 - > dac [ dac_nr ] . filtered_l [ out_idx + c ] = ( int ) low_fir_es1371 ( dac_nr , 0 , 0 ) ;
es1371 - > dac [ dac_nr ] . filtered_r [ out_idx + c ] = ( int ) low_fir_es1371 ( dac_nr , 1 , 0 ) ;
}
2017-11-24 02:23:00 -05:00
// 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 + + ;
// 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);
2017-10-14 07:03:19 +02:00
}
//static FILE *es1371_f;//,*es1371_f2;
2018-03-15 23:15:33 +01:00
static void es1371_update ( es1371_t * es1371 )
{
int32_t l , r ;
l = ( es1371 - > dac [ 0 ] . out_l * es1371 - > dac [ 0 ] . vol_l ) > > 12 ;
l + = ( ( es1371 - > dac [ 1 ] . out_l * es1371 - > dac [ 1 ] . vol_l ) > > 12 ) ;
r = ( es1371 - > dac [ 0 ] . out_r * es1371 - > dac [ 0 ] . vol_r ) > > 12 ;
2020-10-19 01:02:40 +02:00
r + = ( ( es1371 - > dac [ 1 ] . out_r * es1371 - > dac [ 1 ] . vol_r ) > > 12 ) ;
2018-03-15 23:15:33 +01:00
l > > = 1 ;
r > > = 1 ;
l = ( l * es1371 - > master_vol_l ) > > 15 ;
r = ( r * es1371 - > master_vol_r ) > > 15 ;
if ( l < - 32768 )
l = - 32768 ;
else if ( l > 32767 )
l = 32767 ;
if ( r < - 32768 )
r = - 32768 ;
else if ( r > 32767 )
r = 32767 ;
for ( ; es1371 - > pos < sound_pos_global ; es1371 - > pos + + )
{
es1371 - > buffer [ es1371 - > pos * 2 ] = l ;
es1371 - > buffer [ es1371 - > pos * 2 + 1 ] = r ;
}
}
2017-10-14 07:03:19 +02:00
static void es1371_poll ( void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_advance_u64 ( & es1371 - > dac [ 1 ] . timer , es1371 - > dac [ 1 ] . latch ) ;
2020-01-01 20:20:16 +01:00
es1371_update ( es1371 ) ;
if ( es1371 - > int_ctrl & INT_UART_EN ) {
audiopci_log ( " UART INT Enabled \n " ) ;
2020-01-19 05:45:05 +01:00
if ( es1371 - > uart_ctrl & UART_CTRL_RXINTEN ) { /*We currently don't implement MIDI Input.*/
2020-01-01 20:20:16 +01:00
/*But if anything sets MIDI Input and Output together we'd have to take account
of the MIDI Output case , and disable IRQ ' s and RX bits when MIDI Input is enabled as well but not in the MIDI Output portion */
if ( es1371 - > uart_ctrl & UART_CTRL_TXINTEN )
es1371 - > int_status | = INT_STATUS_UART ;
else
es1371 - > int_status & = ~ INT_STATUS_UART ;
2020-01-19 05:45:05 +01:00
} else if ( ! ( es1371 - > uart_ctrl & UART_CTRL_RXINTEN ) & & ( ( es1371 - > uart_ctrl & UART_CTRL_TXINTEN ) ) ) { /*Or enable the UART IRQ and the respective TX bits only when the MIDI Output is enabled*/
2020-01-01 20:20:16 +01:00
es1371 - > int_status | = INT_STATUS_UART ;
}
2020-01-19 05:45:05 +01:00
if ( es1371 - > uart_ctrl & UART_CTRL_RXINTEN ) {
2020-01-01 20:20:16 +01:00
if ( es1371 - > uart_ctrl & UART_CTRL_TXINTEN )
es1371 - > uart_status | = ( UART_STATUS_TXINT | UART_STATUS_TXRDY ) ;
else
es1371 - > uart_status & = ~ ( UART_STATUS_TXINT | UART_STATUS_TXRDY ) ;
} else
es1371 - > uart_status | = ( UART_STATUS_TXINT | UART_STATUS_TXRDY ) ;
es1371_update_irqs ( es1371 ) ;
}
if ( es1371 - > int_ctrl & INT_DAC1_EN ) {
2018-03-15 23:15:33 +01:00
int frac = es1371 - > dac [ 0 ] . ac & 0x7fff ;
int idx = es1371 - > dac [ 0 ] . ac > > 15 ;
int samp1_l = es1371 - > dac [ 0 ] . filtered_l [ idx ] ;
int samp1_r = es1371 - > dac [ 0 ] . filtered_r [ idx ] ;
int samp2_l = es1371 - > dac [ 0 ] . filtered_l [ ( idx + 1 ) & 31 ] ;
int samp2_r = es1371 - > dac [ 0 ] . filtered_r [ ( idx + 1 ) & 31 ] ;
es1371 - > dac [ 0 ] . out_l = ( ( samp1_l * ( 0x8000 - frac ) ) + ( samp2_l * frac ) ) > > 15 ;
es1371 - > dac [ 0 ] . out_r = ( ( samp1_r * ( 0x8000 - frac ) ) + ( samp2_r * frac ) ) > > 15 ;
es1371 - > dac [ 0 ] . ac + = es1371 - > dac [ 0 ] . vf ;
es1371 - > dac [ 0 ] . ac & = ( ( 32 < < 15 ) - 1 ) ;
if ( ( es1371 - > dac [ 0 ] . ac > > ( 15 + 4 ) ) ! = es1371 - > dac [ 0 ] . f_pos )
2017-11-24 02:23:00 -05:00
{
2018-03-15 23:15:33 +01:00
es1371_next_sample_filtered ( es1371 , 0 , es1371 - > dac [ 0 ] . f_pos ? 16 : 0 ) ;
es1371 - > dac [ 0 ] . f_pos = ( es1371 - > dac [ 0 ] . f_pos + 1 ) & 1 ;
2017-11-24 02:23:00 -05:00
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
es1371 - > dac [ 0 ] . curr_samp_ct - - ;
if ( es1371 - > dac [ 0 ] . curr_samp_ct < 0 )
2017-11-24 02:23:00 -05:00
{
es1371 - > int_status | = INT_STATUS_DAC1 ;
es1371_update_irqs ( es1371 ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
es1371 - > dac [ 0 ] . curr_samp_ct = es1371 - > dac [ 0 ] . samp_ct ;
2017-11-24 02:23:00 -05:00
}
}
}
if ( es1371 - > int_ctrl & INT_DAC2_EN )
{
2018-03-15 23:15:33 +01:00
int frac = es1371 - > dac [ 1 ] . ac & 0x7fff ;
int idx = es1371 - > dac [ 1 ] . ac > > 15 ;
int samp1_l = es1371 - > dac [ 1 ] . filtered_l [ idx ] ;
int samp1_r = es1371 - > dac [ 1 ] . filtered_r [ idx ] ;
int samp2_l = es1371 - > dac [ 1 ] . filtered_l [ ( idx + 1 ) & 31 ] ;
int samp2_r = es1371 - > dac [ 1 ] . filtered_r [ ( idx + 1 ) & 31 ] ;
es1371 - > dac [ 1 ] . out_l = ( ( samp1_l * ( 0x8000 - frac ) ) + ( samp2_l * frac ) ) > > 15 ;
es1371 - > dac [ 1 ] . out_r = ( ( samp1_r * ( 0x8000 - frac ) ) + ( samp2_r * frac ) ) > > 15 ;
2017-11-24 02:23:00 -05:00
es1371 - > dac [ 1 ] . ac + = es1371 - > dac [ 1 ] . vf ;
2018-03-15 23:15:33 +01:00
es1371 - > dac [ 1 ] . ac & = ( ( 32 < < 15 ) - 1 ) ;
if ( ( es1371 - > dac [ 1 ] . ac > > ( 15 + 4 ) ) ! = es1371 - > dac [ 1 ] . f_pos )
2017-11-24 02:23:00 -05:00
{
2018-03-15 23:15:33 +01:00
es1371_next_sample_filtered ( es1371 , 1 , es1371 - > dac [ 1 ] . f_pos ? 16 : 0 ) ;
es1371 - > dac [ 1 ] . f_pos = ( es1371 - > dac [ 1 ] . f_pos + 1 ) & 1 ;
2017-11-24 02:23:00 -05:00
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
es1371 - > dac [ 1 ] . curr_samp_ct - - ;
if ( es1371 - > dac [ 1 ] . curr_samp_ct < 0 )
2017-11-24 02:23:00 -05:00
{
es1371 - > int_status | = INT_STATUS_DAC2 ;
es1371_update_irqs ( es1371 ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
es1371 - > dac [ 1 ] . curr_samp_ct = es1371 - > dac [ 1 ] . samp_ct ;
2017-11-24 02:23:00 -05:00
}
}
}
2017-10-14 07:03:19 +02:00
}
static void es1371_get_buffer ( int32_t * buffer , int len , void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
int c ;
2017-10-14 07:03:19 +02:00
2018-03-15 23:15:33 +01:00
es1371_update ( es1371 ) ;
2017-11-24 02:23:00 -05:00
for ( c = 0 ; c < len * 2 ; c + + )
buffer [ c ] + = ( es1371 - > buffer [ c ] / 2 ) ;
es1371 - > pos = 0 ;
2017-10-14 07:03:19 +02:00
}
2020-10-21 02:46:50 +02:00
static void es1371_filter_cd_audio ( int channel , double * buffer , void * p )
2020-10-19 01:02:40 +02:00
{
es1371_t * es1371 = ( es1371_t * ) p ;
int32_t c ;
2020-10-19 02:21:05 +02:00
int cd = channel ? es1371 - > cd_vol_r : es1371 - > cd_vol_l ;
2020-10-19 01:02:40 +02:00
int master = channel ? es1371 - > master_vol_r : es1371 - > master_vol_l ;
2020-10-19 02:21:05 +02:00
c = ( ( ( int32_t ) * buffer ) * cd ) > > 15 ;
2020-10-19 01:02:40 +02:00
c = ( c * master ) > > 15 ;
2020-10-21 02:46:50 +02:00
* buffer = ( double ) c ;
2020-10-19 01:02:40 +02:00
}
2018-03-15 23:15:33 +01:00
static inline double sinc ( double x )
{
return sin ( M_PI * x ) / ( M_PI * x ) ;
}
static void generate_es1371_filter ( )
{
/*Cutoff frequency = 1 / 32*/
float fC = 1.0 / 32.0 ;
float gain ;
int n ;
for ( n = 0 ; n < ES1371_NCoef ; n + + )
{
/*Blackman window*/
double w = 0.42 - ( 0.5 * cos ( ( 2.0 * n * M_PI ) / ( double ) ( ES1371_NCoef - 1 ) ) ) + ( 0.08 * cos ( ( 4.0 * n * M_PI ) / ( double ) ( ES1371_NCoef - 1 ) ) ) ;
/*Sinc filter*/
double h = sinc ( 2.0 * fC * ( ( double ) n - ( ( double ) ( ES1371_NCoef - 1 ) / 2.0 ) ) ) ;
/*Create windowed-sinc filter*/
low_fir_es1371_coef [ n ] = w * h ;
}
low_fir_es1371_coef [ ( ES1371_NCoef - 1 ) / 2 ] = 1.0 ;
gain = 0.0 ;
for ( n = 0 ; n < ES1371_NCoef ; n + + )
gain + = low_fir_es1371_coef [ n ] / ( float ) N ;
2018-04-25 23:51:13 +02:00
gain / = 0.95 ;
2018-03-15 23:15:33 +01:00
/*Normalise filter, to produce unity gain*/
for ( n = 0 ; n < ES1371_NCoef ; n + + )
low_fir_es1371_coef [ n ] / = gain ;
}
2020-01-19 05:45:05 +01:00
static void * es1371_init ( const device_t * info )
2017-10-14 07:03:19 +02:00
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = malloc ( sizeof ( es1371_t ) ) ;
memset ( es1371 , 0 , sizeof ( es1371_t ) ) ;
sound_add_handler ( es1371_get_buffer , es1371 ) ;
2020-10-19 01:02:40 +02:00
sound_set_cd_audio_filter ( es1371_filter_cd_audio , es1371 ) ;
2017-10-14 07:03:19 +02:00
2021-05-20 22:51:55 -03:00
/* Add our own always-present game port to override the standalone ISAPnP one. */
gameport_remap ( gameport_add ( & gameport_pnp_device ) , 0x200 ) ;
2020-05-19 21:15:25 -03:00
es1371 - > card = pci_add_card ( info - > local ? PCI_ADD_SOUND : PCI_ADD_NORMAL , es1371_pci_read , es1371_pci_write , es1371 ) ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
timer_add ( & es1371 - > dac [ 1 ] . timer , es1371_poll , es1371 , 1 ) ;
2018-03-15 23:15:33 +01:00
generate_es1371_filter ( ) ;
2020-04-29 23:39:54 +02:00
2021-05-20 22:51:55 -03:00
/* Return a CS4297A like VMware does. */
2020-04-29 23:39:54 +02:00
es1371 - > codec_regs [ 0x7c ] = 0x4352 ;
es1371 - > codec_regs [ 0x7e ] = 0x5910 ;
2017-11-24 02:23:00 -05:00
return es1371 ;
2017-10-14 07:03:19 +02:00
}
static void es1371_close ( void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
free ( es1371 ) ;
2017-10-14 07:03:19 +02:00
}
static void es1371_speed_changed ( void * p )
{
2017-11-24 02:23:00 -05:00
es1371_t * es1371 = ( es1371_t * ) p ;
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
es1371 - > dac [ 1 ] . latch = ( uint64_t ) ( ( double ) TIMER_USEC * ( 1000000.0 / 48000.0 ) ) ;
2017-10-14 07:03:19 +02:00
}
2018-03-15 23:15:33 +01:00
void es1371_add_status_info_dac ( es1371_t * es1371 , char * s , int max_len , int dac_nr )
{
int ena = dac_nr ? INT_DAC2_EN : INT_DAC1_EN ;
char * dac_name = dac_nr ? " DAC2 (Wave) " : " DAC1 (MIDI) " ;
char temps [ 128 ] ;
if ( es1371 - > int_ctrl & ena )
{
int format = dac_nr ? ( ( es1371 - > si_cr > > 2 ) & 3 ) : ( es1371 - > si_cr & 3 ) ;
double freq = 48000.0 * ( ( double ) es1371 - > dac [ dac_nr ] . vf / ( 32768.0 * 16.0 ) ) ;
switch ( format )
{
case FORMAT_MONO_8 :
snprintf ( temps , 128 , " %s format : 8-bit mono \n " , dac_name ) ;
break ;
case FORMAT_STEREO_8 :
snprintf ( temps , 128 , " %s format : 8-bit stereo \n " , dac_name ) ;
break ;
case FORMAT_MONO_16 :
snprintf ( temps , 128 , " %s format : 16-bit mono \n " , dac_name ) ;
break ;
case FORMAT_STEREO_16 :
snprintf ( temps , 128 , " %s format : 16-bit stereo \n " , dac_name ) ;
break ;
}
strncat ( s , temps , max_len ) ;
max_len - = strlen ( temps ) ;
snprintf ( temps , 128 , " Playback frequency : %i Hz \n " , ( int ) freq ) ;
strncat ( s , temps , max_len ) ;
}
else
{
snprintf ( temps , max_len , " %s stopped \n " , dac_name ) ;
strncat ( s , temps , max_len ) ;
}
}
2018-03-19 01:02:04 +01:00
const device_t es1371_device =
2017-10-14 07:03:19 +02:00
{
2020-05-19 21:15:25 -03:00
" Ensoniq AudioPCI (ES1371) " ,
DEVICE_PCI ,
0 ,
es1371_init ,
es1371_close ,
NULL ,
2020-11-16 00:01:21 +01:00
{ NULL } ,
2020-05-19 21:15:25 -03:00
es1371_speed_changed ,
NULL ,
NULL
} ;
const device_t es1371_onboard_device =
{
" Ensoniq AudioPCI (ES1371) (On-Board) " ,
DEVICE_PCI ,
1 ,
es1371_init ,
es1371_close ,
NULL ,
2020-11-16 00:01:21 +01:00
{ NULL } ,
2020-05-19 21:15:25 -03:00
es1371_speed_changed ,
NULL ,
NULL
2017-10-14 07:03:19 +02:00
} ;