annotate xband.c @ 1944:357878be8be6

Fix vgmplay target
author Michael Pavone <pavone@retrodev.com>
date Sun, 26 Apr 2020 14:56:44 -0700
parents 17c1c30e0d6f
children d74d3998482c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <stdlib.h>
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stddef.h>
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include <string.h>
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include "romdb.h"
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
5 #include "genesis.h"
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
6 #include "tern.h"
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
7 #include "xband.h"
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
8 #include "util.h"
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
9
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
10 #define BIT_ROM_HI 4
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
11
1230
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
12 enum {
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
13 PATCH0_LOW,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
14 PATCH0_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
15 PATCH0_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
16 PATCH1_LOW=4,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
17 PATCH1_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
18 PATCH1_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
19 PATCH2_LOW=8,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
20 PATCH2_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
21 PATCH2_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
22 PATCH3_LOW=12,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
23 PATCH3_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
24 PATCH3_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
25 PATCH4_LOW=16,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
26 PATCH4_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
27 PATCH4_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
28 PATCH5_LOW=20,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
29 PATCH5_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
30 PATCH5_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
31 PATCH6_LOW=24,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
32 PATCH6_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
33 PATCH6_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
34 PATCH7_LOW=28,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
35 PATCH7_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
36 PATCH7_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
37 PATCH8_LOW=32,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
38 PATCH8_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
39 PATCH8_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
40 PATCH9_LOW=36,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
41 PATCH9_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
42 PATCH9_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
43 PATCH10_LOW=40,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
44 PATCH10_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
45 PATCH10_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
46 RANGE0_START_LOW=44,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
47 RANGE0_START_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
48 RANGE0_START_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
49 RANGE1_START=48,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
50 RANGE1_START_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
51 RANGE1_START_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
52 MAGIC_LOW=56,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
53 MAGIC_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
54 MAGIC_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
55 RANGE0_END_LOW=64,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
56 RANGE0_END_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
57 RANGE0_END_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
58 RANGE1_END_LOW=68,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
59 RANGE1_END_MID,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
60 RANGE1_END_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
61 RANGE0_DEST_LOW=80,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
62 RANGE0_DEST_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
63 RANGE0_MASK,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
64 RANGE1_DEST_LOW=84,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
65 RANGE1_DEST_HI,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
66 RANGE1_MASK,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
67
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
68 MORE_MYSTERY=219,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
69 UNKNOWN_REG=221,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
70 UNKNOWN_REG2,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
71 UNKNOWN_REG3,
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
72
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
73 };
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
74
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
75 //#define DO_DEBUG_PRINT
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
76 #ifdef DO_DEBUG_PRINT
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
77 #define dprintf printf
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
78 #define dputs puts
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
79 #else
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
80 #define dprintf
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
81 #define dputs
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
82 #endif
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
83
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
84 uint8_t xband_detect(uint8_t *rom, uint32_t rom_size)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
85 {
1468
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
86 if (rom_size < 0x200) {
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
87 return 0;
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
88 }
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
89
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
90 //product ID is all NULL
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
91 for (int i = GAME_ID_OFF; i <= (GAME_ID_OFF + GAME_ID_LEN); i++)
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
92 {
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
93 if (rom[i]) {
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
94 return 0;
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
95 }
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
96 }
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
97
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
98 if (!memcmp(rom+8, "DAVE", 4)) {
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
99 //XBAND test roms
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
100 return 1;
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
101 }
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
102
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
103 //Internal ROM is 512KB, accept larger ones for overdumps and custom firmware
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
104 if (rom_size < (512*1024)) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
105 return 0;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
106 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
107
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
108 //ROM has no standard header, but does have a jump at $100
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
109 if (rom[0x100] != 0x4E || rom[0x101] != 0xF9) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
110 return 0;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
111 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
112
1468
17c1c30e0d6f Added detection of XBAND test ROMs. None seem to actually work with my limited FRED chip implementation though
Michael Pavone <pavone@retrodev.com>
parents: 1446
diff changeset
113
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
114 return 1;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
115 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
116
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
117 static xband *get_xband(genesis_context *gen)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
118 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
119 if (!gen->extra) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
120 gen->extra = gen->m68k->options->gen.memmap[0].buffer;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
121 gen->m68k->mem_pointers[2] = (uint16_t *)gen->save_storage;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
122 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
123 return gen->extra;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
124 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
125
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
126 static void update_control(genesis_context *gen, uint8_t value)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
127 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
128 xband *x = gen->extra;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
129 if ((x->control ^ value) & BIT_ROM_HI) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
130 if (value & BIT_ROM_HI) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
131 gen->m68k->mem_pointers[0] = (uint16_t *)gen->save_storage;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
132 gen->m68k->mem_pointers[1] = NULL;
1229
a8313793216a Minor xband fixes
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
133 gen->m68k->mem_pointers[2] = gen->cart;
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
134 gen->m68k->mem_pointers[3] = x->cart_space - 0x100000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
135 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
136 gen->m68k->mem_pointers[0] = x->cart_space;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
137 gen->m68k->mem_pointers[1] = x->cart_space;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
138 gen->m68k->mem_pointers[2] = (uint16_t *)gen->save_storage;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
139 gen->m68k->mem_pointers[3] = NULL;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
140 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
141 m68k_invalidate_code_range(gen->m68k, 0, 0x3BC000);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
142 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
143 x->control = value;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
144 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
145
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
146 static void *xband_write_b(uint32_t address, void *context, uint8_t value)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
147 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
148 m68k_context *m68k = context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
149 genesis_context *gen = m68k->system;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
150 xband *x = get_xband(gen);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
151 if (address == 0x181) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
152 x->kill = value;
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
153 dprintf("Write to \"soft\" kill register %X\n", value);
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
154 } else if (address == 0x183) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
155 update_control(gen, value);
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
156 dprintf("Write to \"soft\" control register %X\n", value);
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
157 } else if ((x->control & BIT_ROM_HI && address < 0x200000) || (address >= 0x200000 && !(x->control & BIT_ROM_HI))) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
158 gen->save_storage[(address & 0xFFFF) ^ 1] = value;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
159 m68k_handle_code_write(address, m68k);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
160 //TODO: handle code at mirror addresses
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
161 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
162 printf("Unhandled write to cartridge area %X: %X\n", address, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
163 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
164 return context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
165 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
166
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
167 static void *xband_write_hi_b(uint32_t address, void *context, uint8_t value)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
168 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
169 return xband_write_b(address | 0x200000, context, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
170 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
171
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
172 static void *xband_write_w(uint32_t address, void *context, uint16_t value)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
173 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
174 m68k_context *m68k = context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
175 genesis_context *gen = m68k->system;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
176 xband *x = get_xband(gen);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
177 if (address == 0x180 || address == 0x182) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
178 return xband_write_b(address | 1, context, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
179 } else if ((x->control & BIT_ROM_HI && address < 0x200000) || (address >= 0x200000 && !(x->control & BIT_ROM_HI))) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
180 gen->save_storage[address & 0xFFFE] = value;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
181 gen->save_storage[(address & 0xFFFE) | 1] = value >> 8;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
182 m68k_handle_code_write(address, m68k);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
183 //TODO: handle code at mirror addresses
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
184 return context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
185 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
186 printf("Unhandled write to %X: %X\n", address, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
187 return context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
188 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
189
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
190 static void *xband_write_hi_w(uint32_t address, void *context, uint16_t value)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
191 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
192 return xband_write_w(address | 0x200000, context, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
193 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
194
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
195 static uint16_t xband_read_w(uint32_t address, void *context)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
196 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
197 m68k_context *m68k = context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
198 genesis_context *gen = m68k->system;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
199 xband *x = get_xband(gen);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
200 //TODO: actually do something intelligent here
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
201 return x->cart_space[address >> 1];
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
202 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
203
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
204 static uint16_t xband_read_hi_w(uint32_t address, void *context)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
205 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
206 return xband_read_w(address | 0x200000, context);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
207 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
208
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
209 static uint8_t xband_read_b(uint32_t address, void *context)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
210 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
211 uint16_t val = xband_read_w(address, context);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
212 return address & 1 ? val : val >> 8;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
213 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
214
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
215 static uint8_t xband_read_hi_b(uint32_t address, void *context)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
216 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
217 return xband_read_b(address | 0x200000, context);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
218 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
219
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
220 static void *xband_reg_write_b(uint32_t address, void *context, uint8_t value)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
221 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
222 m68k_context *m68k = context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
223 genesis_context *gen = m68k->system;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
224 if (!(address & 1)) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
225 printf("Ignoring write to even address %X: %X\n", address, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
226 return context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
227 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
228 xband *x = get_xband(gen);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
229 if (address < 0x3BFE00) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
230 uint32_t offset = (address - 0x3BC001) / 2;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
231 if (offset < XBAND_REGS) {
1230
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
232 switch (offset)
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
233 {
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
234 case MORE_MYSTERY:
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
235 case UNKNOWN_REG:
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
236 dprintf("Write to mysterious reg: %X: %X\n", address, value);
1230
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
237 value = value & 0x7F;
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
238 break;
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
239 case UNKNOWN_REG3:
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
240 dprintf("Write to mysterious reg: %X: %X\n", address, value);
1230
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
241 value = value & 0xFE;
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
242 break;
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
243 }
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
244 x->regs[offset] = value;
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
245 dprintf("Write to register %X(%d): %X\n", address, offset, value);
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
246 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
247 printf("Unhandled register write %X: %X\n", address, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
248 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
249 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
250 if (address == 0x3BFE01) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
251 x->kill = value;
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
252 dprintf("Write to kill register %X\n", value);
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
253 } else if (address == 0x3BFE03) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
254 update_control(gen, value);
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
255 dprintf("Write to control register %X\n", value);
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
256 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
257 printf("Unhandled register write %X: %X\n", address, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
258 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
259 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
260 return context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
261 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
262
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
263 static void *xband_reg_write_w(uint32_t address, void *context, uint16_t value)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
264 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
265 return xband_reg_write_b(address | 1, context, value);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
266 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
267
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
268 static uint8_t xband_reg_read_b(uint32_t address, void *context)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
269 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
270 m68k_context *m68k = context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
271 genesis_context *gen = m68k->system;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
272 if (!(address & 1)) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
273 printf("Read from even address %X\n", address);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
274 return gen->header.get_open_bus_value(&gen->header) >> 8;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
275 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
276 xband *x = get_xband(gen);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
277 if (address < 0x3BFE00) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
278 uint32_t offset = (address - 0x3BC001) / 2;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
279 if (offset < XBAND_REGS) {
1231
d9d775d61fcf Cut down on the verbose logging in XBAND code
Michael Pavone <pavone@retrodev.com>
parents: 1230
diff changeset
280 dprintf("Regsister read: %X\n", address);
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
281 return x->regs[offset];
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
282 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
283 printf("Unhandled register read from address %X\n", address);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
284 return 0x5D;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
285 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
286 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
287 if (address == 0x3BFE01) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
288 return x->kill;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
289 } else if (address == 0x3BFE03) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
290 return x->control;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
291 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
292 printf("Unhandled register read from address %X\n", address);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
293 return 0x5D;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
294 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
295 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
296 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
297
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
298 static uint16_t xband_reg_read_w(uint32_t address, void *context)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
299 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
300 m68k_context *m68k = context;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
301 genesis_context *gen = m68k->system;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
302 uint16_t value = xband_reg_read_b(address | 1, context);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
303 value |= gen->header.get_open_bus_value(&gen->header) & 0xFF00;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
304 return value;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
305 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
306
1444
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
307 void xband_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
308 {
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
309 xband *x = get_xband(gen);
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
310 save_int8(buf, x->kill);
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
311 save_int8(buf, x->control);
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
312 save_buffer8(buf, x->regs, XBAND_REGS);
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
313 }
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
314
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
315 void xband_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
316 {
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
317 xband *x = get_xband(gen);
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
318 x->kill = load_int8(buf);
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
319 update_control(gen, load_int8(buf));
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
320 for (int i = 0; i < XBAND_REGS; i++)
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
321 {
1446
adb62000d296 Pass the correct context pointer to write handlers in mapper deserialize functions
Michael Pavone <pavone@retrodev.com>
parents: 1444
diff changeset
322 xband_write_b(0x3BC001 + i*2, gen->m68k, load_int8(buf));
1444
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
323 }
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
324 }
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
325
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
326 rom_info xband_configure_rom(tern_node *rom_db, void *rom, uint32_t rom_size, void *lock_on, uint32_t lock_on_size, memmap_chunk const *base_map, uint32_t base_chunks)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
327 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
328 rom_info info;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
329 if (lock_on && lock_on_size) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
330 rom_info lock_on_info = configure_rom(rom_db, lock_on, lock_on_size, NULL, 0, base_map, base_chunks);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
331 info.name = alloc_concat("XBAND - ", lock_on_info.name);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
332 info.regions = lock_on_info.regions;
1411
780fbe0b97be WIP support for handling S3 save RAM when locked on
Michael Pavone <pavone@retrodev.com>
parents: 1255
diff changeset
333 free_rom_info(&lock_on_info);
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
334 } else {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
335 info.name = strdup("XBAND");
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
336 info.regions = REGION_J|REGION_U|REGION_E;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
337 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
338 info.save_size = 64*1024;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
339 info.save_buffer = malloc(info.save_size);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
340 info.save_mask = info.save_size-1;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
341 info.save_type = RAM_FLAG_BOTH;
1255
6370b80491c7 Automatically connect XBAND keyboard if XBAND ROM is detected
Michael Pavone <pavone@retrodev.com>
parents: 1231
diff changeset
342 info.port1_override = info.ext_override = info.mouse_mode = NULL;
6370b80491c7 Automatically connect XBAND keyboard if XBAND ROM is detected
Michael Pavone <pavone@retrodev.com>
parents: 1231
diff changeset
343 info.port2_override = strdup("xband keyboard");
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
344 info.eeprom_map = NULL;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
345 info.num_eeprom = 0;
1416
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents: 1411
diff changeset
346 info.rom = rom;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents: 1411
diff changeset
347 info.rom_size = rom_size;
11ac0b511cff Support a couple of bootleg X-in-1 carts
Michael Pavone <pavone@retrodev.com>
parents: 1411
diff changeset
348 info.is_save_lock_on = 0;
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
349 xband *x = calloc(sizeof(xband), 1);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
350 rom_size = nearest_pow2(rom_size);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
351 for (int i = 0; (i + rom_size) <= sizeof(x->cart_space) / 2; i += rom_size)
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
352 {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
353 memcpy(x->cart_space + i/2, rom, rom_size);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
354 }
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
355 if (lock_on && lock_on_size >= 0x200) {
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
356 memcpy(x->cart_space + 0x80, ((uint16_t *)lock_on) + 0x80, 0x100);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
357 }
1229
a8313793216a Minor xband fixes
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
358 //observed power on values
1230
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
359 memset(x->regs, 0, sizeof(x->regs));
1229
a8313793216a Minor xband fixes
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
360 x->regs[0x7C] = 0;
a8313793216a Minor xband fixes
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
361 x->regs[0x7D] = 0x80;
a8313793216a Minor xband fixes
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
362 x->regs[0xB4] = 0x7F;
1230
0ed27bb6a658 Awful hack to get the XBAND menu booting
Michael Pavone <pavone@retrodev.com>
parents: 1229
diff changeset
363 x->regs[UNKNOWN_REG2] = 8;
1229
a8313793216a Minor xband fixes
Michael Pavone <pavone@retrodev.com>
parents: 1228
diff changeset
364
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
365 byteswap_rom(0x400000, x->cart_space);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
366
1444
14a2834d010c Save/restore mapper state in native save states
Michael Pavone <pavone@retrodev.com>
parents: 1416
diff changeset
367 info.mapper_type = MAPPER_XBAND;
1228
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
368 info.map_chunks = base_chunks + 5;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
369 info.map = calloc(sizeof(memmap_chunk), info.map_chunks);
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
370 info.map[0].mask = 0xFFFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
371 info.map[0].aux_mask = 0xFFFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
372 info.map[0].flags = MMAP_READ|MMAP_CODE|MMAP_PTR_IDX|MMAP_FUNC_NULL|MMAP_AUX_BUFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
373 info.map[0].start = 0;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
374 info.map[0].end = 0x10000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
375 info.map[0].ptr_index = 0;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
376 info.map[0].buffer = x->cart_space;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
377 info.map[0].write_16 = xband_write_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
378 info.map[0].write_8 = xband_write_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
379 info.map[0].read_16 = xband_read_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
380 info.map[0].read_8 = xband_read_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
381 info.map[1].mask = 0xFFFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
382 info.map[1].aux_mask = 0xFFFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
383 info.map[1].flags = MMAP_READ|MMAP_CODE|MMAP_PTR_IDX|MMAP_FUNC_NULL|MMAP_AUX_BUFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
384 info.map[1].start = 0x10000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
385 info.map[1].end = 0x200000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
386 info.map[1].ptr_index = 1;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
387 info.map[1].buffer = x->cart_space;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
388 info.map[1].write_16 = xband_write_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
389 info.map[1].write_8 = xband_write_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
390 info.map[1].read_16 = xband_read_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
391 info.map[1].read_8 = xband_read_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
392 info.map[2].mask = 0xFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
393 info.map[2].aux_mask = 0xFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
394 info.map[2].flags = MMAP_READ|MMAP_CODE|MMAP_PTR_IDX|MMAP_FUNC_NULL;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
395 info.map[2].start = 0x200000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
396 info.map[2].end = 0x210000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
397 info.map[2].ptr_index = 2;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
398 info.map[2].buffer = NULL;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
399 info.map[2].write_16 = xband_write_hi_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
400 info.map[2].write_8 = xband_write_hi_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
401 info.map[2].read_16 = xband_read_hi_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
402 info.map[2].read_8 = xband_read_hi_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
403 info.map[3].mask = 0xFFFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
404 info.map[3].aux_mask = 0xFFFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
405 info.map[3].flags = MMAP_READ|MMAP_CODE|MMAP_PTR_IDX|MMAP_FUNC_NULL;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
406 info.map[3].start = 0x210000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
407 info.map[3].end = 0x3BC000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
408 info.map[3].ptr_index = 3;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
409 info.map[3].buffer = NULL;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
410 info.map[3].write_16 = xband_write_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
411 info.map[3].write_8 = xband_write_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
412 info.map[3].read_16 = xband_read_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
413 info.map[3].read_8 = xband_read_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
414 info.map[4].mask = 0xFFFFFF;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
415 info.map[4].flags = MMAP_READ|MMAP_CODE|MMAP_PTR_IDX|MMAP_FUNC_NULL;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
416 info.map[4].start = 0x3BC000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
417 info.map[4].end = 0x3C0000;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
418 info.map[4].ptr_index = 4;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
419 info.map[4].write_16 = xband_reg_write_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
420 info.map[4].write_8 = xband_reg_write_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
421 info.map[4].read_16 = xband_reg_read_w;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
422 info.map[4].read_8 = xband_reg_read_b;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
423 memcpy(info.map + 5, base_map, base_chunks * sizeof(memmap_chunk));
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
424
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
425 return info;
2e6dcb5c11a2 WIP support for XBAND mapper hardware
Michael Pavone <pavone@retrodev.com>
parents:
diff changeset
426 }