Skip to content

Commit

Permalink
port CreateStartInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Mar 9, 2021
1 parent 59e7d60 commit fbda274
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 8 deletions.
12 changes: 6 additions & 6 deletions docs/progress.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ WriteSGLara ---------- ---------- -
LoadSaveGameInfo ---------- ---------- -
InitialiseStartInfo 0x004344D0 0x00000042 +
ModifyStartInfo 0x00434520 0x000000BF +
CreateStartInfo 0x004345E0 0x00000139 *
CreateStartInfo 0x004345E0 0x00000139 +
CreateSaveGameInfo 0x00434720 0x00000866 *
ExtractSaveGameInfo 0x00434F90 0x00000971 *
ResetSG ---------- ---------- -
Expand Down
53 changes: 53 additions & 0 deletions src/game/savegame.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "game/inv.h"
#include "game/savegame.h"
#include "game/vars.h"
#include "util.h"
Expand Down Expand Up @@ -75,8 +76,60 @@ void ModifyStartInfo(int32_t level_num)
}
}

void CreateStartInfo(int level_num)
{
START_INFO *start = &SaveGame[0].start[level_num];

start->available = 1;
start->costume = 0;

start->pistol_ammo = 1000;
if (Inv_RequestItem(O_GUN_ITEM)) {
start->got_pistols = 1;
} else {
start->got_pistols = 0;
}

if (Inv_RequestItem(O_MAGNUM_ITEM)) {
start->magnum_ammo = Lara.magnums.ammo;
start->got_magnums = 1;
} else {
start->magnum_ammo = Inv_RequestItem(O_MAG_AMMO_ITEM) * MAGNUM_AMMO_QTY;
start->got_magnums = 0;
}

if (Inv_RequestItem(O_UZI_ITEM)) {
start->uzi_ammo = Lara.uzis.ammo;
start->got_uzis = 1;
} else {
start->uzi_ammo = Inv_RequestItem(O_UZI_AMMO_ITEM) * UZI_AMMO_QTY;
start->got_uzis = 0;
}

if (Inv_RequestItem(O_SHOTGUN_ITEM)) {
start->shotgun_ammo = Lara.shotgun.ammo;
start->got_shotgun = 1;
} else {
start->shotgun_ammo =
Inv_RequestItem(O_SG_AMMO_ITEM) * SHOTGUN_AMMO_QTY;
start->got_shotgun = 0;
}

start->num_medis = Inv_RequestItem(O_MEDI_ITEM);
start->num_big_medis = Inv_RequestItem(O_BIGMEDI_ITEM);
start->num_scions = Inv_RequestItem(O_SCION_ITEM);

start->gun_type = Lara.gun_type;
if (Lara.gun_status == LGS_READY) {
start->gun_status = LGS_READY;
} else {
start->gun_status = LGS_ARMLESS;
}
}

void T1MInjectGameSaveGame()
{
INJECT(0x004344D0, InitialiseStartInfo);
INJECT(0x00434520, ModifyStartInfo);
INJECT(0x004345E0, CreateStartInfo)
}
2 changes: 1 addition & 1 deletion src/game/savegame.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
#include <stdint.h>

// clang-format off
#define CreateStartInfo ((void (*)(int32_t level_num))0x004345E0)
#define CreateSaveGameInfo ((void (*)())0x00434720)
#define ExtractSaveGameInfo ((void (*)())0x00434F90)
// clang-format on

void InitialiseStartInfo();
void ModifyStartInfo(int32_t level_num);
void CreateStartInfo(int level_num);

void T1MInjectGameSaveGame();

Expand Down

0 comments on commit fbda274

Please sign in to comment.