annotate multi_game.c @ 1603:c0727712d529

Read extral SDL2 mappings on startup from controller_types.cfg
author Michael Pavone <pavone@retrodev.com>
date Tue, 31 Jul 2018 23:08:52 -0700
parents adb62000d296
children d74d3998482c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1416
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include "genesis.h"
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 void *write_multi_game_b(uint32_t address, void *vcontext, uint8_t value)
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 {
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 m68k_context *context = vcontext;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 genesis_context *gen = context->system;
1444
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
7 gen->bank_regs[0] = address;
1416
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 uint32_t base = (address & 0x3F) << 16, start = 0, end = 0x400000;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9 //find the memmap chunk, so we can properly mask the base value
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 for (int i = 0; i < context->options->gen.memmap_chunks; i++)
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11 {
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
12 if (context->options->gen.memmap[i].flags & MMAP_PTR_IDX) {
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
13 base &= context->options->gen.memmap[i].mask;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
14 start = context->options->gen.memmap[i].start;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
15 end = context->options->gen.memmap[i].end;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
16 break;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
17 }
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
18 }
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
19 context->mem_pointers[gen->mapper_start_index] = gen->cart + base/2;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
20 m68k_invalidate_code_range(context, start, end);
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
21 return vcontext;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
22 }
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
23
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
24 void *write_multi_game_w(uint32_t address, void *context, uint16_t value)
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
25 {
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
26 return write_multi_game_b(address, context, value);
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
27 }
1444
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
28
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
29 void multi_game_serialize(genesis_context *gen, serialize_buffer *buf)
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
30 {
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
31 save_int8(buf, gen->bank_regs[0]);
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
32 }
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
33
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
34 void multi_game_deserialize(deserialize_buffer *buf, genesis_context *gen)
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
35 {
1446
adb62000d296 Pass the correct context pointer to write handlers in mapper deserialize functions
Michael Pavone <pavone@retrodev.com>
parents: 1444
diff changeset
36 write_multi_game_b(load_int8(buf), gen->m68k, 0);
1444
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
37 }