Casio_asm/common/platform.h

102 lines
2.2 KiB
C

#ifndef PLATFORM_H
#define PLATFORM_H
//BEGIN plarform detection
// only keep the one on which you are compiling
// #define CASIO_gint
// #define CASIO_fxlib
#if defined(CASIO_gint)||defined(CASIO_fxlib)
#undef __gnu_linux__
#undef __CYGWIN__
#undef __WIN32
#endif
#if defined(__CYGWIN__)||defined(__gnu_linux__)
// figure out whether or not we are on Linux (or Cygwin)
#define LINUX
#define PC
#define PLATFORM_CODE 0x11
#elif defined(__WIN32)
// same, but for Windows
#define WINDOWS
#define PC
#define PLATFORM_CODE 0x12
#elif defined(CASIO_gint)
// handle casio with gint
#define CASIO
#define PLATFORM_CODE 0x21
#elif defined(CASIO_fxlib)
// handle casio with fxlib
#define CASIO
#define PLATFORM_CODE 0x22
void* malloc(int sz);
void* calloc(int sz, int n);
void* realloc(void* ptr, int sz);
void free(void* ptr);
#else
// we don't know what we are compiling for
#define PLATFORM_CODE 0x00
#endif
//END platform detection
//BEGIN compatibility
// use big-endian structs and unions
// this is REQUIRED for compatibility between PC and Casio
// as the SH4 is in big-endian mode and a x86 is in little-endian
// for performance reasons, it is only used in the opcodes
#if defined(__GNUC__)&&(__BYTE_ORDER__!=__ORDER_BIG_ENDIAN__)
#define BIG __attribute__((scalar_storage_order("big-endian")))
#else
#define BIG
#endif
#ifndef CASIO_fxlib
#include <stdlib.h>
#include <stdio.h>
#endif
//END compatibility
//BEGIN files
int File_open(char* path, int mode);
int File_close(int handle);
int File_read(int handle, int pos, void* buffer, int len);
int File_write(int handle, int pos, void* buffer, int len);
int File_length(int handle);
int File_truncate(int handle, int len);
int File_delete(char* path);
int File_mkdir(char* path);
#define FILE_OPEN_read 1
#define FILE_OPEN_write 2
#define FILE_OPEN_create 4
//END files
//BEGIN graphics
char* Graph_getVramAddress();
void Graph_printVram();
#define VRAM_LENGTH (128*64/8)
#define VRAM_HEIGHT 64
#define VRAM_WIDTH 128
#define VRAM_BYTES_PER_LINE (128/8)
//END graphics
//BEGIN timers
int Timer_start(int ms);
int Timer_stop(int id);
//BEGIN common
int Platform_init();
int Platform_quit();
void Platform_tick(int block);
int Platform_running();
void Platform_setError(int err);
int Platform_getError();
//END common
#endif