comparison sms.c @ 2325:26597f9805b4

Initial Codemasters mapper support
author Michael Pavone <pavone@retrodev.com>
date Tue, 18 Jul 2023 21:46:09 -0700
parents 2eda5f81f91e
children 03e6ac327ba0
comparison
equal deleted inserted replaced
2321:2eda5f81f91e 2325:26597f9805b4
174 location &= 0x3FFF; 174 location &= 0x3FFF;
175 z80->mem_pointers[2][location] = value; 175 z80->mem_pointers[2][location] = value;
176 z80_handle_code_write(0x8000 + location, z80); 176 z80_handle_code_write(0x8000 + location, z80);
177 } 177 }
178 return vcontext; 178 return vcontext;
179 }
180
181 static z80_context *codemasters_write(uint8_t bank, z80_context *z80, uint8_t value)
182 {
183 sms_context *sms = z80->system;
184 if (value != sms->bank_regs[bank]) {
185 sms->bank_regs[bank] = value;
186 value &= 0x7F;
187 z80->mem_pointers[bank] = sms->rom + (value << 14 & (sms->rom_size-1));
188 z80_invalidate_code_range(z80, bank * 0x4000, bank * 0x4000 + 0x4000);
189 }
190 return z80;
191 }
192
193 void *sms_codemasters_bank0_write(uint32_t location, void *vcontext, uint8_t value)
194 {
195 return codemasters_write(0, vcontext, value);
196 }
197
198 void *sms_codemasters_bank1_write(uint32_t location, void *vcontext, uint8_t value)
199 {
200 return codemasters_write(1, vcontext, value);
201 }
202
203 void *sms_codemasters_bank2_write(uint32_t location, void *vcontext, uint8_t value)
204 {
205 //TODO: Handle Ernie Els Golf cart RAM
206 return codemasters_write(2, vcontext, value);
179 } 207 }
180 208
181 uint8_t debug_commands(system_header *system, char *input_buf) 209 uint8_t debug_commands(system_header *system, char *input_buf)
182 { 210 {
183 sms_context *sms = (sms_context *)system; 211 sms_context *sms = (sms_context *)system;