Skip to content

Commit

Permalink
port DoInventoryOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
rr- committed Mar 7, 2021
1 parent 18ecb01 commit 50968fc
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 58 deletions.
60 changes: 30 additions & 30 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.
33 changes: 17 additions & 16 deletions docs/progress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ LaraFloorFront ---------- ---------- +
LaraLandedBad 0x00425D70 0x000000BE +

# lara1gun.cpp
draw_shotgun 0x00425E30 0x00000113 +
undraw_shotgun 0x00425F50 0x00000160 +
DrawShotgun 0x00425E30 0x00000113 +
UndrawShotgun 0x00425F50 0x00000160 +
draw_shotgun_meshes ---------- ---------- +
undraw_shotgun_meshes ---------- ---------- +
ready_shotgun ---------- ---------- +
Expand All @@ -569,10 +569,10 @@ AnimateShotgun ---------- ---------- +
FireShotgun ---------- ---------- +

# lara2gun.cpp
draw_pistols 0x00426470 0x00000147 +
undraw_pistols 0x004265C0 0x00000261 +
DrawPistols 0x00426470 0x00000147 +
UndrawPistols 0x004265C0 0x00000261 +
ready_pistols ---------- ---------- +
draw_pistol_meshes 0x00426830 0x00000061 +
DrawPistolMeshes 0x00426830 0x00000061 +
undraw_pistol_mesh_left ---------- ---------- +
undraw_pistol_mesh_right ---------- ---------- +
PistolHandler 0x004268A0 0x0000012E +
Expand Down Expand Up @@ -723,22 +723,23 @@ EarthQuakeControl 0x0042D700 0x0000006F +

# option.cpp
GetScancodeName ---------- ---------- -
do_inventory_options 0x0042D770 0x00000180 *
do_passport_option 0x0042D9C0 0x000004D0 -
do_detail_option_hw 0x0042DE90 0x00000435 -
do_detail_option 0x0042E2D0 0x000002E8 -
do_sound_option 0x0042E5C0 0x000004F2 -
do_compass_option ---------- ---------- -
DoInventoryOptions 0x0042D770 0x00000180 +
DoPassportOption 0x0042D9C0 0x000004D0 *
DoGammaOption ---------- ---------- +
DoDetailOptionHW 0x0042DE90 0x00000435 -
DoDetailOption 0x0042E2D0 0x000002E8 -
DoSoundOption 0x0042E5C0 0x000004F2 -
DoCompassOption ---------- ---------- +
FlashConflicts ---------- ---------- -
DefaultConflict ---------- ---------- -
do_control_option 0x0042EAC0 0x0000075D -
DoControlOption 0x0042EAC0 0x0000075D -
S_ShowControls 0x0042F230 0x000004B1 +
S_ChangeCtrlText ---------- ---------- -
S_RemoveCtrlText ---------- ---------- -
S_RemoveCtrl ---------- ---------- -
Init_Requester ---------- ---------- -
Remove_Requester ---------- ---------- -
Display_Requester 0x0042F6F0 0x0000056B -
InitRequester ---------- ---------- -
RemoveRequester ---------- ---------- -
DisplayRequester 0x0042F6F0 0x0000056B *

# shell/output.cpp
S_InitialisePolyList 0x0042FC60 0x00000005 *
Expand Down Expand Up @@ -962,7 +963,7 @@ sub_43D5F0 0x0043D5F0 0x00000176 -
ShowFatalError 0x0043D770 0x00000147 *
KeyboardHook(x,x,x) 0x0043D8C0 0x00000077 -
sub_43D940 0x0043D940 0x00000136 -
WinMain(x,x,x,x) 0x0043DA80 0x0000037D -
WinMain 0x0043DA80 0x0000037D -
WndProc 0x0043DE00 0x0000011F -

# wolf.cpp
Expand Down
20 changes: 10 additions & 10 deletions src/game/inventry.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,19 +254,19 @@ int32_t Display_Inventory(int inv_mode)
case RNG_OPEN:
if (CHK_ANY(Input, IN_RIGHT) && ring.number_of_objects > 1) {
Inv_RingRotateLeft(&ring);
SoundEffect(108, 0, SFX_ALWAYS);
SoundEffect(108, NULL, SFX_ALWAYS);
break;
}

if (CHK_ANY(Input, IN_LEFT) && ring.number_of_objects > 1) {
Inv_RingRotateRight(&ring);
SoundEffect(108, 0, SFX_ALWAYS);
SoundEffect(108, NULL, SFX_ALWAYS);
break;
}

if ((ResetFlag || CHK_ANY(InputDB, IN_OPTION))
&& (ResetFlag || InventoryMode != INV_TITLE_MODE)) {
SoundEffect(112, 0, SFX_ALWAYS);
SoundEffect(112, NULL, SFX_ALWAYS);
InventoryChosen = -1;

if (ring.type == RT_MAIN) {
Expand Down Expand Up @@ -325,26 +325,26 @@ int32_t Display_Inventory(int inv_mode)

switch (inv_item->object_number) {
case O_MAP_OPTION:
SoundEffect(113, 0, SFX_ALWAYS);
SoundEffect(113, NULL, SFX_ALWAYS);
break;

case O_PHOTO_OPTION:
SoundEffect(109, 0, SFX_ALWAYS);
SoundEffect(109, NULL, SFX_ALWAYS);
break;

case O_CONTROL_OPTION:
SoundEffect(110, 0, SFX_ALWAYS);
SoundEffect(110, NULL, SFX_ALWAYS);
break;

case O_GUN_OPTION:
case O_SHOTGUN_OPTION:
case O_MAGNUM_OPTION:
case O_UZI_OPTION:
SoundEffect(114, 0, SFX_ALWAYS);
SoundEffect(114, NULL, SFX_ALWAYS);
break;

default:
SoundEffect(111, 0, SFX_ALWAYS);
SoundEffect(111, NULL, SFX_ALWAYS);
break;
}
}
Expand Down Expand Up @@ -506,7 +506,7 @@ int32_t Display_Inventory(int inv_mode)
}

if (!busy && !IDelay) {
do_inventory_options(inv_item);
DoInventoryOptions(inv_item);

if (CHK_ANY(InputDB, IN_DESELECT)) {
inv_item->sprlist = NULL;
Expand Down Expand Up @@ -552,7 +552,7 @@ int32_t Display_Inventory(int inv_mode)
}

case RNG_DESELECT:
SoundEffect(112, 0, SFX_ALWAYS);
SoundEffect(112, NULL, SFX_ALWAYS);
Inv_RingMotionSetup(
&ring, RNG_DESELECTING, RNG_OPEN, SELECTING_FRAMES);
Inv_RingMotionRotation(
Expand Down
131 changes: 131 additions & 0 deletions src/game/option.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,128 @@
#include "game/effects.h"
#include "game/game.h"
#include "game/option.h"
#include "game/text.h"
#include "game/vars.h"
#include "specific/output.h"
#include "config.h"
#include "util.h"

#define GAMMA_MODIFIER 8
#define MIN_GAMMA_LEVEL -127
#define MAX_GAMMA_LEVEL 127

// original name: do_inventory_options
void DoInventoryOptions(INVENTORY_ITEM* inv_item)
{
switch (inv_item->object_number) {
case O_PASSPORT_OPTION:
DoPassportOption(inv_item);
break;

case O_MAP_OPTION:
DoCompassOption(inv_item);
break;

case O_DETAIL_OPTION:
DoDetailOption(inv_item);
break;

case O_SOUND_OPTION:
DoSoundOption(inv_item);
break;

case O_CONTROL_OPTION:
DoControlOption(inv_item);
break;

case O_GAMMA_OPTION:
DoGammaOption(inv_item);
break;

case O_GUN_OPTION:
case O_SHOTGUN_OPTION:
case O_MAGNUM_OPTION:
case O_UZI_OPTION:
case O_EXPLOSIVE_OPTION:
case O_MEDI_OPTION:
case O_BIGMEDI_OPTION:
case O_PUZZLE_OPTION1:
case O_PUZZLE_OPTION2:
case O_PUZZLE_OPTION3:
case O_PUZZLE_OPTION4:
case O_KEY_OPTION1:
case O_KEY_OPTION2:
case O_KEY_OPTION3:
case O_KEY_OPTION4:
case O_PICKUP_OPTION1:
case O_PICKUP_OPTION2:
case O_SCION_OPTION:
InputDB |= IN_SELECT;
break;

case O_GUN_AMMO_OPTION:
case O_SG_AMMO_OPTION:
case O_MAG_AMMO_OPTION:
case O_UZI_AMMO_OPTION:
break;

default:
if (CHK_ANY(InputDB, (IN_DESELECT | IN_SELECT))) {
inv_item->goal_frame = 0;
inv_item->anim_direction = -1;
}
break;
}
}

// original name: do_gamma_option
void DoGammaOption(INVENTORY_ITEM* inv_item)
{
if (CHK_ANY(Input, IN_LEFT)) {
IDelay = 1;
IDCount = 10;
OptionGammaLevel -= GAMMA_MODIFIER;
if (OptionGammaLevel < MIN_GAMMA_LEVEL) {
OptionGammaLevel = MIN_GAMMA_LEVEL;
}
}
if (CHK_ANY(Input, IN_RIGHT)) {
IDCount = 10;
IDelay = 1;
OptionGammaLevel += GAMMA_MODIFIER;
if (OptionGammaLevel > MAX_GAMMA_LEVEL) {
OptionGammaLevel = MAX_GAMMA_LEVEL;
}
}
inv_item->sprlist = InvSprGammaList;
InvSprGammaLevel[6].param1 = OptionGammaLevel / 2 + 63;
// S_SetGamma(OptionGammaLevel);

if (CHK_ANY(InputDB, IN_SELECT)) {
inv_item->goal_frame = 0;
inv_item->anim_direction = -1;
}

if (CHK_ANY(InputDB, IN_DESELECT)) {
int32_t gamma = OptionGammaLevel - 64;
if (gamma < -255) {
gamma = -255;
}
if (InventoryMode != INV_TITLE_MODE) {
// S_SetBackgroundGamma(gamma);
}
}
}

// original name: do_compass_option
void DoCompassOption(INVENTORY_ITEM* inv_item)
{
if (CHK_ANY(InputDB, IN_DESELECT | IN_SELECT)) {
inv_item->goal_frame = inv_item->frames_total - 1;
inv_item->anim_direction = 1;
}
}

void S_ShowControls()
{
#ifdef T1M_FEAT_UI
Expand Down Expand Up @@ -147,7 +265,20 @@ void S_ShowControls()
}
}

// original name: Init_Requester
void InitRequester(REQUEST_INFO* req)
{
req->heading = NULL;
req->background = NULL;
req->moreup = NULL;
req->moredown = NULL;
for (int i = 0; i < MAX_REQLINES; i++) {
req->texts[i] = NULL;
}
}

void T1MInjectGameOption()
{
INJECT(0x0042D770, DoInventoryOptions);
INJECT(0x0042F230, S_ShowControls);
}
9 changes: 8 additions & 1 deletion src/game/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,16 @@
#include "game/types.h"

// clang-format off
#define do_inventory_options ((void (*)(INVENTORY_ITEM* inv_item))0x0042D770)
#define DoPassportOption ((void (*)(INVENTORY_ITEM* inv_item))0x0042D9C0)
#define DoDetailOption ((void (*)(INVENTORY_ITEM* inv_item))0x0042E2D0)
#define DoSoundOption ((void (*)(INVENTORY_ITEM* inv_item))0x0042E5C0)
#define DoControlOption ((void (*)(INVENTORY_ITEM* inv_item))0x0042EAC0)
#define DisplayRequester ((int32_t (*)(REQUEST_INFO* req))0x0042F6F0)
// clang-format on

void DoInventoryOptions(INVENTORY_ITEM* inv_item);
void DoGammaOption(INVENTORY_ITEM* inv_item);
void DoCompassOption(INVENTORY_ITEM* inv_item);
void S_ShowControls();

void T1MInjectGameOption();
Expand Down
8 changes: 7 additions & 1 deletion src/game/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1407,7 +1407,13 @@ typedef struct {
/* 0014 */ int32_t item_heading;
/* 0018 */ char* item_texts;
/* 001C */ int16_t item_text_len;
/* 0020 end */
/* 001E */ TEXTSTRING* heading;
/* 0022 */ TEXTSTRING* background;
/* 0026 */ TEXTSTRING* moreup;
/* 002A */ TEXTSTRING* moredown;
/* 002E */ TEXTSTRING* texts[MAX_REQLINES];
/* 006E */ int16_t flags[MAX_REQLINES];
/* 008E end */
} REQUEST_INFO;

typedef struct {
Expand Down
3 changes: 3 additions & 0 deletions src/game/vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
#define ControlText ARRAY_(0x0045A2F8, TEXTSTRING*, [2])
#define ScanCodeNames ARRAY_(0x00454A40, char*, [])
#define OptionMusicVolume VAR_I_(0x00456334, int32_t, 255)
#define OptionGammaLevel VAR_U_(0x0045A0A0, int16_t)
#define CDFlags ARRAY_(0x00462C20, int16_t, [MAX_CD_TRACKS])
#define FlipMapTable ARRAY_(0x00462CC0, int32_t, [MAX_FLIP_MAPS])
#define Cine VAR_U_(0x00462CF4, int16_t*)
Expand Down Expand Up @@ -229,6 +230,8 @@
#define IShotgunAmmoOption VAR_U_(0x004558E0, INVENTORY_ITEM)
#define IMagnumAmmoOption VAR_U_(0x00455920, INVENTORY_ITEM)
#define IUziAmmoOption VAR_U_(0x00455960, INVENTORY_ITEM)
#define InvSprGammaLevel ARRAY_(0x00455218, INVENTORY_SPRITE, [10])
#define InvSprGammaList ARRAY_(0x004552F8, INVENTORY_SPRITE*, [])

// clang-format on

Expand Down

0 comments on commit 50968fc

Please sign in to comment.