mirror of
https://github.com/holub/mame
synced 2025-04-19 15:11:37 +03:00
osd: Removed support for SDL < 2.0.6; apple/apple2video.cpp: Code style cleanups.
This commit is contained in:
parent
9228b3baed
commit
660670fd9b
@ -154,9 +154,9 @@ WRITE_LINE_MEMBER(a2_video_device::an2_w)
|
||||
|
||||
|
||||
// 4-bit left rotate. Bits 4-6 of n must be a copy of bits 0-2.
|
||||
static inline unsigned rotl4b(unsigned n, unsigned count) { return (n >> (-count & 3)) & 0x0F; }
|
||||
static constexpr unsigned rotl4b(unsigned n, unsigned count) { return (n >> (-count & 3)) & 0x0f; }
|
||||
// 4-bit left rotate. Bits 4-6 of n must be zero.
|
||||
static inline unsigned rotl4(unsigned n, unsigned count) { return rotl4b(n * 0x11, count); }
|
||||
static constexpr unsigned rotl4(unsigned n, unsigned count) { return rotl4b(n * 0x11, count); }
|
||||
|
||||
static constexpr class bit_doubler
|
||||
{
|
||||
@ -231,32 +231,32 @@ static uint8_t const artifact_color_lut[2][1<<7] = {
|
||||
// A window size of 7 is enough to find the length of the middle pixel's run to a maximum of 4.
|
||||
// Each color is duplicated in both nibbles to slightly simplify the 4-bit rotation logic.
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x88,0x00,0x00,0x00,0x11,0x11,0x55,0x11,0x99,0x99,0xDD,0xFF,
|
||||
0x22,0x22,0x66,0x66,0xAA,0xAA,0xEE,0xEE,0x33,0x33,0x33,0x33,0xBB,0xBB,0xFF,0xFF,
|
||||
0x00,0x00,0x44,0x44,0xCC,0xCC,0xCC,0xCC,0x55,0x55,0x55,0x55,0x99,0x99,0xDD,0xFF,
|
||||
0x00,0x22,0x66,0x66,0xEE,0xAA,0xEE,0xEE,0x77,0x77,0x77,0x77,0xFF,0xFF,0xFF,0xFF,
|
||||
0x00,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x11,0x11,0x55,0x11,0x99,0x99,0xDD,0xFF,
|
||||
0x00,0x22,0x66,0x66,0xAA,0xAA,0xAA,0xAA,0x33,0x33,0x33,0x33,0xBB,0xBB,0xFF,0xFF,
|
||||
0x00,0x00,0x44,0x44,0xCC,0xCC,0xCC,0xCC,0x11,0x11,0x55,0x55,0x99,0x99,0xDD,0xDD,
|
||||
0x00,0x22,0x66,0x66,0xEE,0xAA,0xEE,0xEE,0xFF,0xFF,0xFF,0x77,0xFF,0xFF,0xFF,0xFF
|
||||
0x00,0x00,0x00,0x00,0x88,0x00,0x00,0x00,0x11,0x11,0x55,0x11,0x99,0x99,0xdd,0xff,
|
||||
0x22,0x22,0x66,0x66,0xaa,0xaa,0xee,0xee,0x33,0x33,0x33,0x33,0xbb,0xbb,0xff,0xff,
|
||||
0x00,0x00,0x44,0x44,0xcc,0xcc,0xcc,0xcc,0x55,0x55,0x55,0x55,0x99,0x99,0xdd,0xff,
|
||||
0x00,0x22,0x66,0x66,0xee,0xaa,0xee,0xee,0x77,0x77,0x77,0x77,0xff,0xff,0xff,0xff,
|
||||
0x00,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x11,0x11,0x55,0x11,0x99,0x99,0xdd,0xff,
|
||||
0x00,0x22,0x66,0x66,0xaa,0xaa,0xaa,0xaa,0x33,0x33,0x33,0x33,0xbb,0xbb,0xff,0xff,
|
||||
0x00,0x00,0x44,0x44,0xcc,0xcc,0xcc,0xcc,0x11,0x11,0x55,0x55,0x99,0x99,0xdd,0xdd,
|
||||
0x00,0x22,0x66,0x66,0xee,0xaa,0xee,0xee,0xff,0xff,0xff,0x77,0xff,0xff,0xff,0xff
|
||||
},
|
||||
// This alternate table colors 0110000 as a permutation of 0110, so that runs of medium colors
|
||||
// against black or white produce 4n colored pixels instead of 4n-2. The disadvantage is it makes
|
||||
// colorized 40-column text uglier. The 0010000 rule causes problems for 80-column text, but
|
||||
// that's a lost cause anyway.
|
||||
{
|
||||
0x00,0x00,0x00,0x00,0x88,0x00,0xCC,0x00,0x11,0x11,0x55,0x11,0x99,0x99,0xDD,0xFF,
|
||||
0x22,0x22,0x66,0x66,0xAA,0xAA,0xEE,0xEE,0x33,0x33,0x33,0x33,0xBB,0xBB,0xFF,0xFF,
|
||||
0x00,0x00,0x44,0x44,0xCC,0xCC,0xCC,0xCC,0x55,0x55,0x55,0x55,0x99,0x99,0xDD,0xFF,
|
||||
0x66,0x22,0x66,0x66,0xEE,0xAA,0xEE,0xEE,0x77,0x77,0x77,0x77,0xFF,0xFF,0xFF,0xFF,
|
||||
0x00,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x11,0x11,0x55,0x11,0x99,0x99,0xDD,0x99,
|
||||
0x00,0x22,0x66,0x66,0xAA,0xAA,0xAA,0xAA,0x33,0x33,0x33,0x33,0xBB,0xBB,0xFF,0xFF,
|
||||
0x00,0x00,0x44,0x44,0xCC,0xCC,0xCC,0xCC,0x11,0x11,0x55,0x55,0x99,0x99,0xDD,0xDD,
|
||||
0x00,0x22,0x66,0x66,0xEE,0xAA,0xEE,0xEE,0xFF,0x33,0xFF,0x77,0xFF,0xFF,0xFF,0xFF,
|
||||
0x00,0x00,0x00,0x00,0x88,0x00,0xcc,0x00,0x11,0x11,0x55,0x11,0x99,0x99,0xdd,0xff,
|
||||
0x22,0x22,0x66,0x66,0xaa,0xaa,0xee,0xee,0x33,0x33,0x33,0x33,0xbb,0xbB,0xff,0xff,
|
||||
0x00,0x00,0x44,0x44,0xcc,0xcc,0xcc,0xcc,0x55,0x55,0x55,0x55,0x99,0x99,0xdd,0xff,
|
||||
0x66,0x22,0x66,0x66,0xee,0xaa,0xee,0xee,0x77,0x77,0x77,0x77,0xff,0xfF,0xff,0xff,
|
||||
0x00,0x00,0x00,0x00,0x88,0x88,0x88,0x88,0x11,0x11,0x55,0x11,0x99,0x99,0xdd,0x99,
|
||||
0x00,0x22,0x66,0x66,0xaa,0xaa,0xaa,0xaa,0x33,0x33,0x33,0x33,0xbb,0xbB,0xff,0xff,
|
||||
0x00,0x00,0x44,0x44,0xcc,0xcc,0xcc,0xcc,0x11,0x11,0x55,0x55,0x99,0x99,0xdd,0xdd,
|
||||
0x00,0x22,0x66,0x66,0xee,0xaa,0xee,0xee,0xff,0x33,0xff,0x77,0xff,0xfF,0xff,0xff,
|
||||
}};
|
||||
|
||||
template<int ContextBits, class F>
|
||||
static void render_line_pixel_window(uint16_t *out, uint16_t const *in, int startcol, int stopcol, F const &color_function)
|
||||
template <int ContextBits, typename F>
|
||||
static void render_line_pixel_window(uint16_t *out, uint16_t const *in, int startcol, int stopcol, F &&color_function)
|
||||
{
|
||||
static_assert(ContextBits >= 0 && ContextBits <= 4); // uint32_t has room for 4+14+14 bits
|
||||
|
||||
@ -282,12 +282,22 @@ static void render_line_pixel_window(uint16_t *out, uint16_t const *in, int star
|
||||
|
||||
static void render_line_monochrome(uint16_t *out, uint16_t const *in, int startcol, int stopcol, int fg, int bg)
|
||||
{
|
||||
render_line_pixel_window<0>(out, in, startcol, stopcol, [=](uint32_t w, int x) { return (w & 1) ? fg : bg; });
|
||||
render_line_pixel_window<0>(
|
||||
out,
|
||||
in,
|
||||
startcol,
|
||||
stopcol,
|
||||
[fg, bg] (uint32_t w, int x) { return (w & 1) ? fg : bg; });
|
||||
}
|
||||
|
||||
static void render_line_artifact_color(uint16_t *out, uint16_t const *in, int startcol, int stopcol, bool is_80_column, uint8_t const *lut)
|
||||
{
|
||||
render_line_pixel_window<3>(out, in, startcol, stopcol, [=](uint32_t w, int x) { return rotl4b(lut[w & 0x7F], x + is_80_column); });
|
||||
render_line_pixel_window<3>(
|
||||
out,
|
||||
in,
|
||||
startcol,
|
||||
stopcol,
|
||||
[is_80_column, lut] (uint32_t w, int x) { return rotl4b(lut[w & 0x7f], x + is_80_column); });
|
||||
}
|
||||
|
||||
void a2_video_device::render_line(uint16_t *out, uint16_t const *in, int startcol, int stopcol, bool monochrome, bool is_80_column)
|
||||
@ -301,7 +311,12 @@ void a2_video_device::render_line(uint16_t *out, uint16_t const *in, int startco
|
||||
// There is no way to communicate the chroma phase of the first pixel to the NTSC shader, and it
|
||||
// differs between Apple II modes. As a workaround, shift some modes right by one pixel (losing
|
||||
// the rightmost pixel). This should be removed when there is a way to pass parameters to shaders.
|
||||
render_line_pixel_window<1>(out, in, startcol, stopcol, [=](uint32_t w, int x) { return (w & 1) ? fg : BLACK; });
|
||||
render_line_pixel_window<1>(
|
||||
out,
|
||||
in,
|
||||
startcol,
|
||||
stopcol,
|
||||
[fg] (uint32_t w, int x) { return (w & 1) ? fg : BLACK; });
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -314,14 +329,19 @@ void a2_video_device::render_line(uint16_t *out, uint16_t const *in, int startco
|
||||
{
|
||||
default:
|
||||
color_mode = 0;
|
||||
// fall through
|
||||
[[fallthrough]];
|
||||
case 0: case 1:
|
||||
// Pixel-run coloring
|
||||
render_line_artifact_color(out, in, startcol, stopcol, is_80_column, artifact_color_lut[color_mode]);
|
||||
break;
|
||||
case 2:
|
||||
// 4-bit square filter
|
||||
render_line_pixel_window<1>(out, in, startcol, stopcol, [=](uint32_t w, int x) { return rotl4(w & 0x0F, x + is_80_column - 1); });
|
||||
render_line_pixel_window<1>(
|
||||
out,
|
||||
in,
|
||||
startcol,
|
||||
stopcol,
|
||||
[is_80_column] (uint32_t w, int x) { return rotl4(w & 0x0f, x + is_80_column - 1); });
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -336,7 +356,7 @@ static void render_line_color_array(uint16_t *out, uint16_t const *in, int start
|
||||
unsigned const fg_bg = fg_bg_array[col];
|
||||
for (int b = 0; b < 14; ++b)
|
||||
{
|
||||
out[col * 14 + b] = (fg_bg >> (w & 4)) & 0x0F;
|
||||
out[col * 14 + b] = (fg_bg >> (w & 4)) & 0x0f;
|
||||
w >>= 1;
|
||||
}
|
||||
}
|
||||
@ -346,7 +366,7 @@ static void render_line_color_array(uint16_t *out, uint16_t const *in, int start
|
||||
template <a2_video_device::model Model, bool Invert, bool Flip>
|
||||
unsigned a2_video_device::get_text_character(uint32_t code, int row)
|
||||
{
|
||||
unsigned invert_mask = Invert ? 0 : 0x7F;
|
||||
unsigned invert_mask = Invert ? 0 : 0x7f;
|
||||
|
||||
if (Model == model::IIE || Model == model::IIGS)
|
||||
{
|
||||
@ -358,7 +378,7 @@ unsigned a2_video_device::get_text_character(uint32_t code, int row)
|
||||
|
||||
if (m_flash)
|
||||
{
|
||||
invert_mask ^= 0x7F;
|
||||
invert_mask ^= 0x7f;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -371,7 +391,7 @@ unsigned a2_video_device::get_text_character(uint32_t code, int row)
|
||||
if ((code >= 0x60) && (code <= 0x7f))
|
||||
{
|
||||
code |= 0x80; // map to lowercase normal
|
||||
invert_mask ^= 0x7F; // and flip the color
|
||||
invert_mask ^= 0x7f; // and flip the color
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -385,12 +405,12 @@ unsigned a2_video_device::get_text_character(uint32_t code, int row)
|
||||
}
|
||||
if (m_flash)
|
||||
{
|
||||
invert_mask ^= 0x7F;
|
||||
invert_mask ^= 0x7f;
|
||||
}
|
||||
}
|
||||
else if (code < 0x40 && Model != model::IVEL_ULTRA) // inverse: flip FG and BG
|
||||
{
|
||||
invert_mask ^= 0x7F;
|
||||
invert_mask ^= 0x7f;
|
||||
}
|
||||
|
||||
if (Model == model::II_J_PLUS && m_an2)
|
||||
@ -401,7 +421,7 @@ unsigned a2_video_device::get_text_character(uint32_t code, int row)
|
||||
|
||||
/* look up the character data */
|
||||
unsigned bits = m_char_ptr[code * 8 + row];
|
||||
bits = (Model == model::IVEL_ULTRA) ? (bits >> 1) : (bits & 0x7F);
|
||||
bits = (Model == model::IVEL_ULTRA) ? (bits >> 1) : (bits & 0x7f);
|
||||
bits ^= invert_mask;
|
||||
return Flip ? reverse_7_bits[bits] : bits;
|
||||
}
|
||||
@ -431,7 +451,7 @@ void a2_video_device::lores_update(screen_device &screen, bitmap_ind16 &bitmap,
|
||||
uint8_t const *const vram = m_ram_ptr + address;
|
||||
uint8_t const *const vaux = Double ? (m_aux_ptr + address) : nullptr;
|
||||
|
||||
#define NIBBLE(byte) (((byte) >> (row & 4)) & 0x0F)
|
||||
auto const NIBBLE = [&row] (auto byte) { return ((byte) >> (row & 4)) & 0x0f; };
|
||||
if (render_perfect_blocks)
|
||||
{
|
||||
uint16_t *p = &bitmap.pix(row, startcol * 14);
|
||||
@ -470,14 +490,13 @@ void a2_video_device::lores_update(screen_device &screen, bitmap_ind16 &bitmap,
|
||||
}
|
||||
else
|
||||
{
|
||||
words[col+0] = (NIBBLE(vram[col+0]) * 0x1111) & 0x3FFF;
|
||||
words[col+0] = (NIBBLE(vram[col+0]) * 0x1111) & 0x3fff;
|
||||
words[col+1] = (NIBBLE(vram[col+1]) * 0x1111) >> 2;
|
||||
}
|
||||
}
|
||||
|
||||
render_line(&bitmap.pix(row), words, startcol, stopcol, monochrome, Double);
|
||||
}
|
||||
#undef NIBBLE
|
||||
|
||||
if (startcol < stopcol)
|
||||
{
|
||||
@ -582,9 +601,9 @@ void a2_video_device::hgr_update(screen_device &screen, bitmap_ind16 &bitmap, co
|
||||
|
||||
for (int col = std::max(0, startcol-1); col < std::min(stopcol+1, 40); col++)
|
||||
{
|
||||
unsigned word = double_7_bits[vram_row[col] & 0x7F];
|
||||
unsigned word = double_7_bits[vram_row[col] & 0x7f];
|
||||
if (vram_row[col] & bit7_mask)
|
||||
word = (word * 2 + last_output_bit) & 0x3FFF;
|
||||
word = (word * 2 + last_output_bit) & 0x3fff;
|
||||
words[col] = word;
|
||||
last_output_bit = word >> 13;
|
||||
}
|
||||
@ -665,7 +684,7 @@ void a2_video_device::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, c
|
||||
|
||||
for (int col = std::max(0, startcol-1); col < std::min(stopcol+1, 40); col++)
|
||||
{
|
||||
words[col] = (vaux_row[col] & 0x7F) + ((vram_row[col] & 0x7F) << 7);
|
||||
words[col] = (vaux_row[col] & 0x7f) + ((vram_row[col] & 0x7f) << 7);
|
||||
}
|
||||
|
||||
if (rgbmode < 0)
|
||||
@ -696,12 +715,12 @@ void a2_video_device::dhgr_update(screen_device &screen, bitmap_ind16 &bitmap, c
|
||||
unsigned const w = words[col] + (words[col+1] << 14);
|
||||
|
||||
unsigned const color_mask = (rgbmode == 3) ? -1u :
|
||||
(vaux_row[col] >> 7) * 0x7F + (vram_row[col] >> 7) * 0x3F80
|
||||
+ (vaux_row[col+1] >> 7) * 0x1FC000 + (vram_row[col+1] >> 7) * 0xFE00000;
|
||||
(vaux_row[col] >> 7) * 0x7f + (vram_row[col] >> 7) * 0x3f80
|
||||
+ (vaux_row[col+1] >> 7) * 0x1fc000 + (vram_row[col+1] >> 7) * 0xfe00000;
|
||||
|
||||
for (int b = 0; b < 28; ++b)
|
||||
{
|
||||
*p++ = (color_mask & (1 << b)) ? rotl4((w >> (b & ~3u)) & 0x0F, 1) : (w & (1 << b)) ? WHITE : BLACK;
|
||||
*p++ = (color_mask & (1 << b)) ? rotl4((w >> (b & ~3u)) & 0x0f, 1) : (w & (1 << b)) ? WHITE : BLACK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,15 +36,8 @@
|
||||
#include <OpenGL/gl.h>
|
||||
#include <OpenGL/glext.h>
|
||||
#else
|
||||
#include <SDL2/SDL_version.h>
|
||||
|
||||
#if (SDL_VERSION_ATLEAST(1,2,10))
|
||||
#if defined(SDLMAME_WIN32)
|
||||
// Avoid that winnt.h (included via sdl_opengl.h, windows.h, windef.h includes intrin.h
|
||||
#define __INTRIN_H_
|
||||
#endif
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
#endif
|
||||
#include <SDL2/SDL_version.h>
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
#endif
|
||||
|
||||
class osd_gl_context
|
||||
|
@ -91,17 +91,13 @@ bool sdl_osd_interface::window_init()
|
||||
SDL_HINT_XINPUT_ENABLED, SDL_HINT_GAMECONTROLLERCONFIG,
|
||||
SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, SDL_HINT_ALLOW_TOPMOST,
|
||||
SDL_HINT_TIMER_RESOLUTION,
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 2)
|
||||
SDL_HINT_RENDER_DIRECT3D_THREADSAFE, SDL_HINT_VIDEO_ALLOW_SCREENSAVER,
|
||||
SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK,
|
||||
SDL_HINT_VIDEO_WIN_D3DCOMPILER, SDL_HINT_VIDEO_WINDOW_SHARE_PIXEL_FORMAT,
|
||||
SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, SDL_HINT_MOUSE_RELATIVE_MODE_WARP,
|
||||
#endif
|
||||
#if SDL_VERSION_ATLEAST(2, 0, 3)
|
||||
SDL_HINT_RENDER_DIRECT3D11_DEBUG, SDL_HINT_VIDEO_HIGHDPI_DISABLED,
|
||||
SDL_HINT_WINRT_PRIVACY_POLICY_URL, SDL_HINT_WINRT_PRIVACY_POLICY_LABEL,
|
||||
SDL_HINT_WINRT_HANDLE_BACK_BUTTON,
|
||||
#endif
|
||||
};
|
||||
|
||||
osd_printf_verbose("\nHints:\n");
|
||||
@ -596,24 +592,6 @@ int sdl_window_info::complete_create()
|
||||
m_extra_flags = 0;
|
||||
}
|
||||
|
||||
// We need to workaround an issue in SDL 2.0.4 for OS X where setting the
|
||||
// relative mode on the mouse in fullscreen mode makes mouse events stop
|
||||
// It is fixed in the latest revisions so we'll assume it'll be fixed
|
||||
// in the next public SDL release as well
|
||||
#if defined(SDLMAME_MACOSX) && SDL_VERSION_ATLEAST(2, 0, 2) // SDL_HINT_MOUSE_RELATIVE_MODE_WARP is introduced in 2.0.2
|
||||
SDL_version linked;
|
||||
SDL_GetVersion(&linked);
|
||||
int revision = SDL_GetRevisionNumber();
|
||||
|
||||
// If we're running the exact version of SDL 2.0.4 (revision 10001) from the
|
||||
// SDL web site, we need to work around this issue and send the warp mode hint
|
||||
if (SDL_VERSION_EQUALS(linked, SDL_VERSIONNUM(2, 0, 4)) && revision == 10001)
|
||||
{
|
||||
osd_printf_verbose("Using warp mode for relative mouse in OS X SDL 2.0.4\n");
|
||||
SDL_SetHint(SDL_HINT_MOUSE_RELATIVE_MODE_WARP, "1");
|
||||
}
|
||||
#endif
|
||||
|
||||
// create the SDL window
|
||||
// soft driver also used | SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_MOUSE_FOCUS
|
||||
m_extra_flags |= (fullscreen() ?
|
||||
|
Loading…
Reference in New Issue
Block a user