Browse Source

Make SDL flags more portable; minor GCC warning fixes

master
Nathaniel Walizer 11 months ago
parent
commit
1352754cbd
9 changed files with 20 additions and 19 deletions
  1. +2
    -1
      Makefile
  2. +5
    -5
      src/apu.c
  3. +1
    -1
      src/nese.c
  4. +7
    -7
      src/save.c
  5. +1
    -1
      src/sdl_audio.c
  6. +1
    -1
      src/sdl_input.c
  7. +1
    -1
      src/sdl_overlay.h
  8. +1
    -1
      src/sdl_render.c
  9. +1
    -1
      src/sdl_timer.c

+ 2
- 1
Makefile View File

@@ -27,8 +27,10 @@ PFLAGS = -g
PFLAGS += -DE6502_ILLEGAL PFLAGS += -DE6502_ILLEGAL
CFLAGS = $(PFLAGS) -Wall -Werror -Wshadow -Wunused -I../ -Isrc/ CFLAGS = $(PFLAGS) -Wall -Werror -Wshadow -Wunused -I../ -Isrc/
CFLAGS += -Iinc/$(PLATFORM) -I../inc/$(PLATFORM) CFLAGS += -Iinc/$(PLATFORM) -I../inc/$(PLATFORM)
CFLAGS += $(shell sdl2-config --cflags)
LDFLAGS = $(PFLAGS) LDFLAGS = $(PFLAGS)
LDFLAGS += -Llib/$(PLATFORM) LDFLAGS += -Llib/$(PLATFORM)
LDFLAGS += $(shell sdl2-config --libs)


OBJDIR = obj$(DIR_SUFFIX) OBJDIR = obj$(DIR_SUFFIX)
SRCDIR = src SRCDIR = src
@@ -38,7 +40,6 @@ BINDIR = bin$(DIR_SUFFIX)
# nese # nese


TARGET_1 = nese$(EXTENSION) TARGET_1 = nese$(EXTENSION)
LDLIBS_1 = -lSDL2


SRC_SRCS_1 = nese.c ines.c SRC_SRCS_1 = nese.c ines.c
SRC_SRCS_1 += nes.c ppu.c input.c SRC_SRCS_1 += nes.c ppu.c input.c


+ 5
- 5
src/apu.c View File

@@ -30,13 +30,13 @@ static const uint16_t dmc_period_lut[16] = {
190, 160, 142, 128, 106, 84, 72, 54, 190, 160, 142, 128, 106, 84, 72, 54,
}; };


static const void dmc_restart(nes_apu_Channel* channel) {
static void dmc_restart(nes_apu_Channel* channel) {
channel->length = (channel->reg[3] * 16) + 1; channel->length = (channel->reg[3] * 16) + 1;
channel->addr = 0x4000U | ((uint16_t)channel->reg[2] << 6); channel->addr = 0x4000U | ((uint16_t)channel->reg[2] << 6);
} }


static const void nes_apu_dmc_fetch(nes_apu* apu,
nes_apu_Channel* channel) {
static void nes_apu_dmc_fetch(nes_apu* apu,
nes_apu_Channel* channel) {
channel->data = apu->mem_read(apu->arg_mem, channel->data = apu->mem_read(apu->arg_mem,
0x8000U | channel->addr); 0x8000U | channel->addr);
channel->mask = 1; channel->mask = 1;
@@ -51,8 +51,8 @@ static const void nes_apu_dmc_fetch(nes_apu* apu,
} }
} }


static const void nes_apu_dmc_start(nes_apu* apu,
nes_apu_Channel* channel) {
static void nes_apu_dmc_start(nes_apu* apu,
nes_apu_Channel* channel) {
dmc_restart(channel); dmc_restart(channel);
nes_apu_dmc_fetch(apu, channel); nes_apu_dmc_fetch(apu, channel);
} }


+ 1
- 1
src/nese.c View File

@@ -248,7 +248,7 @@ int main(int argc, char* argv[]) {
uint64_t cycle_last_frame = 0; uint64_t cycle_last_frame = 0;


uint64_t total_cycles = 0; uint64_t total_cycles = 0;
for (int i = 0; status == 0; ++i) {
while (0 == status) {
int run = 0; int run = 0;
nes_ppu_Result result = nes_step(&sys, &run); nes_ppu_Result result = nes_step(&sys, &run);
total_cycles += run; total_cycles += run;


+ 7
- 7
src/save.c View File

@@ -312,9 +312,9 @@ int state_read(nes* sys, const void* mem, int mem_size) {
if ((ptr + size) > end) { if ((ptr + size) > end) {
result = -1; result = -1;
fprintf(stderr, fprintf(stderr,
"Unusually large chunk: %.4s: +%"PRIu64"\n",
"Unusually large chunk: %.4s: +%d\n",
(char*)&tag, (char*)&tag,
((ptr + size) - end));
(int)((ptr + size) - end));
break; break;
} }


@@ -359,27 +359,27 @@ int state_read(nes* sys, const void* mem, int mem_size) {
} }


if (0 == result) { if (0 == result) {
if (!(loaded | Component_CPU)) {
if (!(loaded & Component_CPU)) {
result = -1; result = -1;
fprintf(stderr, "Missing %s state\n", "CPU"); fprintf(stderr, "Missing %s state\n", "CPU");
} }


if (!(loaded | Component_PPU)) {
if (!(loaded & Component_PPU)) {
result = -1; result = -1;
fprintf(stderr, "Missing %s state\n", "PPU"); fprintf(stderr, "Missing %s state\n", "PPU");
} }


if (!(loaded | Component_APU)) {
if (!(loaded & Component_APU)) {
result = -1; result = -1;
fprintf(stderr, "Missing %s state\n", "APU"); fprintf(stderr, "Missing %s state\n", "APU");
} }


if (!(loaded | Component_RAM)) {
if (!(loaded & Component_RAM)) {
result = -1; result = -1;
fprintf(stderr, "Missing %s state\n", "RAM"); fprintf(stderr, "Missing %s state\n", "RAM");
} }


if (!(loaded | Component_Mapper)) {
if (!(loaded & Component_Mapper)) {
result = -1; result = -1;
fprintf(stderr, "Missing %s state\n", "Mapper"); fprintf(stderr, "Missing %s state\n", "Mapper");
} }


+ 1
- 1
src/sdl_audio.c View File

@@ -1,4 +1,4 @@
#include <SDL2/SDL.h>
#include <SDL.h>


#include "audio.h" #include "audio.h"




+ 1
- 1
src/sdl_input.c View File

@@ -1,4 +1,4 @@
#include <SDL2/SDL.h>
#include <SDL.h>


#include "input.h" #include "input.h"




+ 1
- 1
src/sdl_overlay.h View File

@@ -3,7 +3,7 @@


#include <stdint.h> #include <stdint.h>


#include <SDL2/SDL.h>
#include <SDL.h>


#include "overlay.h" #include "overlay.h"




+ 1
- 1
src/sdl_render.c View File

@@ -1,6 +1,6 @@
#include <stdio.h> #include <stdio.h>


#include <SDL2/SDL.h>
#include <SDL.h>


#include "render.h" #include "render.h"
#include "ppu.h" #include "ppu.h"


+ 1
- 1
src/sdl_timer.c View File

@@ -1,6 +1,6 @@
#include "timer.h" #include "timer.h"


#include <SDL2/SDL.h>
#include <SDL.h>




time_us time_now(void) { time_us time_now(void) {


Loading…
Cancel
Save