comparison blastcpm.c @ 1735:ca2336469397

Get new Z80 core running in CPM harness
author Michael Pavone <pavone@retrodev.com>
date Sun, 03 Feb 2019 11:05:40 -0800
parents 8f14767661fa
children 48a43dff4dc0
comparison
equal deleted inserted replaced
1734:88fbc4e711fd 1735:ca2336469397
2 #include <stdlib.h> 2 #include <stdlib.h>
3 #include <stddef.h> 3 #include <stddef.h>
4 #include <string.h> 4 #include <string.h>
5 #include <sys/select.h> 5 #include <sys/select.h>
6 6
7 #ifdef NEW_CORE
8 #include "z80.h"
9 #else
7 #include "z80_to_x86.h" 10 #include "z80_to_x86.h"
11 #endif
8 #include "util.h" 12 #include "util.h"
9 13
10 uint8_t ram[64 * 1024]; 14 uint8_t ram[64 * 1024];
11 15
12 #define START_OFF 0x100 16 #define START_OFF 0x100
13 #define OS_START 0xE400 17 #define OS_START 0xE400
14 #define OS_RESET 0xE403 18 #define OS_RESET 0xE403
15 int headless = 1; 19 int headless = 1;
16 20
21 #ifndef NEW_CORE
17 void z80_next_int_pulse(z80_context * context) 22 void z80_next_int_pulse(z80_context * context)
18 { 23 {
19 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER; 24 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER;
20 } 25 }
26 #endif
21 27
22 void render_errorbox(char *title, char *message) 28 void render_errorbox(char *title, char *message)
23 { 29 {
24 } 30 }
25 31
63 69
64 const memmap_chunk z80_map[] = { 70 const memmap_chunk z80_map[] = {
65 { 0x0000, 0x10000, 0xFFFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, ram, NULL, NULL, NULL, NULL}, 71 { 0x0000, 0x10000, 0xFFFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, ram, NULL, NULL, NULL, NULL},
66 }; 72 };
67 73
68 const memmap_chunk io_map[] = { 74 memmap_chunk io_map[] = {
69 { 0x0, 0x1, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_read, console_write}, 75 { 0x0, 0x1, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_read, console_write},
70 { 0x1, 0x2, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_status_read, console_flush_write}, 76 { 0x1, 0x2, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_status_read, console_flush_write},
71 { 0x2, 0x3, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, NULL, exit_write}, 77 { 0x2, 0x3, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, NULL, exit_write},
72 }; 78 };
73 79
99 ram[6] = OS_START & 0xFF; 105 ram[6] = OS_START & 0xFF;
100 ram[7] = OS_START >> 8; 106 ram[7] = OS_START >> 8;
101 107
102 z80_options opts; 108 z80_options opts;
103 z80_context *context; 109 z80_context *context;
110 #ifdef NEW_CORE
111 memset(&opts, 0, sizeof(opts));
112 opts.gen.memmap = z80_map;
113 opts.gen.memmap_chunks = 1;
114 opts.gen.address_mask = 0xFFFF;
115 opts.gen.max_address = 0xFFFF;
116 opts.gen.clock_divider = 1;
117 context = calloc(1, sizeof(z80_context));
118 context->opts = &opts;
119 context->io_map = io_map;
120 context->io_chunks = 3;
121 context->io_mask = 0xFF;
122 #else
104 init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF); 123 init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF);
105 context = init_z80_context(&opts); 124 context = init_z80_context(&opts);
125 #endif
106 for(;;) 126 for(;;)
107 { 127 {
128 #ifdef NEW_CORE
129 z80_execute(context, 1000000);
130 context->cycles = 0;
131 #else
108 z80_run(context, 1000000); 132 z80_run(context, 1000000);
109 context->current_cycle = 0; 133 context->current_cycle = 0;
134 #endif
135
110 } 136 }
111 return 0; 137 return 0;
112 } 138 }