Skip to content

Commit

Permalink
Add include guards, prepare for XRef (#28)
Browse files Browse the repository at this point in the history
Add definitions, other junk.
  • Loading branch information
galaxyhaxz committed Jun 20, 2018
1 parent 5772426 commit 49a6f4f
Show file tree
Hide file tree
Showing 137 changed files with 324 additions and 1,995 deletions.
19 changes: 0 additions & 19 deletions Source/appfat.cpp
Expand Up @@ -31,7 +31,6 @@ bool __cdecl appfat_cpp_free(void *a1)
}
*/

//----- (0040102A) --------------------------------------------------------
char *__fastcall GetErr(int error_code)
{
int v1; // edi
Expand Down Expand Up @@ -64,7 +63,6 @@ char *__fastcall GetErr(int error_code)
return sz_error_buf;
}

//----- (004010CE) --------------------------------------------------------
void __fastcall GetDDErr(int error_code, char *error_buf, int error_buf_len)
{
const char *v3; // eax
Expand Down Expand Up @@ -494,7 +492,6 @@ void __fastcall GetDDErr(int error_code, char *error_buf, int error_buf_len)
strncpy(error_buf, v3, error_buf_len);
}

//----- (00401831) --------------------------------------------------------
void __fastcall GetDSErr(int error_code, char *error_buf, int error_buf_len)
{
const char *v3; // eax
Expand Down Expand Up @@ -558,7 +555,6 @@ void __fastcall GetDSErr(int error_code, char *error_buf, int error_buf_len)
strncpy(error_buf, v3, error_buf_len);
}

//----- (0040193A) --------------------------------------------------------
char *__cdecl GetLastErr()
{
int v0; // eax
Expand All @@ -567,7 +563,6 @@ char *__cdecl GetLastErr()
return GetErr(v0);
}

//----- (00401947) --------------------------------------------------------
void TermMsg(char *pszFmt, ...)
{
va_list arglist; // [esp+8h] [ebp+8h]
Expand All @@ -580,7 +575,6 @@ void TermMsg(char *pszFmt, ...)
exit(1);
}

//----- (00401975) --------------------------------------------------------
void __fastcall MsgBox(char *pszFmt, va_list va)
{
char Text[256]; // [esp+0h] [ebp-100h]
Expand All @@ -591,7 +585,6 @@ void __fastcall MsgBox(char *pszFmt, va_list va)
MessageBoxA(ghMainWnd, Text, "ERROR", MB_TASKMODAL|MB_ICONHAND);
}

//----- (004019C7) --------------------------------------------------------
void __cdecl FreeDlg()
{
if ( terminating && cleanup_thread_id != GetCurrentThreadId() )
Expand All @@ -611,7 +604,6 @@ void __cdecl FreeDlg()
// 4B7A38: using guessed type int cleanup_thread_id;
// 679660: using guessed type char gbMaxPlayers;

//----- (00401A30) --------------------------------------------------------
void DrawDlg(char *pszFmt, ...)
{
char text[256]; // [esp+0h] [ebp-100h]
Expand All @@ -622,7 +614,6 @@ void DrawDlg(char *pszFmt, ...)
SDrawMessageBox(text, "Diablo", MB_TASKMODAL|MB_ICONEXCLAMATION);
}

//----- (00401A65) --------------------------------------------------------
void __fastcall DDErrDlg(int error_code, int log_line_nr, char *log_file_path)
{
int v3; // esi
Expand All @@ -636,7 +627,6 @@ void __fastcall DDErrDlg(int error_code, int log_line_nr, char *log_file_path)
}
}

//----- (00401A88) --------------------------------------------------------
void __fastcall DSErrDlg(int error_code, int log_line_nr, char *log_file_path)
{
int v3; // esi
Expand All @@ -650,7 +640,6 @@ void __fastcall DSErrDlg(int error_code, int log_line_nr, char *log_file_path)
}
}

//----- (00401AAB) --------------------------------------------------------
void __fastcall CenterDlg(HWND hDlg)
{
LONG v1; // esi
Expand All @@ -677,7 +666,6 @@ void __fastcall CenterDlg(HWND hDlg)
}
}

//----- (00401B3D) --------------------------------------------------------
void __fastcall TermDlg(int template_id, int error_code, char *log_file_path, int log_line_nr)
{
int v4; // ebx
Expand All @@ -701,7 +689,6 @@ void __fastcall TermDlg(int template_id, int error_code, char *log_file_path, in
TermMsg(0);
}

//----- (00401BCA) --------------------------------------------------------
bool __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text)
{
if ( uMsg == WM_INITDIALOG )
Expand All @@ -724,7 +711,6 @@ bool __stdcall FuncDlg(HWND hDlg, UINT uMsg, WPARAM wParam, char *text)
return 1;
}

//----- (00401C0F) --------------------------------------------------------
void __fastcall TextDlg(HWND hDlg, char *text)
{
char *v2; // esi
Expand All @@ -737,7 +723,6 @@ void __fastcall TextDlg(HWND hDlg, char *text)
SetDlgItemTextA(v3, 1000, v2);
}

//----- (00401C2E) --------------------------------------------------------
void __fastcall ErrDlg(template_id template_id, int error_code, char *log_file_path, int log_line_nr)
{
char *v4; // esi
Expand All @@ -758,7 +743,6 @@ void __fastcall ErrDlg(template_id template_id, int error_code, char *log_file_p
DialogBoxParamA(ghInst, (LPCSTR)v6, ghMainWnd, (DLGPROC)FuncDlg, (LPARAM)dwInitParam);
}

//----- (00401C9C) --------------------------------------------------------
void __fastcall FileErrDlg(char *error)
{
char *v1; // esi
Expand All @@ -772,7 +756,6 @@ void __fastcall FileErrDlg(char *error)
TermMsg(0);
}

//----- (00401CE1) --------------------------------------------------------
void __fastcall DiskFreeDlg(char *error)
{
char *v1; // esi
Expand All @@ -784,7 +767,6 @@ void __fastcall DiskFreeDlg(char *error)
TermMsg(0);
}

//----- (00401D1D) --------------------------------------------------------
bool __cdecl InsertCDDlg()
{
int v0; // edi
Expand All @@ -797,7 +779,6 @@ bool __cdecl InsertCDDlg()
return v0 == 1;
}

//----- (00401D68) --------------------------------------------------------
void __fastcall DirErrDlg(char *error)
{
char *v1; // esi
Expand Down
5 changes: 4 additions & 1 deletion Source/appfat.h
@@ -1,6 +1,7 @@
//HEADER_GOES_HERE
#ifndef __APPFAT_H__
#define __APPFAT_H__

//appfat
extern int appfat_terminated; // weak
extern char sz_error_buf[256];
extern int terminating; // weak
Expand All @@ -26,3 +27,5 @@ void __fastcall FileErrDlg(char *error);
void __fastcall DiskFreeDlg(char *error);
bool __cdecl InsertCDDlg();
void __fastcall DirErrDlg(char *error);

#endif /* __APPFAT_H__ */
16 changes: 0 additions & 16 deletions Source/automap.cpp
Expand Up @@ -17,7 +17,6 @@ int AutoMapYPos; // weak
int AMPlayerX; // weak
int AMPlayerY; // weak

//----- (00401DA4) --------------------------------------------------------
void __cdecl InitAutomapOnce()
{
automapflag = 0;
Expand All @@ -34,7 +33,6 @@ void __cdecl InitAutomapOnce()
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;

//----- (00401DE8) --------------------------------------------------------
void __cdecl InitAutomap()
{
signed int v0; // edi
Expand Down Expand Up @@ -124,7 +122,6 @@ void __cdecl InitAutomap()
}
// 5BB1ED: using guessed type char leveltype;

//----- (00401EF4) --------------------------------------------------------
void __cdecl StartAutomap()
{
AutoMapXOfs = 0;
Expand All @@ -134,7 +131,6 @@ void __cdecl StartAutomap()
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;

//----- (00401F0D) --------------------------------------------------------
void __cdecl AutomapUp()
{
--AutoMapXOfs;
Expand All @@ -143,7 +139,6 @@ void __cdecl AutomapUp()
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;

//----- (00401F1A) --------------------------------------------------------
void __cdecl AutomapDown()
{
++AutoMapXOfs;
Expand All @@ -152,7 +147,6 @@ void __cdecl AutomapDown()
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;

//----- (00401F27) --------------------------------------------------------
void __cdecl AutomapLeft()
{
--AutoMapXOfs;
Expand All @@ -161,7 +155,6 @@ void __cdecl AutomapLeft()
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;

//----- (00401F34) --------------------------------------------------------
void __cdecl AutomapRight()
{
++AutoMapXOfs;
Expand All @@ -170,7 +163,6 @@ void __cdecl AutomapRight()
// 4B84B0: using guessed type int AutoMapXOfs;
// 4B84B4: using guessed type int AutoMapYOfs;

//----- (00401F41) --------------------------------------------------------
void __cdecl AutomapZoomIn()
{
if ( AutoMapScale < 200 )
Expand All @@ -189,7 +181,6 @@ void __cdecl AutomapZoomIn()
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;

//----- (00401F80) --------------------------------------------------------
void __cdecl AutomapZoomOut()
{
if ( AutoMapScale > 50 )
Expand All @@ -208,7 +199,6 @@ void __cdecl AutomapZoomOut()
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;

//----- (00401FBD) --------------------------------------------------------
void __cdecl DrawAutomap()
{
int v0; // eax
Expand Down Expand Up @@ -391,7 +381,6 @@ void __cdecl DrawAutomap()
// 69BD04: using guessed type int questlog;
// 69CF0C: using guessed type int screen_buf_end;

//----- (00402233) --------------------------------------------------------
void __fastcall DrawAutomapType(int screen_x, int screen_y, short automap_type)
{
short v3; // al
Expand Down Expand Up @@ -628,7 +617,6 @@ void __fastcall DrawAutomapType(int screen_x, int screen_y, short automap_type)
// 4B84C4: using guessed type int AMPlayerX;
// 4B84C8: using guessed type int AMPlayerY;

//----- (004029A8) --------------------------------------------------------
void __cdecl DrawAutomapPlr()
{
int v0; // ebx
Expand Down Expand Up @@ -782,7 +770,6 @@ void __cdecl DrawAutomapPlr()
// 4B8968: using guessed type int sbookflag;
// 69BD04: using guessed type int questlog;

//----- (00402D83) --------------------------------------------------------
short __fastcall GetAutomapType(int tx, int ty, bool view)
{
int v3; // edi
Expand Down Expand Up @@ -830,7 +817,6 @@ short __fastcall GetAutomapType(int tx, int ty, bool view)
return v7;
}

//----- (00402E4A) --------------------------------------------------------
void __cdecl DrawAutomapGame()
{
int v0; // esi
Expand Down Expand Up @@ -867,7 +853,6 @@ void __cdecl DrawAutomapGame()
// 5CF31D: using guessed type char setlevel;
// 679660: using guessed type char gbMaxPlayers;

//----- (00402F27) --------------------------------------------------------
void __fastcall SetAutomapView(int x, int y)
{
signed int v2; // esi
Expand Down Expand Up @@ -964,7 +949,6 @@ void __fastcall SetAutomapView(int x, int y)
// 4B7E40: using guessed type int AMdword_4B7E40;
// 4B7E44: using guessed type int AMdword_4B7E44;

//----- (004030DD) --------------------------------------------------------
void __cdecl AutomapZoomReset()
{
AutoMapXOfs = 0;
Expand Down
7 changes: 5 additions & 2 deletions Source/automap.h
@@ -1,6 +1,7 @@
//HEADER_GOES_HERE
#ifndef __AUTOMAP_H__
#define __AUTOMAP_H__

//automap
extern short automaptype[512];
extern int AMdword_4B7E40; // weak
extern int AMdword_4B7E44; // weak
Expand Down Expand Up @@ -31,4 +32,6 @@ void __cdecl DrawAutomapPlr();
short __fastcall GetAutomapType(int tx, int ty, bool view);
void __cdecl DrawAutomapGame();
void __fastcall SetAutomapView(int x, int y);
void __cdecl AutomapZoomReset();
void __cdecl AutomapZoomReset();

#endif /* __AUTOMAP_H__ */
7 changes: 0 additions & 7 deletions Source/capture.cpp
Expand Up @@ -2,7 +2,6 @@

#include "../types.h"

//----- (0040311B) --------------------------------------------------------
void __cdecl CaptureScreen()
{
int v4; // edi
Expand Down Expand Up @@ -38,7 +37,6 @@ void __cdecl CaptureScreen()
// 40311B: could not find valid save-restore pair for edi
// 40311B: could not find valid save-restore pair for esi

//----- (00403204) --------------------------------------------------------
bool __fastcall CaptureHdr(HANDLE hFile, short width, int height)
{
short v3; // si
Expand All @@ -62,7 +60,6 @@ bool __fastcall CaptureHdr(HANDLE hFile, short width, int height)
return WriteFile(v4, &Buffer, 0x80u, &lpNumBytes, NULL) && lpNumBytes == 128;
}

//----- (00403294) --------------------------------------------------------
bool __fastcall CapturePal(HANDLE hFile, PALETTEENTRY *palette)
{
BYTE *v2; // eax
Expand All @@ -88,7 +85,6 @@ bool __fastcall CapturePal(HANDLE hFile, PALETTEENTRY *palette)
return WriteFile(hFile, Buffer, 0x301u, &lpNumBytes, 0) && lpNumBytes == 769;
}

//----- (004032FD) --------------------------------------------------------
bool __fastcall CapturePix(HANDLE hFile, short width, short height, short stride, char *pixels)
{
int v5; // esi
Expand Down Expand Up @@ -117,7 +113,6 @@ bool __fastcall CapturePix(HANDLE hFile, short width, short height, short stride
return 0;
}

//----- (0040336A) --------------------------------------------------------
char *__fastcall CaptureEnc(char *src, char *dst, int width)
{
int v3; // esi
Expand Down Expand Up @@ -155,7 +150,6 @@ char *__fastcall CaptureEnc(char *src, char *dst, int width)
return dst;
}

//----- (004033A8) --------------------------------------------------------
HANDLE __fastcall CaptureFile(char *dst_path)
{
char *v1; // edi
Expand Down Expand Up @@ -192,7 +186,6 @@ HANDLE __fastcall CaptureFile(char *dst_path)
}
// 4033A8: using guessed type char var_64[100];

//----- (00403470) --------------------------------------------------------
void __fastcall RedPalette(PALETTEENTRY *pal)
{
int i; // eax
Expand Down
6 changes: 5 additions & 1 deletion Source/capture.h
@@ -1,9 +1,13 @@
//HEADER_GOES_HERE
#ifndef __CAPTURE_H__
#define __CAPTURE_H__

void __cdecl CaptureScreen();
bool __fastcall CaptureHdr(HANDLE hFile, short width, int height);
bool __fastcall CapturePal(HANDLE hFile, PALETTEENTRY *palette);
bool __fastcall CapturePix(HANDLE hFile, short width, short height, short stride, char *pixels);
char *__fastcall CaptureEnc(char *src, char *dst, int width);
HANDLE __fastcall CaptureFile(char *dst_path);
void __fastcall RedPalette(PALETTEENTRY *pal);
void __fastcall RedPalette(PALETTEENTRY *pal);

#endif /* __CAPTURE_H__ */

2 comments on commit 49a6f4f

@mewmew
Copy link
Contributor

@mewmew mewmew commented on 49a6f4f Jun 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@galaxyhaxz Would you consider reverting the change to remove the comments with addresses for each function? I find them very useful when checking how something is implemented in Devilution and mapping it back to the original binary.

Edit: Perhaps the format could be changed to something like:

-//----- (0044951C) --------------------------------------------------------
+// address: 0x44951C

Edit2: Oh, I see. The spreadsheet will track these addresses instead.

@mewmew
Copy link
Contributor

@mewmew mewmew commented on 49a6f4f Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mewmew Yeah, haha I find them very useful as well. I'll try to get the spreadsheet uploaded today. The spreadsheet will be better anyway, since it will also contain offsets for data and variables as well.

Sure, sounds good.

Please sign in to comment.