Mercurial > repos > blastem
comparison blastem.c @ 548:a3afee2271ce
Initial work on the x86-32 target
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 18 Feb 2014 21:37:31 -0800 |
parents | c641006da28e |
children | dc9f178085a0 |
comparison
equal
deleted
inserted
replaced
547:3090d016c9e9 | 548:a3afee2271ce |
---|---|
180 | 180 |
181 #define Z80_VINT_DURATION 128 | 181 #define Z80_VINT_DURATION 128 |
182 | 182 |
183 void sync_z80(z80_context * z_context, uint32_t mclks) | 183 void sync_z80(z80_context * z_context, uint32_t mclks) |
184 { | 184 { |
185 #ifdef X86_64 | |
185 if (z80_enabled && !reset && !busreq) { | 186 if (z80_enabled && !reset && !busreq) { |
186 genesis_context * gen = z_context->system; | 187 genesis_context * gen = z_context->system; |
187 z_context->sync_cycle = mclks / MCLKS_PER_Z80; | 188 z_context->sync_cycle = mclks / MCLKS_PER_Z80; |
188 if (z_context->current_cycle < z_context->sync_cycle) { | 189 if (z_context->current_cycle < z_context->sync_cycle) { |
189 if (need_reset) { | 190 if (need_reset) { |
199 dprintf("Running Z80 from cycle %d to cycle %d. Native PC: %p\n", z_context->current_cycle, z_context->sync_cycle, z_context->native_pc); | 200 dprintf("Running Z80 from cycle %d to cycle %d. Native PC: %p\n", z_context->current_cycle, z_context->sync_cycle, z_context->native_pc); |
200 z80_run(z_context); | 201 z80_run(z_context); |
201 dprintf("Z80 ran to cycle %d\n", z_context->current_cycle); | 202 dprintf("Z80 ran to cycle %d\n", z_context->current_cycle); |
202 } | 203 } |
203 } | 204 } |
204 } else { | 205 } else |
206 #endif | |
207 { | |
205 z_context->current_cycle = mclks / MCLKS_PER_Z80; | 208 z_context->current_cycle = mclks / MCLKS_PER_Z80; |
206 } | 209 } |
207 } | 210 } |
208 | 211 |
209 void sync_sound(genesis_context * gen, uint32_t target) | 212 void sync_sound(genesis_context * gen, uint32_t target) |
467 } | 470 } |
468 if (!(busack || reset)) { | 471 if (!(busack || reset)) { |
469 location &= 0x7FFF; | 472 location &= 0x7FFF; |
470 if (location < 0x4000) { | 473 if (location < 0x4000) { |
471 z80_ram[location & 0x1FFF] = value; | 474 z80_ram[location & 0x1FFF] = value; |
475 #ifdef X86_64 | |
472 z80_handle_code_write(location & 0x1FFF, gen->z80); | 476 z80_handle_code_write(location & 0x1FFF, gen->z80); |
477 #endif | |
473 } else if (location < 0x6000) { | 478 } else if (location < 0x6000) { |
474 sync_sound(gen, context->current_cycle * MCLKS_PER_68K); | 479 sync_sound(gen, context->current_cycle * MCLKS_PER_68K); |
475 if (location & 1) { | 480 if (location & 1) { |
476 ym_data_write(gen->ym, value); | 481 ym_data_write(gen->ym, value); |
477 } else if(location & 2) { | 482 } else if(location & 2) { |
984 printf("Loaded %s\n", statefile); | 989 printf("Loaded %s\n", statefile); |
985 if (debugger) { | 990 if (debugger) { |
986 insert_breakpoint(&context, pc, debugger); | 991 insert_breakpoint(&context, pc, debugger); |
987 } | 992 } |
988 adjust_int_cycle(gen->m68k, gen->vdp); | 993 adjust_int_cycle(gen->m68k, gen->vdp); |
994 #ifdef X86_64 | |
989 gen->z80->native_pc = z80_get_native_address_trans(gen->z80, gen->z80->pc); | 995 gen->z80->native_pc = z80_get_native_address_trans(gen->z80, gen->z80->pc); |
996 #endif | |
990 start_68k_context(&context, pc); | 997 start_68k_context(&context, pc); |
991 } else { | 998 } else { |
992 if (debugger) { | 999 if (debugger) { |
993 insert_breakpoint(&context, address, debugger); | 1000 insert_breakpoint(&context, address, debugger); |
994 } | 1001 } |
1229 psg_context p_context; | 1236 psg_context p_context; |
1230 psg_init(&p_context, render_sample_rate(), gen.master_clock, MCLKS_PER_PSG, render_audio_buffer()); | 1237 psg_init(&p_context, render_sample_rate(), gen.master_clock, MCLKS_PER_PSG, render_audio_buffer()); |
1231 | 1238 |
1232 z80_context z_context; | 1239 z80_context z_context; |
1233 x86_z80_options z_opts; | 1240 x86_z80_options z_opts; |
1241 #ifdef X86_64 | |
1234 init_x86_z80_opts(&z_opts); | 1242 init_x86_z80_opts(&z_opts); |
1235 init_z80_context(&z_context, &z_opts); | 1243 init_z80_context(&z_context, &z_opts); |
1244 #endif | |
1236 | 1245 |
1237 z_context.system = &gen; | 1246 z_context.system = &gen; |
1238 z_context.mem_pointers[0] = z80_ram; | 1247 z_context.mem_pointers[0] = z80_ram; |
1239 z_context.sync_cycle = z_context.target_cycle = mclks_per_frame/MCLKS_PER_Z80; | 1248 z_context.sync_cycle = z_context.target_cycle = mclks_per_frame/MCLKS_PER_Z80; |
1240 z_context.int_cycle = CYCLE_NEVER; | 1249 z_context.int_cycle = CYCLE_NEVER; |