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

Only use KEYBOARD.COK when it is available, otherwise use embedded table #322

Merged
merged 7 commits into from
May 4, 2023

Conversation

madebr
Copy link
Collaborator

@madebr madebr commented May 2, 2023

  • The Carmagedddon keyboard table was taken from KEYBOARD.TOK from the steam/gog release
  • All tables are now commented alongside their meaning KEY_xxx
  • Replace a few KEY_SHIFT_LSHIFT with KEY_SHIFT_ANY
    Because of this, Holding down SHIFT makes key repeat go crazy quick #321 is triggered with both shift keys.

Fixes #315

'z', /* KEY_Y */
'y', /* KEY_Z */
'^', /* KEY_GRAVE */
-0x21, /* KEY_MINUS */
Copy link
Owner

Choose a reason for hiding this comment

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

Is it supposed to be -0x21?

Copy link
Collaborator Author

@madebr madebr May 3, 2023

Choose a reason for hiding this comment

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

I think this is a German Eszett (ẞ).

>>> b'\xdf'.decode("windows-1252")
'ß'

The binary really contains FFFFFFDFh.
I think their compiler treated characters as signed ==> the 8-bit 0xdf value is negative and must be sign-extended to a 32-bit integer.

I think the Carma devs had the source file(s) containing this ascii table in the windows-1252 codepage.
This is of course unwanted by us, and we don't want to encode the Eszett as utf-8. So I think we should just hardcode 0xdf here and add an extra comment (that can use utf-8).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The German DOS version contains the same codes, but they are all positive there.
So it looks like this is an oversight/bug of OG.

The text input behavior of German Dethrace and the German DOS version is now the same.
I didn't verify the German Windows executable.

@@ -36,49 +36,884 @@ tHarness_game_config harness_game_config;
// Platform hooks
tHarness_platform gHarness_platform;

/* clang-format off */
// Carmgeddon ASCII codes
Copy link
Owner

Choose a reason for hiding this comment

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

how about putting these tables in a separate file like ascii_tables.h to avoid adding all this data to the code file?

Copy link
Owner

Choose a reason for hiding this comment

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

I did something similar with sdl2_scancode_to_dinput.h

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I created a ascii_tables.h header.

@@ -403,13 +403,15 @@ int AddRollingLetter(char pChar, int pX, int pY, tRolling_type rolling_type) {
let->current_offset = (gCurrent_graf_data->save_slot_letter_height * let->number_of_letters);
for (i = 0; i < let->number_of_letters; i++) {
if (rolling_type == eRT_numeric) {
let->letters[i] = pChar;
/* The (tU8) cast makes sure extended ASCII is positive. */
let->letters[i] = (tU8)pChar;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is done in the German Carmageddon DOS executable.

This makes sure the extended ASCII codes remain positive.
Before, these became negative here.

Not doing this causes an out-of-bounds access when reading the texture of an extended ASCII character.

@@ -0,0 +1,893 @@
#ifndef DETHRACE_ASCII_TABLES_H
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This file was generated with the attached python script + json files: ascii-codegen.zip

@madebr
Copy link
Collaborator Author

madebr commented May 4, 2023

If this pr is accepted, the new error message that is shown when no game data can be found is:
image

Copy link
Owner

@dethrace-labs dethrace-labs left a comment

Choose a reason for hiding this comment

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

Nice change!

'z', /* KEY_Y */
'y', /* KEY_Z */
'^', /* KEY_GRAVE */
0xdf, /* KEY_MINUS (ß) */
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't verify the actual textures. So there might be cases where the character in the comments does not match the actual glyph present in the texture.

@madebr madebr merged commit 07d5173 into dethrace-labs:main May 4, 2023
@madebr madebr deleted the ascii-table-in-exe branch May 4, 2023 11:27
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

Successfully merging this pull request may close these issues.

Dethrace won't start on my VMWare/Fedora 38
2 participants