Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create classes, constructors, and static variables #13

Closed
ghost opened this issue Jun 14, 2018 · 5 comments
Closed

Create classes, constructors, and static variables #13

ghost opened this issue Jun 14, 2018 · 5 comments
Labels
code cleanup Cosmetic enhancement to the code to make it look nicer. low priority This should be worked on later

Comments

@ghost
Copy link

ghost commented Jun 14, 2018

This issue will be for creating the relevant C++ parts of the code. The decompiler doesn't have enough information on it's own to do so. The majority of data is currently written to the .DATA section of the executable, instead of .RDATA like the original. Classes will help to declare static/external variables and functions. The PSX symbol defines this for most functions/data.

Constructors should be used for a few files, example engine.cpp:

Class Engine
{
  public:
    gdwRandSeed;
    CelDecodeRaw(blah blah blah);
  private:
    Engine();
    ~Engine();
}
Engine()
//initialize CCritSection
~Engine()
//delete CCritSection
@ghost ghost added the low priority This should be worked on later label Jun 20, 2018
@ghost ghost mentioned this issue Jun 21, 2018
@nomdenom nomdenom added the code cleanup Cosmetic enhancement to the code to make it look nicer. label Sep 28, 2018
@squidcc
Copy link
Contributor

squidcc commented Oct 5, 2018

It's possible to have static initializer functions without using C++, for example:

static void msgcmd_cpp_init_2(void)  // static initializer function
{
  msgcmd_init_event();
  msgcmd_cleanup_chatcmd_atexit();
}
// switch data segment to CRT$XCU (static constructor list)
#pragma data_seg(".CRT$XCU")
// store a pointer to the init function
void (*msgcmd_init)(void) = msgcmd_cpp_init_2;
// restore normal data segment
#pragma data_seg()

No idea if this works with mingw but I assume it would have to in order to be compatible with static libs.

@ghost ghost closed this as completed Apr 12, 2019
@sskras
Copy link
Contributor

sskras commented Apr 13, 2019

Was that fixed already? The commit stream is so fast this week that it drowned me down a bit.

@mewmew
Copy link
Contributor

mewmew commented Apr 13, 2019

Was that fixed already? The commit stream is so fast this week that it drowned me down a bit.

Haha, you are not the only one to be lost in the flurry of commits. Every time I go for lunch, sleep for a few hours, or look away from the screen, @galaxyhaxz, @AJenbo, @JustAnotherGuid and @qndel bump bin exactness by another percent or 5.

@AJenbo
Copy link
Member

AJenbo commented Apr 13, 2019

this was done as part of the move from C++ to C afaik

@ghost
Copy link
Author

ghost commented Apr 13, 2019

There really aren't any C++ parts of the code except msgcmd.cpp (which is sitting in a PR) and possibly the Critical section constructors. I thought originally Diablo had used far more CPP then it actually did, hehe.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code cleanup Cosmetic enhancement to the code to make it look nicer. low priority This should be worked on later
Projects
None yet
Development

No branches or pull requests

5 participants