Skip to content

Commit

Permalink
Merge pull request #15 from ElementW/typemess
Browse files Browse the repository at this point in the history
Remove typedef'd standard int types
  • Loading branch information
ZachBacon committed Jul 30, 2016
2 parents 4d3d2b7 + 31391e0 commit 0573351
Show file tree
Hide file tree
Showing 171 changed files with 3,368 additions and 3,364 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Expand Up @@ -274,7 +274,6 @@ SET(HDR_MAIN
src/common/Port.h
src/common/SoundDriver.h
src/common/SoundSDL.h
src/common/Types.h
)

if(ENABLE_FFMPEG)
Expand Down
26 changes: 14 additions & 12 deletions src/System.h
@@ -1,6 +1,8 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#include "common/Types.h"

#include <cstdint>

#ifndef __LIBRETRO__
#include <zlib.h>
#endif
Expand All @@ -22,9 +24,9 @@ struct EmulatedSystem {
bool (*emuWriteBattery)(const char *);
#ifdef __LIBRETRO__
// load state
bool (*emuReadState)(const u8 *, unsigned);
bool (*emuReadState)(const uint8_t *, unsigned);
// load state
unsigned (*emuWriteState)(u8 *, unsigned);
unsigned (*emuWriteState)(uint8_t *, unsigned);
#else
// load state
bool (*emuReadState)(const char *);
Expand All @@ -49,25 +51,25 @@ struct EmulatedSystem {

extern void log(const char *, ...);
extern bool systemPauseOnFrame();
extern void systemGbPrint(u8 *, int, int, int, int, int);
extern void systemGbPrint(uint8_t *, int, int, int, int, int);
extern void systemScreenCapture(int);
extern void systemDrawScreen();
// updates the joystick data
extern bool systemReadJoypads();
// return information about the given joystick, -1 for default joystick
extern u32 systemReadJoypad(int);
extern u32 systemGetClock();
extern uint32_t systemReadJoypad(int);
extern uint32_t systemGetClock();
extern void systemMessage(int, const char *, ...);
extern void systemSetTitle(const char *);
extern SoundDriver *systemSoundInit();
extern void systemOnWriteDataToSoundBuffer(const u16 *finalWave, int length);
extern void systemOnWriteDataToSoundBuffer(const uint16_t *finalWave, int length);
extern void systemOnSoundShutdown();
extern void systemScreenMessage(const char *);
extern void systemUpdateMotionSensor();
extern int systemGetSensorX();
extern int systemGetSensorY();
extern int systemGetSensorZ();
extern u8 systemGetSensorDarkness();
extern uint8_t systemGetSensorDarkness();
extern void systemCartridgeRumble(bool);
extern void systemPossibleCartridgeRumble(bool);
extern void updateRumbleFrame();
Expand All @@ -80,11 +82,11 @@ extern void Sm60FPS_Init();
extern bool Sm60FPS_CanSkipFrame();
extern void Sm60FPS_Sleep();
extern void DbgMsg(const char *msg, ...);
extern void (*dbgOutput)(const char *s, u32 addr);
extern void (*dbgOutput)(const char *s, uint32_t addr);
extern void (*dbgSignal)(int sig, int number);
extern u16 systemColorMap16[0x10000];
extern u32 systemColorMap32[0x10000];
extern u16 systemGbPalette[24];
extern uint16_t systemColorMap16[0x10000];
extern uint32_t systemColorMap32[0x10000];
extern uint16_t systemGbPalette[24];
extern int systemRedShift;
extern int systemGreenShift;
extern int systemBlueShift;
Expand Down
100 changes: 50 additions & 50 deletions src/Util.cpp
Expand Up @@ -46,8 +46,8 @@ extern int systemRedShift;
extern int systemGreenShift;
extern int systemBlueShift;

extern u16 systemColorMap16[0x10000];
extern u32 systemColorMap32[0x10000];
extern uint16_t systemColorMap16[0x10000];
extern uint32_t systemColorMap32[0x10000];

static int(ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL;
Expand All @@ -64,17 +64,17 @@ bool FileExists(const char *filename)
#endif
}

void utilReadScreenPixels(u8 *dest, int w, int h)
void utilReadScreenPixels(uint8_t *dest, int w, int h)
{
u8 *b = dest;
uint8_t *b = dest;
int sizeX = w;
int sizeY = h;
switch (systemColorDepth) {
case 16: {
u16 *p = (u16 *)(pix + (w + 2) * 2); // skip first black line
uint16_t *p = (uint16_t *)(pix + (w + 2) * 2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u16 v = *p++;
uint16_t v = *p++;

*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
Expand All @@ -85,7 +85,7 @@ void utilReadScreenPixels(u8 *dest, int w, int h)
}
} break;
case 24: {
u8 *pixU8 = (u8 *)pix;
uint8_t *pixU8 = (uint8_t *)pix;
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) {
Expand All @@ -105,10 +105,10 @@ void utilReadScreenPixels(u8 *dest, int w, int h)
}
} break;
case 32: {
u32 *pixU32 = (u32 *)(pix + 4 * (w + 1));
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u32 v = *pixU32++;
uint32_t v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
Expand All @@ -119,10 +119,10 @@ void utilReadScreenPixels(u8 *dest, int w, int h)
}
}

bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
bool utilWritePNGFile(const char *fileName, int w, int h, uint8_t *pix)
{
#ifndef NO_PNG
u8 writeBuffer[512 * 3];
uint8_t writeBuffer[512 * 3];

FILE *fp = fopen(fileName, "wb");

Expand Down Expand Up @@ -165,17 +165,17 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)

png_write_info(png_ptr, info_ptr);

u8 *b = writeBuffer;
uint8_t *b = writeBuffer;

int sizeX = w;
int sizeY = h;

switch (systemColorDepth) {
case 16: {
u16 *p = (u16 *)(pix + (w + 2) * 2); // skip first black line
uint16_t *p = (uint16_t *)(pix + (w + 2) * 2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u16 v = *p++;
uint16_t v = *p++;

*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
Expand All @@ -189,7 +189,7 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
}
} break;
case 24: {
u8 *pixU8 = (u8 *)pix;
uint8_t *pixU8 = (uint8_t *)pix;
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) {
Expand All @@ -212,10 +212,10 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
}
} break;
case 32: {
u32 *pixU32 = (u32 *)(pix + 4 * (w + 1));
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u32 v = *pixU32++;
uint32_t v = *pixU32++;

*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
Expand All @@ -242,23 +242,23 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
#endif
}

void utilPutDword(u8 *p, u32 value)
void utilPutDword(uint8_t *p, uint32_t value)
{
*p++ = value & 255;
*p++ = (value >> 8) & 255;
*p++ = (value >> 16) & 255;
*p = (value >> 24) & 255;
}

void utilPutWord(u8 *p, u16 value)
void utilPutWord(uint8_t *p, uint16_t value)
{
*p++ = value & 255;
*p = (value >> 8) & 255;
}

bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
bool utilWriteBMPFile(const char *fileName, int w, int h, uint8_t *pix)
{
u8 writeBuffer[512 * 3];
uint8_t writeBuffer[512 * 3];

FILE *fp = fopen(fileName, "wb");

Expand All @@ -268,29 +268,29 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
}

struct {
u8 ident[2];
u8 filesize[4];
u8 reserved[4];
u8 dataoffset[4];
u8 headersize[4];
u8 width[4];
u8 height[4];
u8 planes[2];
u8 bitsperpixel[2];
u8 compression[4];
u8 datasize[4];
u8 hres[4];
u8 vres[4];
u8 colors[4];
u8 importantcolors[4];
// u8 pad[2];
uint8_t ident[2];
uint8_t filesize[4];
uint8_t reserved[4];
uint8_t dataoffset[4];
uint8_t headersize[4];
uint8_t width[4];
uint8_t height[4];
uint8_t planes[2];
uint8_t bitsperpixel[2];
uint8_t compression[4];
uint8_t datasize[4];
uint8_t hres[4];
uint8_t vres[4];
uint8_t colors[4];
uint8_t importantcolors[4];
// uint8_t pad[2];
} bmpheader;
memset(&bmpheader, 0, sizeof(bmpheader));

bmpheader.ident[0] = 'B';
bmpheader.ident[1] = 'M';

u32 fsz = sizeof(bmpheader) + w * h * 3;
uint32_t fsz = sizeof(bmpheader) + w * h * 3;
utilPutDword(bmpheader.filesize, fsz);
utilPutDword(bmpheader.dataoffset, 0x36);
utilPutDword(bmpheader.headersize, 0x28);
Expand All @@ -302,17 +302,17 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)

fwrite(&bmpheader, 1, sizeof(bmpheader), fp);

u8 *b = writeBuffer;
uint8_t *b = writeBuffer;

int sizeX = w;
int sizeY = h;

switch (systemColorDepth) {
case 16: {
u16 *p = (u16 *)(pix + (w + 2) * (h)*2); // skip first black line
uint16_t *p = (uint16_t *)(pix + (w + 2) * (h)*2); // skip first black line
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u16 v = *p++;
uint16_t v = *p++;

*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
Expand All @@ -327,7 +327,7 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
}
} break;
case 24: {
u8 *pixU8 = (u8 *)pix + 3 * w * (h - 1);
uint8_t *pixU8 = (uint8_t *)pix + 3 * w * (h - 1);
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
if (systemRedShift > systemBlueShift) {
Expand All @@ -351,10 +351,10 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
}
} break;
case 32: {
u32 *pixU32 = (u32 *)(pix + 4 * (w + 1) * (h));
uint32_t *pixU32 = (uint32_t *)(pix + 4 * (w + 1) * (h));
for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) {
u32 v = *pixU32++;
uint32_t v = *pixU32++;

*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
Expand Down Expand Up @@ -544,7 +544,7 @@ static int utilGetSize(int size)
return res;
}

u8 *utilLoad(const char *file, bool (*accept)(const char *), u8 *data, int &size)
uint8_t *utilLoad(const char *file, bool (*accept)(const char *), uint8_t *data, int &size)
{
// find image file
char buffer[2048];
Expand Down Expand Up @@ -573,11 +573,11 @@ u8 *utilLoad(const char *file, bool (*accept)(const char *), u8 *data, int &size
if (size == 0)
size = fileSize;

u8 *image = data;
uint8_t *image = data;

if (image == NULL) {
// allocate buffer memory if none was passed to the function
image = (u8 *)malloc(utilGetSize(size));
image = (uint8_t *)malloc(utilGetSize(size));
if (image == NULL) {
fex_close(fe);
systemMessage(MSG_OUT_OF_MEMORY,
Expand Down Expand Up @@ -751,14 +751,14 @@ long utilGzMemTell(gzFile file)

void utilGBAFindSave(const int size)
{
u32 *p = (u32 *)&rom[0];
u32 *end = (u32 *)(&rom[0] + size);
uint32_t *p = (uint32_t *)&rom[0];
uint32_t *end = (uint32_t *)(&rom[0] + size);
int detectedSaveType = 0;
int flashSize = 0x10000;
bool rtcFound = false;

while (p < end) {
u32 d = READ32LE(p);
uint32_t d = READ32LE(p);

if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) {
Expand Down
6 changes: 3 additions & 3 deletions src/Util.h
Expand Up @@ -13,9 +13,9 @@ typedef struct {

bool FileExists(const char *filename);

void utilReadScreenPixels(u8 *dest, int w, int h);
bool utilWritePNGFile(const char *, int, int, u8 *);
bool utilWriteBMPFile(const char *, int, int, u8 *);
void utilReadScreenPixels(uint8_t *dest, int w, int h);
bool utilWritePNGFile(const char *, int, int, uint8_t *);
bool utilWriteBMPFile(const char *, int, int, uint8_t *);
void utilApplyIPS(const char *ips, uint8_t **rom, int *size);
bool utilIsGBAImage(const char *);
bool utilIsGBImage(const char *);
Expand Down

0 comments on commit 0573351

Please sign in to comment.