Dump C code into Wedge log

This commit is contained in:
Elliot Nunn 2017-11-21 12:25:50 +08:00
parent f778eef47f
commit a6e365fcc2
3 changed files with 19 additions and 12 deletions

View File

@ -21,6 +21,6 @@ Loop
Break Break
End End
{IM}Linker "{1}" {IM}RomWedge.x {IM}Linker "{1}" {IM}RomWedge.x Wedge.c
Shift Shift
End End

View File

@ -53,16 +53,16 @@ int main(int argc, char *argv[])
{ {
FILE *fp; FILE *fp;
char *blob[2]; char *blob[3];
long size[2]; long size[3];
int i; int i;
if(argc != 3) { if(argc != 4) {
fprintf(stderr, "Usage: %s ROM WEDGE\n", argv[0]); fprintf(stderr, "Usage: %s ROM WEDGE C\n", argv[0]);
return 1; return 1;
} }
for(i=0; i<2; i++) /* Two or more, use a for. */ for(i=0; i<3; i++) /* Two or more, use a for. */
{ {
char *fname = argv[i+1]; char *fname = argv[i+1];
@ -80,26 +80,35 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
if(size[1] > 0x20000) { if(size[1] > 0x8000) {
fprintf(stderr, "%s: WEDGE is 0x%X bytes, to large\n", argv[0], size[1]); fprintf(stderr, "%s: WEDGE is 0x%X bytes, to large\n", argv[0], size[1]);
return 1; return 1;
} }
if(size[2] > 0x10000) {
fprintf(stderr, "%s: C is 0x%X bytes, to large\n", argv[0], size[2]);
return 1;
}
if(blob[0][0x340000] == 0) { if(blob[0][0x340000] == 0) {
/* NanoKernel needs to be moved */ /* NanoKernel needs to be moved */
printf("Moving NanoKernel from 310000 to 340000.\n"); printf("Moving NanoKernel from 310000 to 340000.\n");
memcpy(blob[0] + 0x340000, blob[0] + 0x310000, 0x20000); memcpy(blob[0] + 0x340000, blob[0] + 0x310000, 0x20000);
printf("Erasing original NanoKernel location.\n"); printf("Erasing original NanoKernel location.\n");
memset(blob[0] + 0x310000, 0, 0x20000); memset(blob[0] + 0x310000, 0, 0x30000);
} else { } else {
printf("NanoKernel already moved to 340000. Erasing old Wedge.\n"); printf("NanoKernel already moved to 340000. Erasing old Wedge.\n");
memset(blob[0] + 0x310000, 0, 0x20000); memset(blob[0] + 0x310000, 0, 0x30000);
} }
printf("Copying Wedge (0x%X bytes).\n", size[1]); printf("Copying Wedge code to 310000 (0x%X bytes).\n", size[1]);
memcpy(blob[0] + 0x310000, blob[1], size[1]); memcpy(blob[0] + 0x310000, blob[1], size[1]);
printf("Copying C source into log at 320000 (0x%X bytes).\n", size[2]);
memcpy(blob[0] + 0x320000, blob[2], size[2]);
*(long *)(blob[0] + 0x320000 - 4) = size[2];
printf("Writing out.\n"); printf("Writing out.\n");
fp = fopen(argv[1], "wb"); fp = fopen(argv[1], "wb");

View File

@ -48,8 +48,6 @@ Magic equ 'Wdg_'
lisori r20, PA_ROM + Middle lisori r20, PA_ROM + Middle
lisori r0, 'WgLg' lisori r0, 'WgLg'
stw r0, -8(r20) stw r0, -8(r20)
li r0, 0
stw r0, -4(r20)
; Search for the string table (tested, works) ; Search for the string table (tested, works)