<NME> CODEWAD.H
<BEF> #ifndef CODEWAD_H
#define CODEWAD_H

#include <stdio.h>
#include "IO.H"

#define NUM_OVERLAYS 59

struct fileEntry
{
	unsigned int binData[2];//Offset, Size
	unsigned int relData[2];//Offset, Size
	unsigned int padding;
};

extern void CODEWAD_Unpack(const char* fileName);
extern void CODEWAD_DumpOverlay(char* fileName, IO::StreamReader* reader, unsigned int* entry);

#endif
<MSG> Merge branch 'master' of https://github.com/TOMB5/TOMB5 into appveyor

<DFF> @@ -10,7 +10,7 @@ struct fileEntry
 {
 	unsigned int binData[2];//Offset, Size
 	unsigned int relData[2];//Offset, Size
-	unsigned int padding;
+	unsigned int moduleIndex;
 };
 
 extern void CODEWAD_Unpack(const char* fileName);

{'commit': 'diff --git a/.gitignore b/.gitignore\nindex 05976d8a..eb4b39c2 100644\n--- a/.gitignore\n+++ b/.gitignore\n@@ -29,4 +29,8 @@\n /DISC/*.CUE\n /DISC/*.OBJ\n /GAME/*.OBJ\n-/SPEC_PSX/*.OBJ\n\\ No newline at end of file\n+/SPEC_PSX/*.OBJ\n+/SPEC_PSX/*.BIN\n+/SPEC_PSX/*.REL\n+/GAME/*.REL\n+/GAME/*.BIN\n\\ No newline at end of file\ndiff --git a/CONTRIBUTING.md b/CONTRIBUTING.md\nindex 580d411d..9615f9f8 100644\n--- a/CONTRIBUTING.md\n+++ b/CONTRIBUTING.md\n@@ -9,6 +9,7 @@ If you\'re able to code in C/C++ please feel free to contact me. I can assign you\n - MIPS R3000 Programmer/Interpreter - Translate TR5 PSX MIPS Disassembled output back to C.\n - x86 Programmer/Interpreter - Translate TR5 PC x86 asm back to C. \n - SH4 Programmer/Interpreter - Translate TR5 Dreamcast SH4 asm back to C. \n+- PPC Programmer/Interpreter - Translate TR5 Mac PPC asm back to C. \n - Platform Programmer (Mac) - (Maintain and ensure that PSXPC code compiles under Mac OSX).\n - Platform Programmer (Linux) - (Maintain and ensure that PSXPC code compiles under Linux).\n - Code Analyser (ASM - PSX) - Compare compiled code to the original to help detect any possible errors in exising code.\n@@ -22,10 +23,10 @@ If you\'re able to code in C/C++ please feel free to contact me. I can assign you\n - SPEC_PC - Platform specific code for PC version.\n - SPEC_PSX - Platform specific code for PSX version.\n - SPEC_PSXPC - Platform specific code for PSX version that runs on PC for debugging purposes (all psx sdk calls stripped).\n-- TOOLS - Game tools (may be removed in the future).\n+- TOOLS - Game tools folder, contains various tools to work with the game files.\n - DISC - Contains PSX specific disc project generation files.\n \n-## Base Versions\n+## Base Version (PSX)\n - PSX NTSC v1.0 SLUS_013.11 MD5: (4EF523E708D7A7D6571F39C6E47784F9)\n \n ## Compiling\ndiff --git a/GAME/CODEWAD.H b/GAME/CODEWAD.H\nindex a8aea35a..eefc3a0d 100644\n--- a/GAME/CODEWAD.H\n+++ b/GAME/CODEWAD.H\n@@ -7,5 +7,62 @@ extern void TriggerEngineEffects_CUT(); // 0x10 (RelocPtr + 0x18)\n extern long sub_1BE988();\n extern long sub_1BDF88(long levelID); // Titleoptions\n \n+#if PSX_VERSION || PSXPC_VERSION\n+\n+enum module_indices\n+{\n+\tMOD_WEATHER,\n+\tMOD_LARA,\n+\tMOD_ROOMLET,\n+\tMOD_UWPARTS,\n+\tMOD_MOVEBLOK,\n+\tMOD_SAS,\n+\tMOD_SUBSUIT,\n+\tMOD_TWOGUN,\n+\tMOD_HYDRA,\n+\tMOD_RAT,\n+\tMOD_ROPE,\n+\tMOD_DEATHSLD,\n+\tMOD_LASERS,\n+\tMOD_TITSEQ,\n+\tMOD_STARS,\n+\tMOD_PIERRE,\n+\tMOD_CROW,\n+\tMOD_HITMAN,\n+\tMOD_LION,\n+\tMOD_IMP,\n+\tMOD_GLADIATR,\n+\tMOD_BAT,\n+\tMOD_DOG,\n+\tMOD_HUSKIE,\n+\tMOD_MAFIA2,\n+\tMOD_SNIPER,\n+\tMOD_WILLWISP,\n+\tMOD_TOWER2,\n+\tMOD_SKELETON,\n+\tMOD_ROMANGOD,\n+\tMOD_SWAMPY,\n+\tMOD_JOBY2,\n+\tMOD_SPIDER,\n+\tMOD_ANDREA2,\n+\tMOD_GUARDIAN,\n+\tMOD_LIGHTNG,\n+\tMOD_CHEF,\n+\tMOD_AUTOGUN,\n+\tMOD_JOBY3,\n+\tMOD_MINISUB,\n+\tMOD_TOWER3,\n+\tMOD_ANDREA1,\n+\tMOD_ANDREA3,\n+\tMOD_ANDY1,\n+\tMOD_ANDY2,\n+\tMOD_ANDY3,\n+\tMOD_TOWER1,\n+\tMOD_JOBY4,\n+\tMOD_JOBY5,\n+\tMOD_LIFTS,\n+\tMOD_T12\n+};\n+#endif\n \n #endif\n\\ No newline at end of file\ndiff --git a/GAME/CONTROL.C b/GAME/CONTROL.C\nindex d76c9d97..bb460356 100644\n--- a/GAME/CONTROL.C\n+++ b/GAME/CONTROL.C\n@@ -839,6 +839,7 @@ long ControlPhase(long nframes, int demo_mode)//1D538(<), 1D6CC(<) //DO NOT TOUC\n \n \tif (bTrackCamInit)\n \t{\n+\t\tprintf("bTrackCamInit Zero\\n");\n \t\tbUseSpotCam = 0;\n \t}\n \n@@ -1404,7 +1405,9 @@ void TestTriggers(short* data, int heavy, int HeavyFlags)//(F)\n }\n \n long rand_1 = 0xD371F947;\n+long rand_2 = 0xD371F947;\n \n+#if PC_VERSION ///@FIXME remove, this needs to go in specific\n long GetRandomControl()//5E9F0, 926F8 (F)\n {\n \trand_1 = (rand_1 * 0x41C64E6D) + 0x3039;\n@@ -1416,8 +1419,6 @@ void SeedRandomControl(long seed)//(F)\n \trand_1 = seed;\n }\n \n-long rand_2 = 0xD371F947;\n-\n long GetRandomDraw()//5EA18, 5F6F8 (F)\n {\n \trand_2 = (rand_2 * 0x41C64E6D) + 0x3039;\n@@ -1428,6 +1429,7 @@ void SeedRandomDraw(long seed)//(F)\n {\n \trand_2 = seed;\n }\n+#endif\n \n void ClearFires()//8B1C8(<), 8D20C(<) (F)\n {\n@@ -2168,6 +2170,7 @@ void AddRoomFlipItems(struct room_info* r)//1FA0C(<), 1FC20(<) (F)\n \t}\n }\n \n+#if PC_VERSION || PSXPC_VERSION\n int IsRoomOutside(long x, long y, long z)//8EF00(<), 90F44(<) (F)\n {\n \tshort off, room_num;\n@@ -2239,6 +2242,7 @@ int IsRoomOutside(long x, long y, long z)//8EF00(<), 90F44(<) (F)\n \n \treturn -2;\n }\n+#endif\n \n short GetDoor(struct FLOOR_INFO* floor)//787CC(<), 7A810(<) (F)\n {\ndiff --git a/GAME/CONTROL.H b/GAME/CONTROL.H\nindex 481ef40e..9414f82c 100644\n--- a/GAME/CONTROL.H\n+++ b/GAME/CONTROL.H\n@@ -168,10 +168,12 @@ extern struct CHARDEF CharDef[106];\n extern struct ROPE_STRUCT Ropes[12];\n \n extern long ControlPhase(long nframes, int demo_mode);\n+#if PC_VERSION ///@FIXME remove, this needs to go in specific\n extern long GetRandomControl();\n extern void SeedRandomControl(long seed);\n extern long GetRandomDraw();\n extern void SeedRandomDraw(long seed);\n+#endif\n extern void AddRoomFlipItems(struct room_info* r);\n extern void KillMoveItems();\n extern void KillMoveEffects();\n@@ -203,7 +205,9 @@ extern struct FLOOR_INFO* GetFloor(int x, int y, int z, short* room_number);\n extern short GetCeiling(struct FLOOR_INFO* floor, int x, int y, int z);\n extern int TriggerActive(struct ITEM_INFO* item);\n extern void AddRoomFlipItems(struct room_info* r);\n+#if PC_VERSION || PSXPC_VERSION\n extern int IsRoomOutside(long x, long y, long z);\n+#endif\n extern short GetDoor(struct FLOOR_INFO* floor);\n extern int LOS(struct GAME_VECTOR* start, struct GAME_VECTOR* target);\n extern int xLOS(struct GAME_VECTOR* start, struct GAME_VECTOR* target);\ndiff --git a/GAME/DELTAPAK.C b/GAME/DELTAPAK.C\nindex f8e4cbaf..dd730283 100644\n--- a/GAME/DELTAPAK.C\n+++ b/GAME/DELTAPAK.C\n@@ -23,6 +23,7 @@\n #include "TEXT.H"\n #include "TOMB4FX.H"\n #include "TYPES.H"\n+#include "TYPEDEFS.H"\n \n #if PC_VERSION\n #include "GLOBAL.H"\n@@ -46,6 +47,11 @@\n #include "EFFECTS.H"\n #include <stdio.h>\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n \n struct CUTSEQ_ROUTINES cutseq_control_routines[45] =\n {\n@@ -2574,14 +2580,22 @@ void special2_init()//2E674(<), 2E980(<) (F)\n \tspecial_num = 2;\n }\n \n-void special1_end()//2E644(<), 2E950(<)\n+void special1_end()//2E644(<), 2E950(<) (F) (*)\n {\n+#if PSX_VERSION\n+\t((VOIDFUNCVOID*)RelocPtr[13][4])();\n+#else\n \tUNIMPLEMENTED();\n+#endif\n }\n \n-void special1_control()//2E614(<), 2E920(<)\n+void special1_control()//2E614(<), 2E920(<) (F) (*)\n {\n+#if PSX_VERSION\n+\t((VOIDFUNCVOID*)RelocPtr[13][3])();\n+#else\n \tUNIMPLEMENTED();\n+#endif\n }\n \n void special1_init()//2E5E4(<), 2E8F0(<) (F)\ndiff --git a/GAME/DRAW.C b/GAME/DRAW.C\nindex e11c2397..7caa0d9b 100644\n--- a/GAME/DRAW.C\n+++ b/GAME/DRAW.C\n@@ -14,6 +14,10 @@\n #include "TOMB4FX.H"\n #include <stddef.h>\n //#include <INLINE_O.H>\n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n \n short LightningSFXDelay;\n struct room_info* room;\ndiff --git a/GAME/EFFECT2.C b/GAME/EFFECT2.C\nindex 9f70d583..b3168e34 100644\n--- a/GAME/EFFECT2.C\n+++ b/GAME/EFFECT2.C\n@@ -14,6 +14,11 @@\n #include "SETUP.H"\n #endif\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n long wibble;\n long SplashCount;\n long KillEverythingFlag;\ndiff --git a/GAME/EFFECTS.C b/GAME/EFFECTS.C\nindex 7bf5c5cc..76d035a5 100644\n--- a/GAME/EFFECTS.C\n+++ b/GAME/EFFECTS.C\n@@ -31,6 +31,11 @@\n \n #include <string.h>\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n long wf = 256;\n short next_fx_free;\n short next_fx_active;\n@@ -571,6 +576,7 @@ void SoundEffects()//39190(<), 39690 (F)\n \tSOUND_EndScene();\n }\n \n+#if PSXPC_VERSION\n long SoundEffect(short sample_index, struct PHD_3DPOS* pos, int arg2)//91780(<), 937C4(!)\n {\n \tlong r;\n@@ -693,7 +699,7 @@ long SoundEffect(short sample_index, struct PHD_3DPOS* pos, int arg2)//91780(<),\n \n \tUNIMPLEMENTED();\n }\n-\n+#endif\n \n void StopSoundEffect(short sample_index)//91FF8(<), 94044(<) (F)\n {\ndiff --git a/GAME/FLMTORCH.C b/GAME/FLMTORCH.C\nindex 3c39df2a..4dc7fea5 100644\n--- a/GAME/FLMTORCH.C\n+++ b/GAME/FLMTORCH.C\n@@ -14,6 +14,11 @@\n #include "SPECIFIC.H"\n #include "TOMB4FX.H"\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n static short FireBounds[12] =\n {\n \t0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF8E4, 0x071C, 0xEAAC, 0x1554, 0xF8E4, 0x071C\ndiff --git a/GAME/GAMEFLOW.C b/GAME/GAMEFLOW.C\nindex a4c15b1c..3d75124d 100644\n--- a/GAME/GAMEFLOW.C\n+++ b/GAME/GAMEFLOW.C\n@@ -2,11 +2,13 @@\n \n #if !PC_VERSION\n #include "3D_GEN.H"\n+#include "TITSEQ.H"\n #endif\n #include "CODEWAD.H"\n #include "CONTROL.H"\n #include "DELTAPAK.H"\n #include "DRAW.H"\n+#include "TYPEDEFS.H"\n \n #include "FILE.H"\n #if !PC_VERSION\n@@ -109,14 +111,15 @@ static int gfStatus;\n static unsigned long OldSP;\n unsigned char gfPickups[16];\n unsigned char gfTakeaways[16];\n+int special_features_num = -1;\n #if PC_VERSION\n char* gfScriptFile;\n-#endif\n-int special_features_num = -1;\n+\n const char* screens[5] =\n {\n \t"SCREENS\\\\STORY1.STR", "SCREENS\\\\NXG.STR", "SCREENS\\\\STORY2.STR", "SCREENS\\\\GALLERY.STR", "SCREENS\\\\SCREENS.STR"\n };\n+#endif\n \n void DoGameflow()//10F5C(<), 10FD8(<)\n {\n@@ -512,7 +515,7 @@ void QuickControlPhase()//10274(<), 10264(<) (F)\n \tOldSP = SetSp(0x1F8003E0);\n #endif\n \n-#if PSX_VERSION\n+#if PSX_VERSION || PSXPC_VERSION\n \tgfStatus = ControlPhase(nframes, (gfGameMode ^ 2) < 1 ? 1 : 0);\n #else\n \tgfStatus = ControlPhase(nframes, 0);\n@@ -532,7 +535,6 @@ void DoTitle(unsigned char Name, unsigned char Audio)//10604(<), 105C4(<)\n \tS_Warn("DoTitle PC");\n \tgfCurrentLevel = LVL5_STREETS_OF_ROME;\n \tDoLevel(LVL5_STREETS_OF_ROME, Audio);\n-\n \treturn;\n #endif*/\n \n@@ -559,16 +561,16 @@ void DoTitle(unsigned char Name, unsigned char Audio)//10604(<), 105C4(<)\n \tXAMasterVolume = savegame.VolumeCD;\n #endif\n \n-\tmemset(&savegame.Level, 0, sizeof(struct STATS));\n-\tmemset(&savegame.Game, 0, sizeof(struct STATS));\n+\tS_MemSet(&savegame.Level, 0, sizeof(struct STATS));\n+\tS_MemSet(&savegame.Game, 0, sizeof(struct STATS));\n \n \tS_LoadLevelFile(Name);\n-\n+\t\n \tGLOBAL_lastinvitem = -1;\n \tdels_cutseq_player = 0;\n \n \tInitSpotCamSequences();\n-\n+\t\n \ttitle_controls_locked_out = 0;\n \n #if PC_VERSION\n@@ -589,58 +591,53 @@ void DoTitle(unsigned char Name, unsigned char Audio)//10604(<), 105C4(<)\n #if PC_VERSION\n \tS_InitialiseScreen();\n #endif\n-\n+\t\n \tSOUND_Stop();\n \n \tIsAtmospherePlaying = 0;\n-\n+\t\n \tS_SetReverbType(1);\n \n \tInitialiseCamera();\n \n-\tif (bDoCredits)\n-\t{\n-\t\tcutseq_num = 28;\n-\t\tSetFadeClip(32, 1);\n-\t\tScreenFadedOut = 1;\n-\t\tScreenFade = 255;\n-\t\tdScreenFade = 255;\n-\n-#if PC_VERSION\n-\t\tS_CDPlay(CDA_XA14_ECREDITS, 1);\n-#endif\n-\t}\n-\telse\n+\tif (!bDoCredits)\n \t{\n \t\ttrigger_title_spotcam(1);\n-\n \t\tScreenFadedOut = 0;\n \t\tScreenFade = 0;\n \t\tdScreenFade = 0;\n \t\tScreenFadeBack = 0;\n \t\tScreenFadeSpeed = 8;\n \t\tScreenFading = 0;\n-\n-#if BETA_VERSION\n+\t}\n+\telse\n+\t{\n+\t\t//loc_10730\n+\t\tcutseq_num = 28;\n+\t\tSetFadeClip(32, 1);\n+\t\tScreenFadedOut = 1;\n+\t\tScreenFade = 255;\n+\t\tdScreenFade = 255;\n+#if !BETA_VERSION\n \t\tS_CDPlay(CDA_XA14_ECREDITS, 1);\n #endif\n \t}\n \n-\t//loc_10764, loc_10730\n+\t//loc_10764\n \tbUseSpotCam = 1;\n \tlara_item->mesh_bits = 0;\n \tgfGameMode = 1;\n \n-#if 1//INTERNAL\n+#if 1//DEBUG_VERSION\n \tshow_game_malloc_totals();\n #endif\n \n \tgfLevelComplete = 0;\n \tnframes = 2;\n \tgfStatus = ControlPhase(2, 0);\n-\n-\tJustLoaded = 0;\n \t\n+\tJustLoaded = 0;\n+\n #if PC_VERSION\n \twhile (gfStatus == 0)\n \t{\n@@ -655,94 +652,86 @@ void DoTitle(unsigned char Name, unsigned char Audio)//10604(<), 105C4(<)\n \t\tDoSpecialFeaturesServer();\n \t}\n #else\n-\t\n-\t\t//loc_107BC, 10778\n+\tif (gfStatus == 0)\n+\t{\n+\t\t//loc_107BC\n \t\twhile (gfStatus == 0)\n \t\t{\n \t\t\tGPU_BeginScene();\n \n \t\t\tif (bDoCredits)\n \t\t\t{\n-\t\t\t\tif (sub_1BE988() == 0)\n+\t\t\t\tif (!((INTFUNCVOID*)RelocPtr[MOD_TITSEQ][1])())\n \t\t\t\t{\n \t\t\t\t\tbDoCredits = 0;\n \t\t\t\t\tSetFadeClip(0, 2);\n-\n-\t\t\t\t\tif (bDoCredits != 0)\n-\t\t\t\t\t{\n-\t\t\t\t\t\tgoto lbl_10890;\n-\t\t\t\t\t}\n \t\t\t\t}\n+\t\t\t\t//loc_10800\n+\t\t\t\tif (bDoCredits)\n+\t\t\t\t\tgoto loc_10890;\n+\t\t\t\t\t\n \t\t\t}\n-\n-\t\t\t//FIXME branching is seriously mangled here\n \t\t\t//loc_10810\n-\t\t\tif (GLOBAL_playing_cutseq != 0)//todo merge case with below then else the rest to sim jump\n-\t\t\t{\n-\t\t\t\tgoto lbl_108A4;\n-\t\t\t}\n-\n-\t\t\tif (ScreenFading != 0 || cutseq_num != 0)\n+\t\t\tif (GLOBAL_playing_cutseq == 0)\n \t\t\t{\n-\t\t\t\tgoto lbl_10890;\n-\t\t\t}\n-\n+\t\t\t\tif (ScreenFading == 0 && cutseq_num == 0)\n+\t\t\t\t{\n #if DEBUG_VERSION\n-\t\t\tif (RawPad & 0x201)\n-\t\t\t{\n-\t\t\t\tdels_cutseq_selector_flag = 1;\n-\t\t\t}\n+\t\t\t\t\tif ((RawPad & 0x201))\n+\t\t\t\t\t{\n+\t\t\t\t\t\tdels_cutseq_selector_flag = 1;\n+\t\t\t\t\t}\n #endif\n-\t\t\t//loc_10868\n-\t\t\tCreditsDone = 1;\n-\t\t\tgfStatus = sub_1BDF88(Name);//TitleOptions(void);\n-\n-\t\tlbl_10890:\n-\t\t\tif (GLOBAL_playing_cutseq != 0)\n-\t\t\t{\n-\t\t\tlbl_108A4:\n-\t\t\t\tif (!bDoCredits || CreditsDone != 0)\n-\t\t\t\t{\n-#if BETA_VERSION\n-\t\t\t\t\tPrintString(256, 220, 1, &gfStringWad[gfStringOffset[176]], 0);\n+\t\t\t\t\t//loc_10868\n+\t\t\t\t\tCreditsDone = 1;\n+#if RELOC\n+\t\t\t\t\tgfStatus = ((INTFUNCINT*)RelocPtr[MOD_TITSEQ][0])(Name);\n #else\n-\t\t\t\t\tPrintString(256, 220, 1, &gfStringWad[gfStringOffset[174]], 0);\n+\t\t\t\t\tgfStatus = TitleOptions(Name);\n #endif\n-\t\t\t\t}\n+\t\t\t\t\tif (gfStatus != 0)\n+\t\t\t\t\t\tgoto loc_10A24;\n \n-\t\t\t}\n+\t\t\t\t}//loc_10890\n \n+\t\t\tloc_10890:\n+\t\t\t\tif (GLOBAL_playing_cutseq == 0)\n+\t\t\t\t\tgoto loc_108EC;\n+\t\t\t}\n+\t\t\t//loc_108A4\n+\t\t\tif (bDoCredits == 0 && CreditsDone)\n+\t\t\t{\n+\t\t\t\tPrintString(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 20, 1, &gfStringWad[gfStringOffset[STR_DEMO_MODE]], 0x8000);\n+\t\t\t}\n \t\t\t//loc_108EC\n+\t\tloc_108EC:\n \t\t\tnframes = DrawPhaseGame();\n \n-#if PSX_VERSION || PSXPC_VERSION\n-\t\t\tif (PadConnected == 0)\n+\t\t\tif (!PadConnected)\n \t\t\t{\n-#if BETA_VERSION\n-\t\t\t\tPrintString(256, 128, 3, &gfStringWad[gfStringOffset[221]], 0);\n-#else\n-\t\t\t\tPrintString(256, 128, 3, &gfStringWad[gfStringOffset[219]], 0);\n-#endif\n+\t\t\t\t\n+\t\t\t\tPrintString(SCREEN_WIDTH / 2, (SCREEN_HEIGHT / 2) + 8, 3, &gfStringWad[gfStringOffset[STR_CONTROLLER_REMOVED]], 0xA000);\n \t\t\t}\n-#endif\n-\n \t\t\t//loc_1092C\n \t\t\thandle_cutseq_triggering(Name);\n \n \t\t\tif (gfGameMode == 2)\n \t\t\t{\n-#if PSX_VERSION || PSXPC_VERSION\n-\t\t\t\tif (!(dbinput & 0x100) || GLOBAL_enterinventory != -1)\n+\t\t\t\t//v0 = -1;\n+\t\t\t\tif ((dbinput & 0x100))\n+\t\t\t\t\tgoto loc_10970;\n+\n+\t\t\t\tif (GLOBAL_enterinventory == -1)\n+\t\t\t\t\tgoto loc_109A8;\n+\n+\t\t\t\t//loc_10970\n+\t\t\tloc_10970:\n+\t\t\t\tif (cutseq_trig == 0 && lara_item->hit_points > 0)\n \t\t\t\t{\n-\t\t\t\t\tif (cutseq_trig == 0 && lara_item->hit_points > 0)\n-\t\t\t\t\t{\n-\t\t\t\t\t\tS_CallInventory2();\n-\t\t\t\t\t}\n-\t\t\t\t}\n-#endif\n-\t\t\t}\n-\t\t\t\n-\t\t\t//loc_109A8\n+\t\t\t\t\tS_CallInventory2();\n+\t\t\t\t}//loc_109A8\n+\t\t\t}//loc_109A8\n+\t\tloc_109A8:\n \t\t\tQuickControlPhase();\n \n \t\t\tif (gfGameMode == 2 && ScreenFadedOut != 0)\n@@ -751,35 +740,29 @@ void DoTitle(unsigned char Name, unsigned char Audio)//10604(<), 105C4(<)\n \n \t\t\t\tif (number_rooms > 0)\n \t\t\t\t{\n-\t\t\t\t\tfor (i = 0; i < number_rooms; i++)\n-\t\t\t\t\t{\n-\t\t\t\t\t\troom[i].flags = -1;\n-\t\t\t\t\t}\n+\t\t\t\t\ti = number_rooms;\n+\t\t\t\t\twhile (i--)\n+\t\t\t\t\t\troom[i].item_number = -1;\n \t\t\t\t}\n-\n+\t\t\t\t//loc_10A10\n \t\t\t\tgfGameMode = 1;\n \n \t\t\t}//loc_10A14\n \t\t}\n-\t\n-\t\n+\t}\n \t//loc_10A24\n-#if PSX_VERSION || PSXPC_VERSION\n \n-\tMotors[0] = 0;\n+loc_10A24:\n \tMotors[1] = 0;\n+\tMotors[0] = 0;\n \n \tif (Gameflow->LoadSaveEnabled)\n \t{\n \t\tmcClose();\n \t}\n-\t\n \t//loc_10A58\n \twhile (XAVolume != 0)\n-\t{\n \t\tXAReqVolume = 0;\n-\t}\n-#endif\n #endif\n \n \tNoInput = 0;\n@@ -788,8 +771,12 @@ void DoTitle(unsigned char Name, unsigned char Audio)//10604(<), 105C4(<)\n \tbUseSpotCam = 0;\n \tbDisableLaraControl = 0;\n \n+#if PSX_VERSION || PSXPC_VERSION\n+\tinput = 0;\n+#else\n \tif (gfStatus != 4)\n \t\tinput = 0;\n+#endif\n \n }\n \n@@ -1076,12 +1063,6 @@ void DoLevel(unsigned char Name, unsigned char Audio)//10ABC(<) 10A84(<) (F)\n \treset_flag = 0;\n }\n \n-int TitleOptions()\n-{\n-\tUNIMPLEMENTED();\n-\treturn 0;\n-}\n-\n void SpecialFeaturesDisplayScreens(int num)\n {\n \tUNIMPLEMENTED();\ndiff --git a/GAME/GAMEFLOW.H b/GAME/GAMEFLOW.H\nindex 5e30b637..ff654fad 100644\n--- a/GAME/GAMEFLOW.H\n+++ b/GAME/GAMEFLOW.H\n@@ -8,7 +8,6 @@ extern void LoadGameflow();\n extern void QuickControlPhase();\n extern void DoTitle(unsigned char Name, unsigned char Audio);\n extern void DoLevel(unsigned char Name, unsigned char Audio);\n-extern int TitleOptions();\n extern void DoSpecialFeaturesServer();\n \n enum gf_languages\ndiff --git a/GAME/LARA.C b/GAME/LARA.C\nindex 45709a98..aa7f21d2 100644\n--- a/GAME/LARA.C\n+++ b/GAME/LARA.C\n@@ -18,6 +18,11 @@\n #include "LARAFIRE.H"\n #include "CODEWAD.H"\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n #define SLOPE_DIF 60\n \n static short LeftClimbTab[4] = // offset 0xA0638\ndiff --git a/GAME/LARAFLAR.C b/GAME/LARAFLAR.C\nindex 58294505..5957efb2 100644\n--- a/GAME/LARAFLAR.C\n+++ b/GAME/LARAFLAR.C\n@@ -17,6 +17,11 @@\n #include "CONTROL.H"\n #include "EFFECT2.H"\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n void FlareControl(short item_number)//4A418, 4A87C\n {\n \tUNIMPLEMENTED();\ndiff --git a/GAME/LARASWIM.C b/GAME/LARASWIM.C\nindex b5c46994..ad83a67c 100644\n--- a/GAME/LARASWIM.C\n+++ b/GAME/LARASWIM.C\n@@ -345,6 +345,7 @@ void LaraUnderWater(struct ITEM_INFO* item, struct COLL_INFO* coll)//4BFB4, 4C41\n \n void UpdateSubsuitAngles()//4BD20, 4C184 (F)\n {\n+#ifdef PC_VERSION\n \tif (subsuit.YVel != 0)\n \t{\n \t\tlara_item->pos.y_pos += subsuit.YVel / 4;\n@@ -409,6 +410,7 @@ void UpdateSubsuitAngles()//4BD20, 4C184 (F)\n \t\t// todo make the formula clearer\n \t\tSoundEffect(SFX_LARA_UNDERWATER_ENGINE, &lara_item->pos, (((subsuit.Vel[0] + subsuit.Vel[1]) * 4) & 0x1F00) + 10);\n \t}\n+#endif\n }\n \n void SwimTurnSubsuit(struct ITEM_INFO* item)//4BBDC, 4C040 (F)\ndiff --git a/GAME/LION.C b/GAME/LION.C\nnew file mode 100644\nindex 00000000..abdc95d8\n--- /dev/null\n+++ b/GAME/LION.C\n@@ -0,0 +1,214 @@\n+#include "LION.H"\n+\n+#include "DRAW.H"\n+#include "BOX.H"\n+#include "LARA.H"\n+#include "OBJECTS.H"\n+#include "SETUP.H"\n+#include "CONTROL.H"\n+#include "TOMB4FX.H"\n+#include "SPECTYPES.H"\n+\n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+struct BITE_INFO LION_BITE_1 = { 0x0FFFFFFFE, 0x0FFFFFFF6, 0x0FA, 0x15 };\n+struct BITE_INFO LION_BITE_2 = { 0x0FFFFFFFE, 0x0FFFFFFF6, 0x84, 0x15 };\n+\n+void InitialiseLion(short item_num)\n+{\n+\tstruct ITEM_INFO* item = &items[item_num];\n+\t\n+\tInitialiseCreature(item_num);\n+\titem->anim_number = objects[LION].anim_index;\n+\titem->frame_number = anims[objects[LION].anim_index].frame_base;\n+\titem->goal_anim_state = 1;\n+\titem->current_anim_state = 1;\n+}\n+\n+void LionControl(short item_num)\n+{\n+\tshort angle;\n+\tshort required;\n+\tchar *data;\n+\tstruct ITEM_INFO* item;\n+\tshort Lion_Object;\n+\tshort Lion_DefaultAnim;\n+\tshort Creature_Turn;\n+\tshort Creature_Angle;\n+\tshort requiredAngle;\n+\tshort requiredAnimState;\n+\tint v9;\n+\tint v10;\n+\tstruct AI_info info;\n+\n+\tdata = (char*)items[item_num].data;\n+\titem = &items[item_num];\n+\tif (CreatureActive(item_num))\n+\t{\n+\t\trequiredAngle = 0;\n+\t\tCreature_Angle = 0;\n+\t\tangle = 0;\n+\t\trequired = 0;\n+\t\tdata = (char *)items[item_num].data;\n+\t\titem = &items[item_num];\n+\t\tif (items[item_num].hit_points <= 0)\n+\t\t{\n+\t\t\titem->hit_points = 0;\n+\t\t\tif (item->current_anim_state != 5)\n+\t\t\t{\n+\t\t\t\tLion_Object = objects[57].anim_index + (GetRandomControl() & 1) + 7;\n+\t\t\t\titem->anim_number = Lion_Object;\n+\t\t\t\tLion_DefaultAnim = anims[Lion_Object].frame_base;\n+\t\t\t\titem->current_anim_state = 5;\n+\t\t\t\titem->frame_number = Lion_DefaultAnim;\n+\t\t\t}\n+\t\t\tCreatureTilt(item, angle);\n+\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\tCreatureJoint(item, 1, required);\n+\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\treturn;\n+\t\t}\n+\t\tCreatureAIInfo(item, &info);\n+\t\tif (info.ahead)\n+\t\t\trequired = info.angle;\n+\t\tGetCreatureMood(item, &info, 1);\n+\t\tCreatureMood(item, &info, 1);\n+\t\tCreature_Turn = CreatureTurn(item, *((unsigned short *)data + 4));\n+\t\tCreature_Angle = Creature_Turn;\n+\t\trequiredAngle = -16 * Creature_Turn;\n+\t\tswitch (item->current_anim_state)\n+\t\t{\n+\t\tcase 1:\n+\t\t\t*((unsigned short *)data + 4) = 0;\n+\t\t\trequiredAnimState = item->required_anim_state;\n+\t\t\tif (requiredAnimState)\n+\t\t\t{\n+\t\t\t\titem->goal_anim_state = requiredAnimState;\n+\t\t\t\tCreatureTilt(item, angle);\n+\t\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\t\tCreatureJoint(item, 1, required);\n+\t\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\t\treturn;\n+\t\t\t}\n+\t\t\tif (!*(unsigned long *)(data + 14))\n+\t\t\t{\n+\t\t\t\tif (!(GetRandomControl() & 0x3F))\n+\t\t\t\t\titem->goal_anim_state = 2;\n+\t\t\t\tCreatureTilt(item, angle);\n+\t\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\t\tCreatureJoint(item, 1, required);\n+\t\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\t\treturn;\n+\t\t\t}\n+\t\t\tif (info.ahead)\n+\t\t\t{\n+\t\t\t\tif (item->touch_bits & 0x200048)\n+\t\t\t\t{\n+\t\t\t\t\titem->goal_anim_state = 7;\n+\t\t\t\t\tCreatureTilt(item, angle);\n+\t\t\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\t\t\tCreatureJoint(item, 1, required);\n+\t\t\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\t\t\treturn;\n+\t\t\t\t}\n+\t\t\t\tif (info.distance < 0x100000)\n+\t\t\t\t{\n+\t\t\t\t\titem->goal_anim_state = 4;\n+\t\t\t\t\tCreatureTilt(item, angle);\n+\t\t\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\t\t\tCreatureJoint(item, 1, required);\n+\t\t\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\t\t\treturn;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\titem->goal_anim_state = 3;\n+\t\t\tCreatureTilt(item, angle);\n+\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\tCreatureJoint(item, 1, required);\n+\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\treturn;\n+\t\tcase 2:\n+\t\t\tv9 = *(unsigned long *)(data + 14);\n+\t\t\t*((unsigned short *)data + 4) = 364;\n+\t\t\tif (!v9)\n+\t\t\t\tif (GetRandomControl() < 128)\n+\t\t\t\t{\n+\t\t\t\t\titem->required_anim_state = 6;\n+\t\t\t\t\titem->goal_anim_state = 1;\n+\t\t\t\t}\n+\t\t\titem->goal_anim_state = 1;\n+\t\t\tCreatureTilt(item, angle);\n+\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\tCreatureJoint(item, 1, required);\n+\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\treturn;\n+\t\tcase 3:\n+\t\t\t*((unsigned short *)data + 4) = 910;\n+\t\t\tv10 = *(unsigned long *)(data + 14);\n+\t\t\tangle = Creature_Turn;\n+\t\t\tif (v10)\n+\t\t\t{\n+\t\t\t\tif (info.ahead && info.distance < 0x100000)\n+\t\t\t\t{\n+\t\t\t\t\titem->goal_anim_state = 1;\n+\t\t\t\t}\n+\t\t\t\telse if (item->touch_bits & 0x200048 && info.ahead)\n+\t\t\t\t{\n+\t\t\t\t\titem->goal_anim_state = 1;\n+\t\t\t\t}\n+\t\t\t\telse if (v10 != 2)\n+\t\t\t\t{\n+\t\t\t\t\tif (GetRandomControl() < 128)\n+\t\t\t\t\t{\n+\t\t\t\t\t\titem->required_anim_state = 6;\n+\t\t\t\t\t\titem->goal_anim_state = 1;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\telse\n+\t\t\t{\n+\t\t\t\titem->goal_anim_state = 1;\n+\t\t\t}\n+\t\t\tCreatureTilt(item, angle);\n+\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\tCreatureJoint(item, 1, required);\n+\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\treturn;\n+\t\tcase 4:\n+\t\t\tif (!item->required_anim_state && item->touch_bits & 0x200048)\n+\t\t\t{\n+\t\t\t\tlara_item->hit_points -= 200;\n+\t\t\t\t//*((unsigned long *)&lara_item->pointer2 + 1) |= 0x10u;\n+\t\t\t\t//CreatureEffectT(item,&LION_BITE_1,10,item->pos.y_rot,(__int16(__cdecl *)(int, int, int, __int16, __int16, __int16))DoBloodSplat);\n+\t\t\t\titem->required_anim_state = 1;\n+\t\t\t}\n+\t\t\tCreatureTilt(item, angle);\n+\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\tCreatureJoint(item, 1, required);\n+\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\treturn;\n+\t\tcase 7:\n+\t\t\t*((unsigned short *)data + 4) = 182;\n+\t\t\tif (!item->required_anim_state && item->touch_bits & 0x200048)\n+\t\t\t{\n+\t\t\t\t//CreatureEffectT(item,&LION_BITE_2,10,item->pos.y_rot,(__int16(__cdecl *)(int, int, int, __int16, __int16, __int16))DoBloodSplat);\n+\t\t\t\tlara_item->hit_points -= 60;\n+\t\t\t\t//*((unsigned long *)&lara_item->pointer2 + 1) |= 0x10u;\n+\t\t\t\titem->required_anim_state= 1;\n+\t\t\t}\n+\t\t\tCreatureTilt(item, angle);\n+\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\tCreatureJoint(item, 1, required);\n+\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\treturn;\n+\t\tdefault:\n+\t\t\tCreatureTilt(item, angle);\n+\t\t\tCreatureJoint(item, 0, requiredAngle);\n+\t\t\tCreatureJoint(item, 1, required);\n+\t\t\tCreatureAnimation(item_num, Creature_Angle, 0);\n+\t\t\treturn;\n+\t\t}\n+\t}\n+}\n\\ No newline at end of file\ndiff --git a/GAME/LION.H b/GAME/LION.H\nnew file mode 100644\nindex 00000000..f4a9ccd1\n--- /dev/null\n+++ b/GAME/LION.H\n@@ -0,0 +1,9 @@\n+#ifndef LION_H\n+#define LION_H\n+\n+#include "SPECTYPES.H"\n+\n+void InitialiseLion(short item_num);\n+void LionControl(short item_num);\n+\n+#endif\n\\ No newline at end of file\ndiff --git a/GAME/MISSILE.C b/GAME/MISSILE.C\nindex c1434476..86e9a554 100644\n--- a/GAME/MISSILE.C\n+++ b/GAME/MISSILE.C\n@@ -10,6 +10,11 @@\n #include "DRAW.H"\n #include "DEBRIS.H"\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n struct ITEM_LIGHT fxil;\n \n void ControlBodyPart(short fx_number)//4E600, 4EA64 (F)\ndiff --git a/GAME/PEOPLE.C b/GAME/PEOPLE.C\nindex aaca767c..7ef36b75 100644\n--- a/GAME/PEOPLE.C\n+++ b/GAME/PEOPLE.C\n@@ -9,6 +9,11 @@\n #include "OBJECTS.H"\n #include "TOMB4FX.H"\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n int ShotLara(struct ITEM_INFO* item, struct AI_info* info, struct BITE_INFO* gun, short extra_rotation, int damage)//50C74, 510D8\n {\n \tUNIMPLEMENTED();\ndiff --git a/GAME/SAVEGAME.C b/GAME/SAVEGAME.C\nindex bb36f581..92c06270 100644\n--- a/GAME/SAVEGAME.C\n+++ b/GAME/SAVEGAME.C\n@@ -27,11 +27,16 @@\n #include "SPOTCAM.H"\n #include "LARA.H"\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n char FromTitle = 0; // offset 0xA14AC\n char JustLoaded = 0; // offset 0xA14AD\n-char *MGSaveGamePtr; // offset 0xA3924\n+char* MGSaveGamePtr; // offset 0xA3924\n static int SGcount; // offset 0xA391C\n-static char *SGpoint; // offset 0xA3920\n+static char* SGpoint; // offset 0xA3920\n struct savegame_info savegame;\n \n #define Write(a, b) WriteSG((char*)a, b)\ndiff --git a/GAME/SPOTCAM.C b/GAME/SPOTCAM.C\nindex 2d2f974a..852db72f 100644\n--- a/GAME/SPOTCAM.C\n+++ b/GAME/SPOTCAM.C\n@@ -25,6 +25,10 @@\n \t#include <LIBMATH.H>\n #endif\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n #include <stdio.h>\n \n int bUseSpotCam = 0;\ndiff --git a/GAME/TOMB4FX.C b/GAME/TOMB4FX.C\nindex c050cabb..93bde815 100644\n--- a/GAME/TOMB4FX.C\n+++ b/GAME/TOMB4FX.C\n@@ -1,5 +1,9 @@\n #include "TOMB4FX.H"\n \n+#if PSX_VERSION\n+#include "CALCLARA.H"\n+#endif\n+\n #include "SPECIFIC.H"\n #include "EFFECT2.H"\n #include "LARA.H"\n@@ -22,6 +26,11 @@\n #include "MATHS.H"\n #endif\n \n+#if PSX_VERSION || PSXPC_VERSION\n+#include "MISC.H"\n+#endif\n+\n+\n char flare_table[121] =\n {\n \t0x60, 0x50, 0x00, 0x06, 0x00, 0x1F, 0x30, 0x20, 0x20, 0x0A, 0xFA, 0x1F, 0x20, 0x18, \n@@ -777,14 +786,74 @@ void TriggerLightningGlow(long x, long y, long z, long rgb)// (F)\n \tsptr->Size = size;\n }\n \n-void trig_actor_gunflash(struct MATRIX3D *matrix, struct PHD_VECTOR *pos)\n+void trig_actor_gunflash(struct MATRIX3D* matrix, struct PHD_VECTOR* pos)//(F)\n {\n-\tUNIMPLEMENTED();\n+#if PSX_VERSION//Likely different for PC\n+\tstruct GUNFLASH_STRUCT* fx;\n+\tlong lp;\n+\n+\tfx = &Gunflashes[0];\n+\n+\t//loc_36638:\n+\tfor (lp = 0; lp < 4; lp++, fx++)\n+\t{\n+\t\tif (!fx->on)\n+\t\t{\n+\t\t\tfx->on = 1;\n+\t\t\tmPushMatrix();\n+\t\t\tmCopyMatrix(matrix);\n+\t\t\tmTranslateXYZ(pos->x, pos->y, pos->z);\n+\t\t\tmRotX(-13680);\n+\t\t\tsnaff_current_gte_matrix_V1(&fx->matrix);\n+\t\t\tmPopMatrix();\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+#endif\n }\n \n-void TriggerFenceSparks(long x, long y, long z, long kill, long crane)\n+void TriggerFenceSparks(long x, long y, long z, long kill, long crane)//(F)\n {\n-\tUNIMPLEMENTED();\n+\tstruct SPARKS* sptr;\n+\n+\tsptr = &spark[GetFreeSpark()];\n+\tsptr->On = 1;\n+\tsptr->sR = (GetRandomControl() & 0x3F) - 0x40;\n+\tsptr->sG = (GetRandomControl() & 0x3F) - 0x40;\n+\tsptr->sB = (GetRandomControl() & 0x3F) - 0x40;\n+\n+\tsptr->dR = GetRandomControl() | 0xC0;\n+\tsptr->ColFadeSpeed = 16;\n+\tsptr->G = 8;\n+\tsptr->dG = sptr->sR >> 1;\n+\tsptr->dB = sptr->sR >> 2;\n+\n+\tsptr->Life = (GetRandomControl() & 7) + 24;\n+\tsptr->sLife = (GetRandomControl() & 7) + 24;\n+\tsptr->TransType = 2;\n+\tsptr->Dynamic = -1;\n+\n+\tsptr->x = x;\n+\tsptr->y = y;\n+\tsptr->z = z;\n+\n+\tsptr->Xvel = ((GetRandomControl() & 0xFF) - 128) << 2;\n+\tsptr->Yvel = (GetRandomControl() & 0xF) - ((kill << 5) + 8) + (crane << 4);\n+\tsptr->Zvel = ((GetRandomControl() & 0xFF) - 128) << 2;\n+\n+\tif (crane != 0)\n+\t{\n+\t\tsptr->Friction = 5;\n+\t}\n+\telse\n+\t{\n+\t\tsptr->Friction = 4;\n+\t}\n+\n+\t//loc_365C4\n+\tsptr->Flags = 0;\n+\tsptr->Gravity = (GetRandomControl() & 0xF) + ((crane << 4) + 16);\n+\tsptr->MaxYvel = 0;\n }\n \n void ControlElectricFence(short item_number)\ndiff --git a/GAME/TRAPS.C b/GAME/TRAPS.C\nindex 9a7ef6a1..af0cd39e 100644\n--- a/GAME/TRAPS.C\n+++ b/GAME/TRAPS.C\n@@ -12,6 +12,10 @@\n #include "SOUND.H"\n #include "COLLIDE.H"\n \n+#if PSX_VERSION || PSXPC_VERSION\n+\t#include "MISC.H"\n+#endif\n+\n short SPDETyoffs[8] =\n {\n \t0x0400, 0x0200, 0x0200, 0x0200, 0x0000, 0x0200, 0x0200, 0x0200\ndiff --git a/GAME/TYPES.H b/GAME/TYPES.H\nindex da6dabb5..047070aa 100644\n--- a/GAME/TYPES.H\n+++ b/GAME/TYPES.H\n@@ -36,7 +36,7 @@\n \n // (65536 / 360) ~ 182.0444...\n // Game used 182, so maybe our code will be more precise %)\n-#define ANGLE(x) ((x) * 65536.0 / 360.0)\n+#define ANGLE(x) (short)((x) * 65536.0 / 360.0)\n \n #define SIN(x) (rcossin_tbl[((int)(x) >> 3) & 0x1FFE])\n #define COS(x) (rcossin_tbl[(((int)(x) >> 3) & 0x1FFE) + 1])\n@@ -102,7 +102,7 @@ inline int phd_atan(long x, long y)\n #define STEP_L     (WALL_L/4)\n \n //#define SECTOR 1024\n-#define SECTOR(x) ((x) * WALL_L)\n+#define SECTOR(x) (short)((x) * WALL_L)\n #define CLICK 256\n \n #define UNIT_SHADOW 256\ndiff --git a/LINK.LNK b/LINK.LNK\nnew file mode 100644\nindex 00000000..eb008804\n--- /dev/null\n+++ b/LINK.LNK\n@@ -0,0 +1,127 @@\n+\torg\t$00010000\n+text\tgroup\n+bss\tgroup\tbss\n+\tsection .text,text\n+\tsection ASM,text\n+\tsection .data,text\n+\tsection .rdata,text\n+\tsection .ctors,text\n+\tsection .dtors,text\n+\tsection .sdata,text\n+\tsection .sbss,bss\n+\tsection\t.bss,bss\n+\t\n+\tinclude SPEC_PSX/PSXMAIN.OBJ\n+\tinclude SPEC_PSX/GPU.OBJ\n+\tinclude GAME/GAMEFLOW.OBJ\n+\tinclude GAME/CONTROL.OBJ\n+\tinclude GAME/FONT.OBJ\n+\tinclude GAME/TEXT.OBJ\n+\tinclude GAME/LARA.OBJ\n+\tinclude GAME/DELSTUFF.OBJ\n+\tinclude GAME/DELTAPAK.OBJ\n+\tinclude GAME/DOOR.OBJ\n+\tinclude GAME/DRAW.OBJ\n+\tinclude GAME/BOX.OBJ\n+\tinclude GAME/CAMERA.OBJ\n+\tinclude GAME/COLLIDE.OBJ\n+\tinclude GAME/ITEMS.OBJ\n+\tinclude GAME/DEBRIS.OBJ\n+\tinclude GAME/SPOTCAM.OBJ\n+\tinclude GAME/EFFECT2.OBJ\n+\tinclude GAME/TOMB4FX.OBJ\n+\tinclude GAME/EFFECTS.OBJ\n+\tinclude GAME/FLMTORCH.OBJ\n+\tinclude GAME/HAIR.OBJ\n+\tinclude GAME/HEALTH.OBJ\n+\tinclude GAME/NEWINV2.OBJ\n+\tinclude GAME/LARAFIRE.OBJ\n+\tinclude GAME/LARAFLAR.OBJ\n+\tinclude GAME/LARA1GUN.OBJ\n+\tinclude GAME/LARA2GUN.OBJ\n+\tinclude GAME/LARACLMB.OBJ\n+\tinclude GAME/LARASWIM.OBJ\n+\tinclude GAME/LARASURF.OBJ\n+\tinclude GAME/LOT.OBJ\n+\tinclude GAME/LARAMISC.OBJ\n+\tinclude SPEC_PSX/LOT_S.OBJ\n+\tinclude GAME/MISSILE.OBJ\n+\tinclude GAME/OBJECTS.OBJ\n+\tinclude GAME/PEOPLE.OBJ\n+\tinclude GAME/SAVEGAME.OBJ\n+\tinclude GAME/SOUND.OBJ\n+\tinclude GAME/SPHERE.OBJ\n+\tinclude GAME/SWITCH.OBJ\n+\tinclude GAME/PICKUP.OBJ\n+\tinclude GAME/OBJLIGHT.OBJ\n+\tinclude GAME/FOOTPRNT.OBJ\n+\tinclude SPEC_PSX/3D_GEN.OBJ\n+\tinclude SPEC_PSX/CD.OBJ\n+\tinclude GAME/TRAPS.OBJ\n+\tinclude SPEC_PSX/MOVIE.OBJ\n+\tinclude SPEC_PSX/FILE.OBJ\n+\tinclude SPEC_PSX/MALLOC.OBJ\n+\tinclude SPEC_PSX/MISC.OBJ\n+\tinclude SPEC_PSX/3D_OBJ.OBJ\n+\t;include SPEC_PSX/C_MATH.OBJ\n+\tinclude SPEC_PSX/PSXINPUT.OBJ\n+\t;include SPEC_PSX/GEN_DRAW.OBJ\n+\tinclude SPEC_PSX/ROOMLOAD.OBJ\n+\tinclude SPEC_PSX/LOAD_LEV.OBJ\n+\tinclude SPEC_PSX/ROOMLETB.OBJ\n+\t;include SPEC_PSX/PRINTOBJ.OBJ\n+\t;include SPEC_PSX/NEWSHIT.OBJ\n+\tinclude SPEC_PSX/MATHS.OBJ\n+\t;include SPEC_PSX/CATAN.OBJ\n+\tinclude SPEC_PSX/DRAWSPKS.OBJ\n+\t;include SPEC_PSX/LITE_SRC.OBJ\n+\tinclude SPEC_PSX/PSOUTPUT.OBJ\n+\tinclude SPEC_PSX/SPECIFIC.OBJ\n+\tinclude SPEC_PSX/PROFILE.OBJ\n+\tinclude SPEC_PSX/MEMCARD.OBJ\n+\tinclude SPEC_PSX/COLLIDE_S.OBJ\n+\tinclude SPEC_PSX/CONTROL_S.OBJ\n+\tinclude SPEC_PSX/DRAWSKY.OBJ\n+\tinclude SPEC_PSX/DRAWOBJ.OBJ\n+\tinclude SPEC_PSX/SPUSOUND.OBJ\n+\t;include SPEC_PSX/AMATHS.OBJ\n+\t;include SPEC_PSX/DOOR_S.OBJ\n+\t;include SPEC_PSX/GET.OBJ\n+\tinclude SPEC_PSX/GETSTUFF.OBJ\n+\t;include SPEC_PSX/QUICKDRAW.OBJ\n+\tinclude SPEC_PSX/ANIMITEM.OBJ\n+\tinclude SPEC_PSX/FOOTPRNT_S.OBJ\n+\t;include SPEC_PSX/CALCHAIR.OBJ\n+\tinclude SPEC_PSX/CALCLARA.OBJ\n+\tinclude SPEC_PSX/LIGHT.OBJ\n+\tinclude SPEC_PSX/SHADOWS.OBJ\n+\t;include SPEC_PSX/FXCTRL.OBJ\n+\tinclude SPEC_PSX/FXDRAW.OBJ\n+\tinclude SPEC_PSX/FXTRIG.OBJ\n+\tinclude SPEC_PSX/TEXT_S.OBJ\n+\tinclude SPEC_PSX/SPHERES.OBJ\n+\tinclude SPEC_PSX/BUBBLES.OBJ\n+\tinclude SPEC_PSX/SPARKS.OBJ\n+\tinclude SPEC_PSX/DELTAPAK_S.OBJ\n+\tinclude SPEC_PSX/SFX.OBJ\n+\tinclude SPEC_PSX/LOADSAVE.OBJ\n+\tinclude SPEC_PSX/CARDHDR.OBJ\n+\tinclude SPEC_PSX/REQUEST.OBJ\n+\tinclude SPEC_PSX/GLOBALS.OBJ\n+\tinclude SPEC_PSX/DRAWPHAS.OBJ\n+\tinclude SPEC_PSX/SETUP.OBJ\n+\tinclude GAME/CODEWAD.OBJ\n+\tinclude SPEC_PSX/TITSEQ.OBJ\n+\n+\tinclib\tC:/psyq/lib/LIBAPI.LIB\n+\tinclib\tC:/psyq/lib/LIBC.LIB\n+\tinclib\tC:/psyq/lib/LIBCARD.LIB\n+\tinclib\tC:/psyq/lib/LIBGTE.LIB\n+\tinclib\tC:/psyq/lib/LIBGPU.LIB\n+\tinclib\tC:/psyq/lib/LIBETC.LIB\n+\tinclib\tC:/psyq/lib/LIBSN.LIB\n+\tinclib\tC:/psyq/lib/LIBCD.LIB\n+\tinclib\tC:/psyq/lib/LIBMCRD.LIB\n+\tinclib\tC:/psyq/lib/LIBSPU.LIB\n+\tinclib\tC:/psyq/lib/LIBPAD.LIB\n+\tregs\tpc=__SN_ENTRY_POINT\ndiff --git a/Makefile b/Makefile\nindex 80a6f9dd..9118c8c1 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -77,9 +77,8 @@ AFILES\t\t= $(foreach dir,$(SOURCES),$(wildcard $(dir)/*.MIP))\n #CFILES =   GAME/CAMERA.C GAME/OBJLIGHT.C SPEC_PSX/SPUSOUND.C SPEC_PSX/LOAD_LEV.C SPEC_PSX/GPU.C SPEC_PSX/PSXMAIN.C SPEC_PSX/LOADSAVE.C SPEC_PSX/PROFILE.C SPEC_PSX/MEMCARD.C SPEC_PSX/REQUEST.C SPEC_PSX/SPECIFIC.C SPEC_PSX/MALLOC.C SPEC_PSX/3D_GEN.C SPEC_PSX/DRAWSPKS.C SPEC_PSX/MOVIE.C SPEC_PSX/CD.C SPEC_PSX/3D_OBJ.C SPEC_PSX/ROOMLOAD.C SPEC_PSX/PSXINPUT.C SPEC_PSX/DRAWPHAS.C SPEC_PSX/PSOUTPUT.C SPEC_PSX/FILE.C SPEC_PSX/SETUP.C GAME/ROPE.C GAME/DELSTUFF.C GAME/SAVEGAME.C GAME/SOUND.C GAME/JOBY5.C GAME/MISSILE.C GAME/TOWER2.C GAME/RICH2.C GAME/OBJECTS.C GAME/EFFECTS.C GAME/LARACLMB.C GAME/SPHERE.C GAME/TOMB4FX.C GAME/RAT.C GAME/RICH3.C GAME/ANDREA1.C GAME/ITEMS.C GAME/ANDY1.C GAME/FLMTORCH.C GAME/MAFIA2.C GAME/ANDY3.C GAME/FOOTPRNT.C GAME/TOWER3.C GAME/CODEWAD.C GAME/SWITCH.C GAME/HAIR.C GAME/JOBY1.C GAME/ANDREA2.C GAME/ANDREA3.C GAME/LARASWIM.C GAME/RICHCUT2.C GAME/JOBY4.C GAME/TEXT.C GAME/FONT.C GAME/DEBRIS.C GAME/SPOTCAM.C GAME/GAMEFLOW.C GAME/LOT.C GAME/DELTAPAK.C GAME/JOBY2.C GAME/PICKUP.C GAME/ANIM.C GAME/ANDY2.C GAME/BOX.C GAME/JOBY3.C GAME/TWOGUN.C GAME/TRAPS.C GAME/COLLIDE.C GAME/PEOPLE.C GAME/NEWINV2.C GAME/LARAFLAR.C GAME/LARAMISC.C GAME/LARA1GUN.C GAME/LARA2GUN.C GAME/LARASURF.C GAME/GUARDIAN.C GAME/TOWER1.C GAME/CONTROL.C GAME/DRAW.C GAME/EFFECT2.C GAME/DOOR.C GAME/RICH1.C GAME/LARA.C GAME/HYDRA.C GAME/LARAFIRE.C GAME/HEALTH.C\n \n ##Same as original\n-CFILES =    SPEC_PSX/PSXMAIN.C GAME/OBJLIGHT.C SPEC_PSX/GPU.C GAME/GAMEFLOW.C GAME/CONTROL.C GAME/TEXT.C GAME/LARA.C GAME/DELSTUFF.C GAME/DELTAPAK.C GAME/DOOR.C GAME/DRAW.C GAME/BOX.C GAME/CAMERA.C GAME/COLLIDE.C GAME/ITEMS.C GAME/DEBRIS.C GAME/SPOTCAM.C GAME/EFFECT2.C GAME/TOMB4FX.C GAME/EFFECTS.C GAME/FLMTORCH.C GAME/HAIR.C GAME/HEALTH.C GAME/NEWINV2.C GAME/LARAFIRE.C GAME/LARAFLAR.C GAME/LARA1GUN.C GAME/LARA2GUN.C GAME/LARACLMB.C GAME/LARASWIM.C GAME/LARASURF.C GAME/LOT.C GAME/LARAMISC.C GAME/MISSILE.C GAME/OBJECTS.C GAME/PEOPLE.C GAME/SAVEGAME.C GAME/SOUND.C GAME/SPHERE.C GAME/SWITCH.C GAME/PICKUP.C SPEC_PSX/3D_GEN.C SPEC_PSX/CD.C GAME/TRAPS.C SPEC_PSX/FILE.C SPEC_PSX/MALLOC.C SPEC_PSX/3D_OBJ.C SPEC_PSX/PSXINPUT.C SPEC_PSX/ROOMLOAD.C SPEC_PSX/LOAD_LEV.C SPEC_PSX/DRAWSPKS.C SPEC_PSX/PSOUTPUT.C SPEC_PSX/SPECIFIC.C SPEC_PSX/PROFILE.C SPEC_PSX/MEMCARD.C SPEC_PSX/SPUSOUND.C SPEC_PSX/LOADSAVE.C SPEC_PSX/REQUEST.C SPEC_PSX/DRAWPHAS.C SPEC_PSX/SETUP.C SPEC_PSX/MOVIE.C GAME/CODEWAD.C\n-##CFILES =   SPEC_PSX/PSXMAIN.C GAME/GAMEFLOW.C GAME/CONTROL.C GAME/TEXT.C GAME/LARA.C GAME/DELSTUFF.C GAME/DELTAPAK.C GAME/DOOR.C GAME/DRAW.C GAME/BOX.C GAME/CAMERA.C GAME/COLLIDE.C GAME/ITEMS.C GAME/DEBRIS.C GAME/SPOTCAM.C GAME/EFFECT2.C GAME/TOMB4FX.C GAME/EFFECTS.C GAME/FLMTORCH.C GAME/HAIR.C GAME/HEALTH.C GAME/NEWINV2.C GAME/LARAFIRE.C GAME/LARAFLAR.C GAME/LARA1GUN.C GAME/LARA2GUN.C GAME/LARACLMB.C GAME/LARASWIM.C GAME/LARASURF.C GAME/LOT.C GAME/LARAMISC.C GAME/MISSILE.C GAME/OBJECTS.C GAME/PEOPLE.C GAME/SAVEGAME.C GAME/SOUND.C GAME/SPHERE.C GAME/SWITCH.C GAME/PICKUP.C GAME/OBJLIGHT.C SPEC_PSX/3D_GEN.C SPEC_PSX/CD.C GAME/TRAPS.C SPEC_PSX/GPU.C SPEC_PSX/FILE.C SPEC_PSX/MALLOC.C SPEC_PSX/3D_OBJ.C SPEC_PSX/PSXINPUT.C SPEC_PSX/ROOMLOAD.C SPEC_PSX/LOAD_LEV.C SPEC_PSX/DRAWSPKS.C SPEC_PSX/PSOUTPUT.C SPEC_PSX/SPECIFIC.C SPEC_PSX/PROFILE.C SPEC_PSX/MEMCARD.C SPEC_PSX/SPUSOUND.C SPEC_PSX/LOADSAVE.C SPEC_PSX/REQUEST.C SPEC_PSX/DRAWPHAS.C SPEC_PSX/SETUP.C SPEC_PSX/MOVIE.C GAME/CODEWAD.C\n-##         GAME/ROPE.C   GAME/JOBY5.C  GAME/TOWER2.C GAME/RICH2.C      GAME/RAT.C GAME/RICH3.C GAME/ANDREA1.C  GAME/ANDY1.C  GAME/MAFIA2.C GAME/ANDY3.C GAME/FOOTPRNT.C GAME/TOWER3.C    GAME/JOBY1.C GAME/ANDREA2.C GAME/ANDREA3.C  GAME/RICHCUT2.C GAME/JOBY4.C  GAME/FONT.C    GAME/JOBY2.C  GAME/ANIM.C GAME/ANDY2.C  GAME/JOBY3.C GAME/TWOGUN.C          GAME/GUARDIAN.C GAME/TOWER1.C   GAME/RICH1.C GAME/HYDRA.C   \n+CFILES =    SPEC_PSX/PSXMAIN.C SPEC_PSX/SPUSOUND.C GAME/OBJLIGHT.C SPEC_PSX/GPU.C SPEC_PSX/LOAD_LEV.C SPEC_PSX/SETUP.C GAME/GAMEFLOW.C GAME/CONTROL.C GAME/TEXT.C GAME/LARA.C GAME/DELSTUFF.C GAME/DELTAPAK.C GAME/DOOR.C GAME/DRAW.C GAME/BOX.C GAME/CAMERA.C GAME/COLLIDE.C GAME/ITEMS.C GAME/DEBRIS.C GAME/SPOTCAM.C GAME/EFFECT2.C GAME/TOMB4FX.C GAME/EFFECTS.C GAME/FLMTORCH.C GAME/HAIR.C GAME/HEALTH.C GAME/NEWINV2.C GAME/LARAFIRE.C GAME/LARAFLAR.C GAME/LARA1GUN.C GAME/LARA2GUN.C GAME/LARACLMB.C GAME/LARASWIM.C GAME/LARASURF.C GAME/LOT.C GAME/LARAMISC.C GAME/MISSILE.C GAME/OBJECTS.C GAME/PEOPLE.C GAME/SAVEGAME.C GAME/SOUND.C GAME/SPHERE.C GAME/SWITCH.C GAME/PICKUP.C SPEC_PSX/3D_GEN.C SPEC_PSX/CD.C GAME/TRAPS.C SPEC_PSX/FILE.C SPEC_PSX/MALLOC.C SPEC_PSX/3D_OBJ.C SPEC_PSX/PSXINPUT.C SPEC_PSX/ROOMLOAD.C SPEC_PSX/DRAWSPKS.C SPEC_PSX/PSOUTPUT.C SPEC_PSX/SPECIFIC.C SPEC_PSX/PROFILE.C SPEC_PSX/MEMCARD.C SPEC_PSX/LOADSAVE.C SPEC_PSX/REQUEST.C SPEC_PSX/DRAWPHAS.C SPEC_PSX/MOVIE.C GAME/CODEWAD.C\n+#CFILES =   SPEC_PSX/PSXMAIN.C GAME/GAMEFLOW.C GAME/CONTROL.C GAME/TEXT.C GAME/LARA.C GAME/DELSTUFF.C GAME/DELTAPAK.C GAME/DOOR.C GAME/DRAW.C GAME/BOX.C GAME/CAMERA.C GAME/COLLIDE.C GAME/ITEMS.C GAME/DEBRIS.C GAME/SPOTCAM.C GAME/EFFECT2.C GAME/TOMB4FX.C GAME/EFFECTS.C GAME/FLMTORCH.C GAME/HAIR.C GAME/HEALTH.C GAME/NEWINV2.C GAME/LARAFIRE.C GAME/LARAFLAR.C GAME/LARA1GUN.C GAME/LARA2GUN.C GAME/LARACLMB.C GAME/LARASWIM.C GAME/LARASURF.C GAME/LOT.C GAME/LARAMISC.C GAME/MISSILE.C GAME/OBJECTS.C GAME/PEOPLE.C GAME/SAVEGAME.C GAME/SOUND.C GAME/SPHERE.C GAME/SWITCH.C GAME/PICKUP.C GAME/OBJLIGHT.C SPEC_PSX/3D_GEN.C SPEC_PSX/CD.C GAME/TRAPS.C SPEC_PSX/GPU.C SPEC_PSX/FILE.C SPEC_PSX/MALLOC.C SPEC_PSX/3D_OBJ.C SPEC_PSX/PSXINPUT.C SPEC_PSX/ROOMLOAD.C SPEC_PSX/LOAD_LEV.C SPEC_PSX/DRAWSPKS.C SPEC_PSX/PSOUTPUT.C SPEC_PSX/SPECIFIC.C SPEC_PSX/PROFILE.C SPEC_PSX/MEMCARD.C SPEC_PSX/SPUSOUND.C SPEC_PSX/LOADSAVE.C SPEC_PSX/REQUEST.C SPEC_PSX/DRAWPHAS.C SPEC_PSX/SETUP.C SPEC_PSX/MOVIE.C GAME/CODEWAD.C GAME/ROPE.C   GAME/JOBY5.C  GAME/TOWER2.C GAME/RICH2.C      GAME/RAT.C GAME/RICH3.C GAME/ANDREA1.C  GAME/ANDY1.C  GAME/MAFIA2.C GAME/ANDY3.C GAME/FOOTPRNT.C GAME/TOWER3.C    GAME/JOBY1.C GAME/ANDREA2.C GAME/ANDREA3.C  GAME/RICHCUT2.C GAME/JOBY4.C  GAME/FONT.C    GAME/JOBY2.C  GAME/ANIM.C GAME/ANDY2.C  GAME/JOBY3.C GAME/TWOGUN.C          GAME/GUARDIAN.C GAME/TOWER1.C   GAME/RICH1.C GAME/HYDRA.C   \n \n \n #---------------------------------------------------------------------------------\ndiff --git a/PSX_BUILD.bat b/PSX_BUILD.bat\nnew file mode 100644\nindex 00000000..a068cafe\n--- /dev/null\n+++ b/PSX_BUILD.bat\n@@ -0,0 +1 @@\n+mingw32-make\n\\ No newline at end of file\ndiff --git a/CLEAN_PSX.bat b/PSX_CLEAN.bat\nsimilarity index 77%\nrename from CLEAN_PSX.bat\nrename to PSX_CLEAN.bat\nindex e64768db..9199aed8 100644\n--- a/CLEAN_PSX.bat\n+++ b/PSX_CLEAN.bat\n@@ -4,4 +4,5 @@ del /S *.bin\n cd ../\n cd SPEC_PSX\n del /S *.obj\n-del /S *.bin\n\\ No newline at end of file\n+del /S *.bin\n+cd ../\n\\ No newline at end of file\ndiff --git a/PSX_LINK.bat b/PSX_LINK.bat\nnew file mode 100644\nindex 00000000..837c0627\n--- /dev/null\n+++ b/PSX_LINK.bat\n@@ -0,0 +1 @@\n+psylink /c /m /q @LINK.LNK,DISC/MAIN.CPE,DISC/MAIN.SYM,DISC/MAIN.MAP\n\\ No newline at end of file\ndiff --git a/PSX_SLINK.bat b/PSX_SLINK.bat\nnew file mode 100644\nindex 00000000..1d94fb85\n--- /dev/null\n+++ b/PSX_SLINK.bat\n@@ -0,0 +1 @@\n+slink /psx /c @LINK.LNK,DISC/MAIN.CPE,DISC/MAIN.SYM,DISC/MAIN.MAP\n\\ No newline at end of file\ndiff --git a/SPEC_PC_N/DEBUG.CPP b/SPEC_PC_N/DEBUG.CPP\nindex 00c9b030..10c4150a 100644\n--- a/SPEC_PC_N/DEBUG.CPP\n+++ b/SPEC_PC_N/DEBUG.CPP\n@@ -7,6 +7,7 @@\n #include "GAMEFLOW.H"\n #include "DELTAPAK.H"\n #include "PICTURE.H"\n+#include "DIRECTX.H"\n \n UINT dbm_logout, dbm_clearlog, dbm_deftype, dbm_command;\n DWORD dbginput;\n@@ -215,11 +216,16 @@ void DrawDebugPre()\n \n void DrawDebugPost()\n {\n-\tRECT dest{ 256, 256, 256, 256 };\n-\tRECT src{ 0, 0, DXTextureList[cur_tpage].width, DXTextureList[cur_tpage].height };\n+\tDDBLTFX fx;\n+\tDXInit(fx);\n+\t//fx.dwFillColor = GENRGB(0, 0, (5 * GnFrameCounter) % 256);\n+\tfx.dwFillColor = (64 + abs((int)((2 * GnFrameCounter) % 192 - 96))) << (8 * (((GnFrameCounter / 6) % 27) / 9));\n+\tApp.lpBackBuffer->Blt(nullptr, nullptr, nullptr, DDBLT_COLORFILL | DDBLT_WAIT, &fx);\n \n-\tApp.lpBackBuffer->Blt(&dest, DXTextureList[cur_tpage].surface, &src, DDBLT_WAIT, nullptr);\n-\tApp.lpFrontBuffer->Blt(&dest, DXTextureList[cur_tpage].surface, &src, DDBLT_WAIT, nullptr);\n+\tRECT dest{ 256, 256, 512, 512 };\n+\tRECT src{ 0, 0, DXTextureList[cur_tpage].width, DXTextureList[cur_tpage].height };\n+\tLog(LT_Info, "Debug draw %08x", DXTextureList[cur_tpage].surface);\n+\tDX_TRY(App.lpBackBuffer->Blt(&dest, DXTextureList[cur_tpage].surface, &src, DDBLT_WAIT, nullptr));\n }\n \n void ShowDebugInfo()// (F)\ndiff --git a/SPEC_PC_N/FILE.CPP b/SPEC_PC_N/FILE.CPP\nindex 658007d3..7110ae0a 100644\n--- a/SPEC_PC_N/FILE.CPP\n+++ b/SPEC_PC_N/FILE.CPP\n@@ -286,12 +286,13 @@ extern "C"\n \t\tLog(LT_Info, "RTPages %d", numRoom);\n \n \t\tauto bufRoom = (char*)malloc(numRoom * tex_size);\n+\t\tauto ptrRoom = bufRoom;\n \t\tOnlyReadT(bufRoom, char, numRoom * tex_size);\n \t\tS_LoadBar();\n \n-\t\tfor(int i = 0; i < numRoom; i++, bufRoom += tex_size)\n+\t\tfor(int i = 0; i < numRoom; i++, ptrRoom += tex_size)\n \t\t{\n-\t\t\tauto surf = CreateTexturePage(App.textRes, App.textRes, 0, (int*)bufRoom, nullptr, depth_bis);\n+\t\t\tauto surf = CreateTexturePage(App.textRes, App.textRes, 0, (int*)ptrRoom, nullptr, depth_bis);\n \n \t\t\tLPDIRECT3DTEXTURE2 tex;\n \t\t\tDX_TRY(surf->QueryInterface(IID_IDirect3DTexture2, (LPVOID*)&tex));\n@@ -309,17 +310,18 @@ extern "C"\n \t\t\tS_LoadBar();\n \t\t}\n \n-\t\t//free(bufRoom);\n+\t\tfree(bufRoom);\n \n \t\tLog(LT_Info, "OTPages %d", numObj);\n \n \t\tauto bufObj = (char*)malloc(numObj * tex_size);\n+\t\tauto ptrObj = bufObj;\n \t\tOnlyReadT(bufObj, char, numObj * tex_size);\n \t\tS_LoadBar();\n \n-\t\tfor (int i = 0; i < numObj; i++, bufObj += tex_size)\n+\t\tfor (int i = 0; i < numObj; i++, ptrObj += tex_size)\n \t\t{\n-\t\t\tauto surf = CreateTexturePage(App.textRes, App.textRes, 0, (int*)bufObj, nullptr, depth_bis);\n+\t\t\tauto surf = CreateTexturePage(App.textRes, App.textRes, 0, (int*)ptrObj, nullptr, depth_bis);\n \n \t\t\tLPDIRECT3DTEXTURE2 tex;\n \t\t\tDX_TRY(surf->QueryInterface(IID_IDirect3DTexture2, (LPVOID*)&tex));\n@@ -338,15 +340,16 @@ extern "C"\n \t\t\tS_LoadBar();\n \t\t}\n \n-\t\t//free(bufObj);\n+\t\tfree(bufObj);\n \n \t\tLog(LT_Info, "BTPages %d", numBump);\n \n \t\tauto bufBump = (char*)malloc(numBump * tex_size);\n+\t\tauto ptrBump = bufBump;\n \t\tOnlyReadT(bufBump, char, numBump * tex_size);\n \t\tS_LoadBar();\n \n-\t\tfor (int i = 0; i < numBump; i++, bufBump += tex_size)\n+\t\tfor (int i = 0; i < numBump; i++, ptrBump += tex_size)\n \t\t{\n \t\t\tbool bump = i >= numBump / 2;\n \n@@ -355,7 +358,7 @@ extern "C"\n \n \t\t\tint res = bump ? App.bumpRes : App.textRes;\n \n-\t\t\tauto surf = CreateTexturePage(App.textRes, App.textRes, 0, (int*)bufBump, nullptr, depth_bis);\n+\t\t\tauto surf = CreateTexturePage(App.textRes, App.textRes, 0, (int*)ptrBump, nullptr, depth_bis);\n \n \t\t\tLPDIRECT3DTEXTURE2 tex;\n \t\t\tDX_TRY(surf->QueryInterface(IID_IDirect3DTexture2, (LPVOID*)&tex));\n@@ -373,7 +376,7 @@ extern "C"\n \t\t\tS_LoadBar();\n \t\t}\n \n-\t\t//free(bufBump);\n+\t\tfree(bufBump);\n \n \t\tfree(level_data_orig);\n \ndiff --git a/SPEC_PC_N/GAME.CPP b/SPEC_PC_N/GAME.CPP\nindex 0c47b2a3..5dc51b7b 100644\n--- a/SPEC_PC_N/GAME.CPP\n+++ b/SPEC_PC_N/GAME.CPP\n@@ -1,12 +1,12 @@\n #include "GAME.H"\n #include "GLOBAL.H"\n #include "DISPLAY.H"\n-#include "DIRECTX.H"\n #include "INIT.H"\n #include "GAMEFLOW.H"\n #include "SOUND.H"\n #include "DRAWPRIMITIVE.H"\n #include "FILE.H"\n+#include "DIRECTX.H"\n \n object_info objects[NUMBER_OBJECTS];\n static_info static_objects[NUMBER_STATIC_OBJECTS];\ndiff --git a/SPEC_PC_N/SPECIFIC.CPP b/SPEC_PC_N/SPECIFIC.CPP\nindex b37e50cb..0968b969 100644\n--- a/SPEC_PC_N/SPECIFIC.CPP\n+++ b/SPEC_PC_N/SPECIFIC.CPP\n@@ -185,13 +185,6 @@ long\t\tS_DumpScreen()\n \t}\n \tGnFrameCounter++;\n \n-\t\n-\t/*DDBLTFX fx;\n-\tDXInit(fx);\n-\t//fx.dwFillColor = GENRGB(0, 0, (5 * GnFrameCounter) % 256);\n-\tfx.dwFillColor = (64 + abs((int)((2 * GnFrameCounter) % 192 - 96))) << (8 * (((GnFrameCounter / 6) % 27) / 9));\n-\tApp.lpBackBuffer->Blt(nullptr, nullptr, nullptr, DDBLT_COLORFILL | DDBLT_WAIT, &fx);*/\n-\n \tDrawDebugPost();\n \t\n \tShowDebugInfo();\ndiff --git a/SPEC_PSX/ANIMITEM.MIP b/SPEC_PSX/ANIMITEM.MIP\nindex a787e31c..4dc2e360 100644\n--- a/SPEC_PSX/ANIMITEM.MIP\n+++ b/SPEC_PSX/ANIMITEM.MIP\n@@ -1,149 +1,309 @@\n \topt at+,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF CalcAllAnimatingItems_ASM, S_DrawFootPrints\n-\tXREF FootPrint, db, mPopMatrix, mPushMatrix, mTranslateAbsXYZ, mRotY, GLOBAL_default_sprites_ptr\n+\tXDEF CalcAllAnimatingItems_ASM, init_scratchpad, stash_the_info, CalcAnimatingItem_ASM\n+\tXREF MatrixStack, CalculateObjectLighting, S_CalculateStaticMeshLight, phd_PutPolygons, phd_PutPolygons_seethrough, mPopMatrix, mPushMatrix, phd_left, phd_right, phd_top, phd_bottom, mClipBoundingBox, draw_rooms, number_draw_rooms, bones, meshes, anims, room, camera, mmPushMatrix, items, static_objects, mmPopMatrix, objects, mTranslateAbsXYZ, mRotY, stashed_objects_list, stashed_matrix_list\n \t\n-CalcAllAnimatingItems_ASM:\n-\tjr\tra\n+CalcAnimatingItem_ASM:\n+\tjr ra\n+\t\n+stash_the_info:\n+\tlw      at, 0x44(fp)\n+\tlw      v0, 0x4C(fp)\n+\tsw      a0, 0(at)\n+\tcfc2    a0, r0\n+\tcfc2    a1, r1\n+\tcfc2    a2, r2\n+\tcfc2    a3, r3\n+\tsw      a0, 4(at)\n+\tsw      a1, 8(at)\n+\tsw      a2, 0xC(at)\n+\tsw      a3, 0x10(at)\n+\tcfc2    a0, r4\n+\tcfc2    a1, r5\n+\tcfc2    a2, r6\n+\tcfc2    a3, r7\n+\tsw      a0, 0x14(at)\n+\tsw      a1, 0x18(at)\n+\tsw      a2, 0x1C(at)\n+\tsw      a3, 0x20(at)\n+\taddiu   at, 0x24\n+\taddiu   v0, 1\n+\tsw      v0, 0x4C(fp)\n+\tjr      ra\n+\tsw      at, 0x44(fp)\n+\t\n+init_scratchpad:\n+\tsw      s0, 0x18(sp)\n+\tsw      s1, 0x1C(sp)\n+\tsw      s2, 0x20(sp)\n+\tsw      s3, 0x24(sp)\n+\tsw      s4, 0x28(sp)\n+\tsw      s5, 0x2C(sp)\n+\tsw      s6, 0x30(sp)\n+\tsw      s7, 0x34(sp)\n+\taddiu   at, fp, 0xBC\n+\tsw      at, 0x50(fp)\n+\tcfc2    t0, r0\n+\tcfc2    t1, r1\n+\tcfc2    t2, r2\n+\tcfc2    t3, r3\n+\tcfc2    t4, r4\n+\tcfc2    t5, r5\n+\tcfc2    t6, r6\n+\tcfc2    t7, r7\n+\tsw      t0, 0(at)\n+\tsw      t1, 4(at)\n+\tsw      t2, 8(at)\n+\tsw      t3, 0xC(at)\n+\tsw      t4, 0x10(at)\n+\tsw      t5, 0x14(at)\n+\tsw      t6, 0x18(at)\n+\tsw      t7, 0x1C(at)\n+\tla      v0, stashed_objects_list\n+\tla      v1, stashed_matrix_list\n+\tlw      a0, items-GP_ADDR(gp)\n+\tlw      a1, room-GP_ADDR(gp)\n+\tsw      v0, 0x40(fp)\n+\tsw      v1, 0x44(fp)\n+\tsw      zero, 0x48(fp)\n+\tsw      a0, 0x60(fp)\n+\tsw      a1, 0x98(fp)\n+\tlh      v0, camera+0xC-GP_ADDR(gp)\n+\tlw      v1, anims-GP_ADDR(gp)\n+\tlw      a0, meshes-GP_ADDR(gp)\n+\tlw      a1, bones-GP_ADDR(gp)\n+\tsh      v0, 0x6A(fp)\n+\tsw      v1, 0x9C(fp)\n+\tsw      a0, 0xA0(fp)\n+\tsw      a1, 0xA4(fp)\n+;\tlw      t0, MatrixStack+0x14-GP_ADDR(gp)\n+;\tlw      t1, MatrixStack+0x18-GP_ADDR(gp)\n+;\tlw      t2, MatrixStack+0x1C-GP_ADDR(gp)\n+\tlw      s1, number_draw_rooms-GP_ADDR(gp)\n+\tlw      a0, 0x1A4(gp)\n+\tla      s0, draw_rooms\n+\tsw      a0, 0xB8(fp)\n+\tsw      t0, 0x6C(fp)\n+\tsw      t1, 0x70(fp)\n+\tjr      ra\n+\tsw      t2, 0x74(fp)\n \t\n-S_DrawFootPrints:\n-\taddiu   sp, -0x30\n-\tsw      s0, 0x30-0x20(sp)\n-\tsw      s1, 0x30-0x1C(sp)\n-\tsw      s2, 0x30-0x18(sp)\n-\tsw      s3, 0x30-0x14(sp)\n-\tsw      s4, 0x30-0x10(sp)\n-\tsw      s5, 0x30-0xC(sp)\n-\tsw      s6, 0x30-0x8(sp)\n-\tsw      ra, 0x30-0x4(sp)\n-\tlw      s3, GLOBAL_default_sprites_ptr-GP_ADDR(gp)\n-\tla      s2, FootPrint-GP_ADDR(gp)\n-\tlw      s0, db+0x8-GP_ADDR(gp)\n-\tlw      s4, db+0x4-GP_ADDR(gp)\n-\tlw      t8, db+0x10-GP_ADDR(gp)\n-\tlw      v0, 0xAC(s3)\n-\tlw      v1, 0xA8(s3)\n-\tandi    s5, v0, 0xFFFF\n-\tsll     at, v1, 16\n-\tor      s5, at\n-\tsrl     s6, v0, 16\n-\tandi    s6, 0xFF\n-\tandi    at, v0, 0xFF00\n-\tor      s6, at\n-\tsrl     v1, 16\n-\tandi    v1, 0xFF9F\n-\tori     v1, 0x40\n-\tsll     v1, 16\n-\tor      s6, v1\n-\tandi    s3, v0, 0xFF\n-\tsrl     at, v0, 24\n-\tsll     at, 8\n-\tor      s3, at\n-\tli      t9, 0x20\n-\n-\tloc_82A8C:\n-\tlhu     a0, 0xE(s2)\n-\taddiu   t9, -1\n-\tbeqz    a0, loc_82BCC\n-\tsltu    at, s0, t8\n-\tbeqz    at, loc_82BD4\n-\tli      s1, 0x38\n-\taddiu   a0, -1\n-\tslti    at, a0, 0x1D\n-\tbeqz    at, loc_82AB8\n-\tsh      a0, 0xE(s2)\n-\tsll     s1, a0, 1\n-\n-\tloc_82AB8:\n+DrawAllAnimatingItems_ASM:\n+\tblez    s4, loc_829E8\n+\tmove    s5, ra\n+\tlui     s0, 0x1E\n \tjal     mPushMatrix\n-\tnop\n+\tla      s0, stashed_objects_list\n+\tla      s2, stashed_matrix_list\n+\n+\tloc_8291C:\n+\tlh      s1, 2(s0)\n+\tlh      s3, 0(s0)\n+\tli      s6, 0x80\n+\tbnez    s1, loc_82950\n+\tlw      a0, 4(s0)\n+\tli      s1, 1\n+\tmove    a3, a0\n+\tlw      a0, 0(a3)\n+\tlw      a1, 4(a3)\n+\tlw      a2, 8(a3)\n+\tlh      a3, 0xE(a3)\n+\tjal     S_CalculateStaticMeshLight\n+\taddiu   ra, 0x14\n+\n+\tloc_82950:\n+\tlw      a1, 8(s0)\n+\tlh      at, 0x30(a0)\n+\tli      s6, 0x80\n+\tjal     CalculateObjectLighting\n+\tsubu    s6, at\n+\n+\tloc_82964:\n+\tlw      t0, 4(s2)\n+\tlw      t1, 8(s2)\n+\tlw      t2, 0xC(s2)\n+\tlw      t3, 0x10(s2)\n+\tctc2    t0, r0\n+\tctc2    t1, r1\n+\tctc2    t2, r2\n+\tctc2    t3, r3\n+\tlw      t0, 0x14(s2)\n+\tlw      t1, 0x18(s2)\n+\tlw      t2, 0x1C(s2)\n+\tlw      t3, 0x20(s2)\n+\tctc2    t0, r4\n+\tctc2    t1, r5\n+\tctc2    t2, r6\n+\tctc2    t3, r7\n+\tli      at, 0x80\n+\tbeq     s6, at, loc_829C4\n \tlw      a0, 0(s2)\n-\tlw      a1, 4(s2)\n+\tslti    at, s6, 5\n+\tbnez    at, loc_829CC\n+\tmove    a1, s6\n+\tjal     phd_PutPolygons_seethrough\n+\taddiu   ra, 8\n+\n+\tloc_829C4:\n+\tjal     phd_PutPolygons\n+\tmove    a1, s3\n+\n+\tloc_829CC:\n+\taddiu   s1, -1\n+\tbgtz    s1, loc_82964\n+\taddiu   s2, 0x24\n+\taddiu   s4, -1\n+\tbgtz    s4, loc_8291C\n+\taddiu   s0, 0xC\n+\tjal     mPopMatrix\n+\n+\tloc_829E8:\n+\tsw      zero, phd_left-GP_ADDR(gp)\n+\tli      v0, 0x1FF\n+\tli      at, 0xEF\n+\tsw      v0, phd_right-GP_ADDR(gp)\n+\tsw      zero, phd_top-GP_ADDR(gp)\n+\tjr      s5\n+\tsw      at, phd_bottom-GP_ADDR(gp)\n+\n+CalcAllAnimatingItems_ASM:\n+\taddiu   sp, -0x80\n+\tsw      fp, 0x80-0x48(sp)\n+\tsw      ra, 0x80-0x44(sp)\n+\tjal     init_scratchpad\n+\tlui     fp, 0x1F80\n+\tblez    s1, loc_827DC\n+\n+\tloc_82658:\n+\tlh      a0, 0(s0)\n+\tlw      v1, 0x80+0x18(fp)\n+\tsll     v0, a0, 2\n+\taddu    v0, a0\n+\tsll     v0, 4\n+\taddu    s2, v1, v0\n+\tsh      a0, 0x80-0x18(fp)\n+\tjal     mmPushMatrix\n+\tsw      s2, 0x80-0x1C(fp)\n+\tlh      s3, 0x32(s2)\n+\tlw      s4, 0x10(s2)\n+\tblez    s3, loc_8275C\n+\tlw      v0, 0x38(s2)\n+\tlw      v1, 0x3C(s2)\n+\tsw      v0, 0x80+0x10(fp)\n+\tsw      v1, 0x80+0x14(fp)\n+\n+\tloc_82698:\n+\tlh      v0, 0x12(s4)\n+\tlh      v1, 0x10(s4)\n+\tla      s5, static_objects\n+\tsll     at, v0, 3\n+\tsubu    at, v0\n+\tsll     at, 2\n+\tandi    v0, v1, 1\n+\tbeqz    v0, loc_82750\n+\taddu    s5, at\n+\tjal     mmPushMatrix\n+\tlw      a1, 4(s4)\n+\tlw      a0, 0(s4)\n \tjal     mTranslateAbsXYZ\n-\tlw      a2, 8(s2)\n-\tlh      a0, 0xC(s2)\n+\tlw      a2, 8(s4)\n+\tlh      a0, 0xC(s4)\n \tjal     mRotY\n \tnop\n-\tli      at, 0xFFFFFFC0\n-\tmtc2    zero, r0\n-\tmtc2    at, r1\n-\tli      at, 0xFF80\n-\tli      v0, 0x40\n-\tmtc2    at, r2\n-\tmtc2    v0, r3\n-\tli      at, 0x80\n-\tmtc2    at, r4\n-\tmtc2    v0, r5\n-\tnop\n-\tli      v1, 0x26\n-\tcop2    0x280030\n-\tsb      v1, 7(s0)\n-\tsb      s1, 4(s0)\n-\tsb      s1, 5(s0)\n-\tsb      s1, 6(s0)\n-\tsw      s5, 0xC(s0)\n-\tsw      s6, 0x14(s0)\n-\tsh      s3, 0x1C(s0)\n-\tswc2    r12, 8(s0)\n-\tswc2    r13, 0x10(s0)\n-\tswc2    r14, 0x18(s0)\n-\tcop2    0x158002D\n-\tjal     mPopMatrix\n+\tlhu     v1, 2(s5)\n+\tcfc2    at, r7\n+\tsrl     v1, 2\n+\tsll     v1, 10\n+\tbeqz    v1, loc_82704\n+\tslt     at, v1, at\n+\tbeqz    at, loc_82704\n \tnop\n-\tmfc2    s1, r7\n-\tmfc2    v0, r12\n-\tmfc2    v1, r13\n-\tmfc2    a0, r14\n-\tandi    at, v0, 0xFE00\n-\tbeqz    at, loc_82B6C\n-\tandi    at, v1, 0xFE00\n-\tbeqz    at, loc_82B6C\n-\tandi    at, a0, 0xFE00\n-\tbnez    at, loc_82BCC\n-\n-\tloc_82B6C:\n-\tand     at, v0, v1\n-\tand     at, a0\n-\tbltz    at, loc_82BCC\n-\tsra     at, v0, 16\n-\tslti    at, at, 0xF0\n-\tbnez    at, loc_82B9C\n-\tsra     at, v1, 16\n-\tslti    at, at, 0xF0\n-\tbnez    at, loc_82B9C\n-\tsra     at, a0, 16\n-\tslti    at, at, 0xF0\n-\tbeqz    at, loc_82BCC\n-\n-\tloc_82B9C:\n-\taddiu   v0, s1, -2\n-\tsltiu   v0, v0, 0x9FF\n-\tbeqz    v0, loc_82BCC\n-\taddiu   s1, -2\n-\tsll     v0, s1, 2\n-\taddu    v0, s4\n+\taddiu   s5, 0x1C\n+\n+\tloc_82704:\n+\tjal     mClipBoundingBox\n+\taddiu   a0, s5, 4\n+\tbeqz    v0, loc_8274C\n+\tlw      a3, 0x80-0x38(fp)\n+\tlw      a2, 0x80-0x40(fp)\n+\taddiu   a3, 1\n+\tsw      a3, 0x80-0x38(fp)\n+\tsh      v0, 0(a2)\n+\tsw      s4, 4(a2)\n+\tsh      zero, 2(a2)\n+\taddiu   a2, 0xC\n+\tsw      a2, 0x80-0x40(fp)\n+\tlh      v1, 0(s5)\n+\tlw      v0, 0x80+0x20(fp)\n+\tsll     v1, 2\n+\taddu    v0, v1\n+\tjal     stash_the_info\n \tlw      a0, 0(v0)\n-\tlui     at, 0x700\n-\tor      a0, at\n-\tsw      s0, 0(v0)\n-\tsw      a0, 0(s0)\n-\taddiu   s0, 0x20\n-\n-\tloc_82BCC:\n-\tbnez    t9, loc_82A8C\n-\taddiu   s2, 0x10\n-\n-\tloc_82BD4:\n-\tsw      s0, 0x3644(gp)\n-\tlw      ra, 0x30-0x4(sp)\n-\tlw      s6, 0x30-0x8(sp)\n-\tlw      s5, 0x30-0xC(sp)\n-\tlw      s4, 0x30-0x10(sp)\n-\tlw      s3, 0x30-0x14(sp)\n-\tlw      s2, 0x30-0x18(sp)\n-\tlw      s1, 0x30-0x1C(sp)\n-\tlw      s0, 0x30-0x20(sp)\n+\n+\tloc_8274C:\n+\tjal     mmPopMatrix\n+\n+\tloc_82750:\n+\taddiu   s3, -1\n+\tbgtz    s3, loc_82698\n+\taddiu   s4, 0x14\n+\n+\tloc_8275C:\n+\tlh      s2, 0x48(s2)\n+\tli      v1, 0xFFFFFFFF\n+\tbeq     s2, v1, loc_827CC\n+\tsll     v0, s2, 7\n+\n+\tloc_8276C:\n+\tsll     v1, s2, 4\n+\tlw      s3, 0x80-0x20(fp)\n+\taddu    v0, v1\n+\taddu    s3, v0\n+\tlh      v1, 0xC(s3)\n+\tla      s6, objects\n+\tsll     v1, 6\n+\taddu    s6, v1\n+\tlhu     v0, 0x32(s6)\n+\tlw      a1, 0x84(s3)\n+\tandi    v0, 0x200\n+\tbeqz    v0, loc_827BC\n+\tli      v1, 6\n+\tandi    a1, 6\n+\tbeq     a1, v1, loc_827BC\n+\tnop\n+\tjal     CalcAnimatingItem_ASM\n+\tmove    s2, s3\n+\tmove    s3, s2\n+\n+\tloc_827BC:\n+\tlh      s2, 0x1A(s3)\n+\tli      v0, 0xFFFFFFFF\n+\tbne     s2, v0, loc_8276C\n+\tsll     v0, s2, 7\n+\n+\tloc_827CC:\n+\tjal     mmPopMatrix\n+\taddiu   s1, -1\n+\tbnez    s1, loc_82658\n+\taddiu   s0, 2\n+\n+\tloc_827DC:\n+\tlw      s4, 0x80-0x38(fp)\n+\tlui     gp, 0xA\n+\tjal     DrawAllAnimatingItems_ASM\n+\tla      gp, GP_ADDR\n+\tlw      ra, 0x80-0x44(sp)\n+\tlw      fp, 0x80-0x48(sp)\n+\tlw      s7, 0x80-0x4C(sp)\n+\tlw      s6, 0x80-0x50(sp)\n+\tlw      s5, 0x80-0x54(sp)\n+\tlw      s4, 0x80-0x58(sp)\n+\tlw      s3, 0x80-0x5C(sp)\n+\tlw      s2, 0x80-0x60(sp)\n+\tlw      s1, 0x80-0x64(sp)\n+\tlw      s0, 0x80-0x68(sp)\n \tjr      ra\n-\taddiu   sp, 0x30\n\\ No newline at end of file\n+\taddiu   sp, 0x80\n+\t\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/BUBBLES.H b/SPEC_PSX/BUBBLES.H\nindex 5550e31f..a2dde3f8 100644\n--- a/SPEC_PSX/BUBBLES.H\n+++ b/SPEC_PSX/BUBBLES.H\n@@ -1,6 +1,7 @@\n #ifndef BUBBLES_H\n #define BUBBLES_H\n \n+extern void DrawMonoScreen(int a0);\n extern void DrawFlash();\n extern void insert_psx_clip_window(long x, long y, long w, long a3, long h);\n extern void CalcClipWindow_ONGTE(short room_number, long unknown);\ndiff --git a/SPEC_PSX/BUBBLES.MIP b/SPEC_PSX/BUBBLES.MIP\nindex 82eb4513..48285d82 100644\n--- a/SPEC_PSX/BUBBLES.MIP\n+++ b/SPEC_PSX/BUBBLES.MIP\n@@ -1,9 +1,61 @@\n \topt at-,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF CalcClipWindow_ONGTE, DrawFlash, DrawPsxTile, insert_psx_clip_window, PrintAllOtherObjects_ASM, print_all_object_NOW\n-\tXREF lara_item, draw_rooms, number_draw_rooms, phd_PutPolygons, phd_bottom, phd_left, phd_top, room, objects, mPopMatrix, FlashFadeR, S_CalculateLight, effects, meshes, FlashFader, FlashFadeG, duff_item, FlashFadeB, db, SetDefDrawEnv, SetDrawEnv, items, CalcAllAnimatingItems_ASM, mPushMatrix, mTranslateAbsXYZ, KillItem, mRotYXZ, phd_right\n+\tXDEF DrawMonoScreen, CalcClipWindow_ONGTE, DrawFlash, DrawPsxTile, insert_psx_clip_window, PrintAllOtherObjects_ASM, print_all_object_NOW\n+\tXREF ClutStartY, lara_item, draw_rooms, number_draw_rooms, phd_PutPolygons, phd_bottom, phd_left, phd_top, room, objects, mPopMatrix, FlashFadeR, S_CalculateLight, effects, meshes, FlashFader, FlashFadeG, duff_item, FlashFadeB, db, SetDefDrawEnv, SetDrawEnv, items, CalcAllAnimatingItems_ASM, mPushMatrix, mTranslateAbsXYZ, KillItem, mRotYXZ, phd_right\n+\n+\t\n+DrawMonoScreen:\n+\tlui     v0, 0x6400\n+\tor      t6, a0, v0\n+\tmove    t4, zero\n+\tli      t2, 0x400040\n+\tlw      a2, db+0x4-GP_ADDR(gp)\n+\tlw      a0, db+0x8-GP_ADDR(gp)\n+\tlhu     t7, ClutStartY-GP_ADDR(gp)\n+\tlw      t5, 0x1F40(a2)\n+\tsll     t7, 6\n+\tori     t7, 0x3C\n+\tli      a3, 0xE1000610\n+\tlui     t0, 0x600\n+\tmove    t1, zero\n+\n+\tloc_8F17C:\n+\tsll     t3, t4, 6\n+\n+\tloc_8F180:\n+\tsll     a1, t1, 6\n+\tsll     v0, t3, 16\n+\tor      v0, a1\n+\tsw      zero, 8(a0)\n+\tsw      t6, 0xC(a0)\n+\tsw      v0, 0x10(a0)\n+\tsw      t2, 0x18(a0)\n+\tsrl     v0, a1, 8\n+\taddiu   v0, 0xD\n+\tor      v0, a3\n+\tandi    a1, 0xFF\n+\tandi    at, t3, 0xFF\n+\tsll     at, 8\n+\tor      at, a1\n+\tor      t5, t0\n+\tsw      t5, 0(a0)\n+\tsw      v0, 4(a0)\n+\tsh      at, 0x14(a0)\n+\tsh      t7, 0x16(a0)\n+\tmove    t5, a0\n+\taddiu   t1, 1\n+\tslti    v0, t1, 8\n+\tbnez    v0, loc_8F180\n+\taddiu   a0, 0x1C\n+\taddiu   t4, 1\n+\tslti    v0, t4, 4\n+\tbnez    v0, loc_8F17C\n+\tmove    t1, zero\n+\tsw      t5, 0x1F40(a2)\n+\tjr      ra\n+\tsw      a0, db+0x8-GP_ADDR(gp)\n \n PrintAllOtherObjects_ASM:\n \tmove    fp, ra\n@@ -118,7 +170,7 @@ PrintAllOtherObjects_ASM:\n \tlw      a0, 0(s4)\n \tlw      a1, 4(s4)\n \tlw      a2, 8(s4)\n-\tla      v0, duff_item+0x54\n+\tla      v0, duff_item+0x54-GP_ADDR(gp)\n \tsw      v0, 0x10(sp)\n \tjal     S_CalculateLight\n \tsb      zero, 0x2F(v0)\ndiff --git a/SPEC_PSX/CALCLARA.H b/SPEC_PSX/CALCLARA.H\nindex 19c7506d..e25dfc40 100644\n--- a/SPEC_PSX/CALCLARA.H\n+++ b/SPEC_PSX/CALCLARA.H\n@@ -5,5 +5,5 @@ extern void S_SetupClutAdder(long unk);\n extern void DEL_CalcLaraMatrices_Normal_ASM(short* frame, long* bone, int flag);\n extern void DEL_CalcLaraMatrices_Interpolated_ASM(short* frame1, short* frame2, int frac, int rate);\n extern short* GetBoundsAccurate(struct ITEM_INFO* item);\n-\n+extern void snaff_current_gte_matrix_V1(struct MATRIX3D* m);\n #endif\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/CALCLARA.MIP b/SPEC_PSX/CALCLARA.MIP\nindex f543188f..1620aab1 100644\n--- a/SPEC_PSX/CALCLARA.MIP\n+++ b/SPEC_PSX/CALCLARA.MIP\n@@ -1,8 +1,8 @@\n \topt at-,w-,c+,m-\n \n-\tsection\t.ASM\n-\txdef S_SetupClutAdder, GetBoundsAccurate, snaff_current_gte_matrix_V1\n-\txref GetFrames, interpolated_bounds\n+\tSECTION\tASM\n+\tXDEF S_SetupClutAdder, GetBoundsAccurate, snaff_current_gte_matrix_V1\n+\tXREF GetFrames, interpolated_bounds\n \t\n snaff_current_gte_matrix_V1:\n \tcfc2    t0, r0\ndiff --git a/SPEC_PSX/CARDHDR.MIP b/SPEC_PSX/CARDHDR.MIP\nindex f6506941..0fda4b68 100644\n--- a/SPEC_PSX/CARDHDR.MIP\n+++ b/SPEC_PSX/CARDHDR.MIP\n@@ -1,4 +1,4 @@\n \topt at+,w-,c+,m-\n \n-\tsection\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/COLLIDE_S.MIP b/SPEC_PSX/COLLIDE_S.MIP\nindex f6506941..0fda4b68 100644\n--- a/SPEC_PSX/COLLIDE_S.MIP\n+++ b/SPEC_PSX/COLLIDE_S.MIP\n@@ -1,4 +1,4 @@\n \topt at+,w-,c+,m-\n \n-\tsection\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/CONTROL_S.MIP b/SPEC_PSX/CONTROL_S.MIP\nindex 12c29228..2d3b8fc1 100644\n--- a/SPEC_PSX/CONTROL_S.MIP\n+++ b/SPEC_PSX/CONTROL_S.MIP\n@@ -1,6 +1,6 @@\n-\topt at+,w-,c+,m-\n+\tOPT at+,w-,c+,m-\n \n-\tsection\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n \tXDEF UpdateSky\n \tXREF gfLevelFlags, gfLayer1Vel, SkyPos, gfLayer2Vel, SkyPos2\ndiff --git a/SPEC_PSX/DELTAPAK_S.MIP b/SPEC_PSX/DELTAPAK_S.MIP\nindex 5b7ace78..f6e25df9 100644\n--- a/SPEC_PSX/DELTAPAK_S.MIP\n+++ b/SPEC_PSX/DELTAPAK_S.MIP\n@@ -1,9 +1,9 @@\n \topt at+,w-,c+,m-\n \n-\tsection\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\txdef DrawCutSeqActors, updateAnimFrame, CalcVolumes_ASM\n-\txref SoundFXVolume, rcossin_tbl, GLOBAL_cutme, meshes, cutrot, mPushMatrix, cutseq_meshbits, cutseq_meshswapbits, temp_rotation_buffer, mTranslateAbsXYZ, objects, bones, mTranslateXYZ, mRotSuperPackedYXZ, phd_PutPolygons_seethrough, phd_PutPolygons, cut_seethrough, mPopMatrix, phd_PutPolygons_seethrough, actor_pnodes, duff_item, mSetTrans, IsRoomOutside, mPushUnitMatrix, S_CalculateLight\n+\tXDEF DrawCutSeqActors, updateAnimFrame, CalcVolumes_ASM\n+\tXREF SoundFXVolume, rcossin_tbl, GLOBAL_cutme, meshes, cutrot, mPushMatrix, cutseq_meshbits, cutseq_meshswapbits, temp_rotation_buffer, mTranslateAbsXYZ, objects, bones, mTranslateXYZ, mRotSuperPackedYXZ, phd_PutPolygons_seethrough, phd_PutPolygons, cut_seethrough, mPopMatrix, phd_PutPolygons_seethrough, actor_pnodes, duff_item, mSetTrans, IsRoomOutside, mPushUnitMatrix, S_CalculateLight\n \n CalcVolumes_ASM:\n \tla      v1, rcossin_tbl\ndiff --git a/SPEC_PSX/DRAWOBJ.MIP b/SPEC_PSX/DRAWOBJ.MIP\nindex 2b34b65a..4471150c 100644\n--- a/SPEC_PSX/DRAWOBJ.MIP\n+++ b/SPEC_PSX/DRAWOBJ.MIP\n@@ -1,6 +1,6 @@\n \topt at+,w-,c+,m-\n \n-\tsection\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n \tXDEF MakeMono, InitObjGTE, phd_PutPolygons, phd_PutPolygons_seethrough\n \t\ndiff --git a/SPEC_PSX/DRAWPHAS.C b/SPEC_PSX/DRAWPHAS.C\nindex f0e67018..ef4a4fb4 100644\n--- a/SPEC_PSX/DRAWPHAS.C\n+++ b/SPEC_PSX/DRAWPHAS.C\n@@ -11,7 +11,9 @@\n #include "DOOR.H"\n #include "DRAW.H"\n #include "DRAWOBJ.H"\n+#include "DRAWSKY.H"\n #include "EFFECTS.H"\n+#include "FOOTPRNT_S.H"\n #include "FXDRAW.H"\n #include "FXTRIG.H"\n #include "GAMEFLOW.H"\n@@ -358,7 +360,7 @@ void DrawRooms(short current_room)//643FC(<), 64B1C(<) (F)\n \t\t\t\tif (gfLevelFlags & GF_LVOP_LIGHTNING)\n \t\t\t\t{\n \t\t\t\t\t//Must convert a0 to CVector\n-\t\t\t\t\t//DrawFlatSky_ASM((LightningRGB[2] << 16) | (LightningRGB[1] << 8) | LightningRGB[0]) | 0x2C00, SkyPos, 0xFFFFFA00);\n+\t\t\t\t\t//DrawFlatSky_ASM(((LightningRGB[2] << 16) | (LightningRGB[1] << 8) | LightningRGB[0]) | 0x2C00), SkyPos, 0xFFFFFA00);\n \t\t\t\t}\n \t\t\t\telse\n \t\t\t\t{\ndiff --git a/SPEC_PSX/DRAWSKY.H b/SPEC_PSX/DRAWSKY.H\nnew file mode 100644\nindex 00000000..db0bbcfc\n--- /dev/null\n+++ b/SPEC_PSX/DRAWSKY.H\n@@ -0,0 +1,8 @@\n+#ifndef DRAWSKY_H\n+#define DRAWSKY_H\n+\n+#include <LIBGTE.H>\n+\n+extern void DrawFlatSky_ASM(struct CVECTOR layer, short pos, int flags);\n+\n+#endif\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/DRAWSKY.MIP b/SPEC_PSX/DRAWSKY.MIP\nindex 9e45e92f..9c67b5eb 100644\n--- a/SPEC_PSX/DRAWSKY.MIP\n+++ b/SPEC_PSX/DRAWSKY.MIP\n@@ -1,6 +1,6 @@\n \topt at-,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n \tXDEF DrawBinoculars, DrawFlatSky_ASM, DrawSubdivChunk, SkyClipXY\n \tXREF LaserSight, SniperOverlay, binoculars_mesh_ptr, db, target_mesh_ptr, psxtextinfo, psxspriteinfo\ndiff --git a/SPEC_PSX/FILE.C b/SPEC_PSX/FILE.C\nindex 7ee3b928..89e3a3a5 100644\n--- a/SPEC_PSX/FILE.C\n+++ b/SPEC_PSX/FILE.C\n@@ -3,9 +3,11 @@\n #include "CD.H"\n \n #include <sys/types.h>\n-#include <libcd.h>\n-#include <stdio.h>\n-#include <libsn.h>\n+#include <LIBCD.H>\n+#include <STDIO.H>\n+#if !DISC_VERSION\n+#include <LIBSN.H>\n+#endif\n \n int FILE_Load(char* szFileName, void* pDest)//5E528, 5E5D8(<) (F) (*) (*)\n {\n@@ -93,11 +95,13 @@ unsigned long FILE_Length(char* szFileName)//5E60C, 5E578(<) (F) (*) (*)\n #endif\n }\n \n+#if !DISC_VERSION\n int FILE_Read(char* pDest, int nItemSize, int nItems, int nHandle)//5E6A8(<), ? (F) (*)\n {\n \tint nAmount = nItems * nItemSize;\n \treturn PCread(nHandle, pDest, nAmount);\n }\n+#endif\n \n void RelocateModule(unsigned long Module, unsigned long* RelocData)//5E6D4(<), 5F430(<) (F) (*)\n {\ndiff --git a/SPEC_PSX/FILE.H b/SPEC_PSX/FILE.H\nindex 75fc20c4..b8f69338 100644\n--- a/SPEC_PSX/FILE.H\n+++ b/SPEC_PSX/FILE.H\n@@ -5,7 +5,9 @@\n \n extern int FILE_Load(char* szFileName, void* pDest);\n extern unsigned long FILE_Length(char* szFileName);\n+#if !DISC_VERSION\n extern int FILE_Read(char* pDest, int nItemSize, int nItems, int nHandle);\n+#endif\n extern void RelocateModule(unsigned long Module, unsigned long* RelocData);\n \n #endif\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/FOOTPRNT.MIP b/SPEC_PSX/FOOTPRNT.MIP\ndeleted file mode 100644\nindex f6506941..00000000\n--- a/SPEC_PSX/FOOTPRNT.MIP\n+++ /dev/null\n@@ -1,4 +0,0 @@\n-\topt at+,w-,c+,m-\n-\n-\tsection\t.ASM\n-\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/FOOTPRNT_S.H b/SPEC_PSX/FOOTPRNT_S.H\nnew file mode 100644\nindex 00000000..e8c2fbe7\n--- /dev/null\n+++ b/SPEC_PSX/FOOTPRNT_S.H\n@@ -0,0 +1,6 @@\n+#ifndef FOOTPRNT_S_H\n+#define FOOTPRNT_S_H\n+\n+extern void S_DrawFootPrints();\n+\n+#endif\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/FOOTPRNT_S.MIP b/SPEC_PSX/FOOTPRNT_S.MIP\nnew file mode 100644\nindex 00000000..f8ab2b7c\n--- /dev/null\n+++ b/SPEC_PSX/FOOTPRNT_S.MIP\n@@ -0,0 +1,146 @@\n+\topt at+,w-,c+,m-\n+\n+\tSECTION\tASM\n+\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n+\tXDEF S_DrawFootPrints\n+\tXREF GLOBAL_default_sprites_ptr, FootPrint, db, mPushMatrix, mTranslateAbsXYZ, mPopMatrix, mRotY\n+\n+S_DrawFootPrints:\n+\taddiu   sp, -0x30\n+\tsw      s0, 0x30-0x20(sp)\n+\tsw      s1, 0x30-0x1C(sp)\n+\tsw      s2, 0x30-0x18(sp)\n+\tsw      s3, 0x30-0x14(sp)\n+\tsw      s4, 0x30-0x10(sp)\n+\tsw      s5, 0x30-0xC(sp)\n+\tsw      s6, 0x30-0x8(sp)\n+\tsw      ra, 0x30-0x4(sp)\n+\tlw      s3, GLOBAL_default_sprites_ptr-GP_ADDR(gp)\n+;\tla      s2, FootPrint-GP_ADDR(gp)\n+\tlw      s0, db+0x8-GP_ADDR(gp)\n+\tlw      s4, db+0x4-GP_ADDR(gp)\n+\tlw      t8, db+0x10-GP_ADDR(gp)\n+\tlw      v0, 0xAC(s3)\n+\tlw      v1, 0xA8(s3)\n+\tandi    s5, v0, 0xFFFF\n+\tsll     at, v1, 16\n+\tor      s5, at\n+\tsrl     s6, v0, 16\n+\tandi    s6, 0xFF\n+\tandi    at, v0, 0xFF00\n+\tor      s6, at\n+\tsrl     v1, 16\n+\tandi    v1, 0xFF9F\n+\tori     v1, 0x40\n+\tsll     v1, 16\n+\tor      s6, v1\n+\tandi    s3, v0, 0xFF\n+\tsrl     at, v0, 24\n+\tsll     at, 8\n+\tor      s3, at\n+\tli      t9, 0x20\n+\n+\tloc_82A8C:\n+\tlhu     a0, 0xE(s2)\n+\taddiu   t9, -1\n+\tbeqz    a0, loc_82BCC\n+\tsltu    at, s0, t8\n+\tbeqz    at, loc_82BD4\n+\tli      s1, 0x38\n+\taddiu   a0, -1\n+\tslti    at, a0, 0x1D\n+\tbeqz    at, loc_82AB8\n+\tsh      a0, 0xE(s2)\n+\tsll     s1, a0, 1\n+\n+\tloc_82AB8:\n+\tjal     mPushMatrix\n+\tnop\n+\tlw      a0, 0(s2)\n+\tlw      a1, 4(s2)\n+\tjal     mTranslateAbsXYZ\n+\tlw      a2, 8(s2)\n+\tlh      a0, 0xC(s2)\n+\tjal     mRotY\n+\tnop\n+\tli      at, 0xFFFFFFC0\n+\tmtc2    zero, r0\n+\tmtc2    at, r1\n+\tli      at, 0xFF80\n+\tli      v0, 0x40\n+\tmtc2    at, r2\n+\tmtc2    v0, r3\n+\tli      at, 0x80\n+\tmtc2    at, r4\n+\tmtc2    v0, r5\n+\tnop\n+\tli      v1, 0x26\n+\tcop2    0x280030\n+\tsb      v1, 7(s0)\n+\tsb      s1, 4(s0)\n+\tsb      s1, 5(s0)\n+\tsb      s1, 6(s0)\n+\tsw      s5, 0xC(s0)\n+\tsw      s6, 0x14(s0)\n+\tsh      s3, 0x1C(s0)\n+\tswc2    r12, 8(s0)\n+\tswc2    r13, 0x10(s0)\n+\tswc2    r14, 0x18(s0)\n+\tcop2    0x158002D\n+\tjal     mPopMatrix\n+\tnop\n+\tmfc2    s1, r7\n+\tmfc2    v0, r12\n+\tmfc2    v1, r13\n+\tmfc2    a0, r14\n+\tandi    at, v0, 0xFE00\n+\tbeqz    at, loc_82B6C\n+\tandi    at, v1, 0xFE00\n+\tbeqz    at, loc_82B6C\n+\tandi    at, a0, 0xFE00\n+\tbnez    at, loc_82BCC\n+\n+\tloc_82B6C:\n+\tand     at, v0, v1\n+\tand     at, a0\n+\tbltz    at, loc_82BCC\n+\tsra     at, v0, 16\n+\tslti    at, at, 0xF0\n+\tbnez    at, loc_82B9C\n+\tsra     at, v1, 16\n+\tslti    at, at, 0xF0\n+\tbnez    at, loc_82B9C\n+\tsra     at, a0, 16\n+\tslti    at, at, 0xF0\n+\tbeqz    at, loc_82BCC\n+\n+\tloc_82B9C:\n+\taddiu   v0, s1, -2\n+\tsltiu   v0, v0, 0x9FF\n+\tbeqz    v0, loc_82BCC\n+\taddiu   s1, -2\n+\tsll     v0, s1, 2\n+\taddu    v0, s4\n+\tlw      a0, 0(v0)\n+\tlui     at, 0x700\n+\tor      a0, at\n+\tsw      s0, 0(v0)\n+\tsw      a0, 0(s0)\n+\taddiu   s0, 0x20\n+\n+\tloc_82BCC:\n+\tbnez    t9, loc_82A8C\n+\taddiu   s2, 0x10\n+\n+\tloc_82BD4:\n+\tsw      s0, 0x3644(gp)\n+\tlw      ra, 0x30-0x4(sp)\n+\tlw      s6, 0x30-0x8(sp)\n+\tlw      s5, 0x30-0xC(sp)\n+\tlw      s4, 0x30-0x10(sp)\n+\tlw      s3, 0x30-0x14(sp)\n+\tlw      s2, 0x30-0x18(sp)\n+\tlw      s1, 0x30-0x1C(sp)\n+\tlw      s0, 0x30-0x20(sp)\n+\tjr      ra\n+\taddiu   sp, 0x30\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/FXDRAW.MIP b/SPEC_PSX/FXDRAW.MIP\nindex 39645332..f5e9d664 100644\n--- a/SPEC_PSX/FXDRAW.MIP\n+++ b/SPEC_PSX/FXDRAW.MIP\n@@ -1,6 +1,6 @@\n \t;opt at+,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n \tXDEF DrawAllFx, local_mTranslateAbsXYZ, local_mRotX, local_mRotY, local_mTranslateAbsXYZ, DrawLaserSightSprite_ASM\n \tXREF db, MatrixStack, lara_item, room, GLOBAL_default_sprites_ptr, phd_persp, subdiv_ripple, rcossin_tbl, ASM_GetBounds\ndiff --git a/SPEC_PSX/FXTRIG.MIP b/SPEC_PSX/FXTRIG.MIP\nindex 84ffa182..feac0d12 100644\n--- a/SPEC_PSX/FXTRIG.MIP\n+++ b/SPEC_PSX/FXTRIG.MIP\n@@ -1,6 +1,6 @@\n \topt at+,w-,c+,m-\n \n-\tsection\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n \tXDEF SetGunFlash, subdiv_ripple\n \tXREF mTranslateXYZ, mRotX, snaff_current_gte_matrix_V1\ndiff --git a/SPEC_PSX/GETSTUFF.MIP b/SPEC_PSX/GETSTUFF.MIP\nindex d60d10a9..b6204165 100644\n--- a/SPEC_PSX/GETSTUFF.MIP\n+++ b/SPEC_PSX/GETSTUFF.MIP\n@@ -1,7 +1,7 @@\n \topt at-,w-,c+,m-\n \n-\tSECTION\t.ASM\n-\tXDEF MULFP\n+\tSECTION\tASM\n+\tXDEF MULFP, DIVFP\n \n MULFP:\n \tmult    a0, a1\n@@ -10,4 +10,11 @@ MULFP:\n \tsrl     v1, 16\n \tsll     v0, 16\n \tjr      ra\n-\tor      v0, v1\n\\ No newline at end of file\n+\tor      v0, v1\n+\t\n+DIVFP:\n+\tsra     a1, 8\n+\tdiv     a0, a1\n+\tmflo    v0\n+\tjr      ra\n+\tsll     v0, 8\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/GLOBALS.MIP b/SPEC_PSX/GLOBALS.MIP\nnew file mode 100644\nindex 00000000..1ff8e25c\n--- /dev/null\n+++ b/SPEC_PSX/GLOBALS.MIP\n@@ -0,0 +1,7 @@\n+\topt L.,C+,at+\n+\n+\tSECTION\tASM\n+\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n+\t\n+objects\n+\tdw 0\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/LIGHT.MIP b/SPEC_PSX/LIGHT.MIP\nindex b7f5e5cb..f63cc20e 100644\n--- a/SPEC_PSX/LIGHT.MIP\n+++ b/SPEC_PSX/LIGHT.MIP\n@@ -1,8 +1,9 @@\n \topt L.,C+,at+\n \n-\tsection\t.ASM\n-\txdef S_CalculateLight\n-\txref room, number_dynamics, dynamics, CamGTE, LightPos, mSqrt, mNormaliseXYZ\n+\tSECTION\tASM\n+\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n+\tXDEF S_CalculateLight, S_CalculateStaticMeshLight, CalculateObjectLighting\n+\tXREF room, number_dynamics, dynamics, CamGTE, LightPos, mSqrt, mNormaliseXYZ\n ;TODO, GP\n S_CalculateLight:\n \taddi    sp, -0x2C\n@@ -37,7 +38,7 @@ S_CalculateLight:\n \tmove    t7, a0\n \tmove    t8, a1\n \tmove    t9, a2\n-\tlw      t0, room\n+\tlw      t0, room-GP_ADDR(gp)\n \tmove    s0, gp\n \tsll     a3, 4\n \tsll     at, a3, 2\n@@ -596,4 +597,172 @@ S_CalculateLight:\n \tlw      s7, 0x2C-0xC(sp)\n \tlw      fp, 0x2C-0x4(sp)\n \tjr      ra\n-\taddi    sp, 0x2C\n\\ No newline at end of file\n+\taddi    sp, 0x2C\n+\t\n+S_CalculateStaticMeshLight:\n+\tlw      t1, number_dynamics-GP_ADDR(gp)\n+\tmove    t5, zero\n+\tmove    t4, zero\n+\tblez    t1, loc_8681C\n+\tmove    t3, zero\n+\tmove    t7, a0\n+\tmove    t6, a1\n+\tmove    t0, a2\n+\tla      t2, dynamics\n+\n+\tloc_866C4:\n+\tlw      a0, 0(t2)\n+\tlw      a1, 4(t2)\n+\tlw      a2, 8(t2)\n+\tsubu    a0, t7, a0\n+\tmtc2    a0, r9\n+\tbgez    a0, loc_866E4\n+\tmove    v0, a0\n+\tnegu    v0, v0\n+\n+\tloc_866E4:\n+\tslti    v0, v0, 0x2001\n+\tbeqz    v0, loc_86810\n+\tsubu    a1, t6, a1\n+\tmtc2    a1, r10\n+\tbgez    a1, loc_86700\n+\tmove    v0, a1\n+\tnegu    v0, v0\n+\n+\tloc_86700:\n+\tslti    v0, v0, 0x2001\n+\tbeqz    v0, loc_86810\n+\tsubu    a2, t0, a2\n+\tmtc2    a2, r11\n+\tbgez    a2, loc_8671C\n+\tmove    v0, a2\n+\tnegu    v0, v0\n+\n+\tloc_8671C:\n+\tslti    v0, v0, 0x2001\n+\tbeqz    v0, loc_86810\n+\tnop\n+\tcop2    0xA00428\n+\tmfc2    a0, r25\n+\tmfc2    a1, r26\n+\tmfc2    a2, r27\n+\tadd     a0, a1\n+\tadd     a0, a2\n+\tmtc2    a0, r30\n+\tbeqz    a0, loc_8679C\n+\tli      v0, 0x1F\n+\tmfc2    v1, r31\n+\tli      at, 0xFFFFFFFE\n+\tand     v1, at\n+\tsub     v0, v1\n+\tsra     v0, 1\n+\taddi    at, v1, -0x18\n+\tbltz    at, loc_86774\n+\tlui     a1, 0xA\n+\tj       loc_86780\n+\tsllv    a0, at\n+\n+\tloc_86774:\n+\tli      at, 0x18\n+\tsub     at, v1\n+\tsrav    a0, at\n+\n+\tloc_86780:\n+\tori     a1, 0x1AA4\n+\taddi    a0, -0x40\n+\tsll     a0, 1\n+\taddu    a0, a1\n+\tlh      a0, 0(a0)\n+\tnop\n+\tsllv    a0, v0\n+\n+\tloc_8679C:\n+\tsrl     v0, a0, 12\n+\tlhu     v1, 0x10(t2)\n+\tmove    a0, v0\n+\tsrl     v1, 1\n+\tslt     v0, v1, a0\n+\tbnez    v0, loc_86810\n+\tsll     v0, a0, 13\n+\tsubu    v0, a0\n+\tdiv     v0, v1\n+\tmflo    v0\n+\tli      v1, 0x1FFF\n+\tlbu     a0, 0xD(t2)\n+\tsubu    v1, v0\n+\tmult    a0, v1\n+\tmflo    at\n+\tlbu     v0, 0xE(t2)\n+\tnop\n+\tmult    v0, v1\n+\tmflo    a0\n+\tlbu     v0, 0xF(t2)\n+\tnop\n+\tmult    v0, v1\n+\tsra     v0, at, 13\n+\taddu    t3, v0\n+\tsra     v0, a0, 13\n+\taddu    t4, v0\n+\tmflo    v1\n+\tsra     v0, v1, 13\n+\taddu    t5, v0\n+\n+\tloc_86810:\n+\taddiu   t1, -1\n+\tbnez    t1, loc_866C4\n+\taddiu   t2, 0x18\n+\n+\tloc_8681C:\n+\taddu    v0, t3, t4\n+\taddu    v0, t5\n+\tbeqz    v0, loc_8688C\n+\tmove    a0, a3\n+\tandi    v0, a3, 0x1F\n+\tsll     v0, 3\n+\taddu    t3, v0\n+\tandi    v1, a3, 0x3E0\n+\tsra     v1, 2\n+\taddu    t4, v1\n+\tandi    v1, a3, 0x7C00\n+\tsra     v1, 7\n+\taddu    t5, v1\n+\tslti    v0, t3, 0x100\n+\tbnez    v0, loc_86860\n+\tslti    v0, t4, 0x100\n+\tli      t3, 0xFF\n+\n+\tloc_86860:\n+\tbnez    v0, loc_8686C\n+\tslti    v0, t5, 0x100\n+\tli      t4, 0xFF\n+\n+\tloc_8686C:\n+\tbnez    v0, loc_86878\n+\tnop\n+\tli      t5, 0xFF\n+\n+\tloc_86878:\n+\tsll     t4, 8\n+\tsll     t5, 16\n+\tor      a0, t3, t4\n+\tj       loc_868AC\n+\tor      a0, t5\n+\n+\tloc_8688C:\n+\tandi    v1, a0, 0x3E0\n+\tandi    v0, a0, 0x7C00\n+\tandi    a0, 0x1F\n+\tsll     a0, 3\n+\tsll     v1, 6\n+\tsll     v0, 9\n+\tor      a0, v1\n+\tor      a0, v0\n+\n+\tloc_868AC:\n+\tmtc2    a0, r6\n+\tjr      ra\n+\tnop\n+\t\n+CalculateObjectLighting:\n+\tjr\tra\n+\tnop\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/LOADSAVE.C b/SPEC_PSX/LOADSAVE.C\nindex b01f4355..e5e6e405 100644\n--- a/SPEC_PSX/LOADSAVE.C\n+++ b/SPEC_PSX/LOADSAVE.C\n@@ -1,13 +1,20 @@\n #include "LOADSAVE.H"\n \n+#include "CD.H"\n+#include "EFFECTS.H"\n+#include "FXTRIG.H"\n #include "GAMEFLOW.H"\n #include "GPU.H"\n #include "MEMCARD.H"\n #include "MISC.H"\n+#include "PSXINPUT.H"\n+#include "REQUEST.H"\n+#include "SAVEGAME.H"\n #include "SPECIFIC.H"\n \n-#include <stdio.h>\n-#include <string.h>\n+#include <STDIO.h>\n+#include <STRING.h>\n+#include <LIBMCRD.H>\n \n static struct REQUESTER InsertReq;\n static struct REQUESTER CheckingReq;\n@@ -100,9 +107,219 @@ int DisplayFiles(int cursor, int maxfiles)//626E4(<), 62DC8(<)\n \treturn n;\n }\n \n-int LoadGame()//6297C, 63060\n+int LoadGame()//6297C(<), 63060\n {\n-\tUNIMPLEMENTED();\n+\tunsigned char stat;\n+\tint ret;\n+\tunsigned char cancel;\n+\tstatic int cursor;\n+\tstatic unsigned char init; // offset 0x144\n+\tstatic unsigned char func; // offset 0x145\n+\tlong cmd;\n+\tlong result;\n+\tstatic unsigned char AutoTime;\n+\tstatic unsigned char AutoFunc;\n+\tstatic struct REQUESTER* AutoRequester;\n+\tint nfiles;\n+\n+\tret = 0;\n+\tcancel = 1;\n+\n+\tif (PadConnected == 0)\n+\t{\n+\t\tmcClose();\n+\t\tinit = 0;\n+\t\treturn 0;\n+\t}\n+\n+\t//loc_629BC\n+\tif (init == 0)\n+\t{\n+\t\tif (mcInit != 0)\n+\t\t{\n+\t\t\tmcClose();\n+\t\t}\n+\t\t//loc_629E8\n+\t\tmcOpen(0);\n+\t\tfunc = 4;\n+\t\tcursor = 0;\n+\t\tinit = cancel;\n+\t}\n+\t//loc_62A00\n+\treset_count = 0;\n+\tstat = mcGetStatus();\n+\n+\tswitch (func)\n+\t{\n+\tcase 0:\n+\t\t//loc_62AE0:\n+\t\tAutoRequester = &InsertReq;\n+\t\tfunc = stat;\n+\n+\t\tif (mcNumFiles == 0)\n+\t\t{\n+\t\t\tRequester(&NoGamesReq);\n+\t\t}\n+\t\telse\n+\t\t{\n+\t\t\t//loc_62B10\n+\t\t\tPrintString(SCREEN_WIDTH / 2, 0x20, 8, &gfStringWad[gfStringOffset[STR_SELECT_GAME_TO_LOAD]], 0x8000);\n+\t\t\tnfiles = DisplayFiles(cursor, mcNumFiles);\n+\n+\t\t\tif ((RawEdge & 0x10) && cursor != 0)\n+\t\t\t{\n+\t\t\t\tSoundEffect(0x6D, 0, 2);\n+\t\t\t\t--cursor;\n+\t\t\t}\n+\t\t\t//loc_62B9C\n+\t\t\telse if ((RawEdge & 0x40) && cursor < nfiles - 1)\n+\t\t\t{\n+\t\t\t\tSoundEffect(0x6D, 0, 2);\n+\t\t\t\t++cursor;\n+\t\t\t}\n+\t\t\t//loc_62BEC\n+\t\t\telse if ((RawEdge & 0x4000))\n+\t\t\t{\n+\t\t\t\tSoundEffect(0x6F, 0, 2);\n+\t\t\t\tfunc = 7;\n+\t\t\t\tAutoRequester = &LoadingReq;\n+\t\t\t\tAutoTime = 3;\n+\t\t\t\tAutoFunc = 0xB;\n+\t\t\t\tcancel = 0;\n+\t\t\t}\n+\t\t}\n+\t\tbreak;\n+\tcase 1:\n+\t\t//loc_62A40\n+\t\tRequester(&InsertReq);\n+\t\tAutoRequester = &InsertReq;\n+\t\tfunc = stat;\n+\t\tbreak;\n+\tcase 2:\n+\t\t//loc_62AC8\n+\t\tRequester(&NotFormatReq);\n+\t\tfunc = stat;\n+\t\tbreak;\n+\tcase 3:\n+\t\t//loc_62A60\n+\t\tRequester(AutoRequester);\n+\n+\t\tif (AutoTime == 0)\n+\t\t{\n+\t\t\tfunc = stat;\n+\t\t\tcancel = 0;\n+\t\t}\n+\t\telse\n+\t\t{\n+\t\t\t//loc_62A88\n+\t\t\t--AutoTime;\n+\t\t\tcancel = 0;\n+\t\t}\n+\t\tbreak;\n+\tcase 4:\n+\t\t//loc_62A94\n+\t\tAutoRequester = &InsertReq;\n+\t\tif (func == 4)\n+\t\t{\n+\t\t\tRequester(&CheckingReq);\n+\t\t}\n+\t\t//loc_62AB8\n+\t\tfunc = stat;\n+\t\tcursor = 0;\n+\t\tbreak;\n+\tcase 5:\n+\tcase 6:\n+\tcase 8:\n+\tcase 9:\n+\tcase 10:\n+\t\t///@TODO loc_62dc0\n+\t\tbreak;\n+\tcase 7:\n+\t\t//loc_62C2C\n+\t\tRequester(AutoRequester);\n+\n+\t\tif (AutoTime == 0)\n+\t\t{\n+\t\t\tif (AutoFunc == -1)\n+\t\t\t{\n+\t\t\t\tret = 1;\n+\t\t\t\t//loc_62DBC\n+\t\t\t\tcancel = 0;\n+\t\t\t}\n+\t\t\telse\n+\t\t\t{\n+\t\t\t\t//loc_62C60\n+\t\t\t\tfunc = AutoFunc;\n+\t\t\t\tcancel = 0;\n+\t\t\t}\n+\t\t}\n+\t\telse\n+\t\t{\n+\t\t\t//loc_62C6C\n+\t\t\t--AutoTime;\n+\t\t\tcancel = 0;\n+\t\t}\n+\t\tbreak;\n+\tcase 11:\n+\t\t//loc_62C78:\n+\t\tAutoRequester = &LoadErrorReq;\n+\t\tAutoTime = 60;\n+\t\tfunc = 3;\n+\n+\t\tif (mcFileLengths[cursor] != 0)\n+\t\t{\n+\t\t\tMemCardSync(0, &cmd, &result);\n+\t\t\tif (MemCardOpen(0, &mcFileNames[cursor][0], 1) == 0)\n+\t\t\t{\n+\t\t\t\tS_MemSet(MGSaveGamePtr, 0, 0x2000);\n+\t\t\t\tif (MemCardReadData((unsigned long*)MGSaveGamePtr, 0x200, 0x1E00) != 0)\n+\t\t\t\t{\n+\t\t\t\t\tMemCardSync(0, &cmd, &result);\n+\n+\t\t\t\t\tif (result == 0)\n+\t\t\t\t\t{\n+\t\t\t\t\t\tif (CheckSumValid(MGSaveGamePtr) != 0)\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tmemcpy(&savegame, MGSaveGamePtr, sizeof(struct savegame_info));\n+\t\t\t\t\t\t\tGPU_SetScreenPosition(savegame.ScreenX, savegame.ScreenY);\n+\t\t\t\t\t\t\tCDDA_SetMasterVolume(savegame.VolumeCD);\n+\n+\t\t\t\t\t\t\tAutoRequester = &LoadOkReq;\n+\t\t\t\t\t\t\tAutoFunc = -1;\n+\t\t\t\t\t\t\tAutoTime = 30;\n+\t\t\t\t\t\t\tfunc = 7;\n+\t\t\t\t\t\t\tSoundFXVolume = savegame.VolumeFX;\n+\t\t\t\t\t\t}//loc_62DB4\n+\t\t\t\t\t}//loc_62DB4\n+\n+\t\t\t\t\tMemCardClose();\n+\t\t\t\t\tcancel = 0;\n+\t\t\t\t}//def_62A38\n+\t\t\t}//def_62A38\n+\t\t}//def_62A38 end\n+\t\tbreak;\n+\tcase 12:\n+\t\t///@TODO loc_63124?\n+\t\tbreak;\n+\t}\n+\n+\t//def_62A38\n+\tif (cancel != 0)\n+\t{\n+\t\tPrintString(SCREEN_WIDTH / 2, 0xE8, 5, &gfStringWad[gfStringOffset[STR_CANCEL]], 0x8000);\n+\t\tif ((RawEdge & 0x1000))\n+\t\t{\n+\t\t\tinit = 0;\n+\t\t\tret = -1;\n+\t\t}\n+\t}\n+\t//loc_62E14\n+\tif (ret != 0)\n+\t{\n+\t\tinit = 0;\n+\t\treturn ret;\n+\t}//loc_62E20\n+\n \treturn 0;\n }\n \ndiff --git a/SPEC_PSX/LOFFSET.TBL b/SPEC_PSX/LOFFSET.TBL\nnew file mode 100644\nindex 00000000..223229d6\nBinary files /dev/null and b/SPEC_PSX/LOFFSET.TBL differ\ndiff --git a/SPEC_PSX/LOT_S.MIP b/SPEC_PSX/LOT_S.MIP\nnew file mode 100644\nindex 00000000..0fda4b68\n--- /dev/null\n+++ b/SPEC_PSX/LOT_S.MIP\n@@ -0,0 +1,4 @@\n+\topt at+,w-,c+,m-\n+\n+\tSECTION\tASM\n+\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/LTAB.TBL b/SPEC_PSX/LTAB.TBL\nnew file mode 100644\nindex 00000000..97258ffb\nBinary files /dev/null and b/SPEC_PSX/LTAB.TBL differ\ndiff --git a/SPEC_PSX/MALLOC.C b/SPEC_PSX/MALLOC.C\nindex f820d790..4c23f423 100644\n--- a/SPEC_PSX/MALLOC.C\n+++ b/SPEC_PSX/MALLOC.C\n@@ -7,7 +7,7 @@\n #include <stdio.h>\n #include <string.h>\n \n-#define GAME_MALLOC_BUFFER_SIZE (1024*1024) + (1024*36)\n+#define GAME_MALLOC_BUFFER_SIZE (1024*1060)\n \n char* malloc_ptr = NULL;\n int malloc_used = 0;\n@@ -98,15 +98,4 @@ void game_free(int size)//5E85C(<), 5F590(<) (F) (*)\n void show_game_malloc_totals()//5E894(<), * (F) (*)\n {\n \tprintf("---->Total Memory Used %dK of %dK<----\\n", ((malloc_used + 1023) / 1024) - 10, ((malloc_used + malloc_free) / 1024) - 10);\n-}\n-\n-/*\n- * [FUNCTIONALITY] - dump_game_malloc.\n- * Dumps the entire malloc_buffer to a file named "DUMP.BIN"\n- * This is typically used to inspect malloc_buffer memory and compare to PS1.\n- */\n-\n-void dump_game_malloc()//*, *\n-{\n-\treturn;\n }\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/MATHS.H b/SPEC_PSX/MATHS.H\nindex 8282841d..aad3544a 100644\n--- a/SPEC_PSX/MATHS.H\n+++ b/SPEC_PSX/MATHS.H\n@@ -13,7 +13,7 @@ extern void mPushUnitMatrix();\n extern void mTranslate();\n extern void mTranslateAbsXYZ(long x, long y, long z);\n extern void mTranslateXYZ(long x, long y, long z);\n-extern void mRotX();\n+extern void mRotX(long rx);\n extern void mRotY(long ry);\n extern void mRotYXZ(short y, short x, short z);\n extern void mRotZ();\ndiff --git a/SPEC_PSX/MATHS.MIP b/SPEC_PSX/MATHS.MIP\nindex 5468b6cb..76bc549c 100644\n--- a/SPEC_PSX/MATHS.MIP\n+++ b/SPEC_PSX/MATHS.MIP\n@@ -1,8 +1,9 @@\n-\topt L.,C+,at+\n+\tOPT L.,C+,at+\n \n-\tsection\t.ASM\n-\txdef mQuickW2VMatrix, ASM_GetBounds, mPushMatrix, mPopMatrix, mSetTrans, mTranslateXYZ, mTranslateAbsXYZ, mPushUnitMatrix, mRotY, mRotX, mRotZ, mNormaliseXYZ, mCopyMatrix, ScaleCurrentMatrix, phd_sqrt_asm, mGetAngle, GetRoomBoundsAsm, phd_LookAt, phd_atan_asm, mRotYXZ, mRotSuperPackedYXZ, iTranslateXYZ, iTranslateXYZ2, InitInterpolation, iRotSuperPackedYXZ, iPopMatrix, iPushMatrix, iRotX, iRotY, iRotZ, InterpolateMatrix, mRotBoundingBoxNoPersp, mSqrt\n-\txref phd_mxptr, MatrixStack, Matrix, MatrixSP, w2v_matrix, CamGTE, iMatrix, atanOctantTab, iFrac, iRate, outside, number_draw_rooms, draw_rooms, room, iAmbientR, CamPos, iAmbientG, iAmbientB\n+\tSECTION\tASM\n+\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n+\tXDEF mQuickW2VMatrix, ASM_GetBounds, mPushMatrix, mPopMatrix, mSetTrans, mTranslateXYZ, mmPushMatrix, mmPopMatrix, mTranslateAbsXYZ, mPushUnitMatrix, mRotY, mRotX, mRotZ, mNormaliseXYZ, mCopyMatrix, ScaleCurrentMatrix, phd_sqrt_asm, mGetAngle, GetRoomBoundsAsm, phd_LookAt, phd_atan_asm, mRotYXZ, mRotSuperPackedYXZ, iTranslateXYZ, iTranslateXYZ2, InitInterpolation, iRotSuperPackedYXZ, iPopMatrix, iPushMatrix, iRotX, iRotY, iRotZ, InterpolateMatrix, mRotBoundingBoxNoPersp, mSqrt, mClipBoundingBox\n+\tXREF phd_right, phd_bottom, phd_left, phd_top, phd_mxptr, MatrixStack, Matrix, MatrixSP, w2v_matrix, CamGTE, iMatrix, atanOctantTab, iFrac, iRate, outside, number_draw_rooms, draw_rooms, room, iAmbientR, CamPos, iAmbientG, iAmbientB\n \n ASM_GetBounds:\n \tslt     at, t0, a2\n@@ -318,6 +319,35 @@ mTranslateXYZ:\n \tjr\tra\n \tsw\tt2, 0x1C(v0)\n \n+;0x81BBC\n+mmPushMatrix:\n+\tlw      a0, 0x50(fp)\n+\tcfc2    t0, r0\n+\tcfc2    t1, r1\n+\tcfc2    t2, r2\n+\tcfc2    t3, r3\n+\tcfc2    t4, r4\n+\tcfc2    t5, r5\n+\tcfc2    t6, r6\n+\tcfc2    t7, r7\n+\taddi    a0, 0x20\n+\tsw      t0, 0(a0)\n+\tsw      t1, 4(a0)\n+\tsw      t2, 8(a0)\n+\tsw      t3, 0xC(a0)\n+\tsw      t4, 0x10(a0)\n+\tsw      t5, 0x14(a0)\n+\tsw      t6, 0x18(a0)\n+\tsw      t7, 0x1C(a0)\n+\tjr      ra\n+\tsw      a0, 0x50(fp)\n+\t\n+;0x81C0C\n+mmPopMatrix:\n+\tlw      a0, 0x50(fp)\n+\tnop\n+\taddi    a0, -0x20\n+\n ;0x7669C\n mRotX:\n \tsrl     a0, 2\n@@ -790,7 +820,116 @@ mSetTrans:\n \n ;0x76B14\n mClipBoundingBox:\n-\tjr\tra\n+\tcfc2    t0, r7\n+\tmove    v0, zero\n+\taddi    t0, -0x5000\n+\tbgez    t0, locret_76CAC\n+\tlhu     t0, 0(a0)\n+\tlhu     t3, 2(a0)\n+\tlhu     t1, 4(a0)\n+\tlhu     t4, 6(a0)\n+\tlhu     t2, 8(a0)\n+\tlhu     t7, 0xA(a0)\n+\tsll     t1, 16\n+\tsll     t4, 16\n+\tor      at, t0, t1\n+\tmtc2    at, r0\n+\tmtc2    t2, r1\n+\tor      at, t3, t1\n+\tmtc2    at, r2\n+\tmtc2    t2, r3\n+\tor      at, t0, t4\n+\tmtc2    at, r4\n+\tmtc2    t2, r5\n+\tmove    v1, ra\n+\tnop\n+\tnop\n+\tcop2    0x280030\n+\tor      t9, t3, t4\n+\tmove    t8, t2\n+\tli      a0, 0x7FFFFFFF\n+\tlui     a1, 0x8100\n+\tmove    a2, a0\n+\tmfc2    t0, r12\n+\tmfc2    t1, r13\n+\tmfc2    t2, r14\n+\tmfc2    t3, r17\n+\tmfc2    t4, r18\n+\tmfc2    t5, r19\n+\tmtc2    t7, r1\n+\tmtc2    t7, r3\n+\tmtc2    t7, r5\n+\tmove    a3, a1\n+\tnop\n+\tnop\n+\tcop2    0x280030\n+\taddi    t3, -0x21\n+\taddi    t4, -0x21\n+\taddi    t5, -0x21\n+\tjal     ASM_GetBounds\n+\tmove    v0, zero\n+\tmfc2    t0, r12\n+\tmfc2    t1, r13\n+\tmfc2    t2, r14\n+\tmfc2    t3, r17\n+\tmfc2    t4, r18\n+\tmfc2    t5, r19\n+\tmtc2    t9, r0\n+\tmtc2    t8, r1\n+\tmtc2    t9, r2\n+\taddi    t3, -0x21\n+\tnop\n+\tnop\n+\tcop2    0x280030\n+\taddi    t4, -0x21\n+\tjal     GetBounds\n+\taddi    t5, -0x21\n+\tmfc2    t0, r12\n+\tmfc2    t1, r13\n+\tmfc2    t3, r17\n+\tmfc2    t4, r18\n+\taddi    t3, -0x21\n+\taddi    t4, -0x21\n+\tmove    t2, t1\n+\tjal     GetBounds\n+\tmove    t5, t4\n+\tmove    ra, v1\n+\tlw      t0, phd_right-GP_ADDR(gp)\n+\tlw      t1, phd_bottom-GP_ADDR(gp)\n+\tlw      t2, phd_left-GP_ADDR(gp)\n+\tlw      t3, phd_top-GP_ADDR(gp)\n+\tsra     a0, 16\n+\tsra     a1, 16\n+\tsra     a2, 16\n+\tsra     a3, 16\n+\tmove    v1, v0\n+\tbeqz    v1, locret_76CAC\n+\tmove    v0, zero\n+\tslt     at, t0, a0\n+\tbnez    at, locret_76CAC\n+\tslt     at, t1, a2\n+\tbnez    at, locret_76CAC\n+\tslt     at, a1, t2\n+\tbnez    at, locret_76CAC\n+\tslt     at, a3, t3\n+\tbnez    at, locret_76CAC\n+\tnop\n+\tslti    at, v1, 9\n+\tbnez    at, locret_76CAC\n+\tli      v0, 0xFFFFFFFF\n+\tslt     at, a0, t2\n+\tbnez    at, locret_76CAC\n+\tslt     at, a2, t3\n+\tbnez    at, locret_76CAC\n+\tslt     at, t0, a1\n+\tbnez    at, locret_76CAC\n+\tslt     at, t1, a3\n+\tbnez    at, locret_76CAC\n+\tnop\n+\tli      v0, 1\n+\n+\tlocret_76CAC:\n+\tjr      ra\n \tnop\n \n ;0x76CB4\ndiff --git a/SPEC_PSX/MISC.H b/SPEC_PSX/MISC.H\nindex a688d3be..a37b4b17 100644\n--- a/SPEC_PSX/MISC.H\n+++ b/SPEC_PSX/MISC.H\n@@ -5,11 +5,12 @@\n #include <LIBGTE.H>\n #include <LIBGPU.H>\n \n+extern void S_MemSet(char* p, int value, int length);\n extern void S_LongMemCpy(unsigned long* pDest, unsigned long* pSrc, unsigned long size);\n-extern void DrawF4(unsigned short x, unsigned short y, unsigned short w, unsigned short h, unsigned short unk, unsigned short unk2);\n+extern void DrawF4(unsigned short x, unsigned short y, unsigned short w, unsigned short h, int unk, int unk2);\n extern void DrawTPage(unsigned char a0, unsigned char a1);\n-extern void DrawLineH(long a0, long a1, long a2, long a3);\n-extern void DrawLineV(long a0, long a1, long a2, long a3);\n+extern void DrawLineH(long a0, long a1, long a2, long a3, long a4, long a5);\n+extern void DrawLineV(long a0, long a1, long a2, long a3, long a4, long a5);\n extern void LOAD_VSyncHandler();\n extern void LOAD_DrawEnable(unsigned char isEnabled);\n extern void GPU_BeginScene();\n@@ -21,5 +22,9 @@ extern void GPU_SetScreenPosition(short x, short y);\n extern void GPU_SyncBothScreens();\n extern void GPU_FlipToBuffer(int buffer_index);\n extern void S_AnimateTextures(long nFrames);\n-\n+extern void PrintGauge(int x, int y, int length);\n+extern long GetRandomControl();\n+extern void SeedRandomControl(long seed);\n+extern long GetRandomDraw();\n+extern void SeedRandomDraw(long seed);\n #endif\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/MISC.MIP b/SPEC_PSX/MISC.MIP\nindex a4d2350f..2841ef68 100644\n--- a/SPEC_PSX/MISC.MIP\n+++ b/SPEC_PSX/MISC.MIP\n@@ -1,9 +1,68 @@\n \topt at-,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF draw_rotate_sprite, S_AnimateTextures, S_LongMemCpy, DrawF4, DrawTPage, DrawLineH, DrawLineV, LOAD_VSyncHandler, GPU_ClearVRAM, GPU_BeginScene, GPU_FlipToBuffer, GPU_GetScreenPosition, GPU_SetScreenPosition, LOAD_DrawEnable, GPU_SyncBothScreens\n-\tXREF LtLoadingBarEnabled, _first_time_ever, DrawOTagEnv, GnLastFrameCount, db, rcossin_tbl, DelRotAng, ClearOTagR, DrawSync, VSync, MoveImage, PutDispEnv, PutDrawEnv, ClearImage, DrawSync, VSync, DrawOTagEnv\n+\tXDEF GetRandomControl, GetRandomDraw, SeedRandomControl, SeedRandomDraw, PrintGauge, S_MemSet, draw_rotate_sprite, S_AnimateTextures, S_LongMemCpy, DrawF4, DrawTPage, DrawLineH, DrawLineV, LOAD_VSyncHandler, GPU_ClearVRAM, GPU_BeginScene, GPU_FlipToBuffer, GPU_GetScreenPosition, GPU_SetScreenPosition, LOAD_DrawEnable, GPU_SyncBothScreens\n+\tXREF rand_1, rand_2, S_DrawGouraudBar, dashBarColourSet, LtLoadingBarEnabled, _first_time_ever, DrawOTagEnv, GnLastFrameCount, db, rcossin_tbl, DelRotAng, ClearOTagR, DrawSync, VSync, MoveImage, PutDispEnv, PutDrawEnv, ClearImage, DrawSync, VSync, DrawOTagEnv\n+\t\n+PrintGauge:\n+\tli      at, 0x64\n+\tmult    a2, at\n+\tmflo    a3\n+\tla      v0, dashBarColourSet\n+\tli      at, 0xFF\n+\tdiv     a3, at\n+\tsw      v0, 0x10(sp)\n+\tandi    a0, 0xFFFF\n+\tandi    a1, 0xFFFF\n+\tmflo    a3\n+\tj       S_DrawGouraudBar\n+\tli      a2, 0x64\n+\n+S_MemSet:\n+\tbeqz    a2, locret_5E95C\n+\tsll     t7, a1, 8\n+\tslti    at, a2, 4\n+\tbnez    at, loc_5E94C\n+\tor      a1, t7\n+\tsll     t7, a1, 16\n+\tor      a1, t7\n+\tandi    t7, a0, 3\n+\tbeqz    t7, loc_5E928\n+\tli      t6, 4\n+\tsubu    t7, t6, t7\n+\tsubu    a2, t7\n+\n+\tloc_5E918:\n+\tsb      a1, 0(a0)\n+\taddi    t7, -1\n+\tbnez    t7, loc_5E918\n+\taddi    a0, 1\n+\n+\tloc_5E928:\n+\tsra     t7, a2, 2\n+\tbeqz    t7, loc_5E944\n+\tandi    a2, 3\n+\n+\tloc_5E934:\n+\tsw      a1, 0(a0)\n+\taddi    t7, -1\n+\tbnez    t7, loc_5E934\n+\taddi    a0, 4\n+\n+\tloc_5E944:\n+\tbeqz    a2, locret_5E95C\n+\tnop\n+\n+\tloc_5E94C:\n+\tsb      a1, 0(a0)\n+\taddi    a2, -1\n+\tbnez    a2, loc_5E94C\n+\taddi    a0, 1\n+\n+\tlocret_5E95C:\n+\tjr      ra\n+\tnop\n \t\n S_AnimateTextures:\n \tjr ra\n@@ -458,4 +517,35 @@ GPU_SyncBothScreens:\n \tlw      ra, 0x14-0x4(sp)\n \taddiu   sp, 0x14\n \tj       DrawSync\n-\tmove    a0, zero\n\\ No newline at end of file\n+\tmove    a0, zero\n+\t\n+\t\n+GetRandomControl:\n+\tlw      v0, rand_1-GP_ADDR(gp)\n+\tli      at, 0x41C64E6D\n+\tmult    v0, at\n+\tmflo    at\n+\taddiu   v0, at, 0x3039\n+\tsw      v0, rand_1-GP_ADDR(gp)\n+\tsra     v0, 16\n+\tjr      ra\n+\tandi    v0, 0x7FFF\n+\t\n+GetRandomDraw:\n+\tlw      v0, rand_2-GP_ADDR(gp)\n+\tli      at, 0x41C64E6D\n+\tmult    v0, at\n+\tmflo    at\n+\taddiu   v0, at, 0x3039\n+\tsw      v0, rand_2-GP_ADDR(gp)\n+\tsra     v0, 16\n+\tjr      ra\n+\tandi    v0, 0x7FFF\n+\t\n+SeedRandomControl:\n+\tjr\t\tra\n+\tsw\t\ta0, rand_1-GP_ADDR(gp)\n+\t\n+SeedRandomDraw:\n+\tjr\t\tra\n+\tsw\t\ta0, rand_2-GP_ADDR(gp)\ndiff --git a/SPEC_PSX/REQUEST.C b/SPEC_PSX/REQUEST.C\nindex b5ed64bb..3d7e28f7 100644\n--- a/SPEC_PSX/REQUEST.C\n+++ b/SPEC_PSX/REQUEST.C\n@@ -1,483 +1,220 @@\n #include "REQUEST.H"\n \n+#include "EFFECTS.H"\n #include "FXTRIG.H"\n #include "GAMEFLOW.H"\n #include "MISC.H"\n+#include "SAVEGAME.H"\n #include "SPECIFIC.H"\n-#include "TEXT.H"\n+#include "PSXINPUT.H"\n+#include "TEXT_S.H"\n \n-long Requester(struct REQUESTER* r)//63718, 63DF4\n+long Requester(struct REQUESTER* r)//63718(<), 63DF4 (F)\n {\n-\t//sizeof(struct REQUESTER);\n-\n-\tint x; // $s4\n-\tint y; // $s2\n-\tshort top; // stack offset -48\n-\tunsigned short w; // stack offset -56\n-\tunsigned short h; // stack offset -54\n-\tint i; // $s1\n-\tint optiony; // $s6\n-\tunsigned short rx; // $s5\n-\tunsigned short ry; // $s7\n-\tunsigned short rw; // stack offset -52\n-\tunsigned short rh; // stack offset -50\n-\tshort OptionTop[5]; // stack offset -88\n-\tshort OptionBottom[5]; // stack offset -72\n-\t//{ // line 66, offset 0x63a90\n-\tint val; // $s0\n-\t//} // line 68, offset 0x63ad0\n-\tlong t0;\n-\n-\t//a1 = &w;\n-\t//s3 = r;\n-\t//v0 = r->TitleTxt;\n-\t//v1 = gfStringOffset;\n-\t//a0 = gfStringWad;\n-\n-\t//a0 = &gfStringWad[gfStringOffset[r->TitleTxt]];\n+\tint x;\n+\tint y;\n+\tshort top;\n+\tunsigned short w;\n+\tunsigned short h;\n+\tint i;\n+\tint optiony;\n+\tunsigned short rx;\n+\tunsigned short ry;\n+\tunsigned short rw;\n+\tunsigned short rh;\n+\tshort OptionTop[5];\n+\tshort OptionBottom[5];\n+\tint val;\n \n \tGetStringDimensions(&gfStringWad[gfStringOffset[r->TitleTxt]], &w, &h);\n-\n-\t//s2 = &top;\n-\t//v0 = 0x00E00000;\n-\t//v1 = h;\n-\n-\t//a0 = r->nOptions\n-\n \toptiony = h + 4;\n-\n \tif (r->nOptions != 0)\n \t{\n-\t\t//loc_637B0\n-\t\tfor (i = 0; i < r->nOptions; i++)\n-\t\t{\n-\t\t\th += 2;\n-\n-\t\t\tGetStringLength(&gfStringWad[gfStringOffset[r->OptionTxt[i]]], (unsigned short*)&OptionTop[i], (unsigned short*)&OptionBottom[i]);\n-\t\t\tGetStringDimensions(&gfStringWad[gfStringOffset[r->OptionTxt[i]]], &rw, &rh);\n+\t\th += 2;\n \n-\t\t\tif (i == 0 && r->Ignore != 0)\n-\t\t\t{\n-\t\t\t\tOptionBottom[0] = OptionTop[0] + rh;\n-\t\t\t}\n-\n-\t\t\t//loc_63858\n-\t\t\tif (w < rw)\n+\t\tif (r->nOptions != 0)\n+\t\t{\n+\t\t\t//loc_637B0\n+\t\t\tfor (i = 0; i < r->nOptions; i++)\n \t\t\t{\n-\t\t\t\tw = rw;\n+\t\t\t\tGetStringLength(&gfStringWad[gfStringOffset[r->OptionTxt[i]]], &OptionTop[i], &OptionBottom[i]);\n+\t\t\t\tGetStringDimensions(&gfStringWad[gfStringOffset[r->OptionTxt[i]]], &rw, &rh);\n+\n+\t\t\t\tif (i == 0 && r->Ignore != 0)\n+\t\t\t\t{\n+\t\t\t\t\tOptionBottom[0] = OptionTop[0] + rh;\n+\t\t\t\t}\n+\t\t\t\t//loc_63858\n+\t\t\t\tif (w < rw)\n+\t\t\t\t{\n+\t\t\t\t\tw = rw;\n+\t\t\t\t}\n \t\t\t}\n-\n-\t\t\t//loc_63874\n-\t\t\th += rh;\n-\t\t}\n+\t\t}//loc_6389C\n \t}\n-\n-#if 1\n \t//loc_6389C\n-\t//a1 = y;\n-\t//a2 = 0;\n-\t//a0 = 0x78\n-\t//v0 = h;\n-\t//a3 = w;\n-\t//v0 >>= 1;\n-\t//s2 = a0 - v0;///@todo y\n-\t//v1 = a3 - 0x20;\n-\t//a3 >>= 1;\n-\n-\trw = w - 32;\n-\n \n-\t//t0 = gfStringOffset[r->TitleTxt];\n-\t//v1 = h;\n-\t//v1 += 0x10;\n-\t//v0 = 0x100\n-\tx = 0x100 - (w >> 1);\n+\ty = 120 - (h >> 1);\n+\trw = w + 32;\n+\tx = 256 - (w >> 1);\n \trh = h + 16;\n+\trx = (x - 16) & 0xFFFF;\n+\try = (y - 8) & 0xFFFF;\n \n-\t//v1 = s4 + -0x10;\n-\t//s5 = v1 & 0xFFFF;\n-\t//v0 = s2 - 8;\n-\t//a0 = gfStringWad;\n-\t//s7 = v0 & 0xFFFF;\n-\n-\tGetStringLength(&gfStringWad[gfStringOffset[r->TitleTxt]], (unsigned short*)&top, NULL);\n-\n-\t//a0 = 0x100\n-\t//a1 = top\n-\t//a2 = r->TitleCol\n-\t//v0 = r->TitleTxt;\n-\n-\t//v1 = gfStringOffset\n-\t//a3 = gfStringWad;\n-\n-\t//a1 = ((y - top) + 2) & 0xFFFF;\n-\n-\t//t0 = gfStringOffset[r->TitleTxt];\n-\t//v0 = 0x8000;\n-\tOptionTop[4] = 0x8000;///@CHECKME sw\t$v0, 0x70 + var_60($sp) //TODO cast word\n-\n-\tPrintString(256, ((y - top) + 2) & 0xFFFF, r->TitleCol, &gfStringWad[gfStringOffset[r->TitleTxt]], 0);\n+\tGetStringLength(&gfStringWad[gfStringOffset[r->TitleTxt]], &top, NULL);\n+\tPrintString(256, ((y - top) + 2) & 0xFFFF, r->TitleCol, &gfStringWad[gfStringOffset[r->TitleTxt]], 0x8000);\n \n \tif (r->nOptions != 0)\n \t{\n-\t\t//s0 = x & 0xFFFF\n-\t\t//a0 = s0;\n-\t\t//a1 = ((y + optiony) - 4) & 0xFFFF\n-#if 1\n-\n-\t\t//a2 = W;\n-\t\t//a3 = 1\n-\n-\t\t((long*) &OptionTop[4])[0] = 0;//sw\t$zero, 0x70 + var_60($sp) check\n-\t\t((long*) &OptionTop[2])[0] = 0xC0C0C0;//sw\t$v0, 0x70 + var_5C($sp)\n-\t\tDrawLineH(x & 0xFFFF, ((y + optiony) - 4) & 0xFFFF, w, 1);\n-\n-\n-\t\tDrawTPage(1, 1);\n-\n-\t\t//v1 = OptionTop[0];\n-\n-\t\t//s1 = 0 (i)\n-\t\t//sw\t$s0, 0x70 + var_2C($sp)\n-\t\t//v1 = optiony - OptionTop[0];\n-\n-\t\ty += optiony - OptionTop[0]; \t//addu\t$s2, $v1\n+\t\tDrawLineH(x & 0xFFFF, ((y + optiony) - 4) & 0xFFFF, w, 1, 0, 0xC0C0C0);\n+\t\tDrawTPage(0, 1);\n \n-\t\t\tif (r->nOptions != 0)\n+\t\ty += optiony - OptionTop[0];\n+\t\tif (r->nOptions != 0)\n+\t\t{\n+\t\t\t//loc_639D8\n+\t\t\tfor (i = 0; i < r->nOptions; i++)\n \t\t\t{\n-\n-\t\t\t\t//s6 = &r->OptionTxt[0];\n-\t\t\t\t//fp = &savegame;\n-\n-\t\t\t\t//loc_639D8://LOOP\n-\t\t\t\t//lw\t$v1, 4($s3)\n-\t\t\t\t\t//v0 = r.JustifyL;\n-\t\t\t\t\tif (i == 0 && r->Ignore != 0)\n+\t\t\t\tif (i == 0 && r->Ignore != 0)\n+\t\t\t\t{\n+\t\t\t\t\tDisplayConfig(x, y);\n+\t\t\t\t}\n+\t\t\t\telse\n+\t\t\t\t{\n+\t\t\t\t\t//loc_63A08\n+\t\t\t\t\tif ((r->JustifyL >> h) & 1)\n \t\t\t\t\t{\n-\t\t\t\t\t\tDisplayConfig(x, y);\n+\t\t\t\t\t\tif (i != r->CursorPos)\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tPrintString(x & 0xFFFF, y & 0xFFFF, r->OptionCol, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], 0);\n+\t\t\t\t\t\t}//loc_63A34\n+\t\t\t\t\t\telse\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tPrintString(x & 0xFFFF, y & 0xFFFF, 1, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], 0);\n+\t\t\t\t\t\t}\n \t\t\t\t\t}\n \t\t\t\t\telse\n \t\t\t\t\t{\n-\t\t\t\t\t\t//loc_63A08\n-\t\t\t\t\t\t//v0 = r.JustifyL >> i;\n-\t\t\t\t\t\t// andi\t$a1, $s2, 0xFFFF\n-\t\t\t\t\t\tif ((r->JustifyL >> i) & 1)\n+\t\t\t\t\t\t//loc_63A78\n+\t\t\t\t\t\tif ((r->JustifyR >> i) & 1)\n \t\t\t\t\t\t{\n-\t\t\t\t\t\t\tt0 = 1;\n-\t\t\t\t\t\t\tif (i == r->CursorPos)\n+\t\t\t\t\t\t\tif (i != 0)\n \t\t\t\t\t\t\t{\n-\t\t\t\t\t\t\t\tt0 = r->OptionCol;\n-\n-\t\t\t\t\t\t\t}//loc_63A34\n+\t\t\t\t\t\t\t\tval = savegame.VolumeCD;\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\telse\n+\t\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t\tval = savegame.VolumeFX;\n+\t\t\t\t\t\t\t}\n \n-\t\t\t\t\t\t\t//v0 = &r->OptionTxt[i << 1];\n-\t\t\t\t\t\t\t//a0 = x;//checkme  lw\t$a0, 0x70 + var_2C($sp)\n-\t\t\t\t\t\t\t//v1 = r->OptionTxt[i << 1];\n-\t\t\t\t\t\t\t//a2 = gfStringOffset\n-\t\t\t\t\t\t\t//a3 = &gfStringWad[gfStringOffset[r->OptionTxt[i << 1]]];\n+\t\t\t\t\t\t\t//loc_63AA8\n+\t\t\t\t\t\t\tif (i == r->CursorPos)\n+\t\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t\tPrintString(((rw + x) - 32) & 0xFFFF, y & 0xFFFF, 1, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], 0x4000);\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\telse\n+\t\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t\t//loc_63AD0\n+\t\t\t\t\t\t\t\tPrintString(((rw + x) - 32) & 0xFFFF, y & 0xFFFF, r->OptionCol, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], 0x4000);\n+\t\t\t\t\t\t\t}\n \n-\t\t\t\t\t\t\t//v1 = gfStringOffset[r->OptionTxt[i << 1]];\n-\t\t\t\t\t\t\tOptionTop[4] = 0;//checkme sw\t$zero, 0x70 + var_60($sp)\n-\t\t\t\t\t\t\tPrintString(x, y & 0xFFFF, t0, &gfStringWad[gfStringOffset[r->OptionTxt[i << 1]]], 0);\n-\t\t\t\t\t\t\t//j\tloc_63B88\n+\t\t\t\t\t\t\tPrintGauge(((rw + x) - 140) & 0xFFFF, (y - 7) & 0xFFFF, val);\n \t\t\t\t\t\t}\n \t\t\t\t\t\telse\n \t\t\t\t\t\t{\n-\t\t\t\t\t\t\t//loc_63A78\n-\t\t\t\t\t\t\tif ((r->JustifyR >> i) & 1)\n+\t\t\t\t\t\t\t//loc_63B30\n+\t\t\t\t\t\t\tif (i == r->CursorPos)\n \t\t\t\t\t\t\t{\n-\t\t\t\t\t\t\t\tif (i != 0)\n-\t\t\t\t\t\t\t\t{\n-\t\t\t\t\t\t\t\t\t//val = lhu\t$s0, 0x70 + var_6E($fp)\n-\t\t\t\t\t\t\t\t}//loc_63AA4\n-\t\t\t\t\t\t\t\telse\n-\t\t\t\t\t\t\t\t{\n-\t\t\t\t\t\t\t\t\t//val =  lhu\t$s0, 0x70 + var_6C($fp)\n-\t\t\t\t\t\t\t\t}\n-\n-\t\t\t\t\t\t\t\t//loc_63AA8\n-\t\t\t\t\t\t\t\t//v0 = rw;\n-\n-\t\t\t\t\t\t\t\t//  lw\t$a2, 0($s3)\n-\t\t\t\t\t\t\t\t//a0 = (x - 32) & 0xFFFF\n-\n-\t\t\t\t\t\t\t\t// srl\t$a2, 27\n-\t\t\t\t\t\t\t\tif (i == r->CursorPos)\n-\t\t\t\t\t\t\t\t{\n-\t\t\t\t\t\t\t\t\t//a2 = 1;\n-\n-\t\t\t\t\t\t\t\t}\n-\n-\t\t\t\t\t\t\t\t//loc_63AD0\n-\t\t\t\t\t\t\t\t//v0 = s1 << 1;\n-\t\t\t\t\t\t\t\t//v0 = &r->OptionTxt[i];\n-\t\t\t\t\t\t\t\t//v1 = &gfStringWad[gfStringOffset[r->OptionTxt[i]]];\n-\t\t\t\t\t\t\t\t//a3 = gfStringWad;\n-\t\t\t\t\t\t\t\t((long*) &OptionTop[4])[0] = 0x4000;\n-\n-\t\t\t\t\t\t\t\t//PrintString((x - 32) & 0xFFFF, y & 0xFFFF, a2, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], 0);\n-\t\t\t\t\t\t\t\t//PrintGauge((rw - 140) & 0xFFFF, (y - 7) & 0xFFFF, val);\n-\n-\t\t\t\t\t\t\t\t//jmp loc_63B88\n-\n+\t\t\t\t\t\t\t\tPrintString(0x100, y & 0xFFFF, 1, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], 0x8000);\n \t\t\t\t\t\t\t}\n \t\t\t\t\t\t\telse\n \t\t\t\t\t\t\t{\n-\t\t\t\t\t\t\t\t//loc_63B30\n-\t\t\t\t\t\t\t\t//lw\t$a2, 0($s3)\n-\t\t\t\t\t\t\t\t//srl\t$a2, 27\n-\t\t\t\t\t\t\t\tif (r->CursorPos = i)\n-\t\t\t\t\t\t\t\t{\n-\t\t\t\t\t\t\t\t//a2 = 1;\n-\t\t\t\t\t\t\t\t\t\n-\t\t\t\t\t\t\t\t}\n-\n-\t\t\t\t\t\t\t\t//loc_63B4C\n-\t\t\t\t\t\t\t\t//a0 = 256;\n-\t\t\t\t\t\t\t\t//v1 = \n-\t\t\t\t\t\t\t\t//((long*) &OptionTop[4])[0] = 0x8000;\n-\t\t\t\t\t\t\t\t//PrintString(256, y & 0xFFFF, a2, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], a4);\n+\t\t\t\t\t\t\t\tPrintString(0x100, y & 0xFFFF, r->OptionCol, &gfStringWad[gfStringOffset[r->OptionTxt[i]]], 0x8000);\n \t\t\t\t\t\t\t}\n \t\t\t\t\t\t}\n \t\t\t\t\t}\n-\n+\t\t\t\t}\n \t\t\t\t//loc_63B88\n-\n-\t\t\t\t\t//s0 = s2 & 0xFFFF\n-\t\t\t\t\tif (r->CursorPos == i && (r->Arrows >> i) & 1)\n+\t\t\t\tif (i == r->CursorPos)\n+\t\t\t\t{\n+\t\t\t\t\tif ((r->Arrows >> i) & 1)\n \t\t\t\t\t{\n-\t\t\t\t\t\t//a0 = (s5 - 4) & 0xFFFF;\n-\t\t\t\t\t\t//a1 = s0;\n-\t\t\t\t\t\t//a2 = 1;\n-\t\t\t\t\t\t//a3 = NoGamesReq[0]\n-\t\t\t\t\t\t//sw\t$zero, 0x70 + var_60($sp)//TODO\n-\t\t\t\t\t\t//PrintString();\n-\n-#if 0\n-\t\t\t\t\t\tli\t$a2, 1\n-\t\t\t\t\t\t\tla\t$a3, dword_A1F44//?\n-\t\t\t\t\t\t\tjal\tsub_8DB4C\n-\n-\t\t\t\t\t\t\tmove\t$a1, $s0\n-\t\t\t\t\t\t\tli\t$a2, 1\n-\t\t\t\t\t\t\tlui\t$a3, 0xA\n-\t\t\t\t\t\t\tlhu\t$a0, 0x70 + var_34($sp)\n-\t\t\t\t\t\t\tla\t$a3, dword_A1F48\n-\t\t\t\t\t\t\tsw\t$zero, 0x70 + var_60($sp)\n-\t\t\t\t\t\t\taddu\t$a0, $s5, $a0\n-\t\t\t\t\t\t\taddiu\t$a0, -8\n-\t\t\t\t\t\t\tjal\tsub_8DB4C\n-\t\t\t\t\t\t\tandi\t$a0, 0xFFFF\n-#endif\n-\n+\t\t\t\t\t\tPrintString((rx - 4) & 0xFFFF, y & 0xFFFF, 2, "\\x00000019", 0);\n+\t\t\t\t\t\tPrintString(((rx + rw) - 8) & 0xFFFF, y & 0xFFFF, 1, "\\x0000001B", 0);\n \t\t\t\t\t}//loc_63C04\n-\t\t\t\t\t\n-\t\t\t\t\t\n-\t\t\t\t\t\n-\t\t\n-\t\t\t\t\n-\t\t\t\t\t\n-\t\t\t\t\t\n-#if 0\n-\t\t\t\t\tloc_63C04:\n-\t\t\t\tlw\t$v0, 0($s3)\n-\t\t\t\t\tnop\n-\t\t\t\t\tsrl\t$v0, 21\n-\t\t\t\t\tandi\t$a3, $v0, 7\n-\t\t\t\t\taddiu\t$v1, $a3, -1\n-\t\t\t\t\tslt\t$v1, $s1, $v1\n-\t\t\t\t\tbeqz\t$v1, loc_63C48\n-\t\t\t\t\taddiu\t$a2, $s1, 1\n-\t\t\t\t\tsll\t$v0, $s1, 1\n-\t\t\t\t\taddu\t$a1, $sp, $v0\n-\t\t\t\t\tsll\t$v1, $a2, 1\n-\t\t\t\t\taddu\t$a0, $sp, $v1\n-\t\t\t\t\tlh\t$v0, 0x28($a1)\n-\t\t\t\t\tlh\t$v1, 0x18($a0)\n-\t\t\t\t\taddiu\t$a1, $s2, 2\n-\t\t\t\t\tsubu\t$v0, $v1\n-\t\t\t\t\taddu\t$s2, $a1, $v0\n-\n-\t\t\t\t\tloc_63C48 :\n-\t\t\t\tmove\t$s1, $a2\n-\t\t\t\t\tslt\t$v0, $s1, $a3\n-\t\t\t\t\tbnez\t$v0, loc_639D8\n-\t\t\t\t\tnop\n-#endif\n-\t}\n+\t\t\t\t}//loc_63C04\n+\n+\t\t\t\tif (i < (r->nOptions - 1))\n+\t\t\t\t{\n+\t\t\t\t\t//v0 = i << 1;\n+#if 0///@FIXME sp\n+\t\t\t\t\tsll     $v0, $s1, 1\n+\t\t\t\t\taddu    $a1, $sp, $v0\n+\t\t\t\t\tsll     $v1, $a2, 1\n+\t\t\t\t\taddu    $a0, $sp, $v1\n+\t\t\t\t\tlh      $v0, 0x28($a1)\n+\t\t\t\t\tlh      $v1, 0x18($a0)\n+\t\t\t\t\taddiu   $a1, $s2, 2\n+\t\t\t\t\tsubu    $v0, $v1\n+\t\t\t\t\taddu    $s2, $a1, $v0\n #endif\n-\t}\n-\t\n-\t//loc_63C58\n-#if 0\n+\t\t\t\t}//loc_63C48\n+\t\t\t}\n+\t\t}//loc_63C58\n+\t}//loc_63C58\n \n-\t//li\t$s2, 0x404040\n-\t((long*) &OptionTop[4])[0] = 0;//sw\t$zero, 0x70 + var_60($sp) check\n-\t((long*) &OptionTop[2])[0] = 0x2A800000;//sw\t$v0, 0x70 + var_5C($sp) check\n-\tDrawF4(rx, ry, rw, rh);\n+\tDrawF4(rx, ry, rw, rh, 0, 0x2A800000);\n+\tDrawTPage(0, 1);\n+\tDrawLineH((rx + 2) & 0xFFFF, (ry + 1) & 0xFFFF, (rw - 4) & 0xFFFF, 0, 0x404040, 0);\n+\tDrawLineH((rx + 2) & 0xFFFF, ((ry - rh) - 2) & 0xFFFF, (rw - 4) & 0xFFFF, 0, 0x404040, 0);\n+\tDrawLineV((rx + 2) & 0xFFFF, (ry + 1) & 0xFFFF, (rh - 2) & 0xFFFF, 0, 0x404040, 0);\n+\tDrawLineV(((rx - rw) - 3) & 0xFFFF, (ry + 1) & 0xFFFF, (rh - 2) & 0xFFFF, 0, 0x404040, 0);\n \tDrawTPage(0, 1);\n \n-\t//a0 = (rx + 2) & 0xFFFF;\n-\t//a1 = (ry + 1) & 0xFFFF;\n-\t\n-\t//a2 = (rw - 4) & 0xFFFF;\n-\t\ta3 = 0;\n-\t\t((long*) &OptionTop[4])[0] = 0x404040;\n-\t\t((long*) &OptionTop[2])[0] = 0//sw\t$zero, 0x70 + var_5C($sp)\n-\n-\t\tDrawLineH((rx + 2) & 0xFFFF, (ry + 1) & 0xFFFF, (rw - 4) & 0xFFFF, 0);\n-\n-\n-\t\t//\n-\t\t//s0 = (rx + 2) & 0xFFFF\n-\n-\t\t//a0 = s0;\n-\n-\t\t//a1 = rh;\n-\t\t//a2 = rw;\n-\t\t//a3 = 0;\n-\n-\t\t((long*) &OptionTop[4])[0] = 0x404040;//sw\t$s2, 0x70 + var_60($sp)\n-\t\t((long*) &OptionTop[2])[0] = 0x0;//sw\t$zero, 0x70 + var_5C($sp)\n-\t\tDrawLineH((rx + 2) & 0xFFFF, ((ry + rh) - 2) & 0xFFFF, (rw - 4) & 0xFFFF, 0);\n-\n-\t\t((long*) &OptionTop[4])[0] = 0x404040;//sw\t$s2, 0x70 + var_60($sp)\n-\t\t((long*) &OptionTop[2])[0] = 0x0;//sw\t$zero, 0x70 + var_5C($sp)\n-\t\tDrawLineV((rx + 2) & 0xFFFF, (ry + 1) & 0xFFFF, (rh - 2) & 0xFFFF, 0);\n-\n-\t\t((long*) &OptionTop[4])[0] = 0x404040;//sw\t$s2, 0x70 + var_60($sp)\n-\t\t((long*) &OptionTop[2])[0] = 0x0;//sw\t$zero, 0x70 + var_5C($sp)\n-\n-\t\tDrawLineV(((rx + rw) - 3) & 0xFFFF, (ry + 1) & 0xFFFF, (rh - 2) & 0xFFFF, 0);\n-\t\tDrawTPage(0, 1);\n-\n+\tif ((r->nOptions != 0))\n+\t{\n+\t\tif ((dbinput2 & 1) && r->CursorPos != 0 && !(r->Ignore >> (r->nOptions - 1) & 1))\n+\t\t{\n \n-\t\tif (r->Options == 0)\n+\t\t\tSoundEffect(0x6D, NULL, 2);\n+\t\t\tr->OptionCol &= 0x18;\n+\t\t\t//loc_63E38\n+\t\t\tr->CursorPos--;\n+\t\t}\n+\t\telse if ((dbinput2 & 2) && r->CursorPos < (r->nOptions - 1)) //loc_63DDC\n \t\t{\n-\t\t\t//loc_63ED4\n-\t\t\treturn 0;\n+\t\t\tSoundEffect(0x6D, NULL, 2);\n+\t\t\tr->OptionCol &= 0x18;\n+\t\t\t//loc_63E38\n+\t\t\tr->CursorPos++;\n \t\t}\n \n-\t\t//a1 = dbinput2;\n-\t\tif (dbinput2 & 1)\n+\t\t//loc_63E4C\n+\t\tif ((RawEdge & 0x4000))\n \t\t{\n-\t\t\t//srl\t$v0, $a0, 24\n-\t\t\tif (((long*) &r)[0] & 0x7000000)\n+\t\t\tif (r->CursorPos < 2)\n \t\t\t{\n-\n-\n-\t\t\t}//loc_63DDC\n-\n-\t\t}//loc_63DDC\n-\n-\n-\t\t\t\t lw\t$v1, 4($s3)\n-\t\t\t\t andi\t$v0, 7\n-\t\t\t\t addiu\t$v0, -1\n-\t\t\t\t srl\t$v1, 15\n-\t\t\t\t andi\t$v1, 0x1F\n-\t\t\t\t srav\t$v1, $v0\n-\t\t\t\t andi\t$v1, 1\n-\t\t\t\t bnez\t$v1, loc_63DDC\n-\t\t\t\t li\t$a0, 0x6D\n-\t\t\t\t move\t$a1, $zero\n-\t\t\t\t jal\tsub_91780\n-\t\t\t\t li\t$a2, 2\n-\t\t\t\t lui\t$v1, 0xF8FF\n-\t\t\t\t lw\t$v0, 0($s3)\n-\t\t\t\t li\t$v1, 0xF8FFFFFF\n-\t\t\t\t and $v1, $v0, $v1\n-\t\t\t\t srl\t$v0, 24\n-\t\t\t\t andi\t$v0, 7\n-\t\t\t\t j\tloc_63E38\n-\t\t\t\t addiu\t$v0, -1\n-\n-\t\t\t\t loc_63DDC:\n-\t\t\t andi\t$v0, $a1, 2\n-\t\t\t\t beqz\t$v0, loc_63E4C\n-\t\t\t\t nop\n-\t\t\t\t lw\t$v0, 0($s3)\n-\t\t\t\t nop\n-\t\t\t\t srl\t$v1, $v0, 24\n-\t\t\t\t andi\t$v1, 7\n-\t\t\t\t srl\t$v0, 21\n-\t\t\t\t andi\t$v0, 7\n-\t\t\t\t addiu\t$v0, -1\n-\t\t\t\t slt\t$v1, $v0\n-\t\t\t\t beqz\t$v1, loc_63E4C\n-\t\t\t\t li\t$a0, 0x6D\n-\t\t\t\t move\t$a1, $zero\n-\t\t\t\t jal\tsub_91780\n-\t\t\t\t li\t$a2, 2\n-\t\t\t\t lui\t$v1, 0xF8FF\n-\t\t\t\t lw\t$v0, 0($s3)\n-\t\t\t\t li\t$v1, 0xF8FFFFFF\n-\t\t\t\t and $v1, $v0, $v1\n-\t\t\t\t srl\t$v0, 24\n-\t\t\t\t andi\t$v0, 7\n-\t\t\t\t addiu\t$v0, 1\n-\n-\t\t\t\t loc_63E38:\n-\t\t\t andi\t$v0, 7\n-\t\t\t\t sll\t$v0, 24\n-\t\t\t\t or $v1, $v0\n-\t\t\t\t j\tloc_63ED0\n-\t\t\t\t sw\t$v1, 0($s3)\n-\n-\t\t\t\t loc_63E4C :\n-\t\t\t\t lw\t$v0, dword_800A4520\n-\t\t\t\t nop\n-\t\t\t\t andi\t$v0, 0x4000\n-\t\t\t\t beqz\t$v0, loc_63ED4\n-\t\t\t\t move\t$v0, $zero\n-\t\t\t\t lw\t$v1, 0($s3)\n-\t\t\t\t nop\n-\t\t\t\t srl\t$v0, $v1, 24\n-\t\t\t\t andi\t$v0, 7\n-\t\t\t\t sltiu\t$v0, 2\n-\t\t\t\t beqz\t$v0, loc_63E90\n-\t\t\t\t lui\t$v0, 0x700\n-\t\t\t\t la\t$v0, dword_A1990\n-\t\t\t\t beq\t$s3, $v0, loc_63ED0\n-\t\t\t\t lui\t$v0, 0x700\n-\n-\t\t\t\t loc_63E90:\n-\t\t\t and\t$v0, $v1, $v0\n-\t\t\t\t lui\t$v1, 0x100\n-\t\t\t\t bne\t$v0, $v1, loc_63EB0\n-\t\t\t\t li\t$a0, 0x6F\n-\t\t\t\t la\t$v0, dword_A19A4\n-\t\t\t\t beq\t$s3, $v0, loc_63ED0\n-\t\t\t\t nop\n-\n-\t\t\t\t loc_63EB0 :\n-\t\t\t move\t$a1, $zero\n-\t\t\t\t jal\tsub_91780\n-\t\t\t\t li\t$a2, 2\n-\t\t\t\t lbu\t$v0, 3($s3)\n-\t\t\t\t nop\n-\t\t\t\t andi\t$v0, 7\n-\t\t\t\t j\tloc_63ED4\n-\t\t\t\t ori\t$v0, 0x8000\n-\n-\t\t\t\t loc_63ED0:\n-\t\t\t move\t$v0, $zero\n-\n-\t\t\t\t loc_63ED4 :\n-\t\t\t lw\t$ra, 0x70 + var_4($sp)\n-\t\t\t\t lw\t$fp, 0x70 + var_8($sp)\n-\t\t\t\t lw\t$s7, 0x70 + var_C($sp)\n-\t\t\t\t lw\t$s6, 0x70 + var_10($sp)\n-\t\t\t\t lw\t$s5, 0x70 + var_14($sp)\n-\t\t\t\t lw\t$s4, 0x70 + var_18($sp)\n-\t\t\t\t lw\t$s3, 0x70 + var_1C($sp)\n-\t\t\t\t lw\t$s2, 0x70 + var_20($sp)\n-\t\t\t\t lw\t$s1, 0x70 + var_24($sp)\n-\t\t\t\t lw\t$s0, 0x70 + var_28($sp)\n-\t\t\t\t jr\t$ra\n-\t\t\t\t addiu\t$sp, 0x70\n-\t\t\t\t # End of function sub_63718\n-#endif\n-#endif\n+\t\t\t\tif (r == &SettingsReq)\n+\t\t\t\t{\n+\t\t\t\t\treturn 0x7000000;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\telse if (r->CursorPos == 0x1000000)//loc_63E90\n+\t\t\t{\n+\t\t\t\tif (r == &ConfigReq)\n+\t\t\t\t{\n+\t\t\t\t\treturn 0;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\telse\n+\t\t\t{\n+\t\t\t\t//loc_63EB0\n+\t\t\t\tSoundEffect(0x6F, NULL, 2);\n+\t\t\t\treturn r->CursorPos | 0x80000000;\n+\t\t\t}\n+\t\t}\n+\t\t//loc_63ED4\n+\t}\n+\t//loc_63ED4\n \treturn 0;\n }\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/ROOMLETB.MIP b/SPEC_PSX/ROOMLETB.MIP\nindex a17984d5..95aeef2e 100644\n--- a/SPEC_PSX/ROOMLETB.MIP\n+++ b/SPEC_PSX/ROOMLETB.MIP\n@@ -1,12 +1,14 @@\n-\topt L.,C+,at+\n+\topt at-,w-,c+,m-\n \n-\tsection\t.ASM\n-\txdef UnpackRGB, DrawRoomletListAsm, DrawRoomletListAsmBinocular, DrawMesh, ClipXY, InitPrim, SubPolyGT3, SubPolyGT4, SubPolyGTLoop, Add2DPrim, CreateNewVertex, ClipToScreen, SubdivSetup3\n-\txref number_draw_rooms, RoomBBoxes, wibble, tsv_buffer, draw_rooms, room, WaterTable, dynamics, db, OurSqrt, RoomTextInfo\n+\tSECTION\tASM\n+\tINCLUDE\tSPEC_PSX/GLOBAL.INC\n+\tXDEF UnpackRGB, DrawRoomletListAsm, DrawRoomletListAsmBinocular, DrawMesh, ClipXY, InitPrim, SubPolyGT3, SubPolyGT4, SubPolyGTLoop, Add2DPrim, CreateNewVertex, ClipToScreen, SubdivSetup3\n+\tXREF MatrixStack, number_draw_rooms, RoomBBoxes, wibble, tsv_buffer, draw_rooms, room, WaterTable, dynamics, db, OurSqrt, RoomTextInfo\n \t\n ;FIXME\n-LOffset equ 0\n-YOffset equ 0\n+LOffset incbin SPEC_PSX//LOFFSET.TBL\n+LTab incbin SPEC_PSX//LTAB.TBL\n+YOffset equ 0 ;FIXME not sure how to extract\n QuadVertTables equ 0\n TriVertTables equ 0\n \t\n@@ -645,24 +647,23 @@ ClipXY:\n \tjr      ra\n \tli      t5, 1\n \n-;needs loffset\n DrawMesh:\n \taddi    sp, -0x38\n-\tsw      s0, 0x38+0x38(sp)\n-\tsw      s1, 0x38+0x34(sp)\n-\tsw      s2, 0x38+0x30(sp)\n-\tsw      s3, 0x38+0x2C(sp)\n-\tsw      s4, 0x38+0x28(sp)\n-\tsw      s5, 0x38+0x24(sp)\n-\tsw      s6, 0x38+0x20(sp)\n-\tsw      s7, 0x38+0x1C(sp)\n-\tsw      ra, 0x38+0x18(sp)\n-\tsw      fp, 0x38+0x14(sp)\n-\tsw      gp, 0x38+0x10(sp)\n+\tsw      s0, 0x38-0x38(sp)\n+\tsw      s1, 0x38-0x34(sp)\n+\tsw      s2, 0x38-0x30(sp)\n+\tsw      s3, 0x38-0x2C(sp)\n+\tsw      s4, 0x38-0x28(sp)\n+\tsw      s5, 0x38-0x24(sp)\n+\tsw      s6, 0x38-0x20(sp)\n+\tsw      s7, 0x38-0x1C(sp)\n+\tsw      ra, 0x38-0x18(sp)\n+\tsw      fp, 0x38-0x14(sp)\n+\tsw      gp, 0x38-0x10(sp)\n \tlui     a2, 0x1F80\n \tla      s0, LOffset\n \taddi    s1, s0, 0x40\n-\tla\t\ts5, OurSqrt\n+\tla      s5, OurSqrt ;addiu   s5, gp, OurSqrt-GP_ADDR\n \taddi    fp, s0, 0x4240\n \tlw      s2, 0x38+0x2C(sp)\n \tlw      s3, 0x38+0x30(sp)\n@@ -718,7 +719,7 @@ DrawMesh:\n \n \tloc_75E8C:\n \tbeqz    t9, loc_75E98\n-\tsw      t6, 0x38+0x38(fp)\n+\tsw      t6, 0x38-0x38(fp)\n \tadd     t1, t6\n \n \tloc_75E98:\n@@ -859,7 +860,7 @@ DrawMesh:\n \taddi    a2, 8\n \tcfc2    a1, r18\n \tcfc2    v0, r27\n-\tlw      a2, RoomTextInfo\n+\tlw      a2, RoomTextInfo-GP_ADDR(gp)\n \tlw      a3, 8(a1)\n \tlw      s0, 4(a1)\n \tlui     s1, 0x1F80\n@@ -1101,7 +1102,7 @@ DrawMesh:\n \tsh      t5, 0x330(s1)\n \taddi    t1, s1, 0x338\n \tjal     SubPolyGT4\n-\taddiu   t0, ra, -0x199C;//really now?\n+\taddiu   t0, ra, -0x199C\n \tcfc2    t0, r19\n \tcfc2    at, r23\n \tcfc2    t9, r27\n@@ -1127,18 +1128,18 @@ DrawMesh:\n \tj       loc_761EC\n \tnop\n \n-\tloc_76420:;Unstack\n-\tlw      s0, 0x38+0x38(sp)\n-\tlw      s1, 0x38+0x34(sp)\n-\tlw      s2, 0x38+0x30(sp)\n-\tlw      s3, 0x38+0x2C(sp)\n-\tlw      s4, 0x38+0x28(sp)\n-\tlw      s5, 0x38+0x24(sp)\n-\tlw      s6, 0x38+0x20(sp)\n-\tlw      ra, 0x38+0x18(sp)\n-\tlw      s7, 0x38+0x1C(sp)\n-\tlw      fp, 0x38+0x14(sp)\n-\tlw      gp, 0x38+0x10(sp)\n+\tloc_76420:\n+\tlw      s0, 0x38-0x38(sp)\n+\tlw      s1, 0x38-0x34(sp)\n+\tlw      s2, 0x38-0x30(sp)\n+\tlw      s3, 0x38-0x2C(sp)\n+\tlw      s4, 0x38-0x28(sp)\n+\tlw      s5, 0x38-0x24(sp)\n+\tlw      s6, 0x38-0x20(sp)\n+\tlw      ra, 0x38-0x18(sp)\n+\tlw      s7, 0x38-0x1C(sp)\n+\tlw      fp, 0x38-0x14(sp)\n+\tlw      gp, 0x38-0x10(sp)\n \tjr      ra\n \taddi    sp, 0x38\n \t\t\n@@ -1157,10 +1158,10 @@ DrawRoomletListAsmBinocular:\n \tsw      gp, 0x38-0x10(sp)\n \tctc2    a0, r21\n \tmtc2    a1, r20\n-\tlw      s0, number_draw_rooms\n-\tlw      s3, RoomBBoxes\n+\tlw      s0, number_draw_rooms-GP_ADDR(gp)\n+\tlw      s3, RoomBBoxes-GP_ADDR(gp)\n \tla   \ts4, draw_rooms\n-\tlw      t2, wibble\n+\tlw      t2, wibble-GP_ADDR(gp)\n \tla      s2, tsv_buffer\n \tandi    t2, 0xFC\n \tctc2    t2, r20\n@@ -1170,7 +1171,7 @@ DrawRoomletListAsmBinocular:\n \taddi    s4, 2\n \tsll     t0, 4\n \tsll     at, t0, 2\n-\tlw      t1, room\n+\tlw      t1, room-GP_ADDR(gp)\n \tadd     t0, at\n \tadd     fp, t0, t1\n \tlbu     t0, 0x38+0x2(fp)\n@@ -1179,11 +1180,11 @@ DrawRoomletListAsmBinocular:\n \tadd     t1, t0\n \tsw      fp, 0(s2)\n \tsw      t1, 4(s2)\n-\tlw      s1, 0x38+0x38(fp)\n-\tlw      t0, 0x38+0x24(fp)\n-\tlw      t1, 0x38+0x20(fp)\n+\tlw      s1, 0x38-0x38(fp)\n+\tlw      t0, 0x38-0x24(fp)\n+\tlw      t1, 0x38-0x20(fp)\n \tmfc2    s5, r20\n-\tlw      t2, 0x38+0x1C(fp)\n+\tlw      t2, 0x38-0x1C(fp)\n \tlw      t3, 0x14(s5)\n \tlw      t4, 0x18(s5)\n \tlw      t5, 0x1C(s5)\n@@ -1202,9 +1203,9 @@ DrawRoomletListAsmBinocular:\n \tbnez    at, loc_74DF8\n \tslti    at, t8, 0x7C00\n \tbeqz    at, loc_74DF8\n-\tlw      t7, 0x38+0x18(fp)\n-\tlh      t6, 0x38+0x10(fp)\n-\tlh      t8, 0x38+0x10+2(fp)\n+\tlw      t7, 0x38-0x18(fp)\n+\tlh      t6, 0x38-0x10(fp)\n+\tlh      t8, 0x38-0x10+2(fp)\n \taddi    t6, -2\n \taddi    t8, -2\n \tsll     t6, 10\n@@ -1267,9 +1268,9 @@ DrawRoomletListAsmBinocular:\n \tsw      t6, 0x14(s2)\n \tsw      t7, 0x18(s2)\n \tsw      t8, 0x1C(s2)\n-\tlw      t3, 0x46D8(gp)\n-\tlw      t4, 0x46DC(gp)\n-\tlw      t5, 0x46E0(gp)\n+;\tlw      t3, MatrixStack+0x14-GP_ADDR(gp)\n+;\tlw      t4, MatrixStack+0x18-GP_ADDR(gp)\n+;\tlw      t5, MatrixStack+0x1C-GP_ADDR(gp)\n \tsub     t0, t3\n \tsub     t1, t4\n \tsub     t2, t5\n@@ -1497,7 +1498,7 @@ DrawRoomletListAsmBinocular:\n \tsw      zero, 0(s2)\n \tla      s2, tsv_buffer\n \n-\tloc_75124:\n+\tRoomLoop:\n \tlw      a1, 0(s2)\n \tlwc2    r20, 4(s2)\n \tbeqz    a1, loc_76420\n@@ -1511,8 +1512,8 @@ DrawRoomletListAsmBinocular:\n \tlw      t0, 0x14(a1)\n \tlw      t1, 0x18(a1)\n \tlw      t2, 0x1C(a1)\n-\tsw      t0, 0x38+0xC(sp)\n-\tsw      t1, 0x38+0x8(sp)\n+\tsw      t0, 0x38-0xC(sp)\n+\tsw      t1, 0x38-0x8(sp)\n \tsw      t2, 0x34(sp)\n \tlw      t0, 0x38(a1)\n \tlw      t2, 0x3C(a1)\n@@ -1538,7 +1539,7 @@ DrawRoomletListAsmBinocular:\n \tloc_751B4:\n \tlw      a0, 0(s2)\n \taddi    s2, 4\n-\tbeqz    a0, loc_75124\n+\tbeqz    a0, RoomLoop\n \tlw      t5, 0(a0)\n \tmove    t6, zero\n \tsll     t0, t5, 3\n@@ -1555,8 +1556,8 @@ DrawRoomletListAsmBinocular:\n \tandi    t0, 0xFFFF\n \tsrl     t4, t3, 16\n \tandi    t3, 0xFFFF\n-\tlw      t7, 0x38+0xC(sp)\n-\tlw      t8, 0x38+0x8(sp)\n+\tlw      t7, 0x38-0xC(sp)\n+\tlw      t8, 0x38-0x8(sp)\n \tlw      t9, 0x34(sp)\n \tadd     t0, t7\n \tadd     t1, t8\n@@ -1726,7 +1727,7 @@ DrawRoomletListAsmBinocular:\n \taddi    t8, 0x18\n \n \tloc_75448:\n-\taddiu   s1, gp, 0x25B8\n+\tla   s1, dynamics;originally addiu\n \tlui     a1, 0x1F80\n \taddi    a1, 0x300\n \tli      v1, 0xF\n@@ -1769,37 +1770,6 @@ DrawRoomletListAsmBinocular:\n \tla   \ta1, db\n \tj       loc_751B4\n \tsw      a3, 8(a1)\n-\tlui     s2, 0xF8\n-\tsrl     t5, s4, 7\n-\tand     t5, s2\n-\tsrl     t6, s4, 10\n-\tandi    t6, 0xF800\n-\tsrl     fp, s4, 13\n-\tandi    fp, 0xF8\n-\tor      fp, t5\n-\tor      fp, t6\n-\tsrl     t5, t8, 24\n-\tori     t5, 0x40\n-\tsll     t5, 24\n-\tor      fp, t5\n-\tsrl     t5, s5, 7\n-\tand     t5, s2\n-\tsrl     t6, s5, 10\n-\tandi    t6, 0xF800\n-\tsrl     gp, s5, 13\n-\tandi    gp, 0xF8\n-\tor      gp, t5\n-\tor      gp, t6\n-\tsrl     t5, s6, 7\n-\tand     t5, s2\n-\tsrl     t6, s6, 10\n-\tandi    t6, 0xF800\n-\tsrl     s3, s6, 13\n-\tandi    s3, 0xF8\n-\tor      s3, t5\n-\tjr      ra\n-\tor      s3, t6\n-\n \n ;74B28\n GetBounds:\ndiff --git a/SPEC_PSX/ROOMLOAD.C b/SPEC_PSX/ROOMLOAD.C\nindex eaedf640..a30a9cc8 100644\n--- a/SPEC_PSX/ROOMLOAD.C\n+++ b/SPEC_PSX/ROOMLOAD.C\n@@ -8,7 +8,10 @@\n #include "SETUP.H"\n \n #include <stdio.h>\n-#include <LIBSN.H>\n+\n+#if !DISC_VERSION\n+\t#include <LIBSN.H>\n+#endif\n \n long AnimFilePos;\n long AnimFileLen;\n@@ -98,7 +101,7 @@ void S_LoadLevelFile(int Name)//60188(<), 60D54(<) (F)\n \t#if RELOC\n \t\t((VOIDFUNCINT*)SetupPtr[5])(PCopen(&buf[0], 0, 0));\n \t#else\n-\t\tRelocateLevel(PCopen(buf, 0, 0))\n+\tRelocateLevel(PCopen(buf, 0, 0));\n \t#endif\n #endif\n \ndiff --git a/SPEC_PSX/SETUP.C b/SPEC_PSX/SETUP.C\nindex d968a311..2b7f8666 100644\n--- a/SPEC_PSX/SETUP.C\n+++ b/SPEC_PSX/SETUP.C\n@@ -44,7 +44,9 @@\n #include <stddef.h>\n #include <stdio.h>\n #include <string.h>\n+#if !DISC_VERSION\n #include <LIBSN.H>\n+#endif\n #include <LIBSPU.H>\n #include <LIBGTE.H>\n \ndiff --git a/SPEC_PSX/SFX.MIP b/SPEC_PSX/SFX.MIP\nindex dc9baf49..8ca87301 100644\n--- a/SPEC_PSX/SFX.MIP\n+++ b/SPEC_PSX/SFX.MIP\n@@ -1,10 +1,520 @@\n-\t;opt at-,w-,c+,m-\n+\topt at+,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF S_SetReverbType, SPU_StopAll, SPU_FreeChannel, S_SoundStopAllSamples, S_SoundSetPanAndVolume, S_SoundSetPitch, S_SoundStopSample, S_SoundSampleIsPlaying, GetPanVolume, SPU_UpdateStatus\n-\tXREF LabSampleType, LabFreeChannel, LnFreeChannels, DepthTable, camera, char_anim, local_mRotY, sample_infos, phd_sqrt_asm, phd_atan_asm, rcossin_tbl, GtSFXEnabled, SpuSetReverbModeDepth, SpuGetAllKeysStatus, SpuSetReverb, SpuGetKeyStatus, SpuSetVoicePitch, SpuSetVoiceVolume, CalcVolumes_ASM, SpuSetKey, CurrentReverb, SpuSetKey\n+\tXDEF SPU_AllocChannel, S_SoundPlaySampleLooped, SoundEffect, S_SetReverbType, SPU_StopAll, SPU_FreeChannel, S_SoundStopAllSamples, S_SoundSetPanAndVolume, S_SoundSetPitch, S_SoundStopSample, S_SoundSampleIsPlaying, GetPanVolume, SPU_UpdateStatus\n+\tXREF sva, LnSamplesLoaded, LadwSampleAddr, SpuSetKeyOnWithAttr, CalcVolumes_ASM, CamRot, LaSlot, mSqrt, GetRandomDraw, sample_lut, room, camera, sound_active, LabSampleType, LabFreeChannel, LnFreeChannels, DepthTable, camera, char_anim, local_mRotY, sample_infos, phd_sqrt_asm, phd_atan_asm, rcossin_tbl, GtSFXEnabled, SpuSetReverbModeDepth, SpuGetAllKeysStatus, SpuSetReverb, SpuGetKeyStatus, SpuSetVoicePitch, SpuSetVoiceVolume, CalcVolumes_ASM, SpuSetKey, CurrentReverb, SpuSetKey\n \n+\t\n+SPU_AllocChannel:\n+\tlw      v0, LnFreeChannels-GP_ADDR(gp)\n+\taddiu   sp, -0x18\n+\tbnez    v0, loc_915DC\n+\tnop\n+\tsw      ra, 0x18-0x8(sp)\n+\tjal     SPU_UpdateStatus\n+\tnop\n+\tlw      ra, 0x18-0x8(sp)\n+\tbeqz    v0, locret_915F4\n+\tli      v0, 0xFFFFFFFF\n+\tlw      v0, LnFreeChannels-GP_ADDR(gp)\n+\n+\tloc_915DC:\n+\tla      v1, LabFreeChannel\n+\taddiu   v0, -1\n+\tsw      v0, LnFreeChannels-GP_ADDR(gp)\n+\taddu    v1, v0\n+\tlbu     v0, 0(v1)\n+\n+\tlocret_915F4:\n+\tjr      ra\n+\taddiu   sp, 0x18\n+\t\n+S_SoundPlaySample:\n+\tlw      v0, GtSFXEnabled-GP_ADDR(gp)\n+\tmove    t1, a0\n+\tbeqz    v0, nosnd\n+\tmove    t2, a2\n+\tlw      a0, 0x10(sp)\n+\tli      v0, 1\n+\tj       loc_914C8\n+\tsw      v0, 0x10(sp)\n+\n+\tloc_914C8:\n+\tmove    t3, ra\n+\tjal     CalcVolumes_ASM\n+\tnop\n+\tmove    ra, t3\n+\tmove    a0, t1\n+\tj       loc_91518\n+\tmove    a3, t2\n+\t\n+loc_91518:\n+\tsh      a1, 0x4EE0(gp)\n+\tsh      a2, 0x4EE2(gp)\n+\tsrl     a3, 6\n+\tsh      a3, 0x4EEC(gp)\n+\tsll     v1, a0, 2\n+\tla\t\tat, LadwSampleAddr\n+\taddu\tat, at, v1\n+\tlw      v1, 0(at)\n+\tlw      v0, LnSamplesLoaded-GP_ADDR(gp)\n+\taddiu   sp, -0x18\n+\tslt     v0, a0, v0\n+\tsw      v1, 0x4EF4(gp)\n+\tsw      ra, 0x18-0x4(sp)\n+\tsw      s0, 0x18-0x8(sp)\n+\tbeqz    v0, loc_915A0\n+\tli      v0, 0xFFFFFFFE\n+\tjal     SPU_AllocChannel\n+\tnop\n+\tmove    s0, v0\n+\tbltz    s0, loc_915A0\n+\tli      v0, 0xFFFFFFFF\n+\tlw      v0, 0x18+0x10(sp)\n+\tla      a0, sva\n+\tla\t\tat, LabSampleType\n+\taddu\tat, at, s0\n+\tsb      v0, 0(at)\n+\tli      v0, 0x93\n+\tsw      v0, 4(a0)\n+\tli      v0, 1\n+\tsllv    v0, s0\n+\tjal     SpuSetKeyOnWithAttr\n+\tsw      v0, 0(a0)\n+\tmove    v0, s0\n+\n+\tloc_915A0:\n+\tlw      ra, 0x18-0x4(sp)\n+\tlw      s0, 0x18-0x8(sp)\n+\tjr      ra\n+\taddiu   sp, 0x18\n+\t\n+S_SoundPlaySampleLooped:\n+\tlw      v0, GtSFXEnabled-GP_ADDR(gp)\n+\tmove    t1, a0\n+\tbeqz    v0, nosnd\n+\tmove    t2, a2\n+\tlw      a0, 0x10(sp)\n+\tli      v0, 2\n+\tj       loc_914C8\n+\tsw      v0, 0x10(sp)\n+\n+\tnosnd:\n+\tjr      ra\n+\tli      v0, 0xFFFFFFFD\n+\t\t\n+SoundEffect:\n+\tlw      v0, sound_active-GP_ADDR(gp)\n+\taddiu   sp, -0x40\n+\tbeqz    v0, locret_91CEC\n+\tandi    at, a2, 2\n+\tsw      s0, 0x40-0x28(sp)\n+\tsw      s1, 0x40-0x24(sp)\n+\tsw      s2, 0x40-0x20(sp)\n+\tsw      s3, 0x40-0x1C(sp)\n+\tsw      s4, 0x40-0x18(sp)\n+\tsw      s5, 0x40-0x14(sp)\n+\tsw      s6, 0x40-0x10(sp)\n+\tsw      s7, 0x40-0xC(sp)\n+\tsw      fp, 0x40-0x8(sp)\n+\tsw      ra, 0x40-0x4(sp)\n+\tmove    s4, a2\n+\tbnez    at, loc_917F0\n+\tmove    s7, a1\n+\tlh      v1, camera+0xC-GP_ADDR(gp)\n+\tlw      at, room-GP_ADDR(gp)\n+\tsll     v0, v1, 2\n+\taddu    v0, v1\n+\tsll     v0, 4\n+\taddu    v0, at\n+\tlhu     v0, 0x4E(v0)\n+\tandi    v1, s4, 1\n+\tandi    v0, 1\n+\tbne     v1, v0, loc_91CC4\n+\tmove    v0, zero\n+\n+\tloc_917F0:\n+\tlw      v0, sample_lut-GP_ADDR(gp)\n+\tsll     v1, a0, 1\n+\taddu    v1, v0\n+\tlh      fp, 0(v1)\n+\tli      v0, 0xFFFFFFFF\n+\tbne     fp, v0, loc_91818\n+\tli      v0, 0xFFFFFFFE\n+\tsh      v0, 0(v1)\n+\n+\tloc_91810:\n+\tj       loc_91CC4\n+\tmove    v0, zero\n+\n+\tloc_91818:\n+\tbeq     fp, v0, loc_91CC4\n+\tmove    v0, zero\n+\tlw      s5, sample_infos-GP_ADDR(gp)\n+\tsll     v1, fp, 3\n+\taddu    s5, v1\n+\tlbu     t1, 4(s5)\n+\tlbu     t0, 3(s5)\n+\tbeqz    t1, loc_91854\n+\tlhu     t2, 6(s5)\n+\tjal     GetRandomDraw\n+\tnop\n+\tandi    v0, 0xFF\n+\tslt     at, t1, v0\n+\tbnez    at, loc_91CC4\n+\tmove    v0, zero\n+\n+\tloc_91854:\n+\tsll     t0, 10\n+\taddiu   t0, 0x400\n+\tmult    t0, t0\n+\tmflo    a2\n+\tbeqz    s7, loc_91950\n+\tli      s1, 0\n+\tlw      v1, 0(s7)\n+\tlw      v0, camera+0x0-GP_ADDR(gp)\n+\tlw      a1, 4(s7)\n+\tlw      a0, 8(s7)\n+\tsubu    t8, v1, v0\n+\tlw      v1, camera+0x4-GP_ADDR(gp)\n+\tlw      v0, camera+0x8-GP_ADDR(gp)\n+\tsubu    a1, v1\n+\tsubu    t9, a0, v0\n+\tnegu    v1, t0\n+\tslt     at, t8, v1\n+\tbnez    at, loc_91CC4\n+\tmove    v0, zero\n+\tslt     at, t0, t8\n+\tbnez    at, loc_91CC4\n+\tslt     at, a1, v1\n+\tbnez    at, loc_91CC4\n+\tslt     at, t0, a1\n+\tbnez    at, loc_91CC4\n+\tslt     at, t9, v1\n+\tbnez    at, loc_91CC4\n+\tslt     at, t0, t9\n+\tbnez    at, loc_91CC4\n+\tnop\n+\tmtc2    t8, r9\n+\tmtc2    a1, r10\n+\tmtc2    t9, r11\n+\tnop\n+\tnop\n+\tcop2    0xA00428\n+\tmfc2    v0, r25\n+\tmfc2    v1, r26\n+\tmfc2    s3, r27\n+\taddu    v0, v1\n+\taddu    s3, v0\n+\tsltu    v0, a2, s3\n+\tbnez    v0, loc_91CC4\n+\tmove    v0, zero\n+\tli      v0, 0xFFFFF\n+\tsltu    v0, v0, s3\n+\tbnez    v0, loc_9191C\n+\tnop\n+\tj       loc_91928\n+\tmove    s3, zero\n+\n+\tloc_9191C:\n+\tjal     mSqrt\n+\tmove    a0, s3\n+\taddiu   s3, v0, -0x400\n+\n+\tloc_91928:\n+\tandi    v0, t2, 0x1000\n+\tbnez    v0, loc_91954\n+\tmove    a0, t9\n+\tjal     phd_atan_asm\n+\tmove    a1, t8\n+\tlhu     v1, CamRot+0x2-GP_ADDR(gp)\n+\tnop\n+\tsll     v1, 4\n+\tj       loc_91954\n+\taddu    s1, v0, v1\n+\n+\tloc_91950:\n+\tmove    s3, zero\n+\n+\tloc_91954:\n+\tlbu     v1, 2(s5)\n+\tandi    at, s4, 8\n+\tbeqz    at, loc_91974\n+\tsrl     at, s4, 8\n+\tandi    at, 0x1F\n+\tmult    at, v1\n+\tmflo    v1\n+\tsrl     v1, 5\n+\n+\tloc_91974:\n+\tandi    v0, t2, 0x4000\n+\tbeqz    v0, loc_91994\n+\tsll     s2, v1, 6\n+\tjal     GetRandomDraw\n+\tnop\n+\tsll     v0, 12\n+\tsra     v0, 15\n+\tsubu    s2, v0\n+\n+\tloc_91994:\n+\tbeqz    s3, loc_919D0\n+\tmove    s6, s2\n+\tsll     v0, s3, 14\n+\tdivu    v0, t0\n+\tmflo    v0\n+\tsra     v0, 2\n+\tandi    v0, 0x3FFC\n+\tla\t\tat, rcossin_tbl\n+\taddu\tat, at, v0\n+\tlh      v1, 0(at)\n+\tli      v0, 0x1000\n+\tsubu    v0, v1\n+\tmult    v0, s2\n+\tmflo    s2\n+\tsra     s2, 12\n+\n+\tloc_919D0:\n+\tblez    s2, loc_91810\n+\tli      v0, 0x7FFF\n+\tslt     v0, v0, s2\n+\tbeqz    v0, loc_919E8\n+\tandi    v0, s4, 4\n+\tli      s2, 0x7FFF\n+\n+\tloc_919E8:\n+\tbnez    v0, loc_919F4\n+\tsrl     s4, 16\n+\tli      s4, 0x100\n+\n+\tloc_919F4:\n+\tsll     s4, 8\n+\tlb      v0, 5(s5)\n+\tandi    v1, t2, 0x2000\n+\tsll     v0, 9\n+\tbeqz    v1, loc_91A3C\n+\taddu    s4, v0\n+\tjal     GetRandomDraw\n+\tnop\n+\taddiu   a0, s4, -0x1770\n+\tsll     v1, v0, 1\n+\taddu    v1, v0\n+\tsll     v1, 4\n+\tsubu    v1, v0\n+\tsll     v1, 3\n+\tsubu    v1, v0\n+\tsll     v1, 4\n+\tsra     v1, 14\n+\taddu    s4, a0, v1\n+\n+\tloc_91A3C:\n+\tlh      s0, 0(s5)\n+\tsrl     t0, t2, 2\n+\tbltz    s0, loc_91CC4\n+\tmove    v0, zero\n+\tandi    t0, 0xF\n+\tli      v0, 1\n+\tbeq     t0, v0, loc_91A74\n+\tnop\n+\tjal     GetRandomDraw\n+\tnop\n+\tmult    v0, t0\n+\tmflo    v0\n+\tsra     v0, 15\n+\taddu    s0, v0\n+\n+\tloc_91A74:\n+\tandi    v1, t2, 3\n+\tctc2    s5, r8\n+\tctc2    s0, r9\n+\tctc2    v1, r10\n+\tli      s0, 0\n+\tla      s5, LaSlot\n+\tbeqz    v1, loc_91BA0\n+\taddiu   v1, -1\n+\tbeqz    v1, loc_91B2C\n+\taddiu   v1, -1\n+\tbeqz    v1, loc_91B6C\n+\tnop\n+\n+\tloc_91AA8:\n+\tlw      v0, 0x10(s5)\n+\tnop\n+\tbne     v0, fp, loc_91B14\n+\tnop\n+\tlw      v0, 4(s5)\n+\tnop\n+\tslt     v0, v0, s2\n+\tbeqz    v0, loc_91CC4\n+\tnop\n+\n+\tloc_91ACC:\n+\tsw      s6, 0(s5)\n+\tsw      s2, 4(s5)\n+\tsw      s1, 8(s5)\n+\tsw      s4, 0xC(s5)\n+\tsw      fp, 0x10(s5)\n+\tsw      s3, 0x14(s5)\n+\tli      v0, 0\n+\tli      v1, 0\n+\tbeqz    s7, loc_91B00\n+\tli      a0, 0\n+\tlw      v0, 0(s7)\n+\tlw      v1, 4(s7)\n+\tlw      a0, 8(s7)\n+\n+\tloc_91B00:\n+\tsw      v0, 0x18(s5)\n+\tsw      v1, 0x1C(s5)\n+\tsw      a0, 0x20(s5)\n+\tj       loc_91CC4\n+\tli      v0, 1\n+\n+\tloc_91B14:\n+\taddiu   s0, 1\n+\tslti    v0, s0, 0x18\n+\tbnez    v0, loc_91AA8\n+\taddiu   s5, 0x24\n+\tj       loc_91BA0\n+\tnop\n+\n+\tloc_91B2C:\n+\tlw      v0, 0x10(s5)\n+\tnop\n+\tbne     v0, fp, loc_91B54\n+\tnop\n+\tjal     S_SoundSampleIsPlaying\n+\tmove    a0, s0\n+\tbnez    v0, loc_91CC4\n+\tmove    v0, zero\n+\tli      at, 0xFFFFFFFF\n+\tsw      at, 0x10(s5)\n+\n+\tloc_91B54:\n+\taddiu   s0, 1\n+\tslti    v0, s0, 0x18\n+\tbnez    v0, loc_91B2C\n+\taddiu   s5, 0x24\n+\tj       loc_91BA0\n+\tnop\n+\n+\tloc_91B6C:\n+\tlw      v0, 0x10(s5)\n+\tnop\n+\tbne     v0, fp, loc_91B90\n+\tnop\n+\tjal     S_SoundStopSample\n+\tmove    a0, s0\n+\tli      v0, 0xFFFFFFFF\n+\tj       loc_91BA0\n+\tsw      at, 0x10(s5)\n+\n+\tloc_91B90:\n+\taddiu   s0, 1\n+\tslti    v0, s0, 0x18\n+\tbnez    v0, loc_91B6C\n+\taddiu   s5, 0x24\n+\n+\tloc_91BA0:\n+\tcfc2    v0, r10\n+\tcfc2    a0, r9\n+\tandi    a1, s2, 0xFFFF\n+\tmove    a2, s4\n+\tmove    a3, s1\n+\tli      at, 3\n+\tbne     v0, at, loc_91BC8\n+\tsw      s3, 0x40-0x30(sp)\n+\tjal     S_SoundPlaySampleLooped\n+\taddiu   ra, 8\n+\n+\tloc_91BC8:\n+\tjal     S_SoundPlaySample\n+\tnop\n+\tbltz    v0, loc_91BF0\n+\tsll     v1, v0, 3\n+\taddu    v1, v0\n+\tsll     v1, 2\n+\tla      s5, LaSlot\n+\tj       loc_91ACC\n+\taddu    s5, v1\n+\n+\tloc_91BF0:\n+\tli      at, 0xFFFFFFFF\n+\tbeq     v0, at, loc_91C08\n+\tmove    v0, zero\n+\tcfc2    v1, r8\n+\tj       loc_91CC4\n+\tsw      at, 0(v1)\n+\n+\tloc_91C08:\n+\tlui     a1, 0x800\n+\tli      a2, 0xFFFFFFFF\n+\tla      a3, LaSlot+0x24\n+\tli      t0, 1\n+\n+\tloc_91C1C:\n+\tlw      v0, 0x10(a3)\n+\tlw      v1, 4(a3)\n+\tbltz    v0, loc_91C40\n+\tslt     v0, a1, v1\n+\tbnez    v0, loc_91C40\n+\tnop\n+\tmove    a1, v1\n+\tmove    a2, t0\n+\tmove    s5, a3\n+\n+\tloc_91C40:\n+\taddiu   t0, 1\n+\tslti    v0, t0, 0x18\n+\tbnez    v0, loc_91C1C\n+\taddiu   a3, 0x24\n+\tslt     v0, s2, a1\n+\tbnez    v0, loc_91CC4\n+\tmove    v0, zero\n+\tjal     S_SoundStopSample\n+\tmove    a0, a2\n+\tli      at, 0xFFFFFFFF\n+\tsw      at, 0x10(s5)\n+\tcfc2    v0, r10\n+\tcfc2    a0, r9\n+\tandi    a1, s2, 0xFFFF\n+\tmove    a2, s4\n+\tmove    a3, s1\n+\tli      at, 3\n+\tbne     v0, at, loc_91C94\n+\tsw      s3, 0x40-0x30(sp)\n+\tjal     S_SoundPlaySampleLooped\n+\taddiu   ra, 8\n+\n+\tloc_91C94:\n+\tjal     S_SoundPlaySample\n+\tnop\n+\tmove    a0, v0\n+\tbltz    a0, loc_91CC4\n+\tmove    v0, zero\n+\tsll     v1, a0, 3\n+\taddu    v1, a0\n+\tsll     v1, 2\n+\tla      s5, LaSlot\n+\tj       loc_91ACC\n+\taddu    s5, v1\n+\n+\tloc_91CC4:\n+\tlw      ra, 0x40-0x4(sp)\n+\tlw      fp, 0x40-0x8(sp)\n+\tlw      s7, 0x40-0xC(sp)\n+\tlw      s6, 0x40-0x10(sp)\n+\tlw      s5, 0x40-0x14(sp)\n+\tlw      s4, 0x40-0x18(sp)\n+\tlw      s3, 0x40-0x1C(sp)\n+\tlw      s2, 0x40-0x20(sp)\n+\tlw      s1, 0x40-0x24(sp)\n+\tlw      s0, 0x40-0x28(sp)\n+\n+\tlocret_91CEC:\n+\tjr      ra\n+\taddiu   sp, 0x40\n+\t\n SPU_UpdateStatus:\n \taddiu   sp, -0x2C\n \tsw      ra, 0x2C-0x4(sp)\n@@ -113,7 +623,7 @@ GetPanVolume:\n \tsra     v0, 2\n \tandi    v0, 0x3FFC\n \tla\t\tat, rcossin_tbl\n-\taddu\tat, at, v0\n+\taddu\tat, v0\n \tlh      v1, 0(at)\n \tli      v0, 0x1000\n \tsubu    v0, v1\n@@ -155,7 +665,9 @@ S_SoundSampleIsPlaying:\n \tsw      ra, 0x18-0x4(sp)\n \tjal     SpuGetKeyStatus\n \tsllv    a0, s0\n-\tlbu     a1, LabSampleType(s0)\n+\tla\t\tat, LabSampleType\n+\taddu\tat, s0\n+\tlbu     a1, 0(at)\n \taddiu   v0, -1\n \tandi    v0, 0xFF\n \tsltiu   v0, v0, 2\n@@ -181,7 +693,9 @@ S_SoundStopSample:\n \taddiu   sp, -0x18\n \tsw      ra, 0x18-0x8(sp)\n \tsw      a0, 0x18-0x4(sp)\n-\tlbu     v0, LabSampleType(a0)\n+\tla\t\tat, LabSampleType\n+\taddu\tat, a0\n+\tlbu     v0, 0(a0)\n \tmove    a2, a0\n \tbeqz    v0, loc_916CC\n \tnop\n@@ -264,7 +778,9 @@ S_SetReverbType:\n \tbeq     a0, v0, loc_91D2C\n \tsll     a1, a0, 1\n \tsh      a0, CurrentReverb-GP_ADDR(gp)\n-\tlh      a1, DepthTable(a1)\n+\tla\t\tat, DepthTable\n+\taddu\tat, a1\n+\tlh      a1, 0(at)\n \tjal     SpuSetReverbModeDepth\n \tmove    a0, a1\n \tjal     SpuSetReverb\n@@ -294,8 +810,12 @@ SPU_StopAll:\n \t\n SPU_FreeChannel:\n \tlw      v1, LnFreeChannels-GP_ADDR(gp)\n-\tsb      zero, LabSampleType(a0)\n+\tla\t\tat, LabSampleType\n+\taddu\tat, a0\n+\tsb      zero, 0(a0)\n \taddiu   v0, v1, 1\n-\tsb      a0, LabFreeChannel(v1)\n+\tla\t\tat, LabFreeChannel\n+\taddu\tat, v1\n+\tsb      a0, 0(at)\n \tjr      ra\n \tsw      v0, LnFreeChannels-GP_ADDR(gp)\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/SHADOWS.MIP b/SPEC_PSX/SHADOWS.MIP\nindex eefd7ce6..a32de258 100644\n--- a/SPEC_PSX/SHADOWS.MIP\n+++ b/SPEC_PSX/SHADOWS.MIP\n@@ -1,10 +1,159 @@\n \topt at-,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF OptimiseOTagR\n-\t;XREF\n+\tXDEF OptimiseOTagR, S_DrawGouraudBar, calcval, DelLine, DelBox\n+\tXREF db\n+\t\n+calcval:\n+\tmult    at, t5\n+\tmflo    at\n+\tnop\n+\tnop\n+\tmult    v0, t3\n+\tmflo    v0\n+\tnop\n+\taddu    v0, at\n+\tdiv     v0, t6\n+\tjr      ra\n+\tmflo    at\n+\t\n+DelLine:\n+\tlui     at, 0x5000\n+\tor      a2, at\n+\tsw      a2, 4(t8)\n+\tsw      a0, 8(t8)\n+\tsw      a3, 0xC(t8)\n+\tsw      a1, 0x10(t8)\n+\tlui     at, 0x400\n+\tor      t7, at\n+\tsw      t7, 0(t8)\n+\tmove    t7, t8\n+\tjr      ra\n+\taddiu   t8, 0x14\n+\t\n+DelBox:\n+\tlui     at, 0x300\n+\tor      t7, at\n+\tsw      t7, 0(t8)\n+\tsw      a2, 4(t8)\n+\tsw      a0, 8(t8)\n+\tsw      a1, 0xC(t8)\n+\tmove    t7, t8\n+\tjr      ra\n+\taddiu   t8, 0x10\n+\n+S_DrawGouraudBar:\n+\taddiu   sp, -0x20\n+\tsw      s0, 0x20+0x10(sp)\n+\tsw      s1, 0x20+0xC(sp)\n+\tsw      ra, 0x20+0x8(sp)\n+\tlw      t9, db+0x4-GP_ADDR(gp)\n+\tlw      t8, db+0x8-GP_ADDR(gp)\n+\tlw      at, db+0x10-GP_ADDR(gp)\n+\tlw      t7, 0(t9)\n+\tsltu    at, t8, at\n+\tbeqz    at, loc_87160\n+\tmove    t6, a2\n+\tmove    s0, a0\n+\tmove    s1, a1\n+\tmove    t3, a3\n+\tbeqz    t3, loc_870AC\n+\taddiu   t3, -1\n+\tsubu    t5, t6, t3\n+\tlw      t2, 0x20+0x10(sp)\n+\tli      t4, 5\n+\tandi    a0, s0, 0xFFFF\n+\tsll     at, s1, 16\n+\taddu    a1, a0, t3\n+\tor      a0, at\n+\tor      a1, at\n \n+\tloc_87038:\n+\tlbu     at, 0(t2)\n+\tlbu     v0, 0xF(t2)\n+\tjal     calcval\n+\tmove    t0, at\n+\tmove    a3, at\n+\tlbu     at, 5(t2)\n+\tlbu     v0, 0x14(t2)\n+\tjal     calcval\n+\tmove    t1, at\n+\tmove    a2, at\n+\tlbu     at, 0xA(t2)\n+\tlbu     v0, 0x19(t2)\n+\tjal     calcval\n+\tmove    v1, at\n+\tsll     at, 16\n+\tor      a3, at, a3\n+\tsll     a2, 8\n+\tor      a3, a2\n+\tsll     t1, 8\n+\tor      a2, t1, t0\n+\tsll     v1, 16\n+\tjal     DelLine\n+\tor      a2, v1\n+\taddiu   t2, 1\n+\tlui     at, 1\n+\taddu    a0, at\n+\taddiu   t4, -1\n+\tbnez    t4, loc_87038\n+\taddu    a1, at\n+\n+\tloc_870AC:\n+\taddiu   s0, -2\n+\taddiu   s1, -2\n+\tsll     t2, s1, 16\n+\taddu    t3, s0, t6\n+\taddiu   t3, 4\n+\taddiu   t4, s1, 8\n+\tsll     t4, 16\n+\tor      a0, s0, t2\n+\tor      a1, t3, t2\n+\tli      a2, 0x828250\n+\tlui     a3, 0xA0\n+\tjal     DelLine\n+\tli      a3, 0xA0A0A0\n+\tor      a0, t3, t4\n+\tjal     DelLine\n+\tor      a1, s0, t4\n+\tor      a1, t3, t2\n+\tjal     DelLine\n+\tor      a0, t3, t4\n+\tor      a1, s0, t4\n+\tjal     DelLine\n+\tor      a0, s0, t2\n+\tlui     at, 1\n+\taddu    t2, at\n+\tsubu    t4, at\n+\taddiu   s0, -1\n+\tor      a0, s0, t2\n+\tor      a1, s0, t4\n+\tli      a2, 0x414128\n+\tlui     a3, 0x50\n+\tjal     DelLine\n+\tli      a3, 0x505050\n+\taddiu   t3, 1\n+\tor      a1, t3, t2\n+\tjal     DelLine\n+\tor      a0, t3, t4\n+\taddiu   s0, 2\n+\tor      a0, s0, t2\n+\taddiu   v0, t6, 3\n+\tlui     a1, 7\n+\tor      a1, v0, a1\n+\tjal     DelBox\n+\tlui     a2, 0x6000\n+\n+\tloc_87160:\n+\tlw      ra, 0x20+0x8(sp)\n+\tlw      s1, 0x20+0xC(sp)\n+\tlw      s0, 0x20+0x10(sp)\n+\taddiu   sp, 0x20\n+\tsw      t7, 0(t9)\n+\tjr      ra\n+\tsw      t8, db+0x8-GP_ADDR(gp)\n+\t\n OptimiseOTagR:\n \tslti    at, a1, 8\n \tbnez    at, locret_86D14\ndiff --git a/SPEC_PSX/SPARKS.MIP b/SPEC_PSX/SPARKS.MIP\nindex 7b075b96..23042ae5 100644\n--- a/SPEC_PSX/SPARKS.MIP\n+++ b/SPEC_PSX/SPARKS.MIP\n@@ -1,8 +1,523 @@\n \topt at+,w-,c+,m-\n \n-\tsection\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF S_DrawSparks\n+\tXDEF S_DrawSparks, local_GetRandomDraw\n+\tXREF mPushMatrix, rand_2, mTranslateAbsXYZ, items, lara_item, effects, mPopMatrix, db, psxspriteinfo, phd_persp, spark, NodeVectors, NodeOffsets, GetLaraJointPos, GetJointAbsPosition, rcossin_tbl\n+\t\n+local_GetRandomDraw:\n+\tlw      v0, rand_2-GP_ADDR(gp)\n+\tli      at, 0x41C64E6D\n+\tmult    v0, at\n+\tmflo    at\n+\taddiu   v0, at, 0x3039\n+\tsw      v0, rand_2-GP_ADDR(gp)\n+\tsra     v0, 16\n+\tjr      ra\n+\tandi    v0, 0x7FFF\n \t\n S_DrawSparks:\n-\tjr      ra\n\\ No newline at end of file\n+\taddiu   sp, -0x48\n+\tsw      s0, 0x48-0x28(sp)\n+\tsw      s1, 0x48-0x24(sp)\n+\tsw      s2, 0x48-0x20(sp)\n+\tsw      s3, 0x48-0x1C(sp)\n+\tsw      s4, 0x48-0x18(sp)\n+\tsw      s5, 0x48-0x14(sp)\n+\tsw      s6, 0x48-0x10(sp)\n+\tsw      s7, 0x48-0xC(sp)\n+\tsw      fp, 0x48-0x8(sp)\n+\tsw      ra, 0x48-0x4(sp)\n+\tla      v0, NodeOffsets+0x7F\n+\tli      v1, 0xF\n+\n+\tloc_8FFC4:\n+\tsb      zero, 0(v0)\n+\taddiu   v1, -1\n+\tbgez    v1, loc_8FFC4\n+\taddiu   v0, -8\n+\tjal     mPushMatrix\n+\tlui     fp, 0x1F80\n+\tlw      s4, db+0x8-GP_ADDR(gp)\n+\tlw      s5, db+0x4-GP_ADDR(gp)\n+\tlw      s7, db+0x10-GP_ADDR(gp)\n+\tlw      s1, psxspriteinfo-GP_ADDR(gp)\n+\tlw      s2, phd_persp-GP_ADDR(gp)\n+\tlw      v0, lara_item-GP_ADDR(gp)\n+\tla      s3, spark\n+\tlw      a0, 0x40(v0)\n+\tlw      a1, 0x44(v0)\n+\tlw      a2, 0x48(v0)\n+\tsw      a0, 0x1F800008\n+\tsw      a1, 0x1F80000C\n+\tjal     mTranslateAbsXYZ\n+\tsw      a2, 0x1F800010\n+\tli      s6, 0x80\n+\n+\tloc_9001C:\n+\tlbu     v0, 0x20(s3)\n+\taddiu   s6, -1\n+\tbeqz    v0, loc_90674\n+\tsltu    at, s4, s7\n+\tbeqz    at, loc_9067C\n+\tlhu     s0, 0x16(s3)\n+\tnop\n+\tandi    v0, s0, 0x40\n+\tbeqz    v0, loc_900C4\n+\tandi    v0, s0, 0x80\n+\tlbu     v1, 0x31(s3)\n+\tlw      a0, effects-GP_ADDR(gp)\n+\tsll     v0, v1, 1\n+\taddu    v0, v1\n+\tsll     v0, 2\n+\tsubu    v0, v1\n+\tsll     v0, 2\n+\taddu    a0, v0\n+\tlw      v1, 0(a0)\n+\tlw      v0, 0(s3)\n+\tlw      a2, 4(a0)\n+\tlw      a1, 8(a0)\n+\taddu    t6, v1, v0\n+\tlw      v1, 4(s3)\n+\tlw      v0, 8(s3)\n+\taddu    t5, a2, v1\n+\tjal     local_GetRandomDraw\n+\taddu    t7, a1, v0\n+\tandi    v0, 7\n+\tlbu     v1, 0x2C(s3)\n+\tlbu     a0, 0x2D(s3)\n+\taddiu   v0, 4\n+\tsubu    v1, a0\n+\tslt     v0, v0, v1\n+\tbeqz    v0, loc_90290\n+\tnop\n+\tsw      t6, 0(s3)\n+\tsw      t5, 4(s3)\n+\tsw      t7, 8(s3)\n+\tandi    s0, 0xFFBF\n+\tj       loc_90290\n+\tsh      s0, 0x16(s3)\n+\n+\tloc_900C4:\n+\tbeqz    v0, loc_90284\n+\tandi    at, s0, 0x1000\n+\tlbu     v1, 0x31(s3)\n+\tlw      t0, items-GP_ADDR(gp)\n+\tsll     v0, v1, 3\n+\taddu    v0, v1\n+\tsll     v0, 4\n+\tbeqz    at, loc_9025C\n+\taddu    t0, v0\n+\tlbu     a0, 0x33(s3)\n+\tla      a1, NodeOffsets\n+\tsll     v0, a0, 3\n+\taddu    a2, v0, a1\n+\tlbu     v1, 7(a2)\n+\tlui     v0, 0xA\n+\tbeqz    v1, loc_90138\n+\tla      v0, NodeVectors\n+\tsll     a2, a0, 1\n+\taddu    a2, a0\n+\tsll     a2, 2\n+\taddu    a2, v0\n+\tlw      a1, 0(a2)\n+\tlw      v1, 4(a2)\n+\tlw      a2, 8(a2)\n+\tsw      a1, 0x48-0x34(fp)\n+\tsw      v1, 0x48-0x30(fp)\n+\tj       loc_901FC\n+\tsw      a2, 0x48-0x2C(fp)\n+\n+\tloc_90138:\n+\tlb      v1, 6(a2)\n+\tlh      a0, 0(a2)\n+\tlh      a1, 2(a2)\n+\tlh      v0, 4(a2)\n+\tli      at, 1\n+\tsb      at, 7(a2)\n+\tsw      a0, 0x48-0x34(fp)\n+\tsw      a1, 0x48-0x30(fp)\n+\tbgez    v1, loc_901B8\n+\tsw      v0, 0x48-0x2C(fp)\n+\taddiu   a0, fp, 0x48-0x34\n+\tjal     GetLaraJointPos\n+\tnegu    a1, v1\n+\tlw      at, 0x48-0x34(fp)\n+\tlw      v0, 0x48-0x30(fp)\n+\tlw      v1, 0x48-0x2C(fp)\n+\tlw      a0, 0x48-0x40(fp)\n+\tlw      a1, 0x48-0x3C(fp)\n+\tlw      a2, 0x48-0x38(fp)\n+\tsubu    at, a0\n+\tsubu    v0, a1\n+\tsubu    v1, a2\n+\tlw      a0, 0x4F94(gp)\n+\tlw      a1, 0x4F98(gp)\n+\tlw      a2, 0x4F9C(gp)\n+\taddu    at, a0\n+\taddu    v0, a1\n+\taddu    v1, a2\n+\tsw      at, 0x48-0x34(fp)\n+\tsw      v0, 0x48-0x30(fp)\n+\tj       loc_901C8\n+\tsw      v1, 0x48-0x2C(fp)\n+\n+\tloc_901B8:\n+\tmove    a0, t0\n+\taddiu   a1, fp, 0x48-0x34\n+\tjal     GetJointAbsPosition\n+\tmove    a2, v1\n+\n+\tloc_901C8:\n+\tlbu     a1, 0x33(s3)\n+\tla      v1, NodeVectors\n+\tsll     v0, a1, 1\n+\taddu    v0, a1\n+\tsll     v0, 2\n+\taddu    v0, v1\n+\tlw      v1, 0x48-0x34(fp)\n+\tlw      a0, 0x48-0x30(fp)\n+\tlw      a1, 0x48-0x2C(fp)\n+\tsw      v1, 0(v0)\n+\tsw      a0, 4(v0)\n+\tsw      a1, 8(v0)\n+\n+\tloc_901FC:\n+\tlw      v1, 0x48-0x34(fp)\n+\tlw      v0, 0(s3)\n+\tlw      a1, 0x48-0x30(fp)\n+\tlw      a0, 0x48-0x2C(fp)\n+\taddu    t6, v1, v0\n+\tlw      v1, 4(s3)\n+\tlw      v0, 8(s3)\n+\taddu    t5, a1, v1\n+\tjal     local_GetRandomDraw\n+\taddu    t7, a0, v0\n+\tandi    v0, 3\n+\tlbu     v1, 0x2C(s3)\n+\tlbu     a0, 0x2D(s3)\n+\taddiu   v0, 8\n+\tsubu    v1, a0\n+\tslt     v0, v0, v1\n+\tbeqz    v0, loc_90290\n+\tnop\n+\tsw      t6, 0(s3)\n+\tsw      t5, 4(s3)\n+\tsw      t7, 8(s3)\n+\tandi    s0, 0xEF7F\n+\tj       loc_90290\n+\tsh      s0, 0x16(s3)\n+\n+\tloc_9025C:\n+\tlw      v1, 0x40(t0)\n+\tlw      v0, 0(s3)\n+\tlw      a1, 0x44(t0)\n+\tlw      a0, 0x48(t0)\n+\taddu    t6, v1, v0\n+\tlw      v1, 4(s3)\n+\tlw      v0, 8(s3)\n+\taddu    t5, a1, v1\n+\tj       loc_90290\n+\taddu    t7, a0, v0\n+\n+\tloc_90284:\n+\tlw      t6, 0(s3)\n+\tlw      t5, 4(s3)\n+\tlw      t7, 8(s3)\n+\n+\tloc_90290:\n+\tlw      at, 0x48-0x40(fp)\n+\tlw      v0, 0x48-0x3C(fp)\n+\tlw      v1, 0x48-0x38(fp)\n+\tsubu    t6, at\n+\tsubu    t5, v0\n+\tsubu    t7, v1\n+\tli      v0, 0xA000\n+\taddiu   v1, t6, 0x5000\n+\tsltu    at, v0, v1\n+\tbnez    at, loc_90334\n+\taddiu   v1, t5, 0x5000\n+\tsltu    at, v0, v1\n+\tbnez    at, loc_90334\n+\taddiu   v1, t7, 0x5000\n+\tsltu    at, v0, v1\n+\tbnez    at, loc_90334\n+\tsh      t6, 0x48-0x44(fp)\n+\tsh      t5, 0x48-0x44+2(fp)\n+\tmtc2    t7, r1\n+\tlwc2    r0, 0x48-0x44(fp)\n+\tnop\n+\tnop\n+\tcop2    0x180001\n+\tlbu     t4, 0x1D(s3)\n+\tlbu     t9, 0x2E(s3)\n+\tlbu     t1, 0x1A(s3)\n+\tsll     t4, 4\n+\taddu    t4, s1\n+\tmfc2    t8, r19\n+\tswc2    r14, 0x48-0x48(fp)\n+\tandi    at, s0, 0x4000\n+\tbeqz    at, loc_90318\n+\tandi    at, s0, 0x8000\n+\taddiu   t8, -0x100\n+\n+\tloc_90318:\n+\tbeqz    at, loc_90324\n+\tnop\n+\taddiu   t8, -0x80\n+\n+\tloc_90324:\n+\tblez    t8, loc_90674\n+\tslti    at, t8, 0x5000\n+\tbnez    at, loc_9033C\n+\tandi    at, s0, 8\n+\n+\tloc_90334:\n+\tj       loc_90674\n+\tsb      zero, 0x20(s3)\n+\n+\tloc_9033C:\n+\tbnez    at, loc_90450\n+\tandi    at, s0, 2\n+\tlh      v0, 0xC(s3)\n+\tlh      v1, 0xE(s3)\n+\tlh      a0, 0x10(s3)\n+\tsra     v0, 4\n+\tsra     v1, 4\n+\tsra     a0, 4\n+\tsubu    v0, t6, v0\n+\tsubu    v1, t5, v1\n+\tsubu    a0, t7, a0\n+\tsh      v0, 0x48-0x44(fp)\n+\tsh      v1, 0x48-0x44+2(fp)\n+\tmtc2    a0, r1\n+\tlwc2    r0, 0x48-0x44(fp)\n+\tli      a1, 0xE1000200\n+\tcop2    0x180001\n+\tlbu     v0, 0x27(s3)\n+\tlbu     v1, 0x28(s3)\n+\tlbu     a0, 0x29(s3)\n+\tslti    at, t8, 0x3001\n+\tbnez    at, loc_903CC\n+\tli      at, 0x5000\n+\tsubu    at, t8\n+\tmult    v0, at\n+\tmflo    v0\n+\tsra     v0, 13\n+\tnop\n+\tmult    v1, at\n+\tmflo    v1\n+\tsra     v1, 13\n+\tnop\n+\tmult    a0, at\n+\tmflo    a0\n+\tsra     a0, 13\n+\n+\tloc_903CC:\n+\tsb      v0, 0xC(s4)\n+\tsb      v1, 0xD(s4)\n+\tsb      a0, 0xE(s4)\n+\tsrl     v0, 1\n+\tsb      v0, 0x14(s4)\n+\tsrl     v1, 1\n+\tsb      v1, 0x15(s4)\n+\tsrl     a0, 1\n+\tsb      a0, 0x16(s4)\n+\tbnez    t9, loc_903FC\n+\tli      v0, 0x52\n+\tli      v0, 0x50\n+\n+\tloc_903FC:\n+\tsb      v0, 0xF(s4)\n+\taddiu   v1, t9, -1\n+\tandi    v1, 3\n+\tsll     v1, 5\n+\tor      v1, a1\n+\tsw      v1, 4(s4)\n+\tlw      a2, 0x48-0x48(fp)\n+\tmfc2    a3, r14\n+\tsw      a2, 0x10(s4)\n+\tsw      a3, 0x18(s4)\n+\tsra     v1, t8, 3\n+\tsll     v1, 2\n+\taddu    v1, s5\n+\tlw      v0, 0(v1)\n+\tlui     at, 0x600\n+\tor      v0, at\n+\tsw      s4, 0(v1)\n+\tsw      v0, 0(s4)\n+\tsw      zero, 8(s4)\n+\tj       loc_90674\n+\taddiu   s4, 0x1C\n+\n+\tloc_90450:\n+\tbeqz    at, loc_90494\n+\tnop\n+\tmult    t1, s2\n+\tlbu     at, 0x1C(s3)\n+\tmflo    v0\n+\tsllv    v1, t1, at\n+\tsllv    v0, at\n+\tdiv     v0, t8\n+\tmflo    t1\n+\tslt     at, v1, t1\n+\tbeqz    at, loc_90488\n+\tslti    at, t1, 2\n+\tj       loc_90494\n+\tmove    t1, v1\n+\n+\tloc_90488:\n+\tbeqz    at, loc_90494\n+\tnop\n+\tli      t1, 2\n+\n+\tloc_90494:\n+\tlh      t3, 0x48-0x48(fp)\n+\tlh      t2, 0x48-0x48+2(fp)\n+\tsra     a0, t1, 1\n+\taddu    t0, t3, a0\n+\tbltz    t0, loc_90674\n+\tsubu    a2, t3, a0\n+\tslti    v0, a2, 0x200\n+\tbeqz    v0, loc_90674\n+\taddu    a1, t2, a0\n+\tbltz    a1, loc_90674\n+\tsubu    v1, t2, a0\n+\tslti    v0, v1, 0xF0\n+\tbeqz    v0, loc_90674\n+\tandi    v0, s0, 0x10\n+\tbeqz    v0, loc_90578\n+\tnop\n+\tlh      v1, 0x14(s3)\n+\tla      a1, rcossin_tbl\n+\tsll     v1, 2\n+\taddu    v1, a1\n+\tnegu    a0, t1\n+\tlh      t0, 0(v1)\n+\tsra     a0, 1\n+\tmult    a0, t0\n+\tlh      a2, 2(v1)\n+\tmflo    v0\n+\tsra     t0, v0, 12\n+\tnegu    a1, t0\n+\tmult    a0, a2\n+\tmflo    a0\n+\tsra     a2, a0, 12\n+\tsubu    v0, t0, a2\n+\taddu    t6, v0, t3\n+\tsubu    v0, a1, a2\n+\taddu    t1, v0, t3\n+\taddu    v1, t0, a2\n+\taddu    t5, v1, t2\n+\tnegu    a0, a2\n+\taddu    v0, a0, t0\n+\taddu    v0, t2\n+\taddu    v1, t3\n+\tsh      v0, 0x12(s4)\n+\tsubu    v0, a2, t0\n+\taddu    v0, t2\n+\taddu    a1, a2\n+\taddu    a1, t3\n+\tsubu    a0, t0\n+\taddu    a0, t2\n+\tsh      t6, 8(s4)\n+\tsh      t5, 0xA(s4)\n+\tsh      t1, 0x10(s4)\n+\tsh      v1, 0x18(s4)\n+\tsh      v0, 0x1A(s4)\n+\tsh      a1, 0x20(s4)\n+\tj       loc_90598\n+\tsh      a0, 0x22(s4)\n+\n+\tloc_90578:\n+\tsh      a2, 8(s4)\n+\tsh      v1, 0xA(s4)\n+\tsh      t0, 0x10(s4)\n+\tsh      v1, 0x12(s4)\n+\tsh      a2, 0x18(s4)\n+\tsh      a1, 0x1A(s4)\n+\tsh      t0, 0x20(s4)\n+\tsh      a1, 0x22(s4)\n+\n+\tloc_90598:\n+\tlbu     a1, 0x27(s3)\n+\tlbu     v1, 0x28(s3)\n+\tlbu     a0, 0x29(s3)\n+\tbeqz    t9, loc_905B0\n+\tli      v0, 0x2C\n+\tli      v0, 0x2E\n+\n+\tloc_905B0:\n+\tslti    at, t8, 0x3001\n+\tbnez    at, loc_905EC\n+\tli      at, 0x5000\n+\tsubu    at, t8\n+\tmult    a1, at\n+\tmflo    a1\n+\tnop\n+\tsra     a1, 13\n+\tmult    v1, at\n+\tmflo    v1\n+\tnop\n+\tsra     v1, 13\n+\tmult    a0, at\n+\tmflo    a0\n+\tsra     a0, 13\n+\n+\tloc_905EC:\n+\tsb      a1, 4(s4)\n+\tsb      v1, 5(s4)\n+\tsb      a0, 6(s4)\n+\tsb      v0, 7(s4)\n+\tlbu     t6, 0xC(t4)\n+\tlbu     t1, 0xE(t4)\n+\tlbu     t5, 0xD(t4)\n+\tlbu     v0, 0xF(t4)\n+\tsb      t6, 0xC(s4)\n+\tsb      t5, 0xD(s4)\n+\tsb      t1, 0x14(s4)\n+\tsb      t5, 0x15(s4)\n+\tsb      t6, 0x1C(s4)\n+\tsb      v0, 0x1D(s4)\n+\tsb      t1, 0x24(s4)\n+\tsb      v0, 0x25(s4)\n+\tlhu     v1, 0xA(t4)\n+\tbeqz    t9, loc_90648\n+\tlhu     v0, 8(t4)\n+\tandi    v1, 0xFF9F\n+\taddiu   at, t9, -1\n+\tsll     at, 5\n+\tor      v1, at\n+\n+\tloc_90648:\n+\tsh      v1, 0x16(s4)\n+\tsh      v0, 0xE(s4)\n+\tsra     a0, t8, 3\n+\tsll     a0, 2\n+\taddu    a0, s5\n+\tlw      v0, 0(a0)\n+\tlui     at, 0x900\n+\tor      v0, at\n+\tsw      s4, 0(a0)\n+\tsw      v0, 0(s4)\n+\taddiu   s4, 0x28\n+\n+\tloc_90674:\n+\tbnez    s6, loc_9001C\n+\taddiu   s3, 0x34\n+\n+\tloc_9067C:\n+\tjal     mPopMatrix\n+\tsw      s4, db+0x8-GP_ADDR(gp)\n+\tlw      ra, 0x48-0x4(sp)\n+\tlw      fp, 0x48-0x8(sp)\n+\tlw      s7, 0x48-0xC(sp)\n+\tlw      s6, 0x48-0x10(sp)\n+\tlw      s5, 0x48-0x14(sp)\n+\tlw      s4, 0x48-0x18(sp)\n+\tlw      s3, 0x48-0x1C(sp)\n+\tlw      s2, 0x48-0x20(sp)\n+\tlw      s1, 0x48-0x24(sp)\n+\tlw      s0, 0x48-0x28(sp)\n+\tjr      ra\n+\taddiu   sp, 0x48\n\\ No newline at end of file\ndiff --git a/SPEC_PSX/SPECIFIC.C b/SPEC_PSX/SPECIFIC.C\nindex 55851e76..82e263f4 100644\n--- a/SPEC_PSX/SPECIFIC.C\n+++ b/SPEC_PSX/SPECIFIC.C\n@@ -1,16 +1,25 @@\n #include "SPECIFIC.H"\n \n #include "3D_OBJ.H"\n+#include "BUBBLES.H"\n #include "CAMERA.H"\n #include "CD.H"\n+#include "CONTROL.H"\n+#include "EFFECTS.H"\n+#include "FXTRIG.H"\n+#include "GAMEFLOW.H"\n+#include "MEMCARD.H"\n #include "MISC.H"\n #include "GPU.H"\n+#include "LARA.H"\n+#include "LOADSAVE.H"\n #include "PROFILE.H"\n #include "PSXINPUT.H"\n #include "REQUEST.H"\n #include "SAVEGAME.H"\n #include "SFX.H"\n #include "SOUND.H"\n+#include "TEXT_S.H"\n \n #include <assert.h>\n #include <stdio.h>\n@@ -574,10 +583,147 @@ void gInit()//615CC(<), 6210C(<) (F)\n \treturn;\n }\n \n-short S_Death()//61658, 622C8\n+short S_Death()//61658(<), 622C8\n {\n-\tUNIMPLEMENTED();\n-\treturn 0;\n+\tshort ret;\n+\tunsigned char flag;\n+\tunsigned char Cursor;\n+\n+\tret = 0;\n+\tflag = 0;\n+\tCursor = 0;\n+\n+\tgInit();\n+\tmcOpen(0);\n+\n+\t//loc_6169C:\n+\twhile (ret == 0)\n+\t{\n+\t\tXAReqVolume = 0;\n+\n+\t\tGPU_BeginScene();\n+\n+\t\tSetDebounce = 1;\n+\n+\t\tS_UpdateInput();\n+\t\tUpdatePulseColour();\n+\n+\t\t++lara.death_count;\n+\n+\t\tif (PadConnected == 0)\n+\t\t{\n+\t\t\tPrintString(SCREEN_WIDTH / 2, 0x40, 3, &gfStringWad[gfStringOffset[STR_CONTROLLER_REMOVED]], 0xA000);\n+\t\t}\n+\t\telse\n+\t\t{\n+\t\t\t//loc_61704\n+\t\t\tif (flag != 0)\n+\t\t\t{\n+\t\t\t\tif (flag == 1)\n+\t\t\t\t{\n+\t\t\t\t\t//loc_6189C\n+\t\t\t\t\tret = LoadGame();\n+\n+\t\t\t\t\tif (ret != 0)\n+\t\t\t\t\t{\n+\t\t\t\t\t\tret = 2;\n+\t\t\t\t\t\tif (ret < 0)\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tflag = 0;\n+\t\t\t\t\t\t\tret = 0;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t}//loc_618C4\n+\t\t\t}\n+\t\t\telse\n+\t\t\t{\n+\t\t\t\t//loc_6171C\n+\t\t\t\tif (mcGetStatus() == 0)\n+\t\t\t\t{\n+\t\t\t\t\tif (mcNumFiles != 0)\n+\t\t\t\t\t{\n+\t\t\t\t\t\tif (Cursor == 0)\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t//loc_6174C\n+\t\t\t\t\t\t\tPrintString(SCREEN_WIDTH / 2, 0xC0, 1, &gfStringWad[gfStringOffset[STR_LOAD_GAME_BIS]], 0x8000);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\telse\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t//loc_6174C\n+\t\t\t\t\t\t\tPrintString(SCREEN_WIDTH / 2, 0xC0, 2, &gfStringWad[gfStringOffset[STR_LOAD_GAME_BIS]], 0x8000);\n+\t\t\t\t\t\t}\n+\n+\t\t\t\t\t\tif (Cursor == 0)\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tPrintString(SCREEN_WIDTH / 2, 0xD0, 2, &gfStringWad[gfStringOffset[STR_EXIT_TO_TITLE]], 0x8000);\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\telse\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tPrintString(SCREEN_WIDTH / 2, 0xD0, 1, &gfStringWad[gfStringOffset[STR_EXIT_TO_TITLE]], 0x8000);\n+\t\t\t\t\t\t}\n+\n+\t\t\t\t\t\tif (Cursor != 0)\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tif ((RawEdge & 0x10))\n+\t\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t\tSoundEffect(0x6D, NULL, 2);\n+\t\t\t\t\t\t\t\tCursor = 0;\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\telse\n+\t\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t\t//loc_617E0\n+\t\t\t\t\t\t\t\tif ((RawEdge & 0x4000))\n+\t\t\t\t\t\t\t\t{\n+\t\t\t\t\t\t\t\t\tSoundEffect(0x6F, NULL, 2);\n+\t\t\t\t\t\t\t\t\tCursor = 1;\n+\t\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t\t}\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\t//loc_61800\n+\t\t\t\t\t\tif ((RawEdge & 0x40))\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tSoundEffect(0x6D, NULL, 2);\n+\t\t\t\t\t\t\tCursor = 1;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t\t//loc_6182C\n+\t\t\t\t\t\tif ((RawEdge & 0x4000))\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tSoundEffect(0x6F, NULL, 2);\n+\t\t\t\t\t\t\tCursor = 1;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t\telse\n+\t\t\t\t\t{\n+\t\t\t\t\t\t//loc_6184C\n+\t\t\t\t\t\tif (lara.death_count > 0x12C)\n+\t\t\t\t\t\t{\n+\t\t\t\t\t\t\tCursor = 1;\n+\t\t\t\t\t\t}\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\telse\n+\t\t\t\t{\n+\t\t\t\t\t//loc_6184C\n+\t\t\t\t\tif (lara.death_count > 0x12C)\n+\t\t\t\t\t{\n+\t\t\t\t\t\tCursor = 1;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\n+\t\t\t\t//loc_61864\n+\t\t\t\tPrintString(SCREEN_WIDTH/2, 0x78, 3, &gfStringWad[gfStringOffset[STR_GAME_OVER]], 0x8000);\n+\t\t\t}\n+\t\t}\n+\t\t//loc_618C4\n+\t\tSOUND_EndScene();\n+\t\tDrawMonoScreen(0x203040);\n+\t\tGPU_EndScene();\n+\t\tcamera.number_frames = S_DumpScreen();\n+\t}\n+\n+\tmcClose();\n+\n+\treturn ret;\n }\n \n void DisplayStatsUCunt()//61928(<), 625A8(<) (F)\ndiff --git a/SPEC_PSX/SPHERES.MIP b/SPEC_PSX/SPHERES.MIP\nindex 2a7fb1c8..7ceb39b6 100644\n--- a/SPEC_PSX/SPHERES.MIP\n+++ b/SPEC_PSX/SPHERES.MIP\n@@ -1,9 +1,171 @@\n \topt at-,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF GetJointAbsPosition\n-\tXREF bones, Matrix, GetFrames, mPushUnitMatrix, mSetTrans, mRotYXZ, mTranslateXYZ, mRotSuperPackedYXZ, mPopMatrix, mPushMatrix, mRotY, mCopyMatrix, iTranslateXYZ, InterpolateMatrix, iRotZ, mRotZ, iRotX, mRotX, iRotY, mRotY, InitInterpolation, iTranslateXYZ2, iRotSuperPackedYXZ, iPopMatrix, iPushMatrix, objects, iMatrixStack\n+\tXDEF GetJointAbsPosition, IsRoomOutside\n+\tXREF IsRoomOutsideNo, OutsideRoomTable, GetCeiling, GetHeight, room, OutsideRoomOffsets, GetFloor, bones, Matrix, GetFrames, mPushUnitMatrix, mSetTrans, mRotYXZ, mTranslateXYZ, mRotSuperPackedYXZ, mPopMatrix, mPushMatrix, mRotY, mCopyMatrix, iTranslateXYZ, InterpolateMatrix, iRotZ, mRotZ, iRotX, mRotX, iRotY, mRotY, InitInterpolation, iTranslateXYZ2, iRotSuperPackedYXZ, iPopMatrix, iPushMatrix, objects, iMatrixStack\n+\t\n+IsRoomOutside:\n+\taddiu   sp, -0x38\n+\tsw      s3, 0x38-0xC(sp)\n+\tmove    s3, a0\n+\tsw      s2, 0x38-0x10(sp)\n+\tmove    s2, a1\n+\tsw      s4, 0x38-0x8(sp)\n+\tmove    s4, a2\n+\tsra     v1, s3, 12\n+\tsra     a0, s4, 12\n+\tsll     v0, v1, 3\n+\tsubu    v0, v1\n+\tsll     v0, 2\n+\tsubu    v0, v1\n+\taddu    v0, a0\n+\tlw      v1, OutsideRoomOffsets-GP_ADDR(gp)\n+\tsll     v0, 1\n+\tsw      ra, 0x38-0x4(sp)\n+\tsw      s1, 0x38-0x14(sp)\n+\tbgez    s3, loc_8EF54\n+\tsw      s0, 0x38-0x18(sp)\n+\tbltz    s4, loc_8F11C\n+\n+\tloc_8EF54:\n+\taddu    v0, v1\n+\tlh      v1, 0(v0)\n+\tli      v0, 0xFFFFFFFF\n+\tbeq     v1, v0, loc_8F11C\n+\tandi    t0, v1, 0x7FFF\n+\tbgez    v1, loc_8EFF4\n+\tsll     v0, t0, 2\n+\taddu    v0, t0\n+\tlw      v1, room-GP_ADDR(gp)\n+\tsll     v0, 4\n+\taddu    s1, v1, v0\n+\tlw      v0, 0x24(s1)\n+\tlw      v1, 0x20(s1)\n+\tslt     at, s2, v0\n+\tbnez    at, loc_8F11C\n+\tslt     at, v1, s2\n+\tbnez    at, loc_8F11C\n+\tlw      v1, 0x1C(s1)\n+\tlh      v0, 0x28(s1)\n+\taddiu   at, v1, 0x400\n+\tslt     at, s4, at\n+\tbnez    at, loc_8F11C\n+\taddiu   v0, -1\n+\tsll     v0, 10\n+\taddu    v0, v1, v0\n+\tslt     v0, v0, s4\n+\tbnez    v0, loc_8F11C\n+\tlw      v1, 0x14(s1)\n+\tlh      v0, 0x2A(s1)\n+\taddiu   at, v1, 0x400\n+\tslt     at, s3, at\n+\tbnez    at, loc_8F11C\n+\taddiu   v0, -1\n+\tsll     v0, 10\n+\taddu    v0, v1, v0\n+\tslt     v0, v0, s3\n+\tbnez    v0, loc_8F11C\n+\tnop\n+\tj       loc_8F07C\n+\tmove    v0, t0\n+\n+\tloc_8EFF4:\n+\tlw      v0, OutsideRoomTable-GP_ADDR(gp)\n+\tj       loc_8F108\n+\taddu    a0, v0, v1\n+\n+\tloc_8F000:\n+\taddu    v0, t0\n+\tlw      v1, room-GP_ADDR(gp)\n+\tsll     v0, 4\n+\taddu    s1, v1, v0\n+\tlw      v0, 0x24(s1)\n+\tlw      v1, 0x20(s1)\n+\tslt     at, s2, v0\n+\tbnez    at, loc_8F104\n+\tslt     at, v1, s2\n+\tbnez    at, loc_8F104\n+\tlw      v1, 0x1C(s1)\n+\tlh      v0, 0x28(s1)\n+\taddiu   at, v1, 0x400\n+\tslt     at, s4, at\n+\tbnez    at, loc_8F104\n+\taddiu   v0, -1\n+\tsll     v0, 10\n+\taddu    v0, v1, v0\n+\tslt     v0, v0, s4\n+\tbnez    v0, loc_8F104\n+\tlw      v1, 0x14(s1)\n+\tlh      v0, 0x2A(s1)\n+\taddiu   at, v1, 0x400\n+\tslt     at, s3, at\n+\tbnez    at, loc_8F104\n+\taddiu   v0, -1\n+\tsll     v0, 10\n+\taddu    v0, v1, v0\n+\tslt     v0, v0, s3\n+\tbnez    v0, loc_8F104\n+\tandi    v0, t0, 0xFF\n+\n+\tloc_8F07C:\n+\tmove    a1, s2\n+\tmove    a0, s3\n+\tmove    a2, s4\n+\taddiu   a3, sp, 0x38-0x28\n+\tsh      v0, 0x38-0x28(sp)\n+\tjal     GetFloor\n+\tsh      v0, IsRoomOutsideNo-GP_ADDR(gp)\n+\tmove    s0, v0\n+\tmove    a0, s0\n+\tmove    a1, s3\n+\tmove    a2, s2\n+\tjal     GetHeight\n+\tmove    a3, s4\n+\tmove    v1, v0\n+\tli      v0, 0xFFFF8100\n+\tbeq     v1, v0, loc_8F11C\n+\tslt     v0, v1, s2\n+\tbnez    v0, loc_8F120\n+\tli      v0, 0xFFFFFFFE\n+\tmove    a0, s0\n+\tmove    a1, s3\n+\tmove    a2, s2\n+\tjal     GetCeiling\n+\tmove    a3, s4\n+\tslt     v0, s2, v0\n+\tbnez    v0, loc_8F11C\n+\tnop\n+\tlhu     v1, 0x4E(s1)\n+\tnop\n+\tandi    v1, 0x21\n+\tbnez    v1, loc_8F120\n+\tli      v0, 1\n+\tj       loc_8F120\n+\tli      v0, 0xFFFFFFFD\n+\n+\tloc_8F104:\n+\taddiu   a0, 1\n+\n+\tloc_8F108:\n+\tlbu     t0, 0(a0)\n+\tli      v0, 0xFF\n+\tandi    v1, t0, 0xFF\n+\tbne     v1, v0, loc_8F000\n+\tsll     v0, t0, 2\n+\n+\tloc_8F11C:\n+\tli      v0, 0xFFFFFFFE\n+\n+\tloc_8F120:\n+\tlw      ra, 0x38-0x4(sp)\n+\tlw      s4, 0x38-0x8(sp)\n+\tlw      s3, 0x38-0xC(sp)\n+\tlw      s2, 0x38-0x10(sp)\n+\tlw      s1, 0x38-0x14(sp)\n+\tlw      s0, 0x38-0x18(sp)\n+\tjr      ra\n+\taddiu   sp, 0x38\n \t\n GetJointAbsPosition:\n \taddiu   sp, -0x50\ndiff --git a/SPEC_PSX/SPUSOUND.H b/SPEC_PSX/SPUSOUND.H\nindex f5d55956..6d95d98d 100644\n--- a/SPEC_PSX/SPUSOUND.H\n+++ b/SPEC_PSX/SPUSOUND.H\n@@ -1,8 +1,6 @@\n #ifndef SPUSOUND_H\n #define SPUSOUND_H\n \n-#include "SPECTYPES.H"\n-\n #include <LIBSPU.H>\n \n #define MAX_NUM_SOUND_EFFECTS 256\n@@ -15,7 +13,7 @@ extern SpuVoiceAttr sva;\n extern unsigned char LabSampleType[];\n extern unsigned char LabFreeChannel[];\n extern int LnFreeChannels;\n-extern unsigned long LadwSampleAddr[256];\n+extern unsigned long LadwSampleAddr[];\n \n extern void SPU_FreeSamples();\n extern void SPU_Init();\ndiff --git a/SPEC_PSX/TEXT_S.H b/SPEC_PSX/TEXT_S.H\nindex a80fa461..4403adf1 100644\n--- a/SPEC_PSX/TEXT_S.H\n+++ b/SPEC_PSX/TEXT_S.H\n@@ -3,6 +3,7 @@\n \n #include "TYPES.H"\n \n+extern void UpdatePulseColour();\n extern long GetStringLength(char* string, unsigned short* a1, unsigned short* a2);\n extern void GetStringDimensions(char* string, unsigned short* w, unsigned short* h);\n extern void DrawChar(unsigned short a0, unsigned short a1, unsigned short a2, struct CHARDEF* a3);\ndiff --git a/SPEC_PSX/TEXT_S.MIP b/SPEC_PSX/TEXT_S.MIP\nindex 422113b3..50913e91 100644\n--- a/SPEC_PSX/TEXT_S.MIP\n+++ b/SPEC_PSX/TEXT_S.MIP\n@@ -1,14 +1,42 @@\n \topt at-,w-,c+,m-\n \n-\tSECTION\t.ASM\n+\tSECTION\tASM\n \tINCLUDE\tSPEC_PSX/GLOBAL.INC\n-\tXDEF PrintString, DrawChar, GetStringLength, GetStringDimensions\n-\tXREF FontShades, phd_mxptr, MatrixStack, Matrix, MatrixSP, AccentTable, LaSlot, CharDef, sound_active, sample_infos, sample_lut, ScaleFlag, GnFrameCounter, db, S_SoundStopSample, db.ot\n+\tXDEF UpdatePulseColour, PrintString, DrawChar, GetStringLength, GetStringDimensions\n+\tXREF PulseCnt, FontShades, phd_mxptr, MatrixStack, Matrix, MatrixSP, AccentTable, LaSlot, CharDef, sound_active, sample_infos, sample_lut, ScaleFlag, GnFrameCounter, db, S_SoundStopSample, db.ot\n \n aUEAAAAEEEAAEOO equ 0\n loc_92020 equ 0\n word_9230E equ 0\n \n+UpdatePulseColour:\n+\tlbu     a0, PulseCnt-GP_ADDR(gp)\n+\tla      v1, FontShades\n+\taddiu   a0, 1\n+\tandi    a0, 0x1F\n+\tsltiu   at, a0, 0x10\n+\tbnez    at, loc_8E11C\n+\tsb      a0, PulseCnt-GP_ADDR(gp)\n+\tnegu    a0, a0\n+\n+\tloc_8E11C:\n+\tsll     a0, 3\n+\tandi    a0, 0xFF\n+\tsll     at, a0, 8\n+\tor      v0, a0, at\n+\tsll     at, a0, 16\n+\tor      v0, at\n+\tli      a1, 0xF\n+\n+\tloc_8E138:\n+\tsw      v0, 0x40(v1)\n+\tsw      a2, 0x240(v1)\n+\taddiu   a1, -1\n+\tbgez    a1, loc_8E138\n+\taddiu   v1, 4\n+\tjr      ra\n+\tnop\n+\n PrintString:\n \taddiu   sp, -0x40\n \tsw      s0, 0x40-0x20(sp)\ndiff --git a/SPEC_PSX/TITSEQ.C b/SPEC_PSX/TITSEQ.C\nnew file mode 100644\nindex 00000000..710947ac\n--- /dev/null\n+++ b/SPEC_PSX/TITSEQ.C\n@@ -0,0 +1,6 @@\n+#include "TITSEQ.H"\n+\n+int TitleOptions(int Name)\n+{\n+\treturn 0;\n+}\ndiff --git a/SPEC_PSX/TITSEQ.H b/SPEC_PSX/TITSEQ.H\nnew file mode 100644\nindex 00000000..5ce14216\n--- /dev/null\n+++ b/SPEC_PSX/TITSEQ.H\n@@ -0,0 +1,5 @@\n+#ifndef TITSEQ_H\n+#define TITSEQ_H\n+\n+extern int TitleOptions(int Name);\n+#endif\n\\ No newline at end of file\ndiff --git a/SPEC_PSXPC/3D_GEN.C b/SPEC_PSXPC/3D_GEN.C\nindex 03f0e5f6..73462bea 100644\n--- a/SPEC_PSXPC/3D_GEN.C\n+++ b/SPEC_PSXPC/3D_GEN.C\n@@ -6,8 +6,6 @@\n #include "SPECIFIC.H"\n #include "TYPES.H"\n \n-#include <assert.h>\n-\n long phd_left;\n long phd_right;\n long phd_top;\ndiff --git a/SPEC_PSXPC/MALLOC.C b/SPEC_PSXPC/MALLOC.C\nindex 654b1285..10f7dcf4 100644\n--- a/SPEC_PSXPC/MALLOC.C\n+++ b/SPEC_PSXPC/MALLOC.C\n@@ -7,7 +7,7 @@\n #include <stdio.h>\n #include <string.h>\n \n-#define GAME_MALLOC_BUFFER_SIZE (1024*1024) + (1024*36)\n+#define GAME_MALLOC_BUFFER_SIZE (1024*1060)\n \n char* malloc_ptr = NULL;\n int malloc_used = 0;\ndiff --git a/SPEC_PSXPC/MISC.C b/SPEC_PSXPC/MISC.C\nindex c56a9860..33615449 100644\n--- a/SPEC_PSXPC/MISC.C\n+++ b/SPEC_PSXPC/MISC.C\n@@ -1,5 +1,5 @@\n #include "MISC.H"\n-\n+#include "CONTROL.H"\n #include "CAMERA.H"\n #include "GPU.H"\n #include "LOAD_LEV.H"\n@@ -275,3 +275,25 @@ void S_AnimateTextures(long nFrames)\n {\n \tS_Warn("[S_AnimateTextures] - Unimplemented!\\n");\n }\n+\n+long GetRandomControl()//5E9F0, 926F8 (F)\n+{\n+\trand_1 = (rand_1 * 0x41C64E6D) + 0x3039;\n+\treturn (rand_1 >> 16) & 0x7FFF;\n+}\n+\n+void SeedRandomControl(long seed)//(F)\n+{\n+\trand_1 = seed;\n+}\n+\n+long GetRandomDraw()//5EA18, 5F6F8 (F)\n+{\n+\trand_2 = (rand_2 * 0x41C64E6D) + 0x3039;\n+\treturn (rand_2 >> 16) * 0x7FFF;\n+}\n+\n+void SeedRandomDraw(long seed)//(F)\n+{\n+\trand_2 = seed;\n+}\ndiff --git a/SPEC_PSXPC/MISC.H b/SPEC_PSXPC/MISC.H\nindex bef728c5..e2e422bc 100644\n--- a/SPEC_PSXPC/MISC.H\n+++ b/SPEC_PSXPC/MISC.H\n@@ -21,5 +21,9 @@ extern void GPU_SetScreenPosition(short x, short y);\n extern void GPU_SyncBothScreens();\n extern void GPU_FlipToBuffer(int buffer_index);\n extern void S_AnimateTextures(long nFrames);\n+extern long GetRandomControl();\n+extern void SeedRandomControl(long seed);\n+extern long GetRandomDraw();\n+extern void SeedRandomDraw(long seed);\n \n #endif\n\\ No newline at end of file\ndiff --git a/SPEC_PSXPC/TITSEQ.C b/SPEC_PSXPC/TITSEQ.C\nnew file mode 100644\nindex 00000000..710947ac\n--- /dev/null\n+++ b/SPEC_PSXPC/TITSEQ.C\n@@ -0,0 +1,6 @@\n+#include "TITSEQ.H"\n+\n+int TitleOptions(int Name)\n+{\n+\treturn 0;\n+}\ndiff --git a/SPEC_PSXPC/TITSEQ.H b/SPEC_PSXPC/TITSEQ.H\nindex b334b0ba..5ce14216 100644\n--- a/SPEC_PSXPC/TITSEQ.H\n+++ b/SPEC_PSXPC/TITSEQ.H\n@@ -1,4 +1,5 @@\n-#ifndef TITLESEQ_H\n-#define TITLESEQ_H\n+#ifndef TITSEQ_H\n+#define TITSEQ_H\n \n+extern int TitleOptions(int Name);\n #endif\n\\ No newline at end of file\ndiff --git a/TOOLS/CMakeLists.txt b/TOOLS/CMakeLists.txt\nindex 322c19a2..9f118fbf 100644\n--- a/TOOLS/CMakeLists.txt\n+++ b/TOOLS/CMakeLists.txt\n@@ -7,7 +7,7 @@ get_filename_component(ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)\n \n set(SPEC_PSX_DIR ${ROOT_DIR}/SPEC_PSX "${SPEC_PSX_DIR}")\n set(SPEC_PSXPC_DIR ${ROOT_DIR}/SPEC_PSXPC "${SPEC_PSXPC_DIR}")\n-set(SPEC_PC_DIR ${ROOT_DIR}/SPEC_PC "${SPEC_PC_DIR}")\n+set(SPEC_PC_DIR ${ROOT_DIR}/SPEC_PC_N "${SPEC_PC_DIR}")\n \n #Add each tool project\n if(NOT(DEFINED ENV{TRAVIS} OR DEFINED ENV{APPVEYOR}))\ndiff --git a/TOOLS/CODEWAD_Pack/CODEWAD.CPP b/TOOLS/CODEWAD_Pack/CODEWAD.CPP\nindex 3d4f2c6d..3e74e6bb 100644\n--- a/TOOLS/CODEWAD_Pack/CODEWAD.CPP\n+++ b/TOOLS/CODEWAD_Pack/CODEWAD.CPP\n@@ -46,6 +46,8 @@ void CODEWAD_Pack(const char* fileName)\n \t\t\treturn;\n \t\t}\n \t\t\n+\t\tentry->moduleIndex = moduleIndices[i];\n+\n \t\tcurrentOffset = (currentOffset + (CD_SECTOR_SIZE - 1) & ~(CD_SECTOR_SIZE - 1));\n \t\tentry->binData[0] = currentOffset;\n \t\tentry->binData[1] = readerBin.m_length;\ndiff --git a/TOOLS/CODEWAD_Pack/CODEWAD.H b/TOOLS/CODEWAD_Pack/CODEWAD.H\nindex 46454b46..8b05feb8 100644\n--- a/TOOLS/CODEWAD_Pack/CODEWAD.H\n+++ b/TOOLS/CODEWAD_Pack/CODEWAD.H\n@@ -10,7 +10,7 @@ struct fileEntry\n {\n \tunsigned int binData[2];//Offset, Size\n \tunsigned int relData[2];//Offset, Size\n-\tunsigned int padding;\n+\tunsigned int moduleIndex;\n };\n \n extern void CODEWAD_Pack(const char* fileName);\ndiff --git a/TOOLS/CODEWAD_Pack/FILES.CPP b/TOOLS/CODEWAD_Pack/FILES.CPP\nindex 9a45dff7..00713dab 100644\n--- a/TOOLS/CODEWAD_Pack/FILES.CPP\n+++ b/TOOLS/CODEWAD_Pack/FILES.CPP\n@@ -61,4 +61,67 @@ const char* cwFileNames[NUM_OVERLAYS] =\n \t"GAME\\\\JOBY5",\n \t"GAME\\\\LIFTS",\n \t"GAME\\\\T12",\n+};\n+\n+int moduleIndices[NUM_OVERLAYS] =\n+{\n+\t0,\n+\t0,\n+\t1,\n+\t1,\n+\t1,\n+\t1,\n+\t1,\n+\t2,\n+\t2,\n+\t2,\n+\t2,\n+\t3,\n+\t4,\n+\t5,\n+\t6,\n+\t7,\n+\t8,\n+\t9,\n+\t10,\n+\t11,\n+\t12,\n+\t13,\n+\t14,\n+\t15,\n+\t16,\n+\t17,\n+\t18,\n+\t19,\n+\t20,\n+\t21,\n+\t22,\n+\t23,\n+\t24,\n+\t25,\n+\t26,\n+\t27,\n+\t28,\n+\t29,\n+\t30,\n+\t31,\n+\t32,\n+\t33,\n+\t34,\n+\t35,\n+\t36,\n+\t37,\n+\t38,\n+\t39,\n+\t40,\n+\t41,\n+\t42,\n+\t43,\n+\t44,\n+\t45,\n+\t46,\n+\t47,\n+\t48,\n+\t49,\n+\t50\n };\n\\ No newline at end of file\ndiff --git a/TOOLS/CODEWAD_Pack/FILES.H b/TOOLS/CODEWAD_Pack/FILES.H\nindex d5d8a9ce..f481da50 100644\n--- a/TOOLS/CODEWAD_Pack/FILES.H\n+++ b/TOOLS/CODEWAD_Pack/FILES.H\n@@ -2,5 +2,6 @@\n #define FILES_H\n \n extern const char* cwFileNames[];\n+extern int moduleIndices[];\n \n #endif\n\\ No newline at end of file\ndiff --git a/TOOLS/CODEWAD_Unpack/CODEWAD.CPP b/TOOLS/CODEWAD_Unpack/CODEWAD.CPP\nindex ea643e42..fd3ff863 100644\n--- a/TOOLS/CODEWAD_Unpack/CODEWAD.CPP\n+++ b/TOOLS/CODEWAD_Unpack/CODEWAD.CPP\n@@ -35,12 +35,12 @@ void CODEWAD_Unpack(const char* fileName)\n \t\tstrcat(&nameBin[0], ".BIN"); \n \t\tstrcat(&nameRel[0], ".REL"); \n \n-\t\tprintf("Name: %s, Name: %s\\n", &nameBin[0], &nameRel[0]);\n+\t\tprintf("Name: %s, Name: %s Index: %i\\n", &nameBin[0], &nameRel[0], entry[i].moduleIndex);\n \n \t\tCODEWAD_DumpOverlay(&nameBin[0], &reader, &entry[i].binData[0]);\n \t\tCODEWAD_DumpOverlay(&nameRel[0], &reader, &entry[i].relData[0]);\n \n-\t\tprintf("Offset: %i, Size: %i\\n", entry[i].binData[0], entry[i].binData[1]);\n+\t\tprintf("Offset: %i, Size: %i Index: %i\\n", entry[i].binData[0], entry[i].binData[1], entry[i].moduleIndex);\n \t}\n \n \treader.close();\ndiff --git a/TOOLS/CODEWAD_Unpack/CODEWAD.H b/TOOLS/CODEWAD_Unpack/CODEWAD.H\nindex ced7c338..65851893 100644\n--- a/TOOLS/CODEWAD_Unpack/CODEWAD.H\n+++ b/TOOLS/CODEWAD_Unpack/CODEWAD.H\n@@ -10,7 +10,7 @@ struct fileEntry\n {\n \tunsigned int binData[2];//Offset, Size\n \tunsigned int relData[2];//Offset, Size\n-\tunsigned int padding;\n+\tunsigned int moduleIndex;\n };\n \n extern void CODEWAD_Unpack(const char* fileName);\n', 'commit_subject': "Merge branch 'master' of https://github.com/TOMB5/TOMB5 into appveyor", 'repo_name': 'TOMB5/TOMB5', 'committer': {'name': 'Gh0stBlade', 'email': '19ffcc48b5297ad4998e7ea4f40eaa34eefb03dd@users.noreply.github.com', 'time_sec': '1542555904', 'tz_offset': '0', 'date': {'seconds': '1542555904'}}, 'commit_tree': '80d266b0da4b58ea3c98c2b509f3631538cc6c2b', 'commit_message': "Merge branch 'master' of https://github.com/TOMB5/TOMB5 into appveyor\n", 'language_name': 'C', 'license': 'mit', 'hunks': '@@ -10,7 +10,7 @@ struct fileEntry\n {\n \tunsigned int binData[2];//Offset, Size\n \tunsigned int relData[2];//Offset, Size\n-\tunsigned int padding;\n+\tunsigned int moduleIndex;\n };\n \n extern void CODEWAD_Unpack(const char* fileName);\n', 'addition_count': 1, 'deletion_count': 1, 'src_file': 'a/TOOLS/CODEWAD_Unpack/CODEWAD.H', 'tgt_file': 'b/TOOLS/CODEWAD_Unpack/CODEWAD.H', 'file_extension': '.H', 'before_file': '#ifndef CODEWAD_H\n#define CODEWAD_H\n\n#include <stdio.h>\n#include "IO.H"\n\n#define NUM_OVERLAYS 59\n\nstruct fileEntry\n{\n\tunsigned int binData[2];//Offset, Size\n\tunsigned int relData[2];//Offset, Size\n\tunsigned int padding;\n};\n\nextern void CODEWAD_Unpack(const char* fileName);\nextern void CODEWAD_DumpOverlay(char* fileName, IO::StreamReader* reader, unsigned int* entry);\n\n#endif', 'message': "Merge branch 'master' of https://github.com/TOMB5/TOMB5 into appveyor\n", 'author_name': 'Gh0stBlade', 'lang': 'H'}