Mercurial > repos > blastem
comparison m68k_util.c @ 2651:1072cc337822
Implement TAS in new 68K core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 02 Mar 2025 01:01:57 -0800 |
parents | 620f30af9fdc |
children | 6068d32b756c |
comparison
equal
deleted
inserted
replaced
2650:9263d064294c | 2651:1072cc337822 |
---|---|
1 #include <string.h> | 1 #include <string.h> |
2 | 2 |
3 void m68k_read_8(m68k_context *context) | 3 void m68k_read_8(m68k_context *context) |
4 { | 4 { |
5 context->cycles += 4 * context->opts->gen.clock_divider; | 5 context->cycles += 4 * context->opts->gen.clock_divider; |
6 #ifdef DEBUG_DISASM | |
7 uint32_t tmp = context->scratch1; | |
8 #endif | |
6 context->scratch1 = read_byte(context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); | 9 context->scratch1 = read_byte(context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); |
10 #ifdef DEBUG_DISASM | |
11 if (context->pc >= 0x3F48 && context->pc < 0x3FCE) { | |
12 printf("Read.b %05X: %02X\n", tmp, context->scratch1); | |
13 } | |
14 #endif | |
7 } | 15 } |
8 | 16 |
9 #ifdef DEBUG_DISASM | 17 #ifdef DEBUG_DISASM |
10 #include "68kinst.h" | 18 #include "68kinst.h" |
11 static uint16_t debug_disasm_fetch(uint32_t address, void *vcontext) | 19 static uint16_t debug_disasm_fetch(uint32_t address, void *vcontext) |
20 #ifdef DEBUG_DISASM | 28 #ifdef DEBUG_DISASM |
21 uint32_t tmp = context->scratch1; | 29 uint32_t tmp = context->scratch1; |
22 #endif | 30 #endif |
23 context->scratch1 = read_word(context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); | 31 context->scratch1 = read_word(context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); |
24 #ifdef DEBUG_DISASM | 32 #ifdef DEBUG_DISASM |
33 if (context->pc >= 0x3F48 && context->pc < 0x3FCE) { | |
25 if (tmp == context->pc) { | 34 if (tmp == context->pc) { |
26 m68kinst inst; | 35 m68kinst inst; |
27 m68k_decode(debug_disasm_fetch, context, &inst, tmp); | 36 m68k_decode(debug_disasm_fetch, context, &inst, tmp); |
28 static char disasm_buf[256]; | 37 static char disasm_buf[256]; |
29 m68k_disasm(&inst, disasm_buf); | 38 m68k_disasm(&inst, disasm_buf); |
30 printf("Fetch %05X: %04X - %s, d0=%X, d1=%X, d2=%X, d3=%X, d4=%X, d6=%X, a7=%X, xflag=%d\n", tmp, context->scratch1, disasm_buf, context->dregs[0], context->dregs[1], context->dregs[2], context->dregs[3], context->dregs[4], context->dregs[6], context->aregs[7], context->xflag); | 39 printf("Fetch %05X: %04X - %s, d0=%X, d1=%X, d2=%X, d3=%X, d4=%X, d6=%X, d7=%X, a3=%X, a7=%X, xflag=%d\n", |
40 tmp, context->scratch1, disasm_buf, context->dregs[0], context->dregs[1], context->dregs[2], context->dregs[3], | |
41 context->dregs[4], context->dregs[6], context->dregs[7], context->aregs[3], context->aregs[7], context->xflag | |
42 ); | |
31 } else { | 43 } else { |
32 printf("Read %05X: %04X\n", tmp, context->scratch1); | 44 printf("Read %05X: %04X\n", tmp, context->scratch1); |
33 } | 45 } |
46 } | |
34 #endif | 47 #endif |
35 } | 48 } |
36 | 49 |
37 void m68k_write_8(m68k_context *context) | 50 void m68k_write_8(m68k_context *context) |
38 { | 51 { |
39 context->cycles += 4 * context->opts->gen.clock_divider; | 52 context->cycles += 4 * context->opts->gen.clock_divider; |
40 write_byte(context->scratch2, context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); | 53 write_byte(context->scratch2, context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); |
54 #ifdef DEBUG_DISASM | |
55 if (context->pc >= 0x3F48 && context->pc < 0x3FCE) { | |
56 printf("Write.b %05X: %02X\n", context->scratch2, context->scratch1); | |
57 } | |
58 #endif | |
59 } | |
60 | |
61 void m68k_rmw_writeback(m68k_context *context) | |
62 { | |
63 if (context->opts->gen.flags & M68K_OPT_BROKEN_READ_MODIFY) { | |
64 context->cycles += 4 * context->opts->gen.clock_divider; | |
65 } else { | |
66 write_byte(context->scratch2, context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); | |
67 } | |
41 } | 68 } |
42 | 69 |
43 void m68k_write_16(m68k_context *context) | 70 void m68k_write_16(m68k_context *context) |
44 { | 71 { |
45 context->cycles += 4 * context->opts->gen.clock_divider; | 72 context->cycles += 4 * context->opts->gen.clock_divider; |
46 write_word(context->scratch2, context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); | 73 write_word(context->scratch2, context->scratch1, (void**)context->mem_pointers, &context->opts->gen, context); |
74 #ifdef DEBUG_DISASM | |
75 if (context->pc >= 0x3F48 && context->pc < 0x3FCE) { | |
76 printf("Write %05X: %04X\n", context->scratch2, context->scratch1); | |
77 } | |
78 #endif | |
47 } | 79 } |
48 | 80 |
49 void m68k_sync_cycle(m68k_context *context, uint32_t target_cycle) | 81 void m68k_sync_cycle(m68k_context *context, uint32_t target_cycle) |
50 { | 82 { |
51 context->sync_cycle = target_cycle; //why? | 83 context->sync_cycle = target_cycle; //why? |