Merge commit 'a9e8b14ea0' into dev-hats

* commit 'a9e8b14ea0':
  Allows Custom-remappable Controllers to be used as in normal 'mouse' mode (replaces mouse map)
  Bumped version to v2.15 beta
  Code modernization and indentation cleanup
This commit is contained in:
HoraceAndTheSpider 2018-03-10 20:19:27 +00:00
commit 6e42a39b20
5 changed files with 458 additions and 280 deletions

View file

@ -196,15 +196,15 @@ void target_fixup_options(struct uae_prefs* p)
{
p->rtgboards[0].rtgmem_type = GFXBOARD_UAE_Z3;
if (z3base_adr == Z3BASE_REAL) {
if (z3_base_adr == Z3BASE_REAL) {
// map Z3 memory at real address (0x40000000)
p->z3_mapping_mode = Z3MAPPING_REAL;
p->z3autoconfig_start = z3base_adr;
p->z3autoconfig_start = z3_base_adr;
}
else {
// map Z3 memory at UAE address (0x10000000)
p->z3_mapping_mode = Z3MAPPING_UAE;
p->z3autoconfig_start = z3base_adr;
p->z3autoconfig_start = z3_base_adr;
}
if (p->cs_cd32cd && p->cs_cd32nvram && (p->cs_compatible == CP_GENERIC || p->cs_compatible == 0)) {

View file

@ -233,7 +233,7 @@ const int RemapKeyMapList[] = {
SDL_SCANCODE_MINUS, SDL_SCANCODE_SLASH, SDL_SCANCODE_SEMICOLON, SDL_SCANCODE_EQUALS, SDL_SCANCODE_LEFTBRACKET,
SDL_SCANCODE_BACKSLASH, SDL_SCANCODE_RIGHTBRACKET,
SDL_SCANCODE_KP_PERIOD, SDL_SCANCODE_KP_EQUALS, SDL_SCANCODE_RCTRL, SDL_SCANCODE_RALT
};
};
#endif
const char* RemapKeyMapListStrings[] = {
@ -255,10 +255,10 @@ const char* RemapKeyMapListStrings[] = {
"keypad5", "keypad6", "keypad7", "keypad8", "keypad9",
"period", "capslock", "numlock", "backspace",
"multiply", "divide", "print_screen", "scroll_lock",
"tilde", "backquote","pause", "quote", "comma",
"minus", "slash", "semicolon","equals", "leftbracket",
"tilde", "backquote", "pause", "quote", "comma",
"minus", "slash", "semicolon", "equals", "leftbracket",
"backslash", "rightbracket",
"kp_period", "kp_equals","rctrl", "ralt"
"kp_period", "kp_equals", "rctrl", "ralt"
};
@ -327,7 +327,7 @@ static int get_mouse_widget_first(const int mouse, const int type)
return FIRST_MOUSE_AXIS;
case IDEV_WIDGET_BUTTONAXIS:
return MAX_MOUSE_AXES + MAX_MOUSE_BUTTONS;
default:
default:
return -1;
}
}
@ -388,7 +388,8 @@ struct inputdevice_functions inputdevicefunc_mouse = {
get_mouse_flags
};
static void setid(struct uae_input_device* uid, const int i, const int slot, const int sub, const int port, int evt, const bool gp)
static void setid(struct uae_input_device* uid, const int i, const int slot, const int sub, const int port, int evt,
const bool gp)
{
if (gp)
inputdevice_sparecopy(&uid[i], slot, 0);
@ -396,7 +397,8 @@ static void setid(struct uae_input_device* uid, const int i, const int slot, con
uid[i].port[slot][sub] = port + 1;
}
static void setid_af(struct uae_input_device* uid, const int i, const int slot, const int sub, const int port, const int evt, const int af, const bool gp)
static void setid_af(struct uae_input_device* uid, const int i, const int slot, const int sub, const int port,
const int evt, const int af, const bool gp)
{
setid(uid, i, slot, sub, port, evt, gp);
uid[i].flags[slot][sub] &= ~ID_FLAG_AUTOFIRE_MASK;
@ -404,14 +406,22 @@ static void setid_af(struct uae_input_device* uid, const int i, const int slot,
uid[i].flags[slot][sub] |= ID_FLAG_AUTOFIRE;
}
int input_get_default_mouse(struct uae_input_device* uid, const int i, const int port, const int af, const bool gp, bool wheel,
int input_get_default_mouse(struct uae_input_device* uid, const int i, const int port, const int af, const bool gp,
bool wheel,
bool joymouseswap)
{
setid(uid, i, ID_AXIS_OFFSET + 0, 0, port, port ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ, gp);
{
if (currprefs.jports[port].id >= JSEM_MICE && currprefs.jports[port].id < JSEM_END)
{
setid(uid, i, ID_AXIS_OFFSET + 0, 0, port, port ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ, gp);
setid(uid, i, ID_AXIS_OFFSET + 1, 0, port, port ? INPUTEVENT_MOUSE2_VERT : INPUTEVENT_MOUSE1_VERT, gp);
setid_af(uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af, gp);
setid_af(uid, i, ID_BUTTON_OFFSET + 0, 0, port, port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON, af,
gp);
setid(uid, i, ID_BUTTON_OFFSET + 1, 0, port, port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON, gp);
}
else
input_get_default_joystick(uid, i, port, af, JSEM_MODE_MOUSE, port, joymouseswap);
if (i == 0)
return 1;
return 0;
@ -900,7 +910,7 @@ static int get_joystick_widget_first(const int joy, const int type)
return FIRST_JOY_AXIS;
case IDEV_WIDGET_BUTTONAXIS:
return MAX_JOY_AXES + MAX_JOY_BUTTONS;
default:
default:
return -1;
}
}
@ -938,7 +948,7 @@ static int get_joystick_widget_type(const int joy, const int num, TCHAR* name, u
case FIRST_JOY_BUTTON + 6:
sprintf(name, "CD32 rwd");
break;
default:
default:
break;
}
}
@ -989,7 +999,7 @@ static void read_joystick(void)
setjoybuttonstate(0, 4, keystate[host_keyboard_buttons[hostkeyid].left_shoulder]); // z
setjoybuttonstate(0, 5, keystate[host_keyboard_buttons[hostkeyid].right_shoulder]); // x
setjoybuttonstate(0, 6, keystate[host_keyboard_buttons[hostkeyid].start_button]); //num1
// up down left right
// up down left right
setjoybuttonstate(0, 7, keystate[host_keyboard_buttons[hostkeyid].dpad_up]);
setjoybuttonstate(0, 8, keystate[host_keyboard_buttons[hostkeyid].dpad_down]);
setjoybuttonstate(0, 9, keystate[host_keyboard_buttons[hostkeyid].dpad_left]);
@ -1001,7 +1011,7 @@ static void read_joystick(void)
setjoybuttonstate(0, 13, keystate[host_keyboard_buttons[hostkeyid].select_button]); // num2
}
// this is what we actually use on the Pi (for joysticks :)
// this is what we actually use on the Pi (for joysticks :)
else if (jsem_isjoy(joyid, &currprefs) != -1)
{
// Now we handle real SDL joystick...
@ -1053,13 +1063,13 @@ static void read_joystick(void)
{
held_offset = REMAP_BUTTONS;
setjoybuttonstate(hostjoyid + 1, 14,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.menu_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.menu_button) & 1));
// menu button
setjoybuttonstate(hostjoyid + 1, 15,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.quit_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.quit_button) & 1));
// quit button
setjoybuttonstate(hostjoyid + 1, 30,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.reset_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.reset_button) & 1));
// reset button
}
@ -1071,34 +1081,48 @@ static void read_joystick(void)
// held_offset = REMAP_BUTTONS * 3;
else
{ held_offset = 0; }
auto val = 0;
// left stick
if (currprefs.input_analog_remap == false)
{
// handle the X axis (left stick)
val = SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_x);
setjoystickstate(hostjoyid + 1, 0, val, 32767);
{
held_offset = 0;
}
// handle the Y axis
val = SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_y);
setjoystickstate(hostjoyid + 1, 1, val, 32767);
}
else
{
// alternative code for custom remapping the left stick
// handle the Y axis (left stick)
setjoybuttonstate(hostjoyid + 1, 7 + held_offset, SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_y) == -32768 ? 1 : 0);
setjoybuttonstate(hostjoyid + 1, 8 + held_offset, SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_y) == 32767 ? 1 : 0);
// handle the X axis
setjoybuttonstate(hostjoyid + 1, 9 + held_offset, SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_x) == -32768 ? 1 : 0);
setjoybuttonstate(hostjoyid + 1, 10 + held_offset, SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_x) == 32767 ? 1 : 0);
}
auto val = 0;
// left stick
if (!currprefs.input_analog_remap)
{
// handle the X axis (left stick)
val = SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_x);
setjoystickstate(hostjoyid + 1, 0, val, 32767);
// handle the Y axis
val = SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_y);
setjoystickstate(hostjoyid + 1, 1, val, 32767);
}
else
{
// alternative code for custom remapping the left stick
// handle the Y axis (left stick)
setjoybuttonstate(hostjoyid + 1, 7 + held_offset,
SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_y) == -32768
? 1
: 0);
setjoybuttonstate(hostjoyid + 1, 8 + held_offset,
SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_y) == 32767
? 1
: 0);
// handle the X axis
setjoybuttonstate(hostjoyid + 1, 9 + held_offset,
SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_x) == -32768
? 1
: 0);
setjoybuttonstate(hostjoyid + 1, 10 + held_offset,
SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.lstick_axis_x) == 32767
? 1
: 0);
}
// right stick
val = SDL_JoystickGetAxis(Joysticktable[hostjoyid], current_controller_map.rstick_axis_x);
@ -1111,27 +1135,27 @@ static void read_joystick(void)
// cd32 red, blue, green, yellow
// south
setjoybuttonstate(hostjoyid + 1, 0 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.south_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.south_button) & 1));
// east
setjoybuttonstate(hostjoyid + 1, 1 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.east_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.east_button) & 1));
// west
setjoybuttonstate(hostjoyid + 1, 2 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.west_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.west_button) & 1));
// north
setjoybuttonstate(hostjoyid + 1, 3 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.north_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.north_button) & 1));
// cd32 rwd, ffw, start
setjoybuttonstate(hostjoyid + 1, 4 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.left_shoulder) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.left_shoulder) & 1));
// left shoulder
setjoybuttonstate(hostjoyid + 1, 5 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.right_shoulder) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.right_shoulder) & 1));
// right shoulder
setjoybuttonstate(hostjoyid + 1, 6 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.start_button) & 1));
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.start_button) & 1));
// start
// up down left right
@ -1139,23 +1163,34 @@ static void read_joystick(void)
const int hat = SDL_JoystickGetHat(Joysticktable[hostjoyid], 0);
setjoybuttonstate(hostjoyid + 1, 7 + held_offset, current_controller_map.dpad_up + 1
? (SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.dpad_up) & 1)
: hat & SDL_HAT_UP);
? (SDL_JoystickGetButton(
Joysticktable[hostjoyid], current_controller_map.dpad_up) & 1)
: hat & SDL_HAT_UP);
setjoybuttonstate(hostjoyid + 1, 8 + held_offset, current_controller_map.dpad_down + 1
? (SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.dpad_down) & 1)
: hat & SDL_HAT_DOWN);
? (SDL_JoystickGetButton(
Joysticktable[hostjoyid], current_controller_map.dpad_down) & 1)
: hat & SDL_HAT_DOWN);
setjoybuttonstate(hostjoyid + 1, 9 + held_offset, current_controller_map.dpad_left + 1
? (SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.dpad_left) & 1)
: hat & SDL_HAT_LEFT);
? (SDL_JoystickGetButton(
Joysticktable[hostjoyid], current_controller_map.dpad_left) & 1)
: hat & SDL_HAT_LEFT);
setjoybuttonstate(hostjoyid + 1, 10 + held_offset, current_controller_map.dpad_right + 1
? (SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.dpad_right) & 1)
: hat & SDL_HAT_RIGHT);
? (SDL_JoystickGetButton(
Joysticktable[hostjoyid],
current_controller_map.dpad_right) & 1)
: hat & SDL_HAT_RIGHT);
// stick left/right/select
setjoybuttonstate(hostjoyid + 1, 11 + held_offset, (SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.lstick_button) & 1)); // left stick
setjoybuttonstate(hostjoyid + 1, 12 + held_offset, (SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.rstick_button) & 1)); // right stick
setjoybuttonstate(hostjoyid + 1, 11 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.lstick_button) & 1));
// left stick
setjoybuttonstate(hostjoyid + 1, 12 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.rstick_button) & 1));
// right stick
setjoybuttonstate(hostjoyid + 1, 13 + held_offset, (SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.select_button) & 1)); // select button
setjoybuttonstate(hostjoyid + 1, 13 + held_offset,
(SDL_JoystickGetButton(Joysticktable[hostjoyid], current_controller_map.select_button) & 1));
// select button
}
}
}
@ -1169,7 +1204,8 @@ struct inputdevice_functions inputdevicefunc_joystick = {
get_joystick_flags
};
int input_get_default_joystick(struct uae_input_device* uid, const int num, int port, const int af, const int mode, const bool gp,
int input_get_default_joystick(struct uae_input_device* uid, const int num, int port, const int af, const int mode,
const bool gp,
bool joymouseswap)
{
// DEAL WITH AXIS INPUT EVENTS
@ -1179,7 +1215,8 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int
{
for (auto n = 0; n < 2; ++n)
{
if (CHECK_BIT(currprefs.jports[port].mousemap, n))
//if (CHECK_BIT(currprefs.jports[port].mousemap, n))
if (mode == JSEM_MODE_MOUSE)
{
h = port ? INPUTEVENT_MOUSE2_HORIZ : INPUTEVENT_MOUSE1_HORIZ;
v = port ? INPUTEVENT_MOUSE2_VERT : INPUTEVENT_MOUSE1_VERT;
@ -1222,76 +1259,112 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int
if (port < 2) // ports 0, 1 ...
{
if (CHECK_BIT(currprefs.jports[port].mousemap,0))
//if (CHECK_BIT(currprefs.jports[port].mousemap,0))
if (mode == JSEM_MODE_MOUSE)
{
thismap[0].dpad_up_action = thismap[0].dpad_up_action
? thismap[0].dpad_up_action
: port ? INPUTEVENT_MOUSE2_UP : INPUTEVENT_MOUSE1_UP;
: port
? INPUTEVENT_MOUSE2_UP
: INPUTEVENT_MOUSE1_UP;
thismap[0].dpad_down_action = thismap[0].dpad_down_action
? thismap[0].dpad_down_action
: port ? INPUTEVENT_MOUSE2_DOWN : INPUTEVENT_MOUSE1_DOWN;
: port
? INPUTEVENT_MOUSE2_DOWN
: INPUTEVENT_MOUSE1_DOWN;
thismap[0].dpad_left_action = thismap[0].dpad_left_action
? thismap[0].dpad_left_action
: port ? INPUTEVENT_MOUSE2_LEFT : INPUTEVENT_MOUSE1_LEFT;
: port
? INPUTEVENT_MOUSE2_LEFT
: INPUTEVENT_MOUSE1_LEFT;
thismap[0].dpad_right_action = thismap[0].dpad_right_action
? thismap[0].dpad_right_action
: port ? INPUTEVENT_MOUSE2_RIGHT : INPUTEVENT_MOUSE1_RIGHT;
: port
? INPUTEVENT_MOUSE2_RIGHT
: INPUTEVENT_MOUSE1_RIGHT;
}
else
{
thismap[0].dpad_up_action = thismap[0].dpad_up_action
? thismap[0].dpad_up_action
: port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP;
: port
? INPUTEVENT_JOY2_UP
: INPUTEVENT_JOY1_UP;
thismap[0].dpad_down_action = thismap[0].dpad_down_action
? thismap[0].dpad_down_action
: port ? INPUTEVENT_JOY2_DOWN : INPUTEVENT_JOY1_DOWN;
: port
? INPUTEVENT_JOY2_DOWN
: INPUTEVENT_JOY1_DOWN;
thismap[0].dpad_left_action = thismap[0].dpad_left_action
? thismap[0].dpad_left_action
: port ? INPUTEVENT_JOY2_LEFT : INPUTEVENT_JOY1_LEFT;
: port
? INPUTEVENT_JOY2_LEFT
: INPUTEVENT_JOY1_LEFT;
thismap[0].dpad_right_action = thismap[0].dpad_right_action
? thismap[0].dpad_right_action
: port ? INPUTEVENT_JOY2_RIGHT : INPUTEVENT_JOY1_RIGHT;
: port
? INPUTEVENT_JOY2_RIGHT
: INPUTEVENT_JOY1_RIGHT;
}
// standard fire buttons
if (mode == JSEM_MODE_JOYSTICK_CD32) // CD32 joypad
{
thismap[0].south_action = thismap[0].south_action
? thismap[0].south_action
: port ? INPUTEVENT_JOY2_CD32_RED : INPUTEVENT_JOY1_CD32_RED;
: port
? INPUTEVENT_JOY2_CD32_RED
: INPUTEVENT_JOY1_CD32_RED;
thismap[0].east_action = thismap[0].east_action
? thismap[0].east_action
: port ? INPUTEVENT_JOY2_CD32_BLUE : INPUTEVENT_JOY1_CD32_BLUE;
: port
? INPUTEVENT_JOY2_CD32_BLUE
: INPUTEVENT_JOY1_CD32_BLUE;
thismap[0].west_action = thismap[0].west_action
? thismap[0].west_action
: port ? INPUTEVENT_JOY2_CD32_GREEN : INPUTEVENT_JOY1_CD32_GREEN;
: port
? INPUTEVENT_JOY2_CD32_GREEN
: INPUTEVENT_JOY1_CD32_GREEN;
thismap[0].north_action = thismap[0].north_action
? thismap[0].north_action
: port ? INPUTEVENT_JOY2_CD32_YELLOW : INPUTEVENT_JOY1_CD32_YELLOW;
: port
? INPUTEVENT_JOY2_CD32_YELLOW
: INPUTEVENT_JOY1_CD32_YELLOW;
thismap[0].start_action = thismap[0].start_action
? thismap[0].start_action
: port ? INPUTEVENT_JOY2_CD32_PLAY : INPUTEVENT_JOY1_CD32_PLAY;
: port
? INPUTEVENT_JOY2_CD32_PLAY
: INPUTEVENT_JOY1_CD32_PLAY;
}
else if(currprefs.jports[port].id >= JSEM_JOYS) // default, normal joystick
else if (currprefs.jports[port].id >= JSEM_JOYS) // default, normal joystick
{
thismap[0].south_action = thismap[0].south_action
? thismap[0].south_action
: port ? INPUTEVENT_JOY2_FIRE_BUTTON : INPUTEVENT_JOY1_FIRE_BUTTON;
: port
? INPUTEVENT_JOY2_FIRE_BUTTON
: INPUTEVENT_JOY1_FIRE_BUTTON;
thismap[0].east_action = thismap[0].east_action
? thismap[0].east_action
: port ? INPUTEVENT_JOY2_2ND_BUTTON : INPUTEVENT_JOY1_2ND_BUTTON;
: port
? INPUTEVENT_JOY2_2ND_BUTTON
: INPUTEVENT_JOY1_2ND_BUTTON;
thismap[0].west_action = thismap[0].west_action
? thismap[0].west_action
: port ? INPUTEVENT_JOY2_UP : INPUTEVENT_JOY1_UP;
: port
? INPUTEVENT_JOY2_UP
: INPUTEVENT_JOY1_UP;
thismap[0].north_action = thismap[0].north_action
? thismap[0].north_action
: port ? INPUTEVENT_JOY2_3RD_BUTTON : INPUTEVENT_JOY1_3RD_BUTTON;
: port
? INPUTEVENT_JOY2_3RD_BUTTON
: INPUTEVENT_JOY1_3RD_BUTTON;
thismap[0].start_action = thismap[0].start_action ? thismap[0].start_action : INPUTEVENT_KEY_P;
}
// shoulder buttons
if (CHECK_BIT(currprefs.jports[port].mousemap,1))
//if (CHECK_BIT(currprefs.jports[port].mousemap,1))
if (mode == JSEM_MODE_MOUSE)
// if we use right-analogue as mouse, then we will use shoulder buttons as LMB/RMB
//if (1==0)
{
@ -1311,14 +1384,18 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int
{
thismap[0].left_shoulder_action = thismap[0].left_shoulder_action
? thismap[0].left_shoulder_action
: port ? INPUTEVENT_JOY2_CD32_RWD : INPUTEVENT_JOY1_CD32_RWD;
: port
? INPUTEVENT_JOY2_CD32_RWD
: INPUTEVENT_JOY1_CD32_RWD;
thismap[0].right_shoulder_action = thismap[0].right_shoulder_action
? thismap[0].right_shoulder_action
: port ? INPUTEVENT_JOY2_CD32_FFW : INPUTEVENT_JOY1_CD32_FFW;
: port
? INPUTEVENT_JOY2_CD32_FFW
: INPUTEVENT_JOY1_CD32_FFW;
}
else if(currprefs.jports[port].id >= JSEM_JOYS) // default, normal joystick
else if (currprefs.jports[port].id >= JSEM_JOYS) // default, normal joystick
{
thismap[0].left_shoulder_action = thismap[0].left_shoulder_action
? thismap[0].left_shoulder_action
@ -1332,23 +1409,35 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int
{
thismap[0].dpad_up_action = thismap[0].dpad_up_action
? thismap[0].dpad_up_action
: port - 2 ? INPUTEVENT_PAR_JOY2_UP : INPUTEVENT_PAR_JOY1_UP;
: port - 2
? INPUTEVENT_PAR_JOY2_UP
: INPUTEVENT_PAR_JOY1_UP;
thismap[0].dpad_down_action = thismap[0].dpad_down_action
? thismap[0].dpad_down_action
: port - 2 ? INPUTEVENT_PAR_JOY2_DOWN : INPUTEVENT_PAR_JOY1_DOWN;
: port - 2
? INPUTEVENT_PAR_JOY2_DOWN
: INPUTEVENT_PAR_JOY1_DOWN;
thismap[0].dpad_left_action = thismap[0].dpad_left_action
? thismap[0].dpad_left_action
: port - 2 ? INPUTEVENT_PAR_JOY2_LEFT : INPUTEVENT_PAR_JOY1_LEFT;
: port - 2
? INPUTEVENT_PAR_JOY2_LEFT
: INPUTEVENT_PAR_JOY1_LEFT;
thismap[0].dpad_right_action = thismap[0].dpad_right_action
? thismap[0].dpad_right_action
: port - 2 ? INPUTEVENT_PAR_JOY2_RIGHT : INPUTEVENT_PAR_JOY1_RIGHT;
: port - 2
? INPUTEVENT_PAR_JOY2_RIGHT
: INPUTEVENT_PAR_JOY1_RIGHT;
thismap[0].south_action = thismap[0].south_action
? thismap[0].south_action
: port - 2 ? INPUTEVENT_PAR_JOY2_FIRE_BUTTON : INPUTEVENT_PAR_JOY1_FIRE_BUTTON;
: port - 2
? INPUTEVENT_PAR_JOY2_FIRE_BUTTON
: INPUTEVENT_PAR_JOY1_FIRE_BUTTON;
thismap[0].east_action = thismap[0].east_action
? thismap[0].east_action
: port - 2 ? INPUTEVENT_PAR_JOY2_2ND_BUTTON : INPUTEVENT_PAR_JOY1_2ND_BUTTON;
: port - 2
? INPUTEVENT_PAR_JOY2_2ND_BUTTON
: INPUTEVENT_PAR_JOY1_2ND_BUTTON;
thismap[0].start_action = thismap[0].start_action ? thismap[0].start_action : INPUTEVENT_KEY_P;
thismap[0].left_shoulder_action = thismap[0].left_shoulder_action
@ -1422,4 +1511,4 @@ int input_get_default_joystick(struct uae_input_device* uid, const int num, int
int input_get_default_joystick_analog(struct uae_input_device* uid, int num, int port, int af, bool joymouseswap)
{
return 0;
}
}

View file

@ -21,42 +21,42 @@ uae_u32 max_z3fastmem;
/* JIT can access few bytes outside of memory block of it executes code at the very end of memory block */
#define BARRIER 32
static uae_u8* additional_mem = (uae_u8*) MAP_FAILED;
#define ADDITIONAL_MEMSIZE (128 + 16) * 1024 * 1024
static uae_u8* additional_mem = (uae_u8*)MAP_FAILED;
#define ADDITIONAL_MEMSIZE ((128 + 16) * 1024 * 1024)
static uae_u8* a3000_mem = (uae_u8*) MAP_FAILED;
static uae_u8* a3000_mem = (uae_u8*)MAP_FAILED;
static int a3000_totalsize = 0;
#define A3000MEM_START 0x08000000
static int lastLowSize = 0;
static int lastHighSize = 0;
static unsigned int last_low_size = 0;
static unsigned int last_high_size = 0;
int z3base_adr = 0;
int z3_base_adr = 0;
void free_AmigaMem(void)
{
if(regs.natmem_offset != 0)
{
if (regs.natmem_offset != nullptr)
{
#ifdef AMIBERRY
munmap(regs.natmem_offset, natmem_size + BARRIER);
munmap(regs.natmem_offset, natmem_size + BARRIER);
#else
free(regs.natmem_offset);
#endif
regs.natmem_offset = 0;
}
if(additional_mem != MAP_FAILED)
{
munmap(additional_mem, ADDITIONAL_MEMSIZE + BARRIER);
additional_mem = (uae_u8*) MAP_FAILED;
}
if(a3000_mem != MAP_FAILED)
{
munmap(a3000_mem, a3000_totalsize);
a3000_mem = (uae_u8*) MAP_FAILED;
a3000_totalsize = 0;
}
regs.natmem_offset = nullptr;
}
if (additional_mem != MAP_FAILED)
{
munmap(additional_mem, ADDITIONAL_MEMSIZE + BARRIER);
additional_mem = (uae_u8*)MAP_FAILED;
}
if (a3000_mem != MAP_FAILED)
{
munmap(a3000_mem, a3000_totalsize);
a3000_mem = (uae_u8*)MAP_FAILED;
a3000_totalsize = 0;
}
}
@ -74,38 +74,41 @@ void alloc_AmigaMem(void)
natmem_size = 16 * 1024 * 1024;
#ifdef AMIBERRY
// address returned by valloc() too high for later mmap() calls. Use mmap() also for first area.
regs.natmem_offset = (uae_u8*)mmap((void *)0x20000000, natmem_size + BARRIER,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
regs.natmem_offset = (uae_u8*)mmap(reinterpret_cast<void *>(0x20000000), natmem_size + BARRIER,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
#else
regs.natmem_offset = (uae_u8*)valloc(natmem_size + BARRIER);
#endif
max_z3fastmem = ADDITIONAL_MEMSIZE - (16 * 1024 * 1024);
if (!regs.natmem_offset) {
if (!regs.natmem_offset)
{
write_log("Can't allocate 16M of virtual address space!?\n");
abort();
}
additional_mem = (uae_u8*)mmap(regs.natmem_offset + Z3BASE_REAL, ADDITIONAL_MEMSIZE + BARRIER,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (additional_mem != MAP_FAILED)
{
// Allocation successful -> we can use natmem_offset for entire memory access at real address
changed_prefs.z3autoconfig_start = currprefs.z3autoconfig_start = Z3BASE_REAL;
z3base_adr = Z3BASE_REAL;
z3_base_adr = Z3BASE_REAL;
write_log("Allocated 16 MB for 24-bit area (0x%08x) and %d MB for Z3 and RTG at real address (0x%08x - 0x%08x)\n",
regs.natmem_offset, ADDITIONAL_MEMSIZE / (1024 * 1024), additional_mem, additional_mem + ADDITIONAL_MEMSIZE + BARRIER);
regs.natmem_offset, ADDITIONAL_MEMSIZE / (1024 * 1024), additional_mem, additional_mem + ADDITIONAL_MEMSIZE + BARRIER
);
set_expamem_z3_hack_mode(Z3MAPPING_REAL);
return;
}
additional_mem = (uae_u8*)mmap(regs.natmem_offset + Z3BASE_UAE, ADDITIONAL_MEMSIZE + BARRIER,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (additional_mem != MAP_FAILED)
{
// Allocation successful -> we can use natmem_offset for entire memory access at fake address
changed_prefs.z3autoconfig_start = currprefs.z3autoconfig_start = Z3BASE_UAE;
z3base_adr = Z3BASE_UAE;
z3_base_adr = Z3BASE_UAE;
write_log("Allocated 16 MB for 24-bit area (0x%08x) and %d MB for Z3 and RTG at fake address (0x%08x - 0x%08x)\n",
regs.natmem_offset, ADDITIONAL_MEMSIZE / (1024 * 1024), additional_mem, additional_mem + ADDITIONAL_MEMSIZE + BARRIER);
regs.natmem_offset, ADDITIONAL_MEMSIZE / (1024 * 1024), additional_mem, additional_mem + ADDITIONAL_MEMSIZE + BARRIER
);
set_expamem_z3_hack_mode(Z3MAPPING_UAE);
return;
}
@ -122,7 +125,7 @@ void alloc_AmigaMem(void)
{
// Allocation successful
changed_prefs.z3autoconfig_start = currprefs.z3autoconfig_start = Z3BASE_UAE;
z3base_adr = Z3BASE_UAE;
z3_base_adr = Z3BASE_UAE;
write_log("Allocated %d MB for entire memory\n", natmem_size / (1024 * 1024));
return;
}
@ -131,13 +134,14 @@ void alloc_AmigaMem(void)
natmem_size = 16 * 1024 * 1024;
regs.natmem_offset = (uae_u8*)valloc(natmem_size + BARRIER);
if (!regs.natmem_offset) {
if (!regs.natmem_offset)
{
write_log("Can't allocate 16M of virtual address space!?\n");
abort();
}
changed_prefs.z3autoconfig_start = currprefs.z3autoconfig_start = 0x00000000; // No mem for Z3
z3base_adr = 0x00000000;
z3_base_adr = 0x00000000;
max_z3fastmem = 0;
write_log("Reserved: %p-%p (0x%08x %dM)\n", regs.natmem_offset, (uae_u8*)regs.natmem_offset + natmem_size,
@ -145,55 +149,55 @@ void alloc_AmigaMem(void)
}
static bool HandleA3000Mem(int lowsize, int highsize)
static bool HandleA3000Mem(unsigned int lowsize, unsigned int highsize)
{
bool result = true;
if(lowsize == lastLowSize && highsize == lastHighSize)
return result;
if(a3000_mem != MAP_FAILED)
{
write_log("HandleA3000Mem(): Free A3000 memory (0x%08x). %d MB.\n", a3000_mem, a3000_totalsize / (1024 * 1024));
munmap(a3000_mem, a3000_totalsize);
a3000_mem = (uae_u8*) MAP_FAILED;
a3000_totalsize = 0;
lastLowSize = 0;
lastHighSize = 0;
}
if(lowsize + highsize > 0)
{
// Try to get memory for A3000 motherboard
write_log("Try to get A3000 memory at correct place (0x%08x). %d MB and %d MB.\n", A3000MEM_START,
lowsize / (1024 * 1024), highsize / (1024 * 1024));
a3000_totalsize = lowsize + highsize;
a3000_mem = (uae_u8*) mmap(regs.natmem_offset + (A3000MEM_START - lowsize), a3000_totalsize,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if(a3000_mem != MAP_FAILED)
{
lastLowSize = lowsize;
lastHighSize = highsize;
write_log(_T("Succeeded: location at 0x%08x (Amiga: 0x%08x)\n"), a3000_mem, (A3000MEM_START - lowsize));
}
else
{
write_log("Failed.\n");
a3000_totalsize = 0;
result = false;
}
}
bool result = true;
return result;
if (lowsize == last_low_size && highsize == last_high_size)
return result;
if (a3000_mem != MAP_FAILED)
{
write_log("HandleA3000Mem(): Free A3000 memory (0x%08x). %d MB.\n", a3000_mem, a3000_totalsize / (1024 * 1024));
munmap(a3000_mem, a3000_totalsize);
a3000_mem = (uae_u8*)MAP_FAILED;
a3000_totalsize = 0;
last_low_size = 0;
last_high_size = 0;
}
if (lowsize + highsize > 0)
{
// Try to get memory for A3000 motherboard
write_log("Try to get A3000 memory at correct place (0x%08x). %d MB and %d MB.\n", A3000MEM_START,
lowsize / (1024 * 1024), highsize / (1024 * 1024));
a3000_totalsize = lowsize + highsize;
a3000_mem = (uae_u8*)mmap(regs.natmem_offset + (A3000MEM_START - lowsize), a3000_totalsize,
PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (a3000_mem != MAP_FAILED)
{
last_low_size = lowsize;
last_high_size = highsize;
write_log(_T("Succeeded: location at 0x%08x (Amiga: 0x%08x)\n"), a3000_mem, (A3000MEM_START - lowsize));
}
else
{
write_log("Failed.\n");
a3000_totalsize = 0;
result = false;
}
}
return result;
}
static bool A3000MemAvailable(void)
{
return (a3000_mem != MAP_FAILED);
return (a3000_mem != MAP_FAILED);
}
bool uae_mman_info(addrbank *ab, struct uae_mman_data *md)
bool uae_mman_info(addrbank* ab, struct uae_mman_data* md)
{
bool got = false;
bool readonly = false;
@ -202,156 +206,230 @@ bool uae_mman_info(addrbank *ab, struct uae_mman_data *md)
uae_u32 readonlysize = size;
bool barrier = false;
if (!_tcscmp(ab->label, _T("*"))) {
if (!_tcscmp(ab->label, _T("*")))
{
start = ab->start;
got = true;
if (expansion_get_autoconfig_by_address(&currprefs, ab->start) && !expansion_get_autoconfig_by_address(&currprefs, ab->start + size))
if (expansion_get_autoconfig_by_address(&currprefs, ab->start) && !expansion_get_autoconfig_by_address(
&currprefs, ab->start + size))
barrier = true;
} else if (!_tcscmp(ab->label, _T("*B"))) {
}
else if (!_tcscmp(ab->label, _T("*B")))
{
start = ab->start;
got = true;
barrier = true;
} else if (!_tcscmp(ab->label, _T("chip"))) {
}
else if (!_tcscmp(ab->label, _T("chip")))
{
start = 0;
got = true;
if (!expansion_get_autoconfig_by_address(&currprefs, 0x00200000) && currprefs.chipmem_size == 2 * 1024 * 1024)
barrier = true;
if (currprefs.chipmem_size > 2 * 1024 * 1024)
barrier = true;
} else if (!_tcscmp(ab->label, _T("kick"))) {
}
else if (!_tcscmp(ab->label, _T("kick")))
{
start = 0xf80000;
got = true;
barrier = true;
readonly = true;
} else if (!_tcscmp(ab->label, _T("rom_a8"))) {
}
else if (!_tcscmp(ab->label, _T("rom_a8")))
{
start = 0xa80000;
got = true;
readonly = true;
} else if (!_tcscmp(ab->label, _T("rom_e0"))) {
}
else if (!_tcscmp(ab->label, _T("rom_e0")))
{
start = 0xe00000;
got = true;
readonly = true;
} else if (!_tcscmp(ab->label, _T("rom_f0"))) {
}
else if (!_tcscmp(ab->label, _T("rom_f0")))
{
start = 0xf00000;
got = true;
readonly = true;
} else if (!_tcscmp(ab->label, _T("rom_f0_ppc"))) {
}
else if (!_tcscmp(ab->label, _T("rom_f0_ppc")))
{
// this is flash and also contains IO
start = 0xf00000;
got = true;
readonly = false;
} else if (!_tcscmp(ab->label, _T("rtarea"))) {
}
else if (!_tcscmp(ab->label, _T("rtarea")))
{
start = rtarea_base;
got = true;
readonly = true;
readonlysize = RTAREA_TRAPS;
} else if (!_tcscmp(ab->label, _T("ramsey_low"))) {
if(ab->reserved_size != lastLowSize)
HandleA3000Mem(ab->reserved_size, lastHighSize);
if(A3000MemAvailable()) {
start = a3000lmem_bank.start;
got = true;
}
} else if (!_tcscmp(ab->label, _T("csmk1_maprom"))) {
}
else if (!_tcscmp(ab->label, _T("ramsey_low")))
{
if (ab->reserved_size != last_low_size)
HandleA3000Mem(ab->reserved_size, last_high_size);
if (A3000MemAvailable())
{
start = a3000lmem_bank.start;
got = true;
}
}
else if (!_tcscmp(ab->label, _T("csmk1_maprom")))
{
start = 0x07f80000;
got = true;
} else if (!_tcscmp(ab->label, _T("25bitram"))) {
}
else if (!_tcscmp(ab->label, _T("25bitram")))
{
start = 0x01000000;
got = true;
} else if (!_tcscmp(ab->label, _T("ramsey_high"))) {
if(ab->reserved_size != lastHighSize)
HandleA3000Mem(lastLowSize, ab->reserved_size);
if(A3000MemAvailable()) {
start = 0x08000000;
got = true;
}
} else if (!_tcscmp(ab->label, _T("dkb"))) {
}
else if (!_tcscmp(ab->label, _T("ramsey_high")))
{
if (ab->reserved_size != last_high_size)
HandleA3000Mem(last_low_size, ab->reserved_size);
if (A3000MemAvailable())
{
start = 0x08000000;
got = true;
}
}
else if (!_tcscmp(ab->label, _T("dkb")))
{
start = 0x10000000;
got = true;
} else if (!_tcscmp(ab->label, _T("fusionforty"))) {
}
else if (!_tcscmp(ab->label, _T("fusionforty")))
{
start = 0x11000000;
got = true;
} else if (!_tcscmp(ab->label, _T("blizzard_40"))) {
}
else if (!_tcscmp(ab->label, _T("blizzard_40")))
{
start = 0x40000000;
got = true;
} else if (!_tcscmp(ab->label, _T("blizzard_48"))) {
}
else if (!_tcscmp(ab->label, _T("blizzard_48")))
{
start = 0x48000000;
got = true;
} else if (!_tcscmp(ab->label, _T("blizzard_68"))) {
}
else if (!_tcscmp(ab->label, _T("blizzard_68")))
{
start = 0x68000000;
got = true;
} else if (!_tcscmp(ab->label, _T("blizzard_70"))) {
}
else if (!_tcscmp(ab->label, _T("blizzard_70")))
{
start = 0x70000000;
got = true;
} else if (!_tcscmp(ab->label, _T("cyberstorm"))) {
}
else if (!_tcscmp(ab->label, _T("cyberstorm")))
{
start = 0x0c000000;
got = true;
} else if (!_tcscmp(ab->label, _T("cyberstormmaprom"))) {
}
else if (!_tcscmp(ab->label, _T("cyberstormmaprom")))
{
start = 0xfff00000;
got = true;
} else if (!_tcscmp(ab->label, _T("bogo"))) {
}
else if (!_tcscmp(ab->label, _T("bogo")))
{
start = 0x00C00000;
got = true;
if (currprefs.bogomem_size <= 0x100000)
barrier = true;
} else if (!_tcscmp(ab->label, _T("custmem1"))) {
}
else if (!_tcscmp(ab->label, _T("custmem1")))
{
start = currprefs.custom_memory_addrs[0];
got = true;
} else if (!_tcscmp(ab->label, _T("custmem2"))) {
}
else if (!_tcscmp(ab->label, _T("custmem2")))
{
start = currprefs.custom_memory_addrs[1];
got = true;
} else if (!_tcscmp(ab->label, _T("hrtmem"))) {
}
else if (!_tcscmp(ab->label, _T("hrtmem")))
{
start = 0x00a10000;
got = true;
} else if (!_tcscmp(ab->label, _T("arhrtmon"))) {
}
else if (!_tcscmp(ab->label, _T("arhrtmon")))
{
start = 0x00800000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("xpower_e2"))) {
}
else if (!_tcscmp(ab->label, _T("xpower_e2")))
{
start = 0x00e20000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("xpower_f2"))) {
}
else if (!_tcscmp(ab->label, _T("xpower_f2")))
{
start = 0x00f20000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("nordic_f0"))) {
}
else if (!_tcscmp(ab->label, _T("nordic_f0")))
{
start = 0x00f00000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("nordic_f4"))) {
}
else if (!_tcscmp(ab->label, _T("nordic_f4")))
{
start = 0x00f40000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("nordic_f6"))) {
}
else if (!_tcscmp(ab->label, _T("nordic_f6")))
{
start = 0x00f60000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("superiv_b0"))) {
}
else if (!_tcscmp(ab->label, _T("superiv_b0")))
{
start = 0x00b00000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("superiv_d0"))) {
}
else if (!_tcscmp(ab->label, _T("superiv_d0")))
{
start = 0x00d00000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("superiv_e0"))) {
}
else if (!_tcscmp(ab->label, _T("superiv_e0")))
{
start = 0x00e00000;
barrier = true;
got = true;
} else if (!_tcscmp(ab->label, _T("ram_a8"))) {
}
else if (!_tcscmp(ab->label, _T("ram_a8")))
{
start = 0x00a80000;
barrier = true;
got = true;
}
if (got) {
if (got)
{
md->start = start;
md->size = size;
md->readonly = readonly;
md->readonlysize = readonlysize;
md->hasbarrier = barrier;
if (md->hasbarrier) {
if (md->hasbarrier)
{
md->size += BARRIER;
}
}
@ -359,83 +437,90 @@ bool uae_mman_info(addrbank *ab, struct uae_mman_data *md)
}
bool mapped_malloc (addrbank *ab)
bool mapped_malloc(addrbank* ab)
{
if (ab->allocated_size) {
if (ab->allocated_size)
{
write_log(_T("mapped_malloc with memory bank '%s' already allocated!?\n"), ab->name);
}
ab->allocated_size = 0;
if (ab->label && ab->label[0] == '*') {
if (ab->start == 0 || ab->start == 0xffffffff) {
if (ab->label && ab->label[0] == '*')
{
if (ab->start == 0 || ab->start == 0xffffffff)
{
write_log(_T("mapped_malloc(*) without start address!\n"));
return false;
}
}
struct uae_mman_data md = { 0 };
struct uae_mman_data md = {0};
uaecptr start = ab->start;
if (uae_mman_info(ab, &md)) {
if (uae_mman_info(ab, &md))
{
start = md.start;
ab->baseaddr = regs.natmem_offset + start;
ab->baseaddr = regs.natmem_offset + start;
}
if (ab->baseaddr) {
if (md.hasbarrier) {
if (ab->baseaddr)
{
if (md.hasbarrier)
{
// fill end of ram with ILLEGAL to catch direct PC falling out of RAM.
put_long_host(ab->baseaddr + ab->reserved_size, 0x4afc4afc);
}
ab->allocated_size = ab->reserved_size;
write_log("mapped_malloc(): 0x%08x - 0x%08x (0x%08x - 0x%08x) -> %s (%s)\n",
ab->baseaddr - regs.natmem_offset, ab->baseaddr - regs.natmem_offset + ab->allocated_size,
ab->baseaddr, ab->baseaddr + ab->allocated_size, ab->name, ab->label);
write_log("mapped_malloc(): 0x%08x - 0x%08x (0x%08x - 0x%08x) -> %s (%s)\n",
ab->baseaddr - regs.natmem_offset, ab->baseaddr - regs.natmem_offset + ab->allocated_size,
ab->baseaddr, ab->baseaddr + ab->allocated_size, ab->name, ab->label);
}
ab->flags |= ABFLAG_DIRECTMAP;
return (ab->baseaddr != NULL);
ab->flags |= ABFLAG_DIRECTMAP;
return (ab->baseaddr != nullptr);
}
void mapped_free (addrbank *ab)
void mapped_free(addrbank* ab)
{
if(ab->label != NULL && !strcmp(ab->label, "filesys") && ab->baseaddr != NULL) {
free(ab->baseaddr);
write_log("mapped_free(): 0x%08x - 0x%08x (0x%08x - 0x%08x) -> %s (%s)\n",
ab->baseaddr - regs.natmem_offset, ab->baseaddr - regs.natmem_offset + ab->allocated_size,
ab->baseaddr, ab->baseaddr + ab->allocated_size, ab->name, ab->label);
if (ab->label != nullptr && !strcmp(ab->label, "filesys") && ab->baseaddr != nullptr)
{
free(ab->baseaddr);
write_log("mapped_free(): 0x%08x - 0x%08x (0x%08x - 0x%08x) -> %s (%s)\n",
ab->baseaddr - regs.natmem_offset, ab->baseaddr - regs.natmem_offset + ab->allocated_size,
ab->baseaddr, ab->baseaddr + ab->allocated_size, ab->name, ab->label);
}
ab->baseaddr = nullptr;
ab->allocated_size = 0;
}
void protect_roms(bool protect)
{
/*
If this code is enabled, we can't switch back from JIT to nonJIT emulation...
if (protect) {
// protect only if JIT enabled, always allow unprotect
if (!currprefs.cachesize)
return;
}
ab->baseaddr = NULL;
ab->allocated_size = 0;
}
void protect_roms (bool protect)
{
/*
If this code is enabled, we can't switch back from JIT to nonJIT emulation...
if (protect) {
// protect only if JIT enabled, always allow unprotect
if (!currprefs.cachesize)
return;
}
// Protect all regions, which contains ROM
if(extendedkickmem_bank.baseaddr != NULL)
mprotect(extendedkickmem_bank.baseaddr, 0x80000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(extendedkickmem2_bank.baseaddr != NULL)
mprotect(extendedkickmem2_bank.baseaddr, 0x80000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(kickmem_bank.baseaddr != NULL)
mprotect(kickmem_bank.baseaddr, 0x80000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(rtarea != NULL)
mprotect(rtarea, RTAREA_SIZE, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(filesysory != NULL)
mprotect(filesysory, 0x10000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
// Protect all regions, which contains ROM
if(extendedkickmem_bank.baseaddr != NULL)
mprotect(extendedkickmem_bank.baseaddr, 0x80000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(extendedkickmem2_bank.baseaddr != NULL)
mprotect(extendedkickmem2_bank.baseaddr, 0x80000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(kickmem_bank.baseaddr != NULL)
mprotect(kickmem_bank.baseaddr, 0x80000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(rtarea != NULL)
mprotect(rtarea, RTAREA_SIZE, protect ? PROT_READ : PROT_READ | PROT_WRITE);
if(filesysory != NULL)
mprotect(filesysory, 0x10000, protect ? PROT_READ : PROT_READ | PROT_WRITE);
*/
}
static int doinit_shm (void)
static int doinit_shm(void)
{
expansion_scan_autoconfig(&currprefs, true);
@ -448,17 +533,19 @@ static uae_u32 ofastmem_size[MAX_RAM_BOARDS];
static uae_u32 ortgmem_size[MAX_RTG_BOARDS];
static int ortgmem_type[MAX_RTG_BOARDS];
bool init_shm (void)
bool init_shm(void)
{
bool changed = false;
auto changed = false;
for (int i = 0; i < MAX_RAM_BOARDS; i++) {
for (auto i = 0; i < MAX_RAM_BOARDS; i++)
{
if (oz3fastmem_size[i] != changed_prefs.z3fastmem[i].size)
changed = true;
if (ofastmem_size[i] != changed_prefs.fastmem[i].size)
changed = true;
}
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
for (auto i = 0; i < MAX_RTG_BOARDS; i++)
{
if (ortgmem_size[i] != changed_prefs.rtgboards[i].rtgmem_size)
changed = true;
if (ortgmem_type[i] != changed_prefs.rtgboards[i].rtgmem_type)
@ -467,18 +554,20 @@ bool init_shm (void)
if (!changed)
return true;
for (int i = 0; i < MAX_RAM_BOARDS;i++) {
for (auto i = 0; i < MAX_RAM_BOARDS; i++)
{
oz3fastmem_size[i] = changed_prefs.z3fastmem[i].size;
ofastmem_size[i] = changed_prefs.fastmem[i].size;
}
for (int i = 0; i < MAX_RTG_BOARDS; i++) {
for (auto i = 0; i < MAX_RTG_BOARDS; i++)
{
ortgmem_size[i] = changed_prefs.rtgboards[i].rtgmem_size;
ortgmem_type[i] = changed_prefs.rtgboards[i].rtgmem_type;
}
if (doinit_shm () < 0)
if (doinit_shm() < 0)
return false;
memory_hardreset (2);
memory_hardreset(2);
return true;
}

View file

@ -29,7 +29,7 @@ void InitPanelAbout(const struct _ConfigCategory& category)
{
amiberryLogoImage = gcn::Image::load("data/amiberry-logo.png");
icon = new gcn::Icon(amiberryLogoImage);
lblEmulatorVersion = new gcn::Label("Amiberry v2.14 beta");
lblEmulatorVersion = new gcn::Label("Amiberry v2.15 beta");
textBox = new gcn::TextBox(
"Dimitris Panokostas (MiDWaN) - Amiberry author\n"

View file

@ -25,7 +25,7 @@ extern int generic_main (int argc, char *argv[]);
extern int emulating;
extern int z3base_adr;
extern int z3_base_adr;
extern unsigned long time_per_frame;