diff 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
line wrap: on
line diff
--- a/blastcpm.c	Fri Mar 01 08:17:57 2019 -0800
+++ b/blastcpm.c	Fri Mar 01 14:17:29 2019 -0800
@@ -2,13 +2,18 @@
 #include <stdlib.h>
 #include <stddef.h>
 #include <string.h>
+#include <time.h>
 #include <sys/select.h>
 
+#ifdef NEW_CORE
+#include "z80.h"
+#else
 #ifdef USE_NATIVE
 #include "z80_to_x86.h"
 #else
 #include "mame_z80/z80.h"
 #endif
+#endif
 #include "util.h"
 
 uint8_t ram[64 * 1024];
@@ -18,10 +23,12 @@
 #define OS_RESET 0xE403
 int headless = 1;
 
+#ifndef NEW_CORE
 void z80_next_int_pulse(z80_context * context)
 {
 	context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER;
 }
+#endif
 
 void render_errorbox(char *title, char *message)
 {
@@ -59,8 +66,18 @@
 	return select(fileno(stdin)+1, &read_fds, NULL, NULL, &timeout) > 0; 
 }
 
+time_t start;
+uint64_t total_cycles;
 void *exit_write(uint32_t address, void *context, uint8_t value)
 {
+	time_t duration = time(NULL) - start;
+	z80_context *z80 = context;
+#ifdef NEW_CORE
+	total_cycles += z80->cycles;
+#else
+	total_cycles += context->current_cycle;
+#endif
+	printf("Effective clock speed: %f MHz\n", ((double)total_cycles) / (1000000.0 * duration));
 	exit(0);
 	return context;
 }
@@ -69,7 +86,7 @@
 	{ 0x0000, 0x10000,  0xFFFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, ram, NULL, NULL, NULL, NULL},
 };
 
-const memmap_chunk io_map[] = {
+memmap_chunk io_map[] = {
 	{ 0x0, 0x1, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_read, console_write},
 	{ 0x1, 0x2, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, console_status_read, console_flush_write},
 	{ 0x2, 0x3, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, NULL, exit_write},
@@ -107,10 +124,19 @@
 	z80_context *context;
 	init_z80_opts(&opts, z80_map, 1, io_map, 3, 1, 0xFF);
 	context = init_z80_context(&opts);
+	start = time(NULL);
 	for(;;)
 	{
+#ifdef NEW_CORE
+		z80_execute(context, 1000000);
+		total_cycles += context->cycles;
+		context->cycles = 0;
+#else
 		z80_run(context, 1000000);
+		total_cycles += context->current_cycle;
 		context->current_cycle = 0;
+#endif
+		
 	}
 	return 0;
 }
\ No newline at end of file