DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/hardware/mame/fmopl.h
00001 // license:GPL-2.0+
00002 // copyright-holders:Jarek Burczynski,Tatsuyuki Satoh
00003 #ifndef MAME_SOUND_FMOPL_H
00004 #define MAME_SOUND_FMOPL_H
00005 
00006 #pragma once
00007 
00008 #if defined(_MSC_VER) && (_MSC_VER  <= 1500)
00009 #include <SDL.h>
00010 #else
00011 #include <stdint.h>
00012 #endif
00013 
00014 
00015 /* --- select emulation chips --- */
00016 #define BUILD_YM3812 1
00017 #define BUILD_YM3526 (0)
00018 #define BUILD_Y8950  (0)
00019 
00020 /* select output bits size of output : 8 or 16 */
00021 #define OPL_SAMPLE_BITS 16
00022 
00023 typedef stream_sample_t OPLSAMPLE;
00024 /*
00025 #if (OPL_SAMPLE_BITS==16)
00026 typedef int16_t OPLSAMPLE;
00027 #endif
00028 #if (OPL_SAMPLE_BITS==8)
00029 typedef int8_t OPLSAMPLE;
00030 #endif
00031 */
00032 
00033 typedef void (*OPL_TIMERHANDLER)(device_t *device,int timer,const attotime &period);
00034 typedef void (*OPL_IRQHANDLER)(device_t *device,int irq);
00035 typedef void (*OPL_UPDATEHANDLER)(device_t *device,int min_interval_us);
00036 typedef void (*OPL_PORTHANDLER_W)(device_t *device,unsigned char data);
00037 typedef unsigned char (*OPL_PORTHANDLER_R)(device_t *device);
00038 
00039 
00040 #if BUILD_YM3812
00041 
00042 void *ym3812_init(device_t *device, uint32_t clock, uint32_t rate);
00043 void ym3812_clock_changed(void *chip, uint32_t clock, uint32_t rate);
00044 void ym3812_shutdown(void *chip);
00045 void ym3812_reset_chip(void *chip);
00046 int  ym3812_write(void *chip, int a, int v);
00047 unsigned char ym3812_read(void *chip, int a);
00048 int  ym3812_timer_over(void *chip, int c);
00049 void ym3812_update_one(void *chip, OPLSAMPLE *buffer, int length);
00050 
00051 void ym3812_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
00052 void ym3812_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
00053 void ym3812_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device);
00054 
00055 #endif /* BUILD_YM3812 */
00056 
00057 
00058 #if BUILD_YM3526
00059 
00060 /*
00061 ** Initialize YM3526 emulator(s).
00062 **
00063 ** 'num' is the number of virtual YM3526's to allocate
00064 ** 'clock' is the chip clock in Hz
00065 ** 'rate' is sampling rate
00066 */
00067 void *ym3526_init(device_t *device, uint32_t clock, uint32_t rate);
00068 void ym3526_clock_changed(void *chip, uint32_t clock, uint32_t rate);
00069 /* shutdown the YM3526 emulators*/
00070 void ym3526_shutdown(void *chip);
00071 void ym3526_reset_chip(void *chip);
00072 int  ym3526_write(void *chip, int a, int v);
00073 unsigned char ym3526_read(void *chip, int a);
00074 int  ym3526_timer_over(void *chip, int c);
00075 /*
00076 ** Generate samples for one of the YM3526's
00077 **
00078 ** 'which' is the virtual YM3526 number
00079 ** '*buffer' is the output buffer pointer
00080 ** 'length' is the number of samples that should be generated
00081 */
00082 void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length);
00083 
00084 void ym3526_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
00085 void ym3526_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
00086 void ym3526_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device);
00087 
00088 #endif /* BUILD_YM3526 */
00089 
00090 
00091 #if BUILD_Y8950
00092 
00093 /* Y8950 port handlers */
00094 void y8950_set_port_handler(void *chip, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, device_t *device);
00095 void y8950_set_keyboard_handler(void *chip, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, device_t *device);
00096 void y8950_set_delta_t_memory(void *chip, void * deltat_mem_ptr, int deltat_mem_size );
00097 
00098 void * y8950_init(device_t *device, uint32_t clock, uint32_t rate);
00099 void y8950_shutdown(void *chip);
00100 void y8950_reset_chip(void *chip);
00101 int  y8950_write(void *chip, int a, int v);
00102 unsigned char y8950_read (void *chip, int a);
00103 int  y8950_timer_over(void *chip, int c);
00104 void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length);
00105 
00106 void y8950_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
00107 void y8950_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
00108 void y8950_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device);
00109 
00110 #endif /* BUILD_Y8950 */
00111 
00112 
00113 #endif // MAME_SOUND_FMOPL_H