#include "stdafx.h"
#if defined(WITH_SDL)
#include "ttd.h"
#include "gfx.h"
#include "sound.h"
#include "window.h"
#include <SDL.h>
#include "player.h"
#include "hal.h"
#ifdef UNIX
#include <signal.h>
#ifdef __MORPHOS__
#define SIG_DFL (void (*)(int))0
#endif
#define DYNAMICALLY_LOADED_SDL
static SDL_Surface *_sdl_screen;
static int _sdl_usage;
static bool _all_modes;
#define MAX_DIRTY_RECTS 100
static SDL_Rect _dirty_rects[MAX_DIRTY_RECTS];
static int _num_dirty_rects;
#define SDL_CALL
#if defined(DYNAMICALLY_LOADED_SDL) && defined(WIN32)
bool LoadLibraryList(void **proc, const char *dll);
typedef struct {
int (SDLCALL *SDL_Init)(Uint32);
int (SDLCALL *SDL_InitSubSystem)(Uint32);
char *(SDLCALL *SDL_GetError)();
void (SDLCALL *SDL_QuitSubSystem)(Uint32);
void (SDLCALL *SDL_UpdateRect)(SDL_Surface *, Sint32, Sint32, Uint32, Uint32);
@@ -128,53 +132,49 @@ static char *SdlOpen(uint32 x)
}
if (_sdl_usage++ == 0) {
if (SDL_CALL SDL_Init(x) == -1)
return SDL_CALL SDL_GetError();
} else if (x != 0) {
if (SDL_CALL SDL_InitSubSystem(x) == -1)
signal(SIGABRT, SdlAbort);
return NULL;
static void SdlClose(uint32 x)
{
if (x != 0)
SDL_CALL SDL_QuitSubSystem(x);
if (--_sdl_usage == 0) {
SDL_CALL SDL_Quit();
#ifndef __MORPHOS__
signal(SIGABRT, SIG_DFL);
#else
signal(SIGABRT, (void (*)(int))0);
static void SdlVideoMakeDirty(int left, int top, int width, int height)
// printf("(%d,%d)-(%d,%d)\n", left, top, width, height);
// _pixels_redrawn += width*height;
if (_num_dirty_rects < MAX_DIRTY_RECTS) {
_dirty_rects[_num_dirty_rects].x = left;
_dirty_rects[_num_dirty_rects].y = top;
_dirty_rects[_num_dirty_rects].w = width;
_dirty_rects[_num_dirty_rects].h = height;
_num_dirty_rects++;
static SDL_Color pal[256];
static void UpdatePalette(uint start, uint end)
uint i;
byte *b;
Status change: