- [NEW] load binary to memory from inside or as arguments to exe

- Trying berserk
This commit is contained in:
2024-04-25 06:41:35 +02:00
parent b05ce14a95
commit 7eb5df248f
7 changed files with 65 additions and 6 deletions

View File

@@ -74,7 +74,7 @@ namespace z80debug
void show()
{
is_debugging = true;
is_debugging = false;
if (win) return;
win = SDL_CreateWindow("Z80 Debugger", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 71*CHR_W, 34*CHR_H, SDL_WINDOW_RESIZABLE);
ren = SDL_CreateRenderer(win, -1, 0);
@@ -421,6 +421,14 @@ namespace z80debug
int address = getnum(cmd);
if (address<0 || address>65536) { strcpy(console_error, "Illegal memory address"); return; }
mem_viewer_pos = address;
} else if (strcmp(cmd, "l")==0 || strcmp(cmd, "load")==0) {
getcmd();
char filename[256];
strcpy(filename, cmd);
getcmd();
char address[256];
strcpy(address, cmd);
loadngo(filename, address);
}
}
@@ -441,4 +449,20 @@ namespace z80debug
{
mem_modified[addr] = true;
}
void loadngo(const char* filename, const char* addr)
{
int address = getnum(addr);
if (address<0 || address>65536) { strcpy(console_error, "Illegal offset"); return; }
FILE *f = fopen(filename, "rb");
fseek(f, 0, SEEK_END);
int size = ftell(f);
fseek(f, 0, SEEK_SET);
uint8_t *memory = z80::getMem();
fread(memory+address, size, 1, f);
fclose(f);
z80::setPC(address);
is_debugging = false;
}
}