Skip to content

Commit

Permalink
Fix peekInfinite and game info command for usb.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koi-3088 committed Apr 1, 2023
1 parent 94bee88 commit a8019bf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
22 changes: 12 additions & 10 deletions sys-botbase/source/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,35 +265,37 @@ void peekInfinite(u64 offset, u64 size)
u64 sizeRemainder = size;
u64 totalFetched = 0;
u8 *out = malloc(sizeof(u8) * MAX_LINE_LENGTH);
u8 *usbOut = malloc(size);

attach();
while (sizeRemainder > 0)
{
u64 thisBuffersize = sizeRemainder > MAX_LINE_LENGTH ? MAX_LINE_LENGTH : sizeRemainder;
sizeRemainder -= thisBuffersize;
readMem(out, offset + totalFetched, thisBuffersize);
if (!usb)

u64 i;
for (i = 0; i < thisBuffersize; i++)
{
u64 i;
for (i = 0; i < thisBuffersize; i++)
{
printf("%02X", out[i]);
}
if (usb)
usbOut[totalFetched + i] = out[i];
else printf("%02X", out[i]);
}

totalFetched += thisBuffersize;
}

detach();
if (usb)
{
response.size = totalFetched;
response.data = &out[0];
response.size = size;
response.data = &usbOut[0];
sendUsbResponse(response);
}
else printf("\n");

detach();
printf("\n");
free(out);
free(usbOut);
}

void peekMulti(u64* offset, u64* size, u64 count)
Expand Down
17 changes: 11 additions & 6 deletions sys-botbase/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,19 +404,24 @@ int argmain(int argc, char **argv)
NacpLanguageEntry* langentry = NULL;
if (outsize != 0) {
if (!strcmp(argv[1], "icon")) {
u8* icon = malloc(outsize);

u64 i;
for (i = 0; i < outsize - sizeof(buf->nacp); i++)
{
u8 ic = buf->icon[i];
if (usb)
{
response.size = sizeof(ic);
response.data = &ic;
sendUsbResponse(response);
}
icon[i] = ic;
else printf("%02X", ic);
}
printf("\n");
if (usb)
{
response.size = outsize;
response.data = &icon[0];
sendUsbResponse(response);
}
else printf("\n");
free(icon);
}
if (!strcmp(argv[1], "version"))
{
Expand Down

0 comments on commit a8019bf

Please sign in to comment.