Mercurial > repos > blastem
annotate backend.c @ 2688:b42f00a3a937 default tip
Fix default target. Ensure m68k.h and z80.h are built before anything else when no dep info is available
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Mon, 31 Mar 2025 21:06:18 -0700 |
parents | b0b6c6042103 |
children |
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 |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 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
|
10 { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 deferred_addr * new_head = malloc(sizeof(deferred_addr)); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 new_head->next = old_head; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 new_head->address = address & 0xFFFFFF; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 new_head->dest = dest; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 return new_head; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 } |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
282
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
18 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
|
19 { |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
20 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
|
21 { |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
22 *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
|
23 free(cur); |
7b8a49220e3b
Remove deferred address entries from abandoned translations inside z80_retrans_inst
Mike Pavone <pavone@retrodev.com>
parents:
235
diff
changeset
|
24 } |
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 |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 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
|
28 { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 deferred_addr * cur = *head_ptr; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 deferred_addr **last_next = head_ptr; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 while(cur) |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 { |
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
|
33 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
|
34 if (native) { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 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
|
36 code_ptr out = cur->dest; |
235
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 *(out++) = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 disp >>= 8; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 *out = disp; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 *last_next = cur->next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 free(cur); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 cur = *last_next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 } else { |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 last_next = &(cur->next); |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 cur = cur->next; |
d9bf8e61c33c
Get Z80 core working for simple programs
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 } |
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 |
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
|
54 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
|
55 { |
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 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
|
57 *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
|
58 } |
2113
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
59 uint32_t size_round_mask; |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
60 if (flags == MMAP_CODE) { |
2113
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
61 size_round_mask = (1 << (opts->ram_flags_shift + 3)) - 1; |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
62 } else { |
2113
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
63 size_round_mask = 0; |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
64 } |
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
|
65 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
|
66 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
|
67 { |
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 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
|
69 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
|
70 } else if (size_sum && (cur->flags & flags) == flags) { |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
71 uint32_t size = chunk_size(opts, cur); |
2113
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
72 if (size_round_mask) { |
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
73 if (size & size_round_mask) { |
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
74 size &= ~size_round_mask; |
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
75 size += size_round_mask + 1; |
0013362c320c
Fix handling of ram code flag offset calculation for ranges that are not an even multiple of the code flag page size
Michael Pavone <pavone@retrodev.com>
parents:
2036
diff
changeset
|
76 } |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
77 } |
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
78 *size_sum += size; |
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
|
79 } |
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
|
80 } |
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
|
81 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
|
82 } |
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
|
83 |
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
|
84 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
|
85 { |
654
98927f1b005b
Fix some issues with 68K instruction retranslation
Michael Pavone <pavone@retrodev.com>
parents:
653
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 { |
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 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
|
91 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
|
92 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
|
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 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
|
95 ? 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
|
96 : 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
|
97 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
|
98 if (memmap[chunk].flags & MMAP_AUX_BUFF) { |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
99 address &= memmap[chunk].aux_mask; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
100 if (memmap[chunk].shift > 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
101 address <<= memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
102 } else if (memmap[chunk].shift < 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
103 address >>= -memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
104 } |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
105 return ((uint8_t *)memmap[chunk].buffer) + address; |
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
|
106 } |
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
|
107 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
|
108 } |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
109 address &= memmap[chunk].mask; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
110 if (memmap[chunk].shift > 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
111 address <<= memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
112 } else if (memmap[chunk].shift < 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
113 address >>= -memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
114 } |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
115 return base + address; |
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
|
116 } |
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
|
117 } |
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
|
118 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
|
119 } |
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
|
120 |
1753
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
121 void * get_native_write_pointer(uint32_t address, void ** mem_pointers, cpu_options * opts) |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
122 { |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
123 memmap_chunk const * memmap = opts->memmap; |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
124 address &= opts->address_mask; |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
125 for (uint32_t chunk = 0; chunk < opts->memmap_chunks; chunk++) |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
126 { |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
127 if (address >= memmap[chunk].start && address < memmap[chunk].end) { |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
128 if (!(memmap[chunk].flags & (MMAP_WRITE))) { |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
129 return NULL; |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
130 } |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
131 uint8_t * base = memmap[chunk].flags & MMAP_PTR_IDX |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
132 ? mem_pointers[memmap[chunk].ptr_index] |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
133 : memmap[chunk].buffer; |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
134 if (!base) { |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
135 if (memmap[chunk].flags & MMAP_AUX_BUFF) { |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
136 address &= memmap[chunk].aux_mask; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
137 if (memmap[chunk].shift > 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
138 address <<= memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
139 } else if (memmap[chunk].shift < 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
140 address >>= -memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
141 } |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
142 return ((uint8_t *)memmap[chunk].buffer) + address; |
1753
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
143 } |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
144 return NULL; |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
145 } |
2134
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
146 address &= memmap[chunk].mask; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
147 if (memmap[chunk].shift > 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
148 address <<= memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
149 } else if (memmap[chunk].shift < 0) { |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
150 address >>= -memmap[chunk].shift; |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
151 } |
9caebcfeac72
Implement word RAM interleaving in 1M mode, now passes mcd-verificator word RAM tests
Michael Pavone <pavone@retrodev.com>
parents:
2113
diff
changeset
|
152 return base + address; |
1753
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
153 } |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
154 } |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
155 return NULL; |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
156 } |
33ec5df77fac
Integration of new Z80 core is sort of working now
Michael Pavone <pavone@retrodev.com>
parents:
1703
diff
changeset
|
157 |
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
|
158 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
|
159 { |
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
|
160 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
|
161 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
|
162 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
|
163 } |
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
|
164 uint32_t offset = address & chunk->mask; |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
165 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
166 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
167 } else if (chunk->shift < 0){ |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
168 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
169 } |
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
|
170 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
|
171 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
|
172 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
|
173 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
|
174 } 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
|
175 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
|
176 } |
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
|
177 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
|
178 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
|
179 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
|
180 offset /= 2; |
1419
92e7dafcc0dc
Fix a silly variable shadowing bug in read_word
Michael Pavone <pavone@retrodev.com>
parents:
1313
diff
changeset
|
181 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
|
182 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
|
183 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
|
184 } 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
|
185 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
|
186 } |
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
|
187 } 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
|
188 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
|
189 } |
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
|
190 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
|
191 } |
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
|
192 } |
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
|
193 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
|
194 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
|
195 } |
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
|
196 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
|
197 } |
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
|
198 |
1838
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
199 void write_word(uint32_t address, uint16_t value, void **mem_pointers, cpu_options *opts, void *context) |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
200 { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
201 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
202 if (!chunk) { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
203 return; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
204 } |
1964
9d35ce5012a6
Apply fixes to helper functions in backend.c from interp branch
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
205 uint32_t offset = address & chunk->mask; |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
206 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
207 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
208 } else if (chunk->shift < 0){ |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
209 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
210 } |
1838
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
211 if (chunk->flags & MMAP_WRITE) { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
212 uint8_t *base; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
213 if (chunk->flags & MMAP_PTR_IDX) { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
214 base = mem_pointers[chunk->ptr_index]; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
215 } else { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
216 base = chunk->buffer; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
217 } |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
218 if (base) { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
219 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
220 offset /= 2; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
221 if (chunk->flags & MMAP_ONLY_EVEN) { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
222 value >>= 16; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
223 } |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
224 base[offset] = value; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
225 } else { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
226 *(uint16_t *)(base + offset) = value; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
227 } |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
228 return; |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
229 } |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
230 } |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
231 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_16) { |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
232 chunk->write_16(offset, context, value); |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
233 } |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
234 } |
0c1491818f4b
WIP new 68K core using CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1753
diff
changeset
|
235 |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
236 uint8_t read_byte(uint32_t address, void **mem_pointers, cpu_options *opts, void *context) |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
237 { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
238 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
239 if (!chunk) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
240 return 0xFF; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
241 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
242 uint32_t offset = address & chunk->mask; |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
243 if (offset) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
244 uint32_t low_bit = offset & 1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
245 offset &= ~1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
246 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
247 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
248 } else { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
249 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
250 } |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
251 offset |= low_bit; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
252 } |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
253 if (chunk->flags & MMAP_READ) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
254 uint8_t *base; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
255 if (chunk->flags & MMAP_PTR_IDX) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
256 base = mem_pointers[chunk->ptr_index]; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
257 } else { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
258 base = chunk->buffer; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
259 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
260 if (base) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
261 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
262 if (address & 1) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
263 if (chunk->flags & MMAP_ONLY_EVEN) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
264 return 0xFF; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
265 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
266 } else if (chunk->flags & MMAP_ONLY_ODD) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
267 return 0xFF; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
268 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
269 offset /= 2; |
1964
9d35ce5012a6
Apply fixes to helper functions in backend.c from interp branch
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
270 } else if(opts->byte_swap) { |
9d35ce5012a6
Apply fixes to helper functions in backend.c from interp branch
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
271 offset ^= 1; |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
272 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
273 return base[offset]; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
274 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
275 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
276 if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_8) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
277 return chunk->read_8(offset, context); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
278 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
279 return 0xFF; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
280 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
281 |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
282 void write_byte(uint32_t address, uint8_t value, void **mem_pointers, cpu_options *opts, void *context) |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
283 { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
284 memmap_chunk const *chunk = find_map_chunk(address, opts, 0, NULL); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
285 if (!chunk) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
286 return; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
287 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
288 uint32_t offset = address & chunk->mask; |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
289 if (chunk->shift) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
290 uint32_t low_bit = offset & 1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
291 offset &= ~1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
292 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
293 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
294 } else { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
295 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
296 } |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
297 offset |= low_bit; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
298 } |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
299 if (chunk->flags & MMAP_WRITE) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
300 uint8_t *base; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
301 if (chunk->flags & MMAP_PTR_IDX) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
302 base = mem_pointers[chunk->ptr_index]; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
303 } else { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
304 base = chunk->buffer; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
305 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
306 if (base) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
307 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
308 if (address & 1) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
309 if (chunk->flags & MMAP_ONLY_EVEN) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
310 return; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
311 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
312 } else if (chunk->flags & MMAP_ONLY_ODD) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
313 return; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
314 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
315 offset /= 2; |
1964
9d35ce5012a6
Apply fixes to helper functions in backend.c from interp branch
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
316 } else if(opts->byte_swap) { |
9d35ce5012a6
Apply fixes to helper functions in backend.c from interp branch
Michael Pavone <pavone@retrodev.com>
parents:
1952
diff
changeset
|
317 offset ^= 1; |
1703
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
318 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
319 base[offset] = value; |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
320 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
321 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
322 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_8) { |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
323 chunk->write_8(offset, context, value); |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
324 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
325 } |
49a52c737bf0
Fix zero flag calculation in CPU DSL
Michael Pavone <pavone@retrodev.com>
parents:
1678
diff
changeset
|
326 |
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
|
327 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
|
328 { |
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
|
329 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
|
330 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
|
331 } 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
|
332 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
|
333 } |
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
|
334 } |
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
|
335 |
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
|
336 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
|
337 { |
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
|
338 uint32_t size = 0; |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
339 uint32_t minsize = 1 << (opts->ram_flags_shift + 3); |
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
|
340 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
|
341 { |
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
|
342 if (opts->memmap[i].flags & MMAP_CODE) { |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
343 uint32_t cursize = chunk_size(opts, opts->memmap + i); |
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
344 if (cursize < minsize) { |
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
345 size += minsize; |
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
|
346 } else { |
2036
45c4b74e7676
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Michael Pavone <pavone@retrodev.com>
parents:
1964
diff
changeset
|
347 size += cursize; |
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
|
348 } |
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
|
349 } |
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
|
350 } |
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
|
351 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
|
352 } |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
353 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
354 uint16_t interp_read_direct_16(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
355 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
356 return *(uint16_t *)((address & 0xFFFE) + (uint8_t *)data); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
357 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
358 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
359 uint8_t interp_read_direct_8(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
360 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
361 return ((uint8_t *)data)[(address & 0xFFFF) ^ 1]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
362 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
363 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
364 void interp_write_direct_16(uint32_t address, void *context, uint16_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
365 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
366 *(uint16_t *)((address & 0xFFFE) + (uint8_t *)data) = value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
367 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
368 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
369 void interp_write_direct_8(uint32_t address, void *context, uint8_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
370 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
371 ((uint8_t *)data)[(address & 0xFFFF) ^ 1] = value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
372 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
373 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
374 uint16_t interp_read_indexed_16(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
375 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
376 return *(uint16_t *)((*(uint8_t **)data) + (address & 0xFFFE)); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
377 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
378 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
379 uint8_t interp_read_indexed_8(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
380 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
381 return (*(uint8_t **)data)[(address & 0xFFFF) ^ 1]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
382 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
383 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
384 void interp_write_indexed_16(uint32_t address, void *context, uint16_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
385 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
386 *(uint16_t *)((*(uint8_t **)data) + (address & 0xFFFE)) = value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
387 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
388 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
389 void interp_write_indexed_8(uint32_t address, void *context, uint8_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
390 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
391 (*(uint8_t **)data)[(address & 0xFFFF) ^ 1] = value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
392 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
393 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
394 uint16_t interp_read_fixed_16(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
395 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
396 return (uintptr_t)data; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
397 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
398 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
399 uint8_t interp_read_fixed_8(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
400 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
401 uint16_t val = (uintptr_t)data; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
402 if (address & 1) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
403 return val; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
404 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
405 return val >> 8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
406 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
407 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
408 void interp_write_ignored_16(uint32_t address, void *context, uint16_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
409 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
410 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
411 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
412 void interp_write_ignored_8(uint32_t address, void *context, uint8_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
413 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
414 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
415 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
416 uint16_t interp_read_map_16(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
417 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
418 const memmap_chunk *chunk = data; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
419 cpu_options * opts = *(cpu_options **)context; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
420 if (address < chunk->start || address >= chunk->end) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
421 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
422 const memmap_chunk *map_end = opts->memmap + opts->memmap_chunks; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
423 for (chunk++; chunk < map_end; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
424 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
425 if (address >= chunk->start && address < chunk->end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
426 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
427 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
428 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
429 if (chunk == map_end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
430 return 0xFFFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
431 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
432 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
433 uint32_t offset = address & chunk->mask; |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
434 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
435 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
436 } else if (chunk->shift < 0){ |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
437 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
438 } |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
439 if (chunk->flags & MMAP_READ) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
440 uint8_t *base; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
441 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
442 uint8_t ** mem_pointers = (uint8_t**)(opts->mem_ptr_off + (uint8_t *)context); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
443 base = mem_pointers[chunk->ptr_index]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
444 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
445 base = chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
446 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
447 if (base) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
448 uint16_t val; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
449 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
450 offset /= 2; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
451 val = base[offset]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
452 if (chunk->flags & MMAP_ONLY_ODD) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
453 val |= 0xFF00; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
454 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
455 val = val << 8 | 0xFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
456 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
457 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
458 val = *(uint16_t *)(base + offset); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
459 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
460 return val; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
461 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
462 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
463 if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_16) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
464 return chunk->read_16(offset, context); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
465 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
466 return 0xFFFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
467 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
468 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
469 uint8_t interp_read_map_8(uint32_t address, void *context, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
470 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
471 const memmap_chunk *chunk = data; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
472 cpu_options * opts = *(cpu_options **)context; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
473 if (address < chunk->start || address >= chunk->end) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
474 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
475 const memmap_chunk *map_end = opts->memmap + opts->memmap_chunks; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
476 for (chunk++; chunk < map_end; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
477 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
478 if (address >= chunk->start && address < chunk->end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
479 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
480 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
481 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
482 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
483 if (chunk == map_end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
484 return 0xFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
485 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
486 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
487 uint32_t offset = address & chunk->mask; |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
488 if (chunk->shift) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
489 uint32_t low_bit = offset & 1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
490 offset &= ~1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
491 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
492 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
493 } else { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
494 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
495 } |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
496 offset |= low_bit; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
497 } |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
498 if (chunk->flags & MMAP_READ) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
499 uint8_t *base; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
500 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
501 uint8_t ** mem_pointers = (uint8_t**)(opts->mem_ptr_off + (uint8_t *)context); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
502 base = mem_pointers[chunk->ptr_index]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
503 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
504 base = chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
505 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
506 if (base) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
507 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
508 if (address & 1) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
509 if (chunk->flags & MMAP_ONLY_EVEN) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
510 return 0xFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
511 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
512 } else if (chunk->flags & MMAP_ONLY_ODD) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
513 return 0xFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
514 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
515 offset /= 2; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
516 } else if(opts->byte_swap) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
517 offset ^= 1; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
518 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
519 return base[offset]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
520 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
521 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
522 if ((!(chunk->flags & MMAP_READ) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->read_8) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
523 return chunk->read_8(offset, context); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
524 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
525 return 0xFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
526 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
527 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
528 void interp_write_map_16(uint32_t address, void *context, uint16_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
529 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
530 const memmap_chunk *chunk = data; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
531 cpu_options * opts = *(cpu_options **)context; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
532 if (address < chunk->start || address >= chunk->end) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
533 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
534 const memmap_chunk *map_end = opts->memmap + opts->memmap_chunks; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
535 for (chunk++; chunk < map_end; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
536 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
537 if (address >= chunk->start && address < chunk->end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
538 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
539 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
540 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
541 if (chunk == map_end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
542 return; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
543 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
544 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
545 uint32_t offset = address & chunk->mask; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
546 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
547 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
548 } else if (chunk->shift < 0){ |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
549 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
550 } |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
551 if (chunk->flags & MMAP_WRITE) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
552 uint8_t *base; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
553 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
554 uint8_t ** mem_pointers = (uint8_t**)(opts->mem_ptr_off + (uint8_t *)context); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
555 base = mem_pointers[chunk->ptr_index]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
556 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
557 base = chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
558 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
559 if (base) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
560 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
561 offset /= 2; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
562 if (chunk->flags & MMAP_ONLY_EVEN) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
563 value >>= 16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
564 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
565 base[offset] = value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
566 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
567 *(uint16_t *)(base + offset) = value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
568 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
569 return; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
570 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
571 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
572 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_16) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
573 chunk->write_16(offset, context, value); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
574 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
575 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
576 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
577 void interp_write_map_8(uint32_t address, void *context, uint8_t value, void *data) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
578 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
579 const memmap_chunk *chunk = data; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
580 cpu_options * opts = *(cpu_options **)context; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
581 if (address < chunk->start || address >= chunk->end) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
582 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
583 const memmap_chunk *map_end = opts->memmap + opts->memmap_chunks; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
584 for (chunk++; chunk < map_end; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
585 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
586 if (address >= chunk->start && address < chunk->end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
587 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
588 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
589 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
590 if (chunk == map_end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
591 return; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
592 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
593 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
594 uint32_t offset = address & chunk->mask; |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
595 if (chunk->shift) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
596 uint32_t low_bit = offset & 1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
597 offset &= ~1; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
598 if (chunk->shift > 0) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
599 offset <<= chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
600 } else { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
601 offset >>= -chunk->shift; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
602 } |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
603 offset |= low_bit; |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
604 } |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
605 if (chunk->flags & MMAP_WRITE) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
606 uint8_t *base; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
607 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
608 uint8_t ** mem_pointers = (uint8_t**)(opts->mem_ptr_off + (uint8_t *)context); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
609 base = mem_pointers[chunk->ptr_index]; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
610 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
611 base = chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
612 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
613 if (base) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
614 if ((chunk->flags & MMAP_ONLY_ODD) || (chunk->flags & MMAP_ONLY_EVEN)) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
615 if (address & 1) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
616 if (chunk->flags & MMAP_ONLY_EVEN) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
617 return; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
618 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
619 } else if (chunk->flags & MMAP_ONLY_ODD) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
620 return; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
621 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
622 offset /= 2; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
623 } else if(opts->byte_swap) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
624 offset ^= 1; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
625 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
626 base[offset] = value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
627 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
628 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
629 if ((!(chunk->flags & MMAP_WRITE) || (chunk->flags & MMAP_FUNC_NULL)) && chunk->write_8) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
630 chunk->write_8(offset, context, value); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
631 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
632 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
633 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
634 interp_read_16 get_interp_read_16(void *context, cpu_options *opts, uint32_t start, uint32_t end, void **data_out) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
635 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
636 const memmap_chunk *chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
637 for (chunk = opts->memmap; chunk < opts->memmap + opts->memmap_chunks; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
638 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
639 if (chunk->end > start && chunk->start < end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
640 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
641 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
642 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
643 if (chunk == opts->memmap + opts->memmap_chunks) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
644 *data_out = (void *)(uintptr_t)0xFFFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
645 return interp_read_fixed_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
646 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
647 if (chunk->end < end || chunk->start > start || chunk->shift) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
648 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
649 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
650 if (chunk->flags & MMAP_READ) { |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
651 if ((chunk->flags & (MMAP_ONLY_ODD|MMAP_ONLY_EVEN|MMAP_FUNC_NULL))) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
652 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
653 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
654 if (!chunk->mask && !(chunk->flags & ~MMAP_READ)) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
655 uintptr_t value = *(uint16_t *)chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
656 *data_out = (void *)value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
657 return interp_read_fixed_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
658 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
659 if ((chunk->mask & 0xFFFF) != 0xFFFF) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
660 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
661 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
662 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
663 if (chunk->mask != 0xFFFF && start > 0) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
664 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
665 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
666 *data_out = (void *)(chunk->ptr_index + (void **)(((char *)context) + opts->mem_ptr_off)); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
667 return interp_read_indexed_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
668 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
669 *data_out = (start & chunk->mask) + (uint8_t *)chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
670 return interp_read_direct_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
671 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
672 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
673 if (chunk->read_16 && chunk->mask == opts->address_mask) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
674 *data_out = NULL; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
675 //This is not safe for all calling conventions due to the extra param |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
676 //but should work for the ones we actually care about |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
677 return (interp_read_16)chunk->read_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
678 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
679 use_map: |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
680 *data_out = (void *)chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
681 return interp_read_map_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
682 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
683 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
684 interp_read_8 get_interp_read_8(void *context, cpu_options *opts, uint32_t start, uint32_t end, void **data_out) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
685 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
686 const memmap_chunk *chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
687 for (chunk = opts->memmap; chunk < opts->memmap + opts->memmap_chunks; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
688 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
689 if (chunk->end > start && chunk->start < end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
690 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
691 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
692 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
693 if (chunk == opts->memmap + opts->memmap_chunks) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
694 *data_out = (void *)(uintptr_t)0xFFFF; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
695 return interp_read_fixed_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
696 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
697 if (chunk->end != end || chunk->start != start || chunk->shift) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
698 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
699 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
700 if (chunk->flags & MMAP_READ) { |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
701 if ((chunk->flags & (MMAP_ONLY_ODD|MMAP_ONLY_EVEN|MMAP_FUNC_NULL)) || !opts->byte_swap) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
702 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
703 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
704 if (!chunk->mask && !(chunk->flags & ~MMAP_READ)) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
705 uintptr_t value = *(uint8_t *)chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
706 *data_out = (void *)value; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
707 return interp_read_fixed_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
708 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
709 if ((chunk->mask & 0xFFFF) != 0xFFFF) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
710 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
711 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
712 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
713 if (chunk->mask != 0xFFFF && start > 0) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
714 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
715 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
716 *data_out = (void *)(chunk->ptr_index + (void **)(((char *)context) + opts->mem_ptr_off)); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
717 return interp_read_indexed_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
718 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
719 *data_out = (start & chunk->mask) + (uint8_t *)chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
720 return interp_read_direct_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
721 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
722 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
723 if (chunk->read_8 && chunk->mask == opts->address_mask) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
724 *data_out = NULL; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
725 //This is not safe for all calling conventions due to the extra param |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
726 //but should work for the ones we actually care about |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
727 return (interp_read_8)chunk->read_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
728 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
729 use_map: |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
730 *data_out = (void *)chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
731 return interp_read_map_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
732 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
733 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
734 interp_write_16 get_interp_write_16(void *context, cpu_options *opts, uint32_t start, uint32_t end, void **data_out) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
735 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
736 const memmap_chunk *chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
737 for (chunk = opts->memmap; chunk < opts->memmap + opts->memmap_chunks; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
738 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
739 if (chunk->end > start && chunk->start < end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
740 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
741 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
742 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
743 if (chunk == opts->memmap + opts->memmap_chunks) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
744 *data_out = NULL; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
745 return interp_write_ignored_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
746 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
747 if (chunk->end != end || chunk->start != start || chunk->shift) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
748 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
749 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
750 if (chunk->flags & MMAP_WRITE) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
751 if ((chunk->flags & (MMAP_ONLY_ODD|MMAP_ONLY_EVEN|MMAP_FUNC_NULL)) || (chunk->mask & 0xFFFF) != 0xFFFF) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
752 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
753 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
754 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
755 if (chunk->mask != 0xFFFF && start > 0) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
756 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
757 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
758 *data_out = (void *)(chunk->ptr_index + (void **)(((char *)context) + opts->mem_ptr_off)); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
759 return interp_write_indexed_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
760 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
761 *data_out = (start & chunk->mask) + (uint8_t *)chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
762 return interp_write_direct_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
763 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
764 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
765 if (chunk->write_16 && chunk->mask == opts->address_mask) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
766 *data_out = NULL; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
767 //This is not safe for all calling conventions due to the extra param |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
768 //but should work for the ones we actually care about |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
769 return (interp_write_16)chunk->write_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
770 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
771 use_map: |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
772 *data_out = (void *)chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
773 return interp_write_map_16; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
774 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
775 |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
776 interp_write_8 get_interp_write_8(void *context, cpu_options *opts, uint32_t start, uint32_t end, void **data_out) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
777 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
778 const memmap_chunk *chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
779 for (chunk = opts->memmap; chunk < opts->memmap + opts->memmap_chunks; chunk++) |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
780 { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
781 if (chunk->end > start && chunk->start < end) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
782 break; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
783 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
784 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
785 if (chunk == opts->memmap + opts->memmap_chunks) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
786 *data_out = NULL; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
787 return interp_write_ignored_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
788 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
789 if (chunk->end != end || chunk->start != start || chunk->shift) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
790 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
791 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
792 if (chunk->flags & MMAP_WRITE) { |
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
793 if ((chunk->flags & (MMAP_ONLY_ODD|MMAP_ONLY_EVEN|MMAP_FUNC_NULL)) |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
794 || (chunk->mask & 0xFFFF) != 0xFFFF || !opts->byte_swap |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
795 ) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
796 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
797 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
798 if (chunk->flags & MMAP_PTR_IDX) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
799 if (chunk->mask != 0xFFFF && start > 0) { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
800 goto use_map; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
801 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
802 *data_out = (void *)(chunk->ptr_index + (void **)(((char *)context) + opts->mem_ptr_off)); |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
803 return interp_write_indexed_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
804 } else { |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
805 *data_out = (start & chunk->mask) + (uint8_t *)chunk->buffer; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
806 return interp_write_direct_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
807 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
808 } |
2668
b0b6c6042103
Fix some bugs in memory access functions used in interpreter mode
Michael Pavone <pavone@retrodev.com>
parents:
2666
diff
changeset
|
809 if (chunk->write_8 && chunk->mask == opts->address_mask) { |
2666
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
810 *data_out = NULL; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
811 //This is not safe for all calling conventions due to the extra param |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
812 //but should work for the ones we actually care about |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
813 return (interp_write_8)chunk->write_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
814 } |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
815 use_map: |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
816 *data_out = (void *)chunk; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
817 return interp_write_map_8; |
38c281ef57b0
Memory access optimizaiton in new 68K core that gives a modest speed bump on average and will allow low-cost watchpoints
Michael Pavone <pavone@retrodev.com>
parents:
2134
diff
changeset
|
818 } |