Replace SDL 1.2 with SDL 2.0
This massive patch is based on work of NY00123, which was published on Vogons forum in 2013 and was waiting for inclusion in SVN since then: https://www.vogons.org/viewtopic.php?f=41&t=34770 Revision from December 2018 was used to kickstart this work. However, a number of changes were implemented: - Original patch preserves all SDL 1.2 code by ifdefing it; this patch completely removes all code ifdefed for several versions of SDL 1.2.* This way the code will be easier to maintain going forward and features enabled by SDL 2.0 do not need to be backported. A side-effect of this change is almost-complete removal of DirectDraw support - but users can now use Direct3D based acceleration (without any ifdefs in code). - Code ifdefed for Android was removed to make the project easier to understand and modify. Android port should still be possible, but it requires more work (mostly CI and buildsystem work). Android-related functionalities that were cross-platform were preserved. - Code ifdefed for OpenGL ES (which was only used for Android) was removed - this should not affect Android support, as hardware-accelerated 2D should still be viable via "texture" output, but it was not tested, as buildsystem does not support Android ATM. - SDL_cdrom code is not included; it was outside of scope of SDL2 changes. Inclusion of that library did not justify supporting one small usecase (playblack of CD audio from physical CDs). - Few code warning were fixed (but new sdl_mapper implementation introduces many, many new warnings). - Some formatting changes were implemented. Overall, the original patch had ~40k lines of code - here it was trimmed to +769,-972 (so more old code got removed than new code added). This implementation was extensively tested on Linux and somewhat tested on Windows 10. It fixes numerous issues (too many too list). Testing found two small regressions: - Starting game in fullscreen makes it impossible to switch back to windowed mode correctly (Windows 10) - Scaling works a bit worse, only in text mode, only in window (Linux) This implementation introduces revised user settings in sdl section - it is only partly compatible with settings from SDL 1.2; this is an issue, but it will need to be addressed in a separete commit.
This commit is contained in:
parent
3eaabb41c1
commit
a06035a35e
4 changed files with 768 additions and 972 deletions
|
@ -27,15 +27,6 @@
|
|||
#include "dos_inc.h"
|
||||
#include "SDL.h"
|
||||
|
||||
/* SDL by default treats numlock and scrolllock different from all other keys.
|
||||
* In recent versions this can disabled by a environment variable which we set in sdlmain.cpp
|
||||
* Define the following if this is the case */
|
||||
#if SDL_VERSION_ATLEAST(1, 2, 14)
|
||||
#define CAN_USE_LOCK 1
|
||||
/* For lower versions of SDL we also use a slight hack to get the startup states of numclock and capslock right.
|
||||
* The proper way is in the mapper, but the repeating key is an unwanted side effect for lower versions of SDL */
|
||||
#endif
|
||||
|
||||
static Bitu call_int16,call_irq1,call_irq6;
|
||||
|
||||
/* Nice table from BOCHS i should feel bad for ripping this */
|
||||
|
@ -241,11 +232,6 @@ static Bitu IRQ1_Handler(void) {
|
|||
flags2=mem_readb(BIOS_KEYBOARD_FLAGS2);
|
||||
flags3=mem_readb(BIOS_KEYBOARD_FLAGS3);
|
||||
leds =mem_readb(BIOS_KEYBOARD_LEDS);
|
||||
#ifdef CAN_USE_LOCK
|
||||
/* No hack anymore! */
|
||||
#else
|
||||
flags2&=~(0x40+0x20);//remove numlock/capslock pressed (hack for sdl only reporting states)
|
||||
#endif
|
||||
if (DOS_LayoutKey(scancode,flags1,flags2,flags3)) return CBRET_NONE;
|
||||
//LOG_MSG("key input %d %d %d %d",scancode,flags1,flags2,flags3);
|
||||
switch (scancode) {
|
||||
|
@ -308,14 +294,8 @@ static Bitu IRQ1_Handler(void) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef CAN_USE_LOCK
|
||||
case 0x3a:flags2 |=0x40;break;//CAPSLOCK
|
||||
case 0xba:flags1 ^=0x40;flags2 &=~0x40;leds ^=0x04;break;
|
||||
#else
|
||||
case 0x3a:flags2 |=0x40;flags1 |=0x40;leds |=0x04;break; //SDL gives only the state instead of the toggle /* Caps Lock */
|
||||
case 0xba:flags1 &=~0x40;leds &=~0x04;break;
|
||||
#endif
|
||||
case 0x45:
|
||||
if (flags3 &0x01) {
|
||||
/* last scancode of pause received; first remove 0xe1-prefix */
|
||||
|
@ -336,13 +316,7 @@ static Bitu IRQ1_Handler(void) {
|
|||
}
|
||||
} else {
|
||||
/* Num Lock */
|
||||
#ifdef CAN_USE_LOCK
|
||||
flags2 |=0x20;
|
||||
#else
|
||||
flags2 |=0x20;
|
||||
flags1 |=0x20;
|
||||
leds |=0x02;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case 0xc5:
|
||||
|
@ -350,15 +324,9 @@ static Bitu IRQ1_Handler(void) {
|
|||
/* pause released */
|
||||
flags3 &=~0x01;
|
||||
} else {
|
||||
#ifdef CAN_USE_LOCK
|
||||
flags1^=0x20;
|
||||
leds^=0x02;
|
||||
flags2&=~0x20;
|
||||
#else
|
||||
/* Num Lock released */
|
||||
flags1 &=~0x20;
|
||||
leds &=~0x02;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case 0x46:flags2 |=0x10;break; /* Scroll Lock SDL Seems to do this one fine (so break and make codes) */
|
||||
|
@ -605,14 +573,6 @@ static void InitBiosSegment(void) {
|
|||
mem_writew(BIOS_KEYBOARD_BUFFER_TAIL,0x1e);
|
||||
Bit8u flag1 = 0;
|
||||
Bit8u leds = 16; /* Ack received */
|
||||
|
||||
#if SDL_VERSION_ATLEAST(1, 2, 14)
|
||||
//Nothing, mapper handles all.
|
||||
#else
|
||||
if (startup_state_capslock) { flag1|=0x40; leds|=0x04;}
|
||||
if (startup_state_numlock) { flag1|=0x20; leds|=0x02;}
|
||||
#endif
|
||||
|
||||
mem_writeb(BIOS_KEYBOARD_FLAGS1,flag1);
|
||||
mem_writeb(BIOS_KEYBOARD_FLAGS2,0);
|
||||
mem_writeb(BIOS_KEYBOARD_FLAGS3,16); /* Enhanced keyboard installed */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue