annotate blastcpm.c @ 1507:2455662378ed mame_interp

Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
author Michael Pavone <pavone@retrodev.com>
date Sat, 30 Dec 2017 18:27:06 -0800
parents 8f14767661fa
children 8fe162bdb038
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
820
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <stdio.h>
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stdlib.h>
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include <stddef.h>
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include <string.h>
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include <sys/select.h>
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6
1507
2455662378ed Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
7 #ifdef USE_NATIVE
820
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 #include "z80_to_x86.h"
1507
2455662378ed Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
9 #else
2455662378ed Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
10 #include "mame_z80/z80.h"
2455662378ed Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
11 #endif
820
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 #include "util.h"
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 uint8_t ram[64 * 1024];
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 #define START_OFF 0x100
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 #define OS_START 0xE400
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 #define OS_RESET 0xE403
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 int headless = 1;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 void z80_next_int_pulse(z80_context * context)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 void render_errorbox(char *title, char *message)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
28 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
29
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
30 void render_infobox(char *title, char *message)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
31 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
32 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
33
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
34 void *console_write(uint32_t address, void *context, uint8_t value)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
35 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
36 putchar(value);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
37 return context;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
38 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
39
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
40 uint8_t console_read(uint32_t address, void *context)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
41 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
42 return getchar();
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
43 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
44
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
45 void *console_flush_write(uint32_t address, void *context, uint8_t value)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
46 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
47 fflush(stdout);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
48 return context;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
49 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
50
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
51 uint8_t console_status_read(uint32_t address, void *context)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
52 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
53 fd_set read_fds;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
54 FD_ZERO(&read_fds);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
55 struct timeval timeout;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
56 timeout.tv_sec = 0;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
57 timeout.tv_usec = 0;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
58 FD_SET(fileno(stdin), &read_fds);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
59 return select(fileno(stdin)+1, &read_fds, NULL, NULL, &timeout) > 0;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
60 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
61
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
62 void *exit_write(uint32_t address, void *context, uint8_t value)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
63 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
64 exit(0);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
65 return context;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
66 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
67
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
68 const memmap_chunk z80_map[] = {
1130
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
69 { 0x0000, 0x10000, 0xFFFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, ram, NULL, NULL, NULL, NULL},
820
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
70 };
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
71
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
72 const memmap_chunk io_map[] = {
1130
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
73 { 0x0, 0x1, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_read, console_write},
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
74 { 0x1, 0x2, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_status_read, console_flush_write},
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
75 { 0x2, 0x3, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, NULL, exit_write},
820
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
76 };
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
77
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
78 int main(int argc, char **argv)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
79 {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
80 FILE *f = fopen("fake_cpm.bin", "rb");
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
81 long fsize = file_size(f);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
82 if (fsize > sizeof(ram) - OS_START) {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
83 fsize = sizeof(ram) - OS_START;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 if (fread(ram + OS_START, 1, fsize, f) != fsize) {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
86 fprintf(stderr, "Error reading from fake_cpm.bin\n");
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
87 exit(1);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
88 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
89 f = fopen(argv[1], "rb");
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
90 fsize = file_size(f);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
91 if (fsize > OS_START - START_OFF) {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
92 fsize = OS_START - START_OFF;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
93 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
94 if (fread(ram + START_OFF, 1, fsize, f) != fsize) {
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
95 fprintf(stderr, "Error reading from file %s\n", argv[1]);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
96 exit(1);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
97 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
98 fclose(f);
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
99 ram[0] = 0xC3;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
100 ram[1] = OS_RESET & 0xFF;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
101 ram[2] = OS_RESET >> 8;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
102 ram[5] = 0xC3;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 ram[6] = OS_START & 0xFF;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
104 ram[7] = OS_START >> 8;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
105
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
106 z80_options opts;
1130
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
107 z80_context *context;
1116
fe8c79f82c22 More cleanup in preparation for SMS/Mark III support
Michael Pavone <pavone@retrodev.com>
parents: 820
diff changeset
108 init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF);
1130
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
109 context = init_z80_context(&opts);
820
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
110 for(;;)
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
111 {
1130
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
112 z80_run(context, 1000000);
8f14767661fa Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents: 1116
diff changeset
113 context->current_cycle = 0;
820
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
114 }
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
115 return 0;
cf6149b7c6e5 Implement a tiny bit of CPM BDOS and add a corresponding Z80 core driver so that simple CPM programs like ZEXDOC/ZEXALL can be run against my Z80 core
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
116 }