comparison 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
comparison
equal deleted inserted replaced
1768:63256371046f 1769:8fe162bdb038
1 #include <stdio.h> 1 #include <stdio.h>
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 <time.h>
5 #include <sys/select.h> 6 #include <sys/select.h>
6 7
8 #ifdef NEW_CORE
9 #include "z80.h"
10 #else
7 #ifdef USE_NATIVE 11 #ifdef USE_NATIVE
8 #include "z80_to_x86.h" 12 #include "z80_to_x86.h"
9 #else 13 #else
10 #include "mame_z80/z80.h" 14 #include "mame_z80/z80.h"
15 #endif
11 #endif 16 #endif
12 #include "util.h" 17 #include "util.h"
13 18
14 uint8_t ram[64 * 1024]; 19 uint8_t ram[64 * 1024];
15 20
16 #define START_OFF 0x100 21 #define START_OFF 0x100
17 #define OS_START 0xE400 22 #define OS_START 0xE400
18 #define OS_RESET 0xE403 23 #define OS_RESET 0xE403
19 int headless = 1; 24 int headless = 1;
20 25
26 #ifndef NEW_CORE
21 void z80_next_int_pulse(z80_context * context) 27 void z80_next_int_pulse(z80_context * context)
22 { 28 {
23 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER; 29 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER;
24 } 30 }
31 #endif
25 32
26 void render_errorbox(char *title, char *message) 33 void render_errorbox(char *title, char *message)
27 { 34 {
28 } 35 }
29 36
57 timeout.tv_usec = 0; 64 timeout.tv_usec = 0;
58 FD_SET(fileno(stdin), &read_fds); 65 FD_SET(fileno(stdin), &read_fds);
59 return select(fileno(stdin)+1, &read_fds, NULL, NULL, &timeout) > 0; 66 return select(fileno(stdin)+1, &read_fds, NULL, NULL, &timeout) > 0;
60 } 67 }
61 68
69 time_t start;
70 uint64_t total_cycles;
62 void *exit_write(uint32_t address, void *context, uint8_t value) 71 void *exit_write(uint32_t address, void *context, uint8_t value)
63 { 72 {
73 time_t duration = time(NULL) - start;
74 z80_context *z80 = context;
75 #ifdef NEW_CORE
76 total_cycles += z80->cycles;
77 #else
78 total_cycles += context->current_cycle;
79 #endif
80 printf("Effective clock speed: %f MHz\n", ((double)total_cycles) / (1000000.0 * duration));
64 exit(0); 81 exit(0);
65 return context; 82 return context;
66 } 83 }
67 84
68 const memmap_chunk z80_map[] = { 85 const memmap_chunk z80_map[] = {
69 { 0x0000, 0x10000, 0xFFFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, ram, NULL, NULL, NULL, NULL}, 86 { 0x0000, 0x10000, 0xFFFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, ram, NULL, NULL, NULL, NULL},
70 }; 87 };
71 88
72 const memmap_chunk io_map[] = { 89 memmap_chunk io_map[] = {
73 { 0x0, 0x1, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_read, console_write}, 90 { 0x0, 0x1, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_read, console_write},
74 { 0x1, 0x2, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_status_read, console_flush_write}, 91 { 0x1, 0x2, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_status_read, console_flush_write},
75 { 0x2, 0x3, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, NULL, exit_write}, 92 { 0x2, 0x3, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, NULL, exit_write},
76 }; 93 };
77 94
105 122
106 z80_options opts; 123 z80_options opts;
107 z80_context *context; 124 z80_context *context;
108 init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF); 125 init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF);
109 context = init_z80_context(&opts); 126 context = init_z80_context(&opts);
127 start = time(NULL);
110 for(;;) 128 for(;;)
111 { 129 {
130 #ifdef NEW_CORE
131 z80_execute(context, 1000000);
132 total_cycles += context->cycles;
133 context->cycles = 0;
134 #else
112 z80_run(context, 1000000); 135 z80_run(context, 1000000);
136 total_cycles += context->current_cycle;
113 context->current_cycle = 0; 137 context->current_cycle = 0;
138 #endif
139
114 } 140 }
115 return 0; 141 return 0;
116 } 142 }