fix some gcc warnings, and maybe even a ppu bug?

first commit in a _long_ time, and it's just because I installed a
fresh linux distro and wanted to see if ANESE compiles on it.
It does, but I noticed a couple of warnings and bugs, so these are
some quick fixes.

looks like I had an unintended fallthrough in my bgr_fetch routine.
not sure how mission-critical this is, but maybe it fixes stuff?

other than that, g++ helpfuly noted some other silly errors and
unused vars, so I cleaned those up too.

lastly, I removed some code that skipped the first directory
returned by cute_files in the menu component. Not _super_ sure why
that was there in the first place, but directory traversal now
works on some more linux distros (such as the one I am running)
This commit is contained in:
Daniel Prilik 2018-12-03 14:04:27 -05:00
parent 0081371aa4
commit cd756d0a2d
7 changed files with 13 additions and 11 deletions

View file

@ -32,7 +32,7 @@ endif(NOT CMAKE_BUILD_TYPE)
# Setup compiler flags for different platforms
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -fno-exceptions -fno-rtti -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -fno-exceptions -fno-rtti -Wno-class-memaccess -std=c++11")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g -fsanitize=undefined -fsanitize=address")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -O3 -g")
elseif (${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)

View file

@ -60,8 +60,10 @@ void CPU::service_interrupt(Interrupts::Type interrupt, bool brk /* = false */)
this->cycles += 7;
switch (interrupt) {
case Interrupts::IRQ: if (brk || !this->reg.p.i)
this->reg.pc = this->read16(0xFFFE); break;
case Interrupts::IRQ:
if (brk || !this->reg.p.i)
this->reg.pc = this->read16(0xFFFE);
break;
case Interrupts::RESET: this->reg.pc = this->read16(0xFFFC); break;
case Interrupts::NMI: this->reg.pc = this->read16(0xFFFA); break;
default: break;
@ -424,7 +426,7 @@ u16 CPU::peek16(u16 addr) const {
u16 CPU::read16(u16 addr) {
return this->mem.read(addr + 0) |
(this->mem.read(addr + 1) << 8);
};
}
u16 CPU::peek16_zpg(u16 addr) const {
return this->mem.peek(addr + 0) |

View file

@ -442,7 +442,7 @@ void PPU::bgr_fetch() {
this->bgr.shift.at_latch[0] = this->bgr.at_byte & 1;
this->bgr.shift.at_latch[1] = this->bgr.at_byte & 2;
}
} break;
// 1) Fetch Nametable Byte
// https://wiki.nesdev.com/w/index.php/PPU_scrolling#Tile_and_attribute_fetching
case 2: {

View file

@ -18,8 +18,9 @@ void get_abs_path(char* abs_path, const char* path, unsigned int n) {
#ifdef WIN32
GetFullPathName(path, n, abs_path, nullptr);
#else
const char* _ = realpath(path, abs_path);
(void)n;
(void)realpath(path, abs_path);
(void)_;
#endif
}

View file

@ -204,7 +204,7 @@ void EmuModule::input(const SDL_Event& event) {
// Use CMD on macOS, and CTRL on windows / linux
bool mod_ctrl = strcmp(SDL_GetPlatform(), "Mac OS X") == 0
? event.key.keysym.mod & (KMOD_LGUI | KMOD_RGUI)
: mod_ctrl = event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL);
: event.key.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL);
// Regular 'ol keys
switch (event.key.keysym.sym) {

View file

@ -110,14 +110,11 @@ void MenuSubModule::update() {
// Get file-listing
cf_dir_t dir;
cf_dir_open(&dir, this->nav.directory);
bool skip_first = true;
while (dir.has_next) {
cf_file_t file;
cf_read_file(&dir, &file);
if (!skip_first)
files.push_back(file);
files.push_back(file);
cf_dir_next(&dir);
skip_first = false;
}
cf_dir_close(&dir);

View file

@ -6338,6 +6338,7 @@ static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g)
// two back is the image from two frames ago, used for a very specific disposal format
static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)
{
(void) req_comp;
int dispose;
int first_frame;
int pi;
@ -6562,6 +6563,7 @@ static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y,
static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
{
(void)ri;
stbi_uc *u = 0;
stbi__gif g;
memset(&g, 0, sizeof(g));