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 void FMOPL_SaveState( void *chip, std::ostream& stream );
00055 void FMOPL_LoadState( void *chip, std::istream& stream );
00056 
00057 #endif /* BUILD_YM3812 */
00058 
00059 
00060 #if BUILD_YM3526
00061 
00062 /*
00063 ** Initialize YM3526 emulator(s).
00064 **
00065 ** 'num' is the number of virtual YM3526's to allocate
00066 ** 'clock' is the chip clock in Hz
00067 ** 'rate' is sampling rate
00068 */
00069 void *ym3526_init(device_t *device, uint32_t clock, uint32_t rate);
00070 void ym3526_clock_changed(void *chip, uint32_t clock, uint32_t rate);
00071 /* shutdown the YM3526 emulators*/
00072 void ym3526_shutdown(void *chip);
00073 void ym3526_reset_chip(void *chip);
00074 int  ym3526_write(void *chip, int a, int v);
00075 unsigned char ym3526_read(void *chip, int a);
00076 int  ym3526_timer_over(void *chip, int c);
00077 /*
00078 ** Generate samples for one of the YM3526's
00079 **
00080 ** 'which' is the virtual YM3526 number
00081 ** '*buffer' is the output buffer pointer
00082 ** 'length' is the number of samples that should be generated
00083 */
00084 void ym3526_update_one(void *chip, OPLSAMPLE *buffer, int length);
00085 
00086 void ym3526_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
00087 void ym3526_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
00088 void ym3526_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device);
00089 
00090 #endif /* BUILD_YM3526 */
00091 
00092 
00093 #if BUILD_Y8950
00094 
00095 /* Y8950 port handlers */
00096 void y8950_set_port_handler(void *chip, OPL_PORTHANDLER_W PortHandler_w, OPL_PORTHANDLER_R PortHandler_r, device_t *device);
00097 void y8950_set_keyboard_handler(void *chip, OPL_PORTHANDLER_W KeyboardHandler_w, OPL_PORTHANDLER_R KeyboardHandler_r, device_t *device);
00098 void y8950_set_delta_t_memory(void *chip, void * deltat_mem_ptr, int deltat_mem_size );
00099 
00100 void * y8950_init(device_t *device, uint32_t clock, uint32_t rate);
00101 void y8950_shutdown(void *chip);
00102 void y8950_reset_chip(void *chip);
00103 int  y8950_write(void *chip, int a, int v);
00104 unsigned char y8950_read (void *chip, int a);
00105 int  y8950_timer_over(void *chip, int c);
00106 void y8950_update_one(void *chip, OPLSAMPLE *buffer, int length);
00107 
00108 void y8950_set_timer_handler(void *chip, OPL_TIMERHANDLER TimerHandler, device_t *device);
00109 void y8950_set_irq_handler(void *chip, OPL_IRQHANDLER IRQHandler, device_t *device);
00110 void y8950_set_update_handler(void *chip, OPL_UPDATEHANDLER UpdateHandler, device_t *device);
00111 
00112 #endif /* BUILD_Y8950 */
00113 
00114 
00115 #endif // MAME_SOUND_FMOPL_H