Skip to content

Commit

Permalink
Merge branch 'sf/trickyjs'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Fosdick committed Dec 1, 2023
2 parents 75b130f + 3e2e40d commit a31b934
Show file tree
Hide file tree
Showing 12 changed files with 384 additions and 202 deletions.
88 changes: 87 additions & 1 deletion b-em.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,81 @@ music2000_out3_alsa_raw_enabled=false
music2000_out1_alsa_raw_device=default
music2000_out2_alsa_raw_device=default
music2000_out3_alsa_raw_device=default

[joymap default]
stick0axis0adc=1
stick0axis1adc=2
stick1axis0adc=3
stick1axis1adc=4
button0btn=0
button1btn=1
button2btn=2
button3btn=3

[joymap default Player 1]
stick0axis0adc=1
stick0axis1adc=2
button0btn=0
button1btn=2

[joymap default Player 2]
stick0axis0adc=3
stick0axis1adc=4
button0btn=1
button1btn=3
[joymap X Box One Standard]
joystick=Microsoft X-Box One S pad
stick0axis0adc=1
stick0axis1adc=2
stick1axis0adc=3
stick1axis1adc=4
button0btn=0
button1btn=1
button2btn=2
button3btn=3

[joymap XInput Joystick 1]
stick0axis0adc=1
stick0axis1adc=2
stick1axis0adc=3
stick1axis1adc=4
button0btn=0
button1btn=1
button2btn=2
button3btn=3
button8key=Escape

[joymap XInput Joystick 1 ZX/:]
stick0axis0nkey=A
stick0axis0pkey=S
stick0axis1nkey=/
stick0axis1pkey=:
button0key=Return
button1key=Shift
button8key=Escape

[joymap XInput Joystick 1 Missile Command]
stick0axis0adc=1
stick0axis1adc=2
button2btn=3
button3btn=4
button1btn=2
button0btn=0
button8key=Escape
button9key=2

[joymap X Box One Standard Player 1]
stick0axis0adc=1
stick0axis1adc=2
button0btn=0
button1btn=2

[joymap X Box One Standard Player 2]
stick0axis0adc=3
stick0axis1adc=4
button0btn=1
button1btn=3

[joymap X Box One Standard AS]
stick0axis0adc=1
stick0axis0nkey=A
stick0axis0pkey=S
Expand All @@ -462,3 +535,16 @@ stick1axis0adc=0
stick1axis1adc=3
stick2axis0adc=4
stick2axis1adc=0
button0btn=0
button1btn=1
button2btn=2
button3btn=3

[joymap X Box One Standard Player 1 AS]
stick0axis0adc=1
stick0axis0nkey=A
stick0axis0pkey=S
stick0axis1adc=2
button0btn=0
button1btn=2

2 changes: 1 addition & 1 deletion mkcross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ buildit() {
export CXX="$2-g++"
export WINDRES="$2-windres"
cd $dir
make -j2 -e -f ../src/Makefile.win b-em.exe
make -j4 -e -f ../src/Makefile.win b-em.exe
zip -q -r b-em-$VERSION-$1.zip *.exe b-em.cfg *.dll $dirs
}

Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ amrefresh:
# INCLUDE_DEBUGGER - include the cpu_debug implementation
# USE_MEMORY_POINTER - do not assume Co Pro memory starts at address 0

b_em_CFLAGS = $(allegro_CFLAGS) -DBEM -DINCLUDE_DEBUGGER -DUSE_MEMORY_POINTER -DMODET -DMODE32 -DBEEBEM
b_em_CFLAGS = $(allegro_CFLAGS) -DBEM -DINCLUDE_DEBUGGER -DUSE_MEMORY_POINTER -DMODET -DMODE32 -DBEEBEM -DM68K

# workaround for Win32 Allegro, which has `allegro-config' missing
if OS_WIN
Expand Down
2 changes: 1 addition & 1 deletion src/adc.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void adc_write(uint16_t addr, uint8_t val)

void adc_poll()
{
uint32_t val = (uint32_t)(joyaxes[adc_status & 3] * -32760.0) + 32760;
uint32_t val = (uint32_t)(joyaxes[adc_status & 3] * -32760.0 + 32760); // putting the ) after the .0 makes the numbers 32k+ ONLY in VS
if (val > 0xFFFF)
val = 0xFFFF;
adc_status =(adc_status & 0xF) | 0x40; /*Not busy, conversion complete*/
Expand Down
3 changes: 2 additions & 1 deletion src/b-em.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ extern ALLEGRO_PATH *find_cfg_file(const char *name, const char *ext);
extern ALLEGRO_PATH *find_cfg_dest(const char *name, const char *ext);
extern bool is_relative_filename(const char *fn);

extern int joybutton[2];
extern int joybutton[4];
extern float joyaxes[4];
extern bool tricky_sega_adapter;

void setquit(void);

Expand Down
14 changes: 8 additions & 6 deletions src/b-em.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
<ProjectGuid>{28E2DE55-0A88-47FA-92DC-3F96D72608F9}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>bem</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down Expand Up @@ -68,9 +68,10 @@
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>VERSION="vsX";USE_MEMORY_POINTER;BEM;MODET;MODE32;BEEBEM;WIN32;INCLUDE_DEBUGGER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS=1;VERSION="vsX";USE_MEMORY_POINTER;BEM;MODET;MODE32;BEEBEM;WIN32;INCLUDE_DEBUGGER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE;%(UndefinePreprocessorDefinitions)</UndefinePreprocessorDefinitions>
<AdditionalIncludeDirectories>..\packages\Allegro.5.2.6\build\native\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4456;4459;4113;4100;4389;4146;4245;4996;4706;4701;4244;4018;4702;4703;4005;4201;4127;4098;4267;4047;4024;4716;4458</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand All @@ -87,10 +88,11 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>VERSION="vsX";USE_MEMORY_POINTER;BEM;WIN32;MODET;MODE32;BEEBEM;INCLUDE_DEBUGGER;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS=1;VERSION="vsX";USE_MEMORY_POINTER;BEM;WIN32;MODET;MODE32;BEEBEM;INCLUDE_DEBUGGER;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE;%(UndefinePreprocessorDefinitions)</UndefinePreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<AdditionalIncludeDirectories>..\packages\Allegro.5.2.6\build\native\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4456;4459;4113;4100;4389;4146;4245;4996;4706;4701;4244;4018;4702;4703;4005;4201;4127;4098;4267;4047;4024;4716;4458</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
Expand Down Expand Up @@ -364,4 +366,4 @@
<Error Condition="!Exists('..\packages\Allegro.5.2.6\build\native\Allegro.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Allegro.5.2.6\build\native\Allegro.targets'))" />
<Error Condition="!Exists('..\packages\dirent.1.13.1\build\native\dirent.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\dirent.1.13.1\build\native\dirent.targets'))" />
</Target>
</Project>
</Project>
66 changes: 53 additions & 13 deletions src/gui-allegro.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,40 @@ static ALLEGRO_MENU *create_keyboard_menu(void)
return menu;
}

static ALLEGRO_MENU *create_joystick_menu(int joystick)
{
ALLEGRO_MENU *menu = al_create_menu();
int i;

for (i = 0; i < joystick_count; i++) if (joystick_names[i])
add_checkbox_item(menu, joystick_names[i], menu_id_num(IDM_JOYSTICK + joystick, i), i == joystick_index[joystick]);
return menu;
}

static ALLEGRO_MENU *create_joymap_menu(int joystick)
{
ALLEGRO_MENU *menu = al_create_menu();
int i;

for (i = 0; i < joymap_count; i++)
add_checkbox_item(menu, joymaps[i].name, menu_id_num(IDM_JOYMAP + joystick, i), i == joymap_index[joystick]);
return menu;
}

static ALLEGRO_MENU *create_joysticks_menu(void)
{
ALLEGRO_MENU *menu = al_create_menu();
add_checkbox_item(menu, "Tricky SEGA Adapter", IDM_TRIACK_SEGA_ADAPTER, autopause);
al_append_menu_item(menu, "Joystick", 0, 0, NULL, create_joystick_menu(0));
al_append_menu_item(menu, "Joystick Map", 0, 0, NULL, create_joymap_menu(0));
if (joystick_count > 1) {
al_append_menu_item(menu, "Joystick 2", 0, 0, NULL, create_joystick_menu(1));
al_append_menu_item(menu, "Joystick 2 Map", 0, 0, NULL, create_joymap_menu(1));
}
return menu;
}


static const char *jim_sizes[] =
{
"None (disabled)",
Expand All @@ -512,16 +546,6 @@ static ALLEGRO_MENU *create_jim_menu(void)
return menu;
}

static ALLEGRO_MENU *create_joymap_menu(void)
{
ALLEGRO_MENU *menu = al_create_menu();
int i;

for (i = 0; i < joymap_count; i++)
add_checkbox_item(menu, joymaps[i].name, menu_id_num(IDM_JOYMAP, i), i == joymap_num);
return menu;
}

static ALLEGRO_MENU *create_settings_menu(void)
{
ALLEGRO_MENU *menu = al_create_menu();
Expand All @@ -534,8 +558,8 @@ static ALLEGRO_MENU *create_settings_menu(void)
al_append_menu_item(menu, "Jim Memory", 0, 0, NULL, create_jim_menu());
add_checkbox_item(menu, "Auto-Pause", IDM_AUTO_PAUSE, autopause);
add_checkbox_item(menu, "Mouse (AMX)", IDM_MOUSE_AMX, mouse_amx);
if (joymap_count > 0)
al_append_menu_item(menu, "Joystick Map", 0, 0, NULL, create_joymap_menu());
if (joystick_count > 0)
al_append_menu_item(menu, "Joysticks", 0, 0, NULL, create_joysticks_menu());
return menu;
}

Expand Down Expand Up @@ -1505,7 +1529,23 @@ void gui_allegro_event(ALLEGRO_EVENT *event)
case IDM_MOUSE_AMX:
mouse_amx = !mouse_amx;
break;
case IDM_TRIACK_SEGA_ADAPTER:
tricky_sega_adapter = !tricky_sega_adapter;
remap_joystick(0);
remap_joystick(1);
break;
case IDM_JOYSTICK:
change_joystick(0, radio_event_with_deselect(event, joystick_index[0]));
break;
case IDM_JOYSTICK2:
change_joystick(1, radio_event_with_deselect(event, joystick_index[1]));
break;
case IDM_JOYMAP:
joystick_change_joymap(radio_event_simple(event, joymap_num));
joymap_index[0] = radio_event_simple(event, joymap_index[0]);
remap_joystick(0);
case IDM_JOYMAP2:
joymap_index[1] = radio_event_simple(event, joymap_index[1]);
remap_joystick(1);
break;
}
}
4 changes: 4 additions & 0 deletions src/gui-allegro.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ typedef enum {
IDM_JIM_SIZE,
IDM_AUTO_PAUSE,
IDM_MOUSE_AMX,
IDM_TRIACK_SEGA_ADAPTER,
IDM_JOYMAP,
IDM_JOYMAP2,
IDM_JOYSTICK,
IDM_JOYSTICK2,
IDM_SPEED,
IDM_DEBUGGER,
IDM_DEBUG_TUBE,
Expand Down
Loading

0 comments on commit a31b934

Please sign in to comment.