Mercurial > repos > blastem
annotate ztestrun.c @ 1720:1648c685083a
Implemented DD/FD prefixes for and/or/xor in new Z80 core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 30 Jan 2019 22:11:12 -0800 |
parents | 9ab64ef5cba0 |
children | 48a43dff4dc0 |
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 | 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 | 48 }; |
49 | |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
50 #ifndef NEW_CORE |
674 | 51 void z80_next_int_pulse(z80_context * context) |
52 { | |
53 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER; | |
54 } | |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
55 #endif |
674 | 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 | 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); |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
99 #ifdef NEW_CORE |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
100 memset(&opts, 0, sizeof(opts)); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
101 opts.gen.memmap = z80_map; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
102 opts.gen.memmap_chunks = 2; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
103 opts.gen.address_mask = 0xFFFF; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
104 opts.gen.max_address = 0xFFFF; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
105 opts.gen.clock_divider = 1; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
106 context = calloc(1, sizeof(z80_context)); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
107 context->opts = &opts; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
108 z80_execute(context, 1000); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
109 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
|
110 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
|
111 context->main[2], context->main[3], |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
112 (context->main[4] << 8) | context->main[5], |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
113 context->ix, |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
114 context->iy, |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
115 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
|
116 printf("Flags: SZYHXVNC\n" |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
117 " %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
|
118 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
|
119 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
|
120 ); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
121 puts("--Alternate Regs--"); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
122 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
|
123 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
|
124 context->alt[2], context->alt[3], |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
125 (context->alt[4] << 8) | context->alt[5]); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
126 #else |
1116
fe8c79f82c22
More cleanup in preparation for SMS/Mark III support
Michael Pavone <pavone@retrodev.com>
parents:
1060
diff
changeset
|
127 init_z80_opts(&opts, z80_map, 2, port_map, 1, 1, 0xFF); |
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 context = init_z80_context(&opts); |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 //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
|
130 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
|
131 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
|
132 //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
|
133 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
|
134 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
|
135 { |
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 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
|
137 } |
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
|
138 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
|
139 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
|
140 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
|
141 } |
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
|
142 z80_run(context, 1000); |
593
5ef3fe516da9
Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
143 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
|
144 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
|
145 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
|
146 (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
|
147 (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
|
148 (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
|
149 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
|
150 printf("Flags: SZYHXVNC\n" |
ef7ee9919a73
Partial support for undocumented flag bits
Michael Pavone <pavone@retrodev.com>
parents:
1046
diff
changeset
|
151 " %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
|
152 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
|
153 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
|
154 ); |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
155 puts("--Alternate Regs--"); |
593
5ef3fe516da9
Z80 core is sort of working again
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
156 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
|
157 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
|
158 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
|
159 (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
|
160 #endif |
292
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
161 return 0; |
b970ea214ecb
Added z80 test generator and z80 test runner.
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
162 } |