Mercurial > repos > blastem
comparison z80.cpu @ 1752:d6d4c006a7b3
Initial attempt at interrupts in new Z80 core and integrating it into main executable
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 10 Feb 2019 11:58:23 -0800 |
parents | 01236179fc71 |
children | 33ec5df77fac |
comparison
equal
deleted
inserted
replaced
1751:c5d4e1d14dac | 1752:d6d4c006a7b3 |
---|---|
1 info | 1 info |
2 prefix z80_ | 2 prefix z80_ |
3 opcode_size 8 | 3 opcode_size 8 |
4 extra_tables cb ed dded fded ddcb fdcb dd fd | 4 extra_tables cb ed dded fded ddcb fdcb dd fd |
5 body z80_run_op | 5 body z80_run_op |
6 sync_cycle z80_sync_cycle | |
7 interrupt z80_interrupt | |
6 include z80_util.c | 8 include z80_util.c |
7 header z80.h | 9 header z80.h |
8 | 10 |
9 declare | 11 declare |
10 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); | 12 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); |
11 z80_context * init_z80_context(z80_options *options); | 13 z80_context * init_z80_context(z80_options *options); |
12 | 14 void z80_run(z80_context *context, uint32_t target_cycle); |
15 void z80_assert_reset(z80_context * context, uint32_t cycle); | |
16 void z80_clear_reset(z80_context * context, uint32_t cycle); | |
17 void z80_assert_busreq(z80_context * context, uint32_t cycle); | |
18 void z80_clear_busreq(z80_context * context, uint32_t cycle); | |
19 void z80_assert_nmi(z80_context *context, uint32_t cycle); | |
20 uint8_t z80_get_busack(z80_context * context, uint32_t cycle); | |
21 void z80_invalidate_code_range(z80_context *context, uint32_t start, uint32_t end); | |
22 void z80_adjust_cycles(z80_context * context, uint32_t deduction); | |
23 void z80_serialize(z80_context *context, serialize_buffer *buf); | |
24 void z80_deserialize(deserialize_buffer *buf, void *vcontext); | |
25 void zinsert_breakpoint(z80_context * context, uint16_t address, uint8_t * bp_handler); | |
26 void zremove_breakpoint(z80_context * context, uint16_t address); | |
27 void z80_options_free(z80_options *opts); | |
28 | |
13 regs | 29 regs |
14 main 8 b c d e h l f a | 30 main 8 b c d e h l f a |
15 alt 8 b' c' d' e' h' l' f' a' | 31 alt 8 b' c' d' e' h' l' f' a' |
16 i 8 | 32 i 8 |
17 r 8 | 33 r 8 |
29 pvflag 8 | 45 pvflag 8 |
30 chflags 8 | 46 chflags 8 |
31 zflag 8 | 47 zflag 8 |
32 scratch1 16 | 48 scratch1 16 |
33 scratch2 16 | 49 scratch2 16 |
50 busreq 8 | |
51 busack 8 | |
52 reset 8 | |
34 io_map ptrmemmap_chunk | 53 io_map ptrmemmap_chunk |
35 io_chunks 32 | 54 io_chunks 32 |
36 io_mask 32 | 55 io_mask 32 |
56 int_cycle 32 | |
57 int_value 8 | |
58 nmi_cycle 32 | |
59 system ptrvoid | |
37 fastmem ptr8 64 | 60 fastmem ptr8 64 |
61 mem_pointers ptr8 4 | |
38 | 62 |
39 flags | 63 flags |
40 register f | 64 register f |
41 S 7 sign last_flag_result.7 | 65 S 7 sign last_flag_result.7 |
42 Z 6 zero zflag | 66 Z 6 zero zflag |
57 add 1 pc pc | 81 add 1 pc pc |
58 | 82 |
59 z80_run_op | 83 z80_run_op |
60 z80_op_fetch | 84 z80_op_fetch |
61 dispatch scratch1 | 85 dispatch scratch1 |
86 | |
87 z80_interrupt | |
88 cmp int_cycle cycles | |
89 if >=U | |
90 | |
91 mov 0xFFFFFFFF int_cycle | |
92 mov 0 iff1 | |
93 mov 0 iff2 | |
94 cycles 6 | |
95 update_sync | |
96 | |
97 switch imode | |
98 case 0 | |
99 dispatch int_value | |
100 | |
101 case 1 | |
102 dispatch 0xFF | |
103 | |
104 case 2 | |
105 lsl i 8 pc | |
106 or int_value pc pc | |
107 #CD is call | |
108 dispatch 0xCD | |
109 end | |
110 | |
111 else | |
112 | |
113 cmp nmi_cycle cycles | |
114 if >=U | |
115 | |
116 mov 0xFFFFFFFF nmi_cycle | |
117 mov 0 iff1 | |
118 local pch 8 | |
119 lsr pc 8 pch | |
120 meta high pch | |
121 meta low pc | |
122 z80_push | |
123 mov 0x66 pc | |
124 update_sync | |
125 | |
126 end | |
127 end | |
128 | |
62 | 129 |
63 11001011 cb_prefix | 130 11001011 cb_prefix |
64 z80_op_fetch | 131 z80_op_fetch |
65 dispatch scratch1 cb | 132 dispatch scratch1 cb |
66 | 133 |
1483 | 1550 |
1484 ed 01D11110 im2 | 1551 ed 01D11110 im2 |
1485 mov 2 imode | 1552 mov 2 imode |
1486 | 1553 |
1487 ed 01D01110 im3 | 1554 ed 01D01110 im3 |
1488 mov 3 imode | 1555 #some sources call this mode 0/1, but unclear |
1556 #if the behavior is really different from im 0 | |
1557 mov 0 imode | |
1489 | 1558 |
1490 11000011 jp | 1559 11000011 jp |
1491 z80_fetch_immed16 | 1560 z80_fetch_immed16 |
1492 mov wz pc | 1561 mov wz pc |
1493 | 1562 |