Setting up PAT80 Emulator
This commit is contained in:
parent
1c77bc82ac
commit
7ce4046796
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "pat80-emulator/z80"]
|
||||
path = pat80-emulator/z80
|
||||
url = git@github.com:algodesigner/z80.git
|
1
pat80-emulator/.gitignore
vendored
Normal file
1
pat80-emulator/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
pat80emu
|
5
pat80-emulator/Makefile
Normal file
5
pat80-emulator/Makefile
Normal file
@ -0,0 +1,5 @@
|
||||
build:
|
||||
gcc -g -o pat80emu z80/console.c z80/z80.c main.c
|
||||
clean:
|
||||
rm -rf main
|
||||
all: clean build
|
9
pat80-emulator/README.md
Normal file
9
pat80-emulator/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
# PAT80 Emulator
|
||||
Uses algodesigner's Z80 emulator (see submodule in z80 folder).
|
||||
Instances the Z80 object (representing the CPU) and:
|
||||
- intercepts all memory access and returns the corresponding rom value (read from rom file) if PC is in first 32k of memory (TODO)
|
||||
- intercepts all memory access and stops execution returning error if trying to write to first 32k of memory (TODO)
|
||||
|
||||
## Usage
|
||||
Build with `make all`
|
||||
Run with `./pat80emu`
|
34
pat80-emulator/main.c
Normal file
34
pat80-emulator/main.c
Normal file
@ -0,0 +1,34 @@
|
||||
#include <stdio.h>
|
||||
#include "z80/z80.h"
|
||||
|
||||
/*
|
||||
* The intercept function is invoked on each and every CPU instruction. It
|
||||
* quits the simulation when the PC register reaches address #0005 by changing
|
||||
* the virtual CPU status.
|
||||
*/
|
||||
static void intercept(void *ctx)
|
||||
{
|
||||
z80 *cpu = ctx;
|
||||
if (PC == 5) {
|
||||
puts("\nReached address: 5, terminating the simulation...");
|
||||
cpu->status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
/*
|
||||
* Instantiate the CPU, activate the debug mode, set the intercept
|
||||
* function and run the virtual CPU until the termination criteria
|
||||
* set by the intercept function, if any, are met.
|
||||
*/
|
||||
z80 *cpu = z80_new();
|
||||
cpu->debug = 1;
|
||||
|
||||
// TODO: Copy rom to first 32k CPU memory
|
||||
_RamWrite(0x03, 0x76); // As an example, here is how to set HALT at posizion 0x03. Use a loop to copy memory from a PAT80 OS rom file.
|
||||
|
||||
z80_set_intercept(cpu, cpu, intercept);
|
||||
z80_run(cpu);
|
||||
z80_destroy(cpu);
|
||||
}
|
1
pat80-emulator/z80
Submodule
1
pat80-emulator/z80
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 80df33fc873e8eb374c1fcb33458a1b7220d20db
|
Loading…
Reference in New Issue
Block a user