diff --git a/src/dma.c b/src/dma.c index 3de4c1431..ff454ec5b 100644 --- a/src/dma.c +++ b/src/dma.c @@ -8,7 +8,7 @@ * * Implementation of the Intel DMA controllers. * - * Version: @(#)dma.c 1.0.6 2017/11/04 + * Version: @(#)dma.c 1.0.7 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -755,25 +755,30 @@ int dma_mode(int channel) } /* DMA Bus Master Page Read/Write */ -void DMAPageRead(uint32_t PhysAddress, char *DataRead, uint32_t TotalSize) +void DMAPageRead(uint32_t PhysAddress, uint8_t *DataRead, uint32_t TotalSize) { int i = 0; - // memcpy(DataRead, &ram[PhysAddress], TotalSize); - +#if 0 + memcpy(DataRead, &ram[PhysAddress], TotalSize); +#else for (i = 0; i < TotalSize; i++) DataRead[i] = mem_readb_phys_dma(PhysAddress + i); +#endif } -void DMAPageWrite(uint32_t PhysAddress, const char *DataWrite, uint32_t TotalSize) +void DMAPageWrite(uint32_t PhysAddress, const uint8_t *DataWrite, uint32_t TotalSize) { int i = 0; - // mem_invalidate_range(PhysAddress, PhysAddress + TotalSize - 1); - // memcpy(&ram[PhysAddress], DataWrite, TotalSize); +#if 0 + mem_invalidate_range(PhysAddress, PhysAddress + TotalSize - 1); + memcpy(&ram[PhysAddress], DataWrite, TotalSize); +#else for (i = 0; i < TotalSize; i++) mem_writeb_phys_dma(PhysAddress + i, DataWrite[i]); +#endif mem_invalidate_range(PhysAddress, PhysAddress + TotalSize - 1); } diff --git a/src/dma.h b/src/dma.h index e41e5df16..f13102e83 100644 --- a/src/dma.h +++ b/src/dma.h @@ -8,7 +8,7 @@ * * Implementation of the Intel DMA controllers. * - * Version: @(#)dma.h 1.0.3 2017/11/01 + * Version: @(#)dma.h 1.0.4 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -72,9 +72,9 @@ extern void dma_alias_set(void); extern void dma_alias_remove(void); extern void dma_alias_remove_piix(void); -extern void DMAPageRead(uint32_t PhysAddress, char *DataRead, +extern void DMAPageRead(uint32_t PhysAddress, uint8_t *DataRead, uint32_t TotalSize); -extern void DMAPageWrite(uint32_t PhysAddress, const char *DataWrite, +extern void DMAPageWrite(uint32_t PhysAddress, const uint8_t *DataWrite, uint32_t TotalSize); diff --git a/src/floppy/fdc.c b/src/floppy/fdc.c index f5b6627da..60746c309 100644 --- a/src/floppy/fdc.c +++ b/src/floppy/fdc.c @@ -9,7 +9,7 @@ * Implementation of the NEC uPD-765 and compatible floppy disk * controller. * - * Version: @(#)fdc.c 1.0.11 2017/12/09 + * Version: @(#)fdc.c 1.0.10 2017/12/08 * * Authors: Sarah Walker, * Miran Grca, @@ -22,7 +22,6 @@ #include #include #include -#define HAVE_STDARG_H #include "../86box.h" #include "../cpu/cpu.h" #include "../machine/machine.h" @@ -182,7 +181,7 @@ fdc_log(const char *fmt, ...) if (fdc_do_log) { va_start(ap, fmt); - pclog_ex(fmt, ap); + pclog(fmt, ap); va_end(ap); } #endif @@ -714,7 +713,7 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv) } if ((val&4) && !(fdc.dor&4)) { - timer_clock(); + timer_process(); floppytime = 128LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); floppyint=-1; @@ -727,6 +726,8 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv) fdc_reset(); } + timer_process(); + timer_update_outstanding(); /* We can now simplify this since each motor now spins separately. */ for (i = 0; i < FDD_NUM; i++) { @@ -755,7 +756,7 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv) case 4: if (val & 0x80) { - timer_clock(); + timer_process(); floppytime = 128LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); floppyint=-1; @@ -936,7 +937,7 @@ void fdc_write(uint16_t addr, uint8_t val, void *priv) bad_command: fdc.stat |= 0x10; floppyint=0xfc; - timer_clock(); + timer_process(); floppytime = 200LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); break; @@ -962,7 +963,7 @@ bad_command: { fdc_log("Got all params %02X\n", fdc.command); floppyint=fdc.command&0x1F; - timer_clock(); + timer_process(); floppytime = 1024LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); fdc_reset_stat = 0; @@ -1140,7 +1141,7 @@ bad_command: fdc.pcn[fdc.params[0] & 3] = 0; floppytime = 0LL; floppyint=-3; - timer_clock(); + timer_process(); floppytime = 2048LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); break; @@ -1197,7 +1198,7 @@ bad_command: } floppytime = 0LL; floppyint=-3; - timer_clock(); + timer_process(); floppytime = 2048LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); break; @@ -1228,7 +1229,7 @@ bad_command: fdc.st0 = 0x20 | (fdc.params[0] & 7); floppytime = 0LL; floppyint=-3; - timer_clock(); + timer_process(); floppytime = 2048LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); break; @@ -1244,7 +1245,7 @@ bad_command: fdc.st0 = 0x20 | (fdc.params[0] & 7); floppytime = 0LL; floppyint=-3; - timer_clock(); + timer_process(); floppytime = 2048LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); break; @@ -1402,7 +1403,7 @@ uint8_t fdc_read(uint16_t addr, void *priv) /* What the heck is this even doing?! */ /* if (floppyint==0xA) { - timer_clock(); + timer_process(); floppytime = 1024LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); } */ @@ -1740,7 +1741,7 @@ void fdc_callback(void *priv) fdc.st0 |= 0x50; } floppyint=-3; - timer_clock(); + timer_process(); floppytime = 2048LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); fdc.stat = 0x80 | (1 << fdc.drive); @@ -1786,7 +1787,7 @@ void fdc_callback(void *priv) if (fdc.format_state == 1) { fdc.format_state = 2; - timer_clock(); + timer_process(); floppytime = 128LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); } @@ -1817,7 +1818,7 @@ void fdc_callback(void *priv) drive_num = real_drive(fdc.rw_drive); fdc.st0 = 0x20 | (fdc.params[0] & 7); floppyint=-3; - timer_clock(); + timer_process(); floppytime = 2048LL * (1LL << TIMER_SHIFT); timer_update_outstanding(); fdc.stat = 0x80 | (1 << fdc.drive); diff --git a/src/floppy/floppy.c b/src/floppy/floppy.c index 0d9d55479..e5c4760bc 100644 --- a/src/floppy/floppy.c +++ b/src/floppy/floppy.c @@ -9,7 +9,7 @@ * Generic floppy disk interface that communicates with the * other handlers. * - * Version: @(#)floppy.c 1.0.12 2017/11/04 + * Version: @(#)floppy.c 1.0.13 2017/12/14 * * Authors: Sarah Walker, * Miran Grca, @@ -323,7 +323,6 @@ void floppy_set_rate(int drive, int drvden, int rate) floppy_period = 4; break; } - break; case 2: /*Double density*/ floppy_period = 32; break; diff --git a/src/floppy/floppy_86f.c b/src/floppy/floppy_86f.c index de00a1cb1..9cecc3066 100644 --- a/src/floppy/floppy_86f.c +++ b/src/floppy/floppy_86f.c @@ -10,7 +10,7 @@ * data in the form of FM/MFM-encoded transitions) which also * forms the core of the emulator's floppy disk emulation. * - * Version: @(#)floppy_86f.c 1.0.13 2017/12/09 + * Version: @(#)floppy_86f.c 1.0.12 2017/11/24 * * Author: Miran Grca, * Copyright 2016,2017 Miran Grca. @@ -23,7 +23,6 @@ #include #include #include "../lzf/lzf.h" -#define HAVE_STDARG_H #include "../86box.h" #include "../config.h" #include "../dma.h" @@ -247,15 +246,15 @@ int d86f_do_log = ENABLE_D86F_LOG; static void -d86f_log(const char *fmt, ...) +d86f_log(const char *format, ...) { #ifdef ENABLE_D86F_LOG va_list ap; if (d86f_do_log) { - va_start(ap, fmt); - pclog_ex(fmt, ap); + va_start(ap, format); + pclog(format, ap); va_end(ap); } #endif diff --git a/src/floppy/floppy_fdi.c b/src/floppy/floppy_fdi.c index 58819ec39..22181a210 100644 --- a/src/floppy/floppy_fdi.c +++ b/src/floppy/floppy_fdi.c @@ -9,7 +9,7 @@ * Implementation of the FDI floppy stream image format * interface to the FDI2RAW module. * - * Version: @(#)floppy_fdi.c 1.0.6 2017/12/15 + * Version: @(#)floppy_fdi.c 1.0.6 2017/12/14 * * Authors: Sarah Walker, * Miran Grca, diff --git a/src/floppy/floppy_fdi.h b/src/floppy/floppy_fdi.h index 75b3b4936..f63f241e3 100644 --- a/src/floppy/floppy_fdi.h +++ b/src/floppy/floppy_fdi.h @@ -9,10 +9,11 @@ * Implementation of the FDI floppy stream image format * interface to the FDI2RAW module. * - * Version: @(#)floppy_fdi.h 1.0.3 2017/12/15 + * Version: @(#)floppy_fdi.h 1.0.3 2017/12/14 * * Authors: Sarah Walker, * Miran Grca, + * * Copyright 2008-2017 Sarah Walker. * Copyright 2016,2017 Miran Grca. */ @@ -20,7 +21,6 @@ # define EMU_FLOPPY_FDI_H -extern void fdi_init(void); extern void fdi_load(int drive, wchar_t *fn); extern void fdi_close(int drive); extern void fdi_seek(int drive, int track); diff --git a/src/intel_piix.c b/src/intel_piix.c index 1afb6fd2c..08c71a6a5 100644 --- a/src/intel_piix.c +++ b/src/intel_piix.c @@ -10,7 +10,7 @@ * word 0 - base address * word 1 - bits 1-15 = byte count, bit 31 = end of transfer * - * Version: @(#)intel_piix.c 1.0.9 2017/11/11 + * Version: @(#)intel_piix.c 1.0.10 2017/12/15 * * Authors: Sarah Walker, * Miran Grca, @@ -414,8 +414,8 @@ struct static void piix_bus_master_next_addr(int channel) { - DMAPageRead(piix_busmaster[channel].ptr_cur, (char *) &(piix_busmaster[channel].addr), 4); - DMAPageRead(piix_busmaster[channel].ptr_cur + 4, (char *) &(piix_busmaster[channel].count), 4); + DMAPageRead(piix_busmaster[channel].ptr_cur, (uint8_t *)&(piix_busmaster[channel].addr), 4); + DMAPageRead(piix_busmaster[channel].ptr_cur + 4, (uint8_t *)&(piix_busmaster[channel].count), 4); #if 0 pclog("PIIX Bus master DWORDs: %08X %08X\n", piix_busmaster[channel].addr, piix_busmaster[channel].count); #endif @@ -521,14 +521,14 @@ int piix_bus_master_dma_read(int channel, uint8_t *data, int transfer_length) #if 0 pclog("Writing %i bytes to %08X\n", piix_busmaster[channel].count, piix_busmaster[channel].addr); #endif - DMAPageWrite(piix_busmaster[channel].addr, (char *) (data + buffer_pos), piix_busmaster[channel].count); + DMAPageWrite(piix_busmaster[channel].addr, (uint8_t *)(data + buffer_pos), piix_busmaster[channel].count); transfer_length -= piix_busmaster[channel].count; buffer_pos += piix_busmaster[channel].count; } else { #if 0 pclog("Writing %i bytes to %08X\n", piix_busmaster[channel].count, piix_busmaster[channel].addr); #endif - DMAPageWrite(piix_busmaster[channel].addr, (char *) (data + buffer_pos), transfer_length); + DMAPageWrite(piix_busmaster[channel].addr, (uint8_t *)(data + buffer_pos), transfer_length); transfer_length = 0; force_end = 1; } @@ -584,14 +584,14 @@ int piix_bus_master_dma_write(int channel, uint8_t *data, int transfer_length) #if 0 pclog("Reading %i bytes from %08X\n", piix_busmaster[channel].count, piix_busmaster[channel].addr); #endif - DMAPageRead(piix_busmaster[channel].addr, (char *) (data + buffer_pos), piix_busmaster[channel].count); + DMAPageRead(piix_busmaster[channel].addr, (uint8_t *)(data + buffer_pos), piix_busmaster[channel].count); transfer_length -= piix_busmaster[channel].count; buffer_pos += piix_busmaster[channel].count; } else { #if 0 pclog("Reading %i bytes from %08X\n", piix_busmaster[channel].count, piix_busmaster[channel].addr); #endif - DMAPageRead(piix_busmaster[channel].addr, (char *) (data + buffer_pos), transfer_length); + DMAPageRead(piix_busmaster[channel].addr, (uint8_t *)(data + buffer_pos), transfer_length); transfer_length = 0; force_end = 1; } diff --git a/src/plat.h b/src/plat.h index a17d32cf0..1a608b205 100644 --- a/src/plat.h +++ b/src/plat.h @@ -8,7 +8,7 @@ * * Define the various platform support functions. * - * Version: @(#)plat.h 1.0.22 2017/12/03 + * Version: @(#)plat.h 1.0.23 2017/12/15 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -55,7 +55,6 @@ extern "C" { GLOBAL int dopause, /* system is paused */ doresize, /* screen resize requested */ quited, /* system exit requested */ - leave_fullscreen_flag, /* windowed-mode requested */ mouse_capture; /* mouse is captured in app */ GLOBAL uint64_t timer_freq; GLOBAL int infocus; diff --git a/src/scsi/scsi_buslogic.c b/src/scsi/scsi_buslogic.c index 145f6b7e3..7c0ce4c1d 100644 --- a/src/scsi/scsi_buslogic.c +++ b/src/scsi/scsi_buslogic.c @@ -11,7 +11,7 @@ * 1 - BT-545S ISA; * 2 - BT-958D PCI * - * Version: @(#)scsi_buslogic.c 1.0.31 2017/12/10 + * Version: @(#)scsi_buslogic.c 1.0.32 2017/12/15 * * Authors: TheCollector1995, * Miran Grca, @@ -570,10 +570,10 @@ BuslogicSCSIBIOSDMATransfer(ESCMD *ESCSICmd, uint8_t TargetID, uint8_t LUN, int if (dir && ((ESCSICmd->DataDirection == CCB_DATA_XFER_OUT) || (ESCSICmd->DataDirection == 0x00))) { buslogic_log("BusLogic BIOS DMA: Reading %i bytes from %08X\n", TransferLength, Address); - DMAPageRead(Address, (char *)SCSIDevices[TargetID][LUN].CmdBuffer, TransferLength); + DMAPageRead(Address, (uint8_t *)SCSIDevices[TargetID][LUN].CmdBuffer, TransferLength); } else if (!dir && ((ESCSICmd->DataDirection == CCB_DATA_XFER_IN) || (ESCSICmd->DataDirection == 0x00))) { buslogic_log("BusLogic BIOS DMA: Writing %i bytes at %08X\n", TransferLength, Address); - DMAPageWrite(Address, (char *)SCSIDevices[TargetID][LUN].CmdBuffer, TransferLength); + DMAPageWrite(Address, (uint8_t *)SCSIDevices[TargetID][LUN].CmdBuffer, TransferLength); } } } diff --git a/src/scsi/scsi_ncr53c810.c b/src/scsi/scsi_ncr53c810.c index 199b54db2..e75e469f1 100644 --- a/src/scsi/scsi_ncr53c810.c +++ b/src/scsi/scsi_ncr53c810.c @@ -10,12 +10,12 @@ * NCR and later Symbios and LSI. This controller was designed * for the PCI bus. * - * Version: @(#)scsi_ncr53c810.c 1.0.0 2017/12/10 + * Version: @(#)scsi_ncr53c810.c 1.0.1 2017/12/15 * - * Authors: TheCollector1995, + * Authors: Paul Brook (QEMU) + * Artyom Tarasenko (QEMU) + * TheCollector1995, * Miran Grca, - * Paul Brook (QEMU), - * Artyom Tarasenko (QEMU), * * Copyright 2006-2017 Paul Brook. * Copyright 2009-2017 Artyom Tarasenko. @@ -398,7 +398,7 @@ static void lsi_soft_reset(LSIState *s) } -static void lsi_read(LSIState *s, uint32_t addr, char *buf, uint32_t len) +static void lsi_read(LSIState *s, uint32_t addr, uint8_t *buf, uint32_t len) { int i = 0; @@ -414,7 +414,7 @@ static void lsi_read(LSIState *s, uint32_t addr, char *buf, uint32_t len) } } -static void lsi_write(LSIState *s, uint32_t addr, char *buf, uint32_t len) +static void lsi_write(LSIState *s, uint32_t addr, uint8_t *buf, uint32_t len) { int i = 0; @@ -434,7 +434,7 @@ static inline uint32_t read_dword(LSIState *s, uint32_t addr) { uint32_t buf; ncr53c810_log("Reading the next DWORD from memory (%08X)...\n", addr); - DMAPageRead(addr, (char *)&buf, 4); + DMAPageRead(addr, (uint8_t *)&buf, 4); return cpu_to_le32(buf); } @@ -601,13 +601,13 @@ static void lsi_do_dma(LSIState *s, int out, uint8_t id) s->dbc -= count; if (out) { - lsi_read(s, addr, ((char *)dev->CmdBuffer) + s->buffer_pos, count); + lsi_read(s, addr, dev->CmdBuffer+s->buffer_pos, count); } else { if (!s->buffer_pos) { DPRINTF("(ID=%02i LUN=%02i) SCSI Command 0x%02x: SCSI Command Phase 1 on PHASE_DI\n", id, s->current_lun, s->last_command); scsi_device_command_phase1(s->current->tag, s->current_lun); } - lsi_write(s, addr, ((char *)dev->CmdBuffer) + s->buffer_pos, count); + lsi_write(s, addr, dev->CmdBuffer+s->buffer_pos, count); } s->temp_buf_len -= count; @@ -735,7 +735,7 @@ static void lsi_do_command(LSIState *s, uint8_t id) uint8_t buf[12]; memset(buf, 0, 12); - DMAPageRead(s->dnad, (char *)buf, MIN(12, s->dbc)); + DMAPageRead(s->dnad, buf, MIN(12, s->dbc)); if (s->dbc > 12) { DPRINTF("(ID=%02i LUN=%02i) SCSI Command 0x%02x: CDB length %i too big\n", id, s->current_lun, buf[0], s->dbc); s->dbc = 12; @@ -791,7 +791,7 @@ static void lsi_do_status(LSIState *s) s->dbc = 1; status = s->status; s->sfbr = status; - lsi_write(s, s->dnad, (char *)&status, 1); + lsi_write(s, s->dnad, &status, 1); lsi_set_phase(s, PHASE_MI); s->msg_action = 1; lsi_add_msg_byte(s, 0); /* COMMAND COMPLETE */ @@ -805,7 +805,7 @@ static void lsi_do_msgin(LSIState *s) len = s->msg_len; if (len > s->dbc) len = s->dbc; - lsi_write(s, s->dnad, (char *)s->msg, len); + lsi_write(s, s->dnad, s->msg, len); /* Linux drivers rely on the last byte being in the SIDL. */ s->sidl = s->msg[len - 1]; s->msg_len -= len; @@ -838,7 +838,7 @@ static void lsi_do_msgin(LSIState *s) static uint8_t lsi_get_msgbyte(LSIState *s) { uint8_t data; - DMAPageRead(s->dnad, (char *)&data, 1); + DMAPageRead(s->dnad, &data, 1); s->dnad++; s->dbc--; return data; @@ -979,8 +979,8 @@ static void lsi_memcpy(LSIState *s, uint32_t dest, uint32_t src, int count) DPRINTF("memcpy dest 0x%08x src 0x%08x count %d\n", dest, src, count); while (count) { n = (count > LSI_BUF_SIZE) ? LSI_BUF_SIZE : count; - lsi_read(s, src, (char *)buf, n); - lsi_write(s, dest, (char *)buf, n); + lsi_read(s, src, buf, n); + lsi_write(s, dest, buf, n); src += n; dest += n; count -= n; @@ -1053,7 +1053,7 @@ again: /* 32-bit Table indirect */ offset = sextract32(addr, 0, 24); - DMAPageRead(s->dsa + offset, (char *)buf, 8); + DMAPageRead(s->dsa + offset, (uint8_t *)buf, 8); /* byte count is stored in bits 0:23 only */ s->dbc = cpu_to_le32(buf[0]) & 0xffffff; addr = cpu_to_le32(buf[1]); @@ -1363,6 +1363,7 @@ again: lsi_memcpy(s, dest, addr, insn & 0xffffff); } else { uint8_t data[7]; + uint8_t *pp = data; int reg; int n; int i; @@ -1373,9 +1374,9 @@ again: n = (insn & 7); reg = (insn >> 16) & 0xff; if (insn & (1 << 24)) { - DMAPageRead(addr, (char *) data, n); - DPRINTF("Load reg 0x%x size %d addr 0x%08x = %08x\n", reg, n, - addr, *(int *)data); + DMAPageRead(addr, data, n); + DPRINTF("Load reg 0x%x size %d addr 0x%08x = %08x\n", + reg, n, addr, *(unsigned *)pp); for (i = 0; i < n; i++) { lsi_reg_writeb(s, reg + i, data[i]); } @@ -1384,7 +1385,7 @@ again: for (i = 0; i < n; i++) { data[i] = lsi_reg_readb(s, reg + i); } - DMAPageWrite(addr, (char *) data, n); + DMAPageWrite(addr, data, n); } } break; diff --git a/src/scsi/scsi_x54x.c b/src/scsi/scsi_x54x.c index 105fa7cbb..d4ea6986e 100644 --- a/src/scsi/scsi_x54x.c +++ b/src/scsi/scsi_x54x.c @@ -11,7 +11,7 @@ * series of SCSI Host Adapters made by Mylex. * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.c 1.0.7 2017/12/09 + * Version: @(#)scsi_x54x.c 1.0.8 2017/12/15 * * Authors: TheCollector1995, * Miran Grca, @@ -371,7 +371,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) x54x_log("BIOS DMA: Reading 14 bytes at %08X\n", dma_address); DMAPageWrite(dma_address, - (char *)scsi_device_sense(cmd->id, cmd->lun), 14); + scsi_device_sense(cmd->id, cmd->lun), 14); } if (dev->CmdBuffer != NULL) { @@ -410,7 +410,7 @@ x54x_bios_command(x54x_t *x54x, uint8_t max_id, BIOSCMD *cmd, int8_t islba) x54x_log("BIOS DMA: Reading %i bytes at %08X\n", dev->BufferLength, dma_address); DMAPageWrite(dma_address, - (char *)dev->CmdBuffer, dev->BufferLength); + dev->CmdBuffer, dev->BufferLength); } skip_read_phase1: @@ -449,7 +449,7 @@ skip_read_phase1: x54x_log("BIOS DMA: Reading %i bytes at %08X\n", dev->BufferLength, dma_address); DMAPageRead(dma_address, - (char *)dev->CmdBuffer, dev->BufferLength); + dev->CmdBuffer, dev->BufferLength); } scsi_device_command_phase1(cmd->id, cmd->lun); @@ -507,7 +507,7 @@ skip_write_phase1: x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address); DMAPageWrite(dma_address, - (char *)dev->CmdBuffer, dev->BufferLength); + dev->CmdBuffer, dev->BufferLength); if (dev->CmdBuffer != NULL) { free(dev->CmdBuffer); @@ -573,7 +573,7 @@ skip_write_phase1: x54x_log("BIOS DMA: Reading 6 bytes at %08X\n", dma_address); DMAPageWrite(dma_address, - (char *)dev->CmdBuffer, dev->BufferLength); + dev->CmdBuffer, dev->BufferLength); if (dev->CmdBuffer != NULL) { free(dev->CmdBuffer); @@ -638,9 +638,9 @@ x54x_ccb(x54x_t *dev) /* Rewrite the CCB up to the CDB. */ x54x_log("CCB completion code and statuses rewritten (pointer %08X)\n", req->CCBPointer); - DMAPageWrite(req->CCBPointer + 0x000D, (char *)&(req->MailboxCompletionCode), 1); - DMAPageWrite(req->CCBPointer + 0x000E, (char *)&(req->HostStatus), 1); - DMAPageWrite(req->CCBPointer + 0x000F, (char *)&(req->TargetStatus), 1); + DMAPageWrite(req->CCBPointer + 0x000D, &(req->MailboxCompletionCode), 1); + DMAPageWrite(req->CCBPointer + 0x000E, &(req->HostStatus), 1); + DMAPageWrite(req->CCBPointer + 0x000F, &(req->TargetStatus), 1); if (dev->MailboxOutInterrupts) dev->ToRaise = INTR_MBOA | INTR_ANY; @@ -669,8 +669,8 @@ x54x_mbi(x54x_t *dev) /* Rewrite the CCB up to the CDB. */ x54x_log("CCB statuses rewritten (pointer %08X)\n", req->CCBPointer); - DMAPageWrite(req->CCBPointer + 0x000E, (char *)&(req->HostStatus), 1); - DMAPageWrite(req->CCBPointer + 0x000F, (char *)&(req->TargetStatus), 1); + DMAPageWrite(req->CCBPointer + 0x000E, &(req->HostStatus), 1); + DMAPageWrite(req->CCBPointer + 0x000F, &(req->TargetStatus), 1); } else { x54x_log("Mailbox not found!\n"); } @@ -680,15 +680,15 @@ x54x_mbi(x54x_t *dev) if (dev->Mbx24bit) { U32_TO_ADDR(CCBPointer, req->CCBPointer); x54x_log("Mailbox 24-bit: Status=0x%02X, CCB at 0x%04X\n", req->MailboxCompletionCode, CCBPointer); - DMAPageWrite(Incoming, (char *)&(req->MailboxCompletionCode), 1); - DMAPageWrite(Incoming + 1, (char *)&CCBPointer, 3); + DMAPageWrite(Incoming, &(req->MailboxCompletionCode), 1); + DMAPageWrite(Incoming + 1, (uint8_t *)&CCBPointer, 3); x54x_log("%i bytes of 24-bit mailbox written to: %08X\n", sizeof(Mailbox_t), Incoming); } else { x54x_log("Mailbox 32-bit: Status=0x%02X, CCB at 0x%04X\n", req->MailboxCompletionCode, CCBPointer); - DMAPageWrite(Incoming, (char *)&(req->CCBPointer), 4); - DMAPageWrite(Incoming + 4, (char *)&(req->HostStatus), 1); - DMAPageWrite(Incoming + 5, (char *)&(req->TargetStatus), 1); - DMAPageWrite(Incoming + 7, (char *)&(req->MailboxCompletionCode), 1); + DMAPageWrite(Incoming, (uint8_t *)&(req->CCBPointer), 4); + DMAPageWrite(Incoming + 4, &(req->HostStatus), 1); + DMAPageWrite(Incoming + 5, &(req->TargetStatus), 1); + DMAPageWrite(Incoming + 7, &(req->MailboxCompletionCode), 1); x54x_log("%i bytes of 32-bit mailbox written to: %08X\n", sizeof(Mailbox32_t), Incoming); } @@ -708,14 +708,14 @@ x54x_rd_sge(int Is24bit, uint32_t Address, SGE32 *SG) SGE SGE24; if (Is24bit) { - DMAPageRead(Address, (char *)&SGE24, sizeof(SGE)); + DMAPageRead(Address, (uint8_t *)&SGE24, sizeof(SGE)); /* Convert the 24-bit entries into 32-bit entries. */ x54x_log("Read S/G block: %06X, %06X\n", SGE24.Segment, SGE24.SegmentPointer); SG->Segment = ADDR_TO_U32(SGE24.Segment); SG->SegmentPointer = ADDR_TO_U32(SGE24.SegmentPointer); } else { - DMAPageRead(Address, (char *)SG, sizeof(SGE32)); + DMAPageRead(Address, (uint8_t *)SG, sizeof(SGE32)); } } @@ -782,10 +782,10 @@ x54x_set_residue(Req_t *req, int32_t TransferLength) if (req->Is24bit) { U32_TO_ADDR(Residue24, Residue); - DMAPageWrite(req->CCBPointer + 0x0004, (char *)&Residue24, 3); + DMAPageWrite(req->CCBPointer + 0x0004, (uint8_t *)&Residue24, 3); x54x_log("24-bit Residual data length for reading: %d\n", Residue); } else { - DMAPageWrite(req->CCBPointer + 0x0004, (char *)&Residue, 4); + DMAPageWrite(req->CCBPointer + 0x0004, (uint8_t *)&Residue, 4); x54x_log("32-bit Residual data length for reading: %d\n", Residue); } } @@ -831,11 +831,11 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir) if (read_from_host && DataToTransfer) { x54x_log("Reading S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); - DMAPageRead(Address, (char *)&(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer); + DMAPageRead(Address, &(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer); } else if (write_to_host && DataToTransfer) { x54x_log("Writing S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); - DMAPageWrite(Address, (char *)&(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer); + DMAPageWrite(Address, &(SCSIDevices[req->TargetID][req->LUN].CmdBuffer[sg_pos]), DataToTransfer); } else { x54x_log("No action on S/G segment %i: length %i, pointer %08X\n", i, DataToTransfer, Address); @@ -856,9 +856,9 @@ x54x_buf_dma_transfer(Req_t *req, int Is24bit, int TransferLength, int dir) if ((DataLength > 0) && (BufLen > 0) && (req->CmdBlock.common.ControlByte < 0x03)) { if (read_from_host) { - DMAPageRead(Address, (char *)SCSIDevices[req->TargetID][req->LUN].CmdBuffer, MIN(BufLen, DataLength)); + DMAPageRead(Address, SCSIDevices[req->TargetID][req->LUN].CmdBuffer, MIN(BufLen, DataLength)); } else if (write_to_host) { - DMAPageWrite(Address, (char *)SCSIDevices[req->TargetID][req->LUN].CmdBuffer, MIN(BufLen, DataLength)); + DMAPageWrite(Address, SCSIDevices[req->TargetID][req->LUN].CmdBuffer, MIN(BufLen, DataLength)); } } } @@ -942,7 +942,7 @@ SenseBufferFree(Req_t *req, int Copy) x54x_log("SenseBufferFree(): Writing %i bytes at %08X\n", SenseLength, SenseBufferAddress); - DMAPageWrite(SenseBufferAddress, (char *)temp_sense, SenseLength); + DMAPageWrite(SenseBufferAddress, temp_sense, SenseLength); x54x_log("Sense data written to buffer: %02X %02X %02X\n", temp_sense[2], temp_sense[12], temp_sense[13]); } @@ -1009,7 +1009,7 @@ x54x_scsi_cmd(x54x_t *dev) scsi_device_command_phase1(id, lun); if ((SCSIStatus != SCSI_STATUS_OK) && (*BufLen > 0)) { SenseBufferAddress = SenseBufferPointer(req); - DMAPageWrite(SenseBufferAddress, (char *)SCSIDevices[id][lun].CmdBuffer, *BufLen); + DMAPageWrite(SenseBufferAddress, SCSIDevices[id][lun].CmdBuffer, *BufLen); } } else { x54x_buf_alloc(id, lun, MIN(target_data_len, *BufLen)); @@ -1064,7 +1064,7 @@ x54x_req_setup(x54x_t *dev, uint32_t CCBPointer, Mailbox32_t *Mailbox32) uint8_t max_id = SCSI_ID_MAX-1; /* Fetch data from the Command Control Block. */ - DMAPageRead(CCBPointer, (char *)&req->CmdBlock, sizeof(CCB32)); + DMAPageRead(CCBPointer, (uint8_t *)&req->CmdBlock, sizeof(CCB32)); req->Is24bit = dev->Mbx24bit; req->CCBPointer = CCBPointer; @@ -1139,7 +1139,7 @@ x54x_req_abort(x54x_t *dev, uint32_t CCBPointer) CCBU CmdBlock; /* Fetch data from the Command Control Block. */ - DMAPageRead(CCBPointer, (char *)&CmdBlock, sizeof(CCB32)); + DMAPageRead(CCBPointer, (uint8_t *)&CmdBlock, sizeof(CCB32)); x54x_mbi_setup(dev, CCBPointer, &CmdBlock, 0x26, SCSI_STATUS_OK, MBI_NOT_FOUND); @@ -1167,7 +1167,7 @@ x54x_mbo(x54x_t *dev, Mailbox32_t *Mailbox32) if (dev->Mbx24bit) { Outgoing = Addr + (Cur * sizeof(Mailbox_t)); - DMAPageRead(Outgoing, (char *)&MailboxOut, sizeof(Mailbox_t)); + DMAPageRead(Outgoing, (uint8_t *)&MailboxOut, sizeof(Mailbox_t)); ccbp = *(uint32_t *) &MailboxOut; Mailbox32->CCBPointer = (ccbp >> 24) | ((ccbp >> 8) & 0xff00) | ((ccbp << 8) & 0xff0000); @@ -1175,7 +1175,7 @@ x54x_mbo(x54x_t *dev, Mailbox32_t *Mailbox32) } else { Outgoing = Addr + (Cur * sizeof(Mailbox32_t)); - DMAPageRead(Outgoing, (char *)Mailbox32, sizeof(Mailbox32_t)); + DMAPageRead(Outgoing, (uint8_t *)Mailbox32, sizeof(Mailbox32_t)); } return(Outgoing); @@ -1207,7 +1207,7 @@ x54x_mbo_process(x54x_t *dev) if ((mb32.u.out.ActionCode == MBO_START) || (!dev->MailboxIsBIOS && (mb32.u.out.ActionCode == MBO_ABORT))) { /* We got the mailbox, mark it as free in the guest. */ x54x_log("x54x_do_mail(): Writing %i bytes at %08X\n", sizeof(CmdStatus), Outgoing + CodeOffset); - DMAPageWrite(Outgoing + CodeOffset, (char *)&CmdStatus, 1); + DMAPageWrite(Outgoing + CodeOffset, &CmdStatus, 1); if (dev->ToRaise) { raise_irq(dev, 0, dev->ToRaise); @@ -1746,7 +1746,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) Address.lo = dev->CmdBuf[2]; FIFOBuf = ADDR_TO_U32(Address); x54x_log("Adaptec LocalRAM: Reading 64 bytes at %08X\n", FIFOBuf); - DMAPageRead(FIFOBuf, (char *)dev->dma_buffer, 64); + DMAPageRead(FIFOBuf, dev->dma_buffer, 64); break; case CMD_READ_CH2: /* write channel 2 buffer */ @@ -1756,7 +1756,7 @@ x54x_out(uint16_t port, uint8_t val, void *priv) Address.lo = dev->CmdBuf[2]; FIFOBuf = ADDR_TO_U32(Address); x54x_log("Adaptec LocalRAM: Writing 64 bytes at %08X\n", FIFOBuf); - DMAPageWrite(FIFOBuf, (char *)dev->dma_buffer, 64); + DMAPageWrite(FIFOBuf, dev->dma_buffer, 64); break; case CMD_OPTIONS: /* Set adapter options */ diff --git a/src/scsi/scsi_x54x.h b/src/scsi/scsi_x54x.h index 33c926082..b4380fc89 100644 --- a/src/scsi/scsi_x54x.h +++ b/src/scsi/scsi_x54x.h @@ -11,7 +11,7 @@ * of SCSI Host Adapters made by Mylex. * These controllers were designed for various buses. * - * Version: @(#)scsi_x54x.h 1.0.3 2017/10/27 + * Version: @(#)scsi_x54x.h 1.0.4 2017/12/15 * * Authors: TheCollector1995, * Miran Grca, @@ -332,9 +332,7 @@ typedef struct { char vendor[16]; /* name of device vendor */ char name[16]; /* name of device */ - volatile int8_t Irq; - volatile uint8_t IrqEnabled; int8_t DmaChannel; @@ -373,8 +371,8 @@ typedef struct { uint16_t DataReply; uint16_t DataReplyLeft; - volatile - uint32_t MailboxInit, + volatile uint32_t + MailboxInit, MailboxCount, MailboxOutAddr, MailboxOutPosCur, @@ -382,19 +380,18 @@ typedef struct { MailboxInPosCur, MailboxReq; - volatile - int Mbx24bit, + volatile int + Mbx24bit, MailboxOutInterrupts; - volatile - int PendingInterrupt, + volatile int + PendingInterrupt, Lock; - volatile uint8_t shadow_ram[128]; - volatile - uint8_t MailboxIsBIOS, + volatile uint8_t + MailboxIsBIOS, ToRaise; uint8_t shram_mode; @@ -402,7 +399,6 @@ typedef struct { uint8_t sync; uint8_t parity; - volatile uint8_t dma_buffer[128]; volatile @@ -413,7 +409,6 @@ typedef struct { BIOSMailboxReq, Residue; - volatile uint8_t BusOnTime, BusOffTime, ATBusSpeed; @@ -491,7 +486,6 @@ typedef struct (p->u.lba.lba2<<8) | p->u.lba.lba3) - extern void x54x_reset_ctrl(x54x_t *dev, uint8_t Reset); extern void x54x_busy(uint8_t set); extern void x54x_thread_start(x54x_t *dev); @@ -512,5 +506,4 @@ extern void x54x_close(void *priv); extern void x54x_device_reset(void *priv); - #endif diff --git a/src/sound/openal.c b/src/sound/openal.c index e0201f0dd..f579b5f4e 100644 --- a/src/sound/openal.c +++ b/src/sound/openal.c @@ -1,3 +1,21 @@ +/* + * 86Box A hypervisor and IBM PC system emulator that specializes in + * running old operating systems and software designed for IBM + * PC systems and compatibles from 1981 through fairly recent + * system designs based on the PCI bus. + * + * This file is part of the 86Box distribution. + * + * Interface to the OpenAL sound processing library. + * + * Version: @(#)openal.c 1.0.2 2017/12/15 + * + * Authors: Sarah Walker, + * Miran Grca, + * + * Copyright 2008-2017 Sarah Walker. + * Copyright 2016,2017 Miran Grca. + */ #include #include #include @@ -28,16 +46,20 @@ ALuint buffers_midi[4]; /* front and back buffers */ static ALuint source[3]; /* audio source */ #endif + static int midi_freq = 44100; static int midi_buf_size = 4410; static int initialized = 0; -void al_set_midi(int freq, int buf_size) + +void +al_set_midi(int freq, int buf_size) { - midi_freq = freq; - midi_buf_size = buf_size; + midi_freq = freq; + midi_buf_size = buf_size; } + #ifdef USE_OPENAL void closeal(void); ALvoid alutInit(ALint *argc,ALbyte **argv) @@ -58,7 +80,8 @@ ALvoid alutInit(ALint *argc,ALbyte **argv) } -ALvoid alutExit(ALvoid) +ALvoid +alutExit(ALvoid) { ALCcontext *Context; ALCdevice *Device; @@ -83,7 +106,8 @@ ALvoid alutExit(ALvoid) #endif -void closeal(void) +void +closeal(void) { #ifdef USE_OPENAL alutExit(); @@ -91,164 +115,160 @@ void closeal(void) } -void initalmain(int argc, char *argv[]) +void +initalmain(int argc, char *argv[]) { - if (!initialized) return; + if (! initialized) return; + #ifdef USE_OPENAL alutInit(0,0); atexit(closeal); #endif - initialized = 0; + initialized = 0; } -void inital(void) +void +inital(void) { - if (initialized) return; + if (initialized) return; #ifdef USE_OPENAL - int c; + float *buf = NULL, *cd_buf = NULL, *midi_buf = NULL; + int16_t *buf_int16 = NULL, *cd_buf_int16 = NULL, *midi_buf_int16 = NULL; + int c; - float *buf = NULL, *cd_buf = NULL, *midi_buf = NULL; - int16_t *buf_int16 = NULL, *cd_buf_int16 = NULL, *midi_buf_int16 = NULL; + if (sound_is_float) { + buf = (float *) malloc((BUFLEN << 1) * sizeof(float)); + cd_buf = (float *) malloc((CD_BUFLEN << 1) * sizeof(float)); + midi_buf = (float *) malloc(midi_buf_size * sizeof(float)); + } else { + buf_int16 = (int16_t *) malloc((BUFLEN << 1) * sizeof(int16_t)); + cd_buf_int16 = (int16_t *) malloc((CD_BUFLEN << 1) * sizeof(int16_t)); + midi_buf_int16 = (int16_t *) malloc(midi_buf_size * sizeof(int16_t)); + } - if (sound_is_float) - { - buf = (float *) malloc((BUFLEN << 1) * sizeof(float)); - cd_buf = (float *) malloc((CD_BUFLEN << 1) * sizeof(float)); - midi_buf = (float *) malloc(midi_buf_size * sizeof(float)); - } - else - { - buf_int16 = (int16_t *) malloc((BUFLEN << 1) * sizeof(int16_t)); - cd_buf_int16 = (int16_t *) malloc((CD_BUFLEN << 1) * sizeof(int16_t)); - midi_buf_int16 = (int16_t *) malloc(midi_buf_size * sizeof(int16_t)); + alGenBuffers(4, buffers); + alGenBuffers(4, buffers_cd); + alGenBuffers(4, buffers_midi); + + alGenSources(3, source); + + alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0); + alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0); + alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0); + alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 ); + alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE ); + alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0); + alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0); + alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0); + alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 ); + alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE ); + alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0); + alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0); + alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0); + alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 ); + alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE ); + + if (sound_is_float) { + memset(buf,0,BUFLEN*2*sizeof(float)); + memset(cd_buf,0,BUFLEN*2*sizeof(float)); + memset(midi_buf,0,midi_buf_size*sizeof(float)); + } else { + memset(buf_int16,0,BUFLEN*2*sizeof(int16_t)); + memset(cd_buf_int16,0,BUFLEN*2*sizeof(int16_t)); + memset(midi_buf_int16,0,midi_buf_size*sizeof(int16_t)); + } + + for (c=0; c<4; c++) { + if (sound_is_float) { + alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); + alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); + alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq); + } else { + alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ); + alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ); + alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq); } + } - alGenBuffers(4, buffers); - alGenBuffers(4, buffers_cd); - alGenBuffers(4, buffers_midi); - - alGenSources(3, source); + alSourceQueueBuffers(source[0], 4, buffers); + alSourceQueueBuffers(source[1], 4, buffers_cd); + alSourceQueueBuffers(source[2], 4, buffers_midi); + alSourcePlay(source[0]); + alSourcePlay(source[1]); + alSourcePlay(source[2]); - alSource3f(source[0], AL_POSITION, 0.0, 0.0, 0.0); - alSource3f(source[0], AL_VELOCITY, 0.0, 0.0, 0.0); - alSource3f(source[0], AL_DIRECTION, 0.0, 0.0, 0.0); - alSourcef (source[0], AL_ROLLOFF_FACTOR, 0.0 ); - alSourcei (source[0], AL_SOURCE_RELATIVE, AL_TRUE ); - alSource3f(source[1], AL_POSITION, 0.0, 0.0, 0.0); - alSource3f(source[1], AL_VELOCITY, 0.0, 0.0, 0.0); - alSource3f(source[1], AL_DIRECTION, 0.0, 0.0, 0.0); - alSourcef (source[1], AL_ROLLOFF_FACTOR, 0.0 ); - alSourcei (source[1], AL_SOURCE_RELATIVE, AL_TRUE ); - alSource3f(source[2], AL_POSITION, 0.0, 0.0, 0.0); - alSource3f(source[2], AL_VELOCITY, 0.0, 0.0, 0.0); - alSource3f(source[2], AL_DIRECTION, 0.0, 0.0, 0.0); - alSourcef (source[2], AL_ROLLOFF_FACTOR, 0.0 ); - alSourcei (source[2], AL_SOURCE_RELATIVE, AL_TRUE ); + if (sound_is_float) { + free(midi_buf); + free(cd_buf); + free(buf); + } else { + free(midi_buf_int16); + free(cd_buf_int16); + free(buf_int16); + } - if (sound_is_float) - { - memset(buf,0,BUFLEN*2*sizeof(float)); - memset(cd_buf,0,BUFLEN*2*sizeof(float)); - memset(midi_buf,0,midi_buf_size*sizeof(float)); - } - else - { - memset(buf_int16,0,BUFLEN*2*sizeof(int16_t)); - memset(cd_buf_int16,0,BUFLEN*2*sizeof(int16_t)); - memset(midi_buf_int16,0,midi_buf_size*sizeof(int16_t)); - } - - for (c = 0; c < 4; c++) - { - if (sound_is_float) - { - alBufferData(buffers[c], AL_FORMAT_STEREO_FLOAT32, buf, BUFLEN*2*sizeof(float), FREQ); - alBufferData(buffers_cd[c], AL_FORMAT_STEREO_FLOAT32, cd_buf, CD_BUFLEN*2*sizeof(float), CD_FREQ); - alBufferData(buffers_midi[c], AL_FORMAT_STEREO_FLOAT32, midi_buf, midi_buf_size*sizeof(float), midi_freq); - } - else - { - alBufferData(buffers[c], AL_FORMAT_STEREO16, buf_int16, BUFLEN*2*sizeof(int16_t), FREQ); - alBufferData(buffers_cd[c], AL_FORMAT_STEREO16, cd_buf_int16, CD_BUFLEN*2*sizeof(int16_t), CD_FREQ); - alBufferData(buffers_midi[c], AL_FORMAT_STEREO16, midi_buf_int16, midi_buf_size*sizeof(int16_t), midi_freq); - } - } - - alSourceQueueBuffers(source[0], 4, buffers); - alSourceQueueBuffers(source[1], 4, buffers_cd); - alSourceQueueBuffers(source[2], 4, buffers_midi); - alSourcePlay(source[0]); - alSourcePlay(source[1]); - alSourcePlay(source[2]); - - if (sound_is_float) - { - free(midi_buf); - free(cd_buf); - free(buf); - } - else - { - free(midi_buf_int16); - free(cd_buf_int16); - free(buf_int16); - } - - initialized = 1; + initialized = 1; #endif } -void givealbuffer_common(void *buf, uint8_t src, int size, int freq) + +void +givealbuffer_common(void *buf, uint8_t src, int size, int freq) { #ifdef USE_OPENAL int processed; int state; ALuint buffer; +#if 0 double gain; +#endif - alGetSourcei(source[src], AL_SOURCE_STATE, &state); + alGetSourcei(source[src], AL_SOURCE_STATE, &state); - if (state==0x1014) - { - alSourcePlay(source[src]); - } - alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed); + if (state == 0x1014) { + alSourcePlay(source[src]); + } - if (processed>=1) - { - gain = pow(10.0, (double)sound_gain[src] / 20.0); - - // alSourcef(source[src], AL_GAIN, gain); + alGetSourcei(source[src], AL_BUFFERS_PROCESSED, &processed); + if (processed >= 1) { +#if 0 + gain = pow(10.0, (double)sound_gain[src] / 20.0); - alSourceUnqueueBuffers(source[src], 1, &buffer); + alSourcef(source[src], AL_GAIN, gain); +#endif - if (sound_is_float) - { - alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, size * sizeof(float), freq); - } - else - { - alBufferData(buffer, AL_FORMAT_STEREO16, buf, size * sizeof(int16_t), freq); - } + alSourceUnqueueBuffers(source[src], 1, &buffer); - alSourceQueueBuffers(source[src], 1, &buffer); - } + if (sound_is_float) { + alBufferData(buffer, AL_FORMAT_STEREO_FLOAT32, buf, size * sizeof(float), freq); + } else { + alBufferData(buffer, AL_FORMAT_STEREO16, buf, size * sizeof(int16_t), freq); + } + + alSourceQueueBuffers(source[src], 1, &buffer); + } #endif } -void givealbuffer(void *buf) + +void +givealbuffer(void *buf) { - givealbuffer_common(buf, 0, BUFLEN << 1, FREQ); + givealbuffer_common(buf, 0, BUFLEN << 1, FREQ); } -void givealbuffer_cd(void *buf) + +void +givealbuffer_cd(void *buf) { - givealbuffer_common(buf, 1, CD_BUFLEN << 1, CD_FREQ); + givealbuffer_common(buf, 1, CD_BUFLEN << 1, CD_FREQ); } -void givealbuffer_midi(void *buf, uint32_t size) + +void +givealbuffer_midi(void *buf, uint32_t size) { - givealbuffer_common(buf, 2, size, midi_freq); + givealbuffer_common(buf, 2, size, midi_freq); }