shithub: zelda3

Download patch

ref: 2c5078c443482b8102b45eb4309b8f8068757a91
parent: e08e1e45940607f7eb21e24e9d829e6ebe8e70e7
author: Snesrev <snesrev@protonmail.com>
date: Fri Sep 2 19:26:04 EDT 2022

Move snes_regs.h

--- a/attract.c
+++ b/attract.c
@@ -1,7 +1,7 @@
 #include "zelda_rtl.h"
 #include "variables.h"
 #include "variables_attract.h"
-#include "snes_regs.h"
+#include "snes/snes_regs.h"
 #include "load_gfx.h"
 #include "dungeon.h"
 #include "sprite.h"
--- a/dungeon.c
+++ b/dungeon.c
@@ -1,8 +1,7 @@
 #include "zelda_rtl.h"
-
+#include "snes/snes_regs.h"
 #include "variables.h"
 #include "dungeon.h"
-#include "snes_regs.h"
 #include "nmi.h"
 #include "hud.h"
 #include "load_gfx.h"
--- a/ending.c
+++ b/ending.c
@@ -1,4 +1,5 @@
 #include "zelda_rtl.h"
+#include "snes/snes_regs.h"
 #include "variables.h"
 #include "load_gfx.h"
 #include "dungeon.h"
--- a/load_gfx.c
+++ b/load_gfx.c
@@ -1,6 +1,6 @@
 #include "zelda_rtl.h"
 #include "variables.h"
-#include "snes_regs.h"
+#include "snes/snes_regs.h"
 #include "overworld.h"
 #include "load_gfx.h"
 #include "player.h"
--- a/messaging.c
+++ b/messaging.c
@@ -1,7 +1,7 @@
 #include "messaging.h"
 #include "zelda_rtl.h"
 #include "variables.h"
-#include "snes_regs.h"
+#include "snes/snes_regs.h"
 #include "dungeon.h"
 #include "hud.h"
 #include "load_gfx.h"
--- a/misc.c
+++ b/misc.c
@@ -15,6 +15,7 @@
 #include "messaging.h"
 #include "ending.h"
 #include "attract.h"
+#include "snes/snes_regs.h"
 #include "tables/generated_predefined_tiles.h"
 #include "tables/generated_sound_banks.h"
 
--- a/nmi.c
+++ b/nmi.c
@@ -1,11 +1,12 @@
 #include "nmi.h"
 #include "zelda_rtl.h"
 #include "variables.h"
-#include "snes_regs.h"
-#include "tables/generated_bg_tilemaps.h"
-#include "tables/generated_link_graphics.h"
 #include "messaging.h"
+#include "snes/snes_regs.h"
 #include "snes/ppu.h"
+#include "tables/generated_bg_tilemaps.h"
+#include "tables/generated_link_graphics.h"
+
 static const uint8 kNmiVramAddrs[] = {
   0, 0, 4, 8, 12, 8, 12, 0, 4, 0, 8, 4, 12, 4, 12, 0,
   8, 16, 20, 24, 28, 24, 28, 16, 20, 16, 24, 20, 28, 20, 28, 16,
--- a/overlord.h
+++ b/overlord.h
@@ -1,7 +1,5 @@
 #pragma once
-#include "zelda_rtl.h"
-#include "variables.h"
-#include "snes_regs.h"
+#include "types.h"
 
 void Overlord_StalfosFactory(int k);
 void Overlord_SetX(int k, uint16 v);
--- a/overworld.c
+++ b/overworld.c
@@ -9,6 +9,7 @@
 #include "misc.h"
 #include "messaging.h"
 #include "player_oam.h"
+#include "snes/snes_regs.h"
 #include "tables/generated_map32_to_map16.h"
 #include "tables/generated_map16_to_map8.h"
 #include "tables/generated_overworld_tables.h"
--- a/overworld.h
+++ b/overworld.h
@@ -1,10 +1,6 @@
 #pragma once
 #include "zelda_rtl.h"
 #include "variables.h"
-#include "snes_regs.h"
-
-
-
 
 const uint8 *GetMap8toTileAttr();
 const uint16 *GetMap16toMap8Table();
--- a/player_oam.c
+++ b/player_oam.c
@@ -1,9 +1,10 @@
 #include "player_oam.h"
 #include "zelda_rtl.h"
 #include "variables.h"
-#include "snes_regs.h"
+#include "snes/snes_regs.h"
 #include "player.h"
 #include "misc.h"
+
 static const int8 kPlayerOam_StairsOffsY[] = {
   0, -2, -3, 0, -2, -3, 0, 0, 0, 0, 0, 0, 0, -2, -3, 0,
   -2, -3, 0, 0, 0, 0, 0, 0,
--- a/select_file.c
+++ b/select_file.c
@@ -2,7 +2,7 @@
 #include "variables.h"
 #include "load_gfx.h"
 #include "select_file.h"
-#include "snes_regs.h"
+#include "snes/snes_regs.h"
 #include "variables_attract.h"
 #include "overworld.h"
 #include "messaging.h"
--- a/snes/dma.c
+++ b/snes/dma.c
@@ -7,7 +7,8 @@
 #include <stddef.h>
 #include "dma.h"
 #include "snes.h"
-#include "../snes_regs.h"
+#include "snes_regs.h"
+
 static const int bAdrOffsets[8][4] = {
   {0, 0, 0, 0},
   {0, 1, 0, 1},
--- a/snes/snes.c
+++ b/snes/snes.c
@@ -16,7 +16,7 @@
 #include "cart.h"
 #include "input.h"
 #include "../tracing.h"
-#include "../snes_regs.h"
+#include "snes_regs.h"
 
 static const double apuCyclesPerMaster = (32040 * 32) / (1364 * 262 * 60.0);
 
--- /dev/null
+++ b/snes/snes_regs.h
@@ -1,0 +1,211 @@
+#pragma once
+
+#define INIDISP 0x2100
+#define OBSEL 0x2101
+#define OAMADDL 0x2102
+#define OAMADDH 0x2103
+#define OAMDATA 0x2104
+#define BGMODE 0x2105
+#define MOSAIC 0x2106
+#define BG1SC 0x2107
+#define BG2SC 0x2108
+#define BG3SC 0x2109
+#define BG4SC 0x210a
+#define BG12NBA 0x210b
+#define BG34NBA 0x210c
+#define BG1HOFS 0x210d
+#define BG1VOFS 0x210e
+#define BG2HOFS 0x210f
+#define BG2VOFS 0x2110
+#define BG3HOFS 0x2111
+#define BG3VOFS 0x2112
+#define BG4HOFS 0x2113
+#define BG4VOFS 0x2114
+#define VMAIN 0x2115
+#define VMADDL 0x2116
+#define VMADDH 0x2117
+#define VMDATAL 0x2118
+#define VMDATAH 0x2119
+#define M7SEL 0x211a
+#define M7A 0x211b
+#define M7B 0x211c
+#define M7C 0x211d
+#define M7D 0x211e
+#define M7X 0x211f
+#define M7Y 0x2120
+#define CGADD 0x2121
+#define CGDATA 0x2122
+#define W12SEL 0x2123
+#define W34SEL 0x2124
+#define WOBJSEL 0x2125
+#define WH0 0x2126
+#define WH1 0x2127
+#define WH2 0x2128
+#define WH3 0x2129
+#define WBGLOG 0x212a
+#define WOBJLOG 0x212b
+#define TM 0x212c
+#define TS 0x212d
+#define TMW 0x212e
+#define TSW 0x212f
+#define CGWSEL 0x2130
+#define CGADSUB 0x2131
+#define COLDATA 0x2132
+#define SETINI 0x2133
+#define MPYL 0x2134
+#define MPYM 0x2135
+#define MPYH 0x2136
+#define SLHV 0x2137
+#define RDOAM 0x2138
+#define RDVRAML 0x2139
+#define RDVRAMH 0x213a
+#define RDCGRAM 0x213b
+#define OPHCT 0x213c
+#define OPVCT 0x213d
+#define STAT77 0x213e
+#define STAT78 0x213f
+#define APUI00 0x2140
+#define APUI01 0x2141
+#define APUI02 0x2142
+#define APUI03 0x2143
+#define WMDATA 0x2180
+#define WMADDL 0x2181
+#define WMADDM 0x2182
+#define WMADDH 0x2183
+#define JOYA 0x4016
+#define JOYB 0x4017
+#define NMITIMEN 0x4200
+#define WRIO 0x4201
+#define WRMPYA 0x4202
+#define WRMPYB 0x4203
+#define WRDIVL 0x4204
+#define WRDIVH 0x4205
+#define WRDIVB 0x4206
+#define HTIMEL 0x4207
+#define HTIMEH 0x4208
+#define VTIMEL 0x4209
+#define VTIMEH 0x420a
+#define MDMAEN 0x420b
+#define HDMAEN 0x420c
+#define MEMSEL 0x420d
+#define RDNMI 0x4210
+#define TIMEUP 0x4211
+#define HVBJOY 0x4212
+#define RDIO 0x4213
+#define RDDIVL 0x4214
+#define RDDIVH 0x4215
+#define RDMPYL 0x4216
+#define RDMPYH 0x4217
+#define JOY1L 0x4218
+#define JOY1H 0x4219
+#define JOY2L 0x421a
+#define JOY2H 0x421b
+#define JOY3L 0x421c
+#define JOY3H 0x421d
+#define JOY4L 0x421e
+#define JOY4H 0x421f
+
+#define DMAP0 0x4300
+#define BBAD0 0x4301
+#define A1T0L 0x4302
+#define A1T0H 0x4303
+#define A1B0 0x4304
+#define DAS0L 0x4305
+#define DAS0H 0x4306
+#define DAS00 0x4307
+#define A2A0L 0x4308
+#define A2A0H 0x4309
+#define NTRL0 0x430a
+#define UNUSED0 0x430b
+#define MIRR0 0x430f
+#define DMAP1 0x4310
+#define BBAD1 0x4311
+#define A1T1L 0x4312
+#define A1T1H 0x4313
+#define A1B1 0x4314
+#define DAS1L 0x4315
+#define DAS1H 0x4316
+#define DAS10 0x4317
+#define A2A1L 0x4318
+#define A2A1H 0x4319
+#define NTRL1 0x431a
+#define UNUSED1 0x431b
+#define MIRR1 0x431f
+#define DMAP2 0x4320
+#define BBAD2 0x4321
+#define A1T2L 0x4322
+#define A1T2H 0x4323
+#define A1B2 0x4324
+#define DAS2L 0x4325
+#define DAS2H 0x4326
+#define DAS20 0x4327
+#define A2A2L 0x4328
+#define A2A2H 0x4329
+#define NTRL2 0x432a
+#define UNUSED2 0x432b
+#define MIRR2 0x432f
+#define DMAP3 0x4330
+#define BBAD3 0x4331
+#define A1T3L 0x4332
+#define A1T3H 0x4333
+#define A1B3 0x4334
+#define DAS3L 0x4335
+#define DAS3H 0x4336
+#define DAS30 0x4337
+#define A2A3L 0x4338
+#define A2A3H 0x4339
+#define NTRL3 0x433a
+#define UNUSED3 0x433b
+#define MIRR3 0x433f
+#define DMAP4 0x4340
+#define BBAD4 0x4341
+#define A1T4L 0x4342
+#define A1T4H 0x4343
+#define A1B4 0x4344
+#define DAS4L 0x4345
+#define DAS4H 0x4346
+#define DAS40 0x4347
+#define A2A4L 0x4348
+#define A2A4H 0x4349
+#define NTRL4 0x434a
+#define UNUSED4 0x434b
+#define MIRR4 0x434f
+#define DMAP5 0x4350
+#define BBAD5 0x4351
+#define A1T5L 0x4352
+#define A1T5H 0x4353
+#define A1B5 0x4354
+#define DAS5L 0x4355
+#define DAS5H 0x4356
+#define DAS50 0x4357
+#define A2A5L 0x4358
+#define A2A5H 0x4359
+#define NTRL5 0x435a
+#define UNUSED5 0x435b
+#define MIRR5 0x435f
+#define DMAP6 0x4360
+#define BBAD6 0x4361
+#define A1T6L 0x4362
+#define A1T6H 0x4363
+#define A1B6 0x4364
+#define DAS6L 0x4365
+#define DAS6H 0x4366
+#define DAS60 0x4367
+#define A2A6L 0x4368
+#define A2A6H 0x4369
+#define NTRL6 0x436a
+#define UNUSED6 0x436b
+#define MIRR6 0x436f
+#define DMAP7 0x4370
+#define BBAD7 0x4371
+#define A1T7L 0x4372
+#define A1T7H 0x4373
+#define A1B7 0x4374
+#define DAS7L 0x4375
+#define DAS7H 0x4376
+#define DAS70 0x4377
+#define A2A7L 0x4378
+#define A2A7H 0x4379
+#define NTRL7 0x437a
+#define UNUSED7 0x437b
+#define MIRR7 0x437f
--- a/snes_regs.h
+++ /dev/null
@@ -1,211 +1,0 @@
-#pragma once
-
-#define INIDISP 0x2100
-#define OBSEL 0x2101
-#define OAMADDL 0x2102
-#define OAMADDH 0x2103
-#define OAMDATA 0x2104
-#define BGMODE 0x2105
-#define MOSAIC 0x2106
-#define BG1SC 0x2107
-#define BG2SC 0x2108
-#define BG3SC 0x2109
-#define BG4SC 0x210a
-#define BG12NBA 0x210b
-#define BG34NBA 0x210c
-#define BG1HOFS 0x210d
-#define BG1VOFS 0x210e
-#define BG2HOFS 0x210f
-#define BG2VOFS 0x2110
-#define BG3HOFS 0x2111
-#define BG3VOFS 0x2112
-#define BG4HOFS 0x2113
-#define BG4VOFS 0x2114
-#define VMAIN 0x2115
-#define VMADDL 0x2116
-#define VMADDH 0x2117
-#define VMDATAL 0x2118
-#define VMDATAH 0x2119
-#define M7SEL 0x211a
-#define M7A 0x211b
-#define M7B 0x211c
-#define M7C 0x211d
-#define M7D 0x211e
-#define M7X 0x211f
-#define M7Y 0x2120
-#define CGADD 0x2121
-#define CGDATA 0x2122
-#define W12SEL 0x2123
-#define W34SEL 0x2124
-#define WOBJSEL 0x2125
-#define WH0 0x2126
-#define WH1 0x2127
-#define WH2 0x2128
-#define WH3 0x2129
-#define WBGLOG 0x212a
-#define WOBJLOG 0x212b
-#define TM 0x212c
-#define TS 0x212d
-#define TMW 0x212e
-#define TSW 0x212f
-#define CGWSEL 0x2130
-#define CGADSUB 0x2131
-#define COLDATA 0x2132
-#define SETINI 0x2133
-#define MPYL 0x2134
-#define MPYM 0x2135
-#define MPYH 0x2136
-#define SLHV 0x2137
-#define RDOAM 0x2138
-#define RDVRAML 0x2139
-#define RDVRAMH 0x213a
-#define RDCGRAM 0x213b
-#define OPHCT 0x213c
-#define OPVCT 0x213d
-#define STAT77 0x213e
-#define STAT78 0x213f
-#define APUI00 0x2140
-#define APUI01 0x2141
-#define APUI02 0x2142
-#define APUI03 0x2143
-#define WMDATA 0x2180
-#define WMADDL 0x2181
-#define WMADDM 0x2182
-#define WMADDH 0x2183
-#define JOYA 0x4016
-#define JOYB 0x4017
-#define NMITIMEN 0x4200
-#define WRIO 0x4201
-#define WRMPYA 0x4202
-#define WRMPYB 0x4203
-#define WRDIVL 0x4204
-#define WRDIVH 0x4205
-#define WRDIVB 0x4206
-#define HTIMEL 0x4207
-#define HTIMEH 0x4208
-#define VTIMEL 0x4209
-#define VTIMEH 0x420a
-#define MDMAEN 0x420b
-#define HDMAEN 0x420c
-#define MEMSEL 0x420d
-#define RDNMI 0x4210
-#define TIMEUP 0x4211
-#define HVBJOY 0x4212
-#define RDIO 0x4213
-#define RDDIVL 0x4214
-#define RDDIVH 0x4215
-#define RDMPYL 0x4216
-#define RDMPYH 0x4217
-#define JOY1L 0x4218
-#define JOY1H 0x4219
-#define JOY2L 0x421a
-#define JOY2H 0x421b
-#define JOY3L 0x421c
-#define JOY3H 0x421d
-#define JOY4L 0x421e
-#define JOY4H 0x421f
-
-#define DMAP0 0x4300
-#define BBAD0 0x4301
-#define A1T0L 0x4302
-#define A1T0H 0x4303
-#define A1B0 0x4304
-#define DAS0L 0x4305
-#define DAS0H 0x4306
-#define DAS00 0x4307
-#define A2A0L 0x4308
-#define A2A0H 0x4309
-#define NTRL0 0x430a
-#define UNUSED0 0x430b
-#define MIRR0 0x430f
-#define DMAP1 0x4310
-#define BBAD1 0x4311
-#define A1T1L 0x4312
-#define A1T1H 0x4313
-#define A1B1 0x4314
-#define DAS1L 0x4315
-#define DAS1H 0x4316
-#define DAS10 0x4317
-#define A2A1L 0x4318
-#define A2A1H 0x4319
-#define NTRL1 0x431a
-#define UNUSED1 0x431b
-#define MIRR1 0x431f
-#define DMAP2 0x4320
-#define BBAD2 0x4321
-#define A1T2L 0x4322
-#define A1T2H 0x4323
-#define A1B2 0x4324
-#define DAS2L 0x4325
-#define DAS2H 0x4326
-#define DAS20 0x4327
-#define A2A2L 0x4328
-#define A2A2H 0x4329
-#define NTRL2 0x432a
-#define UNUSED2 0x432b
-#define MIRR2 0x432f
-#define DMAP3 0x4330
-#define BBAD3 0x4331
-#define A1T3L 0x4332
-#define A1T3H 0x4333
-#define A1B3 0x4334
-#define DAS3L 0x4335
-#define DAS3H 0x4336
-#define DAS30 0x4337
-#define A2A3L 0x4338
-#define A2A3H 0x4339
-#define NTRL3 0x433a
-#define UNUSED3 0x433b
-#define MIRR3 0x433f
-#define DMAP4 0x4340
-#define BBAD4 0x4341
-#define A1T4L 0x4342
-#define A1T4H 0x4343
-#define A1B4 0x4344
-#define DAS4L 0x4345
-#define DAS4H 0x4346
-#define DAS40 0x4347
-#define A2A4L 0x4348
-#define A2A4H 0x4349
-#define NTRL4 0x434a
-#define UNUSED4 0x434b
-#define MIRR4 0x434f
-#define DMAP5 0x4350
-#define BBAD5 0x4351
-#define A1T5L 0x4352
-#define A1T5H 0x4353
-#define A1B5 0x4354
-#define DAS5L 0x4355
-#define DAS5H 0x4356
-#define DAS50 0x4357
-#define A2A5L 0x4358
-#define A2A5H 0x4359
-#define NTRL5 0x435a
-#define UNUSED5 0x435b
-#define MIRR5 0x435f
-#define DMAP6 0x4360
-#define BBAD6 0x4361
-#define A1T6L 0x4362
-#define A1T6H 0x4363
-#define A1B6 0x4364
-#define DAS6L 0x4365
-#define DAS6H 0x4366
-#define DAS60 0x4367
-#define A2A6L 0x4368
-#define A2A6H 0x4369
-#define NTRL6 0x436a
-#define UNUSED6 0x436b
-#define MIRR6 0x436f
-#define DMAP7 0x4370
-#define BBAD7 0x4371
-#define A1T7L 0x4372
-#define A1T7H 0x4373
-#define A1B7 0x4374
-#define DAS7L 0x4375
-#define DAS7H 0x4376
-#define DAS70 0x4377
-#define A2A7L 0x4378
-#define A2A7H 0x4379
-#define NTRL7 0x437a
-#define UNUSED7 0x437b
-#define MIRR7 0x437f
--- a/tagalong.c
+++ b/tagalong.c
@@ -3,7 +3,7 @@
 #include "sprite.h"
 #include "zelda_rtl.h"
 #include "variables.h"
-#include "snes_regs.h"
+#include "snes/snes_regs.h"
 #include "dungeon.h"
 #include "overworld.h"
 #include "ancilla.h"
--- a/zelda3.vcxproj
+++ b/zelda3.vcxproj
@@ -224,8 +224,8 @@
     <ClInclude Include="snes\ppu.h" />
     <ClInclude Include="snes\saveload.h" />
     <ClInclude Include="snes\snes.h" />
+    <ClInclude Include="snes\snes_regs.h" />
     <ClInclude Include="snes\spc.h" />
-    <ClInclude Include="snes_regs.h" />
     <ClInclude Include="spc_player.h" />
     <ClInclude Include="sprite.h" />
     <ClInclude Include="sprite_main.h" />
--- a/zelda3.vcxproj.filters
+++ b/zelda3.vcxproj.filters
@@ -162,9 +162,6 @@
     <ClInclude Include="dungeon.h">
       <Filter>Zelda</Filter>
     </ClInclude>
-    <ClInclude Include="snes_regs.h">
-      <Filter>Zelda</Filter>
-    </ClInclude>
     <ClInclude Include="nmi.h">
       <Filter>Zelda</Filter>
     </ClInclude>
@@ -236,6 +233,9 @@
     </ClInclude>
     <ClInclude Include="config.h">
       <Filter>Zelda</Filter>
+    </ClInclude>
+    <ClInclude Include="snes\snes_regs.h">
+      <Filter>Snes</Filter>
     </ClInclude>
   </ItemGroup>
   <ItemGroup>
--- a/zelda_cpu_infra.c
+++ b/zelda_cpu_infra.c
@@ -7,7 +7,8 @@
 #include "nmi.h"
 #include "poly.h"
 #include "attract.h"
-
+#include "spc_player.h"
+#include "snes/snes_regs.h"
 #include "snes/snes.h"
 #include "snes/cpu.h"
 #include "snes/cart.h"
--- a/zelda_rtl.c
+++ b/zelda_rtl.c
@@ -5,6 +5,8 @@
 #include "poly.h"
 #include "attract.h"
 #include "snes/ppu.h"
+#include "snes/snes_regs.h"
+#include "spc_player.h"
 
 ZeldaEnv g_zenv;
 // These point to the rewritten instance of the emu.
--- a/zelda_rtl.h
+++ b/zelda_rtl.h
@@ -9,18 +9,16 @@
 #include <assert.h>
 
 #include "types.h"
-#include "snes_regs.h"
-#include "snes/dma.h"
-#include "snes/ppu.h"
-#include "spc_player.h"
 
+struct Snes;
+
 typedef struct ZeldaEnv {
   uint8 *ram;
   uint8 *sram;
   uint16 *vram;
-  Ppu *ppu;
-  SpcPlayer *player;
-  Dma *dma;
+  struct Ppu *ppu;
+  struct SpcPlayer *player;
+  struct Dma *dma;
 } ZeldaEnv;
 extern ZeldaEnv g_zenv;
 
@@ -196,6 +194,6 @@
 void Startup_InitializeMemory();
 void LoadSongBank(const uint8 *p);
 void ZeldaWriteSram();
-void ZeldaReadSram(Snes *snes);
+void ZeldaReadSram(struct Snes *snes);
 
 #endif  // ZELDA_RTL_H