Page 1 of 1

OSX 1.14d code edits

Posted: Sun Mar 03, 2019 12:38 pm
by AntiRush
I've been working on replacing the graphics subsystem in the OSX version of D2 and figured I could start sharing
information in case anybody is interested. There is an unfortunate amount of old Carbon code still sticking around, so I've started replacing some of that too.

This is from OSX version 1.14d

Code: Select all

int __attribute__((cdecl)) EnsureDirectory(char* path);
Diablo II.0x226f8
This function is called for various filesystem paths and creates the directories if they don't exist.
Paths will be in the form '\{MacPath01}\Save'.

MacPath01 corresponds to the base directory of the game (by default '/Applications/Diablo II'
MacPath02 is the current user's Application Support directory '$HOME/Library/Application Support'

The default version of this uses some gross old Carbon APIs and, among other things makes startup scale linearly with
the number of directories (and subdirectories!) in your Application Support directory.
It is also prone to crashing if there are 'uncommon' characters in filenames inside of Application Support.

This is pretty easy to replace; just make sure the directories are created when asked and everything will be great.
The MacPath01 stuff is also a good place if you want to change where savegames or logs go.

Code: Select all

int __attribute__((cdecl)) ErrorReporter(char *dump_path, int code);
Diablo II.0x2E90
This is the handler that gets called when D2 crashes. By default it will spawn the Blizzard error reporter which is not
very useful and quite annoying if you happen to be crashing the game a lot. A bunch of debug information gets written to the
file in `dump_path` which can sometimes be nice to look at.

Re: OSX 1.14d code edits

Posted: Sat Apr 06, 2019 12:40 am
by AntiRush
Dropping some more OpenGL related stuff here:

Code: Select all

Diablo II.552B24
bool g_opengl_fullscreen

Code: Select all

Diablo II.552B28
CGDisplayMode g_cgdisplaymode

Code: Select all

Diablo II.552B30
WindowRef g_carbon_window;
This is an old style carbon window ref. It's used for input and event handling, unfortunately

Code: Select all

bool __cdecl OpenGLMacOpenWindow(int32_t resolution_mode)
This creates a Carbon window and initializes an opengl context. resolution_mode is 0 for 640x480 and 1 for 800x600.

Code: Select all

Diablo II.3CE6EC
This is a table of OpenGL related functions. I believe it corresponds to the old D2GFX.dll on Windows, though I'm
not entirely sure.


And a not really rendering related thing, but useful during development:

Code: Select all

HANDLE __cdecl CreateThread(int32_t thread_attributes, 
                        int32_t stacksize, 
                        void *start_address, 
                        int32_t param,
                        int32_t creation_flags, 
                        int32_T *thread_id, 
                        const char *thread_name)
Diablo II.2BF09
This is a wrapper around pthreads to expose a win32 CreateThread style interface. It is used in
most places where a thread is created.
The returned handle is just an index into a global list of threads.

Code: Select all

Diablo II.55254C
HANDLE g_d2client_client_thread_handle;

Code: Select all

Diablo II.552550
int32_t g_d2client_client_thread_id;