Add tests for controller fire attempt suppression and usecode interpreter functionality
- Enhanced isometric_controls_tests.cpp to include assertions for controller fire attempt suppression under various conditions. - Added tests for the Usecode interpreter in usecode_vm_tests.cpp, verifying script execution and stack manipulation. - Introduced a new PowerShell script, clean-old-build-artifacts.ps1, to facilitate the cleanup of old build artifacts in specified directories.
This commit is contained in:
parent
49a15602b6
commit
ffb1918f35
41 changed files with 3611 additions and 349 deletions
|
|
@ -44,6 +44,8 @@ struct StagedContainedFixedMapItem {
|
|||
FixedMapEntry data;
|
||||
};
|
||||
|
||||
constexpr u16 liveItemEtherealFlag = 0x0800;
|
||||
|
||||
struct ItemFindArea {
|
||||
u16 minX = 0;
|
||||
u16 minY = 0;
|
||||
|
|
@ -129,6 +131,12 @@ public:
|
|||
std::optional<std::vector<u16>> sweepCandidateIds(const WorldRect& area, u16 excludedItemNumber) const;
|
||||
std::optional<u16> allocateItem(StagedFixedMapItem item);
|
||||
bool insertItem(StagedFixedMapItem item);
|
||||
bool pushItemToEtherealVoid(u16 itemNumber);
|
||||
std::optional<u16> popItemFromEtherealVoid();
|
||||
std::optional<u16> popItemToCoords(u16 x, u16 y, u8 z);
|
||||
bool destroyItem(u16 itemNumber);
|
||||
bool canCreateItemAt(u16 shape, u16 x, u16 y, u8 z,
|
||||
const std::vector<ShapeTypeInfo>& shapes) const;
|
||||
bool moveItemIntoContainer(u16 itemNumber, u16 containerItemNumber,
|
||||
const std::vector<ShapeTypeInfo>& shapes);
|
||||
bool moveContainedItemToWorld(u16 itemNumber, u16 x, u16 y, u8 z);
|
||||
|
|
@ -153,6 +161,7 @@ private:
|
|||
std::optional<StagedFixedMapItem> avatar_;
|
||||
std::vector<NpcAnimationState> npcAnimations_;
|
||||
std::vector<bool> allocatedIds_;
|
||||
std::vector<bool> destroyedIds_;
|
||||
std::vector<bool> hatchedGlobIds_;
|
||||
std::vector<u16> parentById_;
|
||||
std::vector<std::optional<FixedMapEntry>> containedItemData_;
|
||||
|
|
@ -160,6 +169,7 @@ private:
|
|||
std::vector<u16> containedHeadById_;
|
||||
std::vector<u16> containedTailById_;
|
||||
std::vector<u16> freeItemIds_;
|
||||
std::vector<u16> etherealStack_;
|
||||
u16 nextFreeItemNumber_ = 0x100;
|
||||
};
|
||||
|
||||
|
|
|
|||
16
rebuild/remorse/include/remorse/game_start.h
Normal file
16
rebuild/remorse/include/remorse/game_start.h
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "remorse/compat.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace remorse {
|
||||
|
||||
class LiveFixedMapItems;
|
||||
class ProcessKernel;
|
||||
struct ShapeTypeInfo;
|
||||
|
||||
bool startFreshGameMapOne(ProcessKernel& kernel, LiveFixedMapItems& items,
|
||||
const std::vector<ShapeTypeInfo>& shapes, u16 (&groupCounts)[32]);
|
||||
|
||||
} // namespace remorse
|
||||
|
|
@ -25,6 +25,9 @@ inline bool controllerWalkRequested(u16 modifiers)
|
|||
return shiftDown == capsLockOn;
|
||||
}
|
||||
|
||||
bool controllerFireAttemptSuppressed(bool previousAttemptSlept, u8 scanCode,
|
||||
u8 eventMode, u8 keyState);
|
||||
|
||||
inline bool controllerAllowsInPlaceDirectionUpdate(u8 animation)
|
||||
{
|
||||
switch (animation) {
|
||||
|
|
@ -112,6 +115,7 @@ struct ControllerActorState {
|
|||
bool kneeling = false;
|
||||
bool activeWeapon = false;
|
||||
bool busy = false;
|
||||
bool lastFireAttemptWentToSleep = false;
|
||||
bool lastAnimationNotCombat = true;
|
||||
bool avatarSomethingCombatty = false;
|
||||
};
|
||||
|
|
@ -144,6 +148,10 @@ public:
|
|||
if (eventMode == 0) {
|
||||
return;
|
||||
}
|
||||
if (controllerFireAttemptSuppressed(actor_.lastFireAttemptWentToSleep,
|
||||
scanCode, eventMode, keyState)) {
|
||||
return;
|
||||
}
|
||||
if (keyState != 0 && keyAction == 1 && actor_.npcNumber == 1 &&
|
||||
(scanCode == 0x0f || scanCode == 0x24)) {
|
||||
if (!actor_.busy || (actor_.lastAnimation != 56 &&
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ enum class UsecodeStepResult {
|
|||
|
||||
struct UsecodeOpcodeServices {
|
||||
std::function<std::optional<u16>(u16 offset, u16 segment)> readFarWord;
|
||||
std::function<std::optional<UsecodeEventBody>(u16 classId, u16 eventSlot)> callEvent;
|
||||
std::function<bool(u16 eventType, u16 sourceItem)> setInfo;
|
||||
std::function<u16()> processCount;
|
||||
std::function<std::optional<u16>(u16 classId, u16 eventSlot, u8 extraArgumentBytes,
|
||||
|
|
@ -58,18 +59,29 @@ struct UsecodeOpcodeServices {
|
|||
std::function<u16()> currentProcessId;
|
||||
};
|
||||
|
||||
struct UsecodeRoutineFrame {
|
||||
u16 classId = 0;
|
||||
u16 eventSlot = 0;
|
||||
std::vector<u8> code;
|
||||
std::vector<u8> frame;
|
||||
std::size_t frameBaseOffset = usecodeFrameBaseOffset;
|
||||
std::size_t returnProgramCounter = 0;
|
||||
};
|
||||
|
||||
class UsecodeInterpreterState {
|
||||
public:
|
||||
static std::optional<UsecodeInterpreterState> initialize(
|
||||
const std::vector<u8>& itemParameter, const std::vector<u8>& contextParameter = {},
|
||||
u16 modeFlags = 0, bool contextParameterPresent = false);
|
||||
bool pushCodeAddress(u16 offset, u16 segment);
|
||||
bool pushByte(u8 value);
|
||||
bool pushWord(u16 value);
|
||||
bool pushDword(u32 value);
|
||||
std::optional<u16> popWord();
|
||||
std::optional<u32> popDword();
|
||||
UsecodeStepResult step(const std::vector<u8>& code, std::size_t& programCounter,
|
||||
std::vector<u8>& frame, const UsecodeOpcodeServices& services);
|
||||
std::vector<u8>& frame, std::size_t frameBaseOffset,
|
||||
const UsecodeOpcodeServices& services);
|
||||
std::optional<std::array<u16, 2>> lastSetInfoOperands;
|
||||
|
||||
std::array<u8, 0xcc> valueStack{};
|
||||
|
|
@ -102,10 +114,14 @@ struct UsecodeProcessTask {
|
|||
std::vector<u8> itemMemory;
|
||||
UsecodeInterpreterState interpreter;
|
||||
std::size_t programCounter = usecodeEventBytecodeOffset;
|
||||
std::size_t frameBaseOffset = usecodeFrameBaseOffset;
|
||||
std::vector<UsecodeRoutineFrame> routineFrames;
|
||||
bool halted = false;
|
||||
bool timerDelayProcess = false;
|
||||
u32 wakeTick = 0;
|
||||
|
||||
std::optional<u16> readMappedFarWord(FarPtr16 address) const;
|
||||
bool writeMappedFarWord(FarPtr16 address, u16 value);
|
||||
std::optional<u16> readMappedItemWord(FarPtr16 address) const;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue