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