Mercurial > repos > blastem
annotate sega_mapper.c @ 1554:87350caf6dab
Allow double click to open ROM in file browser
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 29 Mar 2018 00:40:41 -0700 |
parents | 14a2834d010c |
children | 75172d440900 d60f2d7c02a5 |
rev | line source |
---|---|
1415
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #include "genesis.h" |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 uint16_t read_sram_w(uint32_t address, m68k_context * context) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
4 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
5 genesis_context * gen = context->system; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 address &= gen->save_ram_mask; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 switch(gen->save_type) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 case RAM_FLAG_BOTH: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
10 return gen->save_storage[address] << 8 | gen->save_storage[address+1]; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
11 case RAM_FLAG_EVEN: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
12 return gen->save_storage[address >> 1] << 8 | 0xFF; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
13 case RAM_FLAG_ODD: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
14 return gen->save_storage[address >> 1] | 0xFF00; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
15 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
16 return 0xFFFF;//We should never get here |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
18 |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 uint8_t read_sram_b(uint32_t address, m68k_context * context) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
20 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
21 genesis_context * gen = context->system; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
22 address &= gen->save_ram_mask; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
23 switch(gen->save_type) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
24 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
25 case RAM_FLAG_BOTH: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
26 return gen->save_storage[address]; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
27 case RAM_FLAG_EVEN: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
28 if (address & 1) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
29 return 0xFF; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
30 } else { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
31 return gen->save_storage[address >> 1]; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
32 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
33 case RAM_FLAG_ODD: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
34 if (address & 1) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
35 return gen->save_storage[address >> 1]; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
36 } else { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 return 0xFF; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
38 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
39 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
40 return 0xFF;//We should never get here |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
41 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
42 |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
43 m68k_context * write_sram_area_w(uint32_t address, m68k_context * context, uint16_t value) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
44 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
45 genesis_context * gen = context->system; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
46 if ((gen->bank_regs[0] & 0x3) == 1) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
47 address &= gen->save_ram_mask; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
48 switch(gen->save_type) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
49 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
50 case RAM_FLAG_BOTH: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
51 gen->save_storage[address] = value >> 8; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
52 gen->save_storage[address+1] = value; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
53 break; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
54 case RAM_FLAG_EVEN: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
55 gen->save_storage[address >> 1] = value >> 8; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
56 break; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
57 case RAM_FLAG_ODD: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
58 gen->save_storage[address >> 1] = value; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
59 break; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
60 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
61 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
62 return context; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
63 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
64 |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
65 m68k_context * write_sram_area_b(uint32_t address, m68k_context * context, uint8_t value) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
66 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
67 genesis_context * gen = context->system; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
68 if ((gen->bank_regs[0] & 0x3) == 1) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
69 address &= gen->save_ram_mask; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
70 switch(gen->save_type) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
71 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
72 case RAM_FLAG_BOTH: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
73 gen->save_storage[address] = value; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
74 break; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
75 case RAM_FLAG_EVEN: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
76 if (!(address & 1)) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
77 gen->save_storage[address >> 1] = value; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
78 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
79 break; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
80 case RAM_FLAG_ODD: |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
81 if (address & 1) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
82 gen->save_storage[address >> 1] = value; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
83 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
84 break; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
85 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
86 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
87 return context; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
88 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 m68k_context * write_bank_reg_w(uint32_t address, m68k_context * context, uint16_t value) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
92 genesis_context * gen = context->system; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 address &= 0xE; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 address >>= 1; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 gen->bank_regs[address] = value; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
96 if (!address) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 if (value & 1) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
98 //Used for games that only use the mapper for SRAM |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
99 if (context->mem_pointers[gen->mapper_start_index]) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
100 gen->mapper_temp = context->mem_pointers[gen->mapper_start_index]; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
101 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
102 context->mem_pointers[gen->mapper_start_index] = NULL; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
103 //For games that need more than 4MB |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
104 for (int i = 4; i < 8; i++) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
105 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
106 context->mem_pointers[gen->mapper_start_index + i] = NULL; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
107 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
108 } else { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
109 //Used for games that only use the mapper for SRAM |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
110 if (!context->mem_pointers[gen->mapper_start_index]) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
111 context->mem_pointers[gen->mapper_start_index] = gen->mapper_temp; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
112 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
113 //For games that need more than 4MB |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
114 for (int i = 4; i < 8; i++) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
115 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
116 context->mem_pointers[gen->mapper_start_index + i] = gen->cart + 0x40000*gen->bank_regs[i]; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
117 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
118 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 } else { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 void *new_ptr = gen->cart + 0x40000*value; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 if (context->mem_pointers[gen->mapper_start_index + address] != new_ptr) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
122 m68k_invalidate_code_range(gen->m68k, address * 0x80000, (address + 1) * 0x80000); |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 context->mem_pointers[gen->mapper_start_index + address] = new_ptr; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
125 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
126 return context; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
127 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
128 |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
129 m68k_context * write_bank_reg_b(uint32_t address, m68k_context * context, uint8_t value) |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 if (address & 1) { |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
132 write_bank_reg_w(address, context, value); |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
133 } |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
134 return context; |
f7d653bb8899
Move Sega mapper implementation out of romdb.c
Michael Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
135 } |
1444
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
136 |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
137 void sega_mapper_serialize(genesis_context *gen, serialize_buffer *buf) |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
138 { |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
139 save_buffer8(buf, gen->bank_regs, sizeof(gen->bank_regs)); |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
140 } |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
141 |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
142 void sega_mapper_deserialize(deserialize_buffer *buf, genesis_context *gen) |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
143 { |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
144 for (int i = 0; i < sizeof(gen->bank_regs); i++) |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
145 { |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
146 write_bank_reg_w(i * 2, gen->m68k, load_int8(buf)); |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
147 } |
14a2834d010c
Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents:
1415
diff
changeset
|
148 } |