Merge pull request #15 from ElementW/typemess

Remove typedef'd standard int types
This commit is contained in:
Zach Bacon 2016-07-29 20:47:14 -04:00 committed by GitHub
commit 0573351a65
171 changed files with 3365 additions and 3361 deletions

View File

@ -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)

View File

@ -1,6 +1,8 @@
#ifndef SYSTEM_H
#define SYSTEM_H
#include "common/Types.h"
#include <cstdint>
#ifndef __LIBRETRO__
#include <zlib.h>
#endif
@ -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 *);
@ -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();
@ -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;

View File

@ -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;
@ -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
@ -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) {
@ -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
@ -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");
@ -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
@ -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) {
@ -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
@ -242,7 +242,7 @@ 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;
@ -250,15 +250,15 @@ void utilPutDword(u8 *p, u32 value)
*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");
@ -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);
@ -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
@ -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) {
@ -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
@ -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];
@ -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,
@ -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) {

View File

@ -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 *);

View File

@ -62,9 +62,9 @@ static int readInt3(FILE* f)
return c + (res << 8);
}
static s64 readInt4(FILE* f)
static int64_t readInt4(FILE* f)
{
s64 tmp, res = 0;
int64_t tmp, res = 0;
int c;
for (int i = 0; i < 4; i++) {
@ -78,9 +78,9 @@ static s64 readInt4(FILE* f)
return res;
}
static s64 readInt8(FILE* f)
static int64_t readInt8(FILE* f)
{
s64 tmp, res = 0;
int64_t tmp, res = 0;
int c;
for (int i = 0; i < 8; i++) {
@ -94,9 +94,9 @@ static s64 readInt8(FILE* f)
return res;
}
static s64 readVarPtr(FILE* f)
static int64_t readVarPtr(FILE* f)
{
s64 offset = 0, shift = 1;
int64_t offset = 0, shift = 1;
for (;;) {
int c = fgetc(f);
if (c == EOF)
@ -191,7 +191,7 @@ static bool patchApplyIPS(const char* patchname, uint8_t** r, int* s)
static bool patchApplyUPS(const char* patchname, uint8_t** rom, int* size)
{
s64 srcCRC, dstCRC, patchCRC;
int64_t srcCRC, dstCRC, patchCRC;
FILE* f = fopen(patchname, "rb");
if (!f)
@ -231,9 +231,9 @@ static bool patchApplyUPS(const char* patchname, uint8_t** rom, int* size)
crc = crc32(crc, *rom, *size);
fseeko64(f, 4, SEEK_SET);
s64 dataSize;
s64 srcSize = readVarPtr(f);
s64 dstSize = readVarPtr(f);
int64_t dataSize;
int64_t srcSize = readVarPtr(f);
int64_t dstSize = readVarPtr(f);
if (crc == srcCRC) {
if (srcSize != *size) {
@ -257,14 +257,14 @@ static bool patchApplyUPS(const char* patchname, uint8_t** rom, int* size)
*size = dataSize;
}
s64 relative = 0;
int64_t relative = 0;
uint8_t* mem;
while (ftello64(f) < patchSize - 12) {
relative += readVarPtr(f);
if (relative > dataSize)
continue;
mem = *rom + relative;
for (s64 i = relative; i < dataSize; i++) {
for (int64_t i = relative; i < dataSize; i++) {
int x = fgetc(f);
relative++;
if (!x)

View File

@ -1,7 +1,7 @@
#ifndef PATCH_H
#define PATCH_H
#include "Types.h"
#include <cstdint>
bool applyPatch(const char *patchname, uint8_t **rom, int *size);

View File

@ -1,6 +1,8 @@
#ifndef PORT_H
#define PORT_H
#include <cstdint>
#ifdef __CELLOS_LV2__
/* PlayStation3 */
#include <ppu_intrinsics.h>
@ -12,7 +14,7 @@
#endif
// swaps a 16-bit value
static inline uint16_t swap16(u16 v)
static inline uint16_t swap16(uint16_t v)
{
return (v << 8) | (v >> 8);
}

View File

@ -1,33 +0,0 @@
// VisualBoyAdvance - Nintendo Gameboy/GameboyAdvance (TM) emulator.
// Copyright (C) 2008 VBA-M development team
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2, or(at your option)
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef __VBA_TYPES_H__
#define __VBA_TYPES_H__
#include <stdint.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
#endif // __VBA_TYPES_H__

View File

@ -129,7 +129,7 @@ MediaRet MediaRecorder::setup_sound_stream(const char *fname, AVOutputFormat *fm
ctx = aud_st->codec;
ctx->codec_id = fmt->audio_codec;
ctx->codec_type = AVMEDIA_TYPE_AUDIO;
// Some encoders don't like s16 (SAMPLE_FMT_S16)
// Some encoders don't like int16_t (SAMPLE_FMT_S16)
ctx->sample_fmt = codec->sample_fmts[0];
// This was changed in the initial ffmpeg 3.0 update,
// but shouldn't (as far as I'm aware) cause problems with older versions

View File

@ -14,8 +14,6 @@
// is the code to find the available formats & associated extensions for
// the file dialog.
#include "../common/Types.h"
// return codes
// probably ought to put in own namespace, but this is good enough
enum MediaRet {
@ -47,10 +45,10 @@ class MediaRecorder
// add a frame of video; width+height+depth already given
// assumes a 1-pixel border on top & right
// always assumes being passed 1/60th of a second of video
MediaRet AddFrame(const u8 *vid);
MediaRet AddFrame(const uint8_t *vid);
// add a frame of audio; uses current sample rate to know length
// always assumes being passed 1/60th of a second of audio.
MediaRet AddFrame(const u16 *aud);
MediaRet AddFrame(const uint16_t *aud);
private:
static bool did_init;
@ -66,8 +64,8 @@ class MediaRecorder
#endif
priv_AVFormatContext *oc;
priv_AVStream *vid_st, *aud_st;
u8 *audio_buf, *video_buf;
u16 *audio_buf2;
uint8_t *audio_buf, *video_buf;
uint16_t *audio_buf2;
int frame_len, sample_len, in_audio_buf2;
int linesize, pixsize;
priv_PixelFormat pixfmt;

View File

@ -6,38 +6,38 @@ extern "C"
{
#ifdef MMX
void _2xSaILine (u8 *srcPtr, u8 *deltaPtr, u32 srcPitch,
u32 width, u8 *dstPtr, u32 dstPitch);
void _2xSaISuperEagleLine (u8 *srcPtr, u8 *deltaPtr,
u32 srcPitch, u32 width,
u8 *dstPtr, u32 dstPitch);
void _2xSaISuper2xSaILine (u8 *srcPtr, u8 *deltaPtr,
u32 srcPitch, u32 width,
u8 *dstPtr, u32 dstPitch);
void Init_2xSaIMMX (u32 BitFormat);
void BilinearMMX (u16 * A, u16 * B, u16 * C, u16 * D,
u16 * dx, u16 * dy, u8 *dP);
void BilinearMMXGrid0 (u16 * A, u16 * B, u16 * C, u16 * D,
u16 * dx, u16 * dy, u8 *dP);
void BilinearMMXGrid1 (u16 * A, u16 * B, u16 * C, u16 * D,
u16 * dx, u16 * dy, u8 *dP);
void _2xSaILine (uint8_t *srcPtr, uint8_t *deltaPtr, uint32_t srcPitch,
uint32_t width, uint8_t *dstPtr, uint32_t dstPitch);
void _2xSaISuperEagleLine (uint8_t *srcPtr, uint8_t *deltaPtr,
uint32_t srcPitch, uint32_t width,
uint8_t *dstPtr, uint32_t dstPitch);
void _2xSaISuper2xSaILine (uint8_t *srcPtr, uint8_t *deltaPtr,
uint32_t srcPitch, uint32_t width,
uint8_t *dstPtr, uint32_t dstPitch);
void Init_2xSaIMMX (uint32_t BitFormat);
void BilinearMMX (uint16_t * A, uint16_t * B, uint16_t * C, uint16_t * D,
uint16_t * dx, uint16_t * dy, uint8_t *dP);
void BilinearMMXGrid0 (uint16_t * A, uint16_t * B, uint16_t * C, uint16_t * D,
uint16_t * dx, uint16_t * dy, uint8_t *dP);
void BilinearMMXGrid1 (uint16_t * A, uint16_t * B, uint16_t * C, uint16_t * D,
uint16_t * dx, uint16_t * dy, uint8_t *dP);
void EndMMX ();
bool cpu_mmx = 1;
#endif
}
static u32 colorMask = 0xF7DEF7DE;
static u32 lowPixelMask = 0x08210821;
static u32 qcolorMask = 0xE79CE79C;
static u32 qlowpixelMask = 0x18631863;
static u32 redblueMask = 0xF81F;
static u32 greenMask = 0x7E0;
static uint32_t colorMask = 0xF7DEF7DE;
static uint32_t lowPixelMask = 0x08210821;
static uint32_t qcolorMask = 0xE79CE79C;
static uint32_t qlowpixelMask = 0x18631863;
static uint32_t redblueMask = 0xF81F;
static uint32_t greenMask = 0x7E0;
u32 qRGB_COLOR_MASK[2] = { 0xF7DEF7DE, 0xF7DEF7DE };
uint32_t qRGB_COLOR_MASK[2] = { 0xF7DEF7DE, 0xF7DEF7DE };
extern void hq2x_init(unsigned);
int Init_2xSaI(u32 BitFormat)
int Init_2xSaI(uint32_t BitFormat)
{
if(systemColorDepth == 16) {
if (BitFormat == 565) {
@ -81,8 +81,8 @@ int Init_2xSaI(u32 BitFormat)
return 1;
}
static inline int GetResult1 (u32 A, u32 B, u32 C, u32 D,
u32 /* E */)
static inline int GetResult1 (uint32_t A, uint32_t B, uint32_t C, uint32_t D,
uint32_t /* E */)
{
int x = 0;
int y = 0;
@ -103,8 +103,8 @@ static inline int GetResult1 (u32 A, u32 B, u32 C, u32 D,
return r;
}
static inline int GetResult2 (u32 A, u32 B, u32 C, u32 D,
u32 /* E */)
static inline int GetResult2 (uint32_t A, uint32_t B, uint32_t C, uint32_t D,
uint32_t /* E */)
{
int x = 0;
int y = 0;
@ -125,7 +125,7 @@ static inline int GetResult2 (u32 A, u32 B, u32 C, u32 D,
return r;
}
static inline int GetResult (u32 A, u32 B, u32 C, u32 D)
static inline int GetResult (uint32_t A, uint32_t B, uint32_t C, uint32_t D)
{
int x = 0;
int y = 0;
@ -146,7 +146,7 @@ static inline int GetResult (u32 A, u32 B, u32 C, u32 D)
return r;
}
static inline u32 INTERPOLATE (u32 A, u32 B)
static inline uint32_t INTERPOLATE (uint32_t A, uint32_t B)
{
if (A != B) {
return (((A & colorMask) >> 1) + ((B & colorMask) >> 1) +
@ -155,20 +155,20 @@ static inline u32 INTERPOLATE (u32 A, u32 B)
return A;
}
static inline u32 Q_INTERPOLATE (u32 A, u32 B, u32 C, u32 D)
static inline uint32_t Q_INTERPOLATE (uint32_t A, uint32_t B, uint32_t C, uint32_t D)
{
register u32 x = ((A & qcolorMask) >> 2) +
register uint32_t x = ((A & qcolorMask) >> 2) +
((B & qcolorMask) >> 2) +
((C & qcolorMask) >> 2) + ((D & qcolorMask) >> 2);
register u32 y = (A & qlowpixelMask) +
register uint32_t y = (A & qlowpixelMask) +
(B & qlowpixelMask) + (C & qlowpixelMask) + (D & qlowpixelMask);
y = (y >> 2) & qlowpixelMask;
return x + y;
}
static inline int GetResult1_32 (u32 A, u32 B, u32 C, u32 D,
u32 /* E */)
static inline int GetResult1_32 (uint32_t A, uint32_t B, uint32_t C, uint32_t D,
uint32_t /* E */)
{
int x = 0;
int y = 0;
@ -189,8 +189,8 @@ static inline int GetResult1_32 (u32 A, u32 B, u32 C, u32 D,
return r;
}
static inline int GetResult2_32 (u32 A, u32 B, u32 C, u32 D,
u32 /* E */)
static inline int GetResult2_32 (uint32_t A, uint32_t B, uint32_t C, uint32_t D,
uint32_t /* E */)
{
int x = 0;
int y = 0;
@ -219,14 +219,14 @@ static inline int GetResult2_32 (u32 A, u32 B, u32 C, u32 D,
#define RED_MASK555 0x7C007C00
#define GREEN_MASK555 0x03E003E0
void Super2xSaI (u8 *srcPtr, u32 srcPitch,
u8 *deltaPtr, u8 *dstPtr, u32 dstPitch,
void Super2xSaI (uint8_t *srcPtr, uint32_t srcPitch,
uint8_t *deltaPtr, uint8_t *dstPtr, uint32_t dstPitch,
int width, int height)
{
u16 *bP;
u8 *dP;
u32 inc_bP;
u32 Nextline = srcPitch >> 1;
uint16_t *bP;
uint8_t *dP;
uint32_t inc_bP;
uint32_t Nextline = srcPitch >> 1;
#ifdef MMX
if (cpu_mmx) {
for (; height; height--) {
@ -242,15 +242,15 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
inc_bP = 1;
for (; height; height--) {
bP = (u16 *) srcPtr;
dP = (u8 *) dstPtr;
bP = (uint16_t *) srcPtr;
dP = (uint8_t *) dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6;
u32 color1, color2, color3;
u32 colorA0, colorA1, colorA2, colorA3,
for (uint32_t finish = width; finish; finish -= inc_bP) {
uint32_t color4, color5, color6;
uint32_t color1, color2, color3;
uint32_t colorA0, colorA1, colorA2, colorA3,
colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b;
uint32_t product1a, product1b, product2a, product2b;
//--------------------------------------- B1 B2
// 4 5 6 S2
@ -349,11 +349,11 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
product2a = product2a | (product2b << 16);
#endif
*((u32 *) dP) = product1a;
*((u32 *) (dP + dstPitch)) = product2a;
*((uint32_t *) dP) = product1a;
*((uint32_t *) (dP + dstPitch)) = product2a;
bP += inc_bP;
dP += sizeof (u32);
dP += sizeof (uint32_t);
} // end of for ( finish= width etc..)
srcPtr += srcPitch;
@ -363,26 +363,26 @@ void Super2xSaI (u8 *srcPtr, u32 srcPitch,
}
}
void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch,
void Super2xSaI32 (uint8_t *srcPtr, uint32_t srcPitch,
uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch,
int width, int height)
{
u32 *bP;
u32 *dP;
u32 inc_bP;
u32 Nextline = srcPitch >> 2;
uint32_t *bP;
uint32_t *dP;
uint32_t inc_bP;
uint32_t Nextline = srcPitch >> 2;
inc_bP = 1;
for (; height; height--) {
bP = (u32 *) srcPtr;
dP = (u32 *) dstPtr;
bP = (uint32_t *) srcPtr;
dP = (uint32_t *) dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6;
u32 color1, color2, color3;
u32 colorA0, colorA1, colorA2, colorA3,
for (uint32_t finish = width; finish; finish -= inc_bP) {
uint32_t color4, color5, color6;
uint32_t color1, color2, color3;
uint32_t colorA0, colorA1, colorA2, colorA3,
colorB0, colorB1, colorB2, colorB3, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b;
uint32_t product1a, product1b, product2a, product2b;
//--------------------------------------- B1 B2
// 4 5 6 S2
@ -487,13 +487,13 @@ void Super2xSaI32 (u8 *srcPtr, u32 srcPitch,
} // endof: for (; height; height--)
}
void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height)
void SuperEagle (uint8_t *srcPtr, uint32_t srcPitch, uint8_t *deltaPtr,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *dP;
u16 *bP;
u16 *xP;
u32 inc_bP;
uint8_t *dP;
uint16_t *bP;
uint16_t *xP;
uint32_t inc_bP;
#ifdef MMX
if (cpu_mmx) {
@ -509,17 +509,17 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
{
inc_bP = 1;
u32 Nextline = srcPitch >> 1;
uint32_t Nextline = srcPitch >> 1;
for (; height; height--) {
bP = (u16 *) srcPtr;
xP = (u16 *) deltaPtr;
bP = (uint16_t *) srcPtr;
xP = (uint16_t *) deltaPtr;
dP = dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6;
u32 color1, color2, color3;
u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b;
for (uint32_t finish = width; finish; finish -= inc_bP) {
uint32_t color4, color5, color6;
uint32_t color1, color2, color3;
uint32_t colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
uint32_t product1a, product1b, product2a, product2b;
colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1);
@ -618,13 +618,13 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
product2a = product2a | (product2b << 16);
#endif
*((u32 *) dP) = product1a;
*((u32 *) (dP + dstPitch)) = product2a;
*((uint32_t *) dP) = product1a;
*((uint32_t *) (dP + dstPitch)) = product2a;
*xP = color5;
bP += inc_bP;
xP += inc_bP;
dP += sizeof (u32);
dP += sizeof (uint32_t);
} // end of for ( finish= width etc..)
srcPtr += srcPitch;
@ -634,27 +634,27 @@ void SuperEagle (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
}
}
void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height)
void SuperEagle32 (uint8_t *srcPtr, uint32_t srcPitch, uint8_t *deltaPtr,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u32 *dP;
u32 *bP;
u32 *xP;
u32 inc_bP;
uint32_t *dP;
uint32_t *bP;
uint32_t *xP;
uint32_t inc_bP;
inc_bP = 1;
u32 Nextline = srcPitch >> 2;
uint32_t Nextline = srcPitch >> 2;
for (; height; height--) {
bP = (u32 *) srcPtr;
xP = (u32 *) deltaPtr;
dP = (u32 *)dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
u32 color4, color5, color6;
u32 color1, color2, color3;
u32 colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
u32 product1a, product1b, product2a, product2b;
bP = (uint32_t *) srcPtr;
xP = (uint32_t *) deltaPtr;
dP = (uint32_t *)dstPtr;
for (uint32_t finish = width; finish; finish -= inc_bP) {
uint32_t color4, color5, color6;
uint32_t color1, color2, color3;
uint32_t colorA1, colorA2, colorB1, colorB2, colorS1, colorS2;
uint32_t product1a, product1b, product2a, product2b;
colorB1 = *(bP - Nextline);
colorB2 = *(bP - Nextline + 1);
@ -762,12 +762,12 @@ void SuperEagle32 (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
} // endof: for (height; height; height--)
}
void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height)
void _2xSaI (uint8_t *srcPtr, uint32_t srcPitch, uint8_t *deltaPtr,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *dP;
u16 *bP;
u32 inc_bP;
uint8_t *dP;
uint16_t *bP;
uint32_t inc_bP;
#ifdef MMX
if (cpu_mmx) {
@ -782,21 +782,21 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
{
inc_bP = 1;
u32 Nextline = srcPitch >> 1;
uint32_t Nextline = srcPitch >> 1;
for (; height; height--) {
bP = (u16 *) srcPtr;
bP = (uint16_t *) srcPtr;
dP = dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
for (uint32_t finish = width; finish; finish -= inc_bP) {
register u32 colorA, colorB;
u32 colorC, colorD,
register uint32_t colorA, colorB;
uint32_t colorC, colorD,
colorE, colorF, colorG, colorH,
colorI, colorJ, colorK, colorL,
colorM, colorN, colorO, colorP;
u32 product, product1, product2;
uint32_t product, product1, product2;
//---------------------------------------
// Map of the pixels: I|E F|J
@ -922,11 +922,11 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
product = colorA | (product << 16);
product1 = product1 | (product2 << 16);
#endif
*((s32 *) dP) = product;
*((u32 *) (dP + dstPitch)) = product1;
*((int32_t *) dP) = product;
*((uint32_t *) (dP + dstPitch)) = product1;
bP += inc_bP;
dP += sizeof (u32);
dP += sizeof (uint32_t);
} // end of for ( finish= width etc..)
srcPtr += srcPitch;
@ -936,27 +936,27 @@ void _2xSaI (u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
}
}
void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void _2xSaI32 (uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u32 *dP;
u32 *bP;
u32 inc_bP = 1;
uint32_t *dP;
uint32_t *bP;
uint32_t inc_bP = 1;
u32 Nextline = srcPitch >> 2;
uint32_t Nextline = srcPitch >> 2;
for (; height; height--) {
bP = (u32 *) srcPtr;
dP = (u32 *) dstPtr;
bP = (uint32_t *) srcPtr;
dP = (uint32_t *) dstPtr;
for (u32 finish = width; finish; finish -= inc_bP) {
register u32 colorA, colorB;
u32 colorC, colorD,
for (uint32_t finish = width; finish; finish -= inc_bP) {
register uint32_t colorA, colorB;
uint32_t colorC, colorD,
colorE, colorF, colorG, colorH,
colorI, colorJ, colorK, colorL,
colorM, colorN, colorO, colorP;
u32 product, product1, product2;
uint32_t product, product1, product2;
//---------------------------------------
// Map of the pixels: I|E F|J
@ -1089,7 +1089,7 @@ void _2xSaI32 (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
} // endof: for (height; height; height--)
}
static u32 Bilinear (u32 A, u32 B, u32 x)
static uint32_t Bilinear (uint32_t A, uint32_t B, uint32_t x)
{
unsigned long areaA, areaB;
unsigned long result;
@ -1108,8 +1108,8 @@ static u32 Bilinear (u32 A, u32 B, u32 x)
return (result & redblueMask) | ((result >> 16) & greenMask);
}
static u32 Bilinear4 (u32 A, u32 B, u32 C, u32 D, u32 x,
u32 y)
static uint32_t Bilinear4 (uint32_t A, uint32_t B, uint32_t C, uint32_t D, uint32_t x,
uint32_t y)
{
unsigned long areaA, areaB, areaC, areaD;
unsigned long result, xy;
@ -1133,21 +1133,21 @@ static u32 Bilinear4 (u32 A, u32 B, u32 C, u32 D, u32 x,
return (result & redblueMask) | ((result >> 16) & greenMask);
}
void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch,
u32 dstWidth, u32 dstHeight, int width, int height)
void Scale_2xSaI (uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch,
uint32_t dstWidth, uint32_t dstHeight, int width, int height)
{
u8 *dP;
u16 *bP;
uint8_t *dP;
uint16_t *bP;
u32 w;
u32 h;
u32 dw;
u32 dh;
u32 hfinish;
u32 wfinish;
uint32_t w;
uint32_t h;
uint32_t dw;
uint32_t dh;
uint32_t hfinish;
uint32_t wfinish;
u32 Nextline = srcPitch >> 1;
uint32_t Nextline = srcPitch >> 1;
wfinish = (width - 1) << 16; // convert to fixed point
dw = wfinish / (dstWidth - 1);
@ -1155,21 +1155,21 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dh = hfinish / (dstHeight - 1);
for (h = 0; h < hfinish; h += dh) {
u32 y1, y2;
uint32_t y1, y2;
y1 = h & 0xffff; // fraction part of fixed point
bP = (u16 *) (srcPtr + ((h >> 16) * srcPitch));
bP = (uint16_t *) (srcPtr + ((h >> 16) * srcPitch));
dP = dstPtr;
y2 = 0x10000 - y1;
w = 0;
for (; w < wfinish;) {
u32 A, B, C, D;
u32 E, F, G, H;
u32 I, J, K, L;
u32 x1, x2, a1, f1, f2;
u32 position, product1;
uint32_t A, B, C, D;
uint32_t E, F, G, H;
uint32_t I, J, K, L;
uint32_t x1, x2, a1, f1, f2;
uint32_t position, product1;
position = w >> 16;
A = bP[position]; // current pixel
@ -1268,7 +1268,7 @@ void Scale_2xSaI (u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
}
//end First Pixel
*(u32 *) dP = product1;
*(uint32_t *) dP = product1;
dP += 2;
w += dw;
}

View File

@ -41,7 +41,7 @@
extern "C" bool cpu_mmx;
#endif
static void internal_scale2x_16_def(u16 *dst, const u16* src0, const u16* src1, const u16* src2, unsigned count) {
static void internal_scale2x_16_def(uint16_t *dst, const uint16_t* src0, const uint16_t* src1, const uint16_t* src2, unsigned count) {
/* first pixel */
dst[0] = src1[0];
if (src1[1] == src0[0] && src2[0] != src0[0])
@ -79,10 +79,10 @@ static void internal_scale2x_16_def(u16 *dst, const u16* src0, const u16* src1,
dst[1] = src1[0];
}
static void internal_scale2x_32_def(u32* dst,
const u32* src0,
const u32* src1,
const u32* src2,
static void internal_scale2x_32_def(uint32_t* dst,
const uint32_t* src0,
const uint32_t* src1,
const uint32_t* src2,
unsigned count)
{
/* first pixel */
@ -123,7 +123,7 @@ static void internal_scale2x_32_def(u32* dst,
}
#ifdef MMX
static void internal_scale2x_16_mmx_single(u16* dst, const u16* src0, const u16* src1, const u16* src2, unsigned count) {
static void internal_scale2x_16_mmx_single(uint16_t* dst, const uint16_t* src0, const uint16_t* src1, const uint16_t* src2, unsigned count) {
/* always do the first and last run */
count -= 2*4;
@ -505,7 +505,7 @@ static void internal_scale2x_16_mmx_single(u16* dst, const u16* src0, const u16*
#endif
}
static void internal_scale2x_32_mmx_single(u32* dst, const u32* src0, const u32* src1, const u32* src2, unsigned count) {
static void internal_scale2x_32_mmx_single(uint32_t* dst, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count) {
/* always do the first and last run */
count -= 2*2;
@ -886,28 +886,28 @@ label1:
#endif
}
static void internal_scale2x_16_mmx(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count) {
static void internal_scale2x_16_mmx(uint16_t* dst0, uint16_t* dst1, const uint16_t* src0, const uint16_t* src1, const uint16_t* src2, unsigned count) {
// assert( count >= 2*4 );
internal_scale2x_16_mmx_single(dst0, src0, src1, src2, count);
internal_scale2x_16_mmx_single(dst1, src2, src1, src0, count);
}
static void internal_scale2x_32_mmx(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count) {
static void internal_scale2x_32_mmx(uint32_t* dst0, uint32_t* dst1, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count) {
// assert( count >= 2*2 );
internal_scale2x_32_mmx_single(dst0, src0, src1, src2, count);
internal_scale2x_32_mmx_single(dst1, src2, src1, src0, count);
}
#endif
void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void AdMame2x(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1);
uint16_t *dst0 = (uint16_t *)dstPtr;
uint16_t *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1);
uint16_t *src0 = (uint16_t *)srcPtr;
uint16_t *src1 = src0 + (srcPitch >> 1);
uint16_t *src2 = src1 + (srcPitch >> 1);
#ifdef MMX
if(cpu_mmx) {
internal_scale2x_16_mmx(dst0, dst1, src0, src0, src1, width);
@ -954,15 +954,15 @@ void AdMame2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
#endif
}
void AdMame2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void AdMame2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u32 *dst0 = (u32 *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2);
uint32_t *dst0 = (uint32_t *)dstPtr;
uint32_t *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2);
uint32_t *src0 = (uint32_t *)srcPtr;
uint32_t *src1 = src0 + (srcPitch >> 2);
uint32_t *src2 = src1 + (srcPitch >> 2);
#ifdef MMX
if(cpu_mmx) {
internal_scale2x_32_mmx(dst0, dst1, src0, src0, src1, width);

View File

@ -10,19 +10,19 @@
((g) >> 3) << systemGreenShift |\
((b) >> 3) << systemBlueShift\
static void fill_rgb_row_16(u16 *from, int src_width, u8 *row, int width)
static void fill_rgb_row_16(uint16_t *from, int src_width, uint8_t *row, int width)
{
u8 *copy_start = row + src_width*3;
u8 *all_stop = row + width*3;
uint8_t *copy_start = row + src_width*3;
uint8_t *all_stop = row + width*3;
while (row < copy_start) {
u16 color = *from++;
uint16_t color = *from++;
*row++ = ((color >> systemRedShift) & 0x1f) << 3;
*row++ = ((color >> systemGreenShift) & 0x1f) << 3;
*row++ = ((color >> systemBlueShift) & 0x1f) << 3;
}
// any remaining elements to be written to 'row' are a replica of the
// preceding pixel
u8 *p = row-3;
uint8_t *p = row-3;
while (row < all_stop) {
// we're guaranteed three elements per pixel; could unroll the loop
// further, especially with a Duff's Device, but the gains would be
@ -33,19 +33,19 @@ static void fill_rgb_row_16(u16 *from, int src_width, u8 *row, int width)
}
}
static void fill_rgb_row_32(u32 *from, int src_width, u8 *row, int width)
static void fill_rgb_row_32(uint32_t *from, int src_width, uint8_t *row, int width)
{
u8 *copy_start = row + src_width*3;
u8 *all_stop = row + width*3;
uint8_t *copy_start = row + src_width*3;
uint8_t *all_stop = row + width*3;
while (row < copy_start) {
u32 color = *from++;
uint32_t color = *from++;
*row++ = ((color >> systemRedShift) & 0x1f) << 3;
*row++ = ((color >> systemGreenShift) & 0x1f) << 3;
*row++ = ((color >> systemBlueShift) & 0x1f) << 3;
}
// any remaining elements to be written to 'row' are a replica of the
// preceding pixel
u8 *p = row-3;
uint8_t *p = row-3;
while (row < all_stop) {
// we're guaranteed three elements per pixel; could unroll the loop
// further, especially with a Duff's Device, but the gains would be
@ -56,24 +56,24 @@ static void fill_rgb_row_32(u32 *from, int src_width, u8 *row, int width)
}
}
void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Bilinear(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 row_cur[3*322];
u8 row_next[3*322];
u8 *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next;
uint8_t row_cur[3*322];
uint8_t row_next[3*322];
uint8_t *rgb_row_cur = row_cur;
uint8_t *rgb_row_next = row_next;
u16 *to = (u16 *)dstPtr;
u16 *to_odd = (u16 *)(dstPtr + dstPitch);
uint16_t *to = (uint16_t *)dstPtr;
uint16_t *to_odd = (uint16_t *)(dstPtr + dstPitch);
int from_width = width;
u16 *from = (u16 *)srcPtr;
uint16_t *from = (uint16_t *)srcPtr;
fill_rgb_row_16(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) {
u16 *from_orig = from;
u16 *to_orig = to;
uint16_t *from_orig = from;
uint16_t *to_orig = to;
if (y+1 < height)
fill_rgb_row_16(from+width+2, from_width, rgb_row_next,
@ -86,21 +86,21 @@ void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// pixel is 'a', then in what follows 'b' is the src pixel to the
// right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down
u8 *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next;
u8 *ar = cur_row++;
u8 *ag = cur_row++;
u8 *ab = cur_row++;
u8 *cr = next_row++;
u8 *cg = next_row++;
u8 *cb = next_row++;
uint8_t *cur_row = rgb_row_cur;
uint8_t *next_row = rgb_row_next;
uint8_t *ar = cur_row++;
uint8_t *ag = cur_row++;
uint8_t *ab = cur_row++;
uint8_t *cr = next_row++;
uint8_t *cg = next_row++;
uint8_t *cb = next_row++;
for(int x=0; x < width; x++) {
u8 *br = cur_row++;
u8 *bg = cur_row++;
u8 *bb = cur_row++;
u8 *dr = next_row++;
u8 *dg = next_row++;
u8 *db = next_row++;
uint8_t *br = cur_row++;
uint8_t *bg = cur_row++;
uint8_t *bb = cur_row++;
uint8_t *dr = next_row++;
uint8_t *dg = next_row++;
uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in
*to++ = RGB(*ar, *ag, *ab);
@ -127,36 +127,36 @@ void Bilinear(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row
u8 *temp;
uint8_t *temp;
temp = rgb_row_cur;
rgb_row_cur = rgb_row_next;
rgb_row_next = temp;
// update the pointers for start of next pair of lines
from = (u16 *)((u8 *)from_orig + srcPitch);
to = (u16 *)((u8 *)to_orig + (dstPitch << 1));
to_odd = (u16 *)((u8 *)to + dstPitch);
from = (uint16_t *)((uint8_t *)from_orig + srcPitch);
to = (uint16_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (uint16_t *)((uint8_t *)to + dstPitch);
}
}
void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void BilinearPlus(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 row_cur[3*322];
u8 row_next[3*322];
u8 *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next;
uint8_t row_cur[3*322];
uint8_t row_next[3*322];
uint8_t *rgb_row_cur = row_cur;
uint8_t *rgb_row_next = row_next;
u16 *to = (u16 *)dstPtr;
u16 *to_odd = (u16 *)(dstPtr + dstPitch);
uint16_t *to = (uint16_t *)dstPtr;
uint16_t *to_odd = (uint16_t *)(dstPtr + dstPitch);
int from_width = width;
u16 *from = (u16 *)srcPtr;
uint16_t *from = (uint16_t *)srcPtr;
fill_rgb_row_16(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) {
u16 *from_orig = from;
u16 *to_orig = to;
uint16_t *from_orig = from;
uint16_t *to_orig = to;
if (y+1 < height)
fill_rgb_row_16(from+width+2, from_width, rgb_row_next,
@ -169,21 +169,21 @@ void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// pixel is 'a', then in what follows 'b' is the src pixel to the
// right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down
u8 *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next;
u8 *ar = cur_row++;
u8 *ag = cur_row++;
u8 *ab = cur_row++;
u8 *cr = next_row++;
u8 *cg = next_row++;
u8 *cb = next_row++;
uint8_t *cur_row = rgb_row_cur;
uint8_t *next_row = rgb_row_next;
uint8_t *ar = cur_row++;
uint8_t *ag = cur_row++;
uint8_t *ab = cur_row++;
uint8_t *cr = next_row++;
uint8_t *cg = next_row++;
uint8_t *cb = next_row++;
for(int x=0; x < width; x++) {
u8 *br = cur_row++;
u8 *bg = cur_row++;
u8 *bb = cur_row++;
u8 *dr = next_row++;
u8 *dg = next_row++;
u8 *db = next_row++;
uint8_t *br = cur_row++;
uint8_t *bg = cur_row++;
uint8_t *bb = cur_row++;
uint8_t *dr = next_row++;
uint8_t *dg = next_row++;
uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in
//*to++ = manip.rgb(*ar, *ag, *ab);
@ -221,37 +221,37 @@ void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row
u8 *temp;
uint8_t *temp;
temp = rgb_row_cur;
rgb_row_cur = rgb_row_next;
rgb_row_next = temp;
// update the pointers for start of next pair of lines
from = (u16 *)((u8 *)from_orig + srcPitch);
to = (u16 *)((u8 *)to_orig + (dstPitch << 1));
to_odd = (u16 *)((u8 *)to + dstPitch);
from = (uint16_t *)((uint8_t *)from_orig + srcPitch);
to = (uint16_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (uint16_t *)((uint8_t *)to + dstPitch);
}
}
void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Bilinear32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 row_cur[3*322];
u8 row_next[3*322];
u8 *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next;
uint8_t row_cur[3*322];
uint8_t row_next[3*322];
uint8_t *rgb_row_cur = row_cur;
uint8_t *rgb_row_next = row_next;
u32 *to = (u32 *)dstPtr;
u32 *to_odd = (u32 *)(dstPtr + dstPitch);
uint32_t *to = (uint32_t *)dstPtr;
uint32_t *to_odd = (uint32_t *)(dstPtr + dstPitch);
int from_width = width;
u32 *from = (u32 *)srcPtr;
uint32_t *from = (uint32_t *)srcPtr;
fill_rgb_row_32(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) {
u32 *from_orig = from;
u32 *to_orig = to;
uint32_t *from_orig = from;
uint32_t *to_orig = to;
if (y+1 < height)
fill_rgb_row_32(from+width+1, from_width, rgb_row_next,
@ -264,21 +264,21 @@ void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// pixel is 'a', then in what follows 'b' is the src pixel to the
// right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down
u8 *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next;
u8 *ar = cur_row++;
u8 *ag = cur_row++;
u8 *ab = cur_row++;
u8 *cr = next_row++;
u8 *cg = next_row++;
u8 *cb = next_row++;
uint8_t *cur_row = rgb_row_cur;
uint8_t *next_row = rgb_row_next;
uint8_t *ar = cur_row++;
uint8_t *ag = cur_row++;
uint8_t *ab = cur_row++;
uint8_t *cr = next_row++;
uint8_t *cg = next_row++;
uint8_t *cb = next_row++;
for(int x=0; x < width; x++) {
u8 *br = cur_row++;
u8 *bg = cur_row++;
u8 *bb = cur_row++;
u8 *dr = next_row++;
u8 *dg = next_row++;
u8 *db = next_row++;
uint8_t *br = cur_row++;
uint8_t *bg = cur_row++;
uint8_t *bb = cur_row++;
uint8_t *dr = next_row++;
uint8_t *dg = next_row++;
uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in
*to++ = RGB(*ar, *ag, *ab);
@ -305,37 +305,37 @@ void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row
u8 *temp;
uint8_t *temp;
temp = rgb_row_cur;
rgb_row_cur = rgb_row_next;
rgb_row_next = temp;
// update the pointers for start of next pair of lines
from = (u32 *)((u8 *)from_orig + srcPitch);
to = (u32 *)((u8 *)to_orig + (dstPitch << 1));
to_odd = (u32 *)((u8 *)to + dstPitch);
from = (uint32_t *)((uint8_t *)from_orig + srcPitch);
to = (uint32_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (uint32_t *)((uint8_t *)to + dstPitch);
}
}
void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void BilinearPlus32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 row_cur[3*322];
u8 row_next[3*322];
u8 *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next;
uint8_t row_cur[3*322];
uint8_t row_next[3*322];
uint8_t *rgb_row_cur = row_cur;
uint8_t *rgb_row_next = row_next;
u32 *to = (u32 *)dstPtr;
u32 *to_odd = (u32 *)(dstPtr + dstPitch);
uint32_t *to = (uint32_t *)dstPtr;
uint32_t *to_odd = (uint32_t *)(dstPtr + dstPitch);
int from_width = width;
u32 *from = (u32 *)srcPtr;
uint32_t *from = (uint32_t *)srcPtr;
fill_rgb_row_32(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) {
u32 *from_orig = from;
u32 *to_orig = to;
uint32_t *from_orig = from;
uint32_t *to_orig = to;
if (y+1 < height)
fill_rgb_row_32(from+width+1, from_width, rgb_row_next,
@ -348,21 +348,21 @@ void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// pixel is 'a', then in what follows 'b' is the src pixel to the
// right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down
u8 *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next;
u8 *ar = cur_row++;
u8 *ag = cur_row++;
u8 *ab = cur_row++;
u8 *cr = next_row++;
u8 *cg = next_row++;
u8 *cb = next_row++;
uint8_t *cur_row = rgb_row_cur;
uint8_t *next_row = rgb_row_next;
uint8_t *ar = cur_row++;
uint8_t *ag = cur_row++;
uint8_t *ab = cur_row++;
uint8_t *cr = next_row++;
uint8_t *cg = next_row++;
uint8_t *cb = next_row++;
for(int x=0; x < width; x++) {
u8 *br = cur_row++;
u8 *bg = cur_row++;
u8 *bb = cur_row++;
u8 *dr = next_row++;
u8 *dg = next_row++;
u8 *db = next_row++;
uint8_t *br = cur_row++;
uint8_t *bg = cur_row++;
uint8_t *bb = cur_row++;
uint8_t *dr = next_row++;
uint8_t *dg = next_row++;
uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in
//*to++ = manip.rgb(*ar, *ag, *ab);
@ -400,15 +400,15 @@ void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
// the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row
u8 *temp;
uint8_t *temp;
temp = rgb_row_cur;
rgb_row_cur = rgb_row_next;
rgb_row_next = temp;
// update the pointers for start of next pair of lines
from = (u32 *)((u8 *)from_orig + srcPitch);
to = (u32 *)((u8 *)to_orig + (dstPitch << 1));
to_odd = (u32 *)((u8 *)to + dstPitch);
from = (uint32_t *)((uint8_t *)from_orig + srcPitch);
to = (uint32_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (uint32_t *)((uint8_t *)to + dstPitch);
}
}

View File

@ -2362,7 +2362,7 @@ NEWSYM hq3x_16
mov [edi+ebx*2],eax
mov [edi+ebx*2+4],dx
jmp .loopx_end
..@cross8
..@crosint8_t
mov edx,eax
shl eax,16
or eax,edx
@ -2526,6 +2526,6 @@ FuncTable
FuncTable2
dd ..@cross0, ..@cross1, ..@cross2, ..@flag0,
dd ..@cross4, ..@flag0, ..@flag0, ..@flag0,
dd ..@cross8, ..@flag0, ..@flag0, ..@flag0,
dd ..@crosint8_t, ..@flag0, ..@flag0, ..@flag0,
dd ..@flag0, ..@flag0, ..@flag0, ..@flag0

View File

@ -2393,7 +2393,7 @@ NEWSYM hq3x_32
mov [edi+ebx*2+4],eax
mov [edi+ebx*2+8],edx
jmp .loopx_end
..@cross8
..@crosint8_t
mov ecx,[ebp-w8]
mov edx,eax
shl edx,2
@ -2570,6 +2570,6 @@ FuncTable
FuncTable2
dd ..@cross0, ..@cross1, ..@cross2, ..@crossN,
dd ..@cross4, ..@crossN, ..@crossN, ..@crossN,
dd ..@cross8, ..@crossN, ..@crossN, ..@crossN,
dd ..@crosint8_t, ..@crossN, ..@crossN, ..@crossN,
dd ..@crossN, ..@crossN, ..@crossN, ..@crossN

View File

@ -37,14 +37,14 @@
* This effect is a rewritten implementation of the hq2x effect made by Maxim Stepin
*/
static void hq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
static void hq2x_16_def(uint16_t* dst0, uint16_t* dst1, const uint16_t* src0, const uint16_t* src1, const uint16_t* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u16 c[9];
uint16_t c[9];
c[1] = src0[0];
c[4] = src1[0];
@ -147,14 +147,14 @@ static void hq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1,
}
}
static void hq2x_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count)
static void hq2x_32_def(uint32_t* dst0, uint32_t* dst1, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u32 c[9];
uint32_t c[9];
c[1] = src0[0];
c[4] = src1[0];
@ -264,14 +264,14 @@ static void hq2x_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1,
* This effect is derived from the hq2x effect made by Maxim Stepin
*/
static void lq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1, const u16* src2, unsigned count)
static void lq2x_16_def(uint16_t* dst0, uint16_t* dst1, const uint16_t* src0, const uint16_t* src1, const uint16_t* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u16 c[9];
uint16_t c[9];
c[1] = src0[0];
c[4] = src1[0];
@ -374,14 +374,14 @@ static void lq2x_16_def(u16* dst0, u16* dst1, const u16* src0, const u16* src1,
}
}
static void lq2x_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1, const u32* src2, unsigned count)
static void lq2x_32_def(uint32_t* dst0, uint32_t* dst1, const uint32_t* src0, const uint32_t* src1, const uint32_t* src2, unsigned count)
{
unsigned i;
for(i=0;i<count;++i) {
unsigned char mask;
u32 c[9];
uint32_t c[9];
c[1] = src0[0];
c[4] = src1[0];
@ -484,15 +484,15 @@ static void lq2x_32_def(u32* dst0, u32* dst1, const u32* src0, const u32* src1,
}
}
void hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void hq2x(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1);
uint16_t *dst0 = (uint16_t *)dstPtr;
uint16_t *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1);
uint16_t *src0 = (uint16_t *)srcPtr;
uint16_t *src1 = src0 + (srcPitch >> 1);
uint16_t *src2 = src1 + (srcPitch >> 1);
hq2x_16_def(dst0, dst1, src0, src0, src1, width);
@ -513,15 +513,15 @@ void hq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
hq2x_16_def(dst0, dst1, src0, src1, src1, width);
}
void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void hq2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u32 *dst0 = (u32 *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2);
uint32_t *dst0 = (uint32_t *)dstPtr;
uint32_t *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2);
uint32_t *src0 = (uint32_t *)srcPtr;
uint32_t *src1 = src0 + (srcPitch >> 2);
uint32_t *src2 = src1 + (srcPitch >> 2);
hq2x_32_def(dst0, dst1, src0, src0, src1, width);
int count = height;
@ -541,15 +541,15 @@ void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
hq2x_32_def(dst0, dst1, src0, src1, src1, width);
}
void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void lq2x(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u16 *dst0 = (u16 *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1);
uint16_t *dst0 = (uint16_t *)dstPtr;
uint16_t *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1);
uint16_t *src0 = (uint16_t *)srcPtr;
uint16_t *src1 = src0 + (srcPitch >> 1);
uint16_t *src2 = src1 + (srcPitch >> 1);
lq2x_16_def(dst0, dst1, src0, src0, src1, width);
@ -570,15 +570,15 @@ void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
lq2x_16_def(dst0, dst1, src0, src1, src1, width);
}
void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void lq2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u32 *dst0 = (u32 *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2);
uint32_t *dst0 = (uint32_t *)dstPtr;
uint32_t *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2);
uint32_t *src0 = (uint32_t *)srcPtr;
uint32_t *src1 = src0 + (srcPitch >> 2);
uint32_t *src2 = src1 + (srcPitch >> 2);
lq2x_32_def(dst0, dst1, src0, src0, src1, width);
int count = height;

View File

@ -12,20 +12,20 @@ extern "C" bool cpu_mmx;
Incorporated into vba by Anthony Di Franco
*/
static u8 *frm1 = NULL;
static u8 *frm2 = NULL;
static u8 *frm3 = NULL;
static uint8_t *frm1 = NULL;
static uint8_t *frm2 = NULL;
static uint8_t *frm3 = NULL;
extern int RGB_LOW_BITS_MASK;
extern u32 qRGB_COLOR_MASK[2];
extern uint32_t qRGB_COLOR_MASK[2];
static void Init()
{
frm1 = (u8 *)calloc(322*242,4);
frm1 = (uint8_t *)calloc(322*242,4);
// 1 frame ago
frm2 = (u8 *)calloc(322*242,4);
frm2 = (uint8_t *)calloc(322*242,4);
// 2 frames ago
frm3 = (u8 *)calloc(322*242,4);
frm3 = (uint8_t *)calloc(322*242,4);
// 3 frames ago
}
@ -41,12 +41,12 @@ void InterframeCleanup()
}
#ifdef MMX
static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
static void SmartIB_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
u16 *src0 = (u16 *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + srcPitch * starty / 2;
u16 *src2 = (u16 *)frm2 + srcPitch * starty / 2;
u16 *src3 = (u16 *)frm3 + srcPitch * starty / 2;
uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
uint16_t *src1 = (uint16_t *)frm1 + srcPitch * starty / 2;
uint16_t *src2 = (uint16_t *)frm2 + srcPitch * starty / 2;
uint16_t *src3 = (uint16_t *)frm3 + srcPitch * starty / 2;
int count = width >> 2;
@ -152,14 +152,14 @@ static void SmartIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, int hei
}
/* Swap buffers around */
u8 *temp = frm1;
uint8_t *temp = frm1;
frm1 = frm3;
frm3 = frm2;
frm2 = temp;
}
#endif
void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
void SmartIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
if(frm1 == NULL) {
Init();
@ -171,19 +171,19 @@ void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
#endif
u16 colorMask = ~RGB_LOW_BITS_MASK;
uint16_t colorMask = ~RGB_LOW_BITS_MASK;
u16 *src0 = (u16 *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + srcPitch * starty / 2;
u16 *src2 = (u16 *)frm2 + srcPitch * starty / 2;
u16 *src3 = (u16 *)frm3 + srcPitch * starty / 2;
uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
uint16_t *src1 = (uint16_t *)frm1 + srcPitch * starty / 2;
uint16_t *src2 = (uint16_t *)frm2 + srcPitch * starty / 2;
uint16_t *src3 = (uint16_t *)frm3 + srcPitch * starty / 2;
int sPitch = srcPitch >> 1;
int pos = 0;
for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) {
u16 color = src0[pos];
uint16_t color = src0[pos];
src0[pos] =
(src1[pos] != src2[pos]) &&
(src3[pos] != color) &&
@ -195,24 +195,24 @@ void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
/* Swap buffers around */
u8 *temp = frm1;
uint8_t *temp = frm1;
frm1 = frm3;
frm3 = frm2;
frm2 = temp;
}
void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int height)
void SmartIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int height)
{
SmartIB(srcPtr, srcPitch, width, 0, height);
}
#ifdef MMX
static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
static void SmartIB32_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4;
u32 *src2 = (u32 *)frm2 + starty * srcPitch / 4;
u32 *src3 = (u32 *)frm3 + starty * srcPitch / 4;
uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
uint32_t *src2 = (uint32_t *)frm2 + starty * srcPitch / 4;
uint32_t *src3 = (uint32_t *)frm3 + starty * srcPitch / 4;
int count = width >> 1;
@ -318,14 +318,14 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, int h
src3++;
}
/* Swap buffers around */
u8 *temp = frm1;
uint8_t *temp = frm1;
frm1 = frm3;
frm3 = frm2;
frm2 = temp;
}
#endif
void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
void SmartIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
if(frm1 == NULL) {
Init();
@ -337,19 +337,19 @@ void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
#endif
u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4;
u32 *src2 = (u32 *)frm2 + starty * srcPitch / 4;
u32 *src3 = (u32 *)frm3 + starty * srcPitch / 4;
uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
uint32_t *src2 = (uint32_t *)frm2 + starty * srcPitch / 4;
uint32_t *src3 = (uint32_t *)frm3 + starty * srcPitch / 4;
u32 colorMask = 0xfefefe;
uint32_t colorMask = 0xfefefe;
int sPitch = srcPitch >> 2;
int pos = 0;
for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) {
u32 color = src0[pos];
uint32_t color = src0[pos];
src0[pos] =
(src1[pos] != src2[pos]) &&
(src3[pos] != color) &&
@ -361,22 +361,22 @@ void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
/* Swap buffers around */
u8 *temp = frm1;
uint8_t *temp = frm1;
frm1 = frm3;
frm3 = frm2;
frm2 = temp;
}
void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
void SmartIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int height)
{
SmartIB32(srcPtr, srcPitch, width, 0, height);
}
#ifdef MMX
static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
static void MotionBlurIB_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
u16 *src0 = (u16 *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + starty * srcPitch / 2;
uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
uint16_t *src1 = (uint16_t *)frm1 + starty * srcPitch / 2;
int count = width >> 2;
@ -441,7 +441,7 @@ static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, in
}
#endif
void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
void MotionBlurIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
if(frm1 == NULL) {
Init();
@ -454,17 +454,17 @@ void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
#endif
u16 colorMask = ~RGB_LOW_BITS_MASK;
uint16_t colorMask = ~RGB_LOW_BITS_MASK;
u16 *src0 = (u16 *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + starty * srcPitch / 2;
uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
uint16_t *src1 = (uint16_t *)frm1 + starty * srcPitch / 2;
int sPitch = srcPitch >> 1;
int pos = 0;
for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) {
u16 color = src0[pos];
uint16_t color = src0[pos];
src0[pos] =
(((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1));
src1[pos] = color;
@ -472,16 +472,16 @@ void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
}
void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int height)
void MotionBlurIB(uint8_t *srcPtr, uint32_t srcPitch, int width, int height)
{
MotionBlurIB(srcPtr, srcPitch, width, 0, height);
}
#ifdef MMX
static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
static void MotionBlurIB32_MMX(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4;
uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
int count = width >> 1;
@ -546,7 +546,7 @@ static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty,
}
#endif
void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
void MotionBlurIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int starty, int height)
{
if(frm1 == NULL) {
Init();
@ -559,17 +559,17 @@ void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
#endif
u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4;
uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
u32 colorMask = 0xfefefe;
uint32_t colorMask = 0xfefefe;
int sPitch = srcPitch >> 2;
int pos = 0;
for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) {
u32 color = src0[pos];
uint32_t color = src0[pos];
src0[pos] = (((color & colorMask) >> 1) +
((src1[pos] & colorMask) >> 1));
src1[pos] = color;
@ -577,7 +577,7 @@ void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
}
}
void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int height)
void MotionBlurIB32(uint8_t *srcPtr, uint32_t srcPitch, int width, int height)
{
MotionBlurIB32(srcPtr, srcPitch, width, 0, height);
}

View File

@ -50,7 +50,7 @@ static unsigned interp_bits_per_pixel;
#define INTERP_16_MASK_1(v) (v & interp_mask[0])
#define INTERP_16_MASK_2(v) (v & interp_mask[1])
static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3)
static inline uint16_t interp_16_521(uint16_t p1, uint16_t p2, uint16_t p3)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 5 + INTERP_16_MASK_1(p2) * 2 +
INTERP_16_MASK_1(p3) * 1) /
@ -60,7 +60,7 @@ static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3)
8);
}
static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3)
static inline uint16_t interp_16_332(uint16_t p1, uint16_t p2, uint16_t p3)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 3 + INTERP_16_MASK_1(p2) * 3 +
INTERP_16_MASK_1(p3) * 2) /
@ -70,7 +70,7 @@ static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3)
8);
}
static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3)
static inline uint16_t interp_16_611(uint16_t p1, uint16_t p2, uint16_t p3)
{
return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8) |
@ -78,13 +78,13 @@ static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3)
(INTERP_16_MASK_2(p1) * 6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8);
}
static inline u16 interp_16_71(u16 p1, u16 p2)
static inline uint16_t interp_16_71(uint16_t p1, uint16_t p2)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 7 + INTERP_16_MASK_1(p2)) / 8) |
INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 7 + INTERP_16_MASK_2(p2)) / 8);
}
static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3)
static inline uint16_t interp_16_211(uint16_t p1, uint16_t p2, uint16_t p3)
{
return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4) |
@ -92,7 +92,7 @@ static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3)
(INTERP_16_MASK_2(p1) * 2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4);
}
static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3)
static inline uint16_t interp_16_772(uint16_t p1, uint16_t p2, uint16_t p3)
{
return INTERP_16_MASK_1(
((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) * 7 + INTERP_16_MASK_1(p3) * 2) /
@ -102,19 +102,19 @@ static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3)
16);
}
static inline u16 interp_16_11(u16 p1, u16 p2)
static inline uint16_t interp_16_11(uint16_t p1, uint16_t p2)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2) |
INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2);
}
static inline u16 interp_16_31(u16 p1, u16 p2)
static inline uint16_t interp_16_31(uint16_t p1, uint16_t p2)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 3 + INTERP_16_MASK_1(p2)) / 4) |
INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 3 + INTERP_16_MASK_2(p2)) / 4);
}
static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3)
static inline uint16_t interp_16_1411(uint16_t p1, uint16_t p2, uint16_t p3)
{
return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16) |
@ -122,7 +122,7 @@ static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3)
(INTERP_16_MASK_2(p1) * 14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16);
}
static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3)
static inline uint16_t interp_16_431(uint16_t p1, uint16_t p2, uint16_t p3)
{
return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 4 + INTERP_16_MASK_1(p2) * 3 + INTERP_16_MASK_1(p3)) /
@ -132,19 +132,19 @@ static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3)
8);
}
static inline u16 interp_16_53(u16 p1, u16 p2)
static inline uint16_t interp_16_53(uint16_t p1, uint16_t p2)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 5 + INTERP_16_MASK_1(p2) * 3) / 8) |
INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 5 + INTERP_16_MASK_2(p2) * 3) / 8);
}
static inline u16 interp_16_151(u16 p1, u16 p2)
static inline uint16_t interp_16_151(uint16_t p1, uint16_t p2)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 15 + INTERP_16_MASK_1(p2)) / 16) |
INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 15 + INTERP_16_MASK_2(p2)) / 16);
}
static inline u16 interp_16_97(u16 p1, u16 p2)
static inline uint16_t interp_16_97(uint16_t p1, uint16_t p2)
{
return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 9 + INTERP_16_MASK_1(p2) * 7) / 16) |
INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 9 + INTERP_16_MASK_2(p2) * 7) / 16);
@ -153,7 +153,7 @@ static inline u16 interp_16_97(u16 p1, u16 p2)
#define INTERP_32_MASK_1(v) (v & 0xFF00FF)
#define INTERP_32_MASK_2(v) (v & 0x00FF00)
static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3)
static inline uint32_t interp_32_521(uint32_t p1, uint32_t p2, uint32_t p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 5 + INTERP_32_MASK_1(p2) * 2 +
INTERP_32_MASK_1(p3) * 1) /
@ -163,7 +163,7 @@ static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3)
8);
}
static inline u32 interp_32_332(u32 p1, u32 p2, u32 p3)
static inline uint32_t interp_32_332(uint32_t p1, uint32_t p2, uint32_t p3)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 3 + INTERP_32_MASK_1(p2) * 3 +
INTERP_32_MASK_1(p3) * 2) /
@ -173,7 +173,7 @@ static inline u32 interp_32_332(u32 p1, u32 p2, u32 p3)
8);
}
static inline u32 interp_32_211(u32 p1, u32 p2, u32 p3)
static inline uint32_t interp_32_211(uint32_t p1, uint32_t p2, uint32_t p3)
{
return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4) |
@ -181,7 +181,7 @@ static inline u32 interp_32_211(u32 p1, u32 p2, u32 p3)
(INTERP_32_MASK_2(p1) * 2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4);
}
static inline u32 interp_32_611(u32 p1, u32 p2, u32 p3)
static inline uint32_t interp_32_611(uint32_t p1, uint32_t p2, uint32_t p3)
{
return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8) |
@ -189,13 +189,13 @@ static inline u32 interp_32_611(u32 p1, u32 p2, u32 p3)
(INTERP_32_MASK_2(p1) * 6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8);
}
static inline u32 interp_32_71(u32 p1, u32 p2)
static inline uint32_t interp_32_71(uint32_t p1, uint32_t p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 7 + INTERP_32_MASK_1(p2)) / 8) |
INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 7 + INTERP_32_MASK_2(p2)) / 8);
}
static inline u32 interp_32_772(u32 p1, u32 p2, u32 p3)
static inline uint32_t interp_32_772(uint32_t p1, uint32_t p2, uint32_t p3)
{
return INTERP_32_MASK_1(
((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) * 7 + INTERP_32_MASK_1(p3) * 2) /
@ -205,19 +205,19 @@ static inline u32 interp_32_772(u32 p1, u32 p2, u32 p3)
16);
}
static inline u32 interp_32_11(u32 p1, u32 p2)
static inline uint32_t interp_32_11(uint32_t p1, uint32_t p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2) |
INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2);
}
static inline u32 interp_32_31(u32 p1, u32 p2)
static inline uint32_t interp_32_31(uint32_t p1, uint32_t p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 3 + INTERP_32_MASK_1(p2)) / 4) |
INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 3 + INTERP_32_MASK_2(p2)) / 4);
}
static inline u32 interp_32_1411(u32 p1, u32 p2, u32 p3)
static inline uint32_t interp_32_1411(uint32_t p1, uint32_t p2, uint32_t p3)
{
return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16) |
@ -225,7 +225,7 @@ static inline u32 interp_32_1411(u32 p1, u32 p2, u32 p3)
(INTERP_32_MASK_2(p1) * 14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16);
}
static inline u32 interp_32_431(u32 p1, u32 p2, u32 p3)
static inline uint32_t interp_32_431(uint32_t p1, uint32_t p2, uint32_t p3)
{
return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 4 + INTERP_32_MASK_1(p2) * 3 + INTERP_32_MASK_1(p3)) /
@ -235,19 +235,19 @@ static inline u32 interp_32_431(u32 p1, u32 p2, u32 p3)
8);
}
static inline u32 interp_32_53(u32 p1, u32 p2)
static inline uint32_t interp_32_53(uint32_t p1, uint32_t p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 5 + INTERP_32_MASK_1(p2) * 3) / 8) |
INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 5 + INTERP_32_MASK_2(p2) * 3) / 8);
}
static inline u32 interp_32_151(u32 p1, u32 p2)
static inline uint32_t interp_32_151(uint32_t p1, uint32_t p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 15 + INTERP_32_MASK_1(p2)) / 16) |
INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 15 + INTERP_32_MASK_2(p2)) / 16);
}
static inline u32 interp_32_97(u32 p1, u32 p2)
static inline uint32_t interp_32_97(uint32_t p1, uint32_t p2)
{
return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 9 + INTERP_32_MASK_1(p2) * 7) / 16) |
INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 9 + INTERP_32_MASK_2(p2) * 7) / 16);
@ -260,7 +260,7 @@ static inline u32 interp_32_97(u32 p1, u32 p2)
#define INTERP_U_LIMIT (0x07 * 4)
#define INTERP_V_LIMIT (0x06 * 8)
static int interp_16_diff(u16 p1, u16 p2)
static int interp_16_diff(uint16_t p1, uint16_t p2)
{
int r, g, b;
int y, u, v;
@ -294,7 +294,7 @@ static int interp_16_diff(u16 p1, u16 p2)
return 0;
}
static int interp_32_diff(u32 p1, u32 p2)
static int interp_32_diff(uint32_t p1, uint32_t p2)
{
int r, g, b;
int y, u, v;

View File

@ -2,25 +2,25 @@
extern int RGB_LOW_BITS_MASK;
void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Pixelate(uint8_t *srcPtr, uint32_t srcPitch, uint8_t *deltaPtr,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
uint8_t *nextLine, *finish;
uint32_t colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
u32 *xP = (u32 *) deltaPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
u32 nextPixel;
u32 currentDelta;
u32 nextDelta;
uint32_t *bP = (uint32_t *) srcPtr;
uint32_t *xP = (uint32_t *) deltaPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
uint32_t nextPixel;
uint32_t currentDelta;
uint32_t nextDelta;
finish = (u8 *) bP + ((width+2) << 1);
finish = (uint8_t *) bP + ((width+2) << 1);
nextPixel = *bP++;
nextDelta = *xP++;
@ -31,7 +31,7 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
nextDelta = *xP++;
if ((nextPixel != nextDelta) || (currentPixel != currentDelta)) {
u32 colorA, colorB, product;
uint32_t colorA, colorB, product;
*(xP - 2) = currentPixel;
#ifdef WORDS_BIGENDIAN
@ -68,7 +68,7 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
dP += 2;
nL += 2;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
deltaPtr += srcPitch;
srcPtr += srcPitch;
@ -78,30 +78,30 @@ void Pixelate(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr,
while (--height);
}
void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Pixelate32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
u32 colorMask = ~RGB_LOW_BITS_MASK;
uint8_t *nextLine, *finish;
uint32_t colorMask = ~RGB_LOW_BITS_MASK;
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
// u32 *xP = (u32 *) deltaPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
u32 nextPixel;
uint32_t *bP = (uint32_t *) srcPtr;
// uint32_t *xP = (uint32_t *) deltaPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
uint32_t nextPixel;
finish = (u8 *) bP + ((width+1) << 2);
finish = (uint8_t *) bP + ((width+1) << 2);
nextPixel = *bP++;
do {
currentPixel = nextPixel;
nextPixel = *bP++;
u32 colorA, colorB, product;
uint32_t colorA, colorB, product;
colorA = currentPixel;
colorB = nextPixel;
@ -122,7 +122,7 @@ void Pixelate32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dP += 4;
nL += 4;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;

View File

@ -2,27 +2,27 @@
extern int RGB_LOW_BITS_MASK;
void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Scanlines (uint8_t *srcPtr, uint32_t srcPitch, uint8_t *,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
uint8_t *nextLine, *finish;
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
u32 nextPixel;
uint32_t *bP = (uint32_t *) srcPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
uint32_t nextPixel;
finish = (u8 *) bP + ((width+2) << 1);
finish = (uint8_t *) bP + ((width+2) << 1);
nextPixel = *bP++;
do {
currentPixel = nextPixel;
nextPixel = *bP++;
u32 colorA, colorB;
uint32_t colorA, colorB;
#ifdef WORDS_BIGENDIAN
colorA = currentPixel >> 16;
@ -46,7 +46,7 @@ void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *,
dP += 2;
nL += 2;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;
@ -55,28 +55,28 @@ void Scanlines (u8 *srcPtr, u32 srcPitch, u8 *,
while (--height);
}
void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Scanlines32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
uint8_t *nextLine, *finish;
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
u32 nextPixel;
uint32_t *bP = (uint32_t *) srcPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
uint32_t nextPixel;
finish = (u8 *) bP + ((width+1) << 2);
finish = (uint8_t *) bP + ((width+1) << 2);
nextPixel = *bP++;
do {
currentPixel = nextPixel;
nextPixel = *bP++;
u32 colorA, colorB;
uint32_t colorA, colorB;
colorA = currentPixel;
colorB = nextPixel;
@ -95,7 +95,7 @@ void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dP += 4;
nL += 4;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;
@ -104,29 +104,29 @@ void Scanlines32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
while (--height);
}
void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void ScanlinesTV(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
u32 colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
uint8_t *nextLine, *finish;
uint32_t colorMask = ~(RGB_LOW_BITS_MASK | (RGB_LOW_BITS_MASK << 16));
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
u32 nextPixel;
uint32_t *bP = (uint32_t *) srcPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
uint32_t nextPixel;
finish = (u8 *) bP + ((width+2) << 1);
finish = (uint8_t *) bP + ((width+2) << 1);
nextPixel = *bP++;
do {
currentPixel = nextPixel;
nextPixel = *bP++;
u32 colorA, colorB;
uint32_t colorA, colorB;
#ifdef WORDS_BIGENDIAN
colorA = currentPixel >> 16;
@ -153,7 +153,7 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dP += 2;
nL += 2;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;
@ -162,29 +162,29 @@ void ScanlinesTV(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
while (--height);
}
void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void ScanlinesTV32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
u32 colorMask = ~RGB_LOW_BITS_MASK;
uint8_t *nextLine, *finish;
uint32_t colorMask = ~RGB_LOW_BITS_MASK;
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
u32 nextPixel;
uint32_t *bP = (uint32_t *) srcPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
uint32_t nextPixel;
finish = (u8 *) bP + ((width+1) << 2);
finish = (uint8_t *) bP + ((width+1) << 2);
nextPixel = *bP++;
do {
currentPixel = nextPixel;
nextPixel = *bP++;
u32 colorA, colorB, temp;
uint32_t colorA, colorB, temp;
colorA = currentPixel;
colorB = nextPixel;
@ -202,7 +202,7 @@ void ScanlinesTV32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dP += 2;
nL += 2;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;

View File

@ -1,26 +1,26 @@
#include "../System.h"
void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Simple2x16(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
uint8_t *nextLine, *finish;
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
uint32_t *bP = (uint32_t *) srcPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
finish = (u8 *) bP + ((width+2) << 1);
finish = (uint8_t *) bP + ((width+2) << 1);
currentPixel = *bP++;
do {
#ifdef WORDS_BIGENDIAN
u32 color = currentPixel >> 16;
uint32_t color = currentPixel >> 16;
#else
u32 color = currentPixel & 0xffff;
uint32_t color = currentPixel & 0xffff;
#endif
color = color | (color << 16);
@ -41,7 +41,7 @@ void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dP += 2;
nL += 2;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;
@ -50,24 +50,24 @@ void Simple2x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
while (--height);
}
void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Simple2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
u8 *nextLine, *finish;
uint8_t *nextLine, *finish;
nextLine = dstPtr + dstPitch;
do {
u32 *bP = (u32 *) srcPtr;
u32 *dP = (u32 *) dstPtr;
u32 *nL = (u32 *) nextLine;
u32 currentPixel;
uint32_t *bP = (uint32_t *) srcPtr;
uint32_t *dP = (uint32_t *) dstPtr;
uint32_t *nL = (uint32_t *) nextLine;
uint32_t currentPixel;
finish = (u8 *) bP + ((width+1) << 2);
finish = (uint8_t *) bP + ((width+1) << 2);
currentPixel = *bP++;
do {
u32 color = currentPixel;
uint32_t color = currentPixel;
*(dP) = color;
*(dP+1) = color;
@ -78,7 +78,7 @@ void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
dP += 2;
nL += 2;
} while ((u8 *) bP < finish);
} while ((uint8_t *) bP < finish);
srcPtr += srcPitch;
dstPtr += dstPitch << 1;
@ -88,8 +88,8 @@ void Simple2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
}
void Simple3x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Simple3x16(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
#define magnification 3
#define colorBytes 2 // 16 bit colors = 2 byte colors
@ -138,8 +138,8 @@ void Simple3x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
void Simple3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Simple3x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
#define magnification 3
#define colorBytes 4 // 32 bit colors = 4 byte colors
@ -186,8 +186,8 @@ void Simple3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
#undef colorBytes
}
void Simple4x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Simple4x16(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
#define magnification 4
#define colorBytes 2 // 16 bit colors = 2 byte colors
@ -236,8 +236,8 @@ void Simple4x16(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
void Simple4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height)
void Simple4x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
#define magnification 4
#define colorBytes 4 // 32 bit colors = 4 byte colors

View File

@ -2,27 +2,27 @@
#include "xBRZ/xbrz.h"
void xbrz2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
void xbrz2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
xbrz::scale(2, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
}
void xbrz3x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
void xbrz3x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
xbrz::scale(3, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
}
void xbrz4x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
void xbrz4x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
xbrz::scale(4, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
}
void xbrz5x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
void xbrz5x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
xbrz::scale(5, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
}
void xbrz6x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, u8 *dstPtr, u32 dstPitch, int width, int height)
void xbrz6x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */, uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{
xbrz::scale(6, (const uint32_t *)srcPtr, width, height, srcPitch, (uint32_t *)dstPtr, dstPitch, xbrz::RGB);
}

View File

@ -1,10 +1,10 @@
#ifndef GB_H
#define GB_H
#define C_FLAG 0x10
#define H_FLAG 0x20
#define N_FLAG 0x40
#define Z_FLAG 0x80
const int GB_C_FLAG = 0x10;
const int GB_H_FLAG = 0x20;
const int GB_N_FLAG = 0x40;
const int GB_Z_FLAG = 0x80;
typedef union {
struct {
@ -19,7 +19,7 @@ typedef union {
extern gbRegister AF, BC, DE, HL, SP, PC;
extern uint16_t IFF;
int gbDis(char*, u16);
int gbDis(char*, uint16_t);
bool gbLoadRom(const char*);
bool gbUpdateSizes();

View File

@ -451,7 +451,7 @@ uint8_t gbCheatRead(uint16_t address)
void gbCheatWrite(bool reboot)
{
if (cheatsEnabled) {
u16 address = 0;
uint16_t address = 0;
if (gbNextCheat >= gbCheatNumber)
gbNextCheat = 0;

View File

@ -32,7 +32,7 @@ void gbCheatRemove(int);
void gbCheatRemoveAll();
void gbCheatEnable(int);
void gbCheatDisable(int);
uint8_t gbCheatRead(u16);
uint8_t gbCheatRead(uint16_t);
void gbCheatWrite(bool);
bool gbVerifyGsCode(const char* code);
bool gbVerifyGgCode(const char* code);

View File

@ -17,12 +17,12 @@ break;
case 0x04:
// INC B
BC.B.B1++;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B1] | (BC.B.B1 & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[BC.B.B1] | (BC.B.B1 & 0x0F ? 0 : GB_H_FLAG);
break;
case 0x05:
// DEC B
BC.B.B1--;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B1] | ((BC.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[BC.B.B1] | ((BC.B.B1 & 0x0F) == 0x0F ? GB_H_FLAG : 0);
break;
case 0x06:
// LD B, NN
@ -30,7 +30,7 @@ BC.B.B1 = gbReadOpcode(PC.W++);
break;
case 0x07:
// RLCA
tempValue = AF.B.B1 & 0x80 ? C_FLAG : 0;
tempValue = AF.B.B1 & 0x80 ? GB_C_FLAG : 0;
AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B1 >> 7);
AF.B.B0 = tempValue;
break;
@ -44,7 +44,7 @@ break;
case 0x09:
// ADD HL,BC
tempRegister.W = (HL.W + BC.W) & 0xFFFF;
AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ BC.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | (((long)HL.W + (long)BC.W) & 0x10000 ? C_FLAG : 0);
AF.B.B0 = (AF.B.B0 & GB_Z_FLAG) | ((HL.W ^ BC.W ^ tempRegister.W) & 0x1000 ? GB_H_FLAG : 0) | (((long)HL.W + (long)BC.W) & 0x10000 ? GB_C_FLAG : 0);
HL.W = tempRegister.W;
break;
case 0x0a:
@ -58,12 +58,12 @@ break;
case 0x0c:
// INC C
BC.B.B0++;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B0] | (BC.B.B0 & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[BC.B.B0] | (BC.B.B0 & 0x0F ? 0 : GB_H_FLAG);
break;
case 0x0d:
// DEC C
BC.B.B0--;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B0] | ((BC.B.B0 & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[BC.B.B0] | ((BC.B.B0 & 0x0F) == 0x0F ? GB_H_FLAG : 0);
break;
case 0x0e:
// LD C, NN
@ -106,12 +106,12 @@ break;
case 0x14:
// INC D
DE.B.B1++;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B1] | (DE.B.B1 & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[DE.B.B1] | (DE.B.B1 & 0x0F ? 0 : GB_H_FLAG);
break;
case 0x15:
// DEC D
DE.B.B1--;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B1] | ((DE.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[DE.B.B1] | ((DE.B.B1 & 0x0F) == 0x0F ? GB_H_FLAG : 0);
break;
case 0x16:
// LD D,NN
@ -119,18 +119,18 @@ DE.B.B1 = gbReadOpcode(PC.W++);
break;
case 0x17:
// RLA
tempValue = AF.B.B1 & 0x80 ? C_FLAG : 0;
AF.B.B1 = (AF.B.B1 << 1) | ((AF.B.B0 & C_FLAG) >> 4);
tempValue = AF.B.B1 & 0x80 ? GB_C_FLAG : 0;
AF.B.B1 = (AF.B.B1 << 1) | ((AF.B.B0 & GB_C_FLAG) >> 4);
AF.B.B0 = tempValue;
break;
case 0x18:
// JR NN
PC.W += (s8)gbReadOpcode(PC.W) + 1;
PC.W += (int8_t)gbReadOpcode(PC.W) + 1;
break;
case 0x19:
// ADD HL,DE
tempRegister.W = (HL.W + DE.W) & 0xFFFF;
AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ DE.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | (((long)HL.W + (long)DE.W) & 0x10000 ? C_FLAG : 0);
AF.B.B0 = (AF.B.B0 & GB_Z_FLAG) | ((HL.W ^ DE.W ^ tempRegister.W) & 0x1000 ? GB_H_FLAG : 0) | (((long)HL.W + (long)DE.W) & 0x10000 ? GB_C_FLAG : 0);
HL.W = tempRegister.W;
break;
case 0x1a:
@ -144,12 +144,12 @@ break;
case 0x1c:
// INC E
DE.B.B0++;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B0] | (DE.B.B0 & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[DE.B.B0] | (DE.B.B0 & 0x0F ? 0 : GB_H_FLAG);
break;
case 0x1d:
// DEC E
DE.B.B0--;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B0] | ((DE.B.B0 & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[DE.B.B0] | ((DE.B.B0 & 0x0F) == 0x0F ? GB_H_FLAG : 0);
break;
case 0x1e:
// LD E,NN
@ -158,15 +158,15 @@ break;
case 0x1f:
// RRA
tempValue = AF.B.B1 & 0x01;
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = (tempValue << 4);
break;
case 0x20:
// JR NZ,NN
if (AF.B.B0 & Z_FLAG)
if (AF.B.B0 & GB_Z_FLAG)
PC.W++;
else {
PC.W += (s8)gbReadOpcode(PC.W) + 1;
PC.W += (int8_t)gbReadOpcode(PC.W) + 1;
clockTicks++;
}
break;
@ -186,12 +186,12 @@ break;
case 0x24:
// INC H
HL.B.B1++;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B1] | (HL.B.B1 & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[HL.B.B1] | (HL.B.B1 & 0x0F ? 0 : GB_H_FLAG);
break;
case 0x25:
// DEC H
HL.B.B1--;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B1] | ((HL.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[HL.B.B1] | ((HL.B.B1 & 0x0F) == 0x0F ? GB_H_FLAG : 0);
break;
case 0x26:
// LD H,NN
@ -200,13 +200,13 @@ break;
case 0x27:
// DAA
tempRegister.W = AF.B.B1;
tempRegister.W |= (AF.B.B0 & (C_FLAG | H_FLAG | N_FLAG)) << 4;
tempRegister.W |= (AF.B.B0 & (GB_C_FLAG | GB_H_FLAG | GB_N_FLAG)) << 4;
AF.W = DAATable[tempRegister.W];
break;
case 0x28:
// JR Z,NN
if (AF.B.B0 & Z_FLAG) {
PC.W += (s8)gbReadOpcode(PC.W) + 1;
if (AF.B.B0 & GB_Z_FLAG) {
PC.W += (int8_t)gbReadOpcode(PC.W) + 1;
clockTicks++;
} else
PC.W++;
@ -214,7 +214,7 @@ break;
case 0x29:
// ADD HL,HL
tempRegister.W = (HL.W + HL.W) & 0xFFFF;
AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ HL.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | (((long)HL.W + (long)HL.W) & 0x10000 ? C_FLAG : 0);
AF.B.B0 = (AF.B.B0 & GB_Z_FLAG) | ((HL.W ^ HL.W ^ tempRegister.W) & 0x1000 ? GB_H_FLAG : 0) | (((long)HL.W + (long)HL.W) & 0x10000 ? GB_C_FLAG : 0);
HL.W = tempRegister.W;
break;
case 0x2a:
@ -228,12 +228,12 @@ break;
case 0x2c:
// INC L
HL.B.B0++;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B0] | (HL.B.B0 & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[HL.B.B0] | (HL.B.B0 & 0x0F ? 0 : GB_H_FLAG);
break;
case 0x2d:
// DEC L
HL.B.B0--;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B0] | ((HL.B.B0 & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[HL.B.B0] | ((HL.B.B0 & 0x0F) == 0x0F ? GB_H_FLAG : 0);
break;
case 0x2e:
// LD L,NN
@ -242,14 +242,14 @@ break;
case 0x2f:
// CPL
AF.B.B1 ^= 255;
AF.B.B0 |= N_FLAG | H_FLAG;
AF.B.B0 |= GB_N_FLAG | GB_H_FLAG;
break;
case 0x30:
// JR NC,NN
if (AF.B.B0 & C_FLAG)
if (AF.B.B0 & GB_C_FLAG)
PC.W++;
else {
PC.W += (s8)gbReadOpcode(PC.W) + 1;
PC.W += (int8_t)gbReadOpcode(PC.W) + 1;
clockTicks++;
}
break;
@ -269,13 +269,13 @@ break;
case 0x34:
// INC (HL)
tempValue = gbReadMemory(HL.W) + 1;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[tempValue] | (tempValue & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[tempValue] | (tempValue & 0x0F ? 0 : GB_H_FLAG);
gbWriteMemory(HL.W, tempValue);
break;
case 0x35:
// DEC (HL)
tempValue = gbReadMemory(HL.W) - 1;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[tempValue] | ((tempValue & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[tempValue] | ((tempValue & 0x0F) == 0x0F ? GB_H_FLAG : 0);
gbWriteMemory(HL.W, tempValue);
break;
case 0x36:
@ -284,12 +284,12 @@ gbWriteMemory(HL.W, gbReadOpcode(PC.W++));
break;
case 0x37:
// SCF
AF.B.B0 = (AF.B.B0 & Z_FLAG) | C_FLAG;
AF.B.B0 = (AF.B.B0 & GB_Z_FLAG) | GB_C_FLAG;
break;
case 0x38:
// JR C,NN
if (AF.B.B0 & C_FLAG) {
PC.W += (s8)gbReadOpcode(PC.W) + 1;
if (AF.B.B0 & GB_C_FLAG) {
PC.W += (int8_t)gbReadOpcode(PC.W) + 1;
clockTicks++;
} else
PC.W++;
@ -297,7 +297,7 @@ break;
case 0x39:
// ADD HL,SP
tempRegister.W = (HL.W + SP.W) & 0xFFFF;
AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ SP.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | (((long)HL.W + (long)SP.W) & 0x10000 ? C_FLAG : 0);
AF.B.B0 = (AF.B.B0 & GB_Z_FLAG) | ((HL.W ^ SP.W ^ tempRegister.W) & 0x1000 ? GB_H_FLAG : 0) | (((long)HL.W + (long)SP.W) & 0x10000 ? GB_C_FLAG : 0);
HL.W = tempRegister.W;
break;
case 0x3a:
@ -311,12 +311,12 @@ break;
case 0x3c:
// INC A
AF.B.B1++;
AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[AF.B.B1] | (AF.B.B1 & 0x0F ? 0 : H_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | ZeroTable[AF.B.B1] | (AF.B.B1 & 0x0F ? 0 : GB_H_FLAG);
break;
case 0x3d:
// DEC A
AF.B.B1--;
AF.B.B0 = N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[AF.B.B1] | ((AF.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (AF.B.B0 & GB_C_FLAG) | ZeroTable[AF.B.B1] | ((AF.B.B1 & 0x0F) == 0x0F ? GB_H_FLAG : 0);
break;
case 0x3e:
// LD A,NN
@ -324,8 +324,8 @@ AF.B.B1 = gbReadOpcode(PC.W++);
break;
case 0x3f:
// CCF
AF.B.B0 ^= C_FLAG;
AF.B.B0 &= ~(N_FLAG | H_FLAG);
AF.B.B0 ^= GB_C_FLAG;
AF.B.B0 &= ~(GB_N_FLAG | GB_H_FLAG);
break;
case 0x40:
// LD B,B
@ -599,238 +599,238 @@ break;
case 0x80:
// ADD B
tempRegister.W = AF.B.B1 + BC.B.B1;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x81:
// ADD C
tempRegister.W = AF.B.B1 + BC.B.B0;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x82:
// ADD D
tempRegister.W = AF.B.B1 + DE.B.B1;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x83:
// ADD E
tempRegister.W = AF.B.B1 + DE.B.B0;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x84:
// ADD H
tempRegister.W = AF.B.B1 + HL.B.B1;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x85:
// ADD L
tempRegister.W = AF.B.B1 + HL.B.B0;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x86:
// ADD (HL)
tempValue = gbReadMemory(HL.W);
tempRegister.W = AF.B.B1 + tempValue;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x87:
// ADD A
tempRegister.W = AF.B.B1 + AF.B.B1;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x88:
// ADC B:
tempRegister.W = AF.B.B1 + BC.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + BC.B.B1 + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x89:
// ADC C
tempRegister.W = AF.B.B1 + BC.B.B0 + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + BC.B.B0 + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x8a:
// ADC D
tempRegister.W = AF.B.B1 + DE.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + DE.B.B1 + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x8b:
// ADC E
tempRegister.W = AF.B.B1 + DE.B.B0 + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + DE.B.B0 + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x8c:
// ADC H
tempRegister.W = AF.B.B1 + HL.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + HL.B.B1 + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x8d:
// ADC L
tempRegister.W = AF.B.B1 + HL.B.B0 + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + HL.B.B0 + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x8e:
// ADC (HL)
tempValue = gbReadMemory(HL.W);
tempRegister.W = AF.B.B1 + tempValue + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + tempValue + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x8f:
// ADC A
tempRegister.W = AF.B.B1 + AF.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + AF.B.B1 + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x90:
// SUB B
tempRegister.W = AF.B.B1 - BC.B.B1;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x91:
// SUB C
tempRegister.W = AF.B.B1 - BC.B.B0;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x92:
// SUB D
tempRegister.W = AF.B.B1 - DE.B.B1;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x93:
// SUB E
tempRegister.W = AF.B.B1 - DE.B.B0;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x94:
// SUB H
tempRegister.W = AF.B.B1 - HL.B.B1;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x95:
// SUB L
tempRegister.W = AF.B.B1 - HL.B.B0;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x96:
// SUB (HL)
tempValue = gbReadMemory(HL.W);
tempRegister.W = AF.B.B1 - tempValue;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x97:
// SUB A
AF.B.B1 = 0;
AF.B.B0 = N_FLAG | Z_FLAG;
AF.B.B0 = GB_N_FLAG | GB_Z_FLAG;
break;
case 0x98:
// SBC B
tempRegister.W = AF.B.B1 - BC.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - BC.B.B1 - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x99:
// SBC C
tempRegister.W = AF.B.B1 - BC.B.B0 - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - BC.B.B0 - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x9a:
// SBC D
tempRegister.W = AF.B.B1 - DE.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - DE.B.B1 - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x9b:
// SBC E
tempRegister.W = AF.B.B1 - DE.B.B0 - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - DE.B.B0 - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x9c:
// SBC H
tempRegister.W = AF.B.B1 - HL.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - HL.B.B1 - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x9d:
// SBC L
tempRegister.W = AF.B.B1 - HL.B.B0 - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - HL.B.B0 - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x9e:
// SBC (HL)
tempValue = gbReadMemory(HL.W);
tempRegister.W = AF.B.B1 - tempValue - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - tempValue - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0x9f:
// SBC A
tempRegister.W = AF.B.B1 - AF.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - AF.B.B1 - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0xa0:
// AND B
AF.B.B1 &= BC.B.B1;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa1:
// AND C
AF.B.B1 &= BC.B.B0;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa2:
// AND_D
AF.B.B1 &= DE.B.B1;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa3:
// AND E
AF.B.B1 &= DE.B.B0;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa4:
// AND H
AF.B.B1 &= HL.B.B1;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa5:
// AND L
AF.B.B1 &= HL.B.B0;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa6:
// AND (HL)
tempValue = gbReadMemory(HL.W);
AF.B.B1 &= tempValue;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa7:
// AND A
AF.B.B1 &= AF.B.B1;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xa8:
// XOR B
@ -871,7 +871,7 @@ break;
case 0xaf:
// XOR A
AF.B.B1 = 0;
AF.B.B0 = Z_FLAG;
AF.B.B0 = GB_Z_FLAG;
break;
case 0xb0:
// OR B
@ -917,46 +917,46 @@ break;
case 0xb8:
// CP B:
tempRegister.W = AF.B.B1 - BC.B.B1;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xb9:
// CP C
tempRegister.W = AF.B.B1 - BC.B.B0;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xba:
// CP D
tempRegister.W = AF.B.B1 - DE.B.B1;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xbb:
// CP E
tempRegister.W = AF.B.B1 - DE.B.B0;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xbc:
// CP H
tempRegister.W = AF.B.B1 - HL.B.B1;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xbd:
// CP L
tempRegister.W = AF.B.B1 - HL.B.B0;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xbe:
// CP (HL)
tempValue = gbReadMemory(HL.W);
tempRegister.W = AF.B.B1 - tempValue;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xbf:
// CP A
AF.B.B0 = N_FLAG | Z_FLAG;
AF.B.B0 = GB_N_FLAG | GB_Z_FLAG;
break;
case 0xc0:
// RET NZ
if (!(AF.B.B0 & Z_FLAG)) {
if (!(AF.B.B0 & GB_Z_FLAG)) {
PC.B.B0 = gbReadMemory(SP.W++);
PC.B.B1 = gbReadMemory(SP.W++);
clockTicks += 3;
@ -969,7 +969,7 @@ BC.B.B1 = gbReadMemory(SP.W++);
break;
case 0xc2:
// JP NZ,NNNN
if (AF.B.B0 & Z_FLAG)
if (AF.B.B0 & GB_Z_FLAG)
PC.W += 2;
else {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
@ -986,7 +986,7 @@ PC.W = tempRegister.W;
break;
case 0xc4:
// CALL NZ,NNNN
if (AF.B.B0 & Z_FLAG)
if (AF.B.B0 & GB_Z_FLAG)
PC.W += 2;
else {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
@ -1006,7 +1006,7 @@ case 0xc6:
// ADD NN
tempValue = gbReadOpcode(PC.W++);
tempRegister.W = AF.B.B1 + tempValue;
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0xc7:
@ -1017,7 +1017,7 @@ PC.W = 0x0000;
break;
case 0xc8:
// RET Z
if (AF.B.B0 & Z_FLAG) {
if (AF.B.B0 & GB_Z_FLAG) {
PC.B.B0 = gbReadMemory(SP.W++);
PC.B.B1 = gbReadMemory(SP.W++);
clockTicks += 3;
@ -1030,7 +1030,7 @@ PC.B.B1 = gbReadMemory(SP.W++);
break;
case 0xca:
// JP Z,NNNN
if (AF.B.B0 & Z_FLAG) {
if (AF.B.B0 & GB_Z_FLAG) {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
tempRegister.B.B1 = gbReadOpcode(PC.W);
PC.W = tempRegister.W;
@ -1041,7 +1041,7 @@ break;
// CB done outside
case 0xcc:
// CALL Z,NNNN
if (AF.B.B0 & Z_FLAG) {
if (AF.B.B0 & GB_Z_FLAG) {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
tempRegister.B.B1 = gbReadOpcode(PC.W++);
gbWriteMemory(--SP.W, PC.B.B1);
@ -1062,8 +1062,8 @@ break;
case 0xce:
// ADC NN
tempValue = gbReadOpcode(PC.W++);
tempRegister.W = AF.B.B1 + tempValue + (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 + tempValue + (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0xcf:
@ -1074,7 +1074,7 @@ PC.W = 0x0008;
break;
case 0xd0:
// RET NC
if (!(AF.B.B0 & C_FLAG)) {
if (!(AF.B.B0 & GB_C_FLAG)) {
PC.B.B0 = gbReadMemory(SP.W++);
PC.B.B1 = gbReadMemory(SP.W++);
clockTicks += 3;
@ -1087,7 +1087,7 @@ DE.B.B1 = gbReadMemory(SP.W++);
break;
case 0xd2:
// JP NC,NNNN
if (AF.B.B0 & C_FLAG)
if (AF.B.B0 & GB_C_FLAG)
PC.W += 2;
else {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
@ -1103,7 +1103,7 @@ IFF = 0;
break;
case 0xd4:
// CALL NC,NNNN
if (AF.B.B0 & C_FLAG)
if (AF.B.B0 & GB_C_FLAG)
PC.W += 2;
else {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
@ -1123,7 +1123,7 @@ case 0xd6:
// SUB NN
tempValue = gbReadOpcode(PC.W++);
tempRegister.W = AF.B.B1 - tempValue;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0xd7:
@ -1134,7 +1134,7 @@ PC.W = 0x0010;
break;
case 0xd8:
// RET C
if (AF.B.B0 & C_FLAG) {
if (AF.B.B0 & GB_C_FLAG) {
PC.B.B0 = gbReadMemory(SP.W++);
PC.B.B1 = gbReadMemory(SP.W++);
clockTicks += 3;
@ -1148,7 +1148,7 @@ IFF |= 0x01;
break;
case 0xda:
// JP C,NNNN
if (AF.B.B0 & C_FLAG) {
if (AF.B.B0 & GB_C_FLAG) {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
tempRegister.B.B1 = gbReadOpcode(PC.W);
PC.W = tempRegister.W;
@ -1163,7 +1163,7 @@ IFF = 0;
break;
case 0xdc:
// CALL C,NNNN
if (AF.B.B0 & C_FLAG) {
if (AF.B.B0 & GB_C_FLAG) {
tempRegister.B.B0 = gbReadOpcode(PC.W++);
tempRegister.B.B1 = gbReadOpcode(PC.W++);
gbWriteMemory(--SP.W, PC.B.B1);
@ -1181,8 +1181,8 @@ break;
case 0xde:
// SBC NN
tempValue = gbReadOpcode(PC.W++);
tempRegister.W = AF.B.B1 - tempValue - (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
tempRegister.W = AF.B.B1 - tempValue - (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
AF.B.B1 = tempRegister.B.B0;
break;
case 0xdf:
@ -1220,7 +1220,7 @@ case 0xe6:
// AND NN
tempValue = gbReadOpcode(PC.W++);
AF.B.B1 &= tempValue;
AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1];
AF.B.B0 = GB_H_FLAG | ZeroTable[AF.B.B1];
break;
case 0xe7:
// RST 20
@ -1230,9 +1230,9 @@ PC.W = 0x0020;
break;
case 0xe8:
// ADD SP,NN
offset = (s8)gbReadOpcode(PC.W++);
offset = (int8_t)gbReadOpcode(PC.W++);
tempRegister.W = SP.W + offset;
AF.B.B0 = ((SP.W ^ offset ^ tempRegister.W) & 0x100 ? C_FLAG : 0) | ((SP.W ^ offset ^ tempRegister.W) & 0x10 ? H_FLAG : 0);
AF.B.B0 = ((SP.W ^ offset ^ tempRegister.W) & 0x100 ? GB_C_FLAG : 0) | ((SP.W ^ offset ^ tempRegister.W) & 0x10 ? GB_H_FLAG : 0);
SP.W = tempRegister.W;
break;
case 0xe9:
@ -1308,9 +1308,9 @@ PC.W = 0x0030;
break;
case 0xf8:
// LD HL,SP+NN
offset = (s8)gbReadOpcode(PC.W++);
offset = (int8_t)gbReadOpcode(PC.W++);
tempRegister.W = SP.W + offset;
AF.B.B0 = ((SP.W ^ offset ^ tempRegister.W) & 0x100 ? C_FLAG : 0) | ((SP.W ^ offset ^ tempRegister.W) & 0x10 ? H_FLAG : 0);
AF.B.B0 = ((SP.W ^ offset ^ tempRegister.W) & 0x100 ? GB_C_FLAG : 0) | ((SP.W ^ offset ^ tempRegister.W) & 0x10 ? GB_H_FLAG : 0);
HL.W = tempRegister.W;
break;
case 0xf9:
@ -1346,7 +1346,7 @@ case 0xfe:
// CP NN
tempValue = gbReadOpcode(PC.W++);
tempRegister.W = AF.B.B1 - tempValue;
AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0);
AF.B.B0 = GB_N_FLAG | (tempRegister.B.B1 ? GB_C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? GB_H_FLAG : 0);
break;
case 0xff:
// RST 38

View File

@ -1,160 +1,160 @@
case 0x00:
// RLC B
AF.B.B0 = (BC.B.B1 & 0x80) ? C_FLAG : 0;
AF.B.B0 = (BC.B.B1 & 0x80) ? GB_C_FLAG : 0;
BC.B.B1 = (BC.B.B1 << 1) | (BC.B.B1 >> 7);
AF.B.B0 |= ZeroTable[BC.B.B1];
break;
case 0x01:
// RLC C
AF.B.B0 = (BC.B.B0 & 0x80) ? C_FLAG : 0;
AF.B.B0 = (BC.B.B0 & 0x80) ? GB_C_FLAG : 0;
BC.B.B0 = (BC.B.B0 << 1) | (BC.B.B0 >> 7);
AF.B.B0 |= ZeroTable[BC.B.B0];
break;
case 0x02:
// RLC D
AF.B.B0 = (DE.B.B1 & 0x80) ? C_FLAG : 0;
AF.B.B0 = (DE.B.B1 & 0x80) ? GB_C_FLAG : 0;
DE.B.B1 = (DE.B.B1 << 1) | (DE.B.B1 >> 7);
AF.B.B0 |= ZeroTable[DE.B.B1];
break;
case 0x03:
// RLC E
AF.B.B0 = (DE.B.B0 & 0x80) ? C_FLAG : 0;
AF.B.B0 = (DE.B.B0 & 0x80) ? GB_C_FLAG : 0;
DE.B.B0 = (DE.B.B0 << 1) | (DE.B.B0 >> 7);
AF.B.B0 |= ZeroTable[DE.B.B0];
break;
case 0x04:
// RLC H
AF.B.B0 = (HL.B.B1 & 0x80) ? C_FLAG : 0;
AF.B.B0 = (HL.B.B1 & 0x80) ? GB_C_FLAG : 0;
HL.B.B1 = (HL.B.B1 << 1) | (HL.B.B1 >> 7);
AF.B.B0 |= ZeroTable[HL.B.B1];
break;
case 0x05:
// RLC L
AF.B.B0 = (HL.B.B0 & 0x80) ? C_FLAG : 0;
AF.B.B0 = (HL.B.B0 & 0x80) ? GB_C_FLAG : 0;
HL.B.B0 = (HL.B.B0 << 1) | (HL.B.B0 >> 7);
AF.B.B0 |= ZeroTable[HL.B.B0];
break;
case 0x06:
// RLC (HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (tempValue & 0x80) ? C_FLAG : 0;
AF.B.B0 = (tempValue & 0x80) ? GB_C_FLAG : 0;
tempValue = (tempValue << 1) | (tempValue >> 7);
AF.B.B0 |= ZeroTable[tempValue];
gbWriteMemory(HL.W, tempValue);
break;
case 0x07:
// RLC A
AF.B.B0 = (AF.B.B1 & 0x80) ? C_FLAG : 0;
AF.B.B0 = (AF.B.B1 & 0x80) ? GB_C_FLAG : 0;
AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B1 >> 7);
AF.B.B0 |= ZeroTable[AF.B.B1];
break;
case 0x08:
// RRC B
AF.B.B0 = (BC.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (BC.B.B1 & 0x01 ? GB_C_FLAG : 0);
BC.B.B1 = (BC.B.B1 >> 1) | (BC.B.B1 << 7);
AF.B.B0 |= ZeroTable[BC.B.B1];
break;
case 0x09:
// RRC C
AF.B.B0 = (BC.B.B0 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (BC.B.B0 & 0x01 ? GB_C_FLAG : 0);
BC.B.B0 = (BC.B.B0 >> 1) | (BC.B.B0 << 7);
AF.B.B0 |= ZeroTable[BC.B.B0];
break;
case 0x0a:
// RRC D
AF.B.B0 = (DE.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (DE.B.B1 & 0x01 ? GB_C_FLAG : 0);
DE.B.B1 = (DE.B.B1 >> 1) | (DE.B.B1 << 7);
AF.B.B0 |= ZeroTable[DE.B.B1];
break;
case 0x0b:
// RRC E
AF.B.B0 = (DE.B.B0 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (DE.B.B0 & 0x01 ? GB_C_FLAG : 0);
DE.B.B0 = (DE.B.B0 >> 1) | (DE.B.B0 << 7);
AF.B.B0 |= ZeroTable[DE.B.B0];
break;
case 0x0c:
// RRC H
AF.B.B0 = (HL.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (HL.B.B1 & 0x01 ? GB_C_FLAG : 0);
HL.B.B1 = (HL.B.B1 >> 1) | (HL.B.B1 << 7);
AF.B.B0 |= ZeroTable[HL.B.B1];
break;
case 0x0d:
// RRC L
AF.B.B0 = (HL.B.B0 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (HL.B.B0 & 0x01 ? GB_C_FLAG : 0);
HL.B.B0 = (HL.B.B0 >> 1) | (HL.B.B0 << 7);
AF.B.B0 |= ZeroTable[HL.B.B0];
break;
case 0x0e:
// RRC (HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (tempValue & 0x01 ? C_FLAG : 0);
AF.B.B0 = (tempValue & 0x01 ? GB_C_FLAG : 0);
tempValue = (tempValue >> 1) | (tempValue << 7);
AF.B.B0 |= ZeroTable[tempValue];
gbWriteMemory(HL.W, tempValue);
break;
case 0x0f:
// RRC A
AF.B.B0 = (AF.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (AF.B.B1 & 0x01 ? GB_C_FLAG : 0);
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B1 << 7);
AF.B.B0 |= ZeroTable[AF.B.B1];
break;
case 0x10:
// RL B
if (BC.B.B1 & 0x80) {
BC.B.B1 = (BC.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[BC.B.B1] | C_FLAG;
BC.B.B1 = (BC.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[BC.B.B1] | GB_C_FLAG;
} else {
BC.B.B1 = (BC.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
BC.B.B1 = (BC.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[BC.B.B1];
}
break;
case 0x11:
// RL C
if (BC.B.B0 & 0x80) {
BC.B.B0 = (BC.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[BC.B.B0] | C_FLAG;
BC.B.B0 = (BC.B.B0 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[BC.B.B0] | GB_C_FLAG;
} else {
BC.B.B0 = (BC.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
BC.B.B0 = (BC.B.B0 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[BC.B.B0];
}
break;
case 0x12:
// RL D
if (DE.B.B1 & 0x80) {
DE.B.B1 = (DE.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[DE.B.B1] | C_FLAG;
DE.B.B1 = (DE.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[DE.B.B1] | GB_C_FLAG;
} else {
DE.B.B1 = (DE.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
DE.B.B1 = (DE.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[DE.B.B1];
}
break;
case 0x13:
// RL E
if (DE.B.B0 & 0x80) {
DE.B.B0 = (DE.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[DE.B.B0] | C_FLAG;
DE.B.B0 = (DE.B.B0 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[DE.B.B0] | GB_C_FLAG;
} else {
DE.B.B0 = (DE.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
DE.B.B0 = (DE.B.B0 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[DE.B.B0];
}
break;
case 0x14:
// RL H
if (HL.B.B1 & 0x80) {
HL.B.B1 = (HL.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[HL.B.B1] | C_FLAG;
HL.B.B1 = (HL.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[HL.B.B1] | GB_C_FLAG;
} else {
HL.B.B1 = (HL.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
HL.B.B1 = (HL.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[HL.B.B1];
}
break;
case 0x15:
// RL L
if (HL.B.B0 & 0x80) {
HL.B.B0 = (HL.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[HL.B.B0] | C_FLAG;
HL.B.B0 = (HL.B.B0 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[HL.B.B0] | GB_C_FLAG;
} else {
HL.B.B0 = (HL.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
HL.B.B0 = (HL.B.B0 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[HL.B.B0];
}
break;
@ -162,10 +162,10 @@ case 0x16:
// RL (HL)
tempValue = gbReadMemory(HL.W);
if (tempValue & 0x80) {
tempValue = (tempValue << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[tempValue] | C_FLAG;
tempValue = (tempValue << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[tempValue] | GB_C_FLAG;
} else {
tempValue = (tempValue << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
tempValue = (tempValue << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[tempValue];
}
gbWriteMemory(HL.W, tempValue);
@ -173,70 +173,70 @@ break;
case 0x17:
// RL A
if (AF.B.B1 & 0x80) {
AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[AF.B.B1] | C_FLAG;
AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[AF.B.B1] | GB_C_FLAG;
} else {
AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0);
AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B0 & GB_C_FLAG ? 1 : 0);
AF.B.B0 = ZeroTable[AF.B.B1];
}
break;
case 0x18:
// RR B
if (BC.B.B1 & 0x01) {
BC.B.B1 = (BC.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[BC.B.B1] | C_FLAG;
BC.B.B1 = (BC.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[BC.B.B1] | GB_C_FLAG;
} else {
BC.B.B1 = (BC.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
BC.B.B1 = (BC.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[BC.B.B1];
}
break;
case 0x19:
// RR C
if (BC.B.B0 & 0x01) {
BC.B.B0 = (BC.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[BC.B.B0] | C_FLAG;
BC.B.B0 = (BC.B.B0 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[BC.B.B0] | GB_C_FLAG;
} else {
BC.B.B0 = (BC.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
BC.B.B0 = (BC.B.B0 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[BC.B.B0];
}
break;
case 0x1a:
// RR D
if (DE.B.B1 & 0x01) {
DE.B.B1 = (DE.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[DE.B.B1] | C_FLAG;
DE.B.B1 = (DE.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[DE.B.B1] | GB_C_FLAG;
} else {
DE.B.B1 = (DE.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
DE.B.B1 = (DE.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[DE.B.B1];
}
break;
case 0x1b:
// RR E
if (DE.B.B0 & 0x01) {
DE.B.B0 = (DE.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[DE.B.B0] | C_FLAG;
DE.B.B0 = (DE.B.B0 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[DE.B.B0] | GB_C_FLAG;
} else {
DE.B.B0 = (DE.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
DE.B.B0 = (DE.B.B0 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[DE.B.B0];
}
break;
case 0x1c:
// RR H
if (HL.B.B1 & 0x01) {
HL.B.B1 = (HL.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[HL.B.B1] | C_FLAG;
HL.B.B1 = (HL.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[HL.B.B1] | GB_C_FLAG;
} else {
HL.B.B1 = (HL.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
HL.B.B1 = (HL.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[HL.B.B1];
}
break;
case 0x1d:
// RR L
if (HL.B.B0 & 0x01) {
HL.B.B0 = (HL.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[HL.B.B0] | C_FLAG;
HL.B.B0 = (HL.B.B0 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[HL.B.B0] | GB_C_FLAG;
} else {
HL.B.B0 = (HL.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
HL.B.B0 = (HL.B.B0 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[HL.B.B0];
}
break;
@ -244,10 +244,10 @@ case 0x1e:
// RR (HL)
tempValue = gbReadMemory(HL.W);
if (tempValue & 0x01) {
tempValue = (tempValue >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[tempValue] | C_FLAG;
tempValue = (tempValue >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[tempValue] | GB_C_FLAG;
} else {
tempValue = (tempValue >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
tempValue = (tempValue >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[tempValue];
}
gbWriteMemory(HL.W, tempValue);
@ -255,110 +255,110 @@ break;
case 0x1f:
// RR A
if (AF.B.B1 & 0x01) {
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[AF.B.B1] | C_FLAG;
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[AF.B.B1] | GB_C_FLAG;
} else {
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0);
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & GB_C_FLAG ? 0x80 : 0);
AF.B.B0 = ZeroTable[AF.B.B1];
}
break;
case 0x20:
// SLA B
AF.B.B0 = (BC.B.B1 & 0x80 ? C_FLAG : 0);
AF.B.B0 = (BC.B.B1 & 0x80 ? GB_C_FLAG : 0);
BC.B.B1 <<= 1;
AF.B.B0 |= ZeroTable[BC.B.B1];
break;
case 0x21:
// SLA C
AF.B.B0 = (BC.B.B0 & 0x80 ? C_FLAG : 0);
AF.B.B0 = (BC.B.B0 & 0x80 ? GB_C_FLAG : 0);
BC.B.B0 <<= 1;
AF.B.B0 |= ZeroTable[BC.B.B0];
break;
case 0x22:
// SLA D
AF.B.B0 = (DE.B.B1 & 0x80 ? C_FLAG : 0);
AF.B.B0 = (DE.B.B1 & 0x80 ? GB_C_FLAG : 0);
DE.B.B1 <<= 1;
AF.B.B0 |= ZeroTable[DE.B.B1];
break;
case 0x23:
// SLA E
AF.B.B0 = (DE.B.B0 & 0x80 ? C_FLAG : 0);
AF.B.B0 = (DE.B.B0 & 0x80 ? GB_C_FLAG : 0);
DE.B.B0 <<= 1;
AF.B.B0 |= ZeroTable[DE.B.B0];
break;
case 0x24:
// SLA H
AF.B.B0 = (HL.B.B1 & 0x80 ? C_FLAG : 0);
AF.B.B0 = (HL.B.B1 & 0x80 ? GB_C_FLAG : 0);
HL.B.B1 <<= 1;
AF.B.B0 |= ZeroTable[HL.B.B1];
break;
case 0x25:
// SLA L
AF.B.B0 = (HL.B.B0 & 0x80 ? C_FLAG : 0);
AF.B.B0 = (HL.B.B0 & 0x80 ? GB_C_FLAG : 0);
HL.B.B0 <<= 1;
AF.B.B0 |= ZeroTable[HL.B.B0];
break;
case 0x26:
// SLA (HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (tempValue & 0x80 ? C_FLAG : 0);
AF.B.B0 = (tempValue & 0x80 ? GB_C_FLAG : 0);
tempValue <<= 1;
AF.B.B0 |= ZeroTable[tempValue];
gbWriteMemory(HL.W, tempValue);
break;
case 0x27:
// SLA A
AF.B.B0 = (AF.B.B1 & 0x80 ? C_FLAG : 0);
AF.B.B0 = (AF.B.B1 & 0x80 ? GB_C_FLAG : 0);
AF.B.B1 <<= 1;
AF.B.B0 |= ZeroTable[AF.B.B1];
break;
case 0x28:
// SRA B
AF.B.B0 = (BC.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (BC.B.B1 & 0x01 ? GB_C_FLAG : 0);
BC.B.B1 = (BC.B.B1 >> 1) | (BC.B.B1 & 0x80);
AF.B.B0 |= ZeroTable[BC.B.B1];
break;
case 0x29:
// SRA C
AF.B.B0 = (BC.B.B0 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (BC.B.B0 & 0x01 ? GB_C_FLAG : 0);
BC.B.B0 = (BC.B.B0 >> 1) | (BC.B.B0 & 0x80);
AF.B.B0 |= ZeroTable[BC.B.B0];
break;
case 0x2a:
// SRA D
AF.B.B0 = (DE.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (DE.B.B1 & 0x01 ? GB_C_FLAG : 0);
DE.B.B1 = (DE.B.B1 >> 1) | (DE.B.B1 & 0x80);
AF.B.B0 |= ZeroTable[DE.B.B1];
break;
case 0x2b:
// SRA E
AF.B.B0 = (DE.B.B0 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (DE.B.B0 & 0x01 ? GB_C_FLAG : 0);
DE.B.B0 = (DE.B.B0 >> 1) | (DE.B.B0 & 0x80);
AF.B.B0 |= ZeroTable[DE.B.B0];
break;
case 0x2c:
// SRA H
AF.B.B0 = (HL.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (HL.B.B1 & 0x01 ? GB_C_FLAG : 0);
HL.B.B1 = (HL.B.B1 >> 1) | (HL.B.B1 & 0x80);
AF.B.B0 |= ZeroTable[HL.B.B1];
break;
case 0x2d:
// SRA L
AF.B.B0 = (HL.B.B0 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (HL.B.B0 & 0x01 ? GB_C_FLAG : 0);
HL.B.B0 = (HL.B.B0 >> 1) | (HL.B.B0 & 0x80);
AF.B.B0 |= ZeroTable[HL.B.B0];
break;
case 0x2e:
// SRA (HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (tempValue & 0x01 ? C_FLAG : 0);
AF.B.B0 = (tempValue & 0x01 ? GB_C_FLAG : 0);
tempValue = (tempValue >> 1) | (tempValue & 0x80);
AF.B.B0 |= ZeroTable[tempValue];
gbWriteMemory(HL.W, tempValue);
break;
case 0x2f:
// SRA A
AF.B.B0 = (AF.B.B1 & 0x01 ? C_FLAG : 0);
AF.B.B0 = (AF.B.B1 & 0x01 ? GB_C_FLAG : 0);
AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B1 & 0x80);
AF.B.B0 |= ZeroTable[AF.B.B1];
break;
@ -406,317 +406,317 @@ AF.B.B0 = ZeroTable[AF.B.B1];
break;
case 0x38:
// SRL B
AF.B.B0 = (BC.B.B1 & 0x01) ? C_FLAG : 0;
AF.B.B0 = (BC.B.B1 & 0x01) ? GB_C_FLAG : 0;
BC.B.B1 >>= 1;
AF.B.B0 |= ZeroTable[BC.B.B1];
break;
case 0x39:
// SRL C
AF.B.B0 = (BC.B.B0 & 0x01) ? C_FLAG : 0;
AF.B.B0 = (BC.B.B0 & 0x01) ? GB_C_FLAG : 0;
BC.B.B0 >>= 1;
AF.B.B0 |= ZeroTable[BC.B.B0];
break;
case 0x3a:
// SRL D
AF.B.B0 = (DE.B.B1 & 0x01) ? C_FLAG : 0;
AF.B.B0 = (DE.B.B1 & 0x01) ? GB_C_FLAG : 0;
DE.B.B1 >>= 1;
AF.B.B0 |= ZeroTable[DE.B.B1];
break;
case 0x3b:
// SRL E
AF.B.B0 = (DE.B.B0 & 0x01) ? C_FLAG : 0;
AF.B.B0 = (DE.B.B0 & 0x01) ? GB_C_FLAG : 0;
DE.B.B0 >>= 1;
AF.B.B0 |= ZeroTable[DE.B.B0];
break;
case 0x3c:
// SRL H
AF.B.B0 = (HL.B.B1 & 0x01) ? C_FLAG : 0;
AF.B.B0 = (HL.B.B1 & 0x01) ? GB_C_FLAG : 0;
HL.B.B1 >>= 1;
AF.B.B0 |= ZeroTable[HL.B.B1];
break;
case 0x3d:
// SRL L
AF.B.B0 = (HL.B.B0 & 0x01) ? C_FLAG : 0;
AF.B.B0 = (HL.B.B0 & 0x01) ? GB_C_FLAG : 0;
HL.B.B0 >>= 1;
AF.B.B0 |= ZeroTable[HL.B.B0];
break;
case 0x3e:
// SRL (HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (tempValue & 0x01) ? C_FLAG : 0;
AF.B.B0 = (tempValue & 0x01) ? GB_C_FLAG : 0;
tempValue >>= 1;
AF.B.B0 |= ZeroTable[tempValue];
gbWriteMemory(HL.W, tempValue);
break;
case 0x3f:
// SRL A
AF.B.B0 = (AF.B.B1 & 0x01) ? C_FLAG : 0;
AF.B.B0 = (AF.B.B1 & 0x01) ? GB_C_FLAG : 0;
AF.B.B1 >>= 1;
AF.B.B0 |= ZeroTable[AF.B.B1];
break;
case 0x40:
// BIT 0,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x41:
// BIT 0,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x42:
// BIT 0,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x43:
// BIT 0,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x44:
// BIT 0,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x45:
// BIT 0,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x46:
// BIT 0,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x47:
// BIT 0,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 0) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 0) ? 0 : GB_Z_FLAG);
break;
case 0x48:
// BIT 1,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x49:
// BIT 1,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x4a:
// BIT 1,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x4b:
// BIT 1,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x4c:
// BIT 1,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x4d:
// BIT 1,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x4e:
// BIT 1,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x4f:
// BIT 1,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 1) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 1) ? 0 : GB_Z_FLAG);
break;
case 0x50:
// BIT 2,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x51:
// BIT 2,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x52:
// BIT 2,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x53:
// BIT 2,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x54:
// BIT 2,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x55:
// BIT 2,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x56:
// BIT 2,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x57:
// BIT 2,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 2) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 2) ? 0 : GB_Z_FLAG);
break;
case 0x58:
// BIT 3,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x59:
// BIT 3,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x5a:
// BIT 3,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x5b:
// BIT 3,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x5c:
// BIT 3,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x5d:
// BIT 3,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x5e:
// BIT 3,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x5f:
// BIT 3,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 3) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 3) ? 0 : GB_Z_FLAG);
break;
case 0x60:
// BIT 4,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x61:
// BIT 4,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x62:
// BIT 4,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x63:
// BIT 4,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x64:
// BIT 4,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x65:
// BIT 4,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x66:
// BIT 4,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x67:
// BIT 4,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 4) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 4) ? 0 : GB_Z_FLAG);
break;
case 0x68:
// BIT 5,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x69:
// BIT 5,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x6a:
// BIT 5,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x6b:
// BIT 5,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x6c:
// BIT 5,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x6d:
// BIT 5,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x6e:
// BIT 5,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x6f:
// BIT 5,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 5) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 5) ? 0 : GB_Z_FLAG);
break;
case 0x70:
// BIT 6,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x71:
// BIT 6,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x72:
// BIT 6,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x73:
// BIT 6,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x74:
// BIT 6,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x75:
// BIT 6,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x76:
// BIT 6,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x77:
// BIT 6,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 6) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 6) ? 0 : GB_Z_FLAG);
break;
case 0x78:
// BIT 7,B
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B1 & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x79:
// BIT 7,C
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (BC.B.B0 & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x7a:
// BIT 7,D
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B1 & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x7b:
// BIT 7,E
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (DE.B.B0 & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x7c:
// BIT 7,H
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B1 & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x7d:
// BIT 7,L
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (HL.B.B0 & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x7e:
// BIT 7,(HL)
tempValue = gbReadMemory(HL.W);
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (tempValue & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x7f:
// BIT 7,A
AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 7) ? 0 : Z_FLAG);
AF.B.B0 = (AF.B.B0 & GB_C_FLAG) | GB_H_FLAG | (AF.B.B1 & (1 << 7) ? 0 : GB_Z_FLAG);
break;
case 0x80:
// RES 0,B

View File

@ -1,5 +1,5 @@
#include "../common/Types.h"
#include <cstdlib>
#include <cstddef>
#include <cstdint>
uint8_t* gbMemoryMap[16];

View File

@ -1,6 +1,8 @@
#ifndef GBGLOBALS_H
#define GBGLOBALS_H
#include <cstdint>
extern int gbRomSizeMask;
extern int gbRomSize;
extern int gbRamSize;

View File

@ -1,6 +1,7 @@
#ifndef GBMEMORY_H
#define GBMEMORY_H
#include <cstdint>
#include <time.h>
struct mapperMBC1 {

View File

@ -1,6 +1,8 @@
#ifndef VBA_BKS_H
#define VBA_BKS_H
#include <cstdint>
#define readWord(addr) \
((map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + ((map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8) + ((map[(addr + 2) >> 24].address[(addr + 2) & map[(addr + 2) >> 24].mask]) << 16) + ((map[(addr + 3) >> 24].address[(addr + 3) & map[(addr + 3) >> 24].mask]) << 24))
@ -61,4 +63,4 @@ bool doBreak(struct ConditionalBreak* toTest);
// uint8_t printConditionalsFromAddress(uint32_t address);
// void printAllFlagConditionals(uint8_t flag, bool orMode);
// void printAllFlagConditionalsWithAddress(uint32_t address, uint8_t flag, bool orMode);
#endif
#endif

View File

@ -40,32 +40,32 @@ static bool cheatSearchGE(uint32_t a, uint32_t b)
return a >= b;
}
static bool cheatSearchSignedEQ(s32 a, s32 b)
static bool cheatSearchSignedEQ(int32_t a, int32_t b)
{
return a == b;
}
static bool cheatSearchSignedNE(s32 a, s32 b)
static bool cheatSearchSignedNE(int32_t a, int32_t b)
{
return a != b;
}
static bool cheatSearchSignedLT(s32 a, s32 b)
static bool cheatSearchSignedLT(int32_t a, int32_t b)
{
return a < b;
}
static bool cheatSearchSignedLE(s32 a, s32 b)
static bool cheatSearchSignedLE(int32_t a, int32_t b)
{
return a <= b;
}
static bool cheatSearchSignedGT(s32 a, s32 b)
static bool cheatSearchSignedGT(int32_t a, int32_t b)
{
return a > b;
}
static bool cheatSearchSignedGE(s32 a, s32 b)
static bool cheatSearchSignedGE(int32_t a, int32_t b)
{
return a >= b;
}
@ -79,7 +79,7 @@ static bool (*cheatSearchFunc[])(uint32_t, uint32_t) = {
cheatSearchGE
};
static bool (*cheatSearchSignedFunc[])(s32, s32) = {
static bool (*cheatSearchSignedFunc[])(int32_t, int32_t) = {
cheatSearchSignedEQ,
cheatSearchSignedNE,
cheatSearchSignedLT,
@ -111,25 +111,25 @@ void cheatSearchStart(const CheatSearchData* cs)
}
}
s32 cheatSearchSignedRead(uint8_t* data, int off, int size)
int32_t cheatSearchSignedRead(uint8_t* data, int off, int size)
{
uint32_t res = data[off++];
switch (size) {
case BITS_8:
res <<= 24;
return ((s32)res) >> 24;
return ((int32_t)res) >> 24;
case BITS_16:
res |= ((uint32_t)data[off++]) << 8;
res <<= 16;
return ((s32)res) >> 16;
return ((int32_t)res) >> 16;
case BITS_32:
res |= ((uint32_t)data[off++]) << 8;
res |= ((uint32_t)data[off++]) << 16;
res |= ((uint32_t)data[off++]) << 24;
return (s32)res;
return (int32_t)res;
}
return (s32)res;
return (int32_t)res;
}
uint32_t cheatSearchRead(uint8_t* data, int off, int size)
@ -157,7 +157,7 @@ void cheatSearch(const CheatSearchData* cs, int compare, int size,
inc = 4;
if (isSigned) {
bool (*func)(s32, s32) = cheatSearchSignedFunc[compare];
bool (*func)(int32_t, int32_t) = cheatSearchSignedFunc[compare];
for (int i = 0; i < cs->count; i++) {
CheatSearchBlock* block = &cs->blocks[i];
@ -168,8 +168,8 @@ void cheatSearch(const CheatSearchData* cs, int compare, int size,
for (int j = 0; j < size2; j += inc) {
if (IS_BIT_SET(bits, j)) {
s32 a = cheatSearchSignedRead(data, j, size);
s32 b = cheatSearchSignedRead(saved, j, size);
int32_t a = cheatSearchSignedRead(data, j, size);
int32_t b = cheatSearchSignedRead(saved, j, size);
if (!func(a, b)) {
CLEAR_BIT(bits, j);
@ -225,7 +225,7 @@ void cheatSearchValue(const CheatSearchData* cs, int compare, int size,
inc = 4;
if (isSigned) {
bool (*func)(s32, s32) = cheatSearchSignedFunc[compare];
bool (*func)(int32_t, int32_t) = cheatSearchSignedFunc[compare];
for (int i = 0; i < cs->count; i++) {
CheatSearchBlock* block = &cs->blocks[i];
@ -235,8 +235,8 @@ void cheatSearchValue(const CheatSearchData* cs, int compare, int size,
for (int j = 0; j < size2; j += inc) {
if (IS_BIT_SET(bits, j)) {
s32 a = cheatSearchSignedRead(data, j, size);
s32 b = (s32)value;
int32_t a = cheatSearchSignedRead(data, j, size);
int32_t b = (int32_t)value;
if (!func(a, b)) {
CLEAR_BIT(bits, j);

View File

@ -1021,62 +1021,62 @@ int cheatsCheckKeys(uint32_t keys, uint32_t extended)
i += 2;
break;
case GSA_8_BIT_IF_LOWER_S:
if (!((s8)CPUReadByte(cheatsList[i].address) < ((s8)cheatsList[i].value & 0xFF))) {
if (!((int8_t)CPUReadByte(cheatsList[i].address) < ((int8_t)cheatsList[i].value & 0xFF))) {
i++;
}
break;
case GSA_16_BIT_IF_LOWER_S:
if (!((s16)CPUReadHalfWord(cheatsList[i].address) < ((s16)cheatsList[i].value & 0xFFFF))) {
if (!((int16_t)CPUReadHalfWord(cheatsList[i].address) < ((int16_t)cheatsList[i].value & 0xFFFF))) {
i++;
}
break;
case GSA_32_BIT_IF_LOWER_S:
if (!((s32)CPUReadMemory(cheatsList[i].address) < (s32)cheatsList[i].value)) {
if (!((int32_t)CPUReadMemory(cheatsList[i].address) < (int32_t)cheatsList[i].value)) {
i++;
}
break;
case GSA_8_BIT_IF_HIGHER_S:
if (!((s8)CPUReadByte(cheatsList[i].address) > ((s8)cheatsList[i].value & 0xFF))) {
if (!((int8_t)CPUReadByte(cheatsList[i].address) > ((int8_t)cheatsList[i].value & 0xFF))) {
i++;
}
break;
case GSA_16_BIT_IF_HIGHER_S:
if (!((s16)CPUReadHalfWord(cheatsList[i].address) > ((s16)cheatsList[i].value & 0xFFFF))) {
if (!((int16_t)CPUReadHalfWord(cheatsList[i].address) > ((int16_t)cheatsList[i].value & 0xFFFF))) {
i++;
}
break;
case GSA_32_BIT_IF_HIGHER_S:
if (!((s32)CPUReadMemory(cheatsList[i].address) > (s32)cheatsList[i].value)) {
if (!((int32_t)CPUReadMemory(cheatsList[i].address) > (int32_t)cheatsList[i].value)) {
i++;
}
break;
case GSA_8_BIT_IF_LOWER_S2:
if (!((s8)CPUReadByte(cheatsList[i].address) < ((s8)cheatsList[i].value & 0xFF))) {
if (!((int8_t)CPUReadByte(cheatsList[i].address) < ((int8_t)cheatsList[i].value & 0xFF))) {
i += 2;
}
break;
case GSA_16_BIT_IF_LOWER_S2:
if (!((s16)CPUReadHalfWord(cheatsList[i].address) < ((s16)cheatsList[i].value & 0xFFFF))) {
if (!((int16_t)CPUReadHalfWord(cheatsList[i].address) < ((int16_t)cheatsList[i].value & 0xFFFF))) {
i += 2;
}
break;
case GSA_32_BIT_IF_LOWER_S2:
if (!((s32)CPUReadMemory(cheatsList[i].address) < (s32)cheatsList[i].value)) {
if (!((int32_t)CPUReadMemory(cheatsList[i].address) < (int32_t)cheatsList[i].value)) {
i += 2;
}
break;
case GSA_8_BIT_IF_HIGHER_S2:
if (!((s8)CPUReadByte(cheatsList[i].address) > ((s8)cheatsList[i].value & 0xFF))) {
if (!((int8_t)CPUReadByte(cheatsList[i].address) > ((int8_t)cheatsList[i].value & 0xFF))) {
i += 2;
}
break;
case GSA_16_BIT_IF_HIGHER_S2:
if (!((s16)CPUReadHalfWord(cheatsList[i].address) > ((s16)cheatsList[i].value & 0xFFFF))) {
if (!((int16_t)CPUReadHalfWord(cheatsList[i].address) > ((int16_t)cheatsList[i].value & 0xFFFF))) {
i += 2;
}
break;
case GSA_32_BIT_IF_HIGHER_S2:
if (!((s32)CPUReadMemory(cheatsList[i].address) > (s32)cheatsList[i].value)) {
if (!((int32_t)CPUReadMemory(cheatsList[i].address) > (int32_t)cheatsList[i].value)) {
i += 2;
}
break;
@ -1123,32 +1123,32 @@ int cheatsCheckKeys(uint32_t keys, uint32_t extended)
}
break;
case GSA_8_BIT_IF_LOWER_S3:
if (!((s8)CPUReadByte(cheatsList[i].address) < ((s8)cheatsList[i].value & 0xFF))) {
if (!((int8_t)CPUReadByte(cheatsList[i].address) < ((int8_t)cheatsList[i].value & 0xFF))) {
onoff = false;
}
break;
case GSA_16_BIT_IF_LOWER_S3:
if (!((s16)CPUReadHalfWord(cheatsList[i].address) < ((s16)cheatsList[i].value & 0xFFFF))) {
if (!((int16_t)CPUReadHalfWord(cheatsList[i].address) < ((int16_t)cheatsList[i].value & 0xFFFF))) {
onoff = false;
}
break;
case GSA_32_BIT_IF_LOWER_S3:
if (!((s32)CPUReadMemory(cheatsList[i].address) < (s32)cheatsList[i].value)) {
if (!((int32_t)CPUReadMemory(cheatsList[i].address) < (int32_t)cheatsList[i].value)) {
onoff = false;
}
break;
case GSA_8_BIT_IF_HIGHER_S3:
if (!((s8)CPUReadByte(cheatsList[i].address) > ((s8)cheatsList[i].value & 0xFF))) {
if (!((int8_t)CPUReadByte(cheatsList[i].address) > ((int8_t)cheatsList[i].value & 0xFF))) {
onoff = false;
}
break;
case GSA_16_BIT_IF_HIGHER_S3:
if (!((s16)CPUReadHalfWord(cheatsList[i].address) > ((s16)cheatsList[i].value & 0xFFFF))) {
if (!((int16_t)CPUReadHalfWord(cheatsList[i].address) > ((int16_t)cheatsList[i].value & 0xFFFF))) {
onoff = false;
}
break;
case GSA_32_BIT_IF_HIGHER_S3:
if (!((s32)CPUReadMemory(cheatsList[i].address) > (s32)cheatsList[i].value)) {
if (!((int32_t)CPUReadMemory(cheatsList[i].address) > (int32_t)cheatsList[i].value)) {
onoff = false;
}
break;

View File

@ -1,6 +1,9 @@
#ifndef EEPROM_H
#define EEPROM_H
#include <cstdint>
#include <zlib.h>
#ifdef __LIBRETRO__
extern void eepromSaveGame(uint8_t*& data);
extern void eepromReadGame(const uint8_t*& data, int version);

View File

@ -1,6 +1,9 @@
#ifndef FLASH_H
#define FLASH_H
#include <cstdint>
#include <zlib.h>
#define FLASH_128K_SZ 0x20000
#ifdef __LIBRETRO__

View File

@ -725,11 +725,13 @@ static void count(uint32_t opcode, int cond_res)
V_FLAG = ((NEG(lhs) & POS(rhs) & POS(res)) | (POS(lhs) & NEG(rhs) & NEG(res))) ? true : false; \
C_FLAG = ((NEG(lhs) & POS(rhs)) | (NEG(lhs) & POS(res)) | (POS(rhs) & POS(res))) ? true : false;
#define maybe_unused(var) (void) var
#ifndef ALU_INIT_C
#define ALU_INIT_C \
int dest = (opcode >> 12) & 15; \
bool C_OUT = C_FLAG; \
uint32_t value;
#define ALU_INIT_C \
int dest = (opcode >> 12) & 15; maybe_unused(dest); \
bool C_OUT = C_FLAG; maybe_unused(C_OUT); \
uint32_t value; maybe_unused(value);
#endif
// OP Rd,Rb,Rm LSL #
#ifndef VALUE_LSL_IMM_C
@ -1250,6 +1252,11 @@ DEFINE_ALU_INSN_C(1F, 3F, MVNS, YES)
busPrefetchCount = ((busPrefetchCount + 1) << clockTicks) - 1; \
clockTicks += 1 + codeTicksAccess32(armNextPC);
typedef uint64_t u64;
typedef int64_t s64;
typedef uint64_t u32;
typedef int64_t s32;
#define OP_MUL \
reg[dest].I = reg[mult].I * rs;
#define OP_MLA \
@ -2974,4 +2981,4 @@ int armExecute()
} while (cpuTotalTicks < cpuNextEvent && armState && !holdState && !SWITicks && !debugger);
return 1;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -4239,7 +4239,7 @@ void CPULoop(int ticks)
}
#ifdef TILED_RENDERING
union u8h {
union uint8_th {
struct
{
/* 0*/ unsigned lo : 4;
@ -4316,7 +4316,7 @@ inline const TileLine gfxReadTilePal(const uint16_t* screenSource, const int yyy
palette += tile.palette * 16;
TileLine tileLine;
const u8h* tileBase = (u8h*)&charBase[tile.tileNum * 32 + tileY * 4];
const uint8_th* tileBase = (uint8_th*)&charBase[tile.tileNum * 32 + tileY * 4];
if (!tile.hFlip) {
gfxDrawPixel(&tileLine.pixels[0], tileBase[0].lo, palette, prio);

View File

@ -1,6 +1,8 @@
#ifndef GBA_H
#define GBA_H
#include <cstdint>
#include "../System.h"
const uint64_t TICKS_PER_SECOND = 16777216;

View File

@ -14,7 +14,7 @@
#define snprintf _snprintf
#endif
#define UPDATE_REG(address, value) WRITE16LE(((u16*)&ioMem[address]), value)
#define UPDATE_REG(address, value) WRITE16LE(((uint16_t*)&ioMem[address]), value)
static int vbaid = 0;
const char* MakeInstanceFilename(const char* Input)
@ -225,9 +225,9 @@ int WaitForSingleObject(sem_t* s, int t)
#define JOYBUS 4
#define GP 5
static int GetSIOMode(u16, u16);
static int GetSIOMode(uint16_t, uint16_t);
static ConnectionState InitSocket();
static void StartCableSocket(u16 siocnt);
static void StartCableSocket(uint16_t siocnt);
static ConnectionState ConnectUpdateSocket(char* const message, size_t size);
static void UpdateCableSocket(int ticks);
static void CloseSocket();
@ -236,9 +236,9 @@ const u64 TICKS_PER_FRAME = TICKS_PER_SECOND / 60;
const u64 BITS_PER_SECOND = 115200;
const u64 BYTES_PER_SECOND = BITS_PER_SECOND / 8;
static u32 lastjoybusupdate = 0;
static u32 nextjoybusupdate = 0;
static u32 lastcommand = 0;
static uint32_t lastjoybusupdate = 0;
static uint32_t nextjoybusupdate = 0;
static uint32_t lastcommand = 0;
static bool booted = false;
static ConnectionState JoyBusConnect();
@ -246,7 +246,7 @@ static void JoyBusUpdate(int ticks);
static void JoyBusShutdown();
static ConnectionState ConnectUpdateRFUSocket(char* const message, size_t size);
static void StartRFUSocket(u16 siocnt);
static void StartRFUSocket(uint16_t siocnt);
bool LinkRFUUpdateSocket();
static void UpdateRFUSocket(int ticks);
@ -256,34 +256,34 @@ static void UpdateRFUSocket(int ticks);
#define RFU_RECV 3
typedef struct {
u16 linkdata[5];
u16 linkcmd[4];
u16 numtransfers;
s32 lastlinktime;
u8 numgbas; //# of GBAs (max vbaid value plus 1), used in Single computer
u8 trgbas;
u8 linkflags;
uint16_t linkdata[5];
uint16_t linkcmd[4];
uint16_t numtransfers;
int32_t lastlinktime;
uint8_t numgbas; //# of GBAs (max vbaid value plus 1), used in Single computer
uint8_t trgbas;
uint8_t linkflags;
u8 rfu_proto[5]; // 0=UDP-like, 1=TCP-like protocols to see whether the data important or not (may or may not be received successfully by the other side)
u16 rfu_qid[5];
s32 rfu_q[5];
u32 rfu_signal[5];
u8 rfu_is_host[5]; //request to join
//u8 rfu_joined[5]; //bool //currenlty joined
u16 rfu_reqid[5]; //id to join
u16 rfu_clientidx[5]; //only used by clients
s32 rfu_linktime[5];
u32 rfu_broadcastdata[5][7]; //for 0x16/0x1d/0x1e?
u32 rfu_gdata[5]; //for 0x17/0x19?/0x1e?
s32 rfu_state[5]; //0=none, 1=waiting for ACK
u8 rfu_listfront[5];
u8 rfu_listback[5];
uint8_t rfu_proto[5]; // 0=UDP-like, 1=TCP-like protocols to see whether the data important or not (may or may not be received successfully by the other side)
uint16_t rfu_qid[5];
int32_t rfu_q[5];
uint32_t rfu_signal[5];
uint8_t rfu_is_host[5]; //request to join
//uint8_t rfu_joined[5]; //bool //currenlty joined
uint16_t rfu_reqid[5]; //id to join
uint16_t rfu_clientidx[5]; //only used by clients
int32_t rfu_linktime[5];
uint32_t rfu_broadcastdata[5][7]; //for 0x16/0x1d/0x1e?
uint32_t rfu_gdata[5]; //for 0x17/0x19?/0x1e?
int32_t rfu_state[5]; //0=none, 1=waiting for ACK
uint8_t rfu_listfront[5];
uint8_t rfu_listback[5];
rfu_datarec rfu_datalist[5][256];
/*u16 rfu_qidlist[5][256];
u16 rfu_qlist[5][256];
u32 rfu_datalist[5][256][255];
u32 rfu_timelist[5][256];*/
/*uint16_t rfu_qidlist[5][256];
uint16_t rfu_qlist[5][256];
uint32_t rfu_datalist[5][256][255];
uint32_t rfu_timelist[5][256];*/
} LINKDATA;
class RFUServer {
@ -291,7 +291,7 @@ class RFUServer {
sf::SocketSelector fdset;
int counter;
int done;
u8 current_host;
uint8_t current_host;
public:
sf::TcpSocket tcpsocket[5];
@ -322,14 +322,14 @@ public:
// RFU crap (except for numtransfers note...should probably check that out)
static LINKDATA* linkmem = NULL;
static LINKDATA rfu_data;
static u8 rfu_cmd, rfu_qsend, rfu_qrecv_broadcast_data_len;
static uint8_t rfu_cmd, rfu_qsend, rfu_qrecv_broadcast_data_len;
static int rfu_state, rfu_polarity, rfu_counter, rfu_masterq;
// numtransfers seems to be used interchangeably with linkmem->numtransfers
// in rfu code; probably a bug?
static int rfu_transfer_end;
// in local comm, setting this keeps slaves from trying to communicate even
// when master isn't
static u16 numtransfers = 0;
static uint16_t numtransfers = 0;
// time until next broadcast
static int rfu_last_broadcast_time;
@ -337,27 +337,27 @@ static int rfu_last_broadcast_time;
// timer to sync data
static int rfu_last_host_send_time;
static u32 rfu_masterdata[255];
static uint32_t rfu_masterdata[255];
bool rfu_enabled = false;
bool rfu_initialized = false;
bool rfu_waiting = false;
u8 rfu_qsend2, rfu_cmd2, rfu_lastcmd, rfu_lastcmd2;
u16 rfu_id, rfu_idx;
uint8_t rfu_qsend2, rfu_cmd2, rfu_lastcmd, rfu_lastcmd2;
uint16_t rfu_id, rfu_idx;
static int gbaid = 0;
static int gbaidx = 0;
bool rfu_ishost, rfu_cansend;
int rfu_lasttime;
u32 rfu_buf;
u16 PrevVAL = 0;
u32 PrevCOM = 0, PrevDAT = 0;
u8 rfu_numclients = 0;
u8 rfu_curclient = 0;
u32 rfu_clientlist[5];
uint32_t rfu_buf;
uint16_t PrevVAL = 0;
uint32_t PrevCOM = 0, PrevDAT = 0;
uint8_t rfu_numclients = 0;
uint8_t rfu_curclient = 0;
uint32_t rfu_clientlist[5];
static RFUServer rfu_server;
static RFUClient rfu_client;
u8 gbSIO_SC = 0;
uint8_t gbSIO_SC = 0;
bool EmuReseted = true;
bool LinkIsWaiting = false;
bool LinkFirstTime = true;
@ -365,10 +365,10 @@ bool LinkFirstTime = true;
#if (defined __WIN32__ || defined _WIN32)
static ConnectionState InitIPC();
static void StartCableIPC(u16 siocnt);
static void StartCableIPC(uint16_t siocnt);
static void ReconnectCableIPC();
static void UpdateCableIPC(int ticks);
static void StartRFU(u16 siocnt);
static void StartRFU(uint16_t siocnt);
static void UpdateRFUIPC(int ticks);
static void CloseIPC();
@ -377,7 +377,7 @@ static void CloseIPC();
struct LinkDriver {
typedef ConnectionState(ConnectFunc)();
typedef ConnectionState(ConnectUpdateFunc)(char* const message, size_t size);
typedef void(StartFunc)(u16 siocnt);
typedef void(StartFunc)(uint16_t siocnt);
typedef void(UpdateFunc)(int ticks);
typedef void(CloseFunc)();
@ -432,10 +432,10 @@ class CableServer {
sf::SocketSelector fdset;
//timeval udptimeout;
char inbuffer[256], outbuffer[256];
s32* intinbuffer;
u16* u16inbuffer;
s32* intoutbuffer;
u16* u16outbuffer;
int32_t* intinbuffer;
uint16_t* uint16_tinbuffer;
int32_t* intoutbuffer;
uint16_t* uint16_toutbuffer;
int counter;
int done;
@ -452,10 +452,10 @@ public:
class CableClient {
sf::SocketSelector fdset;
char inbuffer[256], outbuffer[256];
s32* intinbuffer;
u16* u16inbuffer;
s32* intoutbuffer;
u16* u16outbuffer;
int32_t* intinbuffer;
uint16_t* uint16_tinbuffer;
int32_t* intoutbuffer;
uint16_t* uint16_toutbuffer;
int numbytes;
public:
@ -473,8 +473,8 @@ public:
static int i, j;
static int linktimeout = 1;
static LANLINKDATA lanlink;
static u16 cable_data[4];
static u8 cable_gb_data[4];
static uint16_t cable_data[4];
static uint8_t cable_gb_data[4];
static CableServer ls;
static CableClient lc;
@ -501,7 +501,7 @@ static const int trtimeend[3][4] = {
};
// Hodgepodge
static u8 tspeed = 3;
static uint8_t tspeed = 3;
static bool transfer_direction = false;
static int linkid = 0;
#if (defined __WIN32__ || defined _WIN32)
@ -521,7 +521,7 @@ static char linkevent[] =
#endif
"VBA link event ";
inline static int GetSIOMode(u16 siocnt, u16 rcnt)
inline static int GetSIOMode(uint16_t siocnt, uint16_t rcnt)
{
if (!(rcnt & 0x8000)) {
switch (siocnt & 0x3000) {
@ -667,7 +667,7 @@ ConnectionState InitLink(LinkMode mode)
// Find the link driver
linkDriver = NULL;
for (u8 i = 0; i < sizeof(linkDrivers) / sizeof(linkDrivers[0]); i++) {
for (uint8_t i = 0; i < sizeof(linkDrivers) / sizeof(linkDrivers[0]); i++) {
if (linkDrivers[i].mode == mode) {
linkDriver = &linkDrivers[i];
break;
@ -689,7 +689,7 @@ ConnectionState InitLink(LinkMode mode)
return gba_connection_state;
}
void StartLink(u16 siocnt)
void StartLink(uint16_t siocnt)
{
if (!linkDriver || !linkDriver->start) {
return;
@ -714,7 +714,7 @@ ConnectionState ConnectLinkUpdate(char* const message, size_t size)
return gba_connection_state;
}
void StartGPLink(u16 value)
void StartGPLink(uint16_t value)
{
UPDATE_REG(COMM_RCNT, value);
@ -777,17 +777,17 @@ void CloseLink(void)
// Server
CableServer::CableServer(void)
{
intinbuffer = (s32*)inbuffer;
u16inbuffer = (u16*)inbuffer;
intoutbuffer = (s32*)outbuffer;
u16outbuffer = (u16*)outbuffer;
intinbuffer = (int32_t*)inbuffer;
uint16_tinbuffer = (uint16_t*)inbuffer;
intoutbuffer = (int32_t*)outbuffer;
uint16_toutbuffer = (uint16_t*)outbuffer;
}
void CableServer::Send(void)
{
if (lanlink.type == 0) { // TCP
outbuffer[1] = tspeed;
WRITE16LE(&u16outbuffer[1], cable_data[0]);
WRITE16LE(&uint16_toutbuffer[1], cable_data[0]);
WRITE32LE(&intoutbuffer[1], transfer_start_time_from_master);
if (lanlink.numslaves == 1) {
@ -796,22 +796,22 @@ void CableServer::Send(void)
tcpsocket[1].send(outbuffer, 8);
}
} else if (lanlink.numslaves == 2) {
WRITE16LE(&u16outbuffer[4], cable_data[2]);
WRITE16LE(&uint16_toutbuffer[4], cable_data[2]);
if (lanlink.type == 0) {
outbuffer[0] = 10;
tcpsocket[1].send(outbuffer, 10);
WRITE16LE(&u16outbuffer[4], cable_data[1]);
WRITE16LE(&uint16_toutbuffer[4], cable_data[1]);
tcpsocket[2].send(outbuffer, 10);
}
} else {
if (lanlink.type == 0) {
outbuffer[0] = 12;
WRITE16LE(&u16outbuffer[4], cable_data[2]);
WRITE16LE(&u16outbuffer[5], cable_data[3]);
WRITE16LE(&uint16_toutbuffer[4], cable_data[2]);
WRITE16LE(&uint16_toutbuffer[5], cable_data[3]);
tcpsocket[1].send(outbuffer, 12);
WRITE16LE(&u16outbuffer[4], cable_data[1]);
WRITE16LE(&uint16_toutbuffer[4], cable_data[1]);
tcpsocket[2].send(outbuffer, 12);
WRITE16LE(&u16outbuffer[5], cable_data[2]);
WRITE16LE(&uint16_toutbuffer[5], cable_data[2]);
tcpsocket[3].send(outbuffer, 12);
}
}
@ -856,7 +856,7 @@ void CableServer::Recv(void)
CloseLink();
return;
}
cable_data[i + 1] = READ16LE(&u16inbuffer[1]);
cable_data[i + 1] = READ16LE(&uint16_tinbuffer[1]);
}
}
return;
@ -896,7 +896,7 @@ bool CableServer::RecvGB(void)
for (i = 0; i < lanlink.numslaves; i++) {
numbytes = 0;
u8 recv_byte = 0;
uint8_t recv_byte = 0;
size_t nr;
tcpsocket[i + 1].receive(&recv_byte, 1, nr);
@ -926,10 +926,10 @@ bool CableServer::RecvGB(void)
// Client
CableClient::CableClient(void)
{
intinbuffer = (s32*)inbuffer;
u16inbuffer = (u16*)inbuffer;
intoutbuffer = (s32*)outbuffer;
u16outbuffer = (u16*)outbuffer;
intinbuffer = (int32_t*)inbuffer;
uint16_tinbuffer = (uint16_t*)inbuffer;
intoutbuffer = (int32_t*)outbuffer;
uint16_toutbuffer = (uint16_t*)outbuffer;
transferring = false;
return;
}
@ -953,11 +953,11 @@ void CableClient::CheckConn(void)
}
transferring = true;
transfer_start_time_from_master = 0;
cable_data[0] = READ16LE(&u16inbuffer[1]);
cable_data[0] = READ16LE(&uint16_tinbuffer[1]);
tspeed = inbuffer[1] & 3;
for (i = 1, numbytes = 4; i <= lanlink.numslaves; i++)
if (i != linkid) {
cable_data[i] = READ16LE(&u16inbuffer[numbytes]);
cable_data[i] = READ16LE(&uint16_tinbuffer[numbytes]);
numbytes++;
}
}
@ -978,7 +978,7 @@ bool CableClient::RecvGB(void)
}
numbytes = 0;
size_t nr;
u8 recv_byte = 0;
uint8_t recv_byte = 0;
lanlink.tcpsocket.receive(&recv_byte, 1, nr);
numbytes += nr;
@ -1032,11 +1032,11 @@ void CableClient::Recv(void)
return;
}
tspeed = inbuffer[1] & 3;
cable_data[0] = READ16LE(&u16inbuffer[1]);
transfer_start_time_from_master = (s32)READ32LE(&intinbuffer[1]);
cable_data[0] = READ16LE(&uint16_tinbuffer[1]);
transfer_start_time_from_master = (int32_t)READ32LE(&intinbuffer[1]);
for (i = 1, numbytes = 4; i < lanlink.numslaves + 1; i++) {
if (i != linkid) {
cable_data[i] = READ16LE(&u16inbuffer[numbytes]);
cable_data[i] = READ16LE(&uint16_tinbuffer[numbytes]);
numbytes++;
}
}
@ -1046,7 +1046,7 @@ void CableClient::Send()
{
outbuffer[0] = 4;
outbuffer[1] = linkid << 2;
WRITE16LE(&u16outbuffer[1], cable_data[linkid]);
WRITE16LE(&uint16_toutbuffer[1], cable_data[linkid]);
lanlink.tcpsocket.send(outbuffer, 4);
return;
}
@ -1173,7 +1173,7 @@ static ConnectionState ConnectUpdateSocket(char* const message, size_t size)
return newState;
}
void StartCableSocket(u16 value)
void StartCableSocket(uint16_t value)
{
switch (GetSIOMode(value, READ16LE(&ioMem[COMM_RCNT]))) {
case MULTIPLAYER: {
@ -1346,7 +1346,7 @@ static void JoyBusUpdate(int ticks)
char data[5] = { 0x10, 0, 0, 0, 0 }; // init with invalid cmd
std::vector<char> resp;
u8 cmd = 0x10;
uint8_t cmd = 0x10;
if (lastcommand > (TICKS_PER_FRAME * 4)) {
cmd = dol->ReceiveCmd(data, true);
@ -1370,10 +1370,10 @@ static void JoyBusUpdate(int ticks)
break;
case JOY_CMD_READ:
resp.push_back((u8)(READ16LE(&ioMem[COMM_JOY_TRANS_L]) & 0xff));
resp.push_back((u8)(READ16LE(&ioMem[COMM_JOY_TRANS_L]) >> 8));
resp.push_back((u8)(READ16LE(&ioMem[COMM_JOY_TRANS_H]) & 0xff));
resp.push_back((u8)(READ16LE(&ioMem[COMM_JOY_TRANS_H]) >> 8));
resp.push_back((uint8_t)(READ16LE(&ioMem[COMM_JOY_TRANS_L]) & 0xff));
resp.push_back((uint8_t)(READ16LE(&ioMem[COMM_JOY_TRANS_L]) >> 8));
resp.push_back((uint8_t)(READ16LE(&ioMem[COMM_JOY_TRANS_H]) & 0xff));
resp.push_back((uint8_t)(READ16LE(&ioMem[COMM_JOY_TRANS_H]) >> 8));
UPDATE_REG(COMM_JOYCNT, READ16LE(&ioMem[COMM_JOYCNT]) | JOYCNT_SEND_COMPLETE);
nextjoybusupdate = TICKS_PER_SECOND / BYTES_PER_SECOND;
@ -1381,8 +1381,8 @@ static void JoyBusUpdate(int ticks)
break;
case JOY_CMD_WRITE:
UPDATE_REG(COMM_JOY_RECV_L, (u16)((u16)data[2] << 8) | (u8)data[1]);
UPDATE_REG(COMM_JOY_RECV_H, (u16)((u16)data[4] << 8) | (u8)data[3]);
UPDATE_REG(COMM_JOY_RECV_L, (uint16_t)((uint16_t)data[2] << 8) | (uint8_t)data[1]);
UPDATE_REG(COMM_JOY_RECV_H, (uint16_t)((uint16_t)data[4] << 8) | (uint8_t)data[3]);
UPDATE_REG(COMM_JOYSTAT, READ16LE(&ioMem[COMM_JOYSTAT]) | JOYSTAT_RECV);
UPDATE_REG(COMM_JOYCNT, READ16LE(&ioMem[COMM_JOYCNT]) | JOYCNT_RECV_COMPLETE);
nextjoybusupdate = TICKS_PER_SECOND / BYTES_PER_SECOND;
@ -1396,7 +1396,7 @@ static void JoyBusUpdate(int ticks)
}
lastjoybusupdate = 0;
resp.push_back((u8)READ16LE(&ioMem[COMM_JOYSTAT]));
resp.push_back((uint8_t)READ16LE(&ioMem[COMM_JOYSTAT]));
if (cmd == JOY_CMD_READ) {
UPDATE_REG(COMM_JOYSTAT, READ16LE(&ioMem[COMM_JOYSTAT]) & ~JOYSTAT_SEND);
@ -1478,7 +1478,7 @@ void RFUServer::DeSerialize(sf::Packet packet, int slave)
for (int i = 0; i < MAX_CLIENTS; i++) {
if (i != slave) {
u8 num_data_sent = 0;
uint8_t num_data_sent = 0;
packet >> rfu_data.rfu_clientidx[i];
packet >> rfu_data.rfu_is_host[i];
packet >> num_data_sent;
@ -1615,7 +1615,7 @@ void RFUClient::DeSerialize(sf::Packet packet)
}
if (i == linkid) {
u8 num_data_sent = 0;
uint8_t num_data_sent = 0;
packet >> rfu_data.rfu_clientidx[i];
packet >> rfu_data.rfu_is_host[i];
packet >> num_data_sent;
@ -1755,7 +1755,7 @@ static ConnectionState ConnectUpdateRFUSocket(char* const message, size_t size)
}
// The GBA wireless RFU (see adapter3.txt)
static void StartRFUSocket(u16 value)
static void StartRFUSocket(uint16_t value)
{
int siomode = GetSIOMode(value, READ16LE(&ioMem[COMM_RCNT]));
@ -1782,7 +1782,7 @@ static void StartRFUSocket(u16 value)
}
static bool logstartd;
u32 CurCOM = 0, CurDAT = 0;
uint32_t CurCOM = 0, CurDAT = 0;
bool rfulogd = (READ16LE(&ioMem[COMM_SIOCNT]) != value);
switch (GetSIOMode(value, READ16LE(&ioMem[COMM_RCNT]))) {
@ -1815,7 +1815,7 @@ static void StartRFUSocket(u16 value)
else
rfu_transfer_end = 256;
u16 siodata_h = READ16LE(&ioMem[COMM_SIODATA32_H]);
uint16_t siodata_h = READ16LE(&ioMem[COMM_SIODATA32_H]);
switch (rfu_state) {
case RFU_INIT:
if (READ32LE(&ioMem[COMM_SIODATA32_L]) == 0xb0bb8001) {
@ -1830,7 +1830,7 @@ static void StartRFUSocket(u16 value)
CurCOM = READ32LE(&ioMem[COMM_SIODATA32_L]);
if (siodata_h == 0x9966) //initialize cmd
{
u8 tmpcmd = CurCOM;
uint8_t tmpcmd = CurCOM;
if (tmpcmd != 0x10 && tmpcmd != 0x11 && tmpcmd != 0x13 && tmpcmd != 0x14 && tmpcmd != 0x16 && tmpcmd != 0x17 && tmpcmd != 0x19 && tmpcmd != 0x1a && tmpcmd != 0x1b && tmpcmd != 0x1c && tmpcmd != 0x1d && tmpcmd != 0x1e && tmpcmd != 0x1f && tmpcmd != 0x20 && tmpcmd != 0x21 && tmpcmd != 0x24 && tmpcmd != 0x25 && tmpcmd != 0x26 && tmpcmd != 0x27 && tmpcmd != 0x30 && tmpcmd != 0x32 && tmpcmd != 0x33 && tmpcmd != 0x34 && tmpcmd != 0x3d && tmpcmd != 0xa8 && tmpcmd != 0xee) {
}
rfu_counter = 0;
@ -1994,8 +1994,8 @@ static void StartRFUSocket(u16 value)
//check signal
if (rfu_data.numgbas >= 2 && (rfu_data.rfu_is_host[linkid] | rfu_data.rfu_is_host[gbaid])) //signal only good when connected
if (rfu_ishost) { //update, just incase there are leaving clients
u8 rfureq = rfu_data.rfu_is_host[linkid];
u8 oldnum = rfu_numclients;
uint8_t rfureq = rfu_data.rfu_is_host[linkid];
uint8_t oldnum = rfu_numclients;
rfu_numclients = 0;
for (int i = 0; i < 8; i++) {
if (rfureq & 1)
@ -2011,11 +2011,11 @@ static void StartRFUSocket(u16 value)
rfu_data.rfu_signal[linkid] = 0;
if (rfu_qrecv_broadcast_data_len == 0) {
rfu_qrecv_broadcast_data_len = 1;
rfu_masterdata[0] = (u32)rfu_data.rfu_signal[linkid];
rfu_masterdata[0] = (uint32_t)rfu_data.rfu_signal[linkid];
}
if (rfu_qrecv_broadcast_data_len > 0) {
rfu_state = RFU_RECV;
rfu_masterdata[rfu_qrecv_broadcast_data_len - 1] = (u32)rfu_data.rfu_signal[gbaid];
rfu_masterdata[rfu_qrecv_broadcast_data_len - 1] = (uint32_t)rfu_data.rfu_signal[gbaid];
}
rfu_cmd ^= 0x80;
break;
@ -2023,7 +2023,7 @@ static void StartRFUSocket(u16 value)
if (rfu_data.rfu_signal[linkid] || numtransfers == 0)
rfu_masterdata[0] = 0;
else //0=success
rfu_masterdata[0] = (u32)-1; //0xffffffff; //1=failed, 2++ = reserved/invalid, we use invalid value to let the game retries 0x33 until signal restored
rfu_masterdata[0] = (uint32_t)-1; //0xffffffff; //1=failed, 2++ = reserved/invalid, we use invalid value to let the game retries 0x33 until signal restored
rfu_cmd ^= 0x80;
rfu_state = RFU_RECV;
rfu_qrecv_broadcast_data_len = 1;
@ -2154,7 +2154,7 @@ static void StartRFUSocket(u16 value)
ctr = 0;
if (rfu_data.rfu_listfront[linkid] != rfu_data.rfu_listback[linkid]) //data existed
do {
u8 qdata_len = rfu_data.rfu_datalist[linkid][rfu_data.rfu_listfront[linkid]].len; //(u8)rfu_data.rfu_qlist[linkid][rfu_data.rfu_listfront[linkid]];
uint8_t qdata_len = rfu_data.rfu_datalist[linkid][rfu_data.rfu_listfront[linkid]].len; //(uint8_t)rfu_data.rfu_qlist[linkid][rfu_data.rfu_listfront[linkid]];
ok = false;
if (qdata_len != rfu_qrecv_broadcast_data_len)
ok = true;
@ -2179,7 +2179,7 @@ static void StartRFUSocket(u16 value)
gbaid = rfu_data.rfu_datalist[linkid][rfu_data.rfu_listfront[linkid]].gbaid;
rfu_id = (gbaid << 3) + 0x61f1;
if (rfu_ishost) {
rfu_curclient = (u8)rfu_data.rfu_clientidx[gbaid];
rfu_curclient = (uint8_t)rfu_data.rfu_clientidx[gbaid];
}
if (rfu_qrecv_broadcast_data_len != 0) { //data size > 0
memcpy(rfu_masterdata, rfu_data.rfu_datalist[linkid][rfu_data.rfu_listfront[linkid]].data, std::min(rfu_masterq << 2, (int)sizeof(rfu_masterdata)));
@ -2489,7 +2489,7 @@ static void UpdateRFUSocket(int ticks)
if (LinkRFUUpdateSocket()) {
if (transfer_direction == RECEIVING && rfu_transfer_end <= 0) {
transfer_direction = SENDING;
u16 value = READ16LE(&ioMem[COMM_SIOCNT]);
uint16_t value = READ16LE(&ioMem[COMM_SIOCNT]);
if (value & SIO_IRQ_ENABLE) {
IF |= 0x80;
UPDATE_REG(0x202, IF);
@ -2518,9 +2518,9 @@ void gbInitLink()
}
}
u8 gbStartLink(u8 b) //used on internal clock
uint8_t gbStartLink(uint8_t b) //used on internal clock
{
u8 dat = 0xff; //master (w/ internal clock) will gets 0xff if slave is turned off (or not ready yet also?)
uint8_t dat = 0xff; //master (w/ internal clock) will gets 0xff if slave is turned off (or not ready yet also?)
//if(linkid) return 0xff; //b; //Slave shouldn't be sending from here
//int gbSerialOn = (gbMemory[0xff02] & 0x80); //not needed?
gba_link_enabled = true; //(gbMemory[0xff02]!=0); //not needed?
@ -2559,10 +2559,10 @@ u8 gbStartLink(u8 b) //used on internal clock
return dat;
}
u16 gbLinkUpdate(u8 b, int gbSerialOn) //used on external clock
uint16_t gbLinkUpdate(uint8_t b, int gbSerialOn) //used on external clock
{
u8 dat = b; //0xff; //slave (w/ external clocks) won't be getting 0xff if master turned off
u8 recvd = 0;
uint8_t dat = b; //0xff; //slave (w/ external clocks) won't be getting 0xff if master turned off
uint8_t recvd = 0;
int idx = 0;
gba_link_enabled = true; //(gbMemory[0xff02]!=0);
@ -2608,7 +2608,7 @@ u16 gbLinkUpdate(u8 b, int gbSerialOn) //used on external clock
if (dat == 0xff /*||dat==0x00||b==0x00*/) //dat==0xff||dat==0x00
LinkFirstTime = true;
}
return ((dat << 8) | (recvd & (u8)0xff));
return ((dat << 8) | (recvd & (uint8_t)0xff));
}
#if (defined __WIN32__ || defined _WIN32)
@ -2724,7 +2724,7 @@ static ConnectionState InitIPC()
return LINK_OK;
}
static void StartCableIPC(u16 value)
static void StartCableIPC(uint16_t value)
{
switch (GetSIOMode(value, READ16LE(&ioMem[COMM_RCNT]))) {
case MULTIPLAYER: {
@ -2952,7 +2952,7 @@ static void UpdateCableIPC(int ticks)
ReleaseSemaphore(linksync[0], 1, NULL);
linktime -= trtimeend[transfer_direction - 3][tspeed];
transfer_direction = 0;
u16 value = READ16LE(&ioMem[COMM_SIOCNT]);
uint16_t value = READ16LE(&ioMem[COMM_SIOCNT]);
if (!linkid)
value |= 4; // SI becomes high on slaves after xfer
UPDATE_REG(COMM_SIOCNT, (value & 0xff0f) | (linkid << 4));
@ -2966,7 +2966,7 @@ static void UpdateCableIPC(int ticks)
}
// The GBA wireless RFU (see adapter3.txt)
static void StartRFU(u16 value)
static void StartRFU(uint16_t value)
{
int siomode = GetSIOMode(value, READ16LE(&ioMem[COMM_RCNT]));
@ -3000,7 +3000,7 @@ static void StartRFU(u16 value)
linktimeout = 1;
static bool logstartd;
u32 CurCOM = 0, CurDAT = 0;
uint32_t CurCOM = 0, CurDAT = 0;
bool rfulogd = (READ16LE(&ioMem[COMM_SIOCNT]) != value);
switch (GetSIOMode(value, READ16LE(&ioMem[COMM_RCNT]))) {
@ -3031,7 +3031,7 @@ static void StartRFU(u16 value)
rfu_transfer_end = 2048;
else
rfu_transfer_end = 256;
u16 siodata_h = READ16LE(&ioMem[COMM_SIODATA32_H]);
uint16_t siodata_h = READ16LE(&ioMem[COMM_SIODATA32_H]);
switch (rfu_state) {
case RFU_INIT:
if (READ32LE(&ioMem[COMM_SIODATA32_L]) == 0xb0bb8001) {
@ -3046,7 +3046,7 @@ static void StartRFU(u16 value)
CurCOM = READ32LE(&ioMem[COMM_SIODATA32_L]);
if (siodata_h == 0x9966) //initialize cmd
{
u8 tmpcmd = CurCOM;
uint8_t tmpcmd = CurCOM;
if (tmpcmd != 0x10 && tmpcmd != 0x11 && tmpcmd != 0x13 && tmpcmd != 0x14 && tmpcmd != 0x16 && tmpcmd != 0x17 && tmpcmd != 0x19 && tmpcmd != 0x1a && tmpcmd != 0x1b && tmpcmd != 0x1c && tmpcmd != 0x1d && tmpcmd != 0x1e && tmpcmd != 0x1f && tmpcmd != 0x20 && tmpcmd != 0x21 && tmpcmd != 0x24 && tmpcmd != 0x25 && tmpcmd != 0x26 && tmpcmd != 0x27 && tmpcmd != 0x30 && tmpcmd != 0x32 && tmpcmd != 0x33 && tmpcmd != 0x34 && tmpcmd != 0x3d && tmpcmd != 0xa8 && tmpcmd != 0xee) {
log("%08X : UnkCMD %08X %04X %08X %08X\n", GetTickCount(), CurCOM, PrevVAL, PrevCOM, PrevDAT);
}
@ -3285,8 +3285,8 @@ static void StartRFU(u16 value)
//check signal
if (linkmem->numgbas >= 2 && (linkmem->rfu_is_host[vbaid] | linkmem->rfu_is_host[gbaid])) //signal only good when connected
if (rfu_ishost) { //update, just incase there are leaving clients
u8 rfureq = linkmem->rfu_is_host[vbaid];
u8 oldnum = rfu_numclients;
uint8_t rfureq = linkmem->rfu_is_host[vbaid];
uint8_t oldnum = rfu_numclients;
rfu_numclients = 0;
for (int i = 0; i < 8; i++) {
if (rfureq & 1)
@ -3315,24 +3315,24 @@ static void StartRFU(u16 value)
} while (i!=gbaid);*/
/*if(rfu_numclients>0)
for(int i=0; i<rfu_numclients; i++) {
u32 cid = (rfu_clientlist[i] & 0x0ffff);
uint32_t cid = (rfu_clientlist[i] & 0x0ffff);
if(cid>=0x61f1) {
cid = (cid-0x61f1)>>3;
rfu_masterdata[rfu_qrecv++] = linkmem->rfu_signal[cid] = 0xffffffff>>((3-linkmem->rfu_clientidx[cid])<<3); //0x0ff << (linkmem->rfu_clientidx[cid]<<3);
}
}*/
//rfu_masterdata[0] = (u32)linkmem->rfu_signal[vbaid];
//rfu_masterdata[0] = (uint32_t)linkmem->rfu_signal[vbaid];
}
if (rfu_qrecv_broadcast_data_len == 0) {
rfu_qrecv_broadcast_data_len = 1;
rfu_masterdata[0] = (u32)linkmem->rfu_signal[vbaid];
rfu_masterdata[0] = (uint32_t)linkmem->rfu_signal[vbaid];
}
if (rfu_qrecv_broadcast_data_len > 0) {
rfu_state = RFU_RECV;
int hid = vbaid;
if (!rfu_ishost)
hid = gbaid;
rfu_masterdata[rfu_qrecv_broadcast_data_len - 1] = (u32)linkmem->rfu_signal[hid];
rfu_masterdata[rfu_qrecv_broadcast_data_len - 1] = (uint32_t)linkmem->rfu_signal[hid];
}
rfu_cmd ^= 0x80;
//rfu_polarity = 0;
@ -3350,7 +3350,7 @@ static void StartRFU(u16 value)
if (linkmem->rfu_signal[vbaid] || numtransfers == 0)
rfu_masterdata[0] = 0;
else //0=success
rfu_masterdata[0] = (u32)-1; //0xffffffff; //1=failed, 2++ = reserved/invalid, we use invalid value to let the game retries 0x33 until signal restored
rfu_masterdata[0] = (uint32_t)-1; //0xffffffff; //1=failed, 2++ = reserved/invalid, we use invalid value to let the game retries 0x33 until signal restored
rfu_cmd ^= 0x80;
rfu_state = RFU_RECV;
rfu_qrecv_broadcast_data_len = 1;
@ -3521,7 +3521,7 @@ static void StartRFU(u16 value)
//do
{
if(rfu_numclients>0) { //is a host
u8 cc = rfu_curclient;
uint8_t cc = rfu_curclient;
do {
rfu_curclient = (rfu_curclient+1) % rfu_numclients;
rfu_idx = rfu_clientlist[rfu_curclient];
@ -3559,7 +3559,7 @@ static void StartRFU(u16 value)
//ResetEvent(linksync[vbaid]); //lock it so noone can access it
if (linkmem->rfu_listfront[vbaid] != linkmem->rfu_listback[vbaid]) //data existed
do {
u8 tmpq = linkmem->rfu_datalist[vbaid][linkmem->rfu_listfront[vbaid]].len; //(u8)linkmem->rfu_qlist[vbaid][linkmem->rfu_listfront[vbaid]];
uint8_t tmpq = linkmem->rfu_datalist[vbaid][linkmem->rfu_listfront[vbaid]].len; //(uint8_t)linkmem->rfu_qlist[vbaid][linkmem->rfu_listfront[vbaid]];
ok = false;
if (tmpq != rfu_qrecv_broadcast_data_len)
ok = true;
@ -3585,7 +3585,7 @@ static void StartRFU(u16 value)
gbaid = linkmem->rfu_datalist[vbaid][linkmem->rfu_listfront[vbaid]].gbaid;
rfu_id = (gbaid << 3) + 0x61f1;
if (rfu_ishost)
rfu_curclient = (u8)linkmem->rfu_clientidx[gbaid];
rfu_curclient = (uint8_t)linkmem->rfu_clientidx[gbaid];
if (rfu_qrecv_broadcast_data_len != 0) { //data size > 0
memcpy(rfu_masterdata, linkmem->rfu_datalist[vbaid][linkmem->rfu_listfront[vbaid]].data, std::min(rfu_masterq << 2, (int)sizeof(rfu_masterdata)));
}
@ -3940,9 +3940,9 @@ bool LinkRFUUpdate()
if (transfer_direction && rfu_transfer_end <= 0) {
if (rfu_waiting) {
bool ok = false;
u8 oldcmd = rfu_cmd;
u8 oldq = linkmem->rfu_q[vbaid];
u32 tmout = linktimeout;
uint8_t oldcmd = rfu_cmd;
uint8_t oldq = linkmem->rfu_q[vbaid];
uint32_t tmout = linktimeout;
//if ((!lanlink.active&&speedhack) || (lanlink.speed&&IsLinkConnected()))tmout = 16;
if (rfu_state != RFU_INIT) {
if (rfu_cmd == 0x24 || rfu_cmd == 0x25 || rfu_cmd == 0x35) {
@ -4009,7 +4009,7 @@ static void UpdateRFUIPC(int ticks)
if (LinkRFUUpdate()) {
if (transfer_direction && rfu_transfer_end <= 0) {
transfer_direction = 0;
u16 value = READ16LE(&ioMem[COMM_SIOCNT]);
uint16_t value = READ16LE(&ioMem[COMM_SIOCNT]);
if (value & 0x4000) {
IF |= 0x80;
UPDATE_REG(0x202, IF);
@ -4036,9 +4036,9 @@ void gbInitLinkIPC()
linkmem->linkdata[linkid] = 0xff;
}
u8 gbStartLinkIPC(u8 b) //used on internal clock
uint8_t gbStartLinkIPC(uint8_t b) //used on internal clock
{
u8 dat = 0xff; //master (w/ internal clock) will gets 0xff if slave is turned off (or not ready yet also?)
uint8_t dat = 0xff; //master (w/ internal clock) will gets 0xff if slave is turned off (or not ready yet also?)
//if(linkid) return 0xff; //b; //Slave shouldn't be sending from here
BOOL sent = false;
//int gbSerialOn = (gbMemory[0xff02] & 0x80); //not needed?
@ -4050,11 +4050,11 @@ u8 gbStartLinkIPC(u8 b) //used on internal clock
//Single Computer
if (GetLinkMode() == LINK_GAMEBOY_IPC) {
u32 tm = GetTickCount();
uint32_t tm = GetTickCount();
do {
WaitForSingleObject(linksync[linkid], 1);
ResetEvent(linksync[linkid]);
} while (linkmem->linkcmd[linkid] && (GetTickCount() - tm) < (u32)linktimeout);
} while (linkmem->linkcmd[linkid] && (GetTickCount() - tm) < (uint32_t)linktimeout);
linkmem->linkdata[linkid] = b;
linkmem->linkcmd[linkid] = 1;
SetEvent(linksync[linkid]);
@ -4064,9 +4064,9 @@ u8 gbStartLinkIPC(u8 b) //used on internal clock
do {
WaitForSingleObject(linksync[1 - linkid], 1);
ResetEvent(linksync[1 - linkid]);
} while (!linkmem->linkcmd[1 - linkid] && (GetTickCount() - tm) < (u32)linktimeout);
} while (!linkmem->linkcmd[1 - linkid] && (GetTickCount() - tm) < (uint32_t)linktimeout);
if (linkmem->linkcmd[1 - linkid]) {
dat = (u8)linkmem->linkdata[1 - linkid];
dat = (uint8_t)linkmem->linkdata[1 - linkid];
linkmem->linkcmd[1 - linkid] = 0;
} //else LinkIsWaiting = true;
SetEvent(linksync[1 - linkid]);
@ -4080,9 +4080,9 @@ u8 gbStartLinkIPC(u8 b) //used on internal clock
return dat;
}
u16 gbLinkUpdateIPC(u8 b, int gbSerialOn) //used on external clock
uint16_t gbLinkUpdateIPC(uint8_t b, int gbSerialOn) //used on external clock
{
u8 dat = b; //0xff; //slave (w/ external clocks) won't be getting 0xff if master turned off
uint8_t dat = b; //0xff; //slave (w/ external clocks) won't be getting 0xff if master turned off
BOOL recvd = false;
int idx = 0;
@ -4093,13 +4093,13 @@ u16 gbLinkUpdateIPC(u8 b, int gbSerialOn) //used on external clock
if (gba_link_enabled)
//Single Computer
if (GetLinkMode() == LINK_GAMEBOY_IPC) {
u32 tm; // = GetTickCount();
uint32_t tm; // = GetTickCount();
//do {
WaitForSingleObject(linksync[1 - linkid], linktimeout);
ResetEvent(linksync[1 - linkid]);
//} while (!linkmem->linkcmd[1-linkid] && (GetTickCount()-tm)<(u32)linktimeout);
//} while (!linkmem->linkcmd[1-linkid] && (GetTickCount()-tm)<(uint32_t)linktimeout);
if (linkmem->linkcmd[1 - linkid]) {
dat = (u8)linkmem->linkdata[1 - linkid];
dat = (uint8_t)linkmem->linkdata[1 - linkid];
linkmem->linkcmd[1 - linkid] = 0;
recvd = true;
LinkIsWaiting = false;
@ -4112,7 +4112,7 @@ u16 gbLinkUpdateIPC(u8 b, int gbSerialOn) //used on external clock
do {
WaitForSingleObject(linksync[linkid], 1);
ResetEvent(linksync[linkid]);
} while (linkmem->linkcmd[1 - linkid] && (GetTickCount() - tm) < (u32)linktimeout);
} while (linkmem->linkcmd[1 - linkid] && (GetTickCount() - tm) < (uint32_t)linktimeout);
if (!linkmem->linkcmd[linkid]) {
linkmem->linkdata[linkid] = b;
linkmem->linkcmd[linkid] = 1;
@ -4124,7 +4124,7 @@ u16 gbLinkUpdateIPC(u8 b, int gbSerialOn) //used on external clock
if (dat == 0xff /*||dat==0x00||b==0x00*/) //dat==0xff||dat==0x00
LinkFirstTime = true;
}
return ((dat << 8) | (recvd & (u8)0xff));
return ((dat << 8) | (recvd & (uint8_t)0xff));
}
static void CloseIPC()

View File

@ -108,14 +108,14 @@ extern int GetLinkPlayerId();
*
* @param siocnt the value of SIOCNT to be written
*/
extern void StartLink(u16 siocnt);
extern void StartLink(uint16_t siocnt);
/**
* Start a general purpose link transfer
*
* @param rcnt the value of RCNT to be written
*/
extern void StartGPLink(u16 rcnt);
extern void StartGPLink(uint16_t rcnt);
/**
* Emulate the linked device
@ -185,22 +185,22 @@ extern const char* MakeInstanceFilename(const char* Input);
#define RF_CNT 0x27a // Unknown, Seems to be related to Wireless Adapter(RF_SIOCNT?)
typedef struct {
u8 len; // data len in 32bit words
u8 gbaid; // source id
u32 time; // linktime
u32 data[255];
uint8_t len; // data len in 32bit words
uint8_t gbaid; // source id
uint32_t time; // linktime
uint32_t data[255];
} rfu_datarec;
extern u8 gbSIO_SC;
extern uint8_t gbSIO_SC;
extern bool LinkIsWaiting;
extern bool LinkFirstTime;
extern bool EmuReseted;
extern void gbInitLink();
extern u8 gbStartLink(u8 b);
extern u16 gbLinkUpdate(u8 b, int gbSerialOn);
extern uint8_t gbStartLink(uint8_t b);
extern uint16_t gbLinkUpdate(uint8_t b, int gbSerialOn);
extern void gbInitLinkIPC();
extern u8 gbStartLinkIPC(u8 b);
extern u16 gbLinkUpdateIPC(u8 b, int gbSerialOn);
extern uint8_t gbStartLinkIPC(uint8_t b);
extern uint16_t gbLinkUpdateIPC(uint8_t b, int gbSerialOn);
extern void BootLink(int m_type, const char* host, int timeout, bool m_hacks, int m_numplayers);

View File

@ -27,7 +27,7 @@ GBASockClient::~GBASockClient()
clock_client.disconnect();
}
u32 clock_sync_ticks = 0;
uint32_t clock_sync_ticks = 0;
void GBASockClient::Send(std::vector<char> data)
{
@ -70,15 +70,15 @@ void GBASockClient::ReceiveClock(bool block)
if (num_received == 4) {
clock_sync_ticks = 0;
for (int i = 0; i < 4; i++)
clock_sync_ticks |= (u8)(sync_ticks[i]) << ((3 - i) * 8);
clock_sync_ticks |= (uint8_t)(sync_ticks[i]) << ((3 - i) * 8);
clock_sync += clock_sync_ticks;
}
}
void GBASockClient::ClockSync(u32 ticks)
void GBASockClient::ClockSync(uint32_t ticks)
{
if (clock_sync > (s32)ticks)
clock_sync -= (s32)ticks;
if (clock_sync > (int32_t)ticks)
clock_sync -= (int32_t)ticks;
else
clock_sync = 0;
}

View File

@ -1,6 +1,6 @@
#pragma once
#include "../common/Types.h"
#include <cstdlib>
#include <SFML/Network.hpp>
class GBASockClient {
@ -13,7 +13,7 @@ public:
char ReceiveCmd(char* data_in, bool block);
void ReceiveClock(bool block);
void ClockSync(u32 ticks);
void ClockSync(uint32_t ticks);
void Disconnect();
bool IsDisconnected();
@ -22,6 +22,6 @@ private:
sf::TcpSocket client;
sf::TcpSocket clock_client;
s32 clock_sync;
int32_t clock_sync;
bool is_disconnected;
};

View File

@ -14,99 +14,99 @@ bool Z_FLAG = 0;
bool V_FLAG = 0;
bool armState = true;
bool armIrqEnable = true;
u32 armNextPC = 0x00000000;
uint32_t armNextPC = 0x00000000;
int armMode = 0x1f;
u32 stop = 0x08000568;
uint32_t stop = 0x08000568;
// this is an optional hack to change the backdrop/background color:
// -1: disabled
// 0x0000 to 0x7FFF: set custom 15 bit color
int customBackdropColor = -1;
u8* bios = 0;
u8* rom = 0;
u8* internalRAM = 0;
u8* workRAM = 0;
u8* paletteRAM = 0;
u8* vram = 0;
u8* pix = 0;
u8* oam = 0;
u8* ioMem = 0;
uint8_t* bios = 0;
uint8_t* rom = 0;
uint8_t* internalRAM = 0;
uint8_t* workRAM = 0;
uint8_t* paletteRAM = 0;
uint8_t* vram = 0;
uint8_t* pix = 0;
uint8_t* oam = 0;
uint8_t* ioMem = 0;
u16 DISPCNT = 0x0080;
u16 DISPSTAT = 0x0000;
u16 VCOUNT = 0x0000;
u16 BG0CNT = 0x0000;
u16 BG1CNT = 0x0000;
u16 BG2CNT = 0x0000;
u16 BG3CNT = 0x0000;
u16 BG0HOFS = 0x0000;
u16 BG0VOFS = 0x0000;
u16 BG1HOFS = 0x0000;
u16 BG1VOFS = 0x0000;
u16 BG2HOFS = 0x0000;
u16 BG2VOFS = 0x0000;
u16 BG3HOFS = 0x0000;
u16 BG3VOFS = 0x0000;
u16 BG2PA = 0x0100;
u16 BG2PB = 0x0000;
u16 BG2PC = 0x0000;
u16 BG2PD = 0x0100;
u16 BG2X_L = 0x0000;
u16 BG2X_H = 0x0000;
u16 BG2Y_L = 0x0000;
u16 BG2Y_H = 0x0000;
u16 BG3PA = 0x0100;
u16 BG3PB = 0x0000;
u16 BG3PC = 0x0000;
u16 BG3PD = 0x0100;
u16 BG3X_L = 0x0000;
u16 BG3X_H = 0x0000;
u16 BG3Y_L = 0x0000;
u16 BG3Y_H = 0x0000;
u16 WIN0H = 0x0000;
u16 WIN1H = 0x0000;
u16 WIN0V = 0x0000;
u16 WIN1V = 0x0000;
u16 WININ = 0x0000;
u16 WINOUT = 0x0000;
u16 MOSAIC = 0x0000;
u16 BLDMOD = 0x0000;
u16 COLEV = 0x0000;
u16 COLY = 0x0000;
u16 DM0SAD_L = 0x0000;
u16 DM0SAD_H = 0x0000;
u16 DM0DAD_L = 0x0000;
u16 DM0DAD_H = 0x0000;
u16 DM0CNT_L = 0x0000;
u16 DM0CNT_H = 0x0000;
u16 DM1SAD_L = 0x0000;
u16 DM1SAD_H = 0x0000;
u16 DM1DAD_L = 0x0000;
u16 DM1DAD_H = 0x0000;
u16 DM1CNT_L = 0x0000;
u16 DM1CNT_H = 0x0000;
u16 DM2SAD_L = 0x0000;
u16 DM2SAD_H = 0x0000;
u16 DM2DAD_L = 0x0000;
u16 DM2DAD_H = 0x0000;
u16 DM2CNT_L = 0x0000;
u16 DM2CNT_H = 0x0000;
u16 DM3SAD_L = 0x0000;
u16 DM3SAD_H = 0x0000;
u16 DM3DAD_L = 0x0000;
u16 DM3DAD_H = 0x0000;
u16 DM3CNT_L = 0x0000;
u16 DM3CNT_H = 0x0000;
u16 TM0D = 0x0000;
u16 TM0CNT = 0x0000;
u16 TM1D = 0x0000;
u16 TM1CNT = 0x0000;
u16 TM2D = 0x0000;
u16 TM2CNT = 0x0000;
u16 TM3D = 0x0000;
u16 TM3CNT = 0x0000;
u16 P1 = 0xFFFF;
u16 IE = 0x0000;
u16 IF = 0x0000;
u16 IME = 0x0000;
uint16_t DISPCNT = 0x0080;
uint16_t DISPSTAT = 0x0000;
uint16_t VCOUNT = 0x0000;
uint16_t BG0CNT = 0x0000;
uint16_t BG1CNT = 0x0000;
uint16_t BG2CNT = 0x0000;
uint16_t BG3CNT = 0x0000;
uint16_t BG0HOFS = 0x0000;
uint16_t BG0VOFS = 0x0000;
uint16_t BG1HOFS = 0x0000;
uint16_t BG1VOFS = 0x0000;
uint16_t BG2HOFS = 0x0000;
uint16_t BG2VOFS = 0x0000;
uint16_t BG3HOFS = 0x0000;
uint16_t BG3VOFS = 0x0000;
uint16_t BG2PA = 0x0100;
uint16_t BG2PB = 0x0000;
uint16_t BG2PC = 0x0000;
uint16_t BG2PD = 0x0100;
uint16_t BG2X_L = 0x0000;
uint16_t BG2X_H = 0x0000;
uint16_t BG2Y_L = 0x0000;
uint16_t BG2Y_H = 0x0000;
uint16_t BG3PA = 0x0100;
uint16_t BG3PB = 0x0000;
uint16_t BG3PC = 0x0000;
uint16_t BG3PD = 0x0100;
uint16_t BG3X_L = 0x0000;
uint16_t BG3X_H = 0x0000;
uint16_t BG3Y_L = 0x0000;
uint16_t BG3Y_H = 0x0000;
uint16_t WIN0H = 0x0000;
uint16_t WIN1H = 0x0000;
uint16_t WIN0V = 0x0000;
uint16_t WIN1V = 0x0000;
uint16_t WININ = 0x0000;
uint16_t WINOUT = 0x0000;
uint16_t MOSAIC = 0x0000;
uint16_t BLDMOD = 0x0000;
uint16_t COLEV = 0x0000;
uint16_t COLY = 0x0000;
uint16_t DM0SAD_L = 0x0000;
uint16_t DM0SAD_H = 0x0000;
uint16_t DM0DAD_L = 0x0000;
uint16_t DM0DAD_H = 0x0000;
uint16_t DM0CNT_L = 0x0000;
uint16_t DM0CNT_H = 0x0000;
uint16_t DM1SAD_L = 0x0000;
uint16_t DM1SAD_H = 0x0000;
uint16_t DM1DAD_L = 0x0000;
uint16_t DM1DAD_H = 0x0000;
uint16_t DM1CNT_L = 0x0000;
uint16_t DM1CNT_H = 0x0000;
uint16_t DM2SAD_L = 0x0000;
uint16_t DM2SAD_H = 0x0000;
uint16_t DM2DAD_L = 0x0000;
uint16_t DM2DAD_H = 0x0000;
uint16_t DM2CNT_L = 0x0000;
uint16_t DM2CNT_H = 0x0000;
uint16_t DM3SAD_L = 0x0000;
uint16_t DM3SAD_H = 0x0000;
uint16_t DM3DAD_L = 0x0000;
uint16_t DM3DAD_H = 0x0000;
uint16_t DM3CNT_L = 0x0000;
uint16_t DM3CNT_H = 0x0000;
uint16_t TM0D = 0x0000;
uint16_t TM0CNT = 0x0000;
uint16_t TM1D = 0x0000;
uint16_t TM1CNT = 0x0000;
uint16_t TM2D = 0x0000;
uint16_t TM2CNT = 0x0000;
uint16_t TM3D = 0x0000;
uint16_t TM3CNT = 0x0000;
uint16_t P1 = 0xFFFF;
uint16_t IE = 0x0000;
uint16_t IF = 0x0000;
uint16_t IME = 0x0000;

View File

@ -1,7 +1,6 @@
#ifndef GLOBALS_H
#define GLOBALS_H
#include "../common/Types.h"
#include "GBA.h"
#define VERBOSE_SWI 1
@ -24,9 +23,9 @@ extern bool Z_FLAG;
extern bool V_FLAG;
extern bool armState;
extern bool armIrqEnable;
extern u32 armNextPC;
extern uint32_t armNextPC;
extern int armMode;
extern u32 stop;
extern uint32_t stop;
extern int saveType;
extern int frameSkip;
extern bool gba_joybus_enabled;
@ -36,92 +35,92 @@ extern int layerEnable;
extern int cpuSaveType;
extern int customBackdropColor;
extern u8* bios;
extern u8* rom;
extern u8* internalRAM;
extern u8* workRAM;
extern u8* paletteRAM;
extern u8* vram;
extern u8* pix;
extern u8* oam;
extern u8* ioMem;
extern uint8_t* bios;
extern uint8_t* rom;
extern uint8_t* internalRAM;
extern uint8_t* workRAM;
extern uint8_t* paletteRAM;
extern uint8_t* vram;
extern uint8_t* pix;
extern uint8_t* oam;
extern uint8_t* ioMem;
extern u16 DISPCNT;
extern u16 DISPSTAT;
extern u16 VCOUNT;
extern u16 BG0CNT;
extern u16 BG1CNT;
extern u16 BG2CNT;
extern u16 BG3CNT;
extern u16 BG0HOFS;
extern u16 BG0VOFS;
extern u16 BG1HOFS;
extern u16 BG1VOFS;
extern u16 BG2HOFS;
extern u16 BG2VOFS;
extern u16 BG3HOFS;
extern u16 BG3VOFS;
extern u16 BG2PA;
extern u16 BG2PB;
extern u16 BG2PC;
extern u16 BG2PD;
extern u16 BG2X_L;
extern u16 BG2X_H;
extern u16 BG2Y_L;
extern u16 BG2Y_H;
extern u16 BG3PA;
extern u16 BG3PB;
extern u16 BG3PC;
extern u16 BG3PD;
extern u16 BG3X_L;
extern u16 BG3X_H;
extern u16 BG3Y_L;
extern u16 BG3Y_H;
extern u16 WIN0H;
extern u16 WIN1H;
extern u16 WIN0V;
extern u16 WIN1V;
extern u16 WININ;
extern u16 WINOUT;
extern u16 MOSAIC;
extern u16 BLDMOD;
extern u16 COLEV;
extern u16 COLY;
extern u16 DM0SAD_L;
extern u16 DM0SAD_H;
extern u16 DM0DAD_L;
extern u16 DM0DAD_H;
extern u16 DM0CNT_L;
extern u16 DM0CNT_H;
extern u16 DM1SAD_L;
extern u16 DM1SAD_H;
extern u16 DM1DAD_L;
extern u16 DM1DAD_H;
extern u16 DM1CNT_L;
extern u16 DM1CNT_H;
extern u16 DM2SAD_L;
extern u16 DM2SAD_H;
extern u16 DM2DAD_L;
extern u16 DM2DAD_H;
extern u16 DM2CNT_L;
extern u16 DM2CNT_H;
extern u16 DM3SAD_L;
extern u16 DM3SAD_H;
extern u16 DM3DAD_L;
extern u16 DM3DAD_H;
extern u16 DM3CNT_L;
extern u16 DM3CNT_H;
extern u16 TM0D;
extern u16 TM0CNT;
extern u16 TM1D;
extern u16 TM1CNT;
extern u16 TM2D;
extern u16 TM2CNT;
extern u16 TM3D;
extern u16 TM3CNT;
extern u16 P1;
extern u16 IE;
extern u16 IF;
extern u16 IME;
extern uint16_t DISPCNT;
extern uint16_t DISPSTAT;
extern uint16_t VCOUNT;
extern uint16_t BG0CNT;
extern uint16_t BG1CNT;
extern uint16_t BG2CNT;
extern uint16_t BG3CNT;
extern uint16_t BG0HOFS;
extern uint16_t BG0VOFS;
extern uint16_t BG1HOFS;
extern uint16_t BG1VOFS;
extern uint16_t BG2HOFS;
extern uint16_t BG2VOFS;
extern uint16_t BG3HOFS;
extern uint16_t BG3VOFS;
extern uint16_t BG2PA;
extern uint16_t BG2PB;
extern uint16_t BG2PC;
extern uint16_t BG2PD;
extern uint16_t BG2X_L;
extern uint16_t BG2X_H;
extern uint16_t BG2Y_L;
extern uint16_t BG2Y_H;
extern uint16_t BG3PA;
extern uint16_t BG3PB;
extern uint16_t BG3PC;
extern uint16_t BG3PD;
extern uint16_t BG3X_L;
extern uint16_t BG3X_H;
extern uint16_t BG3Y_L;
extern uint16_t BG3Y_H;
extern uint16_t WIN0H;
extern uint16_t WIN1H;
extern uint16_t WIN0V;
extern uint16_t WIN1V;
extern uint16_t WININ;
extern uint16_t WINOUT;
extern uint16_t MOSAIC;
extern uint16_t BLDMOD;
extern uint16_t COLEV;
extern uint16_t COLY;
extern uint16_t DM0SAD_L;
extern uint16_t DM0SAD_H;
extern uint16_t DM0DAD_L;
extern uint16_t DM0DAD_H;
extern uint16_t DM0CNT_L;
extern uint16_t DM0CNT_H;
extern uint16_t DM1SAD_L;
extern uint16_t DM1SAD_H;
extern uint16_t DM1DAD_L;
extern uint16_t DM1DAD_H;
extern uint16_t DM1CNT_L;
extern uint16_t DM1CNT_H;
extern uint16_t DM2SAD_L;
extern uint16_t DM2SAD_H;
extern uint16_t DM2DAD_L;
extern uint16_t DM2DAD_H;
extern uint16_t DM2CNT_L;
extern uint16_t DM2CNT_H;
extern uint16_t DM3SAD_L;
extern uint16_t DM3SAD_H;
extern uint16_t DM3DAD_L;
extern uint16_t DM3DAD_H;
extern uint16_t DM3CNT_L;
extern uint16_t DM3CNT_H;
extern uint16_t TM0D;
extern uint16_t TM0CNT;
extern uint16_t TM1D;
extern uint16_t TM1CNT;
extern uint16_t TM2D;
extern uint16_t TM2CNT;
extern uint16_t TM3D;
extern uint16_t TM3CNT;
extern uint16_t P1;
extern uint16_t IE;
extern uint16_t IF;
extern uint16_t IME;
#endif // GLOBALS_H

View File

@ -4,7 +4,7 @@
void mode0RenderLine()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -31,7 +31,7 @@ void mode0RenderLine()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -39,55 +39,55 @@ void mode0RenderLine()
}
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if (line0[x] < color) {
color = line0[x];
top = 0x01;
}
if ((u8)(line1[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(color >> 24)) {
color = line1[x];
top = 0x02;
}
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(color >> 24)) {
color = line2[x];
top = 0x04;
}
if ((u8)(line3[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(color >> 24)) {
color = line3[x];
top = 0x08;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
if ((top & 0x10) && (color & 0x00010000)) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24)) {
back = line0[x];
top2 = 0x01;
}
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24)) {
back = line1[x];
top2 = 0x02;
}
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
back = line2[x];
top2 = 0x04;
}
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24)) {
back = line3[x];
top2 = 0x08;
}
@ -116,7 +116,7 @@ void mode0RenderLine()
void mode0RenderLineNoWindow()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -143,7 +143,7 @@ void mode0RenderLineNoWindow()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -153,8 +153,8 @@ void mode0RenderLineNoWindow()
int effect = (BLDMOD >> 6) & 3;
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if (line0[x] < color) {
color = line0[x];
@ -187,8 +187,8 @@ void mode0RenderLineNoWindow()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if (line0[x] < back) {
if (top != 0x01) {
back = line0[x];
@ -241,8 +241,8 @@ void mode0RenderLineNoWindow()
}
} else {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if (line0[x] < back) {
back = line0[x];
@ -288,7 +288,7 @@ void mode0RenderLineNoWindow()
void mode0RenderLineAll()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -301,8 +301,8 @@ void mode0RenderLineAll()
bool inWindow1 = false;
if (layerEnable & 0x2000) {
u8 v0 = WIN0V >> 8;
u8 v1 = WIN0V & 255;
uint8_t v0 = WIN0V >> 8;
uint8_t v1 = WIN0V & 255;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -310,8 +310,8 @@ void mode0RenderLineAll()
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
}
if (layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255;
uint8_t v0 = WIN1V >> 8;
uint8_t v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -338,21 +338,21 @@ void mode0RenderLineAll()
gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
}
u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF;
uint8_t inWin0Mask = WININ & 0xFF;
uint8_t inWin1Mask = WININ >> 8;
uint8_t outMask = WINOUT & 0xFF;
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
u8 mask = outMask;
uint32_t color = backdrop;
uint8_t top = 0x20;
uint8_t mask = outMask;
if (!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8;
@ -374,47 +374,47 @@ void mode0RenderLineAll()
top = 0x01;
}
if ((mask & 2) && ((u8)(line1[x] >> 24) < (u8)(color >> 24))) {
if ((mask & 2) && ((uint8_t)(line1[x] >> 24) < (uint8_t)(color >> 24))) {
color = line1[x];
top = 0x02;
}
if ((mask & 4) && ((u8)(line2[x] >> 24) < (u8)(color >> 24))) {
if ((mask & 4) && ((uint8_t)(line2[x] >> 24) < (uint8_t)(color >> 24))) {
color = line2[x];
top = 0x04;
}
if ((mask & 8) && ((u8)(line3[x] >> 24) < (u8)(color >> 24))) {
if ((mask & 8) && ((uint8_t)(line3[x] >> 24) < (uint8_t)(color >> 24))) {
color = line3[x];
top = 0x08;
}
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
if ((mask & 16) && ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24))) {
color = lineOBJ[x];
top = 0x10;
}
if (color & 0x00010000) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 1) && ((u8)(line0[x] >> 24) < (u8)(back >> 24))) {
if ((mask & 1) && ((uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24))) {
back = line0[x];
top2 = 0x01;
}
if ((mask & 2) && ((u8)(line1[x] >> 24) < (u8)(back >> 24))) {
if ((mask & 2) && ((uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24))) {
back = line1[x];
top2 = 0x02;
}
if ((mask & 4) && ((u8)(line2[x] >> 24) < (u8)(back >> 24))) {
if ((mask & 4) && ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24))) {
back = line2[x];
top2 = 0x04;
}
if ((mask & 8) && ((u8)(line3[x] >> 24) < (u8)(back >> 24))) {
if ((mask & 8) && ((uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24))) {
back = line3[x];
top2 = 0x08;
}
@ -442,37 +442,37 @@ void mode0RenderLineAll()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
if ((mask & 1) && (u8)(line0[x] >> 24) < (u8)(back >> 24)) {
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 1) && (uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x01) {
back = line0[x];
top2 = 0x01;
}
}
if ((mask & 2) && (u8)(line1[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 2) && (uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x02) {
back = line1[x];
top2 = 0x02;
}
}
if ((mask & 4) && (u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 4) && (uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x04) {
back = line2[x];
top2 = 0x04;
}
}
if ((mask & 8) && (u8)(line3[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 8) && (uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x08) {
back = line3[x];
top2 = 0x08;
}
}
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 16) && (uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;

View File

@ -4,7 +4,7 @@
void mode1RenderLine()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -33,7 +33,7 @@ void mode1RenderLine()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -41,45 +41,45 @@ void mode1RenderLine()
}
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if (line0[x] < color) {
color = line0[x];
top = 0x01;
}
if ((u8)(line1[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(color >> 24)) {
color = line1[x];
top = 0x02;
}
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(color >> 24)) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
if ((top & 0x10) && (color & 0x00010000)) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24)) {
back = line0[x];
top2 = 0x01;
}
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24)) {
back = line1[x];
top2 = 0x02;
}
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
back = line2[x];
top2 = 0x04;
}
@ -110,7 +110,7 @@ void mode1RenderLine()
void mode1RenderLineNoWindow()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -139,7 +139,7 @@ void mode1RenderLineNoWindow()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -147,25 +147,25 @@ void mode1RenderLineNoWindow()
}
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if (line0[x] < color) {
color = line0[x];
top = 0x01;
}
if ((u8)(line1[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(color >> 24)) {
color = line1[x];
top = 0x02;
}
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(color >> 24)) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
@ -176,30 +176,30 @@ void mode1RenderLineNoWindow()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x01) {
back = line0[x];
top2 = 0x01;
}
}
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x02) {
back = line1[x];
top2 = 0x02;
}
}
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x04) {
back = line2[x];
top2 = 0x04;
}
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;
@ -223,20 +223,20 @@ void mode1RenderLineNoWindow()
}
} else {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((u8)(line0[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24)) {
back = line0[x];
top2 = 0x01;
}
if ((u8)(line1[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24)) {
back = line1[x];
top2 = 0x02;
}
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
back = line2[x];
top2 = 0x04;
}
@ -267,7 +267,7 @@ void mode1RenderLineNoWindow()
void mode1RenderLineAll()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -281,8 +281,8 @@ void mode1RenderLineAll()
bool inWindow1 = false;
if (layerEnable & 0x2000) {
u8 v0 = WIN0V >> 8;
u8 v1 = WIN0V & 255;
uint8_t v0 = WIN0V >> 8;
uint8_t v1 = WIN0V & 255;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -290,8 +290,8 @@ void mode1RenderLineAll()
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
}
if (layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255;
uint8_t v0 = WIN1V >> 8;
uint8_t v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -319,21 +319,21 @@ void mode1RenderLineAll()
gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
}
u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF;
uint8_t inWin0Mask = WININ & 0xFF;
uint8_t inWin1Mask = WININ >> 8;
uint8_t outMask = WINOUT & 0xFF;
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
u8 mask = outMask;
uint32_t color = backdrop;
uint8_t top = 0x20;
uint8_t mask = outMask;
if (!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8;
@ -355,37 +355,37 @@ void mode1RenderLineAll()
top = 0x01;
}
if ((u8)(line1[x] >> 24) < (u8)(color >> 24) && (mask & 2)) {
if ((uint8_t)(line1[x] >> 24) < (uint8_t)(color >> 24) && (mask & 2)) {
color = line1[x];
top = 0x02;
}
if ((u8)(line2[x] >> 24) < (u8)(color >> 24) && (mask & 4)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(color >> 24) && (mask & 4)) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24) && (mask & 16)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24) && (mask & 16)) {
color = lineOBJ[x];
top = 0x10;
}
if (color & 0x00010000) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 1) && (u8)(line0[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 1) && (uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24)) {
back = line0[x];
top2 = 0x01;
}
if ((mask & 2) && (u8)(line1[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 2) && (uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24)) {
back = line1[x];
top2 = 0x02;
}
if ((mask & 4) && (u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 4) && (uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
back = line2[x];
top2 = 0x04;
}
@ -413,31 +413,31 @@ void mode1RenderLineAll()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 1) && (u8)(line0[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 1) && (uint8_t)(line0[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x01) {
back = line0[x];
top2 = 0x01;
}
}
if ((mask & 2) && (u8)(line1[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 2) && (uint8_t)(line1[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x02) {
back = line1[x];
top2 = 0x02;
}
}
if ((mask & 4) && (u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 4) && (uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x04) {
back = line2[x];
top2 = 0x04;
}
}
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 16) && (uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;

View File

@ -4,7 +4,7 @@
void mode2RenderLine()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -36,7 +36,7 @@ void mode2RenderLine()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -44,35 +44,35 @@ void mode2RenderLine()
}
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(color >> 24)) {
color = line2[x];
top = 0x04;
}
if ((u8)(line3[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(color >> 24)) {
color = line3[x];
top = 0x08;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
if ((top & 0x10) && (color & 0x00010000)) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
back = line2[x];
top2 = 0x04;
}
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24)) {
back = line3[x];
top2 = 0x08;
}
@ -104,7 +104,7 @@ void mode2RenderLine()
void mode2RenderLineNoWindow()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -136,7 +136,7 @@ void mode2RenderLineNoWindow()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -144,20 +144,20 @@ void mode2RenderLineNoWindow()
}
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if ((u8)(line2[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(color >> 24)) {
color = line2[x];
top = 0x04;
}
if ((u8)(line3[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(color >> 24)) {
color = line3[x];
top = 0x08;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
@ -168,24 +168,24 @@ void mode2RenderLineNoWindow()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x04) {
back = line2[x];
top2 = 0x04;
}
}
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x08) {
back = line3[x];
top2 = 0x08;
}
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;
@ -209,15 +209,15 @@ void mode2RenderLineNoWindow()
}
} else {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((u8)(line2[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line2[x] >> 24) < (uint8_t)(back >> 24)) {
back = line2[x];
top2 = 0x04;
}
if ((u8)(line3[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24)) {
back = line3[x];
top2 = 0x08;
}
@ -249,7 +249,7 @@ void mode2RenderLineNoWindow()
void mode2RenderLineAll()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -263,8 +263,8 @@ void mode2RenderLineAll()
bool inWindow1 = false;
if (layerEnable & 0x2000) {
u8 v0 = WIN0V >> 8;
u8 v1 = WIN0V & 255;
uint8_t v0 = WIN0V >> 8;
uint8_t v1 = WIN0V & 255;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -272,8 +272,8 @@ void mode2RenderLineAll()
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
}
if (layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255;
uint8_t v0 = WIN1V >> 8;
uint8_t v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -304,21 +304,21 @@ void mode2RenderLineAll()
gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
}
u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF;
uint8_t inWin0Mask = WININ & 0xFF;
uint8_t inWin1Mask = WININ >> 8;
uint8_t outMask = WINOUT & 0xFF;
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
u8 mask = outMask;
uint32_t color = backdrop;
uint8_t top = 0x20;
uint8_t mask = outMask;
if (!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8;
@ -340,27 +340,27 @@ void mode2RenderLineAll()
top = 0x04;
}
if ((u8)(line3[x] >> 24) < (u8)(color >> 24) && (mask & 8)) {
if ((uint8_t)(line3[x] >> 24) < (uint8_t)(color >> 24) && (mask & 8)) {
color = line3[x];
top = 0x08;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24) && (mask & 16)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24) && (mask & 16)) {
color = lineOBJ[x];
top = 0x10;
}
if (color & 0x00010000) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
back = line2[x];
top2 = 0x04;
}
if ((mask & 8) && (u8)(line3[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 8) && (uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24)) {
back = line3[x];
top2 = 0x08;
}
@ -388,8 +388,8 @@ void mode2RenderLineAll()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
if (top != 0x04) {
@ -398,14 +398,14 @@ void mode2RenderLineAll()
}
}
if ((mask & 8) && (u8)(line3[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 8) && (uint8_t)(line3[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x08) {
back = line3[x];
top2 = 0x08;
}
}
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 16) && (uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;

View File

@ -4,7 +4,7 @@
void mode3RenderLine()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -29,7 +29,7 @@ void mode3RenderLine()
gfxDrawSprites(lineOBJ);
u32 background;
uint32_t background;
if (customBackdropColor == -1) {
background = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -37,23 +37,23 @@ void mode3RenderLine()
}
for (int x = 0; x < 240; x++) {
u32 color = background;
u8 top = 0x20;
uint32_t color = background;
uint8_t top = 0x20;
if (line2[x] < color) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
if ((top & 0x10) && (color & 0x00010000)) {
// semi-transparent OBJ
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if (line2[x] < back) {
back = line2[x];
@ -86,7 +86,7 @@ void mode3RenderLine()
void mode3RenderLineNoWindow()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -111,7 +111,7 @@ void mode3RenderLineNoWindow()
gfxDrawSprites(lineOBJ);
u32 background;
uint32_t background;
if (customBackdropColor == -1) {
background = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -119,15 +119,15 @@ void mode3RenderLineNoWindow()
}
for (int x = 0; x < 240; x++) {
u32 color = background;
u8 top = 0x20;
uint32_t color = background;
uint8_t top = 0x20;
if (line2[x] < color) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
@ -138,8 +138,8 @@ void mode3RenderLineNoWindow()
break;
case 1: {
if (top & BLDMOD) {
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if (line2[x] < back) {
if (top != 0x04) {
@ -148,7 +148,7 @@ void mode3RenderLineNoWindow()
}
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;
@ -172,8 +172,8 @@ void mode3RenderLineNoWindow()
}
} else {
// semi-transparent OBJ
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if (line2[x] < back) {
back = line2[x];
@ -206,7 +206,7 @@ void mode3RenderLineNoWindow()
void mode3RenderLineAll()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x80) {
for (int x = 0; x < 240; x++) {
@ -220,8 +220,8 @@ void mode3RenderLineAll()
bool inWindow1 = false;
if (layerEnable & 0x2000) {
u8 v0 = WIN0V >> 8;
u8 v1 = WIN0V & 255;
uint8_t v0 = WIN0V >> 8;
uint8_t v1 = WIN0V & 255;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -229,8 +229,8 @@ void mode3RenderLineAll()
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
}
if (layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255;
uint8_t v0 = WIN1V >> 8;
uint8_t v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -254,11 +254,11 @@ void mode3RenderLineAll()
gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin);
u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF;
uint8_t inWin0Mask = WININ & 0xFF;
uint8_t inWin1Mask = WININ >> 8;
uint8_t outMask = WINOUT & 0xFF;
u32 background;
uint32_t background;
if (customBackdropColor == -1) {
background = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -266,9 +266,9 @@ void mode3RenderLineAll()
}
for (int x = 0; x < 240; x++) {
u32 color = background;
u8 top = 0x20;
u8 mask = outMask;
uint32_t color = background;
uint8_t top = 0x20;
uint8_t mask = outMask;
if (!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8;
@ -290,15 +290,15 @@ void mode3RenderLineAll()
top = 0x04;
}
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
if ((mask & 16) && ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24))) {
color = lineOBJ[x];
top = 0x10;
}
if (color & 0x00010000) {
// semi-transparent OBJ
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
back = line2[x];
@ -327,8 +327,8 @@ void mode3RenderLineAll()
break;
case 1: {
if (top & BLDMOD) {
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
if (top != 0x04) {
@ -337,7 +337,7 @@ void mode3RenderLineAll()
}
}
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 16) && (uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;

View File

@ -4,7 +4,7 @@
void mode4RenderLine()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x0080) {
for (int x = 0; x < 240; x++) {
@ -28,7 +28,7 @@ void mode4RenderLine()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -36,23 +36,23 @@ void mode4RenderLine()
}
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if (line2[x] < color) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
if ((top & 0x10) && (color & 0x00010000)) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if (line2[x] < back) {
back = line2[x];
@ -85,7 +85,7 @@ void mode4RenderLine()
void mode4RenderLineNoWindow()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x0080) {
for (int x = 0; x < 240; x++) {
@ -109,7 +109,7 @@ void mode4RenderLineNoWindow()
gfxDrawSprites(lineOBJ);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -117,15 +117,15 @@ void mode4RenderLineNoWindow()
}
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
uint32_t color = backdrop;
uint8_t top = 0x20;
if (line2[x] < color) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
@ -136,8 +136,8 @@ void mode4RenderLineNoWindow()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if (line2[x] < back) {
if (top != 0x04) {
@ -146,7 +146,7 @@ void mode4RenderLineNoWindow()
}
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;
@ -170,8 +170,8 @@ void mode4RenderLineNoWindow()
}
} else {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if (line2[x] < back) {
back = line2[x];
@ -204,7 +204,7 @@ void mode4RenderLineNoWindow()
void mode4RenderLineAll()
{
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (DISPCNT & 0x0080) {
for (int x = 0; x < 240; x++) {
@ -218,8 +218,8 @@ void mode4RenderLineAll()
bool inWindow1 = false;
if (layerEnable & 0x2000) {
u8 v0 = WIN0V >> 8;
u8 v1 = WIN0V & 255;
uint8_t v0 = WIN0V >> 8;
uint8_t v1 = WIN0V & 255;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -227,8 +227,8 @@ void mode4RenderLineAll()
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
}
if (layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255;
uint8_t v0 = WIN1V >> 8;
uint8_t v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -251,21 +251,21 @@ void mode4RenderLineAll()
gfxDrawSprites(lineOBJ);
gfxDrawOBJWin(lineOBJWin);
u32 backdrop;
uint32_t backdrop;
if (customBackdropColor == -1) {
backdrop = (READ16LE(&palette[0]) | 0x30000000);
} else {
backdrop = ((customBackdropColor & 0x7FFF) | 0x30000000);
}
u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF;
uint8_t inWin0Mask = WININ & 0xFF;
uint8_t inWin1Mask = WININ >> 8;
uint8_t outMask = WINOUT & 0xFF;
for (int x = 0; x < 240; x++) {
u32 color = backdrop;
u8 top = 0x20;
u8 mask = outMask;
uint32_t color = backdrop;
uint8_t top = 0x20;
uint8_t mask = outMask;
if (!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8;
@ -287,15 +287,15 @@ void mode4RenderLineAll()
top = 0x04;
}
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
if ((mask & 16) && ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24))) {
color = lineOBJ[x];
top = 0x10;
}
if (color & 0x00010000) {
// semi-transparent OBJ
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
back = line2[x];
@ -324,8 +324,8 @@ void mode4RenderLineAll()
break;
case 1: {
if (top & BLDMOD) {
u32 back = backdrop;
u8 top2 = 0x20;
uint32_t back = backdrop;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
if (top != 0x04) {
@ -334,7 +334,7 @@ void mode4RenderLineAll()
}
}
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 16) && (uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;

View File

@ -12,7 +12,7 @@ void mode5RenderLine()
return;
}
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (layerEnable & 0x0400) {
int changed = gfxBG2Changed;
@ -29,7 +29,7 @@ void mode5RenderLine()
gfxDrawSprites(lineOBJ);
u32 background;
uint32_t background;
if (customBackdropColor == -1) {
background = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -37,23 +37,23 @@ void mode5RenderLine()
}
for (int x = 0; x < 240; x++) {
u32 color = background;
u8 top = 0x20;
uint32_t color = background;
uint8_t top = 0x20;
if (line2[x] < color) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
if ((top & 0x10) && (color & 0x00010000)) {
// semi-transparent OBJ
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if (line2[x] < back) {
back = line2[x];
@ -94,7 +94,7 @@ void mode5RenderLineNoWindow()
return;
}
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (layerEnable & 0x0400) {
int changed = gfxBG2Changed;
@ -111,7 +111,7 @@ void mode5RenderLineNoWindow()
gfxDrawSprites(lineOBJ);
u32 background;
uint32_t background;
if (customBackdropColor == -1) {
background = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -119,15 +119,15 @@ void mode5RenderLineNoWindow()
}
for (int x = 0; x < 240; x++) {
u32 color = background;
u8 top = 0x20;
uint32_t color = background;
uint8_t top = 0x20;
if (line2[x] < color) {
color = line2[x];
top = 0x04;
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24)) {
color = lineOBJ[x];
top = 0x10;
}
@ -138,8 +138,8 @@ void mode5RenderLineNoWindow()
break;
case 1: {
if (top & BLDMOD) {
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if (line2[x] < back) {
if (top != 0x04) {
@ -148,7 +148,7 @@ void mode5RenderLineNoWindow()
}
}
if ((u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;
@ -172,8 +172,8 @@ void mode5RenderLineNoWindow()
}
} else {
// semi-transparent OBJ
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if (line2[x] < back) {
back = line2[x];
@ -214,7 +214,7 @@ void mode5RenderLineAll()
return;
}
u16* palette = (u16*)paletteRAM;
uint16_t* palette = (uint16_t*)paletteRAM;
if (layerEnable & 0x0400) {
int changed = gfxBG2Changed;
@ -236,8 +236,8 @@ void mode5RenderLineAll()
bool inWindow1 = false;
if (layerEnable & 0x2000) {
u8 v0 = WIN0V >> 8;
u8 v1 = WIN0V & 255;
uint8_t v0 = WIN0V >> 8;
uint8_t v1 = WIN0V & 255;
inWindow0 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow0 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -245,8 +245,8 @@ void mode5RenderLineAll()
inWindow0 |= (VCOUNT >= v0 || VCOUNT < v1);
}
if (layerEnable & 0x4000) {
u8 v0 = WIN1V >> 8;
u8 v1 = WIN1V & 255;
uint8_t v0 = WIN1V >> 8;
uint8_t v1 = WIN1V & 255;
inWindow1 = ((v0 == v1) && (v0 >= 0xe8));
if (v1 >= v0)
inWindow1 |= (VCOUNT >= v0 && VCOUNT < v1);
@ -254,11 +254,11 @@ void mode5RenderLineAll()
inWindow1 |= (VCOUNT >= v0 || VCOUNT < v1);
}
u8 inWin0Mask = WININ & 0xFF;
u8 inWin1Mask = WININ >> 8;
u8 outMask = WINOUT & 0xFF;
uint8_t inWin0Mask = WININ & 0xFF;
uint8_t inWin1Mask = WININ >> 8;
uint8_t outMask = WINOUT & 0xFF;
u32 background;
uint32_t background;
if (customBackdropColor == -1) {
background = (READ16LE(&palette[0]) | 0x30000000);
} else {
@ -266,9 +266,9 @@ void mode5RenderLineAll()
}
for (int x = 0; x < 240; x++) {
u32 color = background;
u8 top = 0x20;
u8 mask = outMask;
uint32_t color = background;
uint8_t top = 0x20;
uint8_t mask = outMask;
if (!(lineOBJWin[x] & 0x80000000)) {
mask = WINOUT >> 8;
@ -290,15 +290,15 @@ void mode5RenderLineAll()
top = 0x04;
}
if ((mask & 16) && ((u8)(lineOBJ[x] >> 24) < (u8)(color >> 24))) {
if ((mask & 16) && ((uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(color >> 24))) {
color = lineOBJ[x];
top = 0x10;
}
if (color & 0x00010000) {
// semi-transparent OBJ
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
back = line2[x];
@ -327,8 +327,8 @@ void mode5RenderLineAll()
break;
case 1: {
if (top & BLDMOD) {
u32 back = background;
u8 top2 = 0x20;
uint32_t back = background;
uint8_t top2 = 0x20;
if ((mask & 4) && line2[x] < back) {
if (top != 0x04) {
@ -337,7 +337,7 @@ void mode5RenderLineAll()
}
}
if ((mask & 16) && (u8)(lineOBJ[x] >> 24) < (u8)(back >> 24)) {
if ((mask & 16) && (uint8_t)(lineOBJ[x] >> 24) < (uint8_t)(back >> 24)) {
if (top != 0x10) {
back = lineOBJ[x];
top2 = 0x10;

View File

@ -18,18 +18,18 @@ enum RTCSTATE {
typedef struct
{
u8 byte0;
u8 select;
u8 enable;
u8 command;
uint8_t byte0;
uint8_t select;
uint8_t enable;
uint8_t command;
int dataLen;
int bits;
RTCSTATE state;
u8 data[12];
uint8_t data[12];
// reserved variables for future
u8 reserved[12];
uint8_t reserved[12];
bool reserved2;
u32 reserved3;
uint32_t reserved3;
} RTCCLOCKDATA;
struct tm gba_time;
@ -37,7 +37,7 @@ static RTCCLOCKDATA rtcClockData;
static bool rtcClockEnabled = true;
static bool rtcRumbleEnabled = false;
u32 countTicks = 0;
uint32_t countTicks = 0;
void rtcEnable(bool e)
{
@ -54,7 +54,7 @@ void rtcEnableRumble(bool e)
rtcRumbleEnabled = e;
}
u16 rtcRead(u32 address)
uint16_t rtcRead(uint32_t address)
{
int res = 0;
@ -81,7 +81,7 @@ u16 rtcRead(u32 address)
// WarioWare Twisted Tilt Sensor
if (rtcClockData.select == 0x0b) {
u16 v = systemGetSensorZ();
uint16_t v = systemGetSensorZ();
v = 0x6C0 + v;
res |= ((v >> rtcClockData.reserved[11]) & 1) << 2;
}
@ -98,7 +98,7 @@ u16 rtcRead(u32 address)
return READ16LE((&rom[address & 0x1FFFFFE]));
}
static u8 toBCD(u8 value)
static uint8_t toBCD(uint8_t value)
{
value = value % 100;
int l = value % 10;
@ -124,12 +124,12 @@ void rtcUpdateTime(int ticks)
}
}
bool rtcWrite(u32 address, u16 value)
bool rtcWrite(uint32_t address, uint16_t value)
{
if (address == 0x80000c8) {
rtcClockData.enable = (u8)value; // bit 0 = enable reading from 0x80000c4 c6 and c8
rtcClockData.enable = (uint8_t)value; // bit 0 = enable reading from 0x80000c4 c6 and c8
} else if (address == 0x80000c6) {
rtcClockData.select = (u8)value; // 0=read/1=write (for each of 4 low bits)
rtcClockData.select = (uint8_t)value; // 0=read/1=write (for each of 4 low bits)
// rumble is off when not writing to that pin
if (rtcRumbleEnabled && !(value & 8))
@ -183,7 +183,7 @@ bool rtcWrite(u32 address, u16 value)
rtcClockData.command = 0;
} else if (!(rtcClockData.byte0 & 1) && (value & 1)) // bit transfer
{
rtcClockData.byte0 = (u8)value;
rtcClockData.byte0 = (uint8_t)value;
switch (rtcClockData.state) {
case COMMAND:
@ -283,7 +283,7 @@ bool rtcWrite(u32 address, u16 value)
break;
}
} else
rtcClockData.byte0 = (u8)value;
rtcClockData.byte0 = (uint8_t)value;
}
}
@ -305,12 +305,12 @@ void rtcReset()
}
#ifdef __LIBRETRO__
void rtcSaveGame(u8*& data)
void rtcSaveGame(uint8_t*& data)
{
utilWriteMem(data, &rtcClockData, sizeof(rtcClockData));
}
void rtcReadGame(const u8*& data)
void rtcReadGame(const uint8_t*& data)
{
utilReadMem(&rtcClockData, data, sizeof(rtcClockData));
}

View File

@ -1,17 +1,17 @@
#ifndef RTC_H
#define RTC_H
u16 rtcRead(u32 address);
uint16_t rtcRead(uint32_t address);
void rtcUpdateTime(int ticks);
bool rtcWrite(u32 address, u16 value);
bool rtcWrite(uint32_t address, uint16_t value);
void rtcEnable(bool);
void rtcEnableRumble(bool e);
bool rtcIsEnabled();
void rtcReset();
#ifdef __LIBRETRO__
void rtcReadGame(const u8*& data);
void rtcSaveGame(u8*& data);
void rtcReadGame(const uint8_t*& data);
void rtcSaveGame(uint8_t*& data);
#else
void rtcReadGame(gzFile gzFile);
void rtcSaveGame(gzFile gzFile);

View File

@ -40,7 +40,7 @@ extern bool stopState; // TODO: silence sound when true
int const SOUND_CLOCK_TICKS_ = 167772; // 1/100 second
static u16 soundFinalWave[1600];
static uint16_t soundFinalWave[1600];
long soundSampleRate = 44100;
bool soundInterpolation = true;
bool soundPaused = true;
@ -82,7 +82,7 @@ public:
int readIndex;
int count;
int writeIndex;
u8 fifo[32];
uint8_t fifo[32];
int dac;
private:
@ -155,7 +155,7 @@ void Gba_Pcm::update(int dac)
if (output) {
blip_time_t time = blip_time();
dac = (s8)dac >> shift;
dac = (int8_t)dac >> shift;
int delta = dac - last_amp;
if (delta) {
last_amp = dac;
@ -193,8 +193,8 @@ void Gba_Pcm_Fifo::timer_overflowed(int which_timer)
// Not filled by DMA, so fill with 16 bytes of silence
int reg = which ? FIFOB_L : FIFOA_L;
for (int n = 8; n--;) {
soundEvent(reg, (u16)0);
soundEvent(reg + 2, (u16)0);
soundEvent(reg, (uint16_t)0);
soundEvent(reg + 2, (uint16_t)0);
}
}
}
@ -256,7 +256,7 @@ static int gba_to_gb_sound(int addr)
return 0;
}
void soundEvent(u32 address, u8 data)
void soundEvent(uint32_t address, uint8_t data)
{
int gb_addr = gba_to_gb_sound(address);
if (gb_addr) {
@ -294,7 +294,7 @@ static void write_SGCNT0_H(int data)
apply_volume(true);
}
void soundEvent(u32 address, u16 data)
void soundEvent(uint32_t address, uint16_t data)
{
switch (address) {
case SGCNT0_H:
@ -319,8 +319,8 @@ void soundEvent(u32 address, u16 data)
break;
default:
soundEvent(address & ~1, (u8)(data)); // even
soundEvent(address | 1, (u8)(data >> 8)); // odd
soundEvent(address & ~1, (uint8_t)(data)); // even
soundEvent(address | 1, (uint8_t)(data >> 8)); // odd
break;
}
}
@ -527,7 +527,7 @@ void soundReset()
SOUND_CLOCK_TICKS = SOUND_CLOCK_TICKS_;
soundTicks = SOUND_CLOCK_TICKS_;
soundEvent(NR52, (u8)0x80);
soundEvent(NR52, (uint8_t)0x80);
}
bool soundInit()
@ -586,7 +586,7 @@ static struct {
gb_apu_state_t apu;
// old state
u8 soundDSAValue;
uint8_t soundDSAValue;
int soundDSBValue;
} state;
@ -650,16 +650,16 @@ static variable_desc old_gba_state[] = {
LOAD(int, pcm[0].readIndex),
LOAD(int, pcm[0].count),
LOAD(int, pcm[0].writeIndex),
SKIP(u8, soundDSAEnabled), // was bool, which was one byte on MS compiler
SKIP(uint8_t, soundDSAEnabled), // was bool, which was one byte on MS compiler
SKIP(int, soundDSATimer),
LOAD(u8[32], pcm[0].fifo),
LOAD(u8, state.soundDSAValue),
LOAD(uint8_t[32], pcm[0].fifo),
LOAD(uint8_t, state.soundDSAValue),
LOAD(int, pcm[1].readIndex),
LOAD(int, pcm[1].count),
LOAD(int, pcm[1].writeIndex),
SKIP(int, soundDSBEnabled),
SKIP(int, soundDSBTimer),
LOAD(u8[32], pcm[1].fifo),
LOAD(uint8_t[32], pcm[1].fifo),
LOAD(int, state.soundDSBValue),
// skipped manually
@ -669,7 +669,7 @@ static variable_desc old_gba_state[] = {
};
variable_desc old_gba_state2[] = {
LOAD(u8[0x20], state.apu.regs[0x20]),
LOAD(uint8_t[0x20], state.apu.regs[0x20]),
SKIP(int, sound3Bank),
SKIP(int, sound3DataSize),
SKIP(int, sound3ForcedOutput),
@ -682,7 +682,7 @@ static variable_desc gba_state[] = {
LOAD(int, pcm[0].readIndex),
LOAD(int, pcm[0].count),
LOAD(int, pcm[0].writeIndex),
LOAD(u8[32], pcm[0].fifo),
LOAD(uint8_t[32], pcm[0].fifo),
LOAD(int, pcm[0].dac),
SKIP(int[4], room_for_expansion),
@ -690,13 +690,13 @@ static variable_desc gba_state[] = {
LOAD(int, pcm[1].readIndex),
LOAD(int, pcm[1].count),
LOAD(int, pcm[1].writeIndex),
LOAD(u8[32], pcm[1].fifo),
LOAD(uint8_t[32], pcm[1].fifo),
LOAD(int, pcm[1].dac),
SKIP(int[4], room_for_expansion),
// APU
LOAD(u8[0x40], state.apu.regs), // last values written to registers and wave RAM (both banks)
LOAD(uint8_t[0x40], state.apu.regs), // last values written to registers and wave RAM (both banks)
LOAD(int, state.apu.frame_time), // clocks until next frame sequencer action
LOAD(int, state.apu.frame_phase), // next step frame sequencer will run
@ -727,7 +727,7 @@ static variable_desc gba_state[] = {
};
#ifdef __LIBRETRO__
void soundSaveGame(u8*& out)
void soundSaveGame(uint8_t*& out)
#else
void soundSaveGame(gzFile out)
#endif
@ -799,7 +799,7 @@ static void soundReadGameOld(gzFile in, int version)
#include <stdio.h>
#ifdef __LIBRETRO__
void soundReadGame(const u8*& in, int version)
void soundReadGame(const uint8_t*& in, int version)
#else
void soundReadGame(gzFile in, int version)
#endif

View File

@ -58,8 +58,8 @@ extern float soundFiltering; // 0.0 = none, 1.0 = max
void soundReset();
// Emulates write to sound hardware
void soundEvent(u32 addr, u8 data);
void soundEvent(u32 addr, u16 data); // TODO: error-prone to overload like this
void soundEvent(uint32_t addr, uint8_t data);
void soundEvent(uint32_t addr, uint16_t data); // TODO: error-prone to overload like this
// Notifies emulator that a timer has overflowed
void soundTimerOverflow(int which);
@ -74,8 +74,8 @@ extern int soundTicks; // Number of 16.8 MHz clocks until soundTick() will be ca
// Saves/loads emulator state
#ifdef __LIBRETRO__
void soundSaveGame(u8*&);
void soundReadGame(const u8*& in, int version);
void soundSaveGame(uint8_t*&);
void soundReadGame(const uint8_t*& in, int version);
#else
void soundSaveGame(gzFile);
void soundReadGame(gzFile, int version);

View File

@ -3,18 +3,18 @@
#include "GBA.h"
#include "Globals.h"
u8 sramRead(u32 address)
uint8_t sramRead(uint32_t address)
{
return flashSaveMemory[address & 0xFFFF];
}
void sramDelayedWrite(u32 address, u8 byte)
void sramDelayedWrite(uint32_t address, uint8_t byte)
{
saveType = 2;
cpuSaveGameFunc = sramWrite;
sramWrite(address, byte);
}
void sramWrite(u32 address, u8 byte)
void sramWrite(uint32_t address, uint8_t byte)
{
flashSaveMemory[address & 0xFFFF] = byte;
systemSaveUpdateCounter = SYSTEM_SAVE_UPDATED;

View File

@ -1,8 +1,10 @@
#ifndef SRAM_H
#define SRAM_H
u8 sramRead(u32 address);
void sramWrite(u32 address, u8 byte);
void sramDelayedWrite(u32 address, u8 byte);
#include <cstdint>
uint8_t sramRead(uint32_t address);
void sramWrite(uint32_t address, uint8_t byte);
void sramDelayedWrite(uint32_t address, uint8_t byte);
#endif // SRAM_H

View File

@ -478,7 +478,7 @@ void BIOS_Div()
reg[0].I = number / denom;
reg[1].I = number % denom;
int32_t temp = (int32_t)reg[0].I;
reg[3].I = temp < 0 ? (u32)-temp : (u32)temp;
reg[3].I = temp < 0 ? (uint32_t)-temp : (uint32_t)temp;
}
#ifdef GBA_LOGGING
if (systemVerbose & VERBOSE_SWI) {
@ -842,7 +842,7 @@ void BIOS_ObjAffineSet()
}
}
void BIOS_RegisterRamReset(u32 flags)
void BIOS_RegisterRamReset(uint32_t flags)
{
// no need to trace here. this is only called directly from GBA.cpp
// to emulate bios initialization
@ -1221,7 +1221,7 @@ static int32_t BIOS_SndDriver_3e4(uint32_t const r0a, uint32_t const r1a) // 0x3
return v5;
}
static void BIOS_SndDriverSub1(u32 p1) // 0x170a
static void BIOS_SndDriverSub1(uint32_t p1) // 0x170a
{
uint8_t local1 = (p1 & 0x000F0000) >> 16; // param is r0
uint32_t const puser1 = CPUReadMemory(0x3007FF0); // 7FC0 + 0x30
@ -1298,7 +1298,7 @@ void BIOS_SndDriverInit() // 0x166a
uint32_t const user1 = reg[0].I;
uint32_t base3 = 0x040000BC;
//u32 base4 = 0x03007FF0;
//uint32_t base4 = 0x03007FF0;
CPUWriteHalfWord(base1 + 6, 0);
CPUWriteHalfWord(base1 + 12, 0);
@ -1306,7 +1306,7 @@ void BIOS_SndDriverInit() // 0x166a
CPUWriteHalfWord(base2 + 4, 0x8F);
CPUWriteHalfWord(base2 + 2, 0xA90E);
u16 val9 = CPUReadHalfWord(base2 + 9);
uint16_t val9 = CPUReadHalfWord(base2 + 9);
CPUWriteHalfWord(base2 + 9, val9 & ADBITS_MASK); // DA?
CPUWriteMemory(base3 + 0, (user1 + 0x350)); //0x350, 640int

View File

@ -18,7 +18,7 @@ extern void BIOS_LZ77UnCompVram();
extern void BIOS_LZ77UnCompWram();
extern void BIOS_ObjAffineSet();
extern void BIOS_RegisterRamReset();
extern void BIOS_RegisterRamReset(u32);
extern void BIOS_RegisterRamReset(uint32_t);
extern void BIOS_RLUnCompVram();
extern void BIOS_RLUnCompWram();
extern void BIOS_SoftReset();

View File

@ -134,7 +134,7 @@ extern int dexp_error(char*);
extern int dexp_lex();
extern char* dexp_text;
std::map<std::string, u32> dexp_vars;
std::map<std::string, uint32_t> dexp_vars;
#define readWord(addr) \
READ32LE((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]))
@ -1677,7 +1677,7 @@ yyreturn:
#line 86 "src/sdl/debugger-expr.y"
bool dexp_eval(char* expr, u32* result)
bool dexp_eval(char* expr, uint32_t* result)
{
extern void dexp_flush();
extern char* dexprString;
@ -1701,7 +1701,7 @@ int dexp_error(char* s)
return 0;
}
void dexp_setVar(char* name, u32 value)
void dexp_setVar(char* name, uint32_t value)
{
std::string a(name);
dexp_vars[a] = value;
@ -1709,7 +1709,7 @@ void dexp_setVar(char* name, u32 value)
void dexp_listVars()
{
std::map<std::string, u32>::iterator iter;
std::map<std::string, uint32_t>::iterator iter;
for (iter = dexp_vars.begin(); iter != dexp_vars.end(); iter++) {
printf("%s = %08X\n", iter->first.c_str(), iter->second);
@ -1718,7 +1718,7 @@ void dexp_listVars()
void dexp_saveVars(char* file)
{
std::map<std::string, u32>::iterator iter;
std::map<std::string, uint32_t>::iterator iter;
FILE* f = fopen(file, "w");
if (!f) {
@ -1734,10 +1734,10 @@ void dexp_saveVars(char* file)
void dexp_loadVars(char* file)
{
std::map<std::string, u32>::iterator iter;
std::map<std::string, uint32_t>::iterator iter;
char buffer[500];
char name[500];
u32 val;
uint32_t val;
FILE* f = fopen(file, "r");
if (!f) {

View File

@ -14,7 +14,7 @@ extern int dexp_error(char *);
extern int dexp_lex();
extern char *dexp_text;
std::map<std::string, u32> dexp_vars;
std::map<std::string, uint32_t> dexp_vars;
#define readWord(addr) \
READ32LE((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask]))
@ -85,7 +85,7 @@ exp: TOK_NUMBER { $$ = $1; }
;
%%
bool dexp_eval(char *expr, u32 *result)
bool dexp_eval(char *expr, uint32_t *result)
{
extern void dexp_flush();
extern char *dexprString;
@ -110,7 +110,7 @@ int dexp_error(char *s)
return 0;
}
void dexp_setVar(char *name, u32 value)
void dexp_setVar(char *name, uint32_t value)
{
std::string a(name);
dexp_vars[a] = value;
@ -118,7 +118,7 @@ void dexp_setVar(char *name, u32 value)
void dexp_listVars()
{
std::map<std::string, u32>::iterator iter;
std::map<std::string, uint32_t>::iterator iter;
for (iter = dexp_vars.begin(); iter != dexp_vars.end(); iter++) {
printf("%s = %08X\n", iter->first.c_str(), iter->second);
@ -127,7 +127,7 @@ void dexp_listVars()
void dexp_saveVars(char *file)
{
std::map<std::string, u32>::iterator iter;
std::map<std::string, uint32_t>::iterator iter;
FILE *f = fopen(file, "w");
if (!f) {
@ -143,10 +143,10 @@ void dexp_saveVars(char *file)
void dexp_loadVars(char *file)
{
std::map<std::string, u32>::iterator iter;
std::map<std::string, uint32_t>::iterator iter;
char buffer[500];
char name[500];
u32 val;
uint32_t val;
FILE *f = fopen(file, "r");
if (!f) {

View File

@ -31,7 +31,7 @@ void gbafilter_pal(uint16_t* buf, int count)
{
short temp[3 * 3], s;
unsigned pix;
u8 red, green, blue;
uint8_t red, green, blue;
while (count--) {
pix = *buf;
@ -105,7 +105,7 @@ void gbafilter_pal32(uint32_t* buf, int count)
{
short temp[3 * 3], s;
unsigned pix;
u8 red, green, blue;
uint8_t red, green, blue;
while (count--) {
pix = *buf;
@ -178,15 +178,15 @@ void gbafilter_pal32(uint32_t* buf, int count)
// for palette mode to work with the three spoony filters in 32bpp depth
void gbafilter_pad(u8* buf, int count)
void gbafilter_pad(uint8_t* buf, int count)
{
union {
struct
{
u8 r;
u8 g;
u8 b;
u8 a;
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
} part;
unsigned whole;
} mask;

View File

@ -62,19 +62,19 @@ void remoteSetSockets(SOCKET l, SOCKET r)
#endif
#define debuggerReadMemory(addr) \
(*(u32*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])
(*(uint32_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])
#define debuggerReadHalfWord(addr) \
(*(u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])
(*(uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])
#define debuggerReadByte(addr) \
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]
#define debuggerWriteMemory(addr, value) \
*(u32*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
*(uint32_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
#define debuggerWriteHalfWord(addr, value) \
*(u16*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
*(uint16_t*)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
#define debuggerWriteByte(addr, value) \
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
@ -84,7 +84,7 @@ int debuggerNumOfDontBreak = 0;
int debuggerRadix = 0;
#define NUMBEROFDB 1000
u32 debuggerNoBreakpointList[NUMBEROFDB];
uint32_t debuggerNoBreakpointList[NUMBEROFDB];
const char* cmdAliasTable[] = { "help", "?", "h", "?", "continue", "c", "next", "n",
"cpyb", "copyb", "cpyh", "copyh", "cpyw", "copyw",
@ -107,24 +107,24 @@ void debuggerHelp(int n, char** args);
void printFlagHelp();
void dbgExecute(std::string& cmd);
extern bool debuggerBreakOnWrite(u32, u32, int);
extern bool debuggerBreakOnRegisterCondition(u8, u32, u32, u8);
extern bool debuggerBreakOnExecution(u32, u8);
extern bool debuggerBreakOnWrite(uint32_t, uint32_t, int);
extern bool debuggerBreakOnRegisterCondition(uint8_t, uint32_t, uint32_t, uint8_t);
extern bool debuggerBreakOnExecution(uint32_t, uint8_t);
regBreak* breakRegList[16];
u8 lowRegBreakCounter[4]; //(r0-r3)
u8 medRegBreakCounter[4]; //(r4-r7)
u8 highRegBreakCounter[4]; //(r8-r11)
u8 statusRegBreakCounter[4]; //(r12-r15)
u8* regBreakCounter[4] = {
uint8_t lowRegBreakCounter[4]; //(r0-r3)
uint8_t medRegBreakCounter[4]; //(r4-r7)
uint8_t highRegBreakCounter[4]; //(r8-r11)
uint8_t statusRegBreakCounter[4]; //(r12-r15)
uint8_t* regBreakCounter[4] = {
&lowRegBreakCounter[0],
&medRegBreakCounter[0],
&highRegBreakCounter[0],
&statusRegBreakCounter[0]
};
u32 lastWasBranch = 0;
uint32_t lastWasBranch = 0;
struct regBreak* getFromBreakRegList(u8 regnum, int location)
struct regBreak* getFromBreakRegList(uint8_t regnum, int location)
{
if (location > regBreakCounter[regnum >> 2][regnum & 3])
return NULL;
@ -138,20 +138,20 @@ struct regBreak* getFromBreakRegList(u8 regnum, int location)
bool enableRegBreak = false;
reg_pair oldReg[16];
u32 regDiff[16];
uint32_t regDiff[16];
void breakReg_check(int i)
{
struct regBreak* brkR = breakRegList[i];
bool notFound = true;
u8 counter = regBreakCounter[i >> 2][i & 3];
uint8_t counter = regBreakCounter[i >> 2][i & 3];
for (int bri = 0; (bri < counter) && notFound; bri++) {
if (!brkR) {
regBreakCounter[i >> 2][i & 3] = (u8)bri;
regBreakCounter[i >> 2][i & 3] = (uint8_t)bri;
break;
} else {
if (brkR->flags != 0) {
u32 regVal = (i == 15 ? (armState ? reg[15].I - 4 : reg[15].I - 2) : reg[i].I);
uint32_t regVal = (i == 15 ? (armState ? reg[15].I - 4 : reg[15].I - 2) : reg[i].I);
if ((brkR->flags & 0x1) && (regVal == brkR->intVal)) {
debuggerBreakOnRegisterCondition(i, brkR->intVal, regVal, 1);
notFound = false;
@ -201,7 +201,7 @@ void clearBreakRegList()
}
}
void deleteFromBreakRegList(u8 regNum, int num)
void deleteFromBreakRegList(uint8_t regNum, int num)
{
int counter = regBreakCounter[regNum >> 2][regNum & 3];
if (num >= counter) {
@ -222,7 +222,7 @@ void deleteFromBreakRegList(u8 regNum, int num)
regBreakCounter[regNum >> 2][regNum & 3]--;
}
void addBreakRegToList(u8 regnum, u8 flags, u32 value)
void addBreakRegToList(uint8_t regnum, uint8_t flags, uint32_t value)
{
struct regBreak* ans = (struct regBreak*)malloc(sizeof(struct regBreak));
ans->flags = flags;
@ -298,7 +298,7 @@ void printBreakRegList(bool verbose)
}
}
void debuggerOutput(const char* s, u32 addr)
void debuggerOutput(const char* s, uint32_t addr)
{
if (s)
printf("%s", s);
@ -316,7 +316,7 @@ void debuggerOutput(const char* s, u32 addr)
}
// checks that the given address is in the DB list
bool debuggerInDB(u32 address)
bool debuggerInDB(uint32_t address)
{
for (int i = 0; i < debuggerNumOfDontBreak; i++) {
@ -330,7 +330,7 @@ bool debuggerInDB(u32 address)
void debuggerDontBreak(int n, char** args)
{
if (n == 2) {
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
int i = debuggerNumOfDontBreak;
if (i > NUMBEROFDB) {
@ -361,7 +361,7 @@ void debuggerDontBreakClear(int n, char** args)
void debuggerDumpLoad(int n, char** args)
{
u32 address;
uint32_t address;
char* file;
FILE* f;
int c;
@ -405,8 +405,8 @@ void debuggerDumpLoad(int n, char** args)
void debuggerDumpSave(int n, char** args)
{
u32 address;
u32 size;
uint32_t address;
uint32_t size;
char* file;
FILE* f;
@ -436,7 +436,7 @@ void debuggerDumpSave(int n, char** args)
return;
}
for (u32 i = 0; i < size; i++) {
for (uint32_t i = 0; i < size; i++) {
fputc(debuggerReadByte(address), f);
address++;
}
@ -449,8 +449,8 @@ void debuggerDumpSave(int n, char** args)
void debuggerEditByte(int n, char** args)
{
if (n >= 3) {
u32 address;
u32 value;
uint32_t address;
uint32_t value;
if (!dexp_eval(args[1], &address)) {
{
sprintf(monbuf, "Invalid expression in address.\n");
@ -465,7 +465,7 @@ void debuggerEditByte(int n, char** args)
monprintf(monbuf);
}
}
debuggerWriteByte(address, (u16)value);
debuggerWriteByte(address, (uint16_t)value);
address++;
}
} else
@ -475,8 +475,8 @@ void debuggerEditByte(int n, char** args)
void debuggerEditHalfWord(int n, char** args)
{
if (n >= 3) {
u32 address;
u32 value;
uint32_t address;
uint32_t value;
if (!dexp_eval(args[1], &address)) {
{
sprintf(monbuf, "Invalid expression in address.\n");
@ -498,7 +498,7 @@ void debuggerEditHalfWord(int n, char** args)
monprintf(monbuf);
}
}
debuggerWriteHalfWord(address, (u16)value);
debuggerWriteHalfWord(address, (uint16_t)value);
address += 2;
}
} else
@ -508,8 +508,8 @@ void debuggerEditHalfWord(int n, char** args)
void debuggerEditWord(int n, char** args)
{
if (n >= 3) {
u32 address;
u32 value;
uint32_t address;
uint32_t value;
if (!dexp_eval(args[1], &address)) {
{
sprintf(monbuf, "Invalid expression in address.\n");
@ -531,14 +531,14 @@ void debuggerEditWord(int n, char** args)
monprintf(monbuf);
}
}
debuggerWriteMemory(address, (u32)value);
debuggerWriteMemory(address, (uint32_t)value);
address += 4;
}
} else
debuggerUsage("ew");
}
bool debuggerBreakOnRegisterCondition(u8 registerName, u32 compareVal, u32 regVal, u8 type)
bool debuggerBreakOnRegisterCondition(uint8_t registerName, uint32_t compareVal, uint32_t regVal, uint8_t type)
{
const char* typeName;
switch (type) {
@ -602,7 +602,7 @@ void debuggerEditRegister(int n, char** args)
{
if (n == 3) {
int r = getRegisterNumber(args[1]);
u32 val;
uint32_t val;
if (r > 16) {
{
sprintf(monbuf, "Error: Register must be valid (0-16)\n");
@ -629,7 +629,7 @@ void debuggerEditRegister(int n, char** args)
void debuggerEval(int n, char** args)
{
if (n == 2) {
u32 result = 0;
uint32_t result = 0;
if (dexp_eval(args[1], &result)) {
{
sprintf(monbuf, " =$%08X\n", result);
@ -648,9 +648,9 @@ void debuggerEval(int n, char** args)
void debuggerFillByte(int n, char** args)
{
if (n == 4) {
u32 address;
u32 value;
u32 reps;
uint32_t address;
uint32_t value;
uint32_t reps;
if (!dexp_eval(args[1], &address)) {
{
sprintf(monbuf, "Invalid expression in address.\n");
@ -670,8 +670,8 @@ void debuggerFillByte(int n, char** args)
monprintf(monbuf);
}
}
for (u32 i = 0; i < reps; i++) {
debuggerWriteByte(address, (u8)value);
for (uint32_t i = 0; i < reps; i++) {
debuggerWriteByte(address, (uint8_t)value);
address++;
}
} else
@ -681,9 +681,9 @@ void debuggerFillByte(int n, char** args)
void debuggerFillHalfWord(int n, char** args)
{
if (n == 4) {
u32 address;
u32 value;
u32 reps;
uint32_t address;
uint32_t value;
uint32_t reps;
if (!dexp_eval(args[1], &address)) {
{
sprintf(monbuf, "Invalid expression in address.\n");
@ -707,8 +707,8 @@ void debuggerFillHalfWord(int n, char** args)
monprintf(monbuf);
}
}
for (u32 i = 0; i < reps; i++) {
debuggerWriteHalfWord(address, (u16)value);
for (uint32_t i = 0; i < reps; i++) {
debuggerWriteHalfWord(address, (uint16_t)value);
address += 2;
}
} else
@ -718,9 +718,9 @@ void debuggerFillHalfWord(int n, char** args)
void debuggerFillWord(int n, char** args)
{
if (n == 4) {
u32 address;
u32 value;
u32 reps;
uint32_t address;
uint32_t value;
uint32_t reps;
if (!dexp_eval(args[1], &address)) {
{
sprintf(monbuf, "Invalid expression in address.\n");
@ -744,8 +744,8 @@ void debuggerFillWord(int n, char** args)
monprintf(monbuf);
}
}
for (u32 i = 0; i < reps; i++) {
debuggerWriteMemory(address, (u32)value);
for (uint32_t i = 0; i < reps; i++) {
debuggerWriteMemory(address, (uint32_t)value);
address += 4;
}
} else
@ -754,11 +754,11 @@ void debuggerFillWord(int n, char** args)
unsigned int SearchStart = 0xFFFFFFFF;
unsigned int SearchMaxMatches = 5;
u8 SearchData[64]; // It actually doesn't make much sense to search for more than 64 bytes, does it?
uint8_t SearchData[64]; // It actually doesn't make much sense to search for more than 64 bytes, does it?
unsigned int SearchLength = 0;
unsigned int SearchResults;
unsigned int AddressToGBA(u8* mem)
unsigned int AddressToGBA(uint8_t* mem)
{
if (mem >= &bios[0] && mem <= &bios[0x3fff])
return 0x00000000 + (mem - &bios[0]);
@ -786,8 +786,8 @@ void debuggerDoSearch()
while (true) {
unsigned int final = SearchStart + SearchLength - 1;
u8* end;
u8* start;
uint8_t* end;
uint8_t* start;
switch (SearchStart >> 24) {
case 0:
@ -873,7 +873,7 @@ void debuggerDoSearch()
};
end -= SearchLength - 1;
u8 firstbyte = SearchData[0];
uint8_t firstbyte = SearchData[0];
while (start <= end) {
while ((start <= end) && (*start != firstbyte))
start++;
@ -1013,10 +1013,10 @@ void debuggerFindResume(int n, char** args)
void debuggerCopyByte(int n, char** args)
{
u32 source;
u32 dest;
u32 number = 1;
u32 reps = 1;
uint32_t source;
uint32_t dest;
uint32_t number = 1;
uint32_t reps = 1;
if (n > 5 || n < 3) {
debuggerUsage("copyb");
}
@ -1051,8 +1051,8 @@ void debuggerCopyByte(int n, char** args)
}
}
for (u32 j = 0; j < reps; j++) {
for (u32 i = 0; i < number; i++) {
for (uint32_t j = 0; j < reps; j++) {
for (uint32_t i = 0; i < number; i++) {
debuggerWriteByte(dest + i, debuggerReadByte(source + i));
}
dest += number;
@ -1061,10 +1061,10 @@ void debuggerCopyByte(int n, char** args)
void debuggerCopyHalfWord(int n, char** args)
{
u32 source;
u32 dest;
u32 number = 2;
u32 reps = 1;
uint32_t source;
uint32_t dest;
uint32_t number = 2;
uint32_t reps = 1;
if (n > 5 || n < 3) {
debuggerUsage("copyh");
}
@ -1100,8 +1100,8 @@ void debuggerCopyHalfWord(int n, char** args)
}
}
for (u32 j = 0; j < reps; j++) {
for (u32 i = 0; i < number; i += 2) {
for (uint32_t j = 0; j < reps; j++) {
for (uint32_t i = 0; i < number; i += 2) {
debuggerWriteHalfWord(dest + i, debuggerReadHalfWord(source + i));
}
dest += number;
@ -1110,10 +1110,10 @@ void debuggerCopyHalfWord(int n, char** args)
void debuggerCopyWord(int n, char** args)
{
u32 source;
u32 dest;
u32 number = 4;
u32 reps = 1;
uint32_t source;
uint32_t dest;
uint32_t number = 4;
uint32_t reps = 1;
if (n > 5 || n < 3) {
debuggerUsage("copyw");
}
@ -1149,8 +1149,8 @@ void debuggerCopyWord(int n, char** args)
}
}
for (u32 j = 0; j < reps; j++) {
for (u32 i = 0; i < number; i += 4) {
for (uint32_t j = 0; j < reps; j++) {
for (uint32_t i = 0; i < number; i += 4) {
debuggerWriteMemory(dest + i, debuggerReadMemory(source + i));
}
dest += number;
@ -1452,7 +1452,7 @@ char** wordSymbol;
bool isTerminator[256];
bool isNewline[256];
bool isTab[256];
u8 largestSymbol = 1;
uint8_t largestSymbol = 1;
void freeWordSymbolContents()
{
@ -1501,7 +1501,7 @@ void debuggerReadCharTable(int n, char** args)
return;
}
char buffer[30];
u32 slot;
uint32_t slot;
char* character = (char*)calloc(10, sizeof(char));
wordSymbol = (char**)calloc(256, sizeof(char*));
while (fgets(buffer, 30, tlb)) {
@ -1541,7 +1541,7 @@ void debuggerReadCharTable(int n, char** args)
}
}
void printCharGroup(u32 addr, bool useAscii)
void printCharGroup(uint32_t addr, bool useAscii)
{
for (int i = 0; i < 16; i++) {
if (useWordSymbol && !useAscii) {
@ -1575,7 +1575,7 @@ void printCharGroup(u32 addr, bool useAscii)
void debuggerMemoryByte(int n, char** args)
{
if (n == 2) {
u32 addr = 0;
uint32_t addr = 0;
if (!dexp_eval(args[1], &addr)) {
{
@ -1609,7 +1609,7 @@ void debuggerMemoryByte(int n, char** args)
void debuggerMemoryHalfWord(int n, char** args)
{
if (n == 2) {
u32 addr = 0;
uint32_t addr = 0;
if (!dexp_eval(args[1], &addr)) {
{
@ -1646,7 +1646,7 @@ void debuggerMemoryHalfWord(int n, char** args)
void debuggerMemoryWord(int n, char** args)
{
if (n == 2) {
u32 addr = 0;
uint32_t addr = 0;
if (!dexp_eval(args[1], &addr)) {
{
sprintf(monbuf, "Invalid expression\n");
@ -1680,7 +1680,7 @@ void debuggerMemoryWord(int n, char** args)
void debuggerStringRead(int n, char** args)
{
if (n == 2) {
u32 addr = 0;
uint32_t addr = 0;
if (!dexp_eval(args[1], &addr)) {
{
@ -1690,7 +1690,7 @@ void debuggerStringRead(int n, char** args)
return;
}
for (int i = 0; i < 512; i++) {
u8 slot = debuggerReadByte(addr + i);
uint8_t slot = debuggerReadByte(addr + i);
if (useWordSymbol) {
if (isTerminator[slot]) {
@ -1830,8 +1830,8 @@ void debuggerSetRadix(int argc, char** argv)
void debuggerSymbols(int argc, char** argv)
{
int i = 0;
u32 value;
u32 size;
uint32_t value;
uint32_t size;
int type;
bool match = false;
int matchSize = 0;
@ -1882,13 +1882,13 @@ void debuggerSymbols(int argc, char** argv)
void debuggerWhere(int n, char** args)
{
void elfPrintCallChain(u32);
void elfPrintCallChain(uint32_t);
elfPrintCallChain(armNextPC);
}
void debuggerVar(int n, char** args)
{
u32 val;
uint32_t val;
if (n < 2) {
dexp_listVars();
@ -1956,7 +1956,7 @@ void debuggerVar(int n, char** args)
}
}
bool debuggerBreakOnExecution(u32 address, u8 state)
bool debuggerBreakOnExecution(uint32_t address, uint8_t state)
{
if (dontBreakNow)
return false;
@ -1973,7 +1973,7 @@ bool debuggerBreakOnExecution(u32 address, u8 state)
return true;
}
bool debuggerBreakOnRead(u32 address, int size)
bool debuggerBreakOnRead(uint32_t address, int size)
{
if (dontBreakNow)
return false;
@ -1994,7 +1994,7 @@ bool debuggerBreakOnRead(u32 address, int size)
return true;
}
bool debuggerBreakOnWrite(u32 address, u32 value, int size)
bool debuggerBreakOnWrite(uint32_t address, uint32_t value, int size)
{
if (dontBreakNow)
return false;
@ -2002,25 +2002,25 @@ bool debuggerBreakOnWrite(u32 address, u32 value, int size)
return false;
if (!doesBreak(address, 0x11))
return false;
//u32 lastValue;
//uint32_t lastValue;
//dexp_eval("old_value", &lastValue);
//if (size == 2)
// monprintf("Breakpoint (on write) address %08x old:%08x new:%08x\n",
// address, lastValue, value);
//else if (size == 1)
// monprintf("Breakpoint (on write) address %08x old:%04x new:%04x\n",
// address, (u16)lastValue, (u16)value);
// address, (uint16_t)lastValue, (uint16_t)value);
//else
// monprintf("Breakpoint (on write) address %08x old:%02x new:%02x\n",
// address, (u8)lastValue, (u8)value);
// address, (uint8_t)lastValue, (uint8_t)value);
debugger = true;
return true;
}
void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value, int size, int t)
void debuggerBreakOnWrite(uint32_t address, uint32_t oldvalue, uint32_t value, int size, int t)
{
debuggerBreakOnWrite(address, value, size);
//u32 lastValue;
//uint32_t lastValue;
//dexp_eval("old_value", &lastValue);
//const char *type = "write";
@ -2032,14 +2032,14 @@ void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value, int size, int t)
// type, address, oldvalue, value);
//else if (size == 1)
// monprintf("Breakpoint (on %s) address %08x old:%04x new:%04x\n",
// type, address, (u16)oldvalue, (u16)value);
// type, address, (uint16_t)oldvalue, (uint16_t)value);
//else
// monprintf("Breakpoint (on %s) address %08x old:%02x new:%02x\n",
// type, address, (u8)oldvalue, (u8)value);
// type, address, (uint8_t)oldvalue, (uint8_t)value);
//debugger = true;
}
u8 getFlags(char* flagName)
uint8_t getFlags(char* flagName)
{
for (int i = 0; flagName[i] != '\0'; i++) {
@ -2054,7 +2054,7 @@ u8 getFlags(char* flagName)
return 0x0;
}
u8 flag = 0;
uint8_t flag = 0;
bool negate_flag = false;
@ -2096,9 +2096,9 @@ void debuggerBreakRegister(int n, char** args)
printFlagHelp();
return;
}
u8 reg = (u8)getRegisterNumber(args[0]);
u8 flag = getFlags(args[1]);
u32 value;
uint8_t reg = (uint8_t)getRegisterNumber(args[0]);
uint8_t flag = getFlags(args[1]);
uint32_t value;
if (!dexp_eval(args[2], &value)) {
{
sprintf(monbuf, "Invalid expression.\n");
@ -2153,7 +2153,7 @@ void debuggerBreakRegisterDelete(int n, char** args)
}
return;
}
u32 num;
uint32_t num;
if (!dexp_eval(args[1], &num)) {
{
sprintf(monbuf, "Could not parse the breakpoint number:\n Correct usage requires <register> <breakpointNo>.\n");
@ -2331,7 +2331,7 @@ char* breakSymbolCombo(char* command, int* length)
return res;
}
const char* typeMapping[] = { "'u8", "'u16", "'u32", "'u32", "'s8", "'s16", "'s32", "'s32" };
const char* typeMapping[] = { "'uint8_t", "'uint16_t", "'uint32_t", "'uint32_t", "'int8_t", "'int16_t", "'int32_t", "'int32_t" };
const char* compareFlagMapping[] = { "Never", "==", ">", ">=", "<", "<=", "!=", "<=>" };
@ -2393,7 +2393,7 @@ void printConditionalBreak(struct ConditionalBreak* toPrint, bool printAddress)
monprintf(monbuf);
}
bool hasPrevCond = false;
u8 flgs = 0x80;
uint8_t flgs = 0x80;
while (flgs != 0) {
if (toPrint->type_flags & flgs) {
if (hasPrevCond) {
@ -2455,7 +2455,7 @@ void printAllConditionals()
}
struct ConditionalBreak* base = conditionals[i];
int count = 1;
u32 lastAddress = base->break_address;
uint32_t lastAddress = base->break_address;
{
sprintf(monbuf, "Address %08x\n-------------------------\n", lastAddress);
monprintf(monbuf);
@ -2485,9 +2485,9 @@ void printAllConditionals()
}
}
u8 printConditionalsFromAddress(u32 address)
uint8_t printConditionalsFromAddress(uint32_t address)
{
u8 count = 1;
uint8_t count = 1;
if (conditionals[address >> 24] != NULL) {
struct ConditionalBreak* base = conditionals[address >> 24];
while (base) {
@ -2519,7 +2519,7 @@ u8 printConditionalsFromAddress(u32 address)
return count;
}
void printAllFlagConditionals(u8 flag, bool orMode)
void printAllFlagConditionals(uint8_t flag, bool orMode)
{
int count = 1;
int actualCount = 1;
@ -2528,7 +2528,7 @@ void printAllFlagConditionals(u8 flag, bool orMode)
bool isCondStart = true;
struct ConditionalBreak* base = conditionals[i];
u32 lastAddress = base->break_address;
uint32_t lastAddress = base->break_address;
while (base) {
if (lastAddress != base->break_address) {
@ -2568,7 +2568,7 @@ void printAllFlagConditionals(u8 flag, bool orMode)
}
}
void printAllFlagConditionalsWithAddress(u32 address, u8 flag, bool orMode)
void printAllFlagConditionalsWithAddress(uint32_t address, uint8_t flag, bool orMode)
{
int count = 1;
int actualCount = 1;
@ -2577,7 +2577,7 @@ void printAllFlagConditionalsWithAddress(u32 address, u8 flag, bool orMode)
bool isCondStart = true;
struct ConditionalBreak* base = conditionals[i];
u32 lastAddress = base->break_address;
uint32_t lastAddress = base->break_address;
while (base) {
if (lastAddress != base->break_address) {
@ -2617,7 +2617,7 @@ void printAllFlagConditionalsWithAddress(u32 address, u8 flag, bool orMode)
}
}
void makeBreak(u32 address, u8 flags, char** expression, int n)
void makeBreak(uint32_t address, uint8_t flags, char** expression, int n)
{
if (n >= 1) {
if (tolower(expression[0][0]) == 'i' && tolower(expression[0][1]) == 'f') {
@ -2634,7 +2634,7 @@ void makeBreak(u32 address, u8 flags, char** expression, int n)
return;
}
}
void deleteBreak(u32 address, u8 flags, char** expression, int howToDelete)
void deleteBreak(uint32_t address, uint8_t flags, char** expression, int howToDelete)
{
bool applyOr = true;
if (howToDelete > 0) {
@ -2644,7 +2644,7 @@ void deleteBreak(u32 address, u8 flags, char** expression, int howToDelete)
expression++;
}
if (howToDelete > 0) {
u32 number = 0;
uint32_t number = 0;
if (!dexp_eval(expression[0], &number)) {
{
sprintf(monbuf, "Invalid expression for number format.\n");
@ -2652,7 +2652,7 @@ void deleteBreak(u32 address, u8 flags, char** expression, int howToDelete)
}
return;
}
removeFlagFromConditionalBreakNo(address, (u8)number, (flags | (flags >> 4)));
removeFlagFromConditionalBreakNo(address, (uint8_t)number, (flags | (flags >> 4)));
{
sprintf(monbuf, "Removed all specified breaks from %08x.\n", address);
monprintf(monbuf);
@ -2675,7 +2675,7 @@ void deleteBreak(u32 address, u8 flags, char** expression, int howToDelete)
}
return;
}
void clearBreaks(u32 address, u8 flags, char** expression, int howToClear)
void clearBreaks(uint32_t address, uint8_t flags, char** expression, int howToClear)
{
if (howToClear == 2) {
removeConditionalWithFlag(flags, true);
@ -2690,7 +2690,7 @@ void clearBreaks(u32 address, u8 flags, char** expression, int howToClear)
}
}
void listBreaks(u32 address, u8 flags, char** expression, int howToList)
void listBreaks(uint32_t address, uint8_t flags, char** expression, int howToList)
{
flags |= (flags << 4);
if (howToList) {
@ -2723,10 +2723,10 @@ void executeBreakCommands(int n, char** cmd)
}
cmd++;
n--;
void (*operation)(u32, u8, char**, int) = &makeBreak; //the function to be called
void (*operation)(uint32_t, uint8_t, char**, int) = &makeBreak; //the function to be called
u8 flag = 0;
u32 address = 0;
uint8_t flag = 0;
uint32_t address = 0;
//if(strlen(command) == 1){
//Cannot happen, that would mean cmd[0] != b
//}
@ -3158,16 +3158,16 @@ void debuggerUsage(const char* cmd)
monprintf("&& states the next condition must happen with the previous one, or the break\nfails.\n");
monprintf("|| states the next condition is independent from the last one, and break\nseparately.\n\n");
monprintf("Type can be:\n");
monprintf(" [u8, b, byte],[u16, h, hword, halfword],[u32,w, word]\n");
monprintf(" [s8, sb, sbyte],[s16, sh, shword, short, shalfword],[s32, int, sw, word]\n");
monprintf("Types have to be preceded by a ' ex: 'int, 'u8\n\n");
monprintf(" [uint8_t, b, byte],[uint16_t, h, hword, halfword],[uint32_t,w, word]\n");
monprintf(" [int8_t, sb, sbyte],[int16_t, sh, shword, short, shalfword],[int32_t, int, sw, word]\n");
monprintf("Types have to be preceded by a ' ex: 'int, 'uint8_t\n\n");
monprintf("Conditions may be:\n");
monprintf("C-like:\t\t[<], [<=], [>], [>=] , [==], [!= or <>]\n");
monprintf("ASM-like:\t[lt], [le], [gt], [ge] , [eq], [ne]\n\n");
monprintf("EX: bw 0x03005008 if old_value == 'u32 [0x03005008]\n");
monprintf("EX: bw 0x03005008 if old_value == 'uint32_t [0x03005008]\n");
monprintf("Breaks on write from 0x03005008, when the old_value variable, that is assigned\n");
monprintf("as the previous memory value when a write is performed, is equal to the new\ncontents of 0x03005008.\n\n");
monprintf("EX: bx 0x08000500 if r0 == 1 || r0 > 1 && r2 == 0 || 'u8 [r7] == 5\n");
monprintf("EX: bx 0x08000500 if r0 == 1 || r0 > 1 && r2 == 0 || 'uint8_t [r7] == 5\n");
monprintf("Breaks in either thumb or arm execution of 0x08000500, if r0's contents are 1,\n");
monprintf("or if r0's contents are bigger than 1 and r2 is equal to 0, or the content of\nthe address at r7(as byte) is equal to 5.\n");
monprintf("It will not break if r0 > 1 and r2 != 0.\n");
@ -3555,7 +3555,7 @@ void remotePutPacket(const char* packet)
}
}
void remoteOutput(const char* s, u32 addr)
void remoteOutput(const char* s, uint32_t addr)
{
char buffer[16384];
@ -3597,7 +3597,7 @@ void remoteSendStatus()
char* s = buffer;
s += 3;
for (int i = 0; i < 15; i++) {
u32 v = reg[i].I;
uint32_t v = reg[i].I;
sprintf(s, "%02x:%02x%02x%02x%02x;", i,
(v & 255),
(v >> 8) & 255,
@ -3605,7 +3605,7 @@ void remoteSendStatus()
(v >> 24) & 255);
s += 12;
}
u32 v = armNextPC;
uint32_t v = armNextPC;
sprintf(s, "0f:%02x%02x%02x%02x;", (v & 255),
(v >> 8) & 255,
(v >> 16) & 255,
@ -3625,7 +3625,7 @@ void remoteSendStatus()
void remoteBinaryWrite(char* p)
{
u32 address;
uint32_t address;
int count;
sscanf(p, "%x,%x:", &address, &count);
// monprintf("Binary write for %08x %d\n", address, count);
@ -3633,7 +3633,7 @@ void remoteBinaryWrite(char* p)
p = strchr(p, ':');
p++;
for (int i = 0; i < count; i++) {
u8 b = *p++;
uint8_t b = *p++;
switch (b) {
case 0x7d:
b = *p++;
@ -3652,7 +3652,7 @@ void remoteBinaryWrite(char* p)
void remoteMemoryWrite(char* p)
{
u32 address;
uint32_t address;
int count;
sscanf(p, "%x,%x:", &address, &count);
// monprintf("Memory write for %08x %d\n", address, count);
@ -3660,7 +3660,7 @@ void remoteMemoryWrite(char* p)
p = strchr(p, ':');
p++;
for (int i = 0; i < count; i++) {
u8 v = 0;
uint8_t v = 0;
char c = *p++;
if (c <= '9')
v = (c - '0') << 4;
@ -3680,7 +3680,7 @@ void remoteMemoryWrite(char* p)
void remoteMemoryRead(char* p)
{
u32 address;
uint32_t address;
int count;
sscanf(p, "%x,%x:", &address, &count);
// monprintf("Memory read for %08x %d\n", address, count);
@ -3689,7 +3689,7 @@ void remoteMemoryRead(char* p)
char* s = buffer;
for (int i = 0; i < count; i++) {
u8 b = debuggerReadByte(address);
uint8_t b = debuggerReadByte(address);
sprintf(s, "%02x", b);
address++;
s += 2;
@ -3718,8 +3718,8 @@ void remoteQuery(char* p)
void remoteStepOverRange(char* p)
{
u32 address;
u32 final;
uint32_t address;
uint32_t final;
sscanf(p, "%x,%x", &address, & final);
remotePutPacket("OK");
@ -3738,7 +3738,7 @@ void remoteStepOverRange(char* p)
void remoteSetBreakPoint(char* p)
{
u32 address;
uint32_t address;
int count;
sscanf(p, ",%x,%x#", &address, &count);
@ -3756,7 +3756,7 @@ void remoteSetBreakPoint(char* p)
// return;
//}
//u32 final = address + count;
//uint32_t final = address + count;
//if (address < 0x2040000 && final > 0x2040000) {
// remotePutPacket("E01");
@ -3772,7 +3772,7 @@ void remoteSetBreakPoint(char* p)
void remoteClearBreakPoint(char* p)
{
int result;
u32 address;
uint32_t address;
int count;
sscanf(p, ",%x,%x#", &address, &count);
@ -3787,7 +3787,7 @@ void remoteClearBreakPoint(char* p)
void remoteSetMemoryReadBreakPoint(char* p)
{
u32 address;
uint32_t address;
int count;
sscanf(p, ",%x,%x#", &address, &count);
@ -3805,7 +3805,7 @@ void remoteSetMemoryReadBreakPoint(char* p)
// return;
//}
//u32 final = address + count;
//uint32_t final = address + count;
//if (address < 0x2040000 && final > 0x2040000) {
// remotePutPacket("E01");
@ -3822,7 +3822,7 @@ void remoteClearMemoryReadBreakPoint(char* p)
{
bool error = false;
int result;
u32 address;
uint32_t address;
int count;
sscanf(p, ",%x,%x#", &address, &count);
@ -3840,7 +3840,7 @@ void remoteClearMemoryReadBreakPoint(char* p)
void remoteSetMemoryAccessBreakPoint(char* p)
{
u32 address;
uint32_t address;
int count;
sscanf(p, ",%x,%x#", &address, &count);
@ -3858,7 +3858,7 @@ void remoteSetMemoryAccessBreakPoint(char* p)
// return;
//}
//u32 final = address + count;
//uint32_t final = address + count;
//if (address < 0x2040000 && final > 0x2040000) {
// remotePutPacket("E01");
@ -3875,7 +3875,7 @@ void remoteClearMemoryAccessBreakPoint(char* p)
{
bool error = false;
int result;
u32 address;
uint32_t address;
int count;
sscanf(p, ",%x,%x#", &address, &count);
@ -3893,7 +3893,7 @@ void remoteClearMemoryAccessBreakPoint(char* p)
void remoteWriteWatch(char* p, bool active)
{
u32 address;
uint32_t address;
int count;
sscanf(p, ",%x,%x#", &address, &count);
@ -3918,7 +3918,7 @@ void remoteWriteWatch(char* p, bool active)
// return;
//}
u32 final = address + count;
uint32_t final = address + count;
//if(address < 0x2040000 && final > 0x2040000) {
// remotePutPacket("E01");
@ -3947,7 +3947,7 @@ void remoteReadRegister(char* p)
sscanf(p, "%x", &r);
char buffer[1024];
char* s = buffer;
u32 v = reg[r].I;
uint32_t v = reg[r].I;
sprintf(s, "%02x%02x%02x%02x", v & 255, (v >> 8) & 255,
(v >> 16) & 255, (v >> 24) & 255);
remotePutPacket(buffer);
@ -3961,13 +3961,13 @@ void remoteReadRegisters(char* p)
int i;
// regular registers
for (i = 0; i < 15; i++) {
u32 v = reg[i].I;
uint32_t v = reg[i].I;
sprintf(s, "%02x%02x%02x%02x", v & 255, (v >> 8) & 255,
(v >> 16) & 255, (v >> 24) & 255);
s += 8;
}
// PC
u32 pc = armNextPC;
uint32_t pc = armNextPC;
sprintf(s, "%02x%02x%02x%02x", pc & 255, (pc >> 8) & 255,
(pc >> 16) & 255, (pc >> 24) & 255);
s += 8;
@ -3983,7 +3983,7 @@ void remoteReadRegisters(char* p)
s += 8;
// CPSR
CPUUpdateCPSR();
u32 v = reg[16].I;
uint32_t v = reg[16].I;
sprintf(s, "%02x%02x%02x%02x", v & 255, (v >> 8) & 255,
(v >> 16) & 255, (v >> 24) & 255);
s += 8;
@ -4002,14 +4002,14 @@ void remoteWriteRegister(char* p)
char c = *p++;
u32 v = 0;
uint32_t v = 0;
u8 data[4] = { 0, 0, 0, 0 };
uint8_t data[4] = { 0, 0, 0, 0 };
int i = 0;
while (i < 4) {
u8 b = 0;
uint8_t b = 0;
if (c <= '9')
b = (c - '0') << 4;
else
@ -4224,7 +4224,7 @@ std::string HexToString(char* p)
std::string hex(p);
std::string cmd;
std::stringstream ss;
u32 offset = 0;
uint32_t offset = 0;
while (offset < hex.length()) {
unsigned int buffer = 0;
ss.clear();
@ -4240,7 +4240,7 @@ std::string StringToHex(std::string& cmd)
{
std::stringstream ss;
ss << std::hex;
for (u32 i = 0; i < cmd.length(); ++i)
for (uint32_t i = 0; i < cmd.length(); ++i)
ss << std::setw(2) << std::setfill('0') << (int)cmd.c_str()[i];
return ss.str();
}

View File

@ -1,79 +1,78 @@
#ifndef REMOTE_H
#define REMOTE_H
#include "../common/Types.h"
#include "GBA.h"
#define BitSet(array, bit) ((u8*)(array))[(bit) >> 3] |= (1 << ((bit)&7))
#define BitSet(array, bit) ((uint8_t*)(array))[(bit) >> 3] |= (1 << ((bit)&7))
#define BitClear(array, bit) ((u8*)(array))[(bit) >> 3] &= ~(1 << ((bit)&7))
#define BitClear(array, bit) ((uint8_t*)(array))[(bit) >> 3] &= ~(1 << ((bit)&7))
#define BitGet(array, bit) ((u8)((array)[(bit) >> 3]) & (u8)(1 << ((bit)&7)))
#define BitGet(array, bit) ((uint8_t)((array)[(bit) >> 3]) & (uint8_t)(1 << ((bit)&7)))
#define BreakSet(array, addr, flag) \
((u8*)(array))[(addr) >> 1] |= ((addr & 1) ? (flag << 4) : (flag & 0xf))
((uint8_t*)(array))[(addr) >> 1] |= ((addr & 1) ? (flag << 4) : (flag & 0xf))
#define BreakClear(array, addr, flag) \
((u8*)(array))[(addr) >> 1] &= ~((addr & 1) ? (flag << 4) : (flag & 0xf))
((uint8_t*)(array))[(addr) >> 1] &= ~((addr & 1) ? (flag << 4) : (flag & 0xf))
// check
#define BreakThumbCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x80 : 0x8)
#define BreakThumbCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x80 : 0x8)
#define BreakARMCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x40 : 0x4)
#define BreakARMCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x40 : 0x4)
#define BreakReadCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x20 : 0x2)
#define BreakReadCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x20 : 0x2)
#define BreakWriteCheck(array, addr) ((u8*)(array))[(addr) >> 1] & ((addr & 1) ? 0x10 : 0x1)
#define BreakWriteCheck(array, addr) ((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? 0x10 : 0x1)
#define BreakCheck(array, addr, flag) \
((u8*)(array))[(addr) >> 1] & ((addr & 1) ? (flag << 4) : (flag & 0xf))
((uint8_t*)(array))[(addr) >> 1] & ((addr & 1) ? (flag << 4) : (flag & 0xf))
extern bool debugger;
extern bool dexp_eval(char*, u32*);
extern void dexp_setVar(char*, u32);
extern bool dexp_eval(char*, uint32_t*);
extern void dexp_setVar(char*, uint32_t);
extern void dexp_listVars();
extern void dexp_saveVars(char*);
extern void dexp_loadVars(char*);
void debuggerOutput(const char* s, u32 addr);
void debuggerOutput(const char* s, uint32_t addr);
bool debuggerBreakOnExecution(u32 address, u8 state);
bool debuggerBreakOnWrite(u32 address, u32 value, int size);
void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value, int size, int t);
bool debuggerBreakOnRead(u32 address, int size);
bool debuggerBreakOnExecution(uint32_t address, uint8_t state);
bool debuggerBreakOnWrite(uint32_t address, uint32_t value, int size);
void debuggerBreakOnWrite(uint32_t address, uint32_t oldvalue, uint32_t value, int size, int t);
bool debuggerBreakOnRead(uint32_t address, int size);
struct regBreak {
// u8 regNum; /No longer needed
// uint8_t regNum; /No longer needed
// bit 0 = equal
// bit 1 = greater
// bit 2 = smaller
// bit 3 = signed
u8 flags;
u32 intVal;
uint8_t flags;
uint32_t intVal;
struct regBreak* next;
};
extern u8 lowRegBreakCounter[4]; //(r0-r3)
extern u8 medRegBreakCounter[4]; //(r4-r7)
extern u8 highRegBreakCounter[4]; //(r8-r11)
extern u8 statusRegBreakCounter[4]; //(r12-r15)
extern uint8_t lowRegBreakCounter[4]; //(r0-r3)
extern uint8_t medRegBreakCounter[4]; //(r4-r7)
extern uint8_t highRegBreakCounter[4]; //(r8-r11)
extern uint8_t statusRegBreakCounter[4]; //(r12-r15)
extern bool enableRegBreak;
extern regBreak* breakRegList[16];
extern void breakReg_check(int i);
struct regBreak* getFromBreakRegList(u8 regnum, int location);
struct regBreak* getFromBreakRegList(uint8_t regnum, int location);
void clearBreakRegList();
void clearParticularRegListBreaks(int reg);
void deleteFromBreakRegList(u8 regnum, int location);
void deleteFromBreakRegList(uint8_t regnum, int location);
void addBreakRegToList(u8 regnum, u8 flags, u32 value);
void addBreakRegToList(uint8_t regnum, uint8_t flags, uint32_t value);
void printBreakRegList(bool verbose);
void remoteStubMain();
void remoteStubSignal(int sig, int number);
void remoteOutput(const char* s, u32 addr);
void remoteOutput(const char* s, uint32_t addr);
void remoteSetProtocol(int p);
void remoteSetPort(int port);

View File

@ -19,34 +19,34 @@
#include "filters.h"
#include "intl.h"
void _2xSaI(u8*, u32, u8*, u8*, u32, int, int);
void _2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
void Super2xSaI(u8*, u32, u8*, u8*, u32, int, int);
void Super2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
void SuperEagle(u8*, u32, u8*, u8*, u32, int, int);
void SuperEagle32(u8*, u32, u8*, u8*, u32, int, int);
void Pixelate(u8*, u32, u8*, u8*, u32, int, int);
void Pixelate32(u8*, u32, u8*, u8*, u32, int, int);
void AdMame2x(u8*, u32, u8*, u8*, u32, int, int);
void AdMame2x32(u8*, u32, u8*, u8*, u32, int, int);
void Bilinear(u8*, u32, u8*, u8*, u32, int, int);
void Bilinear32(u8*, u32, u8*, u8*, u32, int, int);
void BilinearPlus(u8*, u32, u8*, u8*, u32, int, int);
void BilinearPlus32(u8*, u32, u8*, u8*, u32, int, int);
void Scanlines(u8*, u32, u8*, u8*, u32, int, int);
void Scanlines32(u8*, u32, u8*, u8*, u32, int, int);
void ScanlinesTV(u8*, u32, u8*, u8*, u32, int, int);
void ScanlinesTV32(u8*, u32, u8*, u8*, u32, int, int);
void hq2x(u8*, u32, u8*, u8*, u32, int, int);
void hq2x32(u8*, u32, u8*, u8*, u32, int, int);
void lq2x(u8*, u32, u8*, u8*, u32, int, int);
void lq2x32(u8*, u32, u8*, u8*, u32, int, int);
void xbrz2x32(u8*, u32, u8*, u8*, u32, int, int);
void _2xSaI(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void _2xSaI32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Super2xSaI(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Super2xSaI32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void SuperEagle(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void SuperEagle32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Pixelate(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Pixelate32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void AdMame2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void AdMame2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Bilinear(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Bilinear32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void BilinearPlus(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void BilinearPlus32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Scanlines(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void Scanlines32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void ScanlinesTV(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void ScanlinesTV32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void hq2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void hq2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void lq2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void lq2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void xbrz2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
void SmartIB(u8*, u32, int, int);
void SmartIB32(u8*, u32, int, int);
void MotionBlurIB(u8*, u32, int, int);
void MotionBlurIB32(u8*, u32, int, int);
void SmartIB(uint8_t*, uint32_t, int, int);
void SmartIB32(uint8_t*, uint32_t, int, int);
void MotionBlurIB(uint8_t*, uint32_t, int, int);
void MotionBlurIB32(uint8_t*, uint32_t, int, int);
namespace VBA {

View File

@ -22,11 +22,11 @@
#include "../System.h"
int Init_2xSaI(u32);
int Init_2xSaI(uint32_t);
namespace VBA {
typedef void (*Filter)(u8*, u32, u8*, u8*, u32, int, int);
typedef void (*FilterIB)(u8*, u32, int, int);
typedef void (*Filter)(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
typedef void (*FilterIB)(uint8_t*, uint32_t, int, int);
enum EFilter {
FirstFilter,

View File

@ -33,7 +33,7 @@ ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale)
vUpdateSize();
}
void ScreenAreaCairo::vDrawPixels(u8* _puiData)
void ScreenAreaCairo::vDrawPixels(uint8_t* _puiData)
{
ScreenArea::vDrawPixels(_puiData);
@ -48,14 +48,14 @@ bool ScreenAreaCairo::on_expose_event(GdkEventExpose* _pstEvent)
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::RefPtr<Cairo::Context> poContext;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(uint32_t);
poContext = get_window()->create_cairo_context();
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
poImage = Cairo::ImageSurface::create((uint8_t*)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
@ -77,12 +77,12 @@ bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context>& poContext)
Cairo::RefPtr<Cairo::ImageSurface> poImage;
Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::Matrix oMatrix;
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(uint32_t);
//poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor);
poImage = Cairo::ImageSurface::create((u8*)m_puiPixels, Cairo::FORMAT_RGB24,
poImage = Cairo::ImageSurface::create((uint8_t*)m_puiPixels, Cairo::FORMAT_RGB24,
m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop);
@ -102,7 +102,7 @@ bool ScreenAreaCairo::on_draw(const Cairo::RefPtr<Cairo::Context>& poContext)
void ScreenAreaCairo::vDrawBlackScreen()
{
if (m_puiPixels && get_realized()) {
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(uint32_t));
queue_draw_area(0, 0, get_width(), get_height());
}
}

View File

@ -26,7 +26,7 @@ namespace VBA {
class ScreenAreaCairo : public ScreenArea {
public:
ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8* _puiData);
void vDrawPixels(uint8_t* _puiData);
void vDrawBlackScreen();
protected:

View File

@ -101,7 +101,7 @@ void ScreenAreaGl::on_realize()
glwindow->gl_end();
}
void ScreenAreaGl::vDrawPixels(u8* _puiData)
void ScreenAreaGl::vDrawPixels(uint8_t* _puiData)
{
ScreenArea::vDrawPixels(_puiData);
@ -111,7 +111,7 @@ void ScreenAreaGl::vDrawPixels(u8* _puiData)
void ScreenAreaGl::vDrawBlackScreen()
{
if (m_puiPixels && get_realized()) {
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(u32));
memset(m_puiPixels, 0, m_iHeight * (m_iWidth + 1) * sizeof(uint32_t));
queue_draw_area(0, 0, get_width(), get_height());
}
}

View File

@ -27,7 +27,7 @@ namespace VBA {
class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl> {
public:
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8* _puiData);
void vDrawPixels(uint8_t* _puiData);
void vDrawBlackScreen();
protected:

View File

@ -173,10 +173,10 @@ bool ScreenArea::bOnCursorTimeout()
return false;
}
void ScreenArea::vDrawPixels(u8* _puiData)
void ScreenArea::vDrawPixels(uint8_t* _puiData)
{
const int iSrcPitch = (m_iWidth + 1) * sizeof(u32);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(u32);
const int iSrcPitch = (m_iWidth + 1) * sizeof(uint32_t);
const int iScaledPitch = (m_iScaledWidth + 1) * sizeof(uint32_t);
if (m_vFilterIB != NULL) {
m_vFilterIB(_puiData + iSrcPitch,
@ -189,7 +189,7 @@ void ScreenArea::vDrawPixels(u8* _puiData)
m_vFilter2x(_puiData + iSrcPitch,
iSrcPitch,
m_puiDelta,
(u8*)m_puiPixels,
(uint8_t*)m_puiPixels,
iScaledPitch,
m_iWidth,
m_iHeight);
@ -211,10 +211,10 @@ void ScreenArea::vUpdateSize()
m_iScaledWidth = m_iFilterScale * m_iWidth;
m_iScaledHeight = m_iFilterScale * m_iHeight;
m_puiPixels = new u32[(m_iScaledWidth + 1) * m_iScaledHeight];
m_puiDelta = new u8[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32)];
memset(m_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(u32));
memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * sizeof(u32));
m_puiPixels = new uint32_t[(m_iScaledWidth + 1) * m_iScaledHeight];
m_puiDelta = new uint8_t[(m_iWidth + 2) * (m_iHeight + 2) * sizeof(uint32_t)];
memset(m_puiPixels, 0, (m_iScaledWidth + 1) * m_iScaledHeight * sizeof(uint32_t));
memset(m_puiDelta, 255, (m_iWidth + 2) * (m_iHeight + 2) * sizeof(uint32_t));
vOnSizeUpdated();

View File

@ -36,7 +36,7 @@ public:
void vSetFilter(EFilter _eFilter);
void vSetFilterIB(EFilterIB _eFilterIB);
void vSetEnableRender(bool _bEnable);
virtual void vDrawPixels(u8* _puiData);
virtual void vDrawPixels(uint8_t* _puiData);
virtual void vDrawBlackScreen() = 0;
protected:
@ -57,8 +57,8 @@ protected:
int m_iAreaHeight;
Filter m_vFilter2x;
FilterIB m_vFilterIB;
u32* m_puiPixels;
u8* m_puiDelta;
uint32_t* m_puiPixels;
uint8_t* m_puiDelta;
int m_iScaledWidth;
int m_iScaledHeight;
bool m_bEnableRender;

View File

@ -32,9 +32,9 @@ int systemColorDepth;
int systemVerbose;
int systemSaveUpdateCounter;
int systemFrameSkip;
u32 systemColorMap32[0x10000];
u16 systemColorMap16[0x10000];
u16 systemGbPalette[24];
uint32_t systemColorMap32[0x10000];
uint16_t systemColorMap16[0x10000];
uint16_t systemGbPalette[24];
int emulating;
int RGB_LOW_BITS_MASK;
@ -66,7 +66,7 @@ bool systemReadJoypads()
return true;
}
u32 systemReadJoypad(int joy)
uint32_t systemReadJoypad(int joy)
{
return inputReadJoypad(joy);
}
@ -99,7 +99,7 @@ void systemScreenCapture(int _iNum)
->vCaptureScreen(_iNum);
}
u32 systemGetClock()
uint32_t systemGetClock()
{
Glib::TimeVal time;
time.assign_current_time();
@ -110,7 +110,7 @@ void systemUpdateMotionSensor()
{
}
u8 systemGetSensorDarkness()
uint8_t systemGetSensorDarkness()
{
return 0xE8;
}
@ -134,7 +134,7 @@ void systemCartridgeRumble(bool)
{
}
void systemGbPrint(u8* _puiData,
void systemGbPrint(uint8_t* _puiData,
int _iLen,
int _iPages,
int _iFeed,
@ -172,7 +172,7 @@ void systemOnSoundShutdown()
{
}
void systemOnWriteDataToSoundBuffer(const u16* finalWave, int length)
void systemOnWriteDataToSoundBuffer(const uint16_t* finalWave, int length)
{
}

View File

@ -51,8 +51,8 @@
extern int RGB_LOW_BITS_MASK;
static const u16 STATE_MAX_DEFAULT = 180u;
static const u16 STATE_INTERVAL_DEFAULT = 165u;
static const uint16_t STATE_MAX_DEFAULT = 180u;
static const uint16_t STATE_INTERVAL_DEFAULT = 165u;
namespace VBA {

View File

@ -241,9 +241,9 @@ private:
EShowSpeed m_eShowSpeed;
/* State saving into memory & rewind to saved state */
u16 m_state_count_max;
u16 m_rewind_interval;
static const u32 SZSTATE = 1024 * 512;
uint16_t m_state_count_max;
uint16_t m_rewind_interval;
static const uint32_t SZSTATE = 1024 * 512;
std::deque<char*> m_rewind_load_q;
char* m_psavestate;

View File

@ -24,7 +24,7 @@ SoundRetro::SoundRetro()
{
}
void SoundRetro::write(u16* finalWave, int length)
void SoundRetro::write(uint16_t* finalWave, int length)
{
const int16_t* wave = (const int16_t*)finalWave;
int frames = length >> 1;

View File

@ -29,7 +29,7 @@ public:
virtual void pause();
virtual void reset();
virtual void resume();
virtual void write(u16* finalWave, int length);
virtual void write(uint16_t* finalWave, int length);
};
#endif // __VBA_SOUND_RETRO_H__

View File

@ -32,7 +32,7 @@ bool utilWritePNGFile(const char* fileName, int w, int h, uint8_t* pix)
return false;
}
void utilPutDword(u8* p, u32 value)
void utilPutDword(uint8_t* p, uint32_t value)
{
*p++ = value & 255;
*p++ = (value >> 8) & 255;

View File

@ -1,3 +1,4 @@
#include <cstdint>
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
@ -13,7 +14,6 @@
#include "../apu/Gb_Apu.h"
#include "../apu/Gb_Oscs.h"
#include "../common/Port.h"
#include "../common/Types.h"
#include "../gba/Cheats.h"
#include "../gba/EEprom.h"
#include "../gba/Flash.h"
@ -47,9 +47,9 @@ static unsigned libretro_save_size = sizeof(libretro_save_buf);
int RGB_LOW_BITS_MASK = 0;
u16 systemColorMap16[0x10000];
u32 systemColorMap32[0x10000];
u16 systemGbPalette[24];
uint16_t systemColorMap16[0x10000];
uint32_t systemColorMap32[0x10000];
uint16_t systemGbPalette[24];
int systemRedShift = 0;
int systemBlueShift = 0;
int systemGreenShift = 0;
@ -61,9 +61,9 @@ int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED;
int systemSpeed = 0;
u64 startTime = 0;
u32 renderedFrames = 0;
uint32_t renderedFrames = 0;
void (*dbgOutput)(const char* s, u32 addr);
void (*dbgOutput)(const char* s, uint32_t addr);
void (*dbgSignal)(int sig, int number);
void* retro_get_memory_data(unsigned id)
@ -686,7 +686,7 @@ unsigned retro_get_region(void)
return RETRO_REGION_NTSC;
}
void systemOnWriteDataToSoundBuffer(const u16* finalWave, int length)
void systemOnWriteDataToSoundBuffer(const uint16_t* finalWave, int length)
{
}
@ -747,12 +747,12 @@ int systemGetSensorZ(void)
return 0;
}
u32 systemReadJoypad(int which)
uint32_t systemReadJoypad(int which)
{
if (which == -1)
which = 0;
u32 J = 0;
uint32_t J = 0;
for (unsigned i = 0; i < 10; i++) {
if (controller_layout[0] == 1)
@ -771,14 +771,14 @@ u32 systemReadJoypad(int which)
bool systemReadJoypads() { return true; }
void systemUpdateMotionSensor() {}
u8 systemGetSensorDarkness() {}
uint8_t systemGetSensorDarkness() {}
void systemCartridgeRumble(bool)
{
}
bool systemPauseOnFrame() { return false; }
void systemGbPrint(u8* data, int pages, int feed, int palette, int contrast) {}
void systemGbPrint(uint8_t* data, int pages, int feed, int palette, int contrast) {}
void systemScreenCapture(int a) {}
void systemScreenMessage(const char* msg)
{
@ -790,7 +790,7 @@ void systemSetTitle(const char* title) {}
void systemShowSpeed(int speed) {}
void system10Frames(int rate) {}
u32 systemGetClock()
uint32_t systemGetClock()
{
return 0;
}

View File

@ -90,7 +90,7 @@ extern void remoteInit();
extern void remoteCleanUp();
extern void remoteStubMain();
extern void remoteStubSignal(int, int);
extern void remoteOutput(const char*, u32);
extern void remoteOutput(const char*, uint32_t);
extern void remoteSetProtocol(int);
extern void remoteSetPort(int);
@ -132,7 +132,7 @@ int destHeight = 0;
int desktopWidth = 0;
int desktopHeight = 0;
u8* delta = NULL;
uint8_t* delta = NULL;
static const int delta_size = 322 * 242 * 4;
int filter_enlarge = 2;
@ -141,13 +141,13 @@ int cartridgeType = 3;
int textureSize = 256;
GLuint screenTexture = 0;
u8* filterPix = 0;
uint8_t* filterPix = 0;
int emulating = 0;
int RGB_LOW_BITS_MASK = 0x821;
u32 systemColorMap32[0x10000];
u16 systemColorMap16[0x10000];
u16 systemGbPalette[24];
uint32_t systemColorMap32[0x10000];
uint16_t systemColorMap16[0x10000];
uint16_t systemGbPalette[24];
char filename[2048];
@ -190,7 +190,7 @@ enum VIDEO_SIZE {
#define _stricmp strcasecmp
u32 throttleLastTime = 0;
uint32_t throttleLastTime = 0;
bool pauseNextFrame = false;
int sdlMirroringEnable = 1;
@ -203,7 +203,7 @@ void systemConsoleMessage(const char*);
char* home;
char screenMessageBuffer[21];
u32 screenMessageTime = 0;
uint32_t screenMessageTime = 0;
#define SOUND_MAX_VOLUME 2.0
#define SOUND_ECHO 0.2
@ -627,7 +627,7 @@ static void sdlApplyPerImagePreferences()
fclose(f);
}
static int sdlCalculateShift(u32 mask)
static int sdlCalculateShift(uint32_t mask)
{
int m = 0;
@ -795,7 +795,7 @@ static void sdlResizeVideo()
if (openGL) {
free(filterPix);
filterPix = (u8*)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight);
filterPix = (uint8_t*)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight);
sdlOpenGLVideoResize();
}
@ -856,7 +856,7 @@ void sdlInitVideo()
exit(-1);
}
u32 rmask, gmask, bmask;
uint32_t rmask, gmask, bmask;
#if 0
if(openGL) {
@ -947,7 +947,7 @@ void sdlInitVideo()
int scaledHeight = screenHeight * sdlOpenglScale;
free(filterPix);
filterPix = (u8 *)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight);
filterPix = (uint8_t *)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight);
sdlOpenGLInit(screenWidth, screenHeight);
if ( (!fullScreen)
@ -1833,15 +1833,15 @@ int main(int argc, char** argv)
soundInit();
cartridgeType = 0;
strcpy(filename, "gnu_stub");
rom = (u8*)malloc(0x2000000);
workRAM = (u8*)calloc(1, 0x40000);
bios = (u8*)calloc(1, 0x4000);
internalRAM = (u8*)calloc(1, 0x8000);
paletteRAM = (u8*)calloc(1, 0x400);
vram = (u8*)calloc(1, 0x20000);
oam = (u8*)calloc(1, 0x400);
pix = (u8*)calloc(1, 4 * 241 * 162);
ioMem = (u8*)calloc(1, 0x400);
rom = (uint8_t*)malloc(0x2000000);
workRAM = (uint8_t*)calloc(1, 0x40000);
bios = (uint8_t*)calloc(1, 0x4000);
internalRAM = (uint8_t*)calloc(1, 0x8000);
paletteRAM = (uint8_t*)calloc(1, 0x400);
vram = (uint8_t*)calloc(1, 0x20000);
oam = (uint8_t*)calloc(1, 0x400);
pix = (uint8_t*)calloc(1, 4 * 241 * 162);
ioMem = (uint8_t*)calloc(1, 0x400);
emulator = GBASystem;
@ -1917,7 +1917,7 @@ int main(int argc, char** argv)
utilUpdateSystemColorMaps();
if (delta == NULL) {
delta = (u8*)malloc(delta_size);
delta = (uint8_t*)malloc(delta_size);
memset(delta, 255, delta_size);
}
@ -2025,7 +2025,7 @@ void systemMessage(int num, const char* msg, ...)
va_end(valist);
}
void drawScreenMessage(u8* screen, int pitch, int x, int y, unsigned int duration)
void drawScreenMessage(uint8_t* screen, int pitch, int x, int y, unsigned int duration)
{
if (screenMessage) {
if (cartridgeType == 1 && gbBorderOn) {
@ -2040,7 +2040,7 @@ void drawScreenMessage(u8* screen, int pitch, int x, int y, unsigned int duratio
}
}
void drawSpeed(u8* screen, int pitch, int x, int y)
void drawSpeed(uint8_t* screen, int pitch, int x, int y)
{
char buffer[50];
if (showSpeed == 1)
@ -2056,14 +2056,14 @@ void drawSpeed(u8* screen, int pitch, int x, int y)
void systemDrawScreen()
{
unsigned int destPitch = destWidth * (systemColorDepth >> 3);
u8* screen;
uint8_t* screen;
renderedFrames++;
if (openGL)
screen = filterPix;
else {
screen = (u8*)surface->pixels;
screen = (uint8_t*)surface->pixels;
SDL_LockSurface(surface);
}
@ -2077,7 +2077,7 @@ void systemDrawScreen()
int bytes = (systemColorDepth >> 3);
for (int i = 0; i < destWidth; i++)
for (int j = 0; j < destHeight; j++) {
u8 k;
uint8_t k;
k = filterPix[i * bytes + j * destPitch + 3];
filterPix[i * bytes + j * destPitch + 3] = filterPix[i * bytes + j * destPitch + 1];
filterPix[i * bytes + j * destPitch + 1] = k;
@ -2151,9 +2151,9 @@ void systemFrame()
void system10Frames(int rate)
{
u32 time = systemGetClock();
uint32_t time = systemGetClock();
if (!wasPaused && autoFrameSkip) {
u32 diff = time - autoFrameSkipLastTime;
uint32_t diff = time - autoFrameSkipLastTime;
int speed = 100;
if (diff)
@ -2234,12 +2234,12 @@ void systemLoadRecent()
// I need to be implemented
}
u32 systemGetClock()
uint32_t systemGetClock()
{
return SDL_GetTicks();
}
void systemGbPrint(u8* data, int len, int pages, int feed, int palette, int contrast)
void systemGbPrint(uint8_t* data, int len, int pages, int feed, int palette, int contrast)
{
}
@ -2310,11 +2310,11 @@ bool systemReadJoypads()
return true;
}
u32 systemReadJoypad(int which)
uint32_t systemReadJoypad(int which)
{
return inputReadJoypad(which);
}
//static u8 sensorDarkness = 0xE8; // total darkness (including daylight on rainy days)
//static uint8_t sensorDarkness = 0xE8; // total darkness (including daylight on rainy days)
void systemUpdateSolarSensor()
{
@ -2345,7 +2345,7 @@ int systemGetSensorZ()
return 0;
}
u8 systemGetSensorDarkness()
uint8_t systemGetSensorDarkness()
{
return 0xE8;
}
@ -2361,7 +2361,7 @@ void systemOnSoundShutdown()
{
}
void systemOnWriteDataToSoundBuffer(const u16* finalWave, int length)
void systemOnWriteDataToSoundBuffer(const uint16_t* finalWave, int length)
{
}

View File

@ -56,13 +56,13 @@ extern struct EmulatedSystem emulator;
map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
struct breakpointInfo {
u32 address;
u32 value;
uint32_t address;
uint32_t value;
int size;
u32 cond_address;
uint32_t cond_address;
char cond_rel;
u32 cond_value;
uint32_t cond_value;
int cond_size;
bool ia1;
bool ia2;
@ -77,13 +77,13 @@ struct DebuggerCommand {
unsigned int SearchStart = 0xFFFFFFFF;
unsigned int SearchMaxMatches = 5;
u8 SearchData[64]; // It doesn't make much sense to search for more than 64 bytes
uint8_t SearchData[64]; // It doesn't make much sense to search for more than 64 bytes
unsigned int SearchLength = 0;
unsigned int SearchResults;
static void debuggerContinueAfterBreakpoint();
void debuggerDoSearch();
unsigned int AddressToGBA(u8* mem);
unsigned int AddressToGBA(uint8_t* mem);
static void debuggerHelp(int, char**);
static void debuggerNext(int, char**);
@ -199,7 +199,7 @@ bool debuggerAtBreakpoint = false;
int debuggerBreakpointNumber = 0;
int debuggerRadix = 0;
extern u32 cpuPrefetch[2];
extern uint32_t cpuPrefetch[2];
#define ARM_PREFETCH \
{ \
@ -222,13 +222,13 @@ static void debuggerPrefetch()
}
}
static void debuggerApplyBreakpoint(u32 address, int num, int size)
static void debuggerApplyBreakpoint(uint32_t address, int num, int size)
{
if (size)
debuggerWriteMemory(address, (u32)(0xe1200070 | (num & 0xf) | ((num << 4) & 0xf0)));
debuggerWriteMemory(address, (uint32_t)(0xe1200070 | (num & 0xf) | ((num << 4) & 0xf0)));
else
debuggerWriteHalfWord(address,
(u16)(0xbe00 | num));
(uint16_t)(0xbe00 | num));
}
static void debuggerDisableBreakpoints()
@ -273,7 +273,7 @@ static void debuggerUsage(const char* cmd)
}
}
static void debuggerPrintBaseType(Type* t, u32 value, u32 location,
static void debuggerPrintBaseType(Type* t, uint32_t value, uint32_t location,
LocationType type,
int bitSize, int bitOffset)
{
@ -387,12 +387,12 @@ static const char* debuggerPrintType(Type* t)
return t->name;
}
static void debuggerPrintValueInternal(Function*, Type*, ELFBlock*, int, int, u32);
static void debuggerPrintValueInternal(Function*, Type*, ELFBlock*, int, int, uint32_t);
static void debuggerPrintValueInternal(Function* f, Type* t,
int bitSize, int bitOffset,
u32 objLocation, LocationType type);
uint32_t objLocation, LocationType type);
static u32 debuggerGetValue(u32 location, LocationType type)
static uint32_t debuggerGetValue(uint32_t location, LocationType type)
{
switch (type) {
case LOCATION_memory:
@ -405,22 +405,22 @@ static u32 debuggerGetValue(u32 location, LocationType type)
return 0;
}
static void debuggerPrintPointer(Type* t, u32 value)
static void debuggerPrintPointer(Type* t, uint32_t value)
{
printf("(%s)0x%08x", debuggerPrintType(t), value);
}
static void debuggerPrintReference(Type* t, u32 value)
static void debuggerPrintReference(Type* t, uint32_t value)
{
printf("(%s)0x%08x", debuggerPrintType(t), value);
}
static void debuggerPrintFunction(Type* t, u32 value)
static void debuggerPrintFunction(Type* t, uint32_t value)
{
printf("(%s)0x%08x", debuggerPrintType(t), value);
}
static void debuggerPrintArray(Type* t, u32 value)
static void debuggerPrintArray(Type* t, uint32_t value)
{
// todo
printf("(%s[])0x%08x", debuggerPrintType(t->array->type), value);
@ -428,15 +428,15 @@ static void debuggerPrintArray(Type* t, u32 value)
static void debuggerPrintMember(Function* f,
Member* m,
u32 objLocation,
u32 location)
uint32_t objLocation,
uint32_t location)
{
int bitSize = m->bitSize;
if (bitSize) {
u32 value = 0;
uint32_t value = 0;
int off = m->bitOffset;
int size = m->byteSize;
u32 v = 0;
uint32_t v = 0;
switch (size) {
case 1:
v = debuggerReadByte(location);
@ -482,7 +482,7 @@ static void debuggerPrintMember(Function* f,
}
}
static void debuggerPrintStructure(Function* f, Type* t, u32 objLocation)
static void debuggerPrintStructure(Function* f, Type* t, uint32_t objLocation)
{
printf("{");
int count = t->structure->memberCount;
@ -491,7 +491,7 @@ static void debuggerPrintStructure(Function* f, Type* t, u32 objLocation)
Member* m = &t->structure->members[i];
printf("%s=", m->name);
LocationType type;
u32 location = elfDecodeLocation(f, m->location, &type, objLocation);
uint32_t location = elfDecodeLocation(f, m->location, &type, objLocation);
debuggerPrintMember(f, m, objLocation, location);
i++;
if (i < count)
@ -500,7 +500,7 @@ static void debuggerPrintStructure(Function* f, Type* t, u32 objLocation)
printf("}");
}
static void debuggerPrintUnion(Function* f, Type* t, u32 objLocation)
static void debuggerPrintUnion(Function* f, Type* t, uint32_t objLocation)
{
// todo
printf("{");
@ -517,7 +517,7 @@ static void debuggerPrintUnion(Function* f, Type* t, u32 objLocation)
printf("}");
}
static void debuggerPrintEnum(Type* t, u32 value)
static void debuggerPrintEnum(Type* t, uint32_t value)
{
int i;
for (i = 0; i < t->enumeration->count; i++) {
@ -532,9 +532,9 @@ static void debuggerPrintEnum(Type* t, u32 value)
static void debuggerPrintValueInternal(Function* f, Type* t,
int bitSize, int bitOffset,
u32 objLocation, LocationType type)
uint32_t objLocation, LocationType type)
{
u32 value = debuggerGetValue(objLocation, type);
uint32_t value = debuggerGetValue(objLocation, type);
if (!t) {
printf("void");
return;
@ -572,10 +572,10 @@ static void debuggerPrintValueInternal(Function* f, Type* t,
static void debuggerPrintValueInternal(Function* f, Type* t, ELFBlock* loc,
int bitSize, int bitOffset,
u32 objLocation)
uint32_t objLocation)
{
LocationType type;
u32 location;
uint32_t location;
if (loc) {
if (objLocation)
location = elfDecodeLocation(f, loc, &type, objLocation);
@ -599,8 +599,8 @@ static void debuggerPrintValue(Function* f, Object* o)
static void debuggerSymbols(int argc, char** argv)
{
int i = 0;
u32 value;
u32 size;
uint32_t value;
uint32_t size;
int type;
bool match = false;
int matchSize = 0;
@ -674,7 +674,7 @@ static void debuggerPrint(int argc, char** argv)
if (argc != 2 && argc != 3) {
debuggerUsage(argv[0]);
} else {
u32 pc = armNextPC;
uint32_t pc = armNextPC;
Function* f = NULL;
CompileUnit* u = NULL;
@ -780,7 +780,7 @@ static void debuggerVerbose(int n, char** args)
static void debuggerWhere(int n, char** args)
{
void elfPrintCallChain(u32);
void elfPrintCallChain(uint32_t);
elfPrintCallChain(armNextPC);
}
@ -788,7 +788,7 @@ static void debuggerLocals(int n, char** args)
{
Function* f = NULL;
CompileUnit* u = NULL;
u32 pc = armNextPC;
uint32_t pc = armNextPC;
if (elfGetCurrentFunction(pc,
&f, &u)) {
Object* o = f->parameters;
@ -832,7 +832,7 @@ static void debuggerNext(int n, char** args)
debuggerDisableBreakpoints();
Function* f = NULL;
CompileUnit* u = NULL;
u32 a = armNextPC;
uint32_t a = armNextPC;
if (elfGetCurrentFunction(a, &f, &u)) {
const char* file;
int line = elfFindLine(u, f, a, &file);
@ -927,8 +927,8 @@ static void debuggerBreakDelete(int n, char** args)
static void debuggerBreak(int n, char** args)
{
if (n == 2) {
u32 address = 0;
u32 value = 0;
uint32_t address = 0;
uint32_t value = 0;
int type = 0;
const char* s = args[1];
char c = *s;
@ -938,13 +938,13 @@ static void debuggerBreak(int n, char** args)
*l++ = 0;
int line = atoi(l);
u32 addr;
uint32_t addr;
Function* f;
CompileUnit* u;
if (elfFindLineInModule(&addr, name, line)) {
if (elfGetCurrentFunction(addr, &f, &u)) {
u32 addr2;
uint32_t addr2;
if (elfGetSymbolAddress(f->name, &addr2, &value, &type)) {
address = addr;
} else {
@ -963,12 +963,12 @@ static void debuggerBreak(int n, char** args)
int line = atoi(s);
Function* f;
CompileUnit* u;
u32 addr;
uint32_t addr;
if (elfGetCurrentFunction(armNextPC, &f, &u)) {
if (elfFindLineInUnit(&addr, u, line)) {
if (elfGetCurrentFunction(addr, &f, &u)) {
u32 addr2;
uint32_t addr2;
if (elfGetSymbolAddress(f->name, &addr2, &value, &type)) {
address = addr;
} else {
@ -1017,7 +1017,7 @@ static void debuggerBreak(int n, char** args)
static void debuggerBreakThumb(int n, char** args)
{
if (n == 2) {
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
int i = debuggerNumOfBreakpoints;
debuggerBreakpointList[i].address = address;
@ -1033,7 +1033,7 @@ static void debuggerBreakThumb(int n, char** args)
static void debuggerBreakArm(int n, char** args)
{
if (n == 2) {
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
int i = debuggerNumOfBreakpoints;
debuggerBreakpointList[i].address = address;
@ -1049,7 +1049,7 @@ static void debuggerBreakArm(int n, char** args)
static void debuggerBreakWriteClear(int n, char** args)
{
if (n == 3) {
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
int n = 0;
sscanf(args[2], "%d", &n);
@ -1059,12 +1059,12 @@ static void debuggerBreakWriteClear(int n, char** args)
return;
}
u32 final = address + n;
uint32_t final = address + n;
switch (address >> 24) {
case 2: {
address &= 0x3ffff;
final &= 0x3ffff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeWorkRAM[i] == 1)
freezeWorkRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n",
@ -1073,7 +1073,7 @@ static void debuggerBreakWriteClear(int n, char** args)
case 3: {
address &= 0x7fff;
final &= 0x7fff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeInternalRAM[i] == 1)
freezeInternalRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n",
@ -1082,7 +1082,7 @@ static void debuggerBreakWriteClear(int n, char** args)
case 5: {
address &= 0x3ff;
final &= 0x3ff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezePRAM[i] == 1)
freezePRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n",
@ -1097,7 +1097,7 @@ static void debuggerBreakWriteClear(int n, char** args)
final &= 0xffff;
}
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeVRAM[i] == 1)
freezeVRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n",
@ -1106,7 +1106,7 @@ static void debuggerBreakWriteClear(int n, char** args)
case 7: {
address &= 0x3ff;
final &= 0x3ff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeOAM[i] == 1)
freezeOAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n",
@ -1143,7 +1143,7 @@ static void debuggerBreakWrite(int n, char** args)
printf("Cheats are enabled. Cannot continue.\n");
return;
}
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
int n = 0;
sscanf(args[2], "%d", &n);
@ -1153,7 +1153,7 @@ static void debuggerBreakWrite(int n, char** args)
return;
}
u32 final = address + n;
uint32_t final = address + n;
if (address<0x2040000 && final> 0x2040000) {
printf("Invalid byte count: %d\n", n);
@ -1205,7 +1205,7 @@ static void debuggerBreakWrite(int n, char** args)
static void debuggerBreakChangeClear(int n, char** args)
{
if (n == 3) {
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
int n = 0;
sscanf(args[2], "%d", &n);
@ -1215,12 +1215,12 @@ static void debuggerBreakChangeClear(int n, char** args)
return;
}
u32 final = address + n;
uint32_t final = address + n;
switch (address >> 24) {
case 2: {
address &= 0x3ffff;
final &= 0x3ffff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeWorkRAM[i] == 2)
freezeWorkRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n",
@ -1229,7 +1229,7 @@ static void debuggerBreakChangeClear(int n, char** args)
case 3: {
address &= 0x7fff;
final &= 0x7fff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeInternalRAM[i] == 2)
freezeInternalRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n",
@ -1238,7 +1238,7 @@ static void debuggerBreakChangeClear(int n, char** args)
case 5: {
address &= 0x3ff;
final &= 0x3ff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezePRAM[i] == 2)
freezePRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n",
@ -1252,7 +1252,7 @@ static void debuggerBreakChangeClear(int n, char** args)
address &= 0xffff;
final &= 0xffff;
}
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeVRAM[i] == 2)
freezeVRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n",
@ -1261,7 +1261,7 @@ static void debuggerBreakChangeClear(int n, char** args)
case 7: {
address &= 0x3ff;
final &= 0x3ff;
for (u32 i = address; i < final; i++)
for (uint32_t i = address; i < final; i++)
if (freezeOAM[i] == 2)
freezeOAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n",
@ -1298,7 +1298,7 @@ static void debuggerBreakChange(int n, char** args)
printf("Cheats are enabled. Cannot continue.\n");
return;
}
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
int n = 0;
sscanf(args[2], "%d", &n);
@ -1308,7 +1308,7 @@ static void debuggerBreakChange(int n, char** args)
return;
}
u32 final = address + n;
uint32_t final = address + n;
if (address<0x2040000 && final> 0x2040000) {
printf("Invalid byte count: %d\n", n);
@ -1353,11 +1353,11 @@ static void debuggerBreakChange(int n, char** args)
debuggerUsage("bpc");
}
static void debuggerDisassembleArm(FILE* f, u32 pc, int count)
static void debuggerDisassembleArm(FILE* f, uint32_t pc, int count)
{
char buffer[80];
int i = 0;
u32 len = 0;
uint32_t len = 0;
char format[30];
for (i = 0; i < count; i++) {
size_t l = strlen(elfGetAddressSymbol(pc + 4 * i));
@ -1366,17 +1366,17 @@ static void debuggerDisassembleArm(FILE* f, u32 pc, int count)
}
sprintf(format, "%%08x %%-%ds %%s\n", len);
for (i = 0; i < count; i++) {
u32 addr = pc;
uint32_t addr = pc;
pc += disArm(pc, buffer, 2);
fprintf(f, format, addr, elfGetAddressSymbol(addr), buffer);
}
}
static void debuggerDisassembleThumb(FILE* f, u32 pc, int count)
static void debuggerDisassembleThumb(FILE* f, uint32_t pc, int count)
{
char buffer[80];
int i = 0;
u32 len = 0;
uint32_t len = 0;
char format[30];
for (i = 0; i < count; i++) {
size_t l = strlen(elfGetAddressSymbol(pc + 2 * i));
@ -1386,7 +1386,7 @@ static void debuggerDisassembleThumb(FILE* f, u32 pc, int count)
sprintf(format, "%%08x %%-%ds %%s\n", len);
for (i = 0; i < count; i++) {
u32 addr = pc;
uint32_t addr = pc;
pc += disThumb(pc, buffer, 2);
fprintf(f, format, addr, elfGetAddressSymbol(addr), buffer);
}
@ -1394,7 +1394,7 @@ static void debuggerDisassembleThumb(FILE* f, u32 pc, int count)
static void debuggerDisassembleArm(int n, char** args)
{
u32 pc = reg[15].I;
uint32_t pc = reg[15].I;
pc -= 4;
int count = 20;
if (n >= 2) {
@ -1412,7 +1412,7 @@ static void debuggerDisassembleArm(int n, char** args)
static void debuggerDisassembleThumb(int n, char** args)
{
u32 pc = reg[15].I;
uint32_t pc = reg[15].I;
pc -= 2;
int count = 20;
if (n >= 2) {
@ -1438,7 +1438,7 @@ static void debuggerDisassemble(int n, char** args)
static void debuggerFileDisassembleArm(int n, char** args)
{
u32 pc = reg[15].I;
uint32_t pc = reg[15].I;
pc -= 4;
int count = 20;
if (n < 2) {
@ -1466,7 +1466,7 @@ static void debuggerFileDisassembleArm(int n, char** args)
static void debuggerFileDisassembleThumb(int n, char** args)
{
u32 pc = reg[15].I;
uint32_t pc = reg[15].I;
pc -= 2;
int count = 20;
if (n < 2) {
@ -1581,8 +1581,8 @@ void debuggerDoSearch()
while (true) {
unsigned int final = SearchStart + SearchLength - 1;
u8* end;
u8* start;
uint8_t* end;
uint8_t* start;
switch (SearchStart >> 24) {
case 0:
@ -1666,7 +1666,7 @@ void debuggerDoSearch()
};
end -= SearchLength - 1;
u8 firstbyte = SearchData[0];
uint8_t firstbyte = SearchData[0];
while (start <= end) {
while ((start <= end) && (*start != firstbyte))
start++;
@ -1696,7 +1696,7 @@ void debuggerDoSearch()
};
};
unsigned int AddressToGBA(u8* mem)
unsigned int AddressToGBA(uint8_t* mem)
{
if (mem >= &bios[0] && mem <= &bios[0x3fff])
return 0x00000000 + (mem - &bios[0]);
@ -1890,11 +1890,11 @@ static void debuggerIo(int n, char** args)
static void debuggerEditByte(int n, char** args)
{
if (n == 3) {
u32 address = 0x10000;
u32 byte = 0;
uint32_t address = 0x10000;
uint32_t byte = 0;
sscanf(args[1], "%x", &address);
sscanf(args[2], "%x", &byte);
debuggerWriteByte(address, (u8)byte);
debuggerWriteByte(address, (uint8_t)byte);
} else
debuggerUsage("eb");
}
@ -1902,15 +1902,15 @@ static void debuggerEditByte(int n, char** args)
static void debuggerEditHalfWord(int n, char** args)
{
if (n == 3) {
u32 address = 0x10000;
u32 HalfWord = 0;
uint32_t address = 0x10000;
uint32_t HalfWord = 0;
sscanf(args[1], "%x", &address);
if (address & 1) {
printf("Error: address must be half-word aligned\n");
return;
}
sscanf(args[2], "%x", &HalfWord);
debuggerWriteHalfWord(address, (u16)HalfWord);
debuggerWriteHalfWord(address, (uint16_t)HalfWord);
} else
debuggerUsage("eh");
}
@ -1919,7 +1919,7 @@ static void debuggerEditRegister(int n, char** args)
{
if (n == 3) {
int r = 15;
u32 val;
uint32_t val;
sscanf(args[1], "%d", &r);
if (r > 16 || r == 15) {
// don't allow PC to change
@ -1936,15 +1936,15 @@ static void debuggerEditRegister(int n, char** args)
static void debuggerEdit(int n, char** args)
{
if (n == 3) {
u32 address;
u32 byte;
uint32_t address;
uint32_t byte;
sscanf(args[1], "%x", &address);
if (address & 3) {
printf("Error: address must be word aligned\n");
return;
}
sscanf(args[2], "%x", &byte);
debuggerWriteMemory(address, (u32)byte);
debuggerWriteMemory(address, (uint32_t)byte);
} else
debuggerUsage("ew");
}
@ -1954,7 +1954,7 @@ static void debuggerEdit(int n, char** args)
static void debuggerMemoryByte(int n, char** args)
{
if (n == 2) {
u32 addr = 0;
uint32_t addr = 0;
sscanf(args[1], "%x", &addr);
for (int _i = 0; _i < 16; _i++) {
int a = debuggerReadByte(addr);
@ -1989,7 +1989,7 @@ static void debuggerMemoryByte(int n, char** args)
static void debuggerMemoryHalfWord(int n, char** args)
{
if (n == 2) {
u32 addr = 0;
uint32_t addr = 0;
sscanf(args[1], "%x", &addr);
addr = addr & 0xfffffffe;
for (int _i = 0; _i < 16; _i++) {
@ -2025,7 +2025,7 @@ static void debuggerMemoryHalfWord(int n, char** args)
static void debuggerMemory(int n, char** args)
{
if (n == 2) {
u32 addr = 0;
uint32_t addr = 0;
sscanf(args[1], "%x", &addr);
addr = addr & 0xfffffffc;
for (int _i = 0; _i < 16; _i++) {
@ -2104,7 +2104,7 @@ static void debuggerReadState(int n, char** args)
static void debuggerDumpLoad(int n, char** args)
{
u32 address = 0;
uint32_t address = 0;
const char* file;
FILE* f;
int c;
@ -2139,8 +2139,8 @@ static void debuggerDumpLoad(int n, char** args)
static void debuggerDumpSave(int n, char** args)
{
u32 address = 0;
u32 size = 0;
uint32_t address = 0;
uint32_t size = 0;
const char* file;
FILE* f;
@ -2155,7 +2155,7 @@ static void debuggerDumpSave(int n, char** args)
return;
}
for (u32 i = 0; i < size; i++) {
for (uint32_t i = 0; i < size; i++) {
fputc(debuggerReadByte(address), f);
address++;
}
@ -2170,7 +2170,7 @@ static void debuggerCondBreakThumb(int n, char** args)
if (n > 4) { //conditional args handled separately
int i = debuggerNumOfBreakpoints;
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
debuggerBreakpointList[i].address = address;
@ -2187,7 +2187,7 @@ static void debuggerCondBreakArm(int n, char** args)
if (n > 4) { //conditional args handled separately
int i = debuggerNumOfBreakpoints;
u32 address = 0;
uint32_t address = 0;
sscanf(args[1], "%x", &address);
debuggerBreakpointList[i].address = address;
@ -2216,8 +2216,8 @@ static void debuggerCondValidate(int n, char** args, int start)
int rel = 0;
u32 value1 = 0;
u32 value2 = 0;
uint32_t value1 = 0;
uint32_t value2 = 0;
char size = 0;
int j = 1;
@ -2454,11 +2454,11 @@ static bool debuggerCondEvaluate(int num)
if (debuggerBreakpointList[num].cond_rel == 0)
return true;
u32 address = debuggerBreakpointList[num].cond_address;
uint32_t address = debuggerBreakpointList[num].cond_address;
char size = debuggerBreakpointList[num].cond_size;
u32 value = debuggerBreakpointList[num].cond_value;
u32 value1 = 0;
u32 value2 = 0;
uint32_t value = debuggerBreakpointList[num].cond_value;
uint32_t value1 = 0;
uint32_t value2 = 0;
if (address < 17)
value1 = reg[address].I;
@ -2514,7 +2514,7 @@ static bool debuggerCondEvaluate(int num)
}
}
/*extern*/ void debuggerOutput(const char* s, u32 addr)
/*extern*/ void debuggerOutput(const char* s, uint32_t addr)
{
if (s)
printf("%s", s);

View File

@ -18,5 +18,5 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
extern void debuggerMain();
extern void debuggerOutput(const char*, u32);
extern void debuggerOutput(const char*, uint32_t);
extern void debuggerSignal(int, int);

View File

@ -164,7 +164,7 @@ bool exprNodeDotResolve(Node* n, Function* f, CompileUnit* u)
TypeEnum tt = n->expression->type->type;
if (tt == TYPE_struct || tt == TYPE_union) {
u32 loc = n->expression->location;
uint32_t loc = n->expression->location;
Type* t = n->expression->type;
int count = t->structure->memberCount;
int i = 0;
@ -225,7 +225,7 @@ bool exprNodeArrowResolve(Node* n, Function* f, CompileUnit* u)
tt = n->expression->type->pointer->type;
if (tt == TYPE_struct || tt == TYPE_union) {
u32 loc = debuggerReadMemory(n->expression->location);
uint32_t loc = debuggerReadMemory(n->expression->location);
Type* t = n->expression->type->pointer;
int count = t->structure->memberCount;
int i = 0;
@ -367,7 +367,7 @@ bool exprNodeArrayResolve(Node* n, Function* f, CompileUnit* u)
if (tt == TYPE_array) {
Array* a = n->expression->type->array;
u32 loc = n->expression->location;
uint32_t loc = n->expression->location;
Type* t = a->type;
if (a->maxBounds > 1) {
int index = n->expression->index;
@ -390,7 +390,7 @@ bool exprNodeArrayResolve(Node* n, Function* f, CompileUnit* u)
n->locType = LOCATION_memory;
} else {
Type* t = n->expression->type->pointer;
u32 loc = n->expression->location;
uint32_t loc = n->expression->location;
if (n->expression->locType == LOCATION_register)
loc = reg[loc].I;
else

View File

@ -19,8 +19,8 @@
struct Node {
Type* type;
u32 location;
u32 objLocation;
uint32_t location;
uint32_t objLocation;
LocationType locType;
int value;
int index;

View File

@ -26,45 +26,45 @@
// Screen filters
//
extern int Init_2xSaI(u32);
extern int Init_2xSaI(uint32_t);
extern void hq2x_init(unsigned);
extern bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth);
extern void sdlStretch1x(u8*, u32, u8*, u8*, u32, int, int);
extern void sdlStretch2x(u8*, u32, u8*, u8*, u32, int, int);
extern void sdlStretch3x(u8*, u32, u8*, u8*, u32, int, int);
extern void sdlStretch4x(u8*, u32, u8*, u8*, u32, int, int);
extern void _2xSaI(u8*, u32, u8*, u8*, u32, int, int);
extern void _2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
extern void Super2xSaI(u8*, u32, u8*, u8*, u32, int, int);
extern void Super2xSaI32(u8*, u32, u8*, u8*, u32, int, int);
extern void SuperEagle(u8*, u32, u8*, u8*, u32, int, int);
extern void SuperEagle32(u8*, u32, u8*, u8*, u32, int, int);
extern void Pixelate(u8*, u32, u8*, u8*, u32, int, int);
extern void Pixelate32(u8*, u32, u8*, u8*, u32, int, int);
extern void AdMame2x(u8*, u32, u8*, u8*, u32, int, int);
extern void AdMame2x32(u8*, u32, u8*, u8*, u32, int, int);
extern void Bilinear(u8*, u32, u8*, u8*, u32, int, int);
extern void Bilinear32(u8*, u32, u8*, u8*, u32, int, int);
extern void BilinearPlus(u8*, u32, u8*, u8*, u32, int, int);
extern void BilinearPlus32(u8*, u32, u8*, u8*, u32, int, int);
extern void Scanlines(u8*, u32, u8*, u8*, u32, int, int);
extern void Scanlines32(u8*, u32, u8*, u8*, u32, int, int);
extern void ScanlinesTV(u8*, u32, u8*, u8*, u32, int, int);
extern void ScanlinesTV32(u8*, u32, u8*, u8*, u32, int, int);
extern void hq2x(u8*, u32, u8*, u8*, u32, int, int);
extern void hq2x32(u8*, u32, u8*, u8*, u32, int, int);
extern void lq2x(u8*, u32, u8*, u8*, u32, int, int);
extern void lq2x32(u8*, u32, u8*, u8*, u32, int, int);
extern void hq3x16(u8*, u32, u8*, u8*, u32, int, int);
extern void hq4x16(u8*, u32, u8*, u8*, u32, int, int);
extern void hq3x32_32(u8*, u32, u8*, u8*, u32, int, int);
extern void hq4x32_32(u8*, u32, u8*, u8*, u32, int, int);
extern void xbrz2x32(u8*, u32, u8*, u8*, u32, int, int);
extern void xbrz3x32(u8*, u32, u8*, u8*, u32, int, int);
extern void xbrz4x32(u8*, u32, u8*, u8*, u32, int, int);
extern void xbrz5x32(u8*, u32, u8*, u8*, u32, int, int);
extern void xbrz6x32(u8*, u32, u8*, u8*, u32, int, int);
extern void sdlStretch1x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void sdlStretch2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void sdlStretch3x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void sdlStretch4x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void _2xSaI(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void _2xSaI32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Super2xSaI(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Super2xSaI32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void SuperEagle(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void SuperEagle32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Pixelate(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Pixelate32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void AdMame2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void AdMame2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Bilinear(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Bilinear32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void BilinearPlus(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void BilinearPlus32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Scanlines(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void Scanlines32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void ScanlinesTV(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void ScanlinesTV32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void hq2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void hq2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void lq2x(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void lq2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void hq3x16(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void hq4x16(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void hq3x32_32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void hq4x32_32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void xbrz2x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void xbrz3x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void xbrz4x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void xbrz5x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
extern void xbrz6x32(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
struct FilterDesc {
char name[30];
@ -168,10 +168,10 @@ FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth)
// Interframe blending filters
//
extern void SmartIB(u8*, u32, int, int);
extern void SmartIB32(u8*, u32, int, int);
extern void MotionBlurIB(u8*, u32, int, int);
extern void MotionBlurIB32(u8*, u32, int, int);
extern void SmartIB(uint8_t*, uint32_t, int, int);
extern void SmartIB32(uint8_t*, uint32_t, int, int);
extern void MotionBlurIB(uint8_t*, uint32_t, int, int);
extern void MotionBlurIB32(uint8_t*, uint32_t, int, int);
struct IFBFilterDesc {
char name[30];
@ -216,7 +216,7 @@ char* getIFBFilterName(const IFBFilter f)
//
#ifndef C_CORE
u8 sdlStretcher[16384];
uint8_t sdlStretcher[16384];
#ifdef _MSC_VER
#define SDL_CALL_STRETCHER \
@ -229,7 +229,7 @@ u8 sdlStretcher[16384];
#endif
#define SDL_LONG(val) \
*((u32*)&sdlStretcher[sdlStretcherPos]) = val; \
*((uint32_t*)&sdlStretcher[sdlStretcherPos]) = val; \
sdlStretcherPos += 4;
#define SDL_AND_EAX(val) \
@ -466,13 +466,13 @@ void sdlMakeStretcher(int width, int sizeOption)
#else // C_CORE
void (*sdlStretcher)(u8*, u8*, int) = 0;
void (*sdlStretcher)(uint8_t*, uint8_t*, int) = 0;
#define SDL_CALL_STRETCHER \
sdlStretcher(srcPtr, dstPtr, width)
template <typename T>
void sdlStretchx1(u8* src, u8* dest, int width)
void sdlStretchx1(uint8_t* src, uint8_t* dest, int width)
{
T* s = (T*)src;
T* d = (T*)dest;
@ -481,7 +481,7 @@ void sdlStretchx1(u8* src, u8* dest, int width)
}
template <typename T>
void sdlStretchx2(u8* src, u8* dest, int width)
void sdlStretchx2(uint8_t* src, uint8_t* dest, int width)
{
T* s = (T*)src;
T* d = (T*)dest;
@ -492,7 +492,7 @@ void sdlStretchx2(u8* src, u8* dest, int width)
}
template <typename T>
void sdlStretchx3(u8* src, u8* dest, int width)
void sdlStretchx3(uint8_t* src, uint8_t* dest, int width)
{
T* s = (T*)src;
T* d = (T*)dest;
@ -504,7 +504,7 @@ void sdlStretchx3(u8* src, u8* dest, int width)
}
template <typename T>
void sdlStretchx4(u8* src, u8* dest, int width)
void sdlStretchx4(uint8_t* src, uint8_t* dest, int width)
{
T* s = (T*)src;
T* d = (T*)dest;
@ -516,24 +516,24 @@ void sdlStretchx4(u8* src, u8* dest, int width)
}
}
void (*sdlStretcher16[4])(u8*, u8*, int) = {
sdlStretchx1<u16>,
sdlStretchx2<u16>,
sdlStretchx3<u16>,
sdlStretchx4<u16>
void (*sdlStretcher16[4])(uint8_t*, uint8_t*, int) = {
sdlStretchx1<uint16_t>,
sdlStretchx2<uint16_t>,
sdlStretchx3<uint16_t>,
sdlStretchx4<uint16_t>
};
void (*sdlStretcher32[4])(u8*, u8*, int) = {
sdlStretchx1<u32>,
sdlStretchx2<u32>,
sdlStretchx3<u32>,
sdlStretchx4<u32>
void (*sdlStretcher32[4])(uint8_t*, uint8_t*, int) = {
sdlStretchx1<uint32_t>,
sdlStretchx2<uint32_t>,
sdlStretchx3<uint32_t>,
sdlStretchx4<uint32_t>
};
void sdlStretch24x1(u8* src, u8* dest, int width)
void sdlStretch24x1(uint8_t* src, uint8_t* dest, int width)
{
u8* s = src;
u8* d = dest;
uint8_t* s = src;
uint8_t* d = dest;
for (int i = 0; i < width; i++) {
*d++ = *s++;
*d++ = *s++;
@ -541,10 +541,10 @@ void sdlStretch24x1(u8* src, u8* dest, int width)
}
}
void sdlStretch24x2(u8* src, u8* dest, int width)
void sdlStretch24x2(uint8_t* src, uint8_t* dest, int width)
{
u8* s = (u8*)src;
u8* d = (u8*)dest;
uint8_t* s = (uint8_t*)src;
uint8_t* d = (uint8_t*)dest;
for (int i = 0; i < width; i++) {
*d++ = *s;
*d++ = *(s + 1);
@ -557,10 +557,10 @@ void sdlStretch24x2(u8* src, u8* dest, int width)
}
}
void sdlStretch24x3(u8* src, u8* dest, int width)
void sdlStretch24x3(uint8_t* src, uint8_t* dest, int width)
{
u8* s = (u8*)src;
u8* d = (u8*)dest;
uint8_t* s = (uint8_t*)src;
uint8_t* d = (uint8_t*)dest;
for (int i = 0; i < width; i++) {
*d++ = *s;
*d++ = *(s + 1);
@ -577,10 +577,10 @@ void sdlStretch24x3(u8* src, u8* dest, int width)
}
}
void sdlStretch24x4(u8* src, u8* dest, int width)
void sdlStretch24x4(uint8_t* src, uint8_t* dest, int width)
{
u8* s = (u8*)src;
u8* d = (u8*)dest;
uint8_t* s = (uint8_t*)src;
uint8_t* d = (uint8_t*)dest;
for (int i = 0; i < width; i++) {
*d++ = *s;
*d++ = *(s + 1);
@ -601,7 +601,7 @@ void sdlStretch24x4(u8* src, u8* dest, int width)
}
}
void (*sdlStretcher24[4])(u8*, u8*, int) = {
void (*sdlStretcher24[4])(uint8_t*, uint8_t*, int) = {
sdlStretch24x1,
sdlStretch24x2,
sdlStretch24x3,
@ -632,11 +632,11 @@ bool sdlStretchInit(int colorDepth, int sizeMultiplier, int srcWidth)
return true;
}
void sdlStretch1x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
void sdlStretch1x(uint8_t* srcPtr, uint32_t srcPitch, uint8_t* /* deltaPtr */, uint8_t* dstPtr, uint32_t dstPitch, int width, int height)
{
int i;
#ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher;
uint32_t* stretcher = (uint32_t*)sdlStretcher;
#endif
for (i = 0; i < height; i++) {
SDL_CALL_STRETCHER;
@ -644,11 +644,11 @@ void sdlStretch1x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32
dstPtr += dstPitch;
}
}
void sdlStretch2x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
void sdlStretch2x(uint8_t* srcPtr, uint32_t srcPitch, uint8_t* /* deltaPtr */, uint8_t* dstPtr, uint32_t dstPitch, int width, int height)
{
int i;
#ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher;
uint32_t* stretcher = (uint32_t*)sdlStretcher;
#endif
for (i = 0; i < height; i++) {
SDL_CALL_STRETCHER;
@ -658,11 +658,11 @@ void sdlStretch2x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32
dstPtr += dstPitch;
}
}
void sdlStretch3x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
void sdlStretch3x(uint8_t* srcPtr, uint32_t srcPitch, uint8_t* /* deltaPtr */, uint8_t* dstPtr, uint32_t dstPitch, int width, int height)
{
int i;
#ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher;
uint32_t* stretcher = (uint32_t*)sdlStretcher;
#endif
for (i = 0; i < height; i++) {
SDL_CALL_STRETCHER;
@ -674,11 +674,11 @@ void sdlStretch3x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32
dstPtr += dstPitch;
}
}
void sdlStretch4x(u8* srcPtr, u32 srcPitch, u8* /* deltaPtr */, u8* dstPtr, u32 dstPitch, int width, int height)
void sdlStretch4x(uint8_t* srcPtr, uint32_t srcPitch, uint8_t* /* deltaPtr */, uint8_t* dstPtr, uint32_t dstPitch, int width, int height)
{
int i;
#ifndef C_CORE
u32* stretcher = (u32*)sdlStretcher;
uint32_t* stretcher = (uint32_t*)sdlStretcher;
#endif
for (i = 0; i < height; i++) {
SDL_CALL_STRETCHER;

View File

@ -19,6 +19,8 @@
#ifndef VBA_SDL_FILTERS_H
#define VBA_SDL_FILTERS_H
#include <cstdint>
#include "../System.h"
//
@ -53,7 +55,7 @@ enum Filter {
};
// Function pointer type for a filter function
typedef void (*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int);
typedef void (*FilterFunc)(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
// Initialize a filter and get the corresponding filter function pointer
FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth);
@ -75,7 +77,7 @@ enum IFBFilter { kIFBNone,
kInvalidIFBFilter };
// Function pointer type for an IFB filter function
typedef void (*IFBFilterFunc)(u8*, u32, int, int);
typedef void (*IFBFilterFunc)(uint8_t*, uint32_t, int, int);
// Initialize an IFB filter and get the corresponding filter function pointer
IFBFilterFunc initIFBFilter(const int f, const int colorDepth);

View File

@ -24,7 +24,7 @@
extern int RGB_LOW_BITS_MASK;
static const u8 fontdata2[2048] = {
static const uint8_t fontdata2[2048] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x81, 0xa5, 0x81, 0xbd, 0x99, 0x81, 0x7e, 0x7e, 0xff, 0xdb, 0xff, 0xc3, 0xe7, 0xff, 0x7e, 0x36, 0x7f, 0x7f, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x1c, 0x3e, 0x1c, 0x7f, 0x7f, 0x3e, 0x1c, 0x3e, 0x08, 0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x3e, 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, 0xff, 0xff, 0xe7, 0xc3, 0xc3, 0xe7, 0xff, 0xff, 0x00, 0x3c, 0x66, 0x42, 0x42, 0x66, 0x3c, 0x00, 0xff, 0xc3, 0x99, 0xbd, 0xbd, 0x99, 0xc3, 0xff, 0xf0, 0xe0, 0xf0, 0xbe, 0x33, 0x33, 0x33, 0x1e, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x18, 0x7e, 0x18, 0xfc, 0xcc, 0xfc, 0x0c, 0x0c, 0x0e, 0x0f, 0x07, 0xfe, 0xc6, 0xfe, 0xc6, 0xc6, 0xe6, 0x67, 0x03, 0x99, 0x5a, 0x3c, 0xe7, 0xe7, 0x3c, 0x5a, 0x99, 0x01, 0x07, 0x1f, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x40, 0x70, 0x7c, 0x7f, 0x7c, 0x70, 0x40, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x00, 0xfe, 0xdb, 0xdb, 0xde, 0xd8, 0xd8, 0xd8, 0x00, 0x7c, 0xc6, 0x1c, 0x36, 0x36, 0x1c, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x7e, 0x00, 0x18, 0x3c, 0x7e, 0x18, 0x7e, 0x3c, 0x18, 0xff, 0x18, 0x3c, 0x7e, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x18, 0x30, 0x7f, 0x30, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x06, 0x7f, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x7f, 0x00, 0x00, 0x00, 0x24, 0x66, 0xff, 0x66, 0x24, 0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x1e, 0x1e, 0x0c, 0x0c, 0x00, 0x0c, 0x00, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x36, 0x7f, 0x36, 0x7f, 0x36, 0x36, 0x00, 0x0c, 0x3e, 0x03, 0x1e, 0x30, 0x1f, 0x0c, 0x00, 0x00, 0x63, 0x33, 0x18, 0x0c, 0x66, 0x63, 0x00, 0x1c, 0x36, 0x1c, 0x6e, 0x3b, 0x33, 0x6e, 0x00, 0x06, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0c, 0x06, 0x06, 0x06, 0x0c, 0x18, 0x00, 0x06, 0x0c, 0x18, 0x18, 0x18, 0x0c, 0x06, 0x00, 0x00, 0x66, 0x3c, 0xff, 0x3c, 0x66, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x60, 0x30, 0x18, 0x0c, 0x06, 0x03, 0x01, 0x00, 0x3e, 0x63, 0x73, 0x7b, 0x6f, 0x67, 0x3e, 0x00, 0x0c, 0x0e, 0x0c, 0x0c, 0x0c, 0x0c, 0x3f, 0x00, 0x1e, 0x33, 0x30, 0x1c, 0x06, 0x33, 0x3f, 0x00, 0x1e, 0x33, 0x30, 0x1c, 0x30, 0x33, 0x1e, 0x00, 0x38, 0x3c, 0x36, 0x33, 0x7f, 0x30, 0x78, 0x00, 0x3f, 0x03, 0x1f, 0x30, 0x30, 0x33, 0x1e, 0x00, 0x1c, 0x06, 0x03, 0x1f, 0x33, 0x33, 0x1e, 0x00, 0x3f, 0x33, 0x30, 0x18, 0x0c, 0x0c, 0x0c, 0x00, 0x1e, 0x33, 0x33, 0x1e, 0x33, 0x33, 0x1e, 0x00, 0x1e, 0x33, 0x33, 0x3e, 0x30, 0x18, 0x0e, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x0c, 0x0c, 0x06, 0x18, 0x0c, 0x06, 0x03, 0x06, 0x0c, 0x18, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x06, 0x0c, 0x18, 0x30, 0x18, 0x0c, 0x06, 0x00, 0x1e, 0x33, 0x30, 0x18, 0x0c, 0x00, 0x0c, 0x00,
0x3e, 0x63, 0x7b, 0x7b, 0x7b, 0x03, 0x1e, 0x00, 0x0c, 0x1e, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x66, 0x66, 0x3f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x03, 0x66, 0x3c, 0x00, 0x1f, 0x36, 0x66, 0x66, 0x66, 0x36, 0x1f, 0x00, 0x7f, 0x46, 0x16, 0x1e, 0x16, 0x46, 0x7f, 0x00, 0x7f, 0x46, 0x16, 0x1e, 0x16, 0x06, 0x0f, 0x00, 0x3c, 0x66, 0x03, 0x03, 0x73, 0x66, 0x7c, 0x00, 0x33, 0x33, 0x33, 0x3f, 0x33, 0x33, 0x33, 0x00, 0x1e, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x78, 0x30, 0x30, 0x30, 0x33, 0x33, 0x1e, 0x00, 0x67, 0x66, 0x36, 0x1e, 0x36, 0x66, 0x67, 0x00, 0x0f, 0x06, 0x06, 0x06, 0x46, 0x66, 0x7f, 0x00, 0x63, 0x77, 0x7f, 0x7f, 0x6b, 0x63, 0x63, 0x00, 0x63, 0x67, 0x6f, 0x7b, 0x73, 0x63, 0x63, 0x00, 0x1c, 0x36, 0x63, 0x63, 0x63, 0x36, 0x1c, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x06, 0x06, 0x0f, 0x00, 0x1e, 0x33, 0x33, 0x33, 0x3b, 0x1e, 0x38, 0x00, 0x3f, 0x66, 0x66, 0x3e, 0x36, 0x66, 0x67, 0x00, 0x1e, 0x33, 0x07, 0x0e, 0x38, 0x33, 0x1e, 0x00, 0x3f, 0x2d, 0x0c, 0x0c, 0x0c, 0x0c, 0x1e, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x3f, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x00, 0x63, 0x63, 0x63, 0x6b, 0x7f, 0x77, 0x63, 0x00, 0x63, 0x63, 0x36, 0x1c, 0x1c, 0x36, 0x63, 0x00, 0x33, 0x33, 0x33, 0x1e, 0x0c, 0x0c, 0x1e, 0x00, 0x7f, 0x63, 0x31, 0x18, 0x4c, 0x66, 0x7f, 0x00, 0x1e, 0x06, 0x06, 0x06, 0x06, 0x06, 0x1e, 0x00, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0x40, 0x00, 0x1e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1e, 0x00, 0x08, 0x1c, 0x36, 0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff,
@ -35,7 +35,7 @@ static const u8 fontdata2[2048] = {
0x00, 0x00, 0x6e, 0x3b, 0x13, 0x3b, 0x6e, 0x00, 0x00, 0x1e, 0x33, 0x1f, 0x33, 0x1f, 0x03, 0x03, 0x00, 0x3f, 0x33, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x7f, 0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x3f, 0x33, 0x06, 0x0c, 0x06, 0x33, 0x3f, 0x00, 0x00, 0x00, 0x7e, 0x1b, 0x1b, 0x1b, 0x0e, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3e, 0x06, 0x03, 0x00, 0x6e, 0x3b, 0x18, 0x18, 0x18, 0x18, 0x00, 0x3f, 0x0c, 0x1e, 0x33, 0x33, 0x1e, 0x0c, 0x3f, 0x1c, 0x36, 0x63, 0x7f, 0x63, 0x36, 0x1c, 0x00, 0x1c, 0x36, 0x63, 0x63, 0x36, 0x36, 0x77, 0x00, 0x38, 0x0c, 0x18, 0x3e, 0x33, 0x33, 0x1e, 0x00, 0x00, 0x00, 0x7e, 0xdb, 0xdb, 0x7e, 0x00, 0x00, 0x60, 0x30, 0x7e, 0xdb, 0xdb, 0x7e, 0x06, 0x03, 0x1c, 0x06, 0x03, 0x1f, 0x03, 0x06, 0x1c, 0x00, 0x1e, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x3f, 0x00, 0x00, 0x0c, 0x0c, 0x3f, 0x0c, 0x0c, 0x00, 0x3f, 0x00, 0x06, 0x0c, 0x18, 0x0c, 0x06, 0x00, 0x3f, 0x00, 0x18, 0x0c, 0x06, 0x0c, 0x18, 0x00, 0x3f, 0x00, 0x70, 0xd8, 0xd8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1b, 0x1b, 0x0e, 0x0c, 0x0c, 0x00, 0x3f, 0x00, 0x0c, 0x0c, 0x00, 0x00, 0x6e, 0x3b, 0x00, 0x6e, 0x3b, 0x00, 0x00, 0x1c, 0x36, 0x36, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0xf0, 0x30, 0x30, 0x30, 0x37, 0x36, 0x3c, 0x38, 0x1e, 0x36, 0x36, 0x36, 0x36, 0x00, 0x00, 0x00, 0x0e, 0x18, 0x0c, 0x06, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x3c, 0x3c, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void drawText(u8* screen, int pitch, int x, int y,
void drawText(uint8_t* screen, int pitch, int x, int y,
const char* string, bool trans)
{
screen += y * pitch;
@ -54,11 +54,11 @@ void drawText(u8* screen, int pitch, int x, int y,
case 16: {
while (*string) {
char c = *string++;
u8* scr = screen;
uint8_t* scr = screen;
u16 mask = ~RGB_LOW_BITS_MASK;
uint16_t mask = ~RGB_LOW_BITS_MASK;
int h, w;
u16* s = (u16*)scr;
uint16_t* s = (uint16_t*)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c << 3) + h] >> w) & 1;
@ -72,7 +72,7 @@ void drawText(u8* screen, int pitch, int x, int y,
}
}
scr += pitch;
s = (u16*)scr;
s = (uint16_t*)scr;
}
screen += inc * 8;
}
@ -80,24 +80,24 @@ void drawText(u8* screen, int pitch, int x, int y,
case 24: {
while (*string) {
char c = *string++;
u8* scr = screen;
uint8_t* scr = screen;
int h, w;
u8* s = (u8*)scr;
uint8_t* s = (uint8_t*)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s += 3) {
int on = (fontdata2[(c << 3) + h] >> w) & 1;
if (trans) {
if (on) {
u32 color = (0x1f) << systemRedShift;
uint32_t color = (0x1f) << systemRedShift;
*s = ((color & 255) >> 1) + (*s >> 1);
*(s + 1) = (((color >> 8) & 255) >> 1) + (*(s + 1) >> 1);
*(s + 2) = (((color >> 16) & 255) >> 1) + (*(s + 2) >> 1);
}
} else {
if (on) {
u32 color = (0x1f) << systemRedShift;
uint32_t color = (0x1f) << systemRedShift;
*s = (color & 255);
*(s + 1) = (color >> 8) & 255;
*(s + 2) = (color >> 16) & 255;
@ -105,7 +105,7 @@ void drawText(u8* screen, int pitch, int x, int y,
}
}
scr += pitch;
s = (u8*)scr;
s = (uint8_t*)scr;
}
screen += inc * 8;
}
@ -113,11 +113,11 @@ void drawText(u8* screen, int pitch, int x, int y,
case 32: {
while (*string) {
char c = *string++;
u8* scr = screen;
uint8_t* scr = screen;
int h, w;
u32 mask = 0xfefefe;
u32* s = (u32*)scr;
uint32_t mask = 0xfefefe;
uint32_t* s = (uint32_t*)scr;
for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c << 3) + h] >> w) & 1;
@ -131,7 +131,7 @@ void drawText(u8* screen, int pitch, int x, int y,
}
}
scr += pitch;
s = (u32*)scr;
s = (uint32_t*)scr;
}
screen += inc * 8;
}

View File

@ -17,4 +17,4 @@
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
extern void drawText(u8*, int, int, int, const char*, bool);
extern void drawText(uint8_t*, int, int, int, const char*, bool);

View File

@ -210,7 +210,7 @@ void BitmapControl::setBmpInfo(BITMAPINFO* info)
bmpInfo = info;
}
void BitmapControl::setData(u8* d)
void BitmapControl::setData(uint8_t* d)
{
data = d;
}

View File

@ -30,7 +30,7 @@ public:
void refresh();
void setSize(int w1, int h1);
void setSelectedRectangle(int x, int y, int width, int height);
void setData(u8* d);
void setData(uint8_t* d);
void setBmpInfo(BITMAPINFO* info);
static bool isRegistered;
@ -64,9 +64,9 @@ protected:
private:
void registerClass();
bool stretch;
u8 colors[3 * 64];
uint8_t colors[3 * 64];
BITMAPINFO* bmpInfo;
u8* data;
uint8_t* data;
int h;
int w;
RECT boxreigon;

View File

@ -150,9 +150,9 @@ CString BugReport::createReport()
char buffer[20];
if (theApp.cartridgeType == 0) {
u32 check = 0;
uint32_t check = 0;
for (int i = 0; i < 0x4000; i += 4) {
check += *((u32*)&bios[i]);
check += *((uint32_t*)&bios[i]);
}
AppendFormat(report, "BIOS Checksum: %08X\r\n", check);
@ -165,10 +165,10 @@ CString BugReport::createReport()
AppendFormat(report, "Game code : %s\r\n", buffer);
CString res = "";
u32* p = (u32*)rom;
u32* end = (u32*)((char*)rom + theApp.romSize);
uint32_t* p = (uint32_t*)rom;
uint32_t* end = (uint32_t*)((char*)rom + theApp.romSize);
while (p < end) {
u32 d = READ32LE(p);
uint32_t d = READ32LE(p);
if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) {

View File

@ -73,7 +73,7 @@ void ColorButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
DeleteObject(br);
}
void ColorButton::setColor(u16 c)
void ColorButton::setColor(uint16_t c)
{
color = c;
Invalidate();

View File

@ -32,8 +32,8 @@ public:
// Implementation
public:
void setColor(u16 c);
u16 color;
void setColor(uint16_t c);
uint16_t color;
virtual ~ColorButton();
void registerClass();

View File

@ -55,7 +55,7 @@ BOOL ColorControl::OnEraseBkgnd(CDC* pDC)
return TRUE;
}
void ColorControl::setColor(u16 c)
void ColorControl::setColor(uint16_t c)
{
color = c;
Invalidate();

View File

@ -30,8 +30,8 @@ public:
// Implementation
public:
void setColor(u16 c);
u16 color;
void setColor(uint16_t c);
uint16_t color;
virtual ~ColorControl();
// Generated message map functions

View File

@ -29,7 +29,7 @@
#include <Dxerr.h> // contains debug functions
#include <d3d9.h> // main include file
extern int Init_2xSaI(u32); // initializes all pixel filters
extern int Init_2xSaI(uint32_t); // initializes all pixel filters
extern int systemSpeed;
#ifdef _DEBUG
@ -45,12 +45,12 @@ extern bool detectMMX();
#endif
struct PFTHREAD_DATA {
void (*filterFunction)(u8*, u32, u8*, u8*, u32, int, int);
u8* sourcePointer;
u32 sourcePitch;
u8* deltaPointer;
u8* destPointer;
u32 destPitch;
void (*filterFunction)(uint8_t*, uint32_t, uint8_t*, uint8_t*, uint32_t, int, int);
uint8_t* sourcePointer;
uint32_t sourcePitch;
uint8_t* deltaPointer;
uint8_t* destPointer;
uint32_t destPitch;
int width;
int height;
};
@ -381,17 +381,17 @@ void Direct3DDisplay::render()
DXTRACE_ERR_MSGBOX(_T("Can not lock texture"), hr);
return;
} else {
u32 pitch = sizeX * (systemColorDepth >> 3) + 4;
uint32_t pitch = sizeX * (systemColorDepth >> 3) + 4;
if (theApp.filterFunction) {
if (filterMT) {
u8* start = pix + pitch;
uint8_t* start = pix + pitch;
int src_height_per_thread = sizeY / nThreads;
int src_height_remaining = sizeY - ((sizeY / nThreads) * nThreads);
u32 src_bytes_per_thread = pitch * src_height_per_thread;
uint32_t src_bytes_per_thread = pitch * src_height_per_thread;
int dst_height_per_thread = src_height_per_thread * filterMagnification;
u32 dst_bytes_per_thread = lr.Pitch * dst_height_per_thread;
uint32_t dst_bytes_per_thread = lr.Pitch * dst_height_per_thread;
unsigned int i = nThreads - 1;
@ -404,8 +404,8 @@ void Direct3DDisplay::render()
pfthread_data[i].filterFunction = theApp.filterFunction;
pfthread_data[i].sourcePointer = start + (i * src_bytes_per_thread);
pfthread_data[i].sourcePitch = pitch;
pfthread_data[i].deltaPointer = (u8*)theApp.delta; // TODO: check if thread-safe
pfthread_data[i].destPointer = ((u8*)lr.pBits) + (i * dst_bytes_per_thread);
pfthread_data[i].deltaPointer = (uint8_t*)theApp.delta; // TODO: check if thread-safe
pfthread_data[i].destPointer = ((uint8_t*)lr.pBits) + (i * dst_bytes_per_thread);
pfthread_data[i].destPitch = lr.Pitch;
pfthread_data[i].width = sizeX;
@ -444,8 +444,8 @@ void Direct3DDisplay::render()
theApp.filterFunction(
pix + pitch,
pitch,
(u8*)theApp.delta,
(u8*)lr.pBits,
(uint8_t*)theApp.delta,
(uint8_t*)lr.pBits,
lr.Pitch,
sizeX,
sizeY);

View File

@ -31,7 +31,7 @@ public:
virtual bool initialize();
virtual bool readDevices();
virtual u32 readDevice(int which);
virtual uint32_t readDevice(int which);
virtual CString getKeyName(LONG_PTR key);
virtual void checkKeys();
virtual void checkMotionKeys();
@ -592,9 +592,9 @@ bool DirectInput::readDevices()
return ok;
}
u32 DirectInput::readDevice(int which)
uint32_t DirectInput::readDevice(int which)
{
u32 res = 0;
uint32_t res = 0;
int i = joypadDefault;
if (which >= 0 && which <= 3)
i = which;

View File

@ -41,7 +41,7 @@ public:
void pause(); // pause the secondary sound buffer
void reset(); // stop and reset the secondary sound buffer
void resume(); // resume the secondary sound buffer
void write(u16* finalWave, int length); // write the emulated sound to the secondary sound buffer
void write(uint16_t* finalWave, int length); // write the emulated sound to the secondary sound buffer
};
DirectSound::DirectSound()
@ -219,7 +219,7 @@ void DirectSound::resume()
dsbSecondary->Play(0, 0, DSBPLAY_LOOPING);
}
void DirectSound::write(u16* finalWave, int length)
void DirectSound::write(uint16_t* finalWave, int length)
{
if (!pDirectSound)
return;

View File

@ -133,13 +133,13 @@ void Disassemble::OnNext()
if (rom != NULL) {
CPULoop(1);
if (armState) {
u32 total = address + count * 4;
uint32_t total = address + count * 4;
if (armNextPC >= address && armNextPC < total) {
} else {
OnGopc();
}
} else {
u32 total = address + count * 2;
uint32_t total = address + count * 2;
if (armNextPC >= address && armNextPC < total) {
} else {
OnGopc();
@ -282,7 +282,7 @@ void Disassemble::refresh()
return;
char buffer[80];
u32 addr = address;
uint32_t addr = address;
int i;
int sel = -1;
for (i = 0; i < count; i++) {

View File

@ -21,7 +21,7 @@ public:
void refresh();
int count;
bool autoUpdate;
u32 address;
uint32_t address;
Disassemble(CWnd* pParent = NULL); // standard constructor
// Dialog Data

Some files were not shown because too many files have changed in this diff Show More