visualboyadvance-m/src/System.h

102 lines
3.2 KiB
C
Raw Normal View History

#ifndef SYSTEM_H
#define SYSTEM_H
#include "common/Types.h"
#define winlog log
[WINDOWS] Add function to open unicode files. (#644) We have some issues when trying to open files on Windows that contains characters not included in the current codepage. Using `fopen` fails when that happens. One example is using the `pt_BR` codepage and then using a name with japanese chars for the battery file. The games and BIOS work since they use `blargg_open`. It converts a `const char *` to `const wchat_t *` and uses `_wfopen` for windows. (doing a multibyte to widechar conversion) Since we want to avoid doing many code changes on our cores, we need some `util*` functions for the matter. Replace `mb_fn_str` by UTF-8 strings. Replace all occurrences of `fopen` for `utilOpenFile` on GBA core. Replace all occurrences of `fopen` for `utilOpenFile` on GBA e-reader. Adjust e-readers calls on wx frontend. Replace all occurrences of `fopen` for `utilOpenFile` on Patcher files. Always apply UTF-8 when dealing with path strings. On our wx frontend we should always send UTF-8 `char *` to our cores functions. This way we can have consistency when dealing with them for each platform. On Windows, we will convert all multibyte to wide chars and use proper functions for I/O operation. Create function to deal with unicode calls of `gzopen`. We use `gzopen_w` (`zlib>=1.27`). Replace all occurrences of `fopen` for `utilOpenFile` on Config Manager. Replace all occurrences of `fopen` for `utilOpenFile` on Cheat files. Use proper functions for unicode on GB core. Use function instead of macro for `UTF8()`. Use `nullptr` instead of `NULL`. Print wide char strings on status bar.
2020-04-21 13:24:28 +00:00
#ifdef __LIBRETRO__
#define utilOpenFile fopen
#endif
class SoundDriver;
struct EmulatedSystem {
2016-07-08 23:59:29 +00:00
// main emulation function
void (*emuMain)(int);
// reset emulator
void (*emuReset)();
// clean up memory
void (*emuCleanUp)();
// load battery file
bool (*emuReadBattery)(const char *);
// write battery file
bool (*emuWriteBattery)(const char *);
2013-09-21 13:57:40 +00:00
#ifdef __LIBRETRO__
2016-07-08 23:59:29 +00:00
// load state
bool (*emuReadState)(const uint8_t *, unsigned);
2016-07-08 23:59:29 +00:00
// load state
unsigned (*emuWriteState)(uint8_t *, unsigned);
2013-09-21 13:57:40 +00:00
#else
2016-07-08 23:59:29 +00:00
// load state
bool (*emuReadState)(const char *);
// save state
bool (*emuWriteState)(const char *);
2013-09-21 13:57:40 +00:00
#endif
2016-07-08 23:59:29 +00:00
// load memory state (rewind)
bool (*emuReadMemState)(char *, int);
// write memory state (rewind)
bool (*emuWriteMemState)(char *, int, long &);
// write PNG file
bool (*emuWritePNG)(const char *);
// write BMP file
bool (*emuWriteBMP)(const char *);
// emulator update CPSR (ARM only)
void (*emuUpdateCPSR)();
// emulator has debugger
bool emuHasDebugger;
// clock ticks to emulate
int emuCount;
};
2016-07-08 23:59:29 +00:00
extern void log(const char *, ...);
extern bool systemPauseOnFrame();
extern void systemGbPrint(uint8_t *, int, int, int, int, int);
extern void systemScreenCapture(int);
extern void systemDrawScreen();
extern void systemSendScreen();
// updates the joystick data
extern bool systemReadJoypads();
// return information about the given joystick, -1 for default joystick
extern uint32_t systemReadJoypad(int);
extern uint32_t systemGetClock();
extern void systemMessage(int, const char *, ...);
extern void systemSetTitle(const char *);
2016-07-08 23:59:29 +00:00
extern SoundDriver *systemSoundInit();
extern void systemOnWriteDataToSoundBuffer(const uint16_t *finalWave, int length);
extern void systemOnSoundShutdown();
extern void systemScreenMessage(const char *);
extern void systemUpdateMotionSensor();
2013-09-21 13:57:40 +00:00
extern int systemGetSensorX();
extern int systemGetSensorY();
extern int systemGetSensorZ();
extern uint8_t systemGetSensorDarkness();
extern void systemCartridgeRumble(bool);
extern void systemPossibleCartridgeRumble(bool);
extern void updateRumbleFrame();
extern bool systemCanChangeSoundQuality();
extern void systemShowSpeed(int);
extern void system10Frames(int);
extern void systemFrame();
extern void systemGbBorderOn();
extern void Sm60FPS_Init();
extern bool Sm60FPS_CanSkipFrame();
extern void Sm60FPS_Sleep();
extern void DbgMsg(const char *msg, ...);
extern void (*dbgOutput)(const char *s, uint32_t addr);
2016-07-08 23:59:29 +00:00
extern void (*dbgSignal)(int sig, int number);
extern uint16_t systemColorMap16[0x10000];
extern uint32_t systemColorMap32[0x10000];
extern uint16_t systemGbPalette[24];
extern int systemRedShift;
extern int systemGreenShift;
extern int systemBlueShift;
extern int systemColorDepth;
extern int systemVerbose;
extern int systemFrameSkip;
extern int systemSaveUpdateCounter;
extern int systemSpeed;
#define SYSTEM_SAVE_UPDATED 30
#define SYSTEM_SAVE_NOT_UPDATED 0
2016-07-08 23:59:29 +00:00
#endif // SYSTEM_H