Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/DMG/MBC.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Text;

class MBC {
//MBC is currently only experimental
//MBC0/ROM Only should be good
Expand Down Expand Up @@ -106,17 +108,15 @@ private int CalculateRomSize(byte headerValue) {
}

public string GetTitle() {
byte[] titleBytes = new byte[16];
Array.Copy(rom, 0x0134, titleBytes, 0, 16);

string title = System.Text.Encoding.ASCII.GetString(titleBytes).TrimEnd(null);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

.TrimEnd('\0')

should also solve this issue


if (title.Length > 16)
{
title = title.Substring(0, 16);
int titleStart = 0x0134;
int titleLength;
for (titleLength = 0; titleLength < 16; titleLength++) {
if (rom[titleStart + titleLength] == 0) {
break;
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this if needed if the Array is 16 long?

return "Title: " + title;
string title = Encoding.ASCII.GetString(rom, titleStart, titleLength);
return $"Title: {title}";
}

public string GetCartridgeType() {
Expand Down