Mercurial > repos > blastem
comparison ztestrun.c @ 1703:49a52c737bf0
Fix zero flag calculation in CPU DSL
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 28 Jan 2019 19:24:04 -0800 |
parents | 8f14767661fa |
children | 9ab64ef5cba0 |
comparison
equal
deleted
inserted
replaced
1702:73ac2e59fa3f | 1703:49a52c737bf0 |
---|---|
2 Copyright 2013 Michael Pavone | 2 Copyright 2013 Michael Pavone |
3 This file is part of BlastEm. | 3 This file is part of BlastEm. |
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. | 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. |
5 */ | 5 */ |
6 #include "z80inst.h" | 6 #include "z80inst.h" |
7 #ifdef NEW_CORE | |
8 #include "z80.h" | |
9 #include <string.h> | |
10 #else | |
7 #include "z80_to_x86.h" | 11 #include "z80_to_x86.h" |
12 #endif | |
8 #include "mem.h" | 13 #include "mem.h" |
9 #include "vdp.h" | 14 #include "vdp.h" |
10 #include <stdio.h> | 15 #include <stdio.h> |
11 #include <stdlib.h> | 16 #include <stdlib.h> |
12 #include <stddef.h> | 17 #include <stddef.h> |
40 | 45 |
41 const memmap_chunk port_map[] = { | 46 const memmap_chunk port_map[] = { |
42 { 0x0000, 0x100, 0xFF, 0, 0, 0, NULL, NULL, NULL, z80_unmapped_read, z80_unmapped_write} | 47 { 0x0000, 0x100, 0xFF, 0, 0, 0, NULL, NULL, NULL, z80_unmapped_read, z80_unmapped_write} |
43 }; | 48 }; |
44 | 49 |
50 #ifndef NEW_CORE | |
45 void z80_next_int_pulse(z80_context * context) | 51 void z80_next_int_pulse(z80_context * context) |
46 { | 52 { |
47 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER; | 53 context->int_pulse_start = context->int_pulse_end = CYCLE_NEVER; |
48 } | 54 } |
55 #endif | |
49 | 56 |
50 int main(int argc, char ** argv) | 57 int main(int argc, char ** argv) |
51 { | 58 { |
52 long filesize; | 59 long filesize; |
53 uint8_t *filebuf; | 60 uint8_t *filebuf; |
87 if (fread(z80_ram, 1, filesize, f) != filesize) { | 94 if (fread(z80_ram, 1, filesize, f) != filesize) { |
88 fprintf(stderr, "error reading %s\n",fname); | 95 fprintf(stderr, "error reading %s\n",fname); |
89 exit(1); | 96 exit(1); |
90 } | 97 } |
91 fclose(f); | 98 fclose(f); |
99 #ifdef NEW_CORE | |
100 memset(&opts, 0, sizeof(opts)); | |
101 opts.gen.memmap = z80_map; | |
102 opts.gen.memmap_chunks = 2; | |
103 opts.gen.address_mask = 0xFFFF; | |
104 opts.gen.max_address = 0xFFFF; | |
105 opts.gen.clock_divider = 1; | |
106 context = calloc(1, sizeof(z80_context)); | |
107 context->opts = &opts; | |
108 z80_execute(context, 1000); | |
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", | |
110 context->main[7], context->main[0], context->main[1], | |
111 context->main[2], context->main[3], | |
112 (context->main[4] << 8) | context->main[5], | |
113 context->ix, | |
114 context->iy, | |
115 context->sp, context->imode, context->iff1, context->iff2); | |
116 printf("Flags: SZYHXVNC\n" | |
117 " %d%d%d%d%d%d%d%d\n", | |
118 context->last_flag_result >> 7, context->zflag != 0, context->last_flag_result >> 5 & 1, context->chflags >> 3 & 1, | |
119 context->last_flag_result >> 3 & 1, context->pvflag != 0, context->nflag, context->chflags >> 7 & 1 | |
120 ); | |
121 puts("--Alternate Regs--"); | |
122 printf("A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nHL: %X\n", | |
123 context->alt[7], context->alt[0], context->alt[1], | |
124 context->alt[2], context->alt[3], | |
125 (context->alt[4] << 8) | context->alt[5]); | |
126 #else | |
92 init_z80_opts(&opts, z80_map, 2, port_map, 1, 1, 0xFF); | 127 init_z80_opts(&opts, z80_map, 2, port_map, 1, 1, 0xFF); |
93 context = init_z80_context(&opts); | 128 context = init_z80_context(&opts); |
94 //Z80 RAM | 129 //Z80 RAM |
95 context->mem_pointers[0] = z80_ram; | 130 context->mem_pointers[0] = z80_ram; |
96 if (retranslate) { | 131 if (retranslate) { |
120 puts("--Alternate Regs--"); | 155 puts("--Alternate Regs--"); |
121 printf("A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nHL: %X\n", | 156 printf("A: %X\nB: %X\nC: %X\nD: %X\nE: %X\nHL: %X\n", |
122 context->alt_regs[Z80_A], context->alt_regs[Z80_B], context->alt_regs[Z80_C], | 157 context->alt_regs[Z80_A], context->alt_regs[Z80_B], context->alt_regs[Z80_C], |
123 context->alt_regs[Z80_D], context->alt_regs[Z80_E], | 158 context->alt_regs[Z80_D], context->alt_regs[Z80_E], |
124 (context->alt_regs[Z80_H] << 8) | context->alt_regs[Z80_L]); | 159 (context->alt_regs[Z80_H] << 8) | context->alt_regs[Z80_L]); |
160 #endif | |
125 return 0; | 161 return 0; |
126 } | 162 } |