DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
include/modules.h
00001 /* Standard data types used */
00002 
00003 typedef unsigned char Bit8u;
00004 typedef signed char Bit8s;
00005 typedef unsigned short Bit16u;
00006 typedef signed short Bit16s;
00007 typedef unsigned long Bit32u;
00008 typedef signed long Bit32s;
00009 #if defined(_MSC_VER)
00010 typedef unsigned __int64 Bit64u;
00011 typedef signed __int64 Bit64s;
00012 #else
00013 typedef unsigned long long int Bit64u;
00014 typedef signed long long int Bit64s;
00015 #endif
00016 
00017 
00018 
00019 /* Setting up pointers to all subfunctions */
00020 #ifdef MODULE_WANT_IO_READ
00021 typedef Bit8u (* IO_ReadHandler)(Bit32u port);
00022 static void (* IO_RegisterReadHandler)(Bit32u port,IO_ReadHandler handler,char * name);
00023 static void (* IO_FreeReadHandler)(Bit32u port);
00024 #endif
00025 
00026 #ifdef MODULE_WANT_IO_WRITE
00027 typedef void (* IO_WriteHandler)(Bit32u port,Bit8u value);
00028 static void (* IO_RegisterWriteHandler)(Bit32u port,IO_WriteHandler handler,char * name);
00029 static void (* IO_FreeWriteHandler)(Bit32u port);
00030 #endif
00031 
00032 #ifdef MODULE_WANT_IRQ_EOI
00033 typedef void (* IRQ_EOIHandler)(void);
00034 static void (* IRQ_RegisterEOIHandler)(Bit32u irq,IRQ_EOIHandler handler,char * name);
00035 static void (* IRQ_FreeEOIHandler)(Bit32u irq);
00036 #endif
00037 
00038 #ifdef MODULE_WANT_IRQ 
00039 static void (* IRQ_Activate)(Bit32u irq);
00040 static void (* IRQ_Deactivate)(Bit32u irq);
00041 #endif
00042 
00043 #ifdef MODULE_WANT_TIMER
00044 typedef void (* TIMER_MicroHandler)(void);
00045 static  void (* TIMER_RegisterMicroHandler)(TIMER_MicroHandler handler,Bit32u micro);
00046 #endif
00047 
00048 #ifdef MODULE_WANT_TIMER_TICK
00049 typedef void (* TIMER_TickHandler)(Bit32u ticks);
00050 static  void (* TIMER_RegisterTickHandler)(TIMER_TickHandler handler);
00051 #endif
00052 
00053 /* 
00054         4 8-bit and 4 16-bit channels you can read data from 
00055         16-bit reads are word sized
00056 */
00057 
00058 #ifdef MODULE_WANT_DMA_READ
00059 static void (* DMA_8_Read)(Bit32u chan,Bit8u * data,Bit16u size);
00060 static void (* DMA_16_Read)(Bit32u chan,Bit8u * data,Bit16u size);
00061 #endif
00062 
00063 /* 
00064         4 8-bit and 4 16-bit channels you can write data from 
00065         16-bit writes are word sized
00066 */
00067 
00068 #ifdef MODULE_WANT_DMA_READ
00069 static void (* DMA_8_Write)(Bit32u chan,Bit8u * data,Bit16u size);
00070 static void (* DMA_16_Write)(Bit32u chan,Bit8u * data,Bit16u size);
00071 #endif
00072 
00073 
00074 #ifdef MODULE_WANT_MIXER 
00075 /*      The len here means the amount of samples needed not the buffersize it needed to fill */
00076 typedef void (* MIXER_MixHandler)(Bit8u * sampdate,Bit32u len);
00077 
00078 /* Different types if modes a mixer channel can work in */
00079 #define MIXER_8MONO             0
00080 #define MIXER_8STEREO   1
00081 #define MIXER_16MONO    2
00082 #define MIXER_16STEREO  3
00083 struct MIXER_Channel;
00084 
00085 #define MAX_AUDIO ((1<<(16-1))-1)
00086 #define MIN_AUDIO -(1<<(16-1))
00087 
00088 MIXER_Channel *(* MIXER_AddChannel)(MIXER_MixHandler handler,Bit32u freq,char * name);
00089 void (* MIXER_SetVolume)(MIXER_Channel * chan,Bit8u vol);
00090 void (* MIXER_SetFreq)(MIXER_Channel * chan,Bit32u freq);
00091 void (* MIXER_SetMode)(MIXER_Channel * chan,Bit8u mode);
00092 void (* MIXER_Enable)(MIXER_Channel * chan,bool enable);
00093 #endif
00094 
00095 typedef bool (* MODULE_FindHandler)(char * name,void * * function);
00096 typedef char *(* MODULE_StartHandler)(MODULE_FindHandler find_handler);
00097 
00098 #define MODULE_START_PROC "ModuleStart"
00099 
00100 #ifdef MODULE_START_FUNCTION
00101 #include <stdio.h>
00102 
00103 #define GET_FUNCTION(a)                                                                                                 \
00104         if (!find_handler(#a ,(void * *) &a)) {                                                         \
00105                 return "Can't find requested function";                                                 \
00106         };
00107 
00108 
00109 #if defined (WIN32)
00110 #include <windows.h>
00111 BOOL APIENTRY DllMain( HANDLE hModule, 
00112                        DWORD  ul_reason_for_call, 
00113                        LPVOID lpReserved
00114                                          )
00115 {
00116     return TRUE;
00117 }
00118 
00119 extern "C" {
00120 __declspec(dllexport) 
00121 #endif 
00122 char * ModuleStart (MODULE_FindHandler find_handler) {
00123 
00124 #ifdef MODULE_WANT_IRQ_EOI
00125 GET_FUNCTION(IRQ_RegisterEOIHandler);
00126 GET_FUNCTION(IRQ_FreeEOIHandler);
00127 #endif 
00128 
00129 #ifdef MODULE_WANT_IRQ 
00130 GET_FUNCTION(IRQ_Activate);
00131 GET_FUNCTION(IRQ_Deactivate);
00132 #endif
00133 
00134 #ifdef MODULE_WANT_IO_READ
00135 GET_FUNCTION(IO_RegisterReadHandler);
00136 GET_FUNCTION(IO_FreeReadHandler);
00137 #endif
00138 
00139 #ifdef MODULE_WANT_IO_WRITE
00140 GET_FUNCTION(IO_RegisterWriteHandler);
00141 GET_FUNCTION(IO_FreeWriteHandler);
00142 #endif
00143 
00144 #ifdef MODULE_WANT_TIMER
00145 GET_FUNCTION(TIMER_RegisterMicroHandler);
00146 #endif
00147 
00148 #ifdef MODULE_WANT_TIMER_TICKS
00149 GET_FUNCTION(TIMER_RegisterTickHandler);
00150 #endif
00151 
00152 #ifdef MODULE_WANT_DMA_READ
00153 GET_FUNCTION(DMA_8_Read);
00154 GET_FUNCTION(DMA_16_Read);
00155 #endif
00156 
00157 #ifdef MODULE_WANT_DMA_WRITE
00158 GET_FUNCTION(DMA_8_Write);
00159 GET_FUNCTION(DMA_16_Write);
00160 #endif
00161 
00162 #ifdef MODULE_WANT_MIXER
00163 GET_FUNCTION(MIXER_AddChannel);
00164 GET_FUNCTION(MIXER_SetVolume);
00165 GET_FUNCTION(MIXER_SetFreq);
00166 GET_FUNCTION(MIXER_SetMode);
00167 GET_FUNCTION(MIXER_Enable);
00168 #endif
00169 
00170 return MODULE_START_FUNCTION;
00171 
00172 }
00173 #if defined (WIN32)
00174 }
00175 #endif 
00176 
00177 
00178 
00179 #endif
00180