Mercurial > repos > blastem
annotate blastcpm.c @ 1769:8fe162bdb038 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 01 Mar 2019 14:17:29 -0800 |
parents | 2455662378ed 95e36a227c9d |
children | 0a26f3657295 |
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> |
1760
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
5 #include <time.h> |
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
|
6 #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
|
7 |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
8 #ifdef NEW_CORE |
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
9 #include "z80.h" |
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
10 #else |
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
|
11 #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
|
12 #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
|
13 #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
|
14 #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
|
15 #endif |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
16 #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
|
17 #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
|
18 |
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 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
|
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 #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
|
22 #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
|
23 #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
|
24 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
|
25 |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
26 #ifndef NEW_CORE |
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
|
27 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
|
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 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
|
30 } |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
31 #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
|
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 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
|
34 { |
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 |
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 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
|
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 |
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 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
|
42 { |
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 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
|
44 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
|
45 } |
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 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
|
48 { |
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 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
|
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 |
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 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
|
53 { |
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 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
|
55 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
|
56 } |
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 |
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 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
|
59 { |
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 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
|
61 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
|
62 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
|
63 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
|
64 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
|
65 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
|
66 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
|
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 |
1760
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
69 time_t start; |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
70 uint64_t total_cycles; |
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
|
71 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
|
72 { |
1760
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
73 time_t duration = time(NULL) - start; |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
74 z80_context *z80 = context; |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
75 #ifdef NEW_CORE |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
76 total_cycles += z80->cycles; |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
77 #else |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
78 total_cycles += context->current_cycle; |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
79 #endif |
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
80 printf("Effective clock speed: %f MHz\n", ((double)total_cycles) / (1000000.0 * duration)); |
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
|
81 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
|
82 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
|
83 } |
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 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
|
86 { 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
|
87 }; |
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 |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
89 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
|
90 { 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
|
91 { 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
|
92 { 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
|
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 |
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 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
|
96 { |
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 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
|
98 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
|
99 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
|
100 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
|
101 } |
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 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
|
103 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
|
104 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
|
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 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
|
107 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
|
108 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
|
109 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
|
110 } |
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 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
|
112 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
|
113 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
|
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 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 |
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
|
123 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
|
124 z80_context *context; |
1116
fe8c79f82c22
More cleanup in preparation for SMS/Mark III support
Michael Pavone <pavone@retrodev.com>
parents:
820
diff
changeset
|
125 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
|
126 context = init_z80_context(&opts); |
1760
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
127 start = time(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
|
128 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
|
129 { |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
130 #ifdef NEW_CORE |
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
131 z80_execute(context, 1000000); |
1760
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
132 total_cycles += context->cycles; |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
133 context->cycles = 0; |
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
134 #else |
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
|
135 z80_run(context, 1000000); |
1760
95e36a227c9d
Add emulated MHz output to blastcpm
Michael Pavone <pavone@retrodev.com>
parents:
1748
diff
changeset
|
136 total_cycles += context->current_cycle; |
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
|
137 context->current_cycle = 0; |
1735
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
138 #endif |
ca2336469397
Get new Z80 core running in CPM harness
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
139 |
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
|
140 } |
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
|
141 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
|
142 } |