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

[jak2] Pass 0x01 through format #3143

Merged
merged 2 commits into from Nov 5, 2023
Merged

Conversation

water111
Copy link
Collaborator

@water111 water111 commented Nov 4, 2023

fixes the crash when this message is displayed:

image

as far as I can tell, it looks right.

@ManDude
Copy link
Member

ManDude commented Nov 4, 2023

I think our default case in format is wrong. Our version:

        default:
          MsgErr("format: unknown code 0x%02x\n", format_ptr[1]);
          MsgErr("input was %s\n", format_cstring);
          ASSERT(false);
          break;

the ghidra output is:

switchD_00101b6c_caseD_26:
      MsgErr__3ndiPCce(0x12ce48,bVar4);
      goto LAB_0010230c;
LAB_0010230c:
    pbVar15 = pbVar15 + 1;
LAB_00102310:
    bVar4 = *pbVar15;
    bVar11 = *pbVar15;
    pbVar10 = pbVar15;
    puVar3 = local_1b0;

which is closer to:

default:
  MsgErr("format: unknown code 0x%02x\n", format_ptr[1]);
  *output_ptr = *format_ptr;
  output_ptr++;
  format_ptr++;
  break;

We have this branch:

    } else {
      // got normal char, just copy it
      *output_ptr = *format_ptr;
      output_ptr++;
    }

that we should probably just goto to in this case.

@ManDude
Copy link
Member

ManDude commented Nov 4, 2023

in other words, I think something like this is more accurate to the original code (they either had a goto or a completely different control flow in this function), less annoying, and also functional:

        default:
          MsgErr("format: unknown code 0x%02x\n", format_ptr[1]);
          // MsgErr("input was %s\n", format_cstring);
          goto copy_char_case;
      }
      format_ptr++;
    } else {
copy_char_case:
      // got normal char, just copy it
      *output_ptr = *format_ptr;
      output_ptr++;
    }
    format_ptr++;

@xTVaser xTVaser merged commit 6067c25 into master Nov 5, 2023
10 checks passed
@xTVaser xTVaser deleted the w/japanese-encoding-format-fix branch November 5, 2023 00:02
ManDude added a commit that referenced this pull request Nov 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants