1 // license:GPL-2.0+ 2 // copyright-holders:Jarek Burczynski,Tatsuyuki Satoh 3 #ifndef MAME_SOUND_FMOPL_H 4 #define MAME_SOUND_FMOPL_H 5 6 #pragma once 7 8 #include <stdint.h> 9 10 11 /* --- select emulation chips --- */ 12 #define BUILD_YM3812 (1) 13 #define BUILD_YM3526 (1) 14 #define BUILD_Y8950 (1) 15 16 /* select output bits size of output : 8 or 16 */ 17 #define OPL_SAMPLE_BITS 16 18 19 typedef s32 OPLSAMPLE; 20 /* 21 #if (OPL_SAMPLE_BITS==16) 22 typedef int16_t OPLSAMPLE; 23 #endif 24 #if (OPL_SAMPLE_BITS==8) 25 typedef int8_t OPLSAMPLE; 26 #endif 27 */ 28 29 typedef uint8_t (*FM_READBYTE)(device_t *device, offs_t offset); 30 typedef void(*FM_WRITEBYTE)(device_t *device, offs_t offset, uint8_t data); 31 typedef void (*OPL_TIMERHANDLER)(device_t *device,int timer,const attotime &period); 32 typedef void (*OPL_IRQHANDLER)(device_t *device,int irq); 33 typedef void (*OPL_UPDATEHANDLER)(device_t *device,int min_interval_us); 34 typedef void (*OPL_PORTHANDLER_W)(device_t *device,unsigned char data); 35 typedef unsigned char (*OPL_PORTHANDLER_R)(device_t *device); 36 37 38 #if BUILD_YM3812 39 40 void *ym3812_init(device_t *device, uint32_t clock, uint32_t rate); 41 void ym3812_clock_changed(void *chip, uint32_t clock, uint32_t rate); 42 void ym3812_shutdown(void *chip); 43 void ym3812_reset_chip(void *chip); 44 int ym3812_write(void *chip, int a, int v); 45 unsigned char ym3812_read(void *chip, int a); 46 int ym3812_timer_over(void *chip, int c); 47 void ym3812_update_one(void *chip, write_stream_view &buffer); 48 49 void ym3812_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device); 50 void ym3812_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device); 51 void ym3812_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device); 52 53 #endif /* BUILD_YM3812 */ 54 55 56 #if BUILD_YM3526 57 58 /* 59 ** Initialize YM3526 emulator(s). 60 ** 61 ** 'num' is the number of virtual YM3526's to allocate 62 ** 'clock' is the chip clock in Hz 63 ** 'rate' is sampling rate 64 */ 65 void *ym3526_init(device_t *device, uint32_t clock, uint32_t rate); 66 void ym3526_clock_changed(void *chip, uint32_t clock, uint32_t rate); 67 /* shutdown the YM3526 emulators*/ 68 void ym3526_shutdown(void *chip); 69 void ym3526_reset_chip(void *chip); 70 int ym3526_write(void *chip, int a, int v); 71 unsigned char ym3526_read(void *chip, int a); 72 int ym3526_timer_over(void *chip, int c); 73 /* 74 ** Generate samples for one of the YM3526's 75 ** 76 ** 'which' is the virtual YM3526 number 77 ** '*buffer' is the output buffer pointer 78 ** 'length' is the number of samples that should be generated 79 */ 80 void ym3526_update_one(void *chip, write_stream_view &buffer); 81 82 void ym3526_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device); 83 void ym3526_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device); 84 void ym3526_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device); 85 86 #endif /* BUILD_YM3526 */ 87 88 89 #if BUILD_Y8950 90 91 /* Y8950 port handlers */ 92 void y8950_set_port_handler(void *chip, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, device_t *device); 93 void y8950_set_keyboard_handler(void *chip, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, device_t *device); 94 void y8950_set_delta_t_memory(void *chip, FM_READBYTE read_byte, FM_WRITEBYTE write_byte); 95 96 void * y8950_init(device_t *device, uint32_t clock, uint32_t rate); 97 void y8950_clock_changed(void *chip, uint32_t clock, uint32_t rate); 98 void y8950_shutdown(void *chip); 99 void y8950_reset_chip(void *chip); 100 int y8950_write(void *chip, int a, int v); 101 unsigned char y8950_read (void *chip, int a); 102 int y8950_timer_over(void *chip, int c); 103 void y8950_update_one(void *chip, write_stream_view &buffer); 104 105 void y8950_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device); 106 void y8950_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device); 107 void y8950_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device); 108 109 #endif /* BUILD_Y8950 */ 110 111 112 #endif // MAME_SOUND_FMOPL_H 113