comparison z80_util.c @ 1748:48a43dff4dc0

Added init functions to z80_util.c so new Z80 core is closer to a drop in replacement for the old one
author Michael Pavone <pavone@retrodev.com>
date Thu, 07 Feb 2019 09:43:25 -0800
parents ca2336469397
children 01236179fc71
comparison
equal deleted inserted replaced
1747:89ddf41a50bb 1748:48a43dff4dc0
1 #include <string.h>
1 2
2 void z80_read_8(z80_context *context) 3 void z80_read_8(z80_context *context)
3 { 4 {
4 context->cycles += 3 * context->opts->gen.clock_divider; 5 context->cycles += 3 * context->opts->gen.clock_divider;
5 context->scratch1 = read_byte(context->scratch1, NULL, &context->opts->gen, context); 6 context->scratch1 = read_byte(context->scratch1, NULL, &context->opts->gen, context);
42 43
43 context->opts->gen.address_mask = tmp_mask; 44 context->opts->gen.address_mask = tmp_mask;
44 context->opts->gen.memmap = tmp_map; 45 context->opts->gen.memmap = tmp_map;
45 context->opts->gen.memmap_chunks = tmp_chunks; 46 context->opts->gen.memmap_chunks = tmp_chunks;
46 } 47 }
48
49 //quick hack until I get a chance to change which init method these get passed to
50 static memmap_chunk const * tmp_io_chunks;
51 static uint32_t tmp_num_io_chunks, tmp_io_mask;
52 void init_z80_opts(z80_options * options, memmap_chunk const * chunks, uint32_t num_chunks, memmap_chunk const * io_chunks, uint32_t num_io_chunks, uint32_t clock_divider, uint32_t io_address_mask)
53 {
54 memset(options, 0, sizeof(*options));
55 options->gen.memmap = chunks;
56 options->gen.memmap_chunks = num_chunks;
57 options->gen.address_mask = 0xFFFF;
58 options->gen.max_address = 0xFFFF;
59 options->gen.clock_divider = clock_divider;
60 tmp_io_chunks = io_chunks;
61 tmp_num_io_chunks = num_io_chunks;
62 tmp_io_mask = io_address_mask;
63 }
64
65 z80_context * init_z80_context(z80_options *options)
66 {
67 z80_context *context = calloc(1, sizeof(z80_context));
68 context->opts = options;
69 context->io_map = (memmap_chunk *)tmp_io_chunks;
70 context->io_chunks = tmp_num_io_chunks;
71 context->io_mask = tmp_io_mask;
72 return context;
73 }
74