DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
include/np2glue.h
00001 /* The purpose of this header is to provide defines and macros
00002  * to help port code from Neko Project II and match the typedefs
00003  * it uses. */
00004 
00005 #include <math.h>
00006 #include <stdio.h>
00007 #include <stdint.h>
00008 #include <string.h>
00009 #include <stdlib.h>
00010 #include <limits.h>
00011 
00012 #if defined(WIN32)
00013 # include <windows.h>
00014 # include <io.h>
00015 
00016 # if defined(_MSC_VER)
00017 #  pragma warning(disable:4996)
00018 # endif
00019 #endif
00020 
00021 #if defined(WIN32) && !defined(strcasecmp)
00022 #define strcasecmp strcmpi
00023 #endif
00024 
00025 #define SUPPORT_PX
00026 
00027 #if !defined(MAX_PATH)
00028 #define MAX_PATH PATH_MAX
00029 #endif
00030 
00031 #ifdef WIN32
00032 # define BYTESEX_LITTLE
00033 # define _G_DIR_SEPARATOR '\\'
00034 #else
00035 # include "byteorder.h"
00036 # define _G_DIR_SEPARATOR '/'
00037 # if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
00038 #  error byteorder not enough information
00039 # endif
00040 # if BYTE_ORDER == LITTLE_ENDIAN
00041 #  define BYTESEX_LITTLE
00042 # elif BYTE_ORDER == BIG_ENDIAN
00043 #  define BYTESEX_BIG
00044 # else
00045 #  error unknown byte order
00046 # endif
00047 #endif
00048 
00049 enum {
00050         SUCCESS         = 0,
00051         FAILURE         = 1
00052 };
00053 
00054 enum {
00055         PCBASECLOCK25           = 2457600,
00056         PCBASECLOCK20           = 1996800
00057 };
00058 
00059 enum {
00060         CPUMODE_8MHZ            = 0x20,
00061 
00062         PCMODEL_VF                      = 0,
00063         PCMODEL_VM                      = 1,
00064         PCMODEL_VX                      = 2,
00065         PCMODELMASK                     = 0x3f,
00066         PCMODEL_PC9821          = 0x40,
00067         PCMODEL_EPSON           = 0x80,
00068 
00069         PCHDD_SASI                      = 0x01,
00070         PCHDD_SCSI                      = 0x02,
00071         PCHDD_IDE                       = 0x04,
00072 
00073         PCROM_BIOS                      = 0x01,
00074         PCROM_SOUND                     = 0x02,
00075         PCROM_SASI                      = 0x04,
00076         PCROM_SCSI                      = 0x08,
00077         PCROM_BIOS9821          = 0x10,
00078 
00079         PCSOUND_NONE            = 0x00,
00080 
00081         PCCBUS_PC9861K          = 0x0001,
00082         PCCBUS_MPU98            = 0x0002
00083 };
00084 
00085 // GLUE TYPEDEFS
00086 // WARNING: Windows targets will want to IFDEF some of these out as they will
00087 //          conflict with the typedefs in windows.h
00088 typedef uint32_t UINT32;
00089 typedef int32_t SINT32;
00090 typedef uint16_t UINT16;
00091 typedef int16_t SINT16;
00092 typedef uint8_t UINT8;
00093 typedef int8_t SINT8;
00094 typedef uint32_t UINT;
00095 typedef uint32_t REG8; /* GLIB guint32 -> UINT -> REG8 */
00096 #ifndef WIN32
00097 typedef uint8_t BOOL;
00098 typedef uint8_t BYTE;
00099 #endif
00100 typedef char OEMCHAR;
00101 typedef void* NEVENTITEM;
00102 #define OEMTEXT(x) x
00103 #define SOUNDCALL
00104 
00105 static inline uint16_t LOADINTELWORD(void *x) {
00106     return *((uint16_t*)(x));
00107 }
00108 
00109 static inline void STOREINTELWORD(void *x,uint16_t y) {
00110     *((uint16_t*)(x)) = y;
00111 }
00112 
00113 static inline uint32_t LOADINTELDWORD(void *x) {
00114     return *((uint32_t*)(x));
00115 }
00116 
00117 static inline void STOREINTELDWORD(void *x,uint32_t y) {
00118     *((uint32_t*)(x)) = y;
00119 }
00120 
00121 #ifndef TRUE
00122 #define TRUE 1
00123 #endif
00124 
00125 #ifndef FALSE
00126 #define FALSE 0
00127 #endif
00128 
00129 /* TODO: Move into another header */
00130 #ifndef M_PI
00131 #define M_PI 3.14159265358979323846
00132 #endif
00133 
00134 #ifndef PI
00135 #define PI M_PI
00136 #endif
00137 
00138 #ifndef WIN32
00139 static inline void ZeroMemory(void *p,size_t l) {
00140     memset(p,0,l);
00141 }
00142 
00143 static inline void FillMemory(void *p,size_t l,unsigned char c) {
00144     memset(p,c,l);
00145 }
00146 #endif
00147 
00148 static inline void pcm86io_bind(void) {
00149     /* dummy */
00150 }
00151 
00152 #ifdef __cplusplus
00153 extern "C" {
00154 #endif
00155 
00156 void sound_sync(void);
00157 
00158 #ifdef __cplusplus
00159 }
00160 #endif
00161 
00162 #define BRESULT             UINT8
00163 
00164 #ifdef __cplusplus
00165 extern "C" {
00166 #endif
00167 
00168 #if 1
00169 void _TRACEOUT(const char *fmt,...);
00170 #else
00171 static inline void _TRACEOUT(const char *fmt,...) { };
00172 #endif
00173 #define TRACEOUT(a) _TRACEOUT a
00174 
00175 #ifdef __cplusplus
00176 }
00177 #endif
00178 
00179 typedef struct {
00180         // ƒGƒ~ƒ…ƒŒ[ƒg’†‚É‚æ‚­ŽQÆ‚³‚ê‚é“z
00181         UINT8   uPD72020;
00182         UINT8   DISPSYNC;
00183         UINT8   RASTER;
00184         UINT8   realpal;
00185         UINT8   LCD_MODE;
00186         UINT8   skipline;
00187         UINT16  skiplight;
00188 
00189         UINT8   KEY_MODE;
00190         UINT8   XSHIFT;
00191         UINT8   BTN_RAPID;
00192         UINT8   BTN_MODE;
00193 
00194         UINT8   dipsw[3];
00195         UINT8   MOUSERAPID;
00196 
00197         UINT8   calendar;
00198         UINT8   usefd144;
00199         UINT8   wait[6];
00200 
00201         // ƒŠƒZƒbƒgŽž‚Æ‚©‚ ‚ñ‚Ü‚èŽQÆ‚³‚ê‚È‚¢“z
00202         OEMCHAR model[8];
00203         UINT    baseclock;
00204         UINT    multiple;
00205 
00206         UINT8   memsw[8];
00207 
00208         UINT8   ITF_WORK;
00209         UINT8   EXTMEM;
00210         UINT8   grcg;
00211         UINT8   color16;
00212         UINT32  BG_COLOR;
00213         UINT32  FG_COLOR;
00214 
00215         UINT16  samplingrate;
00216         UINT16  delayms;
00217         UINT8   SOUND_SW;
00218         UINT8   snd_x;
00219 
00220         UINT8   snd14opt[3];
00221         UINT8   snd26opt;
00222         UINT8   snd86opt;
00223         UINT8   spbopt;
00224         UINT8   spb_vrc;                                                                                                // ver0.30
00225         UINT8   spb_vrl;                                                                                                // ver0.30
00226         UINT8   spb_x;                                                                                                  // ver0.30
00227 
00228         UINT8   BEEP_VOL;
00229         UINT8   vol14[6];
00230         UINT8   vol_fm;
00231         UINT8   vol_ssg;
00232         UINT8   vol_adpcm;
00233         UINT8   vol_pcm;
00234         UINT8   vol_rhythm;
00235 
00236         UINT8   mpuenable;
00237         UINT8   mpuopt;
00238 
00239         UINT8   pc9861enable;
00240         UINT8   pc9861sw[3];
00241         UINT8   pc9861jmp[6];
00242 
00243         UINT8   fddequip;
00244         UINT8   MOTOR;
00245         UINT8   MOTORVOL;
00246         UINT8   PROTECTMEM;
00247         UINT8   hdrvacc;
00248 
00249         OEMCHAR sasihdd[2][MAX_PATH];                                                                   // ver0.74
00250 #if defined(SUPPORT_SCSI)
00251         OEMCHAR scsihdd[4][MAX_PATH];                                                                   // ver0.74
00252 #endif
00253         OEMCHAR fontfile[MAX_PATH];
00254         OEMCHAR biospath[MAX_PATH];
00255         OEMCHAR hdrvroot[MAX_PATH];
00256 } NP2CFG;
00257 
00258 #ifdef __cplusplus
00259 extern "C" {
00260 #endif
00261 
00262 unsigned char *CGetMemBase();
00263 
00264 void getbiospath(OEMCHAR *path, const OEMCHAR *fname, int maxlen);
00265 
00266 REG8 joymng_getstat(void);
00267 REG8 keystat_getjoy(void);
00268 
00269 extern NP2CFG pccore;
00270 #define np2cfg pccore
00271 
00272 #ifdef __cplusplus
00273 }
00274 #endif
00275 
00276 #ifdef reg
00277 #undef reg
00278 #endif
00279 
00280 #ifndef min
00281 #define min(a,b)    (((a) < (b)) ? (a) : (b))
00282 #endif
00283 
00284 #ifndef NELEMENTS
00285 #define NELEMENTS(a)    ((int)(sizeof(a) / sizeof(a[0])))
00286 #endif
00287 
00288 #define _MEM_INIT()                             
00289 #define _MALLOC(a, b)                   malloc(a)
00290 #define _MFREE(a)                               free(a)
00291 #define _HANDLE_ADD(a, b)               
00292 #define _HANDLE_REM(a)                  
00293 #define _MEM_USED(a)                    
00294 
00295 #ifndef WIN32
00296 #define CopyMemory(d,s,n)   memcpy((d), (s), (n))
00297 #endif
00298 
00299 typedef FILE *                  FILEH;
00300 
00301 #ifndef FASTCALL
00302 #define FASTCALL
00303 #endif
00304 
00305 #define IOOUTCALL       FASTCALL
00306 #define IOINPCALL       FASTCALL
00307 
00308 typedef void (IOOUTCALL *IOOUT)(UINT port, REG8 val);
00309 typedef REG8 (IOINPCALL *IOINP)(UINT port);
00310 
00311 #ifdef __cplusplus
00312 extern "C" {
00313 #endif
00314 
00315 void pic_setirq(REG8 irq);
00316 void pic_resetirq(REG8 irq);
00317 
00318 void cbuscore_attachsndex(UINT port, const IOOUT *out, const IOINP *inp);
00319 
00320 #ifdef __cplusplus
00321 }
00322 #endif
00323