shithub: zelda3

Download patch

ref: e72f93c47a8e70772c9a247ed68b147684b1a534
parent: d4f9f78c9d7e54c6fa22aec76987cbcec97ab653
author: Snesrev <[email protected]>
date: Wed Oct 19 14:22:23 EDT 2022

Silence a bunch of warnings

--- a/ancilla.c
+++ b/ancilla.c
@@ -5165,7 +5165,7 @@
   }
   Point16U pt;
   Ancilla_PrepAdjustedOamCoord(k, &pt);
-  OamEnt *oam = GetOamCurPtr(), *oam_org = oam;
+  OamEnt *oam = GetOamCurPtr();
 
   int8 z = ancilla_z[k] + (ancilla_K[k] == 3 && BYTE(link_z_coord) != 0xff ? BYTE(link_z_coord) : 0);
   int j = ancilla_item_to_link[k] * 8;
@@ -5923,7 +5923,6 @@
     ancilla_z[k] = 0;
     ancilla_timer[k] = 16;
     ancilla_item_to_link[k] = link_receiveitem_index;
-    int j = link_receiveitem_index;
     Ancilla_SetXY(k,
       link_x_coord + kWishPondItem_X[link_receiveitem_index],
       link_y_coord + kWishPondItem_Y[link_receiveitem_index]);
@@ -6368,8 +6367,6 @@
 }
 
 void AncillaAdd_DashTremor(uint8 a, uint8 y) {  // 8993f3
-  static const uint8 kAddDashingDust_X[4] = {4, 4, 6, 0};
-  static const uint8 kAddDashingDust_Y[4] = {20, 4, 16, 16};
   static const uint8 kAddDashTremor_Dir[4] = {2, 2, 0, 0};
   static const uint8 kAddDashTremor_Tab[2] = {0x80, 0x78};
   if (AncillaAdd_CheckForPresence(a))
--- a/main.c
+++ b/main.c
@@ -34,7 +34,6 @@
 // Forwards
 static bool LoadRom(const char *filename);
 static void LoadLinkGraphics();
-static void PlayAudio(SDL_AudioDeviceID device, int channels, int16 *audioBuffer);
 static void RenderNumber(uint8 *dst, size_t pitch, int n, bool big);
 static void HandleInput(int keyCode, int modCode, bool pressed);
 static void HandleCommand(uint32 j, bool pressed);
@@ -269,10 +268,10 @@
 
 static void SdlRenderer_EndDraw() {
 
-  uint64 before = SDL_GetPerformanceCounter();
+//  uint64 before = SDL_GetPerformanceCounter();
   SDL_UnlockTexture(g_texture);
-  uint64 after = SDL_GetPerformanceCounter();
-  float v = (double)(after - before) / SDL_GetPerformanceFrequency();
+//  uint64 after = SDL_GetPerformanceCounter();
+//  float v = (double)(after - before) / SDL_GetPerformanceFrequency();
 //  printf("%f ms\n", v * 1000);
   SDL_RenderClear(g_renderer);
   SDL_RenderCopy(g_renderer, g_texture, &g_sdl_renderer_rect, NULL);
@@ -365,7 +364,7 @@
   if (!g_renderer_funcs.Initialize(window))
     return 1;
 
-  SDL_AudioDeviceID device;
+  SDL_AudioDeviceID device = 0;
   SDL_AudioSpec want = { 0 }, have;
   g_audio_mutex = SDL_CreateMutex();
   if (!g_audio_mutex) Die("No mutex");
@@ -451,7 +450,8 @@
 
     if (g_paused != audiopaused) {
       audiopaused = g_paused;
-      SDL_PauseAudioDevice(device, audiopaused);
+      if (device)
+        SDL_PauseAudioDevice(device, audiopaused);
     }
 
     if (g_paused) {
--- a/messaging.c
+++ b/messaging.c
@@ -63,7 +63,6 @@
   0x13a4, 0xb00, 0x138e, 0xb00, 0xb00, 0x5393, 0xb00, 0x574e, 0x4b7d, 0xb00, 0x8b7d, 0x139f, 0x97aa, 0x13a4, 0x13a9, 0x53a9, 0x13a5, 0x13a6, 0x93a5, 0xd3a5, 0xd38e, 0x938e, 0x13a4, 0x13aa, 0xb00, 0x13a6, 0xb00, 0x8b5f, 0x139b, 0x13a6, 0x139c, 0x53a2,
   0xb00, 0xb00, 0x138c, 0xb00, 0x9394, 0x139e, 0xb00, 0xb00,
 };
-static const uint16 kDungMap_Ptrs27[14] = {0xfc00, 0xfc08, 0xfc15, 0xfc21, 0xfc2b, 0xfc32, 0xfc3f, 0xfc4d, 0xfc5f, 0xfc68, 0xfc7d, 0xfc83, 0xfc8f, 0xfca0};
 static const uint16 kDungMap_Tab21[3] = {137, 167, 79};
 static const uint16 kDungMap_Tab22[3] = {169, 119, 190};
 static const uint16 kDungMap_Tab24[2] = {0x1f, 0x7f};
@@ -1717,7 +1716,6 @@
 
 void DungeonMap_BuildFloorListBoxes(uint8 t5, uint16 r14) {  // 8ae2f5
   int n = (t5 & 0xf) + (t5 >> 4);
-  uint8 r12 = dung_cur_floor + (t5 & 0xf);
   r14 -= 0x40 - 2;
   r14 += (t5 & 0xf) * 0x40;
   int offs = vram_upload_offset >> 1;
@@ -1971,7 +1969,6 @@
 void DungeonMap_HandleFloorSelect() {  // 8ae986
   uint8 r2 = (kDungMap_Tab5[cur_palace_index_x2 >> 1] >> 4 & 0xf);
   uint8 r3 = (kDungMap_Tab5[cur_palace_index_x2 >> 1] & 0xf);
-  uint8 yv = 7;
   if (r2 + r3 < 3 || dungmap_var2 || !(joypad1H_last & 0xc))
     return;
   dungmap_cur_floor &= 0xff;
--- a/platform/switch/Makefile
+++ b/platform/switch/Makefile
@@ -51,7 +51,7 @@
 #---------------------------------------------------------------------------------
 ARCH	:=	-march=armv8-a+crc+crypto -mtune=cortex-a57 -mtp=soft -fPIE
 
-CFLAGS	:=	-g -Wall -O2 -ffunction-sections \
+CFLAGS	:=	-g -Wall -O2 -ffunction-sections -Wno-parentheses \
 			$(ARCH) $(DEFINES)
 
 CFLAGS	+=	-D__SWITCH__ $(INCLUDE) -DSTBI_NO_THREAD_LOCALS `sdl2-config --cflags`
--- a/snes/ppu.c
+++ b/snes/ppu.c
@@ -220,7 +220,6 @@
   int window_right = 256 + (layer != 2 ? ppu->extraRightCur : 0);
   win->edges[0] = - (layer != 2 ? ppu->extraLeftCur : 0);
   win->edges[1] = window_right;
-  uint8 window_bits = 0;
   uint i, j;
   int t;
   bool w1_ena = (winflags & kWindow1Enabled) && ppu->window1left <= ppu->window1right;
--- a/snes/snes.c
+++ b/snes/snes.c
@@ -18,9 +18,6 @@
 #include "tracing.h"
 #include "snes_regs.h"
 
-static const double apuCyclesPerMaster = (32040 * 32) / (1364 * 262 * 60.0);
-
-static void snes_runCpu(Snes* snes);
 static void snes_catchupApu(Snes* snes);
 static uint8_t snes_readReg(Snes* snes, uint16_t adr);
 static void snes_writeReg(Snes* snes, uint16_t adr, uint8_t val);
@@ -104,8 +101,6 @@
   snes->openBus = 0;
 }
 
-static uint8_t g_last_module;
-
 void snes_printCpuLine(Snes *snes) {
   if (snes->debug_cycles) {
     static FILE *fout;
@@ -119,21 +114,6 @@
     fputs("\n", fout);
     fflush(fout);
   }
-}
-
-static void snes_runCpu(Snes* snes) {
-  if(snes->cpuCyclesLeft == 0) {
-    snes->cpuMemOps = 0;
-    uint32_t pc = snes->cpu->pc | snes->cpu->k << 16;
-    if (snes->debug_cycles) {
-      char line[80];
-      getProcessorStateCpu(snes, line);
-      puts(line);
-    }
-    int cycles = cpu_runOpcode(snes->cpu);
-    snes->cpuCyclesLeft += (cycles - snes->cpuMemOps) * 6;
-  }
-  snes->cpuCyclesLeft -= 2;
 }
 
 static void snes_catchupApu(Snes* snes) {
--- a/sprite_main.c
+++ b/sprite_main.c
@@ -3971,7 +3971,6 @@
   uint8 r12 = kFlailTrooperWeapon_Tab1[sprite_D[k]];
   uint8 r13 = kFlailTrooperWeapon_Tab2[sprite_D[k]];
 
-  uint16 r10 = (r0 & 0x1ff) >> 6;
   uint16 r2 = (r0 + 0x80) & 0x1ff;
 
   uint8 r14 = ChainBallMult(kSinusLookupTable[r0 & 0xff], qq);
@@ -9701,8 +9700,6 @@
   if (!sprite_delay_main[k])
     sprite_graphics[k] = frame_counter >> 4 & 1;
 
-  int type = sprite_subtype2[k];
-
   switch(sprite_subtype2[k]) {
   case 0:
     switch (sprite_ai_state[k]) {
@@ -18036,7 +18033,6 @@
   static const uint8 kGiantMoldorm_Eye_Char[16] = {0xaa, 0xaa, 0xa8, 0xa8, 0x8a, 0x8a, 0xa8, 0xa8, 0xaa, 0xaa, 0xa8, 0xa8, 0x8a, 0x8a, 0xa8, 0xa8};
   static const uint8 kGiantMoldorm_Eye_Flags[16] = {0, 0, 0, 0, 0x80, 0x80, 0x40, 0x40, 0x40, 0x40, 0xc0, 0xc0, 0, 0, 0x80, 0x80};
   OamEnt *oam = GetOamCurPtr();
-  uint8 yoff = kBadPullSwitch_Tab5[kBadPullSwitch_Tab4[sprite_graphics[k]]];
   int r7 = sprite_F[k] ? frame_counter : 0;
   int r6 = sprite_D[k] - 1;
   for (int i = 1; i >= 0; i--, oam++, r6 += 2) {
@@ -20945,7 +20941,7 @@
     }
     if (sign8(--sprite_subtype2[k])) {
       sprite_subtype2[k] = 5;
-      sprite_graphics[k] = (++sprite_graphics[k] & 3) + 8;
+      sprite_graphics[k] = (sprite_graphics[k] + 1 & 3) + 8;
     }
     break;
   case 2: {  // coagulate
--- a/zelda_cpu_infra.c
+++ b/zelda_cpu_infra.c
@@ -168,7 +168,7 @@
   }
 }
 
-static uint8_t *RomByte(Cart *cart, uint32_t addr) {
+uint8_t *RomByte(Cart *cart, uint32_t addr) {
   return &cart->rom[(((addr >> 16) << 15) | (addr & 0x7fff)) & (cart->romSize - 1)];
 }
 
--- a/zelda_rtl.c
+++ b/zelda_rtl.c
@@ -499,7 +499,6 @@
 
   sr->replay_next_cmd_at = 0;
 
-  bool is_reset = false;
   sr->replay_mode = replay_mode;
   if (replay_mode) {
     sr->frames_since_last = 0;
@@ -514,7 +513,6 @@
       assert(state.p == state.pend);
     } else {
       ZeldaReset(false);
-      is_reset = true;
     }
   } else {
     // Resume replay from the saved position?