annotate ztestrun.c @ 1971:80920c21bb52

Add an event log soft flush and call it twice per frame in between hard flushes to netplay latency when there are insufficient hardware updates to flush packets in the middle of a frame
author Michael Pavone <pavone@retrodev.com>
date Fri, 08 May 2020 11:40:30 -0700
parents 48a43dff4dc0
children 0a26f3657295
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 364
diff changeset
1 /*
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 364
diff changeset
2 Copyright 2013 Michael Pavone
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
3 This file is part of BlastEm.
467
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 364
diff changeset
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
140af5509ce7 Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents: 364
diff changeset
5 */
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #include "z80inst.h"
1703
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
7 #ifdef NEW_CORE
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
8 #include "z80.h"
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
9 #include <string.h>
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
10 #else
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
11 #include "z80_to_x86.h"
1703
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
12 #endif
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
13 #include "mem.h"
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
14 #include "vdp.h"
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15 #include <stdio.h>
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 #include <stdlib.h>
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
17 #include <stddef.h>
896
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
18 #include <stdarg.h>
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
19
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
20 void fatal_error(char *format, ...)
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
21 {
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
22 va_list args;
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
23 va_start(args, format);
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
24 vfprintf(stderr, format, args);
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
25 va_end(args);
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
26 exit(1);
74cc31040521 Get ztestrun compiling again
Michael Pavone <pavone@retrodev.com>
parents: 819
diff changeset
27 }
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
28
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
29 uint8_t z80_ram[0x2000];
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
30
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
31 uint8_t z80_unmapped_read(uint32_t location, void * context)
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
32 {
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
33 return 0xFF;
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
34 }
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
35
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
36 void * z80_unmapped_write(uint32_t location, void * context, uint8_t value)
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 {
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 return context;
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 }
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
41 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
42 { 0x0000, 0x4000, 0x1FFF, 0, 0, MMAP_READ | MMAP_WRITE | MMAP_CODE, z80_ram, NULL, NULL, NULL, NULL },
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
43 { 0x4000, 0x10000, 0xFFFF, 0, 0, 0, NULL, NULL, NULL, z80_unmapped_read, z80_unmapped_write}
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
44 };
364
62177cc39049 Incredibly broken YM2612 support plus a fix to Z80 bus request
Mike Pavone <pavone@retrodev.com>
parents: 293
diff changeset
45
1060
56713dac6a69 Implement INI
Michael Pavone <pavone@retrodev.com>
parents: 1049
diff changeset
46 const memmap_chunk port_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
47 { 0x0000, 0x100, 0xFF, 0, 0, 0, NULL, NULL, NULL, z80_unmapped_read, z80_unmapped_write}
1060
56713dac6a69 Implement INI
Michael Pavone <pavone@retrodev.com>
parents: 1049
diff changeset
48 };
56713dac6a69 Implement INI
Michael Pavone <pavone@retrodev.com>
parents: 1049
diff changeset
49
1703
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
50 #ifndef NEW_CORE
674
16e5dfdb67b5 Fix ztestrun
Michael Pavone <pavone@retrodev.com>
parents: 659
diff changeset
51 void z80_next_int_pulse(z80_context * context)
16e5dfdb67b5 Fix ztestrun
Michael Pavone <pavone@retrodev.com>
parents: 659
diff changeset
52 {
16e5dfdb67b5 Fix ztestrun
Michael Pavone <pavone@retrodev.com>
parents: 659
diff changeset
53 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER;
16e5dfdb67b5 Fix ztestrun
Michael Pavone <pavone@retrodev.com>
parents: 659
diff changeset
54 }
1703
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
55 #endif
674
16e5dfdb67b5 Fix ztestrun
Michael Pavone <pavone@retrodev.com>
parents: 659
diff changeset
56
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
57 int main(int argc, char ** argv)
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
58 {
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
59 long filesize;
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
60 uint8_t *filebuf;
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
61 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
62 z80_context *context;
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
63 char *fname = NULL;
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
64 uint8_t retranslate = 0;
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
65 for (int i = 1; i < argc; i++)
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
66 {
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
67 if (argv[i][0] == '-') {
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
68 switch(argv[i][1])
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
69 {
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
70 case 'r':
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
71 retranslate = 1;
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
72 break;
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
73 default:
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
74 fprintf(stderr, "Unrecognized switch -%c\n", argv[i][1]);
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
75 exit(1);
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
76 }
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
77 } else if (!fname) {
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
78 fname = argv[i];
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
79 }
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
80 }
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
81 if (!fname) {
674
16e5dfdb67b5 Fix ztestrun
Michael Pavone <pavone@retrodev.com>
parents: 659
diff changeset
82 fputs("usage: ztestrun zrom [cartrom]\n", stderr);
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
83 exit(1);
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
84 }
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
85 FILE * f = fopen(fname, "rb");
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
86 if (!f) {
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
87 fprintf(stderr, "unable to open file %s\n", fname);
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
88 exit(1);
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
89 }
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
90 fseek(f, 0, SEEK_END);
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
91 filesize = ftell(f);
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
92 fseek(f, 0, SEEK_SET);
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
93 filesize = filesize < sizeof(z80_ram) ? filesize : sizeof(z80_ram);
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
94 if (fread(z80_ram, 1, filesize, f) != filesize) {
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
95 fprintf(stderr, "error reading %s\n",fname);
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
96 exit(1);
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
97 }
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
98 fclose(f);
1748
48a43dff4dc0 Added init functions to z80_util.c so new Z80 core is closer to a drop in replacement for the old one
Michael Pavone <pavone@retrodev.com>
parents: 1705
diff changeset
99 init_z80_opts(&opts, z80_map, 2, port_map, 1, 1, 0xFF);
48a43dff4dc0 Added init functions to z80_util.c so new Z80 core is closer to a drop in replacement for the old one
Michael Pavone <pavone@retrodev.com>
parents: 1705
diff changeset
100 context = init_z80_context(&opts);
1703
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
101 #ifdef NEW_CORE
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
102 z80_execute(context, 1000);
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
103 printf("A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nHL: %X\nIX: %X\nIY: %X\nSP: %X\n\nIM: %d, IFF1: %d, IFF2: %d\n",
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
104 context->main[7], context->main[0], context->main[1],
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
105 context->main[2], context->main[3],
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
106 (context->main[4] << 8) | context->main[5],
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
107 context->ix,
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
108 context->iy,
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
109 context->sp, context->imode, context->iff1, context->iff2);
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
110 printf("Flags: SZYHXVNC\n"
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
111 " %d%d%d%d%d%d%d%d\n",
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
112 context->last_flag_result >> 7, context->zflag != 0, context->last_flag_result >> 5 & 1, context->chflags >> 3 & 1,
1705
9ab64ef5cba0 Initial stab at overflow flag implementation in CPU DSL. Probably broken for subtraction
Michael Pavone <pavone@retrodev.com>
parents: 1703
diff changeset
113 context->last_flag_result >> 3 & 1, context->pvflag != 0, context->nflag != 0, context->chflags >> 7 & 1
1703
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
114 );
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
115 puts("--Alternate Regs--");
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
116 printf("A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nHL: %X\n",
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
117 context->alt[7], context->alt[0], context->alt[1],
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
118 context->alt[2], context->alt[3],
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
119 (context->alt[4] << 8) | context->alt[5]);
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
120 #else
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
121 //Z80 RAM
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
122 context->mem_pointers[0] = z80_ram;
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
123 if (retranslate) {
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
124 //run core long enough to translate code
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
125 z80_run(context, 1);
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
126 for (int i = 0; i < filesize; i++)
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
127 {
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
128 z80_handle_code_write(i, context);
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
129 }
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
130 z80_assert_reset(context, context->current_cycle);
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
131 z80_clear_reset(context, context->current_cycle + 3);
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
132 z80_adjust_cycles(context, context->current_cycle);
675
5bf4e77b1a43 Added a -r flag to ztestrun that force instruction retranslation to allow a quick sanity test of that feature
Michael Pavone <pavone@retrodev.com>
parents: 674
diff changeset
133 }
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
134 z80_run(context, 1000);
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
135 printf("A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nHL: %X\nIX: %X\nIY: %X\nSP: %X\n\nIM: %d, IFF1: %d, IFF2: %d\n",
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
136 context->regs[Z80_A], context->regs[Z80_B], context->regs[Z80_C],
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->regs[Z80_D], context->regs[Z80_E],
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
138 (context->regs[Z80_H] << 8) | context->regs[Z80_L],
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
139 (context->regs[Z80_IXH] << 8) | context->regs[Z80_IXL],
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
140 (context->regs[Z80_IYH] << 8) | context->regs[Z80_IYL],
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
141 context->sp, context->im, context->iff1, context->iff2);
1049
ef7ee9919a73 Partial support for undocumented flag bits
Michael Pavone <pavone@retrodev.com>
parents: 1046
diff changeset
142 printf("Flags: SZYHXVNC\n"
ef7ee9919a73 Partial support for undocumented flag bits
Michael Pavone <pavone@retrodev.com>
parents: 1046
diff changeset
143 " %d%d%d%d%d%d%d%d\n",
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
144 context->flags[ZF_S], context->flags[ZF_Z], context->flags[ZF_XY] >> 5 & 1, context->flags[ZF_H],
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
145 context->flags[ZF_XY] >> 3 & 1, context->flags[ZF_PV], context->flags[ZF_N], context->flags[ZF_C]
1049
ef7ee9919a73 Partial support for undocumented flag bits
Michael Pavone <pavone@retrodev.com>
parents: 1046
diff changeset
146 );
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
147 puts("--Alternate Regs--");
593
5ef3fe516da9 Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents: 467
diff changeset
148 printf("A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nHL: %X\n",
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
149 context->alt_regs[Z80_A], context->alt_regs[Z80_B], context->alt_regs[Z80_C],
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
150 context->alt_regs[Z80_D], context->alt_regs[Z80_E],
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
151 (context->alt_regs[Z80_H] << 8) | context->alt_regs[Z80_L]);
1703
49a52c737bf0 Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents: 1130
diff changeset
152 #endif
292
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
153 return 0;
b970ea214ecb Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
154 }