Fixed build warnings for gcc
This commit is contained in:
parent
cabc0ae639
commit
a579793bd1
|
@ -74,7 +74,7 @@ struct CPU
|
||||||
} pc;
|
} pc;
|
||||||
|
|
||||||
char remainingCycles;
|
char remainingCycles;
|
||||||
Qword totalCycles;
|
QWord totalCycles;
|
||||||
|
|
||||||
Byte fetchedVal;
|
Byte fetchedVal;
|
||||||
Word fetchedAddress;
|
Word fetchedAddress;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
void logBusState(struct Bus* bus)
|
void logBusState(struct Bus* bus)
|
||||||
{
|
{
|
||||||
const char buffer[32];
|
char buffer[32];
|
||||||
|
|
||||||
Word oldPC = bus->cpu->pc.word - bus->cpu->currentOpcode->length;
|
Word oldPC = bus->cpu->pc.word - bus->cpu->currentOpcode->length;
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ void logBusState(struct Bus* bus)
|
||||||
case ABX: sprintf(buffer, "$%04X, X -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
|
case ABX: sprintf(buffer, "$%04X, X -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
|
||||||
case ABY: sprintf(buffer, "$%04X, Y -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
|
case ABY: sprintf(buffer, "$%04X, Y -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
|
||||||
case IMM: sprintf(buffer, "#$%02X", bus->cpu->fetchedVal); break;
|
case IMM: sprintf(buffer, "#$%02X", bus->cpu->fetchedVal); break;
|
||||||
case IMP: sprintf(buffer, ""); break;
|
case IMP: sprintf(buffer, " "); break;
|
||||||
case IND: sprintf(buffer, "($%04X) -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
|
case IND: sprintf(buffer, "($%04X) -> $%04X", (instructionBytes[2] << 8) | instructionBytes[1], bus->cpu->fetchedAddress); break;
|
||||||
case INDX: sprintf(buffer, "($%02X, X) -> $%04X", instructionBytes[1], bus->cpu->fetchedAddress); break;
|
case INDX: sprintf(buffer, "($%02X, X) -> $%04X", instructionBytes[1], bus->cpu->fetchedAddress); break;
|
||||||
case INDY: sprintf(buffer, "($%02X), Y -> $%04X", instructionBytes[1], bus->cpu->fetchedAddress); break;
|
case INDY: sprintf(buffer, "($%02X), Y -> $%04X", instructionBytes[1], bus->cpu->fetchedAddress); break;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _MAPPER_H_
|
#define _MAPPER_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "SDL.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
struct PPU;
|
struct PPU;
|
||||||
|
@ -16,7 +17,7 @@ struct Mapper
|
||||||
void(*write_cpu)(void*, Word, Byte);
|
void(*write_cpu)(void*, Word, Byte);
|
||||||
void(*write_ppu)(void*, Word, Byte);
|
void(*write_ppu)(void*, Word, Byte);
|
||||||
|
|
||||||
void(*get_pattern_table_texture)(void*, void*, int);
|
void(*get_pattern_table_texture)(void*, SDL_Texture*, int);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MapperReadCPU(mapper, addr) mapper->read_cpu(mapper->mapperStruct, addr)
|
#define MapperReadCPU(mapper, addr) mapper->read_cpu(mapper->mapperStruct, addr)
|
||||||
|
|
|
@ -42,8 +42,9 @@ void destroyMapper000(struct Mapper000* mapper)
|
||||||
free(mapper);
|
free(mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte Mapper000_ReadCPU(struct Mapper000* mapper, Word address)
|
Byte Mapper000_ReadCPU(void* mapper, Word address)
|
||||||
{
|
{
|
||||||
|
struct Mapper000* sMapper = (struct Mapper000*)mapper;
|
||||||
Byte val = 0x00;
|
Byte val = 0x00;
|
||||||
|
|
||||||
if (address >= 0x6000 && address < 0x8000)
|
if (address >= 0x6000 && address < 0x8000)
|
||||||
|
@ -54,9 +55,9 @@ Byte Mapper000_ReadCPU(struct Mapper000* mapper, Word address)
|
||||||
else if (address >= 0x8000)
|
else if (address >= 0x8000)
|
||||||
{
|
{
|
||||||
Word effectiveAddress = address - 0x8000;
|
Word effectiveAddress = address - 0x8000;
|
||||||
effectiveAddress %= 0x4000 * (mapper->prg_rom_size == 1);
|
effectiveAddress %= 0x4000 * (sMapper->prg_rom_size == 1);
|
||||||
|
|
||||||
val = mapper->prg_rom[effectiveAddress];
|
val = sMapper->prg_rom[effectiveAddress];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -67,8 +68,9 @@ Byte Mapper000_ReadCPU(struct Mapper000* mapper, Word address)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
Byte Mapper000_ReadPPU(struct Mapper000* mapper, Word address)
|
Byte Mapper000_ReadPPU(void* mapper, Word address)
|
||||||
{
|
{
|
||||||
|
struct Mapper000* sMapper = (struct Mapper000*)mapper;
|
||||||
Byte val = 0x00;
|
Byte val = 0x00;
|
||||||
|
|
||||||
if (address >= 0x2000)
|
if (address >= 0x2000)
|
||||||
|
@ -78,28 +80,30 @@ Byte Mapper000_ReadPPU(struct Mapper000* mapper, Word address)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
val = mapper->chr_rom[address];
|
val = sMapper->chr_rom[address];
|
||||||
}
|
}
|
||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper000_WriteCPU(struct Mapper000* mapper, Word address, Byte value)
|
void Mapper000_WriteCPU(void* mapper, Word address, Byte value)
|
||||||
{
|
{
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Mapper000_WritePPU(struct Mapper000* mapper, Word address, Byte value)
|
void Mapper000_WritePPU(void* mapper, Word address, Byte value)
|
||||||
{
|
{
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper000_GetPatternTableTexture(struct Mapper000* mapper, SDL_Texture* texture, int index)
|
void Mapper000_GetPatternTableTexture(void* mapper, SDL_Texture* texture, int index)
|
||||||
{
|
{
|
||||||
|
struct Mapper000* sMapper = (struct Mapper000*)mapper;
|
||||||
|
|
||||||
int pitch;
|
int pitch;
|
||||||
void* pixels;
|
void* pixels;
|
||||||
SDL_LockTexture(texture, NULL, &pixels, &pitch);
|
SDL_LockTexture(texture, NULL, &pixels, &pitch);
|
||||||
SDL_memcpy(pixels, mapper->chr_rom + 0x1000 * index, 0x1000);
|
SDL_memcpy(pixels, sMapper->chr_rom + 0x1000 * index, 0x1000);
|
||||||
SDL_UnlockTexture(texture);
|
SDL_UnlockTexture(texture);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@ struct Mapper000
|
||||||
struct Mapper000* createMapper000(Byte prg_rom_size, Byte chr_rom_size, FILE* fp);
|
struct Mapper000* createMapper000(Byte prg_rom_size, Byte chr_rom_size, FILE* fp);
|
||||||
void destroyMapper000(struct Mapper000* mapper);
|
void destroyMapper000(struct Mapper000* mapper);
|
||||||
|
|
||||||
Byte Mapper000_ReadCPU(struct Mapper000* mapper, Word address);
|
Byte Mapper000_ReadCPU(void* mapper, Word address);
|
||||||
Byte Mapper000_ReadPPU(struct Mapper000* mapper, Word address);
|
Byte Mapper000_ReadPPU(void* mapper, Word address);
|
||||||
void Mapper000_WriteCPU(struct Mapper000* mapper, Word address, Byte value);
|
void Mapper000_WriteCPU(void* mapper, Word address, Byte value);
|
||||||
void Mapper000_WritePPU(struct Mapper000* mapper, Word address, Byte value);
|
void Mapper000_WritePPU(void* mapper, Word address, Byte value);
|
||||||
|
|
||||||
void Mapper000_GetPatternTableTexture(struct Mapper000* mapper, SDL_Texture* texture, int index);
|
void Mapper000_GetPatternTableTexture(void* mapper, SDL_Texture* texture, int index);
|
||||||
|
|
||||||
#endif _MAPPER_000_
|
#endif // _MAPPER_000_
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct PPU* createPPU(struct Bus* parent)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ppu->oam = (Byte*)malloc(0x100);
|
ppu->oam = (union OAMEntry*)malloc(0x100);
|
||||||
if (ppu->oam == NULL)
|
if (ppu->oam == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to allocate memory for PPU OAM.\n");
|
fprintf(stderr, "Failed to allocate memory for PPU OAM.\n");
|
||||||
|
@ -353,7 +353,7 @@ SDL_Texture* getRenderedNameTableTexture(struct PPU* ppu, int index)
|
||||||
SDL_Texture* target = ppu->renderedNameTableTextures[index];
|
SDL_Texture* target = ppu->renderedNameTableTextures[index];
|
||||||
int pitch;
|
int pitch;
|
||||||
struct Pixel* pixels;
|
struct Pixel* pixels;
|
||||||
SDL_LockTexture(target, NULL, &pixels, &pitch);
|
SDL_LockTexture(target, NULL, (void**)&pixels, &pitch);
|
||||||
|
|
||||||
Byte patternTable = 0x1000 * ppu->ppuCtrl.bgTile;
|
Byte patternTable = 0x1000 * ppu->ppuCtrl.bgTile;
|
||||||
for (int y = 0; y < 30; y++)
|
for (int y = 0; y < 30; y++)
|
||||||
|
|
|
@ -27,6 +27,20 @@ struct FIFO16
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
union OAMEntry
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
Byte y;
|
||||||
|
Byte tile;
|
||||||
|
Byte attr;
|
||||||
|
Byte x;
|
||||||
|
};
|
||||||
|
|
||||||
|
DWord raw;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct PPU
|
struct PPU
|
||||||
{
|
{
|
||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
@ -179,18 +193,7 @@ struct PPU
|
||||||
struct FIFO16 loPatternFIFO;
|
struct FIFO16 loPatternFIFO;
|
||||||
struct FIFO16 hiPatternFIFO;
|
struct FIFO16 hiPatternFIFO;
|
||||||
|
|
||||||
union
|
union OAMEntry* oam;
|
||||||
{
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
Byte y;
|
|
||||||
Byte tile;
|
|
||||||
Byte attr;
|
|
||||||
Byte x;
|
|
||||||
};
|
|
||||||
|
|
||||||
DWord raw;
|
|
||||||
}* oam;
|
|
||||||
|
|
||||||
Word x, y;
|
Word x, y;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
typedef uint8_t Byte;
|
typedef uint8_t Byte;
|
||||||
typedef uint16_t Word;
|
typedef uint16_t Word;
|
||||||
typedef uint32_t DWord;
|
typedef uint32_t DWord;
|
||||||
typedef uint64_t Qword;
|
typedef uint64_t QWord;
|
||||||
|
|
||||||
#endif // _TYPES_H_
|
#endif // _TYPES_H_
|
||||||
|
|
Loading…
Reference in a new issue