mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Moved engine func defines from various files to FalloutEngine.cpp
(HeroAppearance.cpp, Message.cpp, Sound.cpp)
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
#include "FalloutEngine.h"
|
||||
|
||||
#include "ExtraSaveSlots.h"
|
||||
#include "HeroAppearance.h"
|
||||
|
||||
//extern
|
||||
DWORD LSPageOffset = 0;
|
||||
@@ -120,7 +119,7 @@ void SetPageNum() {
|
||||
if (winRef == 0) {
|
||||
return;
|
||||
}
|
||||
WINinfo *SaveLoadWin = GetWinStruct(winRef);
|
||||
WINinfo *SaveLoadWin = GNWFind(winRef);
|
||||
if (SaveLoadWin->surface == nullptr) {
|
||||
return;
|
||||
}
|
||||
@@ -167,7 +166,7 @@ void SetPageNum() {
|
||||
WinDraw(winRef);
|
||||
}
|
||||
|
||||
button = check_buttons();
|
||||
button = GetInputBtn();
|
||||
if (button >= '0' && button <= '9') {
|
||||
if (numpos < 4) {
|
||||
Number[numpos] = button;
|
||||
@@ -264,7 +263,7 @@ void DrawPageText() {
|
||||
if (*ptr_lsgwin == 0) {
|
||||
return;
|
||||
}
|
||||
WINinfo *SaveLoadWin = GetWinStruct(*ptr_lsgwin);
|
||||
WINinfo *SaveLoadWin = GNWFind(*ptr_lsgwin);
|
||||
if (SaveLoadWin->surface == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
+220
-111
@@ -831,31 +831,6 @@ long __stdcall PartyMemberGetCurrentLevel(TGameObj* obj) {
|
||||
WRAP_WATCOM_CALL1(partyMemberGetCurLevel_, obj)
|
||||
}
|
||||
|
||||
char* GetProtoPtr(long pid) {
|
||||
char* proto;
|
||||
long result;
|
||||
__asm {
|
||||
mov eax, pid;
|
||||
lea edx, proto;
|
||||
call proto_ptr_;
|
||||
mov result, eax;
|
||||
}
|
||||
if (result != -1) {
|
||||
return proto;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char AnimCodeByWeapon(TGameObj* weapon) {
|
||||
if (weapon != nullptr) {
|
||||
char* proto = GetProtoPtr(weapon->pid);
|
||||
if (proto != nullptr && *(int*)(proto + 32) == item_type_weapon) {
|
||||
return (char)(*(int*)(proto + 36));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// prints message to debug.log file
|
||||
void __declspec(naked) DebugPrintf(const char* fmt, ...) {
|
||||
__asm jmp debug_printf_;
|
||||
@@ -866,30 +841,12 @@ void __stdcall DisplayConsoleMessage(const char* msg) {
|
||||
WRAP_WATCOM_CALL1(display_print_, msg)
|
||||
}
|
||||
|
||||
static MSGNode messageBuf;
|
||||
|
||||
const char* __stdcall GetMessageStr(const MSGList* fileAddr, long messageId) {
|
||||
const char* result;
|
||||
__asm {
|
||||
lea edx, messageBuf;
|
||||
mov ebx, messageId;
|
||||
mov eax, fileAddr;
|
||||
call getmsg_;
|
||||
mov result, eax;
|
||||
}
|
||||
return result;
|
||||
long __stdcall GetInputBtn() {
|
||||
WRAP_WATCOM_CALL0(get_input_)
|
||||
}
|
||||
|
||||
const char* __stdcall MsgSearch(const MSGList* fileAddr, long messageId) {
|
||||
messageBuf.number = messageId;
|
||||
long result;
|
||||
__asm {
|
||||
lea edx, messageBuf;
|
||||
mov eax, fileAddr;
|
||||
call message_search_;
|
||||
mov result, eax;
|
||||
}
|
||||
return (result == 1) ? messageBuf.message : nullptr;
|
||||
void __stdcall PlaySfx(const char* name) {
|
||||
WRAP_WATCOM_CALL1(gsound_play_sfx_file_, name)
|
||||
}
|
||||
|
||||
// Returns the name of the critter
|
||||
@@ -979,16 +936,6 @@ long __stdcall XFSeek(DbFile* file, long fOffset, long origin) {
|
||||
WRAP_WATCOM_CALL3(xfseek_, file, fOffset, origin)
|
||||
}
|
||||
|
||||
void SkillGetTags(long* result, long num) {
|
||||
if (num > 4) num = 4;
|
||||
WRAP_WATCOM_CALL2(skill_get_tags_, result, num)
|
||||
}
|
||||
|
||||
void SkillSetTags(long* tags, long num) {
|
||||
if (num > 4) num = 4;
|
||||
WRAP_WATCOM_CALL2(skill_set_tags_, tags, num)
|
||||
}
|
||||
|
||||
TGameObj* __stdcall ScrFindObjFromProgram(TProgram* program) {
|
||||
WRAP_WATCOM_CALL1(scr_find_obj_from_program_, program)
|
||||
}
|
||||
@@ -1007,44 +954,6 @@ long __stdcall ScrRemove(long scriptID) {
|
||||
WRAP_WATCOM_CALL1(scr_remove_, scriptID)
|
||||
}
|
||||
|
||||
// Returns the number of local variables of the object script
|
||||
long GetScriptLocalVars(long sid) {
|
||||
TScript* script = nullptr;
|
||||
ScrPtr(sid, &script);
|
||||
return (script) ? script->num_local_vars : 0;
|
||||
}
|
||||
|
||||
// Returns window ID by x/y coordinate (hidden windows are ignored)
|
||||
long __fastcall GetTopWindowID(long xPos, long yPos) {
|
||||
WINinfo* win = nullptr;
|
||||
long countWin = *(DWORD*)_num_windows - 1;
|
||||
for (int n = countWin; n >= 0; n--) {
|
||||
win = (WINinfo*)ptr_window[n];
|
||||
if (xPos >= win->wRect.left && xPos <= win->wRect.right && yPos >= win->wRect.top && yPos <= win->wRect.bottom) {
|
||||
if (!(win->flags & WIN_Hidden)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return win->wID;
|
||||
}
|
||||
|
||||
// Returns an array of objects within the specified radius from the source tile
|
||||
void GetObjectsTileRadius(std::vector<TGameObj*> &objs, long sourceTile, long radius, long elev, long type = -1) {
|
||||
for (long tile = 0; tile < 40000; tile++) {
|
||||
TGameObj* obj = ObjFindFirstAtTile(elev, tile);
|
||||
while (obj) {
|
||||
if (type == -1 || type == obj->pid >> 24) {
|
||||
bool multiHex = (obj->flags & 0x800) ? true : false;
|
||||
if (TileDist(sourceTile, obj->tile) <= (radius + multiHex)) {
|
||||
objs.push_back(obj);
|
||||
}
|
||||
}
|
||||
obj = ObjFindNextAtTile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void __fastcall RegisterObjectCall(long* target, long* source, void* func, long delay) {
|
||||
WRAP_WATCOM_FCALL4(register_object_call_, target, source, func, delay)
|
||||
}
|
||||
@@ -1120,22 +1029,6 @@ TGameObj* __stdcall InvenRightHand(TGameObj* critter) {
|
||||
WRAP_WATCOM_CALL1(inven_right_hand_, critter)
|
||||
}
|
||||
|
||||
__declspec(noinline) TGameObj* __stdcall GetItemPtrSlot(TGameObj* critter, long slot) {
|
||||
TGameObj* itemPtr = nullptr;
|
||||
switch (slot) {
|
||||
case INVEN_TYPE_LEFT_HAND:
|
||||
itemPtr = InvenLeftHand(critter);
|
||||
break;
|
||||
case INVEN_TYPE_RIGHT_HAND:
|
||||
itemPtr = InvenRightHand(critter);
|
||||
break;
|
||||
case INVEN_TYPE_WORN:
|
||||
itemPtr = InvenWorn(critter);
|
||||
break;
|
||||
}
|
||||
return itemPtr;
|
||||
}
|
||||
|
||||
void* __stdcall MemRealloc(void* lpmem, DWORD msize) {
|
||||
WRAP_WATCOM_CALL2(mem_realloc_, lpmem, msize)
|
||||
}
|
||||
@@ -1244,6 +1137,10 @@ long __fastcall WordWrap(const char* text, int maxWidth, DWORD* buf, BYTE* count
|
||||
WRAP_WATCOM_FCALL4(_word_wrap_, text, maxWidth, buf, count)
|
||||
}
|
||||
|
||||
WINinfo* __stdcall GNWFind(long winRef) {
|
||||
WRAP_WATCOM_CALL1(GNW_find_, winRef)
|
||||
}
|
||||
|
||||
DWORD __stdcall WinAdd(long x, long y, long width, long height, long bgColorIndex, long flags) {
|
||||
WRAP_WATCOM_CALL6(win_add_, x, y, width, height, bgColorIndex, flags)
|
||||
}
|
||||
@@ -1256,6 +1153,10 @@ void __stdcall WinHide(DWORD winRef) {
|
||||
WRAP_WATCOM_CALL1(win_hide_, winRef)
|
||||
}
|
||||
|
||||
BYTE* __stdcall WinGetBuf(DWORD winRef) {
|
||||
WRAP_WATCOM_CALL1(win_get_buf_, winRef)
|
||||
}
|
||||
|
||||
void __stdcall WinDraw(DWORD winRef) {
|
||||
WRAP_WATCOM_CALL1(win_draw_, winRef)
|
||||
}
|
||||
@@ -1340,6 +1241,14 @@ long __fastcall ObjNewSidInst(TGameObj* object, long sType, long scriptIndex) {
|
||||
WRAP_WATCOM_FCALL3(obj_new_sid_inst_, object, sType, scriptIndex)
|
||||
}
|
||||
|
||||
long __stdcall LoadMsgList(MSGList *msgList, const char *msgFilePath) {
|
||||
WRAP_WATCOM_CALL2(message_load_, msgList, msgFilePath)
|
||||
}
|
||||
|
||||
long __stdcall DestroyMsgList(MSGList *msgList) {
|
||||
WRAP_WATCOM_CALL1(message_exit_, msgList)
|
||||
}
|
||||
|
||||
long __fastcall TileNum(long x, long y) {
|
||||
__asm push ebx; // don't delete (bug in tile_num_)
|
||||
WRAP_WATCOM_FCALL2(tile_num_, x, y)
|
||||
@@ -1421,3 +1330,203 @@ const char* __stdcall ArtGetName(long artFID) {
|
||||
long __stdcall LoadFrame(const char* filename, FrmFile** frmPtr) {
|
||||
WRAP_WATCOM_CALL2(load_frame_, filename, frmPtr)
|
||||
}
|
||||
|
||||
///////////////////////////////// ENGINE UTILS /////////////////////////////////
|
||||
|
||||
static MSGNode messageBuf;
|
||||
|
||||
const char* __stdcall GetMessageStr(const MSGList* fileAddr, long messageId) {
|
||||
const char* result;
|
||||
__asm {
|
||||
mov ebx, messageId;
|
||||
lea edx, messageBuf;
|
||||
mov eax, fileAddr;
|
||||
call getmsg_;
|
||||
mov result, eax;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const char* __stdcall MsgSearch(const MSGList* fileAddr, long messageId) {
|
||||
messageBuf.number = messageId;
|
||||
long result;
|
||||
__asm {
|
||||
lea edx, messageBuf;
|
||||
mov eax, fileAddr;
|
||||
call message_search_;
|
||||
mov result, eax;
|
||||
}
|
||||
return (result == 1) ? messageBuf.message : nullptr;
|
||||
}
|
||||
|
||||
char* GetProtoPtr(long pid) {
|
||||
char* proto;
|
||||
long result;
|
||||
__asm {
|
||||
mov eax, pid;
|
||||
lea edx, proto;
|
||||
call proto_ptr_;
|
||||
mov result, eax;
|
||||
}
|
||||
if (result != -1) {
|
||||
return proto;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char AnimCodeByWeapon(TGameObj* weapon) {
|
||||
if (weapon != nullptr) {
|
||||
char* proto = GetProtoPtr(weapon->pid);
|
||||
if (proto != nullptr && *(int*)(proto + 32) == item_type_weapon) {
|
||||
return (char)(*(int*)(proto + 36));
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SkillGetTags(long* result, long num) {
|
||||
if (num > 4) num = 4;
|
||||
WRAP_WATCOM_CALL2(skill_get_tags_, result, num)
|
||||
}
|
||||
|
||||
void SkillSetTags(long* tags, long num) {
|
||||
if (num > 4) num = 4;
|
||||
WRAP_WATCOM_CALL2(skill_set_tags_, tags, num)
|
||||
}
|
||||
|
||||
__declspec(noinline) TGameObj* __stdcall GetItemPtrSlot(TGameObj* critter, long slot) {
|
||||
TGameObj* itemPtr = nullptr;
|
||||
switch (slot) {
|
||||
case INVEN_TYPE_LEFT_HAND:
|
||||
itemPtr = InvenLeftHand(critter);
|
||||
break;
|
||||
case INVEN_TYPE_RIGHT_HAND:
|
||||
itemPtr = InvenRightHand(critter);
|
||||
break;
|
||||
case INVEN_TYPE_WORN:
|
||||
itemPtr = InvenWorn(critter);
|
||||
break;
|
||||
}
|
||||
return itemPtr;
|
||||
}
|
||||
|
||||
// Returns the number of local variables of the object script
|
||||
long GetScriptLocalVars(long sid) {
|
||||
TScript* script = nullptr;
|
||||
ScrPtr(sid, &script);
|
||||
return (script) ? script->num_local_vars : 0;
|
||||
}
|
||||
|
||||
// Returns window ID by x/y coordinate (hidden windows are ignored)
|
||||
long __fastcall GetTopWindowID(long xPos, long yPos) {
|
||||
WINinfo* win = nullptr;
|
||||
long countWin = *(DWORD*)_num_windows - 1;
|
||||
for (int n = countWin; n >= 0; n--) {
|
||||
win = (WINinfo*)ptr_window[n];
|
||||
if (xPos >= win->wRect.left && xPos <= win->wRect.right && yPos >= win->wRect.top && yPos <= win->wRect.bottom) {
|
||||
if (!(win->flags & WIN_Hidden)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return win->wID;
|
||||
}
|
||||
|
||||
// Returns an array of objects within the specified radius from the source tile
|
||||
void GetObjectsTileRadius(std::vector<TGameObj*> &objs, long sourceTile, long radius, long elev, long type = -1) {
|
||||
for (long tile = 0; tile < 40000; tile++) {
|
||||
TGameObj* obj = ObjFindFirstAtTile(elev, tile);
|
||||
while (obj) {
|
||||
if (type == -1 || type == obj->pid >> 24) {
|
||||
bool multiHex = (obj->flags & 0x800) ? true : false;
|
||||
if (TileDist(sourceTile, obj->tile) <= (radius + multiHex)) {
|
||||
objs.push_back(obj);
|
||||
}
|
||||
}
|
||||
obj = ObjFindNextAtTile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// print text to surface
|
||||
void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface) {
|
||||
DWORD posOffset = yPos * toWidth + xPos;
|
||||
__asm {
|
||||
xor eax, eax;
|
||||
mov al, colorIndex;
|
||||
mov edx, displayText;
|
||||
push eax;
|
||||
mov ebx, txtWidth;
|
||||
mov eax, toSurface;
|
||||
mov ecx, toWidth;
|
||||
add eax, posOffset;
|
||||
call dword ptr ds:[_text_to_buf];
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//gets the height of the currently selected font
|
||||
DWORD GetTextHeight() {
|
||||
DWORD TxtHeight;
|
||||
__asm {
|
||||
call dword ptr ds:[_text_height]; //get text height
|
||||
mov TxtHeight, eax;
|
||||
}
|
||||
return TxtHeight;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//gets the length of a string using the currently selected font
|
||||
DWORD __stdcall GetTextWidth(const char *TextMsg) {
|
||||
__asm {
|
||||
mov eax, TextMsg;
|
||||
call dword ptr ds:[_text_width]; //get text width
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get width of Char for current font
|
||||
DWORD GetCharWidth(char CharVal) {
|
||||
DWORD charWidth;
|
||||
__asm {
|
||||
mov al, CharVal;
|
||||
call dword ptr ds:[_text_char_width];
|
||||
mov charWidth, eax;
|
||||
}
|
||||
return charWidth;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get maximum string length for current font - if all characters were maximum width
|
||||
DWORD GetMaxTextWidth(char *TextMsg) {
|
||||
DWORD msgWidth;
|
||||
__asm {
|
||||
mov eax, TextMsg;
|
||||
call dword ptr ds:[_text_mono_width];
|
||||
mov msgWidth, eax;
|
||||
}
|
||||
return msgWidth;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get number of pixels between characters for current font
|
||||
DWORD GetCharGapWidth() {
|
||||
DWORD gapWidth;
|
||||
__asm {
|
||||
call dword ptr ds:[_text_spacing];
|
||||
mov gapWidth, eax;
|
||||
}
|
||||
return gapWidth;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
//get maximum character width for current font
|
||||
DWORD GetMaxCharWidth() {
|
||||
DWORD charWidth = 0;
|
||||
__asm {
|
||||
call dword ptr ds:[_text_max];
|
||||
mov charWidth, eax;
|
||||
}
|
||||
return charWidth;
|
||||
}
|
||||
|
||||
+54
-20
@@ -1031,18 +1031,16 @@ long __stdcall ItemWeight(TGameObj* item);
|
||||
long __stdcall IsPartyMember(TGameObj* obj);
|
||||
long __stdcall PartyMemberGetCurrentLevel(TGameObj* obj);
|
||||
|
||||
char* GetProtoPtr(long pid);
|
||||
char AnimCodeByWeapon(TGameObj* weapon);
|
||||
|
||||
// prints message to debug.log file
|
||||
void __declspec() DebugPrintf(const char* fmt, ...);
|
||||
|
||||
// Displays message in main UI console window
|
||||
void __stdcall DisplayConsoleMessage(const char* msg);
|
||||
|
||||
const char* __stdcall GetMessageStr(const MSGList* fileAddr, long messageId);
|
||||
long __stdcall GetInputBtn();
|
||||
|
||||
const char* __stdcall MsgSearch(const MSGList* fileAddr, long messageId);
|
||||
// plays SFX sound with given name
|
||||
void __stdcall PlaySfx(const char* name);
|
||||
|
||||
// Returns the name of the critter
|
||||
const char* __stdcall CritterName(TGameObj* critter);
|
||||
@@ -1100,24 +1098,11 @@ long __stdcall ScrNew(long* scriptID, long sType);
|
||||
|
||||
long __stdcall ScrRemove(long scriptID);
|
||||
|
||||
// Returns the number of local variables of the object script
|
||||
long GetScriptLocalVars(long sid);
|
||||
|
||||
long __fastcall GetTopWindowID(long xPos, long yPos);
|
||||
|
||||
void GetObjectsTileRadius(std::vector<TGameObj*> &objs, long sourceTile, long radius, long elev, long type);
|
||||
|
||||
void __fastcall RegisterObjectCall(long* target, long* source, void* func, long delay);
|
||||
|
||||
long __fastcall ScrGetLocalVar(long sid, long varId, long* value);
|
||||
long __fastcall ScrSetLocalVar(long sid, long varId, long value);
|
||||
|
||||
// wrapper for skill_get_tags with bounds checking
|
||||
void SkillGetTags(long* result, long num);
|
||||
|
||||
// wrapper for skill_set_tags with bounds checking
|
||||
void SkillSetTags(long* tags, long num);
|
||||
|
||||
// redraws the main game interface windows (useful after changing some data like active hand, etc.)
|
||||
void __stdcall InterfaceRedraw();
|
||||
|
||||
@@ -1132,8 +1117,6 @@ TGameObj* __stdcall InvenLeftHand(TGameObj* critter);
|
||||
// item in critter's right hand slot
|
||||
TGameObj* __stdcall InvenRightHand(TGameObj* critter);
|
||||
|
||||
__declspec(noinline) TGameObj* __stdcall GetItemPtrSlot(TGameObj* critter, long slot);
|
||||
|
||||
// pops value type from Data stack (must be followed by InterpretPopLong)
|
||||
DWORD __stdcall InterpretPopShort(TProgram* scriptPtr);
|
||||
|
||||
@@ -1177,9 +1160,12 @@ long __fastcall GetGameConfigString(const char* outValue, const char* section, c
|
||||
|
||||
long __fastcall WordWrap(const char* text, int maxWidth, DWORD* buf, BYTE* count);
|
||||
|
||||
WINinfo* __stdcall GNWFind(long winRef);
|
||||
|
||||
DWORD __stdcall WinAdd(long x, long y, long width, long height, long bgColorIndex, long flags);
|
||||
void __stdcall WinShow(DWORD winRef);
|
||||
void __stdcall WinHide(DWORD winRef);
|
||||
BYTE* __stdcall WinGetBuf(DWORD winRef);
|
||||
void __stdcall WinDraw(DWORD winRef);
|
||||
void __stdcall WinDelete(DWORD winRef);
|
||||
|
||||
@@ -1219,6 +1205,10 @@ TGameObj* __fastcall ObjBlockingAt(TGameObj* object, long tile, long elevation);
|
||||
|
||||
long __fastcall ObjNewSidInst(TGameObj* object, long sType, long scriptIndex);
|
||||
|
||||
long __stdcall LoadMsgList(MSGList *msgList, const char *msgFilePath);
|
||||
|
||||
long __stdcall DestroyMsgList(MSGList *msgList);
|
||||
|
||||
long __fastcall TileNum(long x, long y);
|
||||
|
||||
long __fastcall TileNumInDirection(long tile, long rotation, long distance);
|
||||
@@ -1254,3 +1244,47 @@ long __fastcall MouseClickIn(long x, long y, long x_end, long y_end);
|
||||
const char* __stdcall ArtGetName(long artFID);
|
||||
|
||||
long __stdcall LoadFrame(const char* filename, FrmFile** frmPtr);
|
||||
|
||||
///////////////////////////////// ENGINE UTILS /////////////////////////////////
|
||||
|
||||
// returns message string from given file or "Error" when not found
|
||||
const char* __stdcall GetMessageStr(const MSGList* fileAddr, long messageId);
|
||||
|
||||
// similar to GetMessageStr, but returns nullptr when no message is found
|
||||
const char* __stdcall MsgSearch(const MSGList* fileAddr, long messageId);
|
||||
|
||||
// returns pointer to prototype by PID, or nullptr on failure
|
||||
char* GetProtoPtr(long pid);
|
||||
|
||||
// returns weapon animation code
|
||||
char AnimCodeByWeapon(TGameObj* weapon);
|
||||
|
||||
// wrapper for skill_get_tags with bounds checking
|
||||
void SkillGetTags(long* result, long num);
|
||||
|
||||
// wrapper for skill_set_tags with bounds checking
|
||||
void SkillSetTags(long* tags, long num);
|
||||
|
||||
__declspec(noinline) TGameObj* __stdcall GetItemPtrSlot(TGameObj* critter, long slot);
|
||||
|
||||
// Returns the number of local variables of the object script
|
||||
long GetScriptLocalVars(long sid);
|
||||
|
||||
long __fastcall GetTopWindowID(long xPos, long yPos);
|
||||
|
||||
void GetObjectsTileRadius(std::vector<TGameObj*> &objs, long sourceTile, long radius, long elev, long type);
|
||||
|
||||
// Print text to surface
|
||||
void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface);
|
||||
// gets the height of the currently selected font
|
||||
DWORD GetTextHeight();
|
||||
// gets the length of a string using the currently selected font
|
||||
DWORD __stdcall GetTextWidth(const char *TextMsg);
|
||||
// get width of Char for current font
|
||||
DWORD GetCharWidth(char charVal);
|
||||
// get maximum string length for current font - if all characters were maximum width
|
||||
DWORD GetMaxTextWidth(char *textMsg);
|
||||
// get number of pixels between characters for current font
|
||||
DWORD GetCharGapWidth();
|
||||
// get maximum character width for current font
|
||||
DWORD GetMaxCharWidth();
|
||||
|
||||
+7
-104
@@ -20,12 +20,13 @@
|
||||
|
||||
#include "main.h"
|
||||
#include "FalloutEngine.h"
|
||||
#include "HeroAppearance.h"
|
||||
#include "LoadGameHook.h"
|
||||
#include "Message.h"
|
||||
#include "PartyControl.h"
|
||||
#include "ScriptExtender.h"
|
||||
|
||||
#include "HeroAppearance.h"
|
||||
|
||||
bool appModEnabled = false; // check if Appearance mod enabled for script fuctions
|
||||
|
||||
const char* appearancePathFmt = "Appearance\\h%cR%02dS%02d%s";
|
||||
@@ -336,28 +337,6 @@ UNLSTDfrm *LoadUnlistedFrm(char *frmName, unsigned int folderRef) {
|
||||
return frm;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////WINDOW FUNCTIONS////////////////////////////////////////////////////////////////////
|
||||
|
||||
WINinfo* __stdcall GetWinStruct(long winRef) {
|
||||
__asm {
|
||||
mov eax, winRef;
|
||||
call GNW_find_;
|
||||
}
|
||||
}
|
||||
|
||||
BYTE* __stdcall GetWinSurface(DWORD winRef) {
|
||||
__asm {
|
||||
mov eax, winRef;
|
||||
call win_get_buf_;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////BUTTON FUNCTIONS////////////////////////////////////////////////////////////////////
|
||||
|
||||
long __stdcall check_buttons() {
|
||||
__asm call get_input_;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////TEXT FUNCTIONS//////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void SetFont(long ref) {
|
||||
@@ -371,82 +350,6 @@ static long GetFont() {
|
||||
return *ptr_curr_font_num;
|
||||
}
|
||||
|
||||
// print text to surface
|
||||
void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface) {
|
||||
DWORD posOffset = yPos * toWidth + xPos;
|
||||
__asm {
|
||||
xor eax, eax;
|
||||
mov al, colorIndex;
|
||||
mov edx, displayText;
|
||||
push eax;
|
||||
mov ebx, txtWidth;
|
||||
mov eax, toSurface;
|
||||
mov ecx, toWidth;
|
||||
add eax, posOffset;
|
||||
call dword ptr ds:[_text_to_buf];
|
||||
}
|
||||
}
|
||||
|
||||
// gets the height of the currently selected font
|
||||
DWORD GetTextHeight() {
|
||||
DWORD TxtHeight;
|
||||
__asm {
|
||||
call dword ptr ds:[_text_height]; // get text height
|
||||
mov TxtHeight, eax;
|
||||
}
|
||||
return TxtHeight;
|
||||
}
|
||||
|
||||
// gets the length of a string using the currently selected font
|
||||
DWORD __stdcall GetTextWidth(const char *TextMsg) {
|
||||
__asm {
|
||||
mov eax, TextMsg;
|
||||
call dword ptr ds:[_text_width]; // get text width
|
||||
}
|
||||
}
|
||||
|
||||
// get width of Char for current font
|
||||
DWORD GetCharWidth(char CharVal) {
|
||||
DWORD charWidth;
|
||||
__asm {
|
||||
mov al, CharVal;
|
||||
call dword ptr ds:[_text_char_width];
|
||||
mov charWidth, eax;
|
||||
}
|
||||
return charWidth;
|
||||
}
|
||||
|
||||
// get maximum string length for current font - if all characters were maximum width
|
||||
DWORD GetMaxTextWidth(char *TextMsg) {
|
||||
DWORD msgWidth;
|
||||
__asm {
|
||||
mov eax, TextMsg;
|
||||
call dword ptr ds:[_text_mono_width];
|
||||
mov msgWidth, eax;
|
||||
}
|
||||
return msgWidth;
|
||||
}
|
||||
|
||||
// get number of pixels between characters for current font
|
||||
DWORD GetCharGapWidth() {
|
||||
DWORD gapWidth;
|
||||
__asm {
|
||||
call dword ptr ds:[_text_spacing];
|
||||
mov gapWidth, eax;
|
||||
}
|
||||
return gapWidth;
|
||||
}
|
||||
|
||||
// get maximum character width for current font
|
||||
DWORD GetMaxCharWidth() {
|
||||
DWORD charWidth = 0;
|
||||
__asm {
|
||||
call dword ptr ds:[_text_max];
|
||||
mov charWidth, eax;
|
||||
}
|
||||
return charWidth;
|
||||
}
|
||||
|
||||
static bool CreateWordWrapList(char *TextMsg, DWORD WrapWidth, DWORD *lineNum, LineNode *StartLine) {
|
||||
*lineNum = 1;
|
||||
|
||||
@@ -988,7 +891,7 @@ static void DrawPCConsole() {
|
||||
int WinRef = *ptr_edit_win; // char screen window ref
|
||||
//BYTE *WinSurface = GetWinSurface(WinRef);
|
||||
|
||||
WINinfo *WinInfo = GetWinStruct(WinRef);
|
||||
WINinfo *WinInfo = GNWFind(WinRef);
|
||||
|
||||
BYTE *ConSurface = new BYTE [70 * 102];
|
||||
sub_draw(70, 102, 640, 480, 338, 78, charScrnBackSurface, 70, 102, 0, 0, ConSurface, 0);
|
||||
@@ -1030,7 +933,7 @@ static void DrawCharNote(bool style, int winRef, DWORD xPosWin, DWORD yPosWin, B
|
||||
InfoMsg = GetMsg(&MsgList, 101, 2);
|
||||
}
|
||||
|
||||
WINinfo *winInfo = GetWinStruct(winRef);
|
||||
WINinfo *winInfo = GNWFind(winRef);
|
||||
|
||||
BYTE *PadSurface = new BYTE [280 * 168];
|
||||
sub_draw(280, 168, widthBG, heightBG, xPosBG, yPosBG, BGSurface, 280, 168, 0, 0, PadSurface, 0);
|
||||
@@ -1127,7 +1030,7 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) {
|
||||
int oldMouse = *ptr_gmouse_current_cursor;
|
||||
SetMousePic(1);
|
||||
|
||||
BYTE *winSurface = GetWinSurface(winRef);
|
||||
BYTE *winSurface = WinGetBuf(winRef);
|
||||
BYTE *mainSurface = new BYTE [484 * 230];
|
||||
|
||||
sub_draw(484, 230, 484, 230, 0, 0, frm->frames[0].indexBuff, 484, 230, 0, 0, mainSurface, 0);
|
||||
@@ -1216,7 +1119,7 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) {
|
||||
WinDraw(winRef);
|
||||
}
|
||||
|
||||
button = check_buttons();
|
||||
button = GetInputBtn();
|
||||
if (button == 0x148) { // previous style/race - up arrow button pushed
|
||||
PlayAcm("ib1p1xx1");
|
||||
|
||||
@@ -1326,7 +1229,7 @@ static void FixTextHighLight() {
|
||||
}
|
||||
|
||||
static int _stdcall CheckCharButtons() {
|
||||
int button = check_buttons();
|
||||
int button = GetInputBtn();
|
||||
|
||||
int drawFlag = -1;
|
||||
|
||||
|
||||
@@ -18,12 +18,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
WINinfo* __stdcall GetWinStruct(long winRef);
|
||||
void PrintText(char* displayText, BYTE colorIndex, DWORD xPos, DWORD yPos, DWORD txtWidth, DWORD toWidth, BYTE* toSurface);
|
||||
DWORD __stdcall GetTextWidth(const char *TextMsg);
|
||||
DWORD GetMaxCharWidth();
|
||||
long __stdcall check_buttons();
|
||||
|
||||
void HeroAppearanceModInit();
|
||||
void HeroAppearanceModExit();
|
||||
|
||||
|
||||
+1
-2
@@ -18,7 +18,6 @@
|
||||
|
||||
#include "main.h"
|
||||
#include "FalloutEngine.h"
|
||||
#include "HeroAppearance.h"
|
||||
|
||||
static long costAP = -1;
|
||||
static void __declspec(naked) intface_redraw_items_hack0() {
|
||||
@@ -222,7 +221,7 @@ static long __stdcall gmouse_handle_event_hook() {
|
||||
}
|
||||
if (IFACE_BAR_MODE) return 1;
|
||||
// if IFACE_BAR_MODE is not enabled, check the display_win window area
|
||||
win = GetWinStruct(*(DWORD*)_display_win);
|
||||
win = GNWFind(*(DWORD*)_display_win);
|
||||
RECT *rect = &win->wRect;
|
||||
return MouseClickIn(rect->left, rect->top, rect->right, rect->bottom); // 1 - click in the display_win area
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#include "Perks.h"
|
||||
#include "ScriptExtender.h"
|
||||
#include "Skills.h"
|
||||
#include "Sound.h"
|
||||
#include "Stats.h"
|
||||
#include "TalkingHeads.h"
|
||||
#include "version.h"
|
||||
|
||||
@@ -49,21 +49,6 @@ const MSGList* gameMsgFiles[] = {
|
||||
|
||||
ExtraGameMessageListsMap gExtraGameMsgLists;
|
||||
|
||||
long __stdcall LoadMsgList(MSGList *msgList, const char *msgFilePath) {
|
||||
__asm {
|
||||
mov edx, msgFilePath;
|
||||
mov eax, msgList;
|
||||
call message_load_;
|
||||
}
|
||||
}
|
||||
|
||||
long __stdcall DestroyMsgList(MSGList *msgList) {
|
||||
__asm {
|
||||
mov eax, msgList;
|
||||
call message_exit_;
|
||||
}
|
||||
}
|
||||
|
||||
// Loads the msg file from the 'english' folder if it does not exist in the current language directory
|
||||
static void __declspec(naked) message_load_hook() {
|
||||
__asm {
|
||||
|
||||
@@ -25,9 +25,6 @@ typedef std::tr1::unordered_map<int, MSGList*> ExtraGameMessageListsMap;
|
||||
extern ExtraGameMessageListsMap gExtraGameMsgLists;
|
||||
extern const MSGList* gameMsgFiles[];
|
||||
|
||||
long __stdcall LoadMsgList(MSGList *msgList, const char *msgFilePath);
|
||||
long __stdcall DestroyMsgList(MSGList *msgList);
|
||||
|
||||
MSGNode* GetMsgNode(MSGList* msgList, int msgRef);
|
||||
char* GetMsg(MSGList* msgList, int msgRef, int msgNum);
|
||||
|
||||
|
||||
@@ -22,11 +22,9 @@
|
||||
- doesn't work with NPC's wearing armor mod, armor won't change when you change it from critter's inventory
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "main.h"
|
||||
#include "FalloutEngine.h"
|
||||
#include "HeroAppearance.h"
|
||||
|
||||
#include "PartyControl.h"
|
||||
|
||||
bool npcAutoLevelEnabled;
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include "HeroAppearance.h"
|
||||
#include "input.h"
|
||||
#include "LoadGameHook.h"
|
||||
#include "ScriptExtender.h"
|
||||
@@ -461,7 +460,7 @@ static void sf_set_window_flag() {
|
||||
for (size_t i = 0; i < 16; i++) {
|
||||
sWin = *(sWindow*)&ptr_sWindows[i * 23]; // sWindow struct = 92 bytes
|
||||
if (_stricmp(name, sWin.name) == 0) {
|
||||
WINinfo* win = GetWinStruct(sWin.wID);
|
||||
WINinfo* win = GNWFind(sWin.wID);
|
||||
if (mode) {
|
||||
sWin.flags |= bitFlag;
|
||||
win->flags |= bitFlag;
|
||||
@@ -475,7 +474,7 @@ static void sf_set_window_flag() {
|
||||
opHandler.printOpcodeError("set_window_flag() - window '%s' is not found.", name);
|
||||
} else {
|
||||
long wid = opHandler.arg(0).rawValue();
|
||||
WINinfo* win = GetWinStruct((wid > 0) ? wid : *ptr_i_wid); // i_wid - set flag to current game interface window
|
||||
WINinfo* win = GNWFind((wid > 0) ? wid : *ptr_i_wid); // i_wid - set flag to current game interface window
|
||||
if (win == nullptr) return;
|
||||
if (mode) {
|
||||
win->flags |= bitFlag;
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include "ScriptExtender.h"
|
||||
#include "ScriptArrays.hpp"
|
||||
#include "Arrays.h"
|
||||
#include "HeroAppearance.h"
|
||||
#include "Message.h"
|
||||
|
||||
// compares strings case-insensitive with specifics for Fallout
|
||||
|
||||
@@ -50,13 +50,6 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
void PlaySfx(const char* name) {
|
||||
__asm {
|
||||
mov eax, name;
|
||||
call gsound_play_sfx_file_;
|
||||
}
|
||||
}
|
||||
|
||||
void SoundInit() {
|
||||
if (int sBuff = GetConfigInt("Sound", "NumSoundBuffers", 0)) {
|
||||
SafeWrite8(0x451129, (BYTE)sBuff);
|
||||
|
||||
@@ -1,2 +1 @@
|
||||
void SoundInit();
|
||||
void PlaySfx(const char* name);
|
||||
|
||||
Reference in New Issue
Block a user