Mercurial > repos > blastem
annotate multi_game.c @ 1970:41b9509ede38
megawifi: implement CMD_DATETIME
author | doragasu <doragasu@hotmail.com> |
---|---|
date | Fri, 08 May 2020 00:26:34 -0700 |
parents | adb62000d296 |
children | d74d3998482c |
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 } |