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

Is the Kilrathi Exe limited to e.g. 127 ASCII characters in WC1? #3

Open
MartyShepard opened this issue Mar 10, 2021 · 7 comments
Open

Comments

@MartyShepard
Copy link

Hello,
Is there a technical problem with special characters and umlauts in the ASCII table from character 128?

Would you like to have a look here?

https://www.wcnews.com/chatzone/threads/wing-commander-toolbox.27769/post-411413

greetings

@Bekenn
Copy link
Owner

Bekenn commented Mar 10, 2021

I don't know the answer to this offhand; I'll need to spend some time investigating.

@MartyShepard
Copy link
Author

That would be great if you would have a look. I've already looked myself to death and tried different things.
Could this be due to the VisualC ++ 3.1 compiler that was used at the time?

@Bekenn
Copy link
Owner

Bekenn commented Mar 11, 2021

I could imagine that this has something to do with sign-extending a char to an integer offset, but that's just speculation. I'll take a look when I have some free time; maybe this weekend, we'll see.

@Bekenn
Copy link
Owner

Bekenn commented Mar 13, 2021

Yup, it's sign-extending the char value. That means that values above 127 are treated as negative offsets into the font table, which explains what you're seeing. It's fixable, but there are a lot of locations to track down.

@MartyShepard
Copy link
Author

I would like to fix it myself so that I can translate the Kilrathi Saga WC1. But now I don't know where to look for it in the code. Do you like to do that?

Kilrathi Saga WC2. I have not yet checked whether it is the same as with WC1.

regards

@Bekenn
Copy link
Owner

Bekenn commented Mar 15, 2021

I don't include my IDA databases in the wcdx repo because they contain complete program code for the executables that originally shipped as part of Kilrathi Saga, and those executables do not belong to me. That makes it a bit harder to collaborate on the disassembling and patching aspects of this project, but I can at least point you in the right direction. Wing1.exe has a function at virtual address 0x43AD4E (file offset 0x3A14E) that I have named DrawText, which takes a const char* argument:

void __stdcall DrawText(const char* text)

It references a static structure located at virtual address 0x62264C that I've named ActiveTextContext. That structure has this layout:

#pragma pack(1)
struct TextContext
{
    Viewport* viewport;
    int16_t x;
    int16_t y;
    void* font;	// font data loaded from a resource file
    uint8_t foregroundColor;
    uint8_t backgroundColor;
    const char* textFirst;
    const char* textLast;
    uint8_t alignment;          // specifies left, center, or right alignment
    void* fontSomething;	    // haven't figured this one out yet
	Viewport* anotherViewport;	// not sure what this is used for yet, either
    uint8_t somethingElse;      // not sure about this one, either
};

The text context determines where text will be drawn to the screen. The textFirst and textLast fields are used to compose a row of text; they point into the string passed into the DrawText function.

Hopefully that's enough to get you going in the right direction. At some point, I'll revisit this myself and see if I can get your translation working.

@MartyShepard
Copy link
Author

Hi,
Many thanks . That’s a start. I'll take a look .. but it's still a little bit of new territory for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants