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/Port.h
src/common/SoundDriver.h src/common/SoundDriver.h
src/common/SoundSDL.h src/common/SoundSDL.h
src/common/Types.h
) )
if(ENABLE_FFMPEG) if(ENABLE_FFMPEG)

View File

@ -1,6 +1,8 @@
#ifndef SYSTEM_H #ifndef SYSTEM_H
#define SYSTEM_H #define SYSTEM_H
#include "common/Types.h"
#include <cstdint>
#ifndef __LIBRETRO__ #ifndef __LIBRETRO__
#include <zlib.h> #include <zlib.h>
#endif #endif
@ -22,9 +24,9 @@ struct EmulatedSystem {
bool (*emuWriteBattery)(const char *); bool (*emuWriteBattery)(const char *);
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
// load state // load state
bool (*emuReadState)(const u8 *, unsigned); bool (*emuReadState)(const uint8_t *, unsigned);
// load state // load state
unsigned (*emuWriteState)(u8 *, unsigned); unsigned (*emuWriteState)(uint8_t *, unsigned);
#else #else
// load state // load state
bool (*emuReadState)(const char *); bool (*emuReadState)(const char *);
@ -49,25 +51,25 @@ struct EmulatedSystem {
extern void log(const char *, ...); extern void log(const char *, ...);
extern bool systemPauseOnFrame(); 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 systemScreenCapture(int);
extern void systemDrawScreen(); extern void systemDrawScreen();
// updates the joystick data // updates the joystick data
extern bool systemReadJoypads(); extern bool systemReadJoypads();
// return information about the given joystick, -1 for default joystick // return information about the given joystick, -1 for default joystick
extern u32 systemReadJoypad(int); extern uint32_t systemReadJoypad(int);
extern u32 systemGetClock(); extern uint32_t systemGetClock();
extern void systemMessage(int, const char *, ...); extern void systemMessage(int, const char *, ...);
extern void systemSetTitle(const char *); extern void systemSetTitle(const char *);
extern SoundDriver *systemSoundInit(); 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 systemOnSoundShutdown();
extern void systemScreenMessage(const char *); extern void systemScreenMessage(const char *);
extern void systemUpdateMotionSensor(); extern void systemUpdateMotionSensor();
extern int systemGetSensorX(); extern int systemGetSensorX();
extern int systemGetSensorY(); extern int systemGetSensorY();
extern int systemGetSensorZ(); extern int systemGetSensorZ();
extern u8 systemGetSensorDarkness(); extern uint8_t systemGetSensorDarkness();
extern void systemCartridgeRumble(bool); extern void systemCartridgeRumble(bool);
extern void systemPossibleCartridgeRumble(bool); extern void systemPossibleCartridgeRumble(bool);
extern void updateRumbleFrame(); extern void updateRumbleFrame();
@ -80,11 +82,11 @@ extern void Sm60FPS_Init();
extern bool Sm60FPS_CanSkipFrame(); extern bool Sm60FPS_CanSkipFrame();
extern void Sm60FPS_Sleep(); extern void Sm60FPS_Sleep();
extern void DbgMsg(const char *msg, ...); 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 void (*dbgSignal)(int sig, int number);
extern u16 systemColorMap16[0x10000]; extern uint16_t systemColorMap16[0x10000];
extern u32 systemColorMap32[0x10000]; extern uint32_t systemColorMap32[0x10000];
extern u16 systemGbPalette[24]; extern uint16_t systemGbPalette[24];
extern int systemRedShift; extern int systemRedShift;
extern int systemGreenShift; extern int systemGreenShift;
extern int systemBlueShift; extern int systemBlueShift;

View File

@ -46,8 +46,8 @@ extern int systemRedShift;
extern int systemGreenShift; extern int systemGreenShift;
extern int systemBlueShift; extern int systemBlueShift;
extern u16 systemColorMap16[0x10000]; extern uint16_t systemColorMap16[0x10000];
extern u32 systemColorMap32[0x10000]; extern uint32_t systemColorMap32[0x10000];
static int(ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL; static int(ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL;
static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL; static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL;
@ -64,17 +64,17 @@ bool FileExists(const char *filename)
#endif #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 sizeX = w;
int sizeY = h; int sizeY = h;
switch (systemColorDepth) { switch (systemColorDepth) {
case 16: { 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 y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
u16 v = *p++; uint16_t v = *p++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
@ -85,7 +85,7 @@ void utilReadScreenPixels(u8 *dest, int w, int h)
} }
} break; } break;
case 24: { case 24: {
u8 *pixU8 = (u8 *)pix; uint8_t *pixU8 = (uint8_t *)pix;
for (int y = 0; y < sizeY; y++) { for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) { if (systemRedShift < systemBlueShift) {
@ -105,10 +105,10 @@ void utilReadScreenPixels(u8 *dest, int w, int h)
} }
} break; } break;
case 32: { 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 y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
u32 v = *pixU32++; uint32_t v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R *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 #ifndef NO_PNG
u8 writeBuffer[512 * 3]; uint8_t writeBuffer[512 * 3];
FILE *fp = fopen(fileName, "wb"); 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); png_write_info(png_ptr, info_ptr);
u8 *b = writeBuffer; uint8_t *b = writeBuffer;
int sizeX = w; int sizeX = w;
int sizeY = h; int sizeY = h;
switch (systemColorDepth) { switch (systemColorDepth) {
case 16: { 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 y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
u16 v = *p++; uint16_t v = *p++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
@ -189,7 +189,7 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
} }
} break; } break;
case 24: { case 24: {
u8 *pixU8 = (u8 *)pix; uint8_t *pixU8 = (uint8_t *)pix;
for (int y = 0; y < sizeY; y++) { for (int y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
if (systemRedShift < systemBlueShift) { if (systemRedShift < systemBlueShift) {
@ -212,10 +212,10 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
} }
} break; } break;
case 32: { 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 y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
u32 v = *pixU32++; uint32_t v = *pixU32++;
*b++ = ((v >> systemRedShift) & 0x001f) << 3; // R *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
@ -242,7 +242,7 @@ bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix)
#endif #endif
} }
void utilPutDword(u8 *p, u32 value) void utilPutDword(uint8_t *p, uint32_t value)
{ {
*p++ = value & 255; *p++ = value & 255;
*p++ = (value >> 8) & 255; *p++ = (value >> 8) & 255;
@ -250,15 +250,15 @@ void utilPutDword(u8 *p, u32 value)
*p = (value >> 24) & 255; *p = (value >> 24) & 255;
} }
void utilPutWord(u8 *p, u16 value) void utilPutWord(uint8_t *p, uint16_t value)
{ {
*p++ = value & 255; *p++ = value & 255;
*p = (value >> 8) & 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"); FILE *fp = fopen(fileName, "wb");
@ -268,29 +268,29 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
} }
struct { struct {
u8 ident[2]; uint8_t ident[2];
u8 filesize[4]; uint8_t filesize[4];
u8 reserved[4]; uint8_t reserved[4];
u8 dataoffset[4]; uint8_t dataoffset[4];
u8 headersize[4]; uint8_t headersize[4];
u8 width[4]; uint8_t width[4];
u8 height[4]; uint8_t height[4];
u8 planes[2]; uint8_t planes[2];
u8 bitsperpixel[2]; uint8_t bitsperpixel[2];
u8 compression[4]; uint8_t compression[4];
u8 datasize[4]; uint8_t datasize[4];
u8 hres[4]; uint8_t hres[4];
u8 vres[4]; uint8_t vres[4];
u8 colors[4]; uint8_t colors[4];
u8 importantcolors[4]; uint8_t importantcolors[4];
// u8 pad[2]; // uint8_t pad[2];
} bmpheader; } bmpheader;
memset(&bmpheader, 0, sizeof(bmpheader)); memset(&bmpheader, 0, sizeof(bmpheader));
bmpheader.ident[0] = 'B'; bmpheader.ident[0] = 'B';
bmpheader.ident[1] = 'M'; 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.filesize, fsz);
utilPutDword(bmpheader.dataoffset, 0x36); utilPutDword(bmpheader.dataoffset, 0x36);
utilPutDword(bmpheader.headersize, 0x28); 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); fwrite(&bmpheader, 1, sizeof(bmpheader), fp);
u8 *b = writeBuffer; uint8_t *b = writeBuffer;
int sizeX = w; int sizeX = w;
int sizeY = h; int sizeY = h;
switch (systemColorDepth) { switch (systemColorDepth) {
case 16: { 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 y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
u16 v = *p++; uint16_t v = *p++;
*b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
@ -327,7 +327,7 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
} }
} break; } break;
case 24: { 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 y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
if (systemRedShift > systemBlueShift) { if (systemRedShift > systemBlueShift) {
@ -351,10 +351,10 @@ bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix)
} }
} break; } break;
case 32: { 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 y = 0; y < sizeY; y++) {
for (int x = 0; x < sizeX; x++) { for (int x = 0; x < sizeX; x++) {
u32 v = *pixU32++; uint32_t v = *pixU32++;
*b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B
*b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G
@ -544,7 +544,7 @@ static int utilGetSize(int size)
return res; 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 // find image file
char buffer[2048]; char buffer[2048];
@ -573,11 +573,11 @@ u8 *utilLoad(const char *file, bool (*accept)(const char *), u8 *data, int &size
if (size == 0) if (size == 0)
size = fileSize; size = fileSize;
u8 *image = data; uint8_t *image = data;
if (image == NULL) { if (image == NULL) {
// allocate buffer memory if none was passed to the function // allocate buffer memory if none was passed to the function
image = (u8 *)malloc(utilGetSize(size)); image = (uint8_t *)malloc(utilGetSize(size));
if (image == NULL) { if (image == NULL) {
fex_close(fe); fex_close(fe);
systemMessage(MSG_OUT_OF_MEMORY, systemMessage(MSG_OUT_OF_MEMORY,
@ -751,14 +751,14 @@ long utilGzMemTell(gzFile file)
void utilGBAFindSave(const int size) void utilGBAFindSave(const int size)
{ {
u32 *p = (u32 *)&rom[0]; uint32_t *p = (uint32_t *)&rom[0];
u32 *end = (u32 *)(&rom[0] + size); uint32_t *end = (uint32_t *)(&rom[0] + size);
int detectedSaveType = 0; int detectedSaveType = 0;
int flashSize = 0x10000; int flashSize = 0x10000;
bool rtcFound = false; bool rtcFound = false;
while (p < end) { while (p < end) {
u32 d = READ32LE(p); uint32_t d = READ32LE(p);
if (d == 0x52504545) { if (d == 0x52504545) {
if (memcmp(p, "EEPROM_", 7) == 0) { if (memcmp(p, "EEPROM_", 7) == 0) {

View File

@ -13,9 +13,9 @@ typedef struct {
bool FileExists(const char *filename); bool FileExists(const char *filename);
void utilReadScreenPixels(u8 *dest, int w, int h); void utilReadScreenPixels(uint8_t *dest, int w, int h);
bool utilWritePNGFile(const char *, int, int, u8 *); bool utilWritePNGFile(const char *, int, int, uint8_t *);
bool utilWriteBMPFile(const char *, int, int, u8 *); bool utilWriteBMPFile(const char *, int, int, uint8_t *);
void utilApplyIPS(const char *ips, uint8_t **rom, int *size); void utilApplyIPS(const char *ips, uint8_t **rom, int *size);
bool utilIsGBAImage(const char *); bool utilIsGBAImage(const char *);
bool utilIsGBImage(const char *); bool utilIsGBImage(const char *);

View File

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

View File

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

View File

@ -1,6 +1,8 @@
#ifndef PORT_H #ifndef PORT_H
#define PORT_H #define PORT_H
#include <cstdint>
#ifdef __CELLOS_LV2__ #ifdef __CELLOS_LV2__
/* PlayStation3 */ /* PlayStation3 */
#include <ppu_intrinsics.h> #include <ppu_intrinsics.h>
@ -12,7 +14,7 @@
#endif #endif
// swaps a 16-bit value // 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); 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 = aud_st->codec;
ctx->codec_id = fmt->audio_codec; ctx->codec_id = fmt->audio_codec;
ctx->codec_type = AVMEDIA_TYPE_AUDIO; 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]; ctx->sample_fmt = codec->sample_fmts[0];
// This was changed in the initial ffmpeg 3.0 update, // This was changed in the initial ffmpeg 3.0 update,
// but shouldn't (as far as I'm aware) cause problems with older versions // 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 // is the code to find the available formats & associated extensions for
// the file dialog. // the file dialog.
#include "../common/Types.h"
// return codes // return codes
// probably ought to put in own namespace, but this is good enough // probably ought to put in own namespace, but this is good enough
enum MediaRet { enum MediaRet {
@ -47,10 +45,10 @@ class MediaRecorder
// add a frame of video; width+height+depth already given // add a frame of video; width+height+depth already given
// assumes a 1-pixel border on top & right // assumes a 1-pixel border on top & right
// always assumes being passed 1/60th of a second of video // 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 // add a frame of audio; uses current sample rate to know length
// always assumes being passed 1/60th of a second of audio. // always assumes being passed 1/60th of a second of audio.
MediaRet AddFrame(const u16 *aud); MediaRet AddFrame(const uint16_t *aud);
private: private:
static bool did_init; static bool did_init;
@ -66,8 +64,8 @@ class MediaRecorder
#endif #endif
priv_AVFormatContext *oc; priv_AVFormatContext *oc;
priv_AVStream *vid_st, *aud_st; priv_AVStream *vid_st, *aud_st;
u8 *audio_buf, *video_buf; uint8_t *audio_buf, *video_buf;
u16 *audio_buf2; uint16_t *audio_buf2;
int frame_len, sample_len, in_audio_buf2; int frame_len, sample_len, in_audio_buf2;
int linesize, pixsize; int linesize, pixsize;
priv_PixelFormat pixfmt; priv_PixelFormat pixfmt;

View File

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

View File

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

View File

@ -10,19 +10,19 @@
((g) >> 3) << systemGreenShift |\ ((g) >> 3) << systemGreenShift |\
((b) >> 3) << systemBlueShift\ ((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; uint8_t *copy_start = row + src_width*3;
u8 *all_stop = row + width*3; uint8_t *all_stop = row + width*3;
while (row < copy_start) { while (row < copy_start) {
u16 color = *from++; uint16_t color = *from++;
*row++ = ((color >> systemRedShift) & 0x1f) << 3; *row++ = ((color >> systemRedShift) & 0x1f) << 3;
*row++ = ((color >> systemGreenShift) & 0x1f) << 3; *row++ = ((color >> systemGreenShift) & 0x1f) << 3;
*row++ = ((color >> systemBlueShift) & 0x1f) << 3; *row++ = ((color >> systemBlueShift) & 0x1f) << 3;
} }
// any remaining elements to be written to 'row' are a replica of the // any remaining elements to be written to 'row' are a replica of the
// preceding pixel // preceding pixel
u8 *p = row-3; uint8_t *p = row-3;
while (row < all_stop) { while (row < all_stop) {
// we're guaranteed three elements per pixel; could unroll the loop // we're guaranteed three elements per pixel; could unroll the loop
// further, especially with a Duff's Device, but the gains would be // 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; uint8_t *copy_start = row + src_width*3;
u8 *all_stop = row + width*3; uint8_t *all_stop = row + width*3;
while (row < copy_start) { while (row < copy_start) {
u32 color = *from++; uint32_t color = *from++;
*row++ = ((color >> systemRedShift) & 0x1f) << 3; *row++ = ((color >> systemRedShift) & 0x1f) << 3;
*row++ = ((color >> systemGreenShift) & 0x1f) << 3; *row++ = ((color >> systemGreenShift) & 0x1f) << 3;
*row++ = ((color >> systemBlueShift) & 0x1f) << 3; *row++ = ((color >> systemBlueShift) & 0x1f) << 3;
} }
// any remaining elements to be written to 'row' are a replica of the // any remaining elements to be written to 'row' are a replica of the
// preceding pixel // preceding pixel
u8 *p = row-3; uint8_t *p = row-3;
while (row < all_stop) { while (row < all_stop) {
// we're guaranteed three elements per pixel; could unroll the loop // we're guaranteed three elements per pixel; could unroll the loop
// further, especially with a Duff's Device, but the gains would be // 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 */, void Bilinear(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u8 row_cur[3*322]; uint8_t row_cur[3*322];
u8 row_next[3*322]; uint8_t row_next[3*322];
u8 *rgb_row_cur = row_cur; uint8_t *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next; uint8_t *rgb_row_next = row_next;
u16 *to = (u16 *)dstPtr; uint16_t *to = (uint16_t *)dstPtr;
u16 *to_odd = (u16 *)(dstPtr + dstPitch); uint16_t *to_odd = (uint16_t *)(dstPtr + dstPitch);
int from_width = width; 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); fill_rgb_row_16(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) { for(int y = 0; y < height; y++) {
u16 *from_orig = from; uint16_t *from_orig = from;
u16 *to_orig = to; uint16_t *to_orig = to;
if (y+1 < height) if (y+1 < height)
fill_rgb_row_16(from+width+2, from_width, rgb_row_next, 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 // 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 // right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down // the right and down
u8 *cur_row = rgb_row_cur; uint8_t *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next; uint8_t *next_row = rgb_row_next;
u8 *ar = cur_row++; uint8_t *ar = cur_row++;
u8 *ag = cur_row++; uint8_t *ag = cur_row++;
u8 *ab = cur_row++; uint8_t *ab = cur_row++;
u8 *cr = next_row++; uint8_t *cr = next_row++;
u8 *cg = next_row++; uint8_t *cg = next_row++;
u8 *cb = next_row++; uint8_t *cb = next_row++;
for(int x=0; x < width; x++) { for(int x=0; x < width; x++) {
u8 *br = cur_row++; uint8_t *br = cur_row++;
u8 *bg = cur_row++; uint8_t *bg = cur_row++;
u8 *bb = cur_row++; uint8_t *bb = cur_row++;
u8 *dr = next_row++; uint8_t *dr = next_row++;
u8 *dg = next_row++; uint8_t *dg = next_row++;
u8 *db = next_row++; uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in // upper left pixel in quad: just copy it in
*to++ = RGB(*ar, *ag, *ab); *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 // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; uint8_t *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u16 *)((u8 *)from_orig + srcPitch); from = (uint16_t *)((uint8_t *)from_orig + srcPitch);
to = (u16 *)((u8 *)to_orig + (dstPitch << 1)); to = (uint16_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (u16 *)((u8 *)to + dstPitch); to_odd = (uint16_t *)((uint8_t *)to + dstPitch);
} }
} }
void BilinearPlus(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void BilinearPlus(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u8 row_cur[3*322]; uint8_t row_cur[3*322];
u8 row_next[3*322]; uint8_t row_next[3*322];
u8 *rgb_row_cur = row_cur; uint8_t *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next; uint8_t *rgb_row_next = row_next;
u16 *to = (u16 *)dstPtr; uint16_t *to = (uint16_t *)dstPtr;
u16 *to_odd = (u16 *)(dstPtr + dstPitch); uint16_t *to_odd = (uint16_t *)(dstPtr + dstPitch);
int from_width = width; 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); fill_rgb_row_16(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) { for(int y = 0; y < height; y++) {
u16 *from_orig = from; uint16_t *from_orig = from;
u16 *to_orig = to; uint16_t *to_orig = to;
if (y+1 < height) if (y+1 < height)
fill_rgb_row_16(from+width+2, from_width, rgb_row_next, 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 // 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 // right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down // the right and down
u8 *cur_row = rgb_row_cur; uint8_t *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next; uint8_t *next_row = rgb_row_next;
u8 *ar = cur_row++; uint8_t *ar = cur_row++;
u8 *ag = cur_row++; uint8_t *ag = cur_row++;
u8 *ab = cur_row++; uint8_t *ab = cur_row++;
u8 *cr = next_row++; uint8_t *cr = next_row++;
u8 *cg = next_row++; uint8_t *cg = next_row++;
u8 *cb = next_row++; uint8_t *cb = next_row++;
for(int x=0; x < width; x++) { for(int x=0; x < width; x++) {
u8 *br = cur_row++; uint8_t *br = cur_row++;
u8 *bg = cur_row++; uint8_t *bg = cur_row++;
u8 *bb = cur_row++; uint8_t *bb = cur_row++;
u8 *dr = next_row++; uint8_t *dr = next_row++;
u8 *dg = next_row++; uint8_t *dg = next_row++;
u8 *db = next_row++; uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in // upper left pixel in quad: just copy it in
//*to++ = manip.rgb(*ar, *ag, *ab); //*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 // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; uint8_t *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u16 *)((u8 *)from_orig + srcPitch); from = (uint16_t *)((uint8_t *)from_orig + srcPitch);
to = (u16 *)((u8 *)to_orig + (dstPitch << 1)); to = (uint16_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (u16 *)((u8 *)to + dstPitch); to_odd = (uint16_t *)((uint8_t *)to + dstPitch);
} }
} }
void Bilinear32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void Bilinear32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u8 row_cur[3*322]; uint8_t row_cur[3*322];
u8 row_next[3*322]; uint8_t row_next[3*322];
u8 *rgb_row_cur = row_cur; uint8_t *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next; uint8_t *rgb_row_next = row_next;
u32 *to = (u32 *)dstPtr; uint32_t *to = (uint32_t *)dstPtr;
u32 *to_odd = (u32 *)(dstPtr + dstPitch); uint32_t *to_odd = (uint32_t *)(dstPtr + dstPitch);
int from_width = width; 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); fill_rgb_row_32(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) { for(int y = 0; y < height; y++) {
u32 *from_orig = from; uint32_t *from_orig = from;
u32 *to_orig = to; uint32_t *to_orig = to;
if (y+1 < height) if (y+1 < height)
fill_rgb_row_32(from+width+1, from_width, rgb_row_next, 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 // 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 // right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down // the right and down
u8 *cur_row = rgb_row_cur; uint8_t *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next; uint8_t *next_row = rgb_row_next;
u8 *ar = cur_row++; uint8_t *ar = cur_row++;
u8 *ag = cur_row++; uint8_t *ag = cur_row++;
u8 *ab = cur_row++; uint8_t *ab = cur_row++;
u8 *cr = next_row++; uint8_t *cr = next_row++;
u8 *cg = next_row++; uint8_t *cg = next_row++;
u8 *cb = next_row++; uint8_t *cb = next_row++;
for(int x=0; x < width; x++) { for(int x=0; x < width; x++) {
u8 *br = cur_row++; uint8_t *br = cur_row++;
u8 *bg = cur_row++; uint8_t *bg = cur_row++;
u8 *bb = cur_row++; uint8_t *bb = cur_row++;
u8 *dr = next_row++; uint8_t *dr = next_row++;
u8 *dg = next_row++; uint8_t *dg = next_row++;
u8 *db = next_row++; uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in // upper left pixel in quad: just copy it in
*to++ = RGB(*ar, *ag, *ab); *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 // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; uint8_t *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u32 *)((u8 *)from_orig + srcPitch); from = (uint32_t *)((uint8_t *)from_orig + srcPitch);
to = (u32 *)((u8 *)to_orig + (dstPitch << 1)); to = (uint32_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (u32 *)((u8 *)to + dstPitch); to_odd = (uint32_t *)((uint8_t *)to + dstPitch);
} }
} }
void BilinearPlus32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void BilinearPlus32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u8 row_cur[3*322]; uint8_t row_cur[3*322];
u8 row_next[3*322]; uint8_t row_next[3*322];
u8 *rgb_row_cur = row_cur; uint8_t *rgb_row_cur = row_cur;
u8 *rgb_row_next = row_next; uint8_t *rgb_row_next = row_next;
u32 *to = (u32 *)dstPtr; uint32_t *to = (uint32_t *)dstPtr;
u32 *to_odd = (u32 *)(dstPtr + dstPitch); uint32_t *to_odd = (uint32_t *)(dstPtr + dstPitch);
int from_width = width; 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); fill_rgb_row_32(from, from_width, rgb_row_cur, width+1);
for(int y = 0; y < height; y++) { for(int y = 0; y < height; y++) {
u32 *from_orig = from; uint32_t *from_orig = from;
u32 *to_orig = to; uint32_t *to_orig = to;
if (y+1 < height) if (y+1 < height)
fill_rgb_row_32(from+width+1, from_width, rgb_row_next, 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 // 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 // right, 'c' is the src pixel below, and 'd' is the src pixel to
// the right and down // the right and down
u8 *cur_row = rgb_row_cur; uint8_t *cur_row = rgb_row_cur;
u8 *next_row = rgb_row_next; uint8_t *next_row = rgb_row_next;
u8 *ar = cur_row++; uint8_t *ar = cur_row++;
u8 *ag = cur_row++; uint8_t *ag = cur_row++;
u8 *ab = cur_row++; uint8_t *ab = cur_row++;
u8 *cr = next_row++; uint8_t *cr = next_row++;
u8 *cg = next_row++; uint8_t *cg = next_row++;
u8 *cb = next_row++; uint8_t *cb = next_row++;
for(int x=0; x < width; x++) { for(int x=0; x < width; x++) {
u8 *br = cur_row++; uint8_t *br = cur_row++;
u8 *bg = cur_row++; uint8_t *bg = cur_row++;
u8 *bb = cur_row++; uint8_t *bb = cur_row++;
u8 *dr = next_row++; uint8_t *dr = next_row++;
u8 *dg = next_row++; uint8_t *dg = next_row++;
u8 *db = next_row++; uint8_t *db = next_row++;
// upper left pixel in quad: just copy it in // upper left pixel in quad: just copy it in
//*to++ = manip.rgb(*ar, *ag, *ab); //*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 // the "next" rgb row becomes the current; the old current rgb row is
// recycled and serves as the new "next" row // recycled and serves as the new "next" row
u8 *temp; uint8_t *temp;
temp = rgb_row_cur; temp = rgb_row_cur;
rgb_row_cur = rgb_row_next; rgb_row_cur = rgb_row_next;
rgb_row_next = temp; rgb_row_next = temp;
// update the pointers for start of next pair of lines // update the pointers for start of next pair of lines
from = (u32 *)((u8 *)from_orig + srcPitch); from = (uint32_t *)((uint8_t *)from_orig + srcPitch);
to = (u32 *)((u8 *)to_orig + (dstPitch << 1)); to = (uint32_t *)((uint8_t *)to_orig + (dstPitch << 1));
to_odd = (u32 *)((u8 *)to + dstPitch); 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],eax
mov [edi+ebx*2+4],dx mov [edi+ebx*2+4],dx
jmp .loopx_end jmp .loopx_end
..@cross8 ..@crosint8_t
mov edx,eax mov edx,eax
shl eax,16 shl eax,16
or eax,edx or eax,edx
@ -2526,6 +2526,6 @@ FuncTable
FuncTable2 FuncTable2
dd ..@cross0, ..@cross1, ..@cross2, ..@flag0, dd ..@cross0, ..@cross1, ..@cross2, ..@flag0,
dd ..@cross4, ..@flag0, ..@flag0, ..@flag0, dd ..@cross4, ..@flag0, ..@flag0, ..@flag0,
dd ..@cross8, ..@flag0, ..@flag0, ..@flag0, dd ..@crosint8_t, ..@flag0, ..@flag0, ..@flag0,
dd ..@flag0, ..@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+4],eax
mov [edi+ebx*2+8],edx mov [edi+ebx*2+8],edx
jmp .loopx_end jmp .loopx_end
..@cross8 ..@crosint8_t
mov ecx,[ebp-w8] mov ecx,[ebp-w8]
mov edx,eax mov edx,eax
shl edx,2 shl edx,2
@ -2570,6 +2570,6 @@ FuncTable
FuncTable2 FuncTable2
dd ..@cross0, ..@cross1, ..@cross2, ..@crossN, dd ..@cross0, ..@cross1, ..@cross2, ..@crossN,
dd ..@cross4, ..@crossN, ..@crossN, ..@crossN, dd ..@cross4, ..@crossN, ..@crossN, ..@crossN,
dd ..@cross8, ..@crossN, ..@crossN, ..@crossN, dd ..@crosint8_t, ..@crossN, ..@crossN, ..@crossN,
dd ..@crossN, ..@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 * 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; unsigned i;
for(i=0;i<count;++i) { for(i=0;i<count;++i) {
unsigned char mask; unsigned char mask;
u16 c[9]; uint16_t c[9];
c[1] = src0[0]; c[1] = src0[0];
c[4] = src1[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; unsigned i;
for(i=0;i<count;++i) { for(i=0;i<count;++i) {
unsigned char mask; unsigned char mask;
u32 c[9]; uint32_t c[9];
c[1] = src0[0]; c[1] = src0[0];
c[4] = src1[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 * 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; unsigned i;
for(i=0;i<count;++i) { for(i=0;i<count;++i) {
unsigned char mask; unsigned char mask;
u16 c[9]; uint16_t c[9];
c[1] = src0[0]; c[1] = src0[0];
c[4] = src1[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; unsigned i;
for(i=0;i<count;++i) { for(i=0;i<count;++i) {
unsigned char mask; unsigned char mask;
u32 c[9]; uint32_t c[9];
c[1] = src0[0]; c[1] = src0[0];
c[4] = src1[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 */, void hq2x(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u16 *dst0 = (u16 *)dstPtr; uint16_t *dst0 = (uint16_t *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1); uint16_t *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr; uint16_t *src0 = (uint16_t *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1); uint16_t *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1); uint16_t *src2 = src1 + (srcPitch >> 1);
hq2x_16_def(dst0, dst1, src0, src0, src1, width); 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); hq2x_16_def(dst0, dst1, src0, src1, src1, width);
} }
void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void hq2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u32 *dst0 = (u32 *)dstPtr; uint32_t *dst0 = (uint32_t *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2); uint32_t *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr; uint32_t *src0 = (uint32_t *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2); uint32_t *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2); uint32_t *src2 = src1 + (srcPitch >> 2);
hq2x_32_def(dst0, dst1, src0, src0, src1, width); hq2x_32_def(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;
@ -541,15 +541,15 @@ void hq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */,
hq2x_32_def(dst0, dst1, src0, src1, src1, width); hq2x_32_def(dst0, dst1, src0, src1, src1, width);
} }
void lq2x(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void lq2x(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u16 *dst0 = (u16 *)dstPtr; uint16_t *dst0 = (uint16_t *)dstPtr;
u16 *dst1 = dst0 + (dstPitch >> 1); uint16_t *dst1 = dst0 + (dstPitch >> 1);
u16 *src0 = (u16 *)srcPtr; uint16_t *src0 = (uint16_t *)srcPtr;
u16 *src1 = src0 + (srcPitch >> 1); uint16_t *src1 = src0 + (srcPitch >> 1);
u16 *src2 = src1 + (srcPitch >> 1); uint16_t *src2 = src1 + (srcPitch >> 1);
lq2x_16_def(dst0, dst1, src0, src0, src1, width); 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); lq2x_16_def(dst0, dst1, src0, src1, src1, width);
} }
void lq2x32(u8 *srcPtr, u32 srcPitch, u8 * /* deltaPtr */, void lq2x32(uint8_t *srcPtr, uint32_t srcPitch, uint8_t * /* deltaPtr */,
u8 *dstPtr, u32 dstPitch, int width, int height) uint8_t *dstPtr, uint32_t dstPitch, int width, int height)
{ {
u32 *dst0 = (u32 *)dstPtr; uint32_t *dst0 = (uint32_t *)dstPtr;
u32 *dst1 = dst0 + (dstPitch >> 2); uint32_t *dst1 = dst0 + (dstPitch >> 2);
u32 *src0 = (u32 *)srcPtr; uint32_t *src0 = (uint32_t *)srcPtr;
u32 *src1 = src0 + (srcPitch >> 2); uint32_t *src1 = src0 + (srcPitch >> 2);
u32 *src2 = src1 + (srcPitch >> 2); uint32_t *src2 = src1 + (srcPitch >> 2);
lq2x_32_def(dst0, dst1, src0, src0, src1, width); lq2x_32_def(dst0, dst1, src0, src0, src1, width);
int count = height; int count = height;

View File

@ -12,20 +12,20 @@ extern "C" bool cpu_mmx;
Incorporated into vba by Anthony Di Franco Incorporated into vba by Anthony Di Franco
*/ */
static u8 *frm1 = NULL; static uint8_t *frm1 = NULL;
static u8 *frm2 = NULL; static uint8_t *frm2 = NULL;
static u8 *frm3 = NULL; static uint8_t *frm3 = NULL;
extern int RGB_LOW_BITS_MASK; extern int RGB_LOW_BITS_MASK;
extern u32 qRGB_COLOR_MASK[2]; extern uint32_t qRGB_COLOR_MASK[2];
static void Init() static void Init()
{ {
frm1 = (u8 *)calloc(322*242,4); frm1 = (uint8_t *)calloc(322*242,4);
// 1 frame ago // 1 frame ago
frm2 = (u8 *)calloc(322*242,4); frm2 = (uint8_t *)calloc(322*242,4);
// 2 frames ago // 2 frames ago
frm3 = (u8 *)calloc(322*242,4); frm3 = (uint8_t *)calloc(322*242,4);
// 3 frames ago // 3 frames ago
} }
@ -41,12 +41,12 @@ void InterframeCleanup()
} }
#ifdef MMX #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; uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + srcPitch * starty / 2; uint16_t *src1 = (uint16_t *)frm1 + srcPitch * starty / 2;
u16 *src2 = (u16 *)frm2 + srcPitch * starty / 2; uint16_t *src2 = (uint16_t *)frm2 + srcPitch * starty / 2;
u16 *src3 = (u16 *)frm3 + srcPitch * starty / 2; uint16_t *src3 = (uint16_t *)frm3 + srcPitch * starty / 2;
int count = width >> 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 */ /* Swap buffers around */
u8 *temp = frm1; uint8_t *temp = frm1;
frm1 = frm3; frm1 = frm3;
frm3 = frm2; frm3 = frm2;
frm2 = temp; frm2 = temp;
} }
#endif #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) { if(frm1 == NULL) {
Init(); Init();
@ -171,19 +171,19 @@ void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
} }
#endif #endif
u16 colorMask = ~RGB_LOW_BITS_MASK; uint16_t colorMask = ~RGB_LOW_BITS_MASK;
u16 *src0 = (u16 *)srcPtr + starty * srcPitch / 2; uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + srcPitch * starty / 2; uint16_t *src1 = (uint16_t *)frm1 + srcPitch * starty / 2;
u16 *src2 = (u16 *)frm2 + srcPitch * starty / 2; uint16_t *src2 = (uint16_t *)frm2 + srcPitch * starty / 2;
u16 *src3 = (u16 *)frm3 + srcPitch * starty / 2; uint16_t *src3 = (uint16_t *)frm3 + srcPitch * starty / 2;
int sPitch = srcPitch >> 1; int sPitch = srcPitch >> 1;
int pos = 0; int pos = 0;
for (int j = 0; j < height; j++) for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) { for (int i = 0; i < sPitch; i++) {
u16 color = src0[pos]; uint16_t color = src0[pos];
src0[pos] = src0[pos] =
(src1[pos] != src2[pos]) && (src1[pos] != src2[pos]) &&
(src3[pos] != color) && (src3[pos] != color) &&
@ -195,24 +195,24 @@ void SmartIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
} }
/* Swap buffers around */ /* Swap buffers around */
u8 *temp = frm1; uint8_t *temp = frm1;
frm1 = frm3; frm1 = frm3;
frm3 = frm2; frm3 = frm2;
frm2 = temp; 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); SmartIB(srcPtr, srcPitch, width, 0, height);
} }
#ifdef MMX #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; uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4; uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
u32 *src2 = (u32 *)frm2 + starty * srcPitch / 4; uint32_t *src2 = (uint32_t *)frm2 + starty * srcPitch / 4;
u32 *src3 = (u32 *)frm3 + starty * srcPitch / 4; uint32_t *src3 = (uint32_t *)frm3 + starty * srcPitch / 4;
int count = width >> 1; int count = width >> 1;
@ -318,14 +318,14 @@ static void SmartIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, int h
src3++; src3++;
} }
/* Swap buffers around */ /* Swap buffers around */
u8 *temp = frm1; uint8_t *temp = frm1;
frm1 = frm3; frm1 = frm3;
frm3 = frm2; frm3 = frm2;
frm2 = temp; frm2 = temp;
} }
#endif #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) { if(frm1 == NULL) {
Init(); Init();
@ -337,19 +337,19 @@ void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
} }
#endif #endif
u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4; uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4; uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
u32 *src2 = (u32 *)frm2 + starty * srcPitch / 4; uint32_t *src2 = (uint32_t *)frm2 + starty * srcPitch / 4;
u32 *src3 = (u32 *)frm3 + starty * srcPitch / 4; uint32_t *src3 = (uint32_t *)frm3 + starty * srcPitch / 4;
u32 colorMask = 0xfefefe; uint32_t colorMask = 0xfefefe;
int sPitch = srcPitch >> 2; int sPitch = srcPitch >> 2;
int pos = 0; int pos = 0;
for (int j = 0; j < height; j++) for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) { for (int i = 0; i < sPitch; i++) {
u32 color = src0[pos]; uint32_t color = src0[pos];
src0[pos] = src0[pos] =
(src1[pos] != src2[pos]) && (src1[pos] != src2[pos]) &&
(src3[pos] != color) && (src3[pos] != color) &&
@ -361,22 +361,22 @@ void SmartIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
} }
/* Swap buffers around */ /* Swap buffers around */
u8 *temp = frm1; uint8_t *temp = frm1;
frm1 = frm3; frm1 = frm3;
frm3 = frm2; frm3 = frm2;
frm2 = temp; 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); SmartIB32(srcPtr, srcPitch, width, 0, height);
} }
#ifdef MMX #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; uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + starty * srcPitch / 2; uint16_t *src1 = (uint16_t *)frm1 + starty * srcPitch / 2;
int count = width >> 2; int count = width >> 2;
@ -441,7 +441,7 @@ static void MotionBlurIB_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty, in
} }
#endif #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) { if(frm1 == NULL) {
Init(); Init();
@ -454,17 +454,17 @@ void MotionBlurIB(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
} }
#endif #endif
u16 colorMask = ~RGB_LOW_BITS_MASK; uint16_t colorMask = ~RGB_LOW_BITS_MASK;
u16 *src0 = (u16 *)srcPtr + starty * srcPitch / 2; uint16_t *src0 = (uint16_t *)srcPtr + starty * srcPitch / 2;
u16 *src1 = (u16 *)frm1 + starty * srcPitch / 2; uint16_t *src1 = (uint16_t *)frm1 + starty * srcPitch / 2;
int sPitch = srcPitch >> 1; int sPitch = srcPitch >> 1;
int pos = 0; int pos = 0;
for (int j = 0; j < height; j++) for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) { for (int i = 0; i < sPitch; i++) {
u16 color = src0[pos]; uint16_t color = src0[pos];
src0[pos] = src0[pos] =
(((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1)); (((color & colorMask) >> 1) + ((src1[pos] & colorMask) >> 1));
src1[pos] = color; 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); MotionBlurIB(srcPtr, srcPitch, width, 0, height);
} }
#ifdef MMX #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; uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4; uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
int count = width >> 1; int count = width >> 1;
@ -546,7 +546,7 @@ static void MotionBlurIB32_MMX(u8 *srcPtr, u32 srcPitch, int width, int starty,
} }
#endif #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) { if(frm1 == NULL) {
Init(); Init();
@ -559,17 +559,17 @@ void MotionBlurIB32(u8 *srcPtr, u32 srcPitch, int width, int starty, int height)
} }
#endif #endif
u32 *src0 = (u32 *)srcPtr + starty * srcPitch / 4; uint32_t *src0 = (uint32_t *)srcPtr + starty * srcPitch / 4;
u32 *src1 = (u32 *)frm1 + starty * srcPitch / 4; uint32_t *src1 = (uint32_t *)frm1 + starty * srcPitch / 4;
u32 colorMask = 0xfefefe; uint32_t colorMask = 0xfefefe;
int sPitch = srcPitch >> 2; int sPitch = srcPitch >> 2;
int pos = 0; int pos = 0;
for (int j = 0; j < height; j++) for (int j = 0; j < height; j++)
for (int i = 0; i < sPitch; i++) { for (int i = 0; i < sPitch; i++) {
u32 color = src0[pos]; uint32_t color = src0[pos];
src0[pos] = (((color & colorMask) >> 1) + src0[pos] = (((color & colorMask) >> 1) +
((src1[pos] & colorMask) >> 1)); ((src1[pos] & colorMask) >> 1));
src1[pos] = color; 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); 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_1(v) (v & interp_mask[0])
#define INTERP_16_MASK_2(v) (v & interp_mask[1]) #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 + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 5 + INTERP_16_MASK_1(p2) * 2 +
INTERP_16_MASK_1(p3) * 1) / INTERP_16_MASK_1(p3) * 1) /
@ -60,7 +60,7 @@ static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3)
8); 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 + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 3 + INTERP_16_MASK_1(p2) * 3 +
INTERP_16_MASK_1(p3) * 2) / INTERP_16_MASK_1(p3) * 2) /
@ -70,7 +70,7 @@ static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3)
8); 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( return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8) | (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); (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) | 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); 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( return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4) | (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); (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( return INTERP_16_MASK_1(
((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) * 7 + INTERP_16_MASK_1(p3) * 2) / ((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); 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) | 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); 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) | 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); 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( return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16) | (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); (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( return INTERP_16_MASK_1(
(INTERP_16_MASK_1(p1) * 4 + INTERP_16_MASK_1(p2) * 3 + INTERP_16_MASK_1(p3)) / (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); 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) | 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); 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) | 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); 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) | 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); 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_1(v) (v & 0xFF00FF)
#define INTERP_32_MASK_2(v) (v & 0x00FF00) #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 + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 5 + INTERP_32_MASK_1(p2) * 2 +
INTERP_32_MASK_1(p3) * 1) / INTERP_32_MASK_1(p3) * 1) /
@ -163,7 +163,7 @@ static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3)
8); 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 + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 3 + INTERP_32_MASK_1(p2) * 3 +
INTERP_32_MASK_1(p3) * 2) / INTERP_32_MASK_1(p3) * 2) /
@ -173,7 +173,7 @@ static inline u32 interp_32_332(u32 p1, u32 p2, u32 p3)
8); 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( return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4) | (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); (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( return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8) | (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); (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) | 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); 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( return INTERP_32_MASK_1(
((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) * 7 + INTERP_32_MASK_1(p3) * 2) / ((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); 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) | 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); 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) | 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); 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( return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16) | (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); (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( return INTERP_32_MASK_1(
(INTERP_32_MASK_1(p1) * 4 + INTERP_32_MASK_1(p2) * 3 + INTERP_32_MASK_1(p3)) / (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); 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) | 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); 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) | 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); 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) | 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); 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_U_LIMIT (0x07 * 4)
#define INTERP_V_LIMIT (0x06 * 8) #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 r, g, b;
int y, u, v; int y, u, v;
@ -294,7 +294,7 @@ static int interp_16_diff(u16 p1, u16 p2)
return 0; 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 r, g, b;
int y, u, v; int y, u, v;

View File

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

View File

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

View File

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

View File

@ -2,27 +2,27 @@
#include "xBRZ/xbrz.h" #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); 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); 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); 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); 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); 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 #ifndef GB_H
#define GB_H #define GB_H
#define C_FLAG 0x10 const int GB_C_FLAG = 0x10;
#define H_FLAG 0x20 const int GB_H_FLAG = 0x20;
#define N_FLAG 0x40 const int GB_N_FLAG = 0x40;
#define Z_FLAG 0x80 const int GB_Z_FLAG = 0x80;
typedef union { typedef union {
struct { struct {
@ -19,7 +19,7 @@ typedef union {
extern gbRegister AF, BC, DE, HL, SP, PC; extern gbRegister AF, BC, DE, HL, SP, PC;
extern uint16_t IFF; extern uint16_t IFF;
int gbDis(char*, u16); int gbDis(char*, uint16_t);
bool gbLoadRom(const char*); bool gbLoadRom(const char*);
bool gbUpdateSizes(); bool gbUpdateSizes();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
#ifndef VBA_BKS_H #ifndef VBA_BKS_H
#define VBA_BKS_H #define VBA_BKS_H
#include <cstdint>
#define readWord(addr) \ #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)) ((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); // uint8_t printConditionalsFromAddress(uint32_t address);
// void printAllFlagConditionals(uint8_t flag, bool orMode); // void printAllFlagConditionals(uint8_t flag, bool orMode);
// void printAllFlagConditionalsWithAddress(uint32_t address, 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; return a >= b;
} }
static bool cheatSearchSignedEQ(s32 a, s32 b) static bool cheatSearchSignedEQ(int32_t a, int32_t b)
{ {
return a == b; return a == b;
} }
static bool cheatSearchSignedNE(s32 a, s32 b) static bool cheatSearchSignedNE(int32_t a, int32_t b)
{ {
return a != b; return a != b;
} }
static bool cheatSearchSignedLT(s32 a, s32 b) static bool cheatSearchSignedLT(int32_t a, int32_t b)
{ {
return a < b; return a < b;
} }
static bool cheatSearchSignedLE(s32 a, s32 b) static bool cheatSearchSignedLE(int32_t a, int32_t b)
{ {
return a <= b; return a <= b;
} }
static bool cheatSearchSignedGT(s32 a, s32 b) static bool cheatSearchSignedGT(int32_t a, int32_t b)
{ {
return a > b; return a > b;
} }
static bool cheatSearchSignedGE(s32 a, s32 b) static bool cheatSearchSignedGE(int32_t a, int32_t b)
{ {
return a >= b; return a >= b;
} }
@ -79,7 +79,7 @@ static bool (*cheatSearchFunc[])(uint32_t, uint32_t) = {
cheatSearchGE cheatSearchGE
}; };
static bool (*cheatSearchSignedFunc[])(s32, s32) = { static bool (*cheatSearchSignedFunc[])(int32_t, int32_t) = {
cheatSearchSignedEQ, cheatSearchSignedEQ,
cheatSearchSignedNE, cheatSearchSignedNE,
cheatSearchSignedLT, 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++]; uint32_t res = data[off++];
switch (size) { switch (size) {
case BITS_8: case BITS_8:
res <<= 24; res <<= 24;
return ((s32)res) >> 24; return ((int32_t)res) >> 24;
case BITS_16: case BITS_16:
res |= ((uint32_t)data[off++]) << 8; res |= ((uint32_t)data[off++]) << 8;
res <<= 16; res <<= 16;
return ((s32)res) >> 16; return ((int32_t)res) >> 16;
case BITS_32: case BITS_32:
res |= ((uint32_t)data[off++]) << 8; res |= ((uint32_t)data[off++]) << 8;
res |= ((uint32_t)data[off++]) << 16; res |= ((uint32_t)data[off++]) << 16;
res |= ((uint32_t)data[off++]) << 24; 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) 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; inc = 4;
if (isSigned) { if (isSigned) {
bool (*func)(s32, s32) = cheatSearchSignedFunc[compare]; bool (*func)(int32_t, int32_t) = cheatSearchSignedFunc[compare];
for (int i = 0; i < cs->count; i++) { for (int i = 0; i < cs->count; i++) {
CheatSearchBlock* block = &cs->blocks[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) { for (int j = 0; j < size2; j += inc) {
if (IS_BIT_SET(bits, j)) { if (IS_BIT_SET(bits, j)) {
s32 a = cheatSearchSignedRead(data, j, size); int32_t a = cheatSearchSignedRead(data, j, size);
s32 b = cheatSearchSignedRead(saved, j, size); int32_t b = cheatSearchSignedRead(saved, j, size);
if (!func(a, b)) { if (!func(a, b)) {
CLEAR_BIT(bits, j); CLEAR_BIT(bits, j);
@ -225,7 +225,7 @@ void cheatSearchValue(const CheatSearchData* cs, int compare, int size,
inc = 4; inc = 4;
if (isSigned) { if (isSigned) {
bool (*func)(s32, s32) = cheatSearchSignedFunc[compare]; bool (*func)(int32_t, int32_t) = cheatSearchSignedFunc[compare];
for (int i = 0; i < cs->count; i++) { for (int i = 0; i < cs->count; i++) {
CheatSearchBlock* block = &cs->blocks[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) { for (int j = 0; j < size2; j += inc) {
if (IS_BIT_SET(bits, j)) { if (IS_BIT_SET(bits, j)) {
s32 a = cheatSearchSignedRead(data, j, size); int32_t a = cheatSearchSignedRead(data, j, size);
s32 b = (s32)value; int32_t b = (int32_t)value;
if (!func(a, b)) { if (!func(a, b)) {
CLEAR_BIT(bits, j); CLEAR_BIT(bits, j);

View File

@ -1021,62 +1021,62 @@ int cheatsCheckKeys(uint32_t keys, uint32_t extended)
i += 2; i += 2;
break; break;
case GSA_8_BIT_IF_LOWER_S: 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++; i++;
} }
break; break;
case GSA_16_BIT_IF_LOWER_S: 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++; i++;
} }
break; break;
case GSA_32_BIT_IF_LOWER_S: 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++; i++;
} }
break; break;
case GSA_8_BIT_IF_HIGHER_S: 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++; i++;
} }
break; break;
case GSA_16_BIT_IF_HIGHER_S: 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++; i++;
} }
break; break;
case GSA_32_BIT_IF_HIGHER_S: 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++; i++;
} }
break; break;
case GSA_8_BIT_IF_LOWER_S2: 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; i += 2;
} }
break; break;
case GSA_16_BIT_IF_LOWER_S2: 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; i += 2;
} }
break; break;
case GSA_32_BIT_IF_LOWER_S2: 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; i += 2;
} }
break; break;
case GSA_8_BIT_IF_HIGHER_S2: 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; i += 2;
} }
break; break;
case GSA_16_BIT_IF_HIGHER_S2: 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; i += 2;
} }
break; break;
case GSA_32_BIT_IF_HIGHER_S2: 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; i += 2;
} }
break; break;
@ -1123,32 +1123,32 @@ int cheatsCheckKeys(uint32_t keys, uint32_t extended)
} }
break; break;
case GSA_8_BIT_IF_LOWER_S3: 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; onoff = false;
} }
break; break;
case GSA_16_BIT_IF_LOWER_S3: 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; onoff = false;
} }
break; break;
case GSA_32_BIT_IF_LOWER_S3: 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; onoff = false;
} }
break; break;
case GSA_8_BIT_IF_HIGHER_S3: 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; onoff = false;
} }
break; break;
case GSA_16_BIT_IF_HIGHER_S3: 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; onoff = false;
} }
break; break;
case GSA_32_BIT_IF_HIGHER_S3: 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; onoff = false;
} }
break; break;

View File

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

View File

@ -1,6 +1,9 @@
#ifndef FLASH_H #ifndef FLASH_H
#define FLASH_H #define FLASH_H
#include <cstdint>
#include <zlib.h>
#define FLASH_128K_SZ 0x20000 #define FLASH_128K_SZ 0x20000
#ifdef __LIBRETRO__ #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; \ 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; 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 #ifndef ALU_INIT_C
#define ALU_INIT_C \ #define ALU_INIT_C \
int dest = (opcode >> 12) & 15; \ int dest = (opcode >> 12) & 15; maybe_unused(dest); \
bool C_OUT = C_FLAG; \ bool C_OUT = C_FLAG; maybe_unused(C_OUT); \
uint32_t value; uint32_t value; maybe_unused(value);
#endif #endif
// OP Rd,Rb,Rm LSL # // OP Rd,Rb,Rm LSL #
#ifndef VALUE_LSL_IMM_C #ifndef VALUE_LSL_IMM_C
@ -1250,6 +1252,11 @@ DEFINE_ALU_INSN_C(1F, 3F, MVNS, YES)
busPrefetchCount = ((busPrefetchCount + 1) << clockTicks) - 1; \ busPrefetchCount = ((busPrefetchCount + 1) << clockTicks) - 1; \
clockTicks += 1 + codeTicksAccess32(armNextPC); clockTicks += 1 + codeTicksAccess32(armNextPC);
typedef uint64_t u64;
typedef int64_t s64;
typedef uint64_t u32;
typedef int64_t s32;
#define OP_MUL \ #define OP_MUL \
reg[dest].I = reg[mult].I * rs; reg[dest].I = reg[mult].I * rs;
#define OP_MLA \ #define OP_MLA \
@ -2974,4 +2981,4 @@ int armExecute()
} while (cpuTotalTicks < cpuNextEvent && armState && !holdState && !SWITicks && !debugger); } while (cpuTotalTicks < cpuNextEvent && armState && !holdState && !SWITicks && !debugger);
return 1; 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 #ifdef TILED_RENDERING
union u8h { union uint8_th {
struct struct
{ {
/* 0*/ unsigned lo : 4; /* 0*/ unsigned lo : 4;
@ -4316,7 +4316,7 @@ inline const TileLine gfxReadTilePal(const uint16_t* screenSource, const int yyy
palette += tile.palette * 16; palette += tile.palette * 16;
TileLine tileLine; 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) { if (!tile.hFlip) {
gfxDrawPixel(&tileLine.pixels[0], tileBase[0].lo, palette, prio); gfxDrawPixel(&tileLine.pixels[0], tileBase[0].lo, palette, prio);

View File

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

View File

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

View File

@ -108,14 +108,14 @@ extern int GetLinkPlayerId();
* *
* @param siocnt the value of SIOCNT to be written * @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 * Start a general purpose link transfer
* *
* @param rcnt the value of RCNT to be written * @param rcnt the value of RCNT to be written
*/ */
extern void StartGPLink(u16 rcnt); extern void StartGPLink(uint16_t rcnt);
/** /**
* Emulate the linked device * 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?) #define RF_CNT 0x27a // Unknown, Seems to be related to Wireless Adapter(RF_SIOCNT?)
typedef struct { typedef struct {
u8 len; // data len in 32bit words uint8_t len; // data len in 32bit words
u8 gbaid; // source id uint8_t gbaid; // source id
u32 time; // linktime uint32_t time; // linktime
u32 data[255]; uint32_t data[255];
} rfu_datarec; } rfu_datarec;
extern u8 gbSIO_SC; extern uint8_t gbSIO_SC;
extern bool LinkIsWaiting; extern bool LinkIsWaiting;
extern bool LinkFirstTime; extern bool LinkFirstTime;
extern bool EmuReseted; extern bool EmuReseted;
extern void gbInitLink(); extern void gbInitLink();
extern u8 gbStartLink(u8 b); extern uint8_t gbStartLink(uint8_t b);
extern u16 gbLinkUpdate(u8 b, int gbSerialOn); extern uint16_t gbLinkUpdate(uint8_t b, int gbSerialOn);
extern void gbInitLinkIPC(); extern void gbInitLinkIPC();
extern u8 gbStartLinkIPC(u8 b); extern uint8_t gbStartLinkIPC(uint8_t b);
extern u16 gbLinkUpdateIPC(u8 b, int gbSerialOn); 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); 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(); clock_client.disconnect();
} }
u32 clock_sync_ticks = 0; uint32_t clock_sync_ticks = 0;
void GBASockClient::Send(std::vector<char> data) void GBASockClient::Send(std::vector<char> data)
{ {
@ -70,15 +70,15 @@ void GBASockClient::ReceiveClock(bool block)
if (num_received == 4) { if (num_received == 4) {
clock_sync_ticks = 0; clock_sync_ticks = 0;
for (int i = 0; i < 4; i++) 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; clock_sync += clock_sync_ticks;
} }
} }
void GBASockClient::ClockSync(u32 ticks) void GBASockClient::ClockSync(uint32_t ticks)
{ {
if (clock_sync > (s32)ticks) if (clock_sync > (int32_t)ticks)
clock_sync -= (s32)ticks; clock_sync -= (int32_t)ticks;
else else
clock_sync = 0; clock_sync = 0;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,17 +1,17 @@
#ifndef RTC_H #ifndef RTC_H
#define RTC_H #define RTC_H
u16 rtcRead(u32 address); uint16_t rtcRead(uint32_t address);
void rtcUpdateTime(int ticks); void rtcUpdateTime(int ticks);
bool rtcWrite(u32 address, u16 value); bool rtcWrite(uint32_t address, uint16_t value);
void rtcEnable(bool); void rtcEnable(bool);
void rtcEnableRumble(bool e); void rtcEnableRumble(bool e);
bool rtcIsEnabled(); bool rtcIsEnabled();
void rtcReset(); void rtcReset();
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
void rtcReadGame(const u8*& data); void rtcReadGame(const uint8_t*& data);
void rtcSaveGame(u8*& data); void rtcSaveGame(uint8_t*& data);
#else #else
void rtcReadGame(gzFile gzFile); void rtcReadGame(gzFile gzFile);
void rtcSaveGame(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 int const SOUND_CLOCK_TICKS_ = 167772; // 1/100 second
static u16 soundFinalWave[1600]; static uint16_t soundFinalWave[1600];
long soundSampleRate = 44100; long soundSampleRate = 44100;
bool soundInterpolation = true; bool soundInterpolation = true;
bool soundPaused = true; bool soundPaused = true;
@ -82,7 +82,7 @@ public:
int readIndex; int readIndex;
int count; int count;
int writeIndex; int writeIndex;
u8 fifo[32]; uint8_t fifo[32];
int dac; int dac;
private: private:
@ -155,7 +155,7 @@ void Gba_Pcm::update(int dac)
if (output) { if (output) {
blip_time_t time = blip_time(); blip_time_t time = blip_time();
dac = (s8)dac >> shift; dac = (int8_t)dac >> shift;
int delta = dac - last_amp; int delta = dac - last_amp;
if (delta) { if (delta) {
last_amp = dac; 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 // Not filled by DMA, so fill with 16 bytes of silence
int reg = which ? FIFOB_L : FIFOA_L; int reg = which ? FIFOB_L : FIFOA_L;
for (int n = 8; n--;) { for (int n = 8; n--;) {
soundEvent(reg, (u16)0); soundEvent(reg, (uint16_t)0);
soundEvent(reg + 2, (u16)0); soundEvent(reg + 2, (uint16_t)0);
} }
} }
} }
@ -256,7 +256,7 @@ static int gba_to_gb_sound(int addr)
return 0; return 0;
} }
void soundEvent(u32 address, u8 data) void soundEvent(uint32_t address, uint8_t data)
{ {
int gb_addr = gba_to_gb_sound(address); int gb_addr = gba_to_gb_sound(address);
if (gb_addr) { if (gb_addr) {
@ -294,7 +294,7 @@ static void write_SGCNT0_H(int data)
apply_volume(true); apply_volume(true);
} }
void soundEvent(u32 address, u16 data) void soundEvent(uint32_t address, uint16_t data)
{ {
switch (address) { switch (address) {
case SGCNT0_H: case SGCNT0_H:
@ -319,8 +319,8 @@ void soundEvent(u32 address, u16 data)
break; break;
default: default:
soundEvent(address & ~1, (u8)(data)); // even soundEvent(address & ~1, (uint8_t)(data)); // even
soundEvent(address | 1, (u8)(data >> 8)); // odd soundEvent(address | 1, (uint8_t)(data >> 8)); // odd
break; break;
} }
} }
@ -527,7 +527,7 @@ void soundReset()
SOUND_CLOCK_TICKS = SOUND_CLOCK_TICKS_; SOUND_CLOCK_TICKS = SOUND_CLOCK_TICKS_;
soundTicks = SOUND_CLOCK_TICKS_; soundTicks = SOUND_CLOCK_TICKS_;
soundEvent(NR52, (u8)0x80); soundEvent(NR52, (uint8_t)0x80);
} }
bool soundInit() bool soundInit()
@ -586,7 +586,7 @@ static struct {
gb_apu_state_t apu; gb_apu_state_t apu;
// old state // old state
u8 soundDSAValue; uint8_t soundDSAValue;
int soundDSBValue; int soundDSBValue;
} state; } state;
@ -650,16 +650,16 @@ static variable_desc old_gba_state[] = {
LOAD(int, pcm[0].readIndex), LOAD(int, pcm[0].readIndex),
LOAD(int, pcm[0].count), LOAD(int, pcm[0].count),
LOAD(int, pcm[0].writeIndex), 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), SKIP(int, soundDSATimer),
LOAD(u8[32], pcm[0].fifo), LOAD(uint8_t[32], pcm[0].fifo),
LOAD(u8, state.soundDSAValue), LOAD(uint8_t, state.soundDSAValue),
LOAD(int, pcm[1].readIndex), LOAD(int, pcm[1].readIndex),
LOAD(int, pcm[1].count), LOAD(int, pcm[1].count),
LOAD(int, pcm[1].writeIndex), LOAD(int, pcm[1].writeIndex),
SKIP(int, soundDSBEnabled), SKIP(int, soundDSBEnabled),
SKIP(int, soundDSBTimer), SKIP(int, soundDSBTimer),
LOAD(u8[32], pcm[1].fifo), LOAD(uint8_t[32], pcm[1].fifo),
LOAD(int, state.soundDSBValue), LOAD(int, state.soundDSBValue),
// skipped manually // skipped manually
@ -669,7 +669,7 @@ static variable_desc old_gba_state[] = {
}; };
variable_desc old_gba_state2[] = { 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, sound3Bank),
SKIP(int, sound3DataSize), SKIP(int, sound3DataSize),
SKIP(int, sound3ForcedOutput), SKIP(int, sound3ForcedOutput),
@ -682,7 +682,7 @@ static variable_desc gba_state[] = {
LOAD(int, pcm[0].readIndex), LOAD(int, pcm[0].readIndex),
LOAD(int, pcm[0].count), LOAD(int, pcm[0].count),
LOAD(int, pcm[0].writeIndex), LOAD(int, pcm[0].writeIndex),
LOAD(u8[32], pcm[0].fifo), LOAD(uint8_t[32], pcm[0].fifo),
LOAD(int, pcm[0].dac), LOAD(int, pcm[0].dac),
SKIP(int[4], room_for_expansion), SKIP(int[4], room_for_expansion),
@ -690,13 +690,13 @@ static variable_desc gba_state[] = {
LOAD(int, pcm[1].readIndex), LOAD(int, pcm[1].readIndex),
LOAD(int, pcm[1].count), LOAD(int, pcm[1].count),
LOAD(int, pcm[1].writeIndex), LOAD(int, pcm[1].writeIndex),
LOAD(u8[32], pcm[1].fifo), LOAD(uint8_t[32], pcm[1].fifo),
LOAD(int, pcm[1].dac), LOAD(int, pcm[1].dac),
SKIP(int[4], room_for_expansion), SKIP(int[4], room_for_expansion),
// APU // 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_time), // clocks until next frame sequencer action
LOAD(int, state.apu.frame_phase), // next step frame sequencer will run LOAD(int, state.apu.frame_phase), // next step frame sequencer will run
@ -727,7 +727,7 @@ static variable_desc gba_state[] = {
}; };
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
void soundSaveGame(u8*& out) void soundSaveGame(uint8_t*& out)
#else #else
void soundSaveGame(gzFile out) void soundSaveGame(gzFile out)
#endif #endif
@ -799,7 +799,7 @@ static void soundReadGameOld(gzFile in, int version)
#include <stdio.h> #include <stdio.h>
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
void soundReadGame(const u8*& in, int version) void soundReadGame(const uint8_t*& in, int version)
#else #else
void soundReadGame(gzFile in, int version) void soundReadGame(gzFile in, int version)
#endif #endif

View File

@ -58,8 +58,8 @@ extern float soundFiltering; // 0.0 = none, 1.0 = max
void soundReset(); void soundReset();
// Emulates write to sound hardware // Emulates write to sound hardware
void soundEvent(u32 addr, u8 data); void soundEvent(uint32_t addr, uint8_t data);
void soundEvent(u32 addr, u16 data); // TODO: error-prone to overload like this void soundEvent(uint32_t addr, uint16_t data); // TODO: error-prone to overload like this
// Notifies emulator that a timer has overflowed // Notifies emulator that a timer has overflowed
void soundTimerOverflow(int which); 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 // Saves/loads emulator state
#ifdef __LIBRETRO__ #ifdef __LIBRETRO__
void soundSaveGame(u8*&); void soundSaveGame(uint8_t*&);
void soundReadGame(const u8*& in, int version); void soundReadGame(const uint8_t*& in, int version);
#else #else
void soundSaveGame(gzFile); void soundSaveGame(gzFile);
void soundReadGame(gzFile, int version); void soundReadGame(gzFile, int version);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -31,7 +31,7 @@ void gbafilter_pal(uint16_t* buf, int count)
{ {
short temp[3 * 3], s; short temp[3 * 3], s;
unsigned pix; unsigned pix;
u8 red, green, blue; uint8_t red, green, blue;
while (count--) { while (count--) {
pix = *buf; pix = *buf;
@ -105,7 +105,7 @@ void gbafilter_pal32(uint32_t* buf, int count)
{ {
short temp[3 * 3], s; short temp[3 * 3], s;
unsigned pix; unsigned pix;
u8 red, green, blue; uint8_t red, green, blue;
while (count--) { while (count--) {
pix = *buf; 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 // 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 { union {
struct struct
{ {
u8 r; uint8_t r;
u8 g; uint8_t g;
u8 b; uint8_t b;
u8 a; uint8_t a;
} part; } part;
unsigned whole; unsigned whole;
} mask; } mask;

View File

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

View File

@ -1,79 +1,78 @@
#ifndef REMOTE_H #ifndef REMOTE_H
#define REMOTE_H #define REMOTE_H
#include "../common/Types.h"
#include "GBA.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) \ #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) \ #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 // 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) \ #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 debugger;
extern bool dexp_eval(char*, u32*); extern bool dexp_eval(char*, uint32_t*);
extern void dexp_setVar(char*, u32); extern void dexp_setVar(char*, uint32_t);
extern void dexp_listVars(); extern void dexp_listVars();
extern void dexp_saveVars(char*); extern void dexp_saveVars(char*);
extern void dexp_loadVars(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 debuggerBreakOnExecution(uint32_t address, uint8_t state);
bool debuggerBreakOnWrite(u32 address, u32 value, int size); bool debuggerBreakOnWrite(uint32_t address, uint32_t value, int size);
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);
bool debuggerBreakOnRead(u32 address, int size); bool debuggerBreakOnRead(uint32_t address, int size);
struct regBreak { struct regBreak {
// u8 regNum; /No longer needed // uint8_t regNum; /No longer needed
// bit 0 = equal // bit 0 = equal
// bit 1 = greater // bit 1 = greater
// bit 2 = smaller // bit 2 = smaller
// bit 3 = signed // bit 3 = signed
u8 flags; uint8_t flags;
u32 intVal; uint32_t intVal;
struct regBreak* next; struct regBreak* next;
}; };
extern u8 lowRegBreakCounter[4]; //(r0-r3) extern uint8_t lowRegBreakCounter[4]; //(r0-r3)
extern u8 medRegBreakCounter[4]; //(r4-r7) extern uint8_t medRegBreakCounter[4]; //(r4-r7)
extern u8 highRegBreakCounter[4]; //(r8-r11) extern uint8_t highRegBreakCounter[4]; //(r8-r11)
extern u8 statusRegBreakCounter[4]; //(r12-r15) extern uint8_t statusRegBreakCounter[4]; //(r12-r15)
extern bool enableRegBreak; extern bool enableRegBreak;
extern regBreak* breakRegList[16]; extern regBreak* breakRegList[16];
extern void breakReg_check(int i); extern void breakReg_check(int i);
struct regBreak* getFromBreakRegList(u8 regnum, int location); struct regBreak* getFromBreakRegList(uint8_t regnum, int location);
void clearBreakRegList(); void clearBreakRegList();
void clearParticularRegListBreaks(int reg); 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 printBreakRegList(bool verbose);
void remoteStubMain(); void remoteStubMain();
void remoteStubSignal(int sig, int number); 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 remoteSetProtocol(int p);
void remoteSetPort(int port); void remoteSetPort(int port);

View File

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

View File

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

View File

@ -33,7 +33,7 @@ ScreenAreaCairo::ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale)
vUpdateSize(); vUpdateSize();
} }
void ScreenAreaCairo::vDrawPixels(u8* _puiData) void ScreenAreaCairo::vDrawPixels(uint8_t* _puiData)
{ {
ScreenArea::vDrawPixels(_puiData); ScreenArea::vDrawPixels(_puiData);
@ -48,14 +48,14 @@ bool ScreenAreaCairo::on_expose_event(GdkEventExpose* _pstEvent)
Cairo::RefPtr<Cairo::SurfacePattern> poPattern; Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::RefPtr<Cairo::Context> poContext; Cairo::RefPtr<Cairo::Context> poContext;
Cairo::Matrix oMatrix; 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 = get_window()->create_cairo_context();
//poContext->set_identity_matrix(); //poContext->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor); 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); m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop); //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::ImageSurface> poImage;
Cairo::RefPtr<Cairo::SurfacePattern> poPattern; Cairo::RefPtr<Cairo::SurfacePattern> poPattern;
Cairo::Matrix oMatrix; 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->set_identity_matrix();
poContext->scale(m_dScaleFactor, m_dScaleFactor); 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); m_iScaledWidth, m_iScaledHeight, iScaledPitch);
//cairo_matrix_init_translate(&oMatrix, -m_iAreaLeft, -m_iAreaTop); //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() void ScreenAreaCairo::vDrawBlackScreen()
{ {
if (m_puiPixels && get_realized()) { 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()); queue_draw_area(0, 0, get_width(), get_height());
} }
} }

View File

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

View File

@ -101,7 +101,7 @@ void ScreenAreaGl::on_realize()
glwindow->gl_end(); glwindow->gl_end();
} }
void ScreenAreaGl::vDrawPixels(u8* _puiData) void ScreenAreaGl::vDrawPixels(uint8_t* _puiData)
{ {
ScreenArea::vDrawPixels(_puiData); ScreenArea::vDrawPixels(_puiData);
@ -111,7 +111,7 @@ void ScreenAreaGl::vDrawPixels(u8* _puiData)
void ScreenAreaGl::vDrawBlackScreen() void ScreenAreaGl::vDrawBlackScreen()
{ {
if (m_puiPixels && get_realized()) { 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()); 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> { class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget<ScreenAreaGl> {
public: public:
ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1); ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1);
void vDrawPixels(u8* _puiData); void vDrawPixels(uint8_t* _puiData);
void vDrawBlackScreen(); void vDrawBlackScreen();
protected: protected:

View File

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

View File

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

View File

@ -32,9 +32,9 @@ int systemColorDepth;
int systemVerbose; int systemVerbose;
int systemSaveUpdateCounter; int systemSaveUpdateCounter;
int systemFrameSkip; int systemFrameSkip;
u32 systemColorMap32[0x10000]; uint32_t systemColorMap32[0x10000];
u16 systemColorMap16[0x10000]; uint16_t systemColorMap16[0x10000];
u16 systemGbPalette[24]; uint16_t systemGbPalette[24];
int emulating; int emulating;
int RGB_LOW_BITS_MASK; int RGB_LOW_BITS_MASK;
@ -66,7 +66,7 @@ bool systemReadJoypads()
return true; return true;
} }
u32 systemReadJoypad(int joy) uint32_t systemReadJoypad(int joy)
{ {
return inputReadJoypad(joy); return inputReadJoypad(joy);
} }
@ -99,7 +99,7 @@ void systemScreenCapture(int _iNum)
->vCaptureScreen(_iNum); ->vCaptureScreen(_iNum);
} }
u32 systemGetClock() uint32_t systemGetClock()
{ {
Glib::TimeVal time; Glib::TimeVal time;
time.assign_current_time(); time.assign_current_time();
@ -110,7 +110,7 @@ void systemUpdateMotionSensor()
{ {
} }
u8 systemGetSensorDarkness() uint8_t systemGetSensorDarkness()
{ {
return 0xE8; return 0xE8;
} }
@ -134,7 +134,7 @@ void systemCartridgeRumble(bool)
{ {
} }
void systemGbPrint(u8* _puiData, void systemGbPrint(uint8_t* _puiData,
int _iLen, int _iLen,
int _iPages, int _iPages,
int _iFeed, 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; extern int RGB_LOW_BITS_MASK;
static const u16 STATE_MAX_DEFAULT = 180u; static const uint16_t STATE_MAX_DEFAULT = 180u;
static const u16 STATE_INTERVAL_DEFAULT = 165u; static const uint16_t STATE_INTERVAL_DEFAULT = 165u;
namespace VBA { namespace VBA {

View File

@ -241,9 +241,9 @@ private:
EShowSpeed m_eShowSpeed; EShowSpeed m_eShowSpeed;
/* State saving into memory & rewind to saved state */ /* State saving into memory & rewind to saved state */
u16 m_state_count_max; uint16_t m_state_count_max;
u16 m_rewind_interval; uint16_t m_rewind_interval;
static const u32 SZSTATE = 1024 * 512; static const uint32_t SZSTATE = 1024 * 512;
std::deque<char*> m_rewind_load_q; std::deque<char*> m_rewind_load_q;
char* m_psavestate; 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; const int16_t* wave = (const int16_t*)finalWave;
int frames = length >> 1; int frames = length >> 1;

View File

@ -29,7 +29,7 @@ public:
virtual void pause(); virtual void pause();
virtual void reset(); virtual void reset();
virtual void resume(); virtual void resume();
virtual void write(u16* finalWave, int length); virtual void write(uint16_t* finalWave, int length);
}; };
#endif // __VBA_SOUND_RETRO_H__ #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; return false;
} }
void utilPutDword(u8* p, u32 value) void utilPutDword(uint8_t* p, uint32_t value)
{ {
*p++ = value & 255; *p++ = value & 255;
*p++ = (value >> 8) & 255; *p++ = (value >> 8) & 255;

View File

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

View File

@ -90,7 +90,7 @@ extern void remoteInit();
extern void remoteCleanUp(); extern void remoteCleanUp();
extern void remoteStubMain(); extern void remoteStubMain();
extern void remoteStubSignal(int, int); extern void remoteStubSignal(int, int);
extern void remoteOutput(const char*, u32); extern void remoteOutput(const char*, uint32_t);
extern void remoteSetProtocol(int); extern void remoteSetProtocol(int);
extern void remoteSetPort(int); extern void remoteSetPort(int);
@ -132,7 +132,7 @@ int destHeight = 0;
int desktopWidth = 0; int desktopWidth = 0;
int desktopHeight = 0; int desktopHeight = 0;
u8* delta = NULL; uint8_t* delta = NULL;
static const int delta_size = 322 * 242 * 4; static const int delta_size = 322 * 242 * 4;
int filter_enlarge = 2; int filter_enlarge = 2;
@ -141,13 +141,13 @@ int cartridgeType = 3;
int textureSize = 256; int textureSize = 256;
GLuint screenTexture = 0; GLuint screenTexture = 0;
u8* filterPix = 0; uint8_t* filterPix = 0;
int emulating = 0; int emulating = 0;
int RGB_LOW_BITS_MASK = 0x821; int RGB_LOW_BITS_MASK = 0x821;
u32 systemColorMap32[0x10000]; uint32_t systemColorMap32[0x10000];
u16 systemColorMap16[0x10000]; uint16_t systemColorMap16[0x10000];
u16 systemGbPalette[24]; uint16_t systemGbPalette[24];
char filename[2048]; char filename[2048];
@ -190,7 +190,7 @@ enum VIDEO_SIZE {
#define _stricmp strcasecmp #define _stricmp strcasecmp
u32 throttleLastTime = 0; uint32_t throttleLastTime = 0;
bool pauseNextFrame = false; bool pauseNextFrame = false;
int sdlMirroringEnable = 1; int sdlMirroringEnable = 1;
@ -203,7 +203,7 @@ void systemConsoleMessage(const char*);
char* home; char* home;
char screenMessageBuffer[21]; char screenMessageBuffer[21];
u32 screenMessageTime = 0; uint32_t screenMessageTime = 0;
#define SOUND_MAX_VOLUME 2.0 #define SOUND_MAX_VOLUME 2.0
#define SOUND_ECHO 0.2 #define SOUND_ECHO 0.2
@ -627,7 +627,7 @@ static void sdlApplyPerImagePreferences()
fclose(f); fclose(f);
} }
static int sdlCalculateShift(u32 mask) static int sdlCalculateShift(uint32_t mask)
{ {
int m = 0; int m = 0;
@ -795,7 +795,7 @@ static void sdlResizeVideo()
if (openGL) { if (openGL) {
free(filterPix); free(filterPix);
filterPix = (u8*)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight); filterPix = (uint8_t*)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight);
sdlOpenGLVideoResize(); sdlOpenGLVideoResize();
} }
@ -856,7 +856,7 @@ void sdlInitVideo()
exit(-1); exit(-1);
} }
u32 rmask, gmask, bmask; uint32_t rmask, gmask, bmask;
#if 0 #if 0
if(openGL) { if(openGL) {
@ -947,7 +947,7 @@ void sdlInitVideo()
int scaledHeight = screenHeight * sdlOpenglScale; int scaledHeight = screenHeight * sdlOpenglScale;
free(filterPix); free(filterPix);
filterPix = (u8 *)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight); filterPix = (uint8_t *)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight);
sdlOpenGLInit(screenWidth, screenHeight); sdlOpenGLInit(screenWidth, screenHeight);
if ( (!fullScreen) if ( (!fullScreen)
@ -1833,15 +1833,15 @@ int main(int argc, char** argv)
soundInit(); soundInit();
cartridgeType = 0; cartridgeType = 0;
strcpy(filename, "gnu_stub"); strcpy(filename, "gnu_stub");
rom = (u8*)malloc(0x2000000); rom = (uint8_t*)malloc(0x2000000);
workRAM = (u8*)calloc(1, 0x40000); workRAM = (uint8_t*)calloc(1, 0x40000);
bios = (u8*)calloc(1, 0x4000); bios = (uint8_t*)calloc(1, 0x4000);
internalRAM = (u8*)calloc(1, 0x8000); internalRAM = (uint8_t*)calloc(1, 0x8000);
paletteRAM = (u8*)calloc(1, 0x400); paletteRAM = (uint8_t*)calloc(1, 0x400);
vram = (u8*)calloc(1, 0x20000); vram = (uint8_t*)calloc(1, 0x20000);
oam = (u8*)calloc(1, 0x400); oam = (uint8_t*)calloc(1, 0x400);
pix = (u8*)calloc(1, 4 * 241 * 162); pix = (uint8_t*)calloc(1, 4 * 241 * 162);
ioMem = (u8*)calloc(1, 0x400); ioMem = (uint8_t*)calloc(1, 0x400);
emulator = GBASystem; emulator = GBASystem;
@ -1917,7 +1917,7 @@ int main(int argc, char** argv)
utilUpdateSystemColorMaps(); utilUpdateSystemColorMaps();
if (delta == NULL) { if (delta == NULL) {
delta = (u8*)malloc(delta_size); delta = (uint8_t*)malloc(delta_size);
memset(delta, 255, delta_size); memset(delta, 255, delta_size);
} }
@ -2025,7 +2025,7 @@ void systemMessage(int num, const char* msg, ...)
va_end(valist); 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 (screenMessage) {
if (cartridgeType == 1 && gbBorderOn) { 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]; char buffer[50];
if (showSpeed == 1) if (showSpeed == 1)
@ -2056,14 +2056,14 @@ void drawSpeed(u8* screen, int pitch, int x, int y)
void systemDrawScreen() void systemDrawScreen()
{ {
unsigned int destPitch = destWidth * (systemColorDepth >> 3); unsigned int destPitch = destWidth * (systemColorDepth >> 3);
u8* screen; uint8_t* screen;
renderedFrames++; renderedFrames++;
if (openGL) if (openGL)
screen = filterPix; screen = filterPix;
else { else {
screen = (u8*)surface->pixels; screen = (uint8_t*)surface->pixels;
SDL_LockSurface(surface); SDL_LockSurface(surface);
} }
@ -2077,7 +2077,7 @@ void systemDrawScreen()
int bytes = (systemColorDepth >> 3); int bytes = (systemColorDepth >> 3);
for (int i = 0; i < destWidth; i++) for (int i = 0; i < destWidth; i++)
for (int j = 0; j < destHeight; j++) { for (int j = 0; j < destHeight; j++) {
u8 k; uint8_t k;
k = filterPix[i * bytes + j * destPitch + 3]; k = filterPix[i * bytes + j * destPitch + 3];
filterPix[i * bytes + j * destPitch + 3] = filterPix[i * bytes + j * destPitch + 1]; filterPix[i * bytes + j * destPitch + 3] = filterPix[i * bytes + j * destPitch + 1];
filterPix[i * bytes + j * destPitch + 1] = k; filterPix[i * bytes + j * destPitch + 1] = k;
@ -2151,9 +2151,9 @@ void systemFrame()
void system10Frames(int rate) void system10Frames(int rate)
{ {
u32 time = systemGetClock(); uint32_t time = systemGetClock();
if (!wasPaused && autoFrameSkip) { if (!wasPaused && autoFrameSkip) {
u32 diff = time - autoFrameSkipLastTime; uint32_t diff = time - autoFrameSkipLastTime;
int speed = 100; int speed = 100;
if (diff) if (diff)
@ -2234,12 +2234,12 @@ void systemLoadRecent()
// I need to be implemented // I need to be implemented
} }
u32 systemGetClock() uint32_t systemGetClock()
{ {
return SDL_GetTicks(); 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; return true;
} }
u32 systemReadJoypad(int which) uint32_t systemReadJoypad(int which)
{ {
return inputReadJoypad(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() void systemUpdateSolarSensor()
{ {
@ -2345,7 +2345,7 @@ int systemGetSensorZ()
return 0; return 0;
} }
u8 systemGetSensorDarkness() uint8_t systemGetSensorDarkness()
{ {
return 0xE8; 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) map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] = (value)
struct breakpointInfo { struct breakpointInfo {
u32 address; uint32_t address;
u32 value; uint32_t value;
int size; int size;
u32 cond_address; uint32_t cond_address;
char cond_rel; char cond_rel;
u32 cond_value; uint32_t cond_value;
int cond_size; int cond_size;
bool ia1; bool ia1;
bool ia2; bool ia2;
@ -77,13 +77,13 @@ struct DebuggerCommand {
unsigned int SearchStart = 0xFFFFFFFF; unsigned int SearchStart = 0xFFFFFFFF;
unsigned int SearchMaxMatches = 5; 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 SearchLength = 0;
unsigned int SearchResults; unsigned int SearchResults;
static void debuggerContinueAfterBreakpoint(); static void debuggerContinueAfterBreakpoint();
void debuggerDoSearch(); void debuggerDoSearch();
unsigned int AddressToGBA(u8* mem); unsigned int AddressToGBA(uint8_t* mem);
static void debuggerHelp(int, char**); static void debuggerHelp(int, char**);
static void debuggerNext(int, char**); static void debuggerNext(int, char**);
@ -199,7 +199,7 @@ bool debuggerAtBreakpoint = false;
int debuggerBreakpointNumber = 0; int debuggerBreakpointNumber = 0;
int debuggerRadix = 0; int debuggerRadix = 0;
extern u32 cpuPrefetch[2]; extern uint32_t cpuPrefetch[2];
#define ARM_PREFETCH \ #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) if (size)
debuggerWriteMemory(address, (u32)(0xe1200070 | (num & 0xf) | ((num << 4) & 0xf0))); debuggerWriteMemory(address, (uint32_t)(0xe1200070 | (num & 0xf) | ((num << 4) & 0xf0)));
else else
debuggerWriteHalfWord(address, debuggerWriteHalfWord(address,
(u16)(0xbe00 | num)); (uint16_t)(0xbe00 | num));
} }
static void debuggerDisableBreakpoints() 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, LocationType type,
int bitSize, int bitOffset) int bitSize, int bitOffset)
{ {
@ -387,12 +387,12 @@ static const char* debuggerPrintType(Type* t)
return t->name; 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, static void debuggerPrintValueInternal(Function* f, Type* t,
int bitSize, int bitOffset, 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) { switch (type) {
case LOCATION_memory: case LOCATION_memory:
@ -405,22 +405,22 @@ static u32 debuggerGetValue(u32 location, LocationType type)
return 0; return 0;
} }
static void debuggerPrintPointer(Type* t, u32 value) static void debuggerPrintPointer(Type* t, uint32_t value)
{ {
printf("(%s)0x%08x", debuggerPrintType(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); 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); printf("(%s)0x%08x", debuggerPrintType(t), value);
} }
static void debuggerPrintArray(Type* t, u32 value) static void debuggerPrintArray(Type* t, uint32_t value)
{ {
// todo // todo
printf("(%s[])0x%08x", debuggerPrintType(t->array->type), value); 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, static void debuggerPrintMember(Function* f,
Member* m, Member* m,
u32 objLocation, uint32_t objLocation,
u32 location) uint32_t location)
{ {
int bitSize = m->bitSize; int bitSize = m->bitSize;
if (bitSize) { if (bitSize) {
u32 value = 0; uint32_t value = 0;
int off = m->bitOffset; int off = m->bitOffset;
int size = m->byteSize; int size = m->byteSize;
u32 v = 0; uint32_t v = 0;
switch (size) { switch (size) {
case 1: case 1:
v = debuggerReadByte(location); 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("{"); printf("{");
int count = t->structure->memberCount; int count = t->structure->memberCount;
@ -491,7 +491,7 @@ static void debuggerPrintStructure(Function* f, Type* t, u32 objLocation)
Member* m = &t->structure->members[i]; Member* m = &t->structure->members[i];
printf("%s=", m->name); printf("%s=", m->name);
LocationType type; LocationType type;
u32 location = elfDecodeLocation(f, m->location, &type, objLocation); uint32_t location = elfDecodeLocation(f, m->location, &type, objLocation);
debuggerPrintMember(f, m, objLocation, location); debuggerPrintMember(f, m, objLocation, location);
i++; i++;
if (i < count) if (i < count)
@ -500,7 +500,7 @@ static void debuggerPrintStructure(Function* f, Type* t, u32 objLocation)
printf("}"); printf("}");
} }
static void debuggerPrintUnion(Function* f, Type* t, u32 objLocation) static void debuggerPrintUnion(Function* f, Type* t, uint32_t objLocation)
{ {
// todo // todo
printf("{"); printf("{");
@ -517,7 +517,7 @@ static void debuggerPrintUnion(Function* f, Type* t, u32 objLocation)
printf("}"); printf("}");
} }
static void debuggerPrintEnum(Type* t, u32 value) static void debuggerPrintEnum(Type* t, uint32_t value)
{ {
int i; int i;
for (i = 0; i < t->enumeration->count; 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, static void debuggerPrintValueInternal(Function* f, Type* t,
int bitSize, int bitOffset, 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) { if (!t) {
printf("void"); printf("void");
return; return;
@ -572,10 +572,10 @@ static void debuggerPrintValueInternal(Function* f, Type* t,
static void debuggerPrintValueInternal(Function* f, Type* t, ELFBlock* loc, static void debuggerPrintValueInternal(Function* f, Type* t, ELFBlock* loc,
int bitSize, int bitOffset, int bitSize, int bitOffset,
u32 objLocation) uint32_t objLocation)
{ {
LocationType type; LocationType type;
u32 location; uint32_t location;
if (loc) { if (loc) {
if (objLocation) if (objLocation)
location = elfDecodeLocation(f, loc, &type, 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) static void debuggerSymbols(int argc, char** argv)
{ {
int i = 0; int i = 0;
u32 value; uint32_t value;
u32 size; uint32_t size;
int type; int type;
bool match = false; bool match = false;
int matchSize = 0; int matchSize = 0;
@ -674,7 +674,7 @@ static void debuggerPrint(int argc, char** argv)
if (argc != 2 && argc != 3) { if (argc != 2 && argc != 3) {
debuggerUsage(argv[0]); debuggerUsage(argv[0]);
} else { } else {
u32 pc = armNextPC; uint32_t pc = armNextPC;
Function* f = NULL; Function* f = NULL;
CompileUnit* u = NULL; CompileUnit* u = NULL;
@ -780,7 +780,7 @@ static void debuggerVerbose(int n, char** args)
static void debuggerWhere(int n, char** args) static void debuggerWhere(int n, char** args)
{ {
void elfPrintCallChain(u32); void elfPrintCallChain(uint32_t);
elfPrintCallChain(armNextPC); elfPrintCallChain(armNextPC);
} }
@ -788,7 +788,7 @@ static void debuggerLocals(int n, char** args)
{ {
Function* f = NULL; Function* f = NULL;
CompileUnit* u = NULL; CompileUnit* u = NULL;
u32 pc = armNextPC; uint32_t pc = armNextPC;
if (elfGetCurrentFunction(pc, if (elfGetCurrentFunction(pc,
&f, &u)) { &f, &u)) {
Object* o = f->parameters; Object* o = f->parameters;
@ -832,7 +832,7 @@ static void debuggerNext(int n, char** args)
debuggerDisableBreakpoints(); debuggerDisableBreakpoints();
Function* f = NULL; Function* f = NULL;
CompileUnit* u = NULL; CompileUnit* u = NULL;
u32 a = armNextPC; uint32_t a = armNextPC;
if (elfGetCurrentFunction(a, &f, &u)) { if (elfGetCurrentFunction(a, &f, &u)) {
const char* file; const char* file;
int line = elfFindLine(u, f, a, &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) static void debuggerBreak(int n, char** args)
{ {
if (n == 2) { if (n == 2) {
u32 address = 0; uint32_t address = 0;
u32 value = 0; uint32_t value = 0;
int type = 0; int type = 0;
const char* s = args[1]; const char* s = args[1];
char c = *s; char c = *s;
@ -938,13 +938,13 @@ static void debuggerBreak(int n, char** args)
*l++ = 0; *l++ = 0;
int line = atoi(l); int line = atoi(l);
u32 addr; uint32_t addr;
Function* f; Function* f;
CompileUnit* u; CompileUnit* u;
if (elfFindLineInModule(&addr, name, line)) { if (elfFindLineInModule(&addr, name, line)) {
if (elfGetCurrentFunction(addr, &f, &u)) { if (elfGetCurrentFunction(addr, &f, &u)) {
u32 addr2; uint32_t addr2;
if (elfGetSymbolAddress(f->name, &addr2, &value, &type)) { if (elfGetSymbolAddress(f->name, &addr2, &value, &type)) {
address = addr; address = addr;
} else { } else {
@ -963,12 +963,12 @@ static void debuggerBreak(int n, char** args)
int line = atoi(s); int line = atoi(s);
Function* f; Function* f;
CompileUnit* u; CompileUnit* u;
u32 addr; uint32_t addr;
if (elfGetCurrentFunction(armNextPC, &f, &u)) { if (elfGetCurrentFunction(armNextPC, &f, &u)) {
if (elfFindLineInUnit(&addr, u, line)) { if (elfFindLineInUnit(&addr, u, line)) {
if (elfGetCurrentFunction(addr, &f, &u)) { if (elfGetCurrentFunction(addr, &f, &u)) {
u32 addr2; uint32_t addr2;
if (elfGetSymbolAddress(f->name, &addr2, &value, &type)) { if (elfGetSymbolAddress(f->name, &addr2, &value, &type)) {
address = addr; address = addr;
} else { } else {
@ -1017,7 +1017,7 @@ static void debuggerBreak(int n, char** args)
static void debuggerBreakThumb(int n, char** args) static void debuggerBreakThumb(int n, char** args)
{ {
if (n == 2) { if (n == 2) {
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int i = debuggerNumOfBreakpoints; int i = debuggerNumOfBreakpoints;
debuggerBreakpointList[i].address = address; debuggerBreakpointList[i].address = address;
@ -1033,7 +1033,7 @@ static void debuggerBreakThumb(int n, char** args)
static void debuggerBreakArm(int n, char** args) static void debuggerBreakArm(int n, char** args)
{ {
if (n == 2) { if (n == 2) {
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int i = debuggerNumOfBreakpoints; int i = debuggerNumOfBreakpoints;
debuggerBreakpointList[i].address = address; debuggerBreakpointList[i].address = address;
@ -1049,7 +1049,7 @@ static void debuggerBreakArm(int n, char** args)
static void debuggerBreakWriteClear(int n, char** args) static void debuggerBreakWriteClear(int n, char** args)
{ {
if (n == 3) { if (n == 3) {
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
@ -1059,12 +1059,12 @@ static void debuggerBreakWriteClear(int n, char** args)
return; return;
} }
u32 final = address + n; uint32_t final = address + n;
switch (address >> 24) { switch (address >> 24) {
case 2: { case 2: {
address &= 0x3ffff; address &= 0x3ffff;
final &= 0x3ffff; final &= 0x3ffff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeWorkRAM[i] == 1) if (freezeWorkRAM[i] == 1)
freezeWorkRAM[i] = 0; freezeWorkRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
@ -1073,7 +1073,7 @@ static void debuggerBreakWriteClear(int n, char** args)
case 3: { case 3: {
address &= 0x7fff; address &= 0x7fff;
final &= 0x7fff; final &= 0x7fff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeInternalRAM[i] == 1) if (freezeInternalRAM[i] == 1)
freezeInternalRAM[i] = 0; freezeInternalRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
@ -1082,7 +1082,7 @@ static void debuggerBreakWriteClear(int n, char** args)
case 5: { case 5: {
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezePRAM[i] == 1) if (freezePRAM[i] == 1)
freezePRAM[i] = 0; freezePRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
@ -1097,7 +1097,7 @@ static void debuggerBreakWriteClear(int n, char** args)
final &= 0xffff; final &= 0xffff;
} }
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeVRAM[i] == 1) if (freezeVRAM[i] == 1)
freezeVRAM[i] = 0; freezeVRAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", printf("Cleared break on write from %08x to %08x\n",
@ -1106,7 +1106,7 @@ static void debuggerBreakWriteClear(int n, char** args)
case 7: { case 7: {
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeOAM[i] == 1) if (freezeOAM[i] == 1)
freezeOAM[i] = 0; freezeOAM[i] = 0;
printf("Cleared break on write from %08x to %08x\n", 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"); printf("Cheats are enabled. Cannot continue.\n");
return; return;
} }
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
@ -1153,7 +1153,7 @@ static void debuggerBreakWrite(int n, char** args)
return; return;
} }
u32 final = address + n; uint32_t final = address + n;
if (address<0x2040000 && final> 0x2040000) { if (address<0x2040000 && final> 0x2040000) {
printf("Invalid byte count: %d\n", n); 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) static void debuggerBreakChangeClear(int n, char** args)
{ {
if (n == 3) { if (n == 3) {
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
@ -1215,12 +1215,12 @@ static void debuggerBreakChangeClear(int n, char** args)
return; return;
} }
u32 final = address + n; uint32_t final = address + n;
switch (address >> 24) { switch (address >> 24) {
case 2: { case 2: {
address &= 0x3ffff; address &= 0x3ffff;
final &= 0x3ffff; final &= 0x3ffff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeWorkRAM[i] == 2) if (freezeWorkRAM[i] == 2)
freezeWorkRAM[i] = 0; freezeWorkRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
@ -1229,7 +1229,7 @@ static void debuggerBreakChangeClear(int n, char** args)
case 3: { case 3: {
address &= 0x7fff; address &= 0x7fff;
final &= 0x7fff; final &= 0x7fff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeInternalRAM[i] == 2) if (freezeInternalRAM[i] == 2)
freezeInternalRAM[i] = 0; freezeInternalRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
@ -1238,7 +1238,7 @@ static void debuggerBreakChangeClear(int n, char** args)
case 5: { case 5: {
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezePRAM[i] == 2) if (freezePRAM[i] == 2)
freezePRAM[i] = 0; freezePRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
@ -1252,7 +1252,7 @@ static void debuggerBreakChangeClear(int n, char** args)
address &= 0xffff; address &= 0xffff;
final &= 0xffff; final &= 0xffff;
} }
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeVRAM[i] == 2) if (freezeVRAM[i] == 2)
freezeVRAM[i] = 0; freezeVRAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", printf("Cleared break on change from %08x to %08x\n",
@ -1261,7 +1261,7 @@ static void debuggerBreakChangeClear(int n, char** args)
case 7: { case 7: {
address &= 0x3ff; address &= 0x3ff;
final &= 0x3ff; final &= 0x3ff;
for (u32 i = address; i < final; i++) for (uint32_t i = address; i < final; i++)
if (freezeOAM[i] == 2) if (freezeOAM[i] == 2)
freezeOAM[i] = 0; freezeOAM[i] = 0;
printf("Cleared break on change from %08x to %08x\n", 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"); printf("Cheats are enabled. Cannot continue.\n");
return; return;
} }
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
int n = 0; int n = 0;
sscanf(args[2], "%d", &n); sscanf(args[2], "%d", &n);
@ -1308,7 +1308,7 @@ static void debuggerBreakChange(int n, char** args)
return; return;
} }
u32 final = address + n; uint32_t final = address + n;
if (address<0x2040000 && final> 0x2040000) { if (address<0x2040000 && final> 0x2040000) {
printf("Invalid byte count: %d\n", n); printf("Invalid byte count: %d\n", n);
@ -1353,11 +1353,11 @@ static void debuggerBreakChange(int n, char** args)
debuggerUsage("bpc"); debuggerUsage("bpc");
} }
static void debuggerDisassembleArm(FILE* f, u32 pc, int count) static void debuggerDisassembleArm(FILE* f, uint32_t pc, int count)
{ {
char buffer[80]; char buffer[80];
int i = 0; int i = 0;
u32 len = 0; uint32_t len = 0;
char format[30]; char format[30];
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
size_t l = strlen(elfGetAddressSymbol(pc + 4 * 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); sprintf(format, "%%08x %%-%ds %%s\n", len);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
u32 addr = pc; uint32_t addr = pc;
pc += disArm(pc, buffer, 2); pc += disArm(pc, buffer, 2);
fprintf(f, format, addr, elfGetAddressSymbol(addr), buffer); 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]; char buffer[80];
int i = 0; int i = 0;
u32 len = 0; uint32_t len = 0;
char format[30]; char format[30];
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
size_t l = strlen(elfGetAddressSymbol(pc + 2 * 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); sprintf(format, "%%08x %%-%ds %%s\n", len);
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
u32 addr = pc; uint32_t addr = pc;
pc += disThumb(pc, buffer, 2); pc += disThumb(pc, buffer, 2);
fprintf(f, format, addr, elfGetAddressSymbol(addr), buffer); 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) static void debuggerDisassembleArm(int n, char** args)
{ {
u32 pc = reg[15].I; uint32_t pc = reg[15].I;
pc -= 4; pc -= 4;
int count = 20; int count = 20;
if (n >= 2) { if (n >= 2) {
@ -1412,7 +1412,7 @@ static void debuggerDisassembleArm(int n, char** args)
static void debuggerDisassembleThumb(int n, char** args) static void debuggerDisassembleThumb(int n, char** args)
{ {
u32 pc = reg[15].I; uint32_t pc = reg[15].I;
pc -= 2; pc -= 2;
int count = 20; int count = 20;
if (n >= 2) { if (n >= 2) {
@ -1438,7 +1438,7 @@ static void debuggerDisassemble(int n, char** args)
static void debuggerFileDisassembleArm(int n, char** args) static void debuggerFileDisassembleArm(int n, char** args)
{ {
u32 pc = reg[15].I; uint32_t pc = reg[15].I;
pc -= 4; pc -= 4;
int count = 20; int count = 20;
if (n < 2) { if (n < 2) {
@ -1466,7 +1466,7 @@ static void debuggerFileDisassembleArm(int n, char** args)
static void debuggerFileDisassembleThumb(int n, char** args) static void debuggerFileDisassembleThumb(int n, char** args)
{ {
u32 pc = reg[15].I; uint32_t pc = reg[15].I;
pc -= 2; pc -= 2;
int count = 20; int count = 20;
if (n < 2) { if (n < 2) {
@ -1581,8 +1581,8 @@ void debuggerDoSearch()
while (true) { while (true) {
unsigned int final = SearchStart + SearchLength - 1; unsigned int final = SearchStart + SearchLength - 1;
u8* end; uint8_t* end;
u8* start; uint8_t* start;
switch (SearchStart >> 24) { switch (SearchStart >> 24) {
case 0: case 0:
@ -1666,7 +1666,7 @@ void debuggerDoSearch()
}; };
end -= SearchLength - 1; end -= SearchLength - 1;
u8 firstbyte = SearchData[0]; uint8_t firstbyte = SearchData[0];
while (start <= end) { while (start <= end) {
while ((start <= end) && (*start != firstbyte)) while ((start <= end) && (*start != firstbyte))
start++; 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]) if (mem >= &bios[0] && mem <= &bios[0x3fff])
return 0x00000000 + (mem - &bios[0]); return 0x00000000 + (mem - &bios[0]);
@ -1890,11 +1890,11 @@ static void debuggerIo(int n, char** args)
static void debuggerEditByte(int n, char** args) static void debuggerEditByte(int n, char** args)
{ {
if (n == 3) { if (n == 3) {
u32 address = 0x10000; uint32_t address = 0x10000;
u32 byte = 0; uint32_t byte = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
sscanf(args[2], "%x", &byte); sscanf(args[2], "%x", &byte);
debuggerWriteByte(address, (u8)byte); debuggerWriteByte(address, (uint8_t)byte);
} else } else
debuggerUsage("eb"); debuggerUsage("eb");
} }
@ -1902,15 +1902,15 @@ static void debuggerEditByte(int n, char** args)
static void debuggerEditHalfWord(int n, char** args) static void debuggerEditHalfWord(int n, char** args)
{ {
if (n == 3) { if (n == 3) {
u32 address = 0x10000; uint32_t address = 0x10000;
u32 HalfWord = 0; uint32_t HalfWord = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
if (address & 1) { if (address & 1) {
printf("Error: address must be half-word aligned\n"); printf("Error: address must be half-word aligned\n");
return; return;
} }
sscanf(args[2], "%x", &HalfWord); sscanf(args[2], "%x", &HalfWord);
debuggerWriteHalfWord(address, (u16)HalfWord); debuggerWriteHalfWord(address, (uint16_t)HalfWord);
} else } else
debuggerUsage("eh"); debuggerUsage("eh");
} }
@ -1919,7 +1919,7 @@ static void debuggerEditRegister(int n, char** args)
{ {
if (n == 3) { if (n == 3) {
int r = 15; int r = 15;
u32 val; uint32_t val;
sscanf(args[1], "%d", &r); sscanf(args[1], "%d", &r);
if (r > 16 || r == 15) { if (r > 16 || r == 15) {
// don't allow PC to change // don't allow PC to change
@ -1936,15 +1936,15 @@ static void debuggerEditRegister(int n, char** args)
static void debuggerEdit(int n, char** args) static void debuggerEdit(int n, char** args)
{ {
if (n == 3) { if (n == 3) {
u32 address; uint32_t address;
u32 byte; uint32_t byte;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
if (address & 3) { if (address & 3) {
printf("Error: address must be word aligned\n"); printf("Error: address must be word aligned\n");
return; return;
} }
sscanf(args[2], "%x", &byte); sscanf(args[2], "%x", &byte);
debuggerWriteMemory(address, (u32)byte); debuggerWriteMemory(address, (uint32_t)byte);
} else } else
debuggerUsage("ew"); debuggerUsage("ew");
} }
@ -1954,7 +1954,7 @@ static void debuggerEdit(int n, char** args)
static void debuggerMemoryByte(int n, char** args) static void debuggerMemoryByte(int n, char** args)
{ {
if (n == 2) { if (n == 2) {
u32 addr = 0; uint32_t addr = 0;
sscanf(args[1], "%x", &addr); sscanf(args[1], "%x", &addr);
for (int _i = 0; _i < 16; _i++) { for (int _i = 0; _i < 16; _i++) {
int a = debuggerReadByte(addr); int a = debuggerReadByte(addr);
@ -1989,7 +1989,7 @@ static void debuggerMemoryByte(int n, char** args)
static void debuggerMemoryHalfWord(int n, char** args) static void debuggerMemoryHalfWord(int n, char** args)
{ {
if (n == 2) { if (n == 2) {
u32 addr = 0; uint32_t addr = 0;
sscanf(args[1], "%x", &addr); sscanf(args[1], "%x", &addr);
addr = addr & 0xfffffffe; addr = addr & 0xfffffffe;
for (int _i = 0; _i < 16; _i++) { 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) static void debuggerMemory(int n, char** args)
{ {
if (n == 2) { if (n == 2) {
u32 addr = 0; uint32_t addr = 0;
sscanf(args[1], "%x", &addr); sscanf(args[1], "%x", &addr);
addr = addr & 0xfffffffc; addr = addr & 0xfffffffc;
for (int _i = 0; _i < 16; _i++) { 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) static void debuggerDumpLoad(int n, char** args)
{ {
u32 address = 0; uint32_t address = 0;
const char* file; const char* file;
FILE* f; FILE* f;
int c; int c;
@ -2139,8 +2139,8 @@ static void debuggerDumpLoad(int n, char** args)
static void debuggerDumpSave(int n, char** args) static void debuggerDumpSave(int n, char** args)
{ {
u32 address = 0; uint32_t address = 0;
u32 size = 0; uint32_t size = 0;
const char* file; const char* file;
FILE* f; FILE* f;
@ -2155,7 +2155,7 @@ static void debuggerDumpSave(int n, char** args)
return; return;
} }
for (u32 i = 0; i < size; i++) { for (uint32_t i = 0; i < size; i++) {
fputc(debuggerReadByte(address), f); fputc(debuggerReadByte(address), f);
address++; address++;
} }
@ -2170,7 +2170,7 @@ static void debuggerCondBreakThumb(int n, char** args)
if (n > 4) { //conditional args handled separately if (n > 4) { //conditional args handled separately
int i = debuggerNumOfBreakpoints; int i = debuggerNumOfBreakpoints;
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
debuggerBreakpointList[i].address = address; debuggerBreakpointList[i].address = address;
@ -2187,7 +2187,7 @@ static void debuggerCondBreakArm(int n, char** args)
if (n > 4) { //conditional args handled separately if (n > 4) { //conditional args handled separately
int i = debuggerNumOfBreakpoints; int i = debuggerNumOfBreakpoints;
u32 address = 0; uint32_t address = 0;
sscanf(args[1], "%x", &address); sscanf(args[1], "%x", &address);
debuggerBreakpointList[i].address = address; debuggerBreakpointList[i].address = address;
@ -2216,8 +2216,8 @@ static void debuggerCondValidate(int n, char** args, int start)
int rel = 0; int rel = 0;
u32 value1 = 0; uint32_t value1 = 0;
u32 value2 = 0; uint32_t value2 = 0;
char size = 0; char size = 0;
int j = 1; int j = 1;
@ -2454,11 +2454,11 @@ static bool debuggerCondEvaluate(int num)
if (debuggerBreakpointList[num].cond_rel == 0) if (debuggerBreakpointList[num].cond_rel == 0)
return true; return true;
u32 address = debuggerBreakpointList[num].cond_address; uint32_t address = debuggerBreakpointList[num].cond_address;
char size = debuggerBreakpointList[num].cond_size; char size = debuggerBreakpointList[num].cond_size;
u32 value = debuggerBreakpointList[num].cond_value; uint32_t value = debuggerBreakpointList[num].cond_value;
u32 value1 = 0; uint32_t value1 = 0;
u32 value2 = 0; uint32_t value2 = 0;
if (address < 17) if (address < 17)
value1 = reg[address].I; 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) if (s)
printf("%s", s); printf("%s", s);

View File

@ -18,5 +18,5 @@
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
extern void debuggerMain(); extern void debuggerMain();
extern void debuggerOutput(const char*, u32); extern void debuggerOutput(const char*, uint32_t);
extern void debuggerSignal(int, int); 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; TypeEnum tt = n->expression->type->type;
if (tt == TYPE_struct || tt == TYPE_union) { if (tt == TYPE_struct || tt == TYPE_union) {
u32 loc = n->expression->location; uint32_t loc = n->expression->location;
Type* t = n->expression->type; Type* t = n->expression->type;
int count = t->structure->memberCount; int count = t->structure->memberCount;
int i = 0; int i = 0;
@ -225,7 +225,7 @@ bool exprNodeArrowResolve(Node* n, Function* f, CompileUnit* u)
tt = n->expression->type->pointer->type; tt = n->expression->type->pointer->type;
if (tt == TYPE_struct || tt == TYPE_union) { 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; Type* t = n->expression->type->pointer;
int count = t->structure->memberCount; int count = t->structure->memberCount;
int i = 0; int i = 0;
@ -367,7 +367,7 @@ bool exprNodeArrayResolve(Node* n, Function* f, CompileUnit* u)
if (tt == TYPE_array) { if (tt == TYPE_array) {
Array* a = n->expression->type->array; Array* a = n->expression->type->array;
u32 loc = n->expression->location; uint32_t loc = n->expression->location;
Type* t = a->type; Type* t = a->type;
if (a->maxBounds > 1) { if (a->maxBounds > 1) {
int index = n->expression->index; int index = n->expression->index;
@ -390,7 +390,7 @@ bool exprNodeArrayResolve(Node* n, Function* f, CompileUnit* u)
n->locType = LOCATION_memory; n->locType = LOCATION_memory;
} else { } else {
Type* t = n->expression->type->pointer; Type* t = n->expression->type->pointer;
u32 loc = n->expression->location; uint32_t loc = n->expression->location;
if (n->expression->locType == LOCATION_register) if (n->expression->locType == LOCATION_register)
loc = reg[loc].I; loc = reg[loc].I;
else else

View File

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

View File

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

View File

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

View File

@ -24,7 +24,7 @@
extern int RGB_LOW_BITS_MASK; 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, 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, 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, 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 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) const char* string, bool trans)
{ {
screen += y * pitch; screen += y * pitch;
@ -54,11 +54,11 @@ void drawText(u8* screen, int pitch, int x, int y,
case 16: { case 16: {
while (*string) { while (*string) {
char c = *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; int h, w;
u16* s = (u16*)scr; uint16_t* s = (uint16_t*)scr;
for (h = 0; h < 8; h++) { for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) { for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c << 3) + h] >> w) & 1; int on = (fontdata2[(c << 3) + h] >> w) & 1;
@ -72,7 +72,7 @@ void drawText(u8* screen, int pitch, int x, int y,
} }
} }
scr += pitch; scr += pitch;
s = (u16*)scr; s = (uint16_t*)scr;
} }
screen += inc * 8; screen += inc * 8;
} }
@ -80,24 +80,24 @@ void drawText(u8* screen, int pitch, int x, int y,
case 24: { case 24: {
while (*string) { while (*string) {
char c = *string++; char c = *string++;
u8* scr = screen; uint8_t* scr = screen;
int h, w; int h, w;
u8* s = (u8*)scr; uint8_t* s = (uint8_t*)scr;
for (h = 0; h < 8; h++) { for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s += 3) { for (w = 0; w < 8; w++, s += 3) {
int on = (fontdata2[(c << 3) + h] >> w) & 1; int on = (fontdata2[(c << 3) + h] >> w) & 1;
if (trans) { if (trans) {
if (on) { if (on) {
u32 color = (0x1f) << systemRedShift; uint32_t color = (0x1f) << systemRedShift;
*s = ((color & 255) >> 1) + (*s >> 1); *s = ((color & 255) >> 1) + (*s >> 1);
*(s + 1) = (((color >> 8) & 255) >> 1) + (*(s + 1) >> 1); *(s + 1) = (((color >> 8) & 255) >> 1) + (*(s + 1) >> 1);
*(s + 2) = (((color >> 16) & 255) >> 1) + (*(s + 2) >> 1); *(s + 2) = (((color >> 16) & 255) >> 1) + (*(s + 2) >> 1);
} }
} else { } else {
if (on) { if (on) {
u32 color = (0x1f) << systemRedShift; uint32_t color = (0x1f) << systemRedShift;
*s = (color & 255); *s = (color & 255);
*(s + 1) = (color >> 8) & 255; *(s + 1) = (color >> 8) & 255;
*(s + 2) = (color >> 16) & 255; *(s + 2) = (color >> 16) & 255;
@ -105,7 +105,7 @@ void drawText(u8* screen, int pitch, int x, int y,
} }
} }
scr += pitch; scr += pitch;
s = (u8*)scr; s = (uint8_t*)scr;
} }
screen += inc * 8; screen += inc * 8;
} }
@ -113,11 +113,11 @@ void drawText(u8* screen, int pitch, int x, int y,
case 32: { case 32: {
while (*string) { while (*string) {
char c = *string++; char c = *string++;
u8* scr = screen; uint8_t* scr = screen;
int h, w; int h, w;
u32 mask = 0xfefefe; uint32_t mask = 0xfefefe;
u32* s = (u32*)scr; uint32_t* s = (uint32_t*)scr;
for (h = 0; h < 8; h++) { for (h = 0; h < 8; h++) {
for (w = 0; w < 8; w++, s++) { for (w = 0; w < 8; w++, s++) {
int on = (fontdata2[(c << 3) + h] >> w) & 1; int on = (fontdata2[(c << 3) + h] >> w) & 1;
@ -131,7 +131,7 @@ void drawText(u8* screen, int pitch, int x, int y,
} }
} }
scr += pitch; scr += pitch;
s = (u32*)scr; s = (uint32_t*)scr;
} }
screen += inc * 8; screen += inc * 8;
} }

View File

@ -17,4 +17,4 @@
// along with this program; if not, write to the Free Software Foundation, // along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. // 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; bmpInfo = info;
} }
void BitmapControl::setData(u8* d) void BitmapControl::setData(uint8_t* d)
{ {
data = d; data = d;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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