Mercurial > repos > blastem
comparison blastcpm.c @ 1773:0a26f3657295 mame_interp
Remove MAME Z80 core in favor of my new Z80 core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 12 Mar 2019 21:59:52 -0700 |
parents | 8fe162bdb038 |
children | 374a5ae694e8 |
comparison
equal
deleted
inserted
replaced
1772:75172d440900 | 1773:0a26f3657295 |
---|---|
3 #include <stddef.h> | 3 #include <stddef.h> |
4 #include <string.h> | 4 #include <string.h> |
5 #include <time.h> | 5 #include <time.h> |
6 #include <sys/select.h> | 6 #include <sys/select.h> |
7 | 7 |
8 #ifdef NEW_CORE | |
9 #include "z80.h" | |
10 #else | |
11 #ifdef USE_NATIVE | 8 #ifdef USE_NATIVE |
12 #include "z80_to_x86.h" | 9 #include "z80_to_x86.h" |
13 #else | 10 #else |
14 #include "mame_z80/z80.h" | 11 #include "z80.h" |
15 #endif | |
16 #endif | 12 #endif |
17 #include "util.h" | 13 #include "util.h" |
18 | 14 |
19 uint8_t ram[64 * 1024]; | 15 uint8_t ram[64 * 1024]; |
20 | 16 |
21 #define START_OFF 0x100 | 17 #define START_OFF 0x100 |
22 #define OS_START 0xE400 | 18 #define OS_START 0xE400 |
23 #define OS_RESET 0xE403 | 19 #define OS_RESET 0xE403 |
24 int headless = 1; | 20 int headless = 1; |
25 | 21 |
26 #ifndef NEW_CORE | 22 #ifdef USE_NATIVE |
27 void z80_next_int_pulse(z80_context * context) | 23 void z80_next_int_pulse(z80_context * context) |
28 { | 24 { |
29 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER; | 25 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER; |
30 } | 26 } |
31 #endif | 27 #endif |
70 uint64_t total_cycles; | 66 uint64_t total_cycles; |
71 void *exit_write(uint32_t address, void *context, uint8_t value) | 67 void *exit_write(uint32_t address, void *context, uint8_t value) |
72 { | 68 { |
73 time_t duration = time(NULL) - start; | 69 time_t duration = time(NULL) - start; |
74 z80_context *z80 = context; | 70 z80_context *z80 = context; |
75 #ifdef NEW_CORE | 71 #ifdef USE_NATIVE |
72 total_cycles += context->current_cycle; | |
73 #else | |
76 total_cycles += z80->cycles; | 74 total_cycles += z80->cycles; |
77 #else | |
78 total_cycles += context->current_cycle; | |
79 #endif | 75 #endif |
80 printf("Effective clock speed: %f MHz\n", ((double)total_cycles) / (1000000.0 * duration)); | 76 printf("Effective clock speed: %f MHz\n", ((double)total_cycles) / (1000000.0 * duration)); |
81 exit(0); | 77 exit(0); |
82 return context; | 78 return context; |
83 } | 79 } |
125 init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF); | 121 init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF); |
126 context = init_z80_context(&opts); | 122 context = init_z80_context(&opts); |
127 start = time(NULL); | 123 start = time(NULL); |
128 for(;;) | 124 for(;;) |
129 { | 125 { |
130 #ifdef NEW_CORE | 126 z80_run(context, 1000000); |
131 z80_execute(context, 1000000); | 127 #ifdef USE_NATIVE |
128 total_cycles += context->current_cycle; | |
129 context->current_cycle = 0; | |
130 #else | |
132 total_cycles += context->cycles; | 131 total_cycles += context->cycles; |
133 context->cycles = 0; | 132 context->cycles = 0; |
134 #else | |
135 z80_run(context, 1000000); | |
136 total_cycles += context->current_cycle; | |
137 context->current_cycle = 0; | |
138 #endif | 133 #endif |
139 | 134 |
140 } | 135 } |
141 return 0; | 136 return 0; |
142 } | 137 } |