Mercurial > repos > blastem
annotate backend.c @ 1696:956c1cce05e2 mame_interp
Merge from default
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 24 Jan 2019 19:15:59 -0800 |
parents | b7ecd0d6a77b d377d6037dd9 |
children | 8fe162bdb038 |
rev | line source |
---|---|
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
282
diff
changeset
|
1 /* |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
282
diff
changeset
|
2 Copyright 2013 Michael Pavone |
557
acec5464fa1e
Rename x86_backend.h and x86_backend.c to backend.h and backend.c respectively
Mike Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
3 This file is part of BlastEm. |
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
282
diff
changeset
|
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. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
282
diff
changeset
|
5 */ |
557
acec5464fa1e
Rename x86_backend.h and x86_backend.c to backend.h and backend.c respectively
Mike Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
6 #include "backend.h" |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #include <stdlib.h> |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
9 #ifdef USE_NATIVE |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 deferred_addr * defer_address(deferred_addr * old_head, uint32_t address, uint8_t *dest) |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 deferred_addr * new_head = malloc(sizeof(deferred_addr)); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 new_head->next = old_head; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 new_head->address = address & 0xFFFFFF; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 new_head->dest = dest; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 return new_head; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 |
282
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
19 void remove_deferred_until(deferred_addr **head_ptr, deferred_addr * remove_to) |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
20 { |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
21 for(deferred_addr *cur = *head_ptr; cur && cur != remove_to; cur = *head_ptr) |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
22 { |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
23 *head_ptr = cur->next; |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
24 free(cur); |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
25 } |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
26 } |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
27 |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 void process_deferred(deferred_addr ** head_ptr, void * context, native_addr_func get_native) |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 deferred_addr * cur = *head_ptr; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 deferred_addr **last_next = head_ptr; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 while(cur) |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 { |
558
dc9f178085a0
Use a typedef code_ptr in place of uint8_t * in 68K core to better support host instruction sets with different instruction word sizes. Make x86_68k_options contain a cpu_options so that gen_mem_fun can eventually be shared with the Z80 core.
Mike Pavone <pavone@retrodev.com>
parents:
557
diff
changeset
|
34 code_ptr native = get_native(context, cur->address);//get_native_address(opts->native_code_map, cur->address); |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 if (native) { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 int32_t disp = native - (cur->dest + 4); |
558
dc9f178085a0
Use a typedef code_ptr in place of uint8_t * in 68K core to better support host instruction sets with different instruction word sizes. Make x86_68k_options contain a cpu_options so that gen_mem_fun can eventually be shared with the Z80 core.
Mike Pavone <pavone@retrodev.com>
parents:
557
diff
changeset
|
37 code_ptr out = cur->dest; |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 *out = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 *last_next = cur->next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 free(cur); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 cur = *last_next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 } else { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 last_next = &(cur->next); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 cur = cur->next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 } |
1507
2455662378ed
Added MAME Z80 core, re-enabled 68K tracing in Musashi core, disabled a bunch of code gen stuff when using interpreters from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1506
diff
changeset
|
54 #endif |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 |
1130
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
56 memmap_chunk const *find_map_chunk(uint32_t address, cpu_options *opts, uint16_t flags, uint32_t *size_sum) |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
57 { |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
58 if (size_sum) { |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
59 *size_sum = 0; |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
60 } |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
61 address &= opts->address_mask; |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
62 for (memmap_chunk const *cur = opts->memmap, *end = opts->memmap + opts->memmap_chunks; cur != end; cur++) |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
63 { |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
64 if (address >= cur->start && address < cur->end) { |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
65 return cur; |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
66 } else if (size_sum && (cur->flags & flags) == flags) { |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
67 *size_sum += chunk_size(opts, cur); |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
68 } |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
69 } |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
70 return NULL; |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
71 } |
8f14767661fa
Remove memory map assumptions from Z80 core and move a little bit of logic to the generic backend.c so it can be shared between CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
1079
diff
changeset
|
72 |
653
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
73 void * get_native_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts) |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
74 { |
654
98927f1b005b
Fix some issues with 68K instruction retranslation
Michael Pavone <pavone@retrodev.com>
parents:
653
diff
changeset
|
75 memmap_chunk const * memmap = opts->memmap; |
653
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
76 address &= opts->address_mask; |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
77 for (uint32_t chunk = 0; chunk < opts->memmap_chunks; chunk++) |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
78 { |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
79 if (address >= memmap[chunk].start && address < memmap[chunk].end) { |
1519
1f745318f10a
Made the NOR flash emulation a bit more flexible, but not yet flexible enough to properly support the flash chip in the MegaWiFi cart
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
80 if (!(memmap[chunk].flags & (MMAP_READ|MMAP_READ_CODE))) { |
653
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
81 return NULL; |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
82 } |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
83 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
84 ? mem_pointers[memmap[chunk].ptr_index] |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
85 : memmap[chunk].buffer; |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
86 if (!base) { |
1079
329ff62ea391
Add a new memory map flag to support an auxilliary buffer for translating code from MMAP_PTR_IDX chunks for which the pointer is null
Michael Pavone <pavone@retrodev.com>
parents:
690
diff
changeset
|
87 if (memmap[chunk].flags & MMAP_AUX_BUFF) { |
329ff62ea391
Add a new memory map flag to support an auxilliary buffer for translating code from MMAP_PTR_IDX chunks for which the pointer is null
Michael Pavone <pavone@retrodev.com>
parents:
690
diff
changeset
|
88 return memmap[chunk].buffer + (address & memmap[chunk].aux_mask); |
329ff62ea391
Add a new memory map flag to support an auxilliary buffer for translating code from MMAP_PTR_IDX chunks for which the pointer is null
Michael Pavone <pavone@retrodev.com>
parents:
690
diff
changeset
|
89 } |
653
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
90 return NULL; |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
91 } |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
92 return base + (address & memmap[chunk].mask); |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
93 } |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
94 } |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
95 return NULL; |
a18e3923481e
Remove some of the hard coded assumptions about the memory map from the CPU cores
Michael Pavone <pavone@retrodev.com>
parents:
558
diff
changeset
|
96 } |
690
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
97 |
1313
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
98 uint16_t read_word(uint32_t address, void **mem_pointers, cpu_options *opts, void *context) |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
99 { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
100 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
101 if (!chunk) { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
102 return 0xFFFF; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
103 } |
1678
d377d6037dd9
Don't subtract chunk start from address in read_word as this is inconsistent with other consumers of memory map definitions. Fixes graphical corruption in NBA Jam TE and possibly other titles that use the Acclaim mapper with a 32Mbit ROM
Michael Pavone <pavone@retrodev.com>
parents:
1519
diff
changeset
|
104 uint32_t offset = address & chunk->mask; |
1313
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
105 if (chunk->flags & MMAP_READ) { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
106 uint8_t *base; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
107 if (chunk->flags & MMAP_PTR_IDX) { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
108 base = mem_pointers[chunk->ptr_index]; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
109 } else { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
110 base = chunk->buffer; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
111 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
112 if (base) { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
113 uint16_t val; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
114 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
115 offset /= 2; |
1419
92e7dafcc0dc
Fix a silly variable shadowing bug in read_word
Michael Pavone <pavone@retrodev.com>
parents:
1313
diff
changeset
|
116 val = base[offset]; |
1313
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
117 if (chunk->flags & MMAP_ONLY_ODD) { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
118 val |= 0xFF00; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
119 } else { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
120 val = val << 8 | 0xFF; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
121 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
122 } else { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
123 val = *(uint16_t *)(base + offset); |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
124 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
125 return val; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
126 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
127 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
128 if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_16) { |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
129 return chunk->read_16(offset, context); |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
130 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
131 return 0xFFFF; |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
132 } |
b27d7bf1107e
Improved printing of word at absolute address to support reading from all address types. Implemented support for printing the value pointed to by a register. Removed abuse of read_dma_value in internal debugger.
Michael Pavone <pavone@retrodev.com>
parents:
1142
diff
changeset
|
133 |
1506
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
134 void write_word(uint32_t address, uint16_t value, void **mem_pointers, cpu_options *opts, void *context) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
135 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
136 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
137 if (!chunk) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
138 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
139 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
140 uint32_t offset = (address - chunk->start) & chunk->mask; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
141 if (chunk->flags & MMAP_WRITE) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
142 uint8_t *base; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
143 if (chunk->flags & MMAP_PTR_IDX) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
144 base = mem_pointers[chunk->ptr_index]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
145 } else { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
146 base = chunk->buffer; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
147 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
148 if (base) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
149 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
150 offset /= 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
151 if (chunk->flags & MMAP_ONLY_EVEN) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
152 value >>= 16; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
153 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
154 base[offset] = value; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
155 } else { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
156 *(uint16_t *)(base + offset) = value; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
157 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
158 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
159 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
160 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
161 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_16) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
162 chunk->write_16(offset, context, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
163 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
164 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
165 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
166 uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void *context) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
167 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
168 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
169 if (!chunk) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
170 return 0xFF; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
171 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
172 uint32_t offset = (address - chunk->start) & chunk->mask; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
173 if (chunk->flags & MMAP_READ) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
174 uint8_t *base; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
175 if (chunk->flags & MMAP_PTR_IDX) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
176 base = mem_pointers[chunk->ptr_index]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
177 } else { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
178 base = chunk->buffer; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
179 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
180 if (base) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
181 uint16_t val; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
182 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
183 offset /= 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
184 } else if (opts->byte_swap || (chunk->flags & MMAP_BYTESWAP)) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
185 offset ^= 1; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
186 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
187 return base[offset];; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
188 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
189 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
190 if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_8) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
191 return chunk->read_8(offset, context); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
192 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
193 return 0xFF; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
194 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
195 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
196 void write_byte(uint32_t address, uint8_t value, void **mem_pointers, cpu_options *opts, void *context) |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
197 { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
198 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
199 if (!chunk) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
200 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
201 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
202 uint32_t offset = (address - chunk->start) & chunk->mask; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
203 if (chunk->flags & MMAP_WRITE) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
204 uint8_t *base; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
205 if (chunk->flags & MMAP_PTR_IDX) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
206 base = mem_pointers[chunk->ptr_index]; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
207 } else { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
208 base = chunk->buffer; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
209 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
210 if (base) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
211 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
212 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
213 if (chunk->flags & MMAP_ONLY_EVEN) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
214 if (offset & 1) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
215 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
216 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
217 } else { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
218 if (!(offset & 1)) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
219 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
220 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
221 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
222 offset /= 2; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
223 |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
224 } else if (opts->byte_swap || (chunk->flags & MMAP_BYTESWAP)) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
225 offset ^= 1; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
226 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
227 base[offset] = value; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
228 return; |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
229 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
230 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
231 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_8) { |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
232 chunk->write_8(offset, context, value); |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
233 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
234 } |
ded16f3d7eb4
Super hacky integration of the version of Musashi from MAME
Michael Pavone <pavone@retrodev.com>
parents:
1419
diff
changeset
|
235 |
690
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
236 uint32_t chunk_size(cpu_options *opts, memmap_chunk const *chunk) |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
237 { |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
238 if (chunk->mask == opts->address_mask) { |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
239 return chunk->end - chunk->start; |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
240 } else { |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
241 return chunk->mask + 1; |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
242 } |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
243 } |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
244 |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
245 uint32_t ram_size(cpu_options *opts) |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
246 { |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
247 uint32_t size = 0; |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
248 for (int i = 0; i < opts->memmap_chunks; i++) |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
249 { |
1142
5c8b1c33ca10
Invalidate translated code on a cartridge bank change in SMS mode. Fix handling of bank 0
Michael Pavone <pavone@retrodev.com>
parents:
1130
diff
changeset
|
250 if (opts->memmap[i].flags & MMAP_CODE) { |
690
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
251 if (opts->memmap[i].mask == opts->address_mask) { |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
252 size += opts->memmap[i].end - opts->memmap[i].start; |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
253 } else { |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
254 size += opts->memmap[i].mask + 1; |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
255 } |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
256 } |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
257 } |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
258 return size; |
fc04781f4d28
Removed hardcoded assumptions in M68K core about which parts of the memory map are RAM
Michael Pavone <pavone@retrodev.com>
parents:
654
diff
changeset
|
259 } |