- [NEW] load binary to memory from inside or as arguments to exe
- Trying berserk
This commit is contained in:
6
main.cpp
6
main.cpp
@@ -28,6 +28,8 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
zx_tape::load("manic.tap");
|
zx_tape::load("manic.tap");
|
||||||
|
|
||||||
|
if (argc==3) { z80debug::loadngo(argv[1], argv[2]); }
|
||||||
|
|
||||||
bool should_exit = false;
|
bool should_exit = false;
|
||||||
SDL_Event e;
|
SDL_Event e;
|
||||||
|
|
||||||
@@ -86,12 +88,10 @@ int main(int argc, char *argv[])
|
|||||||
z80debug::stop();
|
z80debug::stop();
|
||||||
zxscreen::redraw();
|
zxscreen::redraw();
|
||||||
} else {
|
} else {
|
||||||
//if (z80::getPC()==0x05C8) zx_tape::go_berserk();
|
if (z80::getPC()==0x05C8) zx_tape::go_berserk();
|
||||||
uint8_t dt = z80::step();
|
uint8_t dt = z80::step();
|
||||||
zx_tape::update(dt);
|
zx_tape::update(dt);
|
||||||
//if (!zx_tape::berserk()) {
|
|
||||||
zx_ula::sound_update(dt);
|
zx_ula::sound_update(dt);
|
||||||
//}
|
|
||||||
zxscreen::refresh(dt);
|
zxscreen::refresh(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
27
test.asm
Normal file
27
test.asm
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
.org $8000
|
||||||
|
|
||||||
|
ei
|
||||||
|
START:
|
||||||
|
ld a, 2
|
||||||
|
out ($fe), a
|
||||||
|
ld b, 255
|
||||||
|
ld de, TILES
|
||||||
|
ld hl, $4000
|
||||||
|
LOOP:
|
||||||
|
ld a, (de)
|
||||||
|
ld (hl), a
|
||||||
|
inc e
|
||||||
|
inc h
|
||||||
|
djnz LOOP
|
||||||
|
ld a, (de)
|
||||||
|
ld hl, $5800
|
||||||
|
ld (hl), a
|
||||||
|
|
||||||
|
ld a, 0
|
||||||
|
out ($fe), a
|
||||||
|
|
||||||
|
halt
|
||||||
|
jr START
|
||||||
|
|
||||||
|
TILES: db $81, $42, $24, $18, $18, $24, $42, $81, $4d
|
||||||
|
|
||||||
3
z80.cpp
3
z80.cpp
@@ -684,7 +684,7 @@ namespace z80
|
|||||||
if (exit_from_halt) {
|
if (exit_from_halt) {
|
||||||
exit_from_halt = false;
|
exit_from_halt = false;
|
||||||
} else {
|
} else {
|
||||||
printf("HALT\n");
|
//printf("HALT\n");
|
||||||
rPC--;
|
rPC--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2697,4 +2697,5 @@ namespace z80
|
|||||||
|
|
||||||
uint16_t getPC() { return rPC; }
|
uint16_t getPC() { return rPC; }
|
||||||
|
|
||||||
|
void setPC(const uint16_t addr) { rPC = addr; }
|
||||||
}
|
}
|
||||||
2
z80.h
2
z80.h
@@ -21,4 +21,6 @@ namespace z80
|
|||||||
uint16_t getIY();
|
uint16_t getIY();
|
||||||
uint16_t getSP();
|
uint16_t getSP();
|
||||||
uint16_t getPC();
|
uint16_t getPC();
|
||||||
|
|
||||||
|
void setPC(const uint16_t addr);
|
||||||
}
|
}
|
||||||
26
z80debug.cpp
26
z80debug.cpp
@@ -74,7 +74,7 @@ namespace z80debug
|
|||||||
|
|
||||||
void show()
|
void show()
|
||||||
{
|
{
|
||||||
is_debugging = true;
|
is_debugging = false;
|
||||||
if (win) return;
|
if (win) return;
|
||||||
win = SDL_CreateWindow("Z80 Debugger", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 71*CHR_W, 34*CHR_H, SDL_WINDOW_RESIZABLE);
|
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);
|
ren = SDL_CreateRenderer(win, -1, 0);
|
||||||
@@ -421,6 +421,14 @@ namespace z80debug
|
|||||||
int address = getnum(cmd);
|
int address = getnum(cmd);
|
||||||
if (address<0 || address>65536) { strcpy(console_error, "Illegal memory address"); return; }
|
if (address<0 || address>65536) { strcpy(console_error, "Illegal memory address"); return; }
|
||||||
mem_viewer_pos = address;
|
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;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -17,4 +17,6 @@ namespace z80debug
|
|||||||
|
|
||||||
const bool isbreak(const uint16_t address, const uint8_t type=1);
|
const bool isbreak(const uint16_t address, const uint8_t type=1);
|
||||||
uint32_t next();
|
uint32_t next();
|
||||||
|
|
||||||
|
void loadngo(const char* filename, const char* addr);
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "z80.h"
|
#include "z80.h"
|
||||||
#include "zx_ula.h"
|
#include "zx_ula.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
#include "zx_tape.h"
|
||||||
|
|
||||||
namespace zxscreen
|
namespace zxscreen
|
||||||
{
|
{
|
||||||
@@ -143,6 +144,8 @@ namespace zxscreen
|
|||||||
|
|
||||||
void redraw()
|
void redraw()
|
||||||
{
|
{
|
||||||
|
if (zx_tape::berserk()) return;
|
||||||
|
|
||||||
Uint32* pixels;
|
Uint32* pixels;
|
||||||
int pitch;
|
int pitch;
|
||||||
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
SDL_LockTexture(tex, NULL, (void**)&pixels, &pitch);
|
||||||
|
|||||||
Reference in New Issue
Block a user