Big disgusting backend rework

We need to avoid `WindowsWrapper.h` in the backends whenever we can,
to avoid name collisions (the Wii U homebrew library) defines its own
BOOL/TRUE/FALSE, which really doesn't work with CSE2.
This commit is contained in:
Clownacy 2020-04-13 18:19:39 +01:00
parent fd0733f6e7
commit c51a074fad
25 changed files with 128 additions and 145 deletions

View file

@ -2,17 +2,15 @@
#include <stddef.h> #include <stddef.h>
#include "../WindowsWrapper.h"
typedef struct AudioBackend_Sound AudioBackend_Sound; typedef struct AudioBackend_Sound AudioBackend_Sound;
BOOL AudioBackend_Init(void); bool AudioBackend_Init(void);
void AudioBackend_Deinit(void); void AudioBackend_Deinit(void);
AudioBackend_Sound* AudioBackend_CreateSound(unsigned int frequency, const unsigned char *samples, size_t length); AudioBackend_Sound* AudioBackend_CreateSound(unsigned int frequency, const unsigned char *samples, size_t length);
void AudioBackend_DestroySound(AudioBackend_Sound *sound); void AudioBackend_DestroySound(AudioBackend_Sound *sound);
void AudioBackend_PlaySound(AudioBackend_Sound *sound, BOOL looping); void AudioBackend_PlaySound(AudioBackend_Sound *sound, bool looping);
void AudioBackend_StopSound(AudioBackend_Sound *sound); void AudioBackend_StopSound(AudioBackend_Sound *sound);
void AudioBackend_RewindSound(AudioBackend_Sound *sound); void AudioBackend_RewindSound(AudioBackend_Sound *sound);
@ -20,4 +18,4 @@ void AudioBackend_SetSoundFrequency(AudioBackend_Sound *sound, unsigned int freq
void AudioBackend_SetSoundVolume(AudioBackend_Sound *sound, long volume); void AudioBackend_SetSoundVolume(AudioBackend_Sound *sound, long volume);
void AudioBackend_SetSoundPan(AudioBackend_Sound *sound, long pan); void AudioBackend_SetSoundPan(AudioBackend_Sound *sound, long pan);
void AudioBackend_SetOrganyaTimer(unsigned short timer); void AudioBackend_SetOrganyaCallback(void (*callback)(void), unsigned int milliseconds);

View file

@ -7,8 +7,6 @@
#include "SDL.h" #include "SDL.h"
#include "../Misc.h" #include "../Misc.h"
#include "../../Organya.h"
#include "../../WindowsWrapper.h"
#include "SoftwareMixer.h" #include "SoftwareMixer.h"
@ -18,7 +16,8 @@ static SDL_AudioDeviceID device_id;
static unsigned long output_frequency; static unsigned long output_frequency;
static unsigned short organya_timer; static void (*organya_callback)(void);
static unsigned int organya_callback_milliseconds;
static void Callback(void *user_data, Uint8 *stream_uint8, int len) static void Callback(void *user_data, Uint8 *stream_uint8, int len)
{ {
@ -30,7 +29,7 @@ static void Callback(void *user_data, Uint8 *stream_uint8, int len)
for (unsigned int i = 0; i < frames_total * 2; ++i) for (unsigned int i = 0; i < frames_total * 2; ++i)
stream[i] = 0.0f; stream[i] = 0.0f;
if (organya_timer == 0) if (organya_callback_milliseconds == 0)
{ {
Mixer_MixSounds(stream, frames_total); Mixer_MixSounds(stream, frames_total);
} }
@ -49,8 +48,8 @@ static void Callback(void *user_data, Uint8 *stream_uint8, int len)
if (organya_countdown == 0) if (organya_countdown == 0)
{ {
organya_countdown = (organya_timer * output_frequency) / 1000; // organya_timer is in milliseconds, so convert it to audio frames organya_countdown = (organya_callback_milliseconds * output_frequency) / 1000; // organya_timer is in milliseconds, so convert it to audio frames
UpdateOrganya(); organya_callback();
} }
const unsigned int frames_to_do = MIN(organya_countdown, frames_total - frames_done); const unsigned int frames_to_do = MIN(organya_countdown, frames_total - frames_done);
@ -63,13 +62,13 @@ static void Callback(void *user_data, Uint8 *stream_uint8, int len)
} }
} }
BOOL AudioBackend_Init(void) bool AudioBackend_Init(void)
{ {
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
{ {
std::string errorMessage = std::string("'SDL_InitSubSystem(SDL_INIT_AUDIO)' failed: ") + SDL_GetError(); std::string errorMessage = std::string("'SDL_InitSubSystem(SDL_INIT_AUDIO)' failed: ") + SDL_GetError();
Backend_ShowMessageBox("Fatal error (SDL2 audio backend)", errorMessage.c_str()); Backend_ShowMessageBox("Fatal error (SDL2 audio backend)", errorMessage.c_str());
return FALSE; return false;
} }
Backend_PrintInfo("Available SDL audio drivers:"); Backend_PrintInfo("Available SDL audio drivers:");
@ -91,7 +90,7 @@ BOOL AudioBackend_Init(void)
{ {
std::string error_message = std::string("'SDL_OpenAudioDevice' failed: ") + SDL_GetError(); std::string error_message = std::string("'SDL_OpenAudioDevice' failed: ") + SDL_GetError();
Backend_ShowMessageBox("Fatal error (SDL2 audio backend)", error_message.c_str()); Backend_ShowMessageBox("Fatal error (SDL2 audio backend)", error_message.c_str());
return FALSE; return false;
} }
output_frequency = obtained_specification.freq; output_frequency = obtained_specification.freq;
@ -101,7 +100,7 @@ BOOL AudioBackend_Init(void)
Backend_PrintInfo("Selected SDL audio driver: %s", SDL_GetCurrentAudioDriver()); Backend_PrintInfo("Selected SDL audio driver: %s", SDL_GetCurrentAudioDriver());
return TRUE; return true;
} }
void AudioBackend_Deinit(void) void AudioBackend_Deinit(void)
@ -134,7 +133,7 @@ void AudioBackend_DestroySound(AudioBackend_Sound *sound)
SDL_UnlockAudioDevice(device_id); SDL_UnlockAudioDevice(device_id);
} }
void AudioBackend_PlaySound(AudioBackend_Sound *sound, BOOL looping) void AudioBackend_PlaySound(AudioBackend_Sound *sound, bool looping)
{ {
if (sound == NULL) if (sound == NULL)
return; return;
@ -206,11 +205,12 @@ void AudioBackend_SetSoundPan(AudioBackend_Sound *sound, long pan)
SDL_UnlockAudioDevice(device_id); SDL_UnlockAudioDevice(device_id);
} }
void AudioBackend_SetOrganyaTimer(unsigned short timer) void AudioBackend_SetOrganyaCallback(void (*callback)(void), unsigned int milliseconds)
{ {
SDL_LockAudioDevice(device_id); SDL_LockAudioDevice(device_id);
organya_timer = timer; organya_callback = callback;
organya_callback_milliseconds = milliseconds;
SDL_UnlockAudioDevice(device_id); SDL_UnlockAudioDevice(device_id);
} }

View file

@ -8,8 +8,6 @@
#include "../../../external/miniaudio.h" #include "../../../external/miniaudio.h"
#include "../Misc.h" #include "../Misc.h"
#include "../../Organya.h"
#include "../../WindowsWrapper.h"
#include "SoftwareMixer.h" #include "SoftwareMixer.h"
@ -21,7 +19,8 @@ static ma_mutex organya_mutex;
static unsigned long output_frequency; static unsigned long output_frequency;
static unsigned short organya_timer; static void (*organya_callback)(void);
static unsigned int organya_callback_milliseconds;
static void Callback(ma_device *device, void *output_stream, const void *input_stream, ma_uint32 frames_total) static void Callback(ma_device *device, void *output_stream, const void *input_stream, ma_uint32 frames_total)
{ {
@ -32,7 +31,7 @@ static void Callback(ma_device *device, void *output_stream, const void *input_s
ma_mutex_lock(&organya_mutex); ma_mutex_lock(&organya_mutex);
if (organya_timer == 0) if (organya_callback_milliseconds == 0)
{ {
ma_mutex_lock(&mutex); ma_mutex_lock(&mutex);
Mixer_MixSounds(stream, frames_total); Mixer_MixSounds(stream, frames_total);
@ -53,8 +52,8 @@ static void Callback(ma_device *device, void *output_stream, const void *input_s
if (organya_countdown == 0) if (organya_countdown == 0)
{ {
organya_countdown = (organya_timer * output_frequency) / 1000; // organya_timer is in milliseconds, so convert it to audio frames organya_countdown = (organya_callback_milliseconds * output_frequency) / 1000; // organya_timer is in milliseconds, so convert it to audio frames
UpdateOrganya(); organya_callback();
} }
const unsigned int frames_to_do = MIN(organya_countdown, frames_total - frames_done); const unsigned int frames_to_do = MIN(organya_countdown, frames_total - frames_done);
@ -71,7 +70,7 @@ static void Callback(ma_device *device, void *output_stream, const void *input_s
ma_mutex_unlock(&organya_mutex); ma_mutex_unlock(&organya_mutex);
} }
BOOL AudioBackend_Init(void) bool AudioBackend_Init(void)
{ {
ma_device_config config = ma_device_config_init(ma_device_type_playback); ma_device_config config = ma_device_config_init(ma_device_type_playback);
config.playback.pDeviceID = NULL; config.playback.pDeviceID = NULL;
@ -103,7 +102,7 @@ BOOL AudioBackend_Init(void)
Mixer_Init(device.sampleRate); Mixer_Init(device.sampleRate);
return TRUE; return true;
} }
else else
{ {
@ -132,7 +131,7 @@ BOOL AudioBackend_Init(void)
} }
return FALSE; return false;
} }
void AudioBackend_Deinit(void) void AudioBackend_Deinit(void)
@ -172,7 +171,7 @@ void AudioBackend_DestroySound(AudioBackend_Sound *sound)
ma_mutex_unlock(&mutex); ma_mutex_unlock(&mutex);
} }
void AudioBackend_PlaySound(AudioBackend_Sound *sound, BOOL looping) void AudioBackend_PlaySound(AudioBackend_Sound *sound, bool looping)
{ {
if (sound == NULL) if (sound == NULL)
return; return;
@ -244,11 +243,12 @@ void AudioBackend_SetSoundPan(AudioBackend_Sound *sound, long pan)
ma_mutex_unlock(&mutex); ma_mutex_unlock(&mutex);
} }
void AudioBackend_SetOrganyaTimer(unsigned short timer) void AudioBackend_SetOrganyaCallback(void (*callback)(void), unsigned int milliseconds)
{ {
ma_mutex_lock(&organya_mutex); ma_mutex_lock(&organya_mutex);
organya_timer = timer; organya_callback = callback;
organya_callback_milliseconds = milliseconds;
ma_mutex_unlock(&organya_mutex); ma_mutex_unlock(&organya_mutex);
} }

View file

@ -1,7 +1,6 @@
#include "../Controller.h" #include "../Controller.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_NONE

View file

@ -10,8 +10,6 @@
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "../../WindowsWrapper.h"
#include "Window.h" #include "Window.h"
#include "../Rendering.h" #include "../Rendering.h"
#include "../../Attributes.h" #include "../../Attributes.h"
@ -25,7 +23,7 @@
keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \ keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \
break; break;
static BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL]; static bool keyboard_state[BACKEND_KEYBOARD_TOTAL];
static GLFWcursor* cursor; static GLFWcursor* cursor;
@ -155,16 +153,16 @@ static void ErrorCallback(int code, const char *description)
Backend_PrintError("GLFW error received (%d): %s", code, description); Backend_PrintError("GLFW error received (%d): %s", code, description);
} }
BOOL Backend_Init(void) bool Backend_Init(void)
{ {
glfwSetErrorCallback(ErrorCallback); glfwSetErrorCallback(ErrorCallback);
if (glfwInit() == GL_TRUE) if (glfwInit() == GL_TRUE)
return TRUE; return true;
Backend_ShowMessageBox("Fatal error", "Could not initialise GLFW3"); Backend_ShowMessageBox("Fatal error", "Could not initialise GLFW3");
return FALSE; return false;
} }
void Backend_Deinit(void) void Backend_Deinit(void)
@ -183,12 +181,12 @@ void Backend_PostWindowCreation(void)
glfwSetWindowSizeCallback(window, WindowSizeCallback); glfwSetWindowSizeCallback(window, WindowSizeCallback);
} }
BOOL Backend_GetBasePath(char *string_buffer) bool Backend_GetBasePath(char *string_buffer)
{ {
(void)string_buffer; (void)string_buffer;
// GLFW3 doesn't seem to have a mechanism for this // GLFW3 doesn't seem to have a mechanism for this
return FALSE; return false;
} }
void Backend_HideMouse(void) void Backend_HideMouse(void)
@ -270,12 +268,12 @@ void PlaybackBackend_EnableDragAndDrop(void)
glfwSetDropCallback(window, DragAndDropCallback); glfwSetDropCallback(window, DragAndDropCallback);
} }
BOOL Backend_SystemTask(BOOL active) bool Backend_SystemTask(bool active)
{ {
if (glfwWindowShouldClose(window)) if (glfwWindowShouldClose(window))
{ {
StopOrganyaMusic(); StopOrganyaMusic();
return FALSE; return false;
} }
if (active) if (active)
@ -283,10 +281,10 @@ BOOL Backend_SystemTask(BOOL active)
else else
glfwWaitEvents(); glfwWaitEvents();
return TRUE; return true;
} }
void Backend_GetKeyboardState(BOOL *out_keyboard_state) void Backend_GetKeyboardState(bool *out_keyboard_state)
{ {
memcpy(out_keyboard_state, keyboard_state, sizeof(keyboard_state)); memcpy(out_keyboard_state, keyboard_state, sizeof(keyboard_state));
} }

View file

@ -11,13 +11,11 @@
#endif #endif
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "../../WindowsWrapper.h"
#include "../Misc.h" #include "../Misc.h"
GLFWwindow *window; GLFWwindow *window;
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen) bool WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)
{ {
#ifdef USE_OPENGLES2 #ifdef USE_OPENGLES2
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
@ -61,7 +59,7 @@ BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_wid
#endif #endif
Backend_PostWindowCreation(); Backend_PostWindowCreation();
return TRUE; return true;
#ifndef USE_OPENGLES2 #ifndef USE_OPENGLES2
} }
else else
@ -82,7 +80,7 @@ BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_wid
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window"); Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
} }
return FALSE; return false;
} }
void WindowBackend_OpenGL_DestroyWindow(void) void WindowBackend_OpenGL_DestroyWindow(void)

View file

@ -11,8 +11,6 @@
#endif #endif
#include <GLFW/glfw3.h> #include <GLFW/glfw3.h>
#include "../../WindowsWrapper.h"
#include "../Misc.h" #include "../Misc.h"
GLFWwindow *window; GLFWwindow *window;
@ -26,7 +24,7 @@ static float framebuffer_y_ratio;
static GLuint screen_texture_id; static GLuint screen_texture_id;
unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, BOOL fullscreen, size_t *pitch) unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen, size_t *pitch)
{ {
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);

View file

@ -1,7 +1,6 @@
#pragma once #pragma once
#include "../Attributes.h" #include "../Attributes.h"
#include "../WindowsWrapper.h"
enum enum
{ {
@ -84,16 +83,16 @@ enum
BACKEND_KEYBOARD_TOTAL BACKEND_KEYBOARD_TOTAL
}; };
BOOL Backend_Init(void); bool Backend_Init(void);
void Backend_Deinit(void); void Backend_Deinit(void);
void Backend_PostWindowCreation(void); void Backend_PostWindowCreation(void);
BOOL Backend_GetBasePath(char *string_buffer); bool Backend_GetBasePath(char *string_buffer);
void Backend_HideMouse(void); void Backend_HideMouse(void);
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height); void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height); void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
void PlaybackBackend_EnableDragAndDrop(void); void PlaybackBackend_EnableDragAndDrop(void);
BOOL Backend_SystemTask(BOOL active); bool Backend_SystemTask(bool active);
void Backend_GetKeyboardState(BOOL *keyboard_state); void Backend_GetKeyboardState(bool *keyboard_state);
void Backend_ShowMessageBox(const char *title, const char *message); void Backend_ShowMessageBox(const char *title, const char *message);
ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintError(const char *format, ...); ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintError(const char *format, ...);
ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintInfo(const char *format, ...); ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintInfo(const char *format, ...);

View file

@ -1,22 +1,28 @@
#pragma once #pragma once
#include "../WindowsWrapper.h"
typedef struct RenderBackend_Surface RenderBackend_Surface; typedef struct RenderBackend_Surface RenderBackend_Surface;
typedef struct RenderBackend_Glyph RenderBackend_Glyph; typedef struct RenderBackend_Glyph RenderBackend_Glyph;
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen); typedef struct RenderBackend_Rect
{
long left;
long top;
long right;
long bottom;
} RenderBackend_Rect;
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, bool fullscreen);
void RenderBackend_Deinit(void); void RenderBackend_Deinit(void);
void RenderBackend_DrawScreen(void); void RenderBackend_DrawScreen(void);
void RenderBackend_ClearScreen(void); void RenderBackend_ClearScreen(void);
RenderBackend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height); RenderBackend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height);
void RenderBackend_FreeSurface(RenderBackend_Surface *surface); void RenderBackend_FreeSurface(RenderBackend_Surface *surface);
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface); bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface);
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface); void RenderBackend_RestoreSurface(RenderBackend_Surface *surface);
unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height); unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height);
void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height); void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int width, unsigned int height);
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key); void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key);
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue); void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue);
RenderBackend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch); RenderBackend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch);
void RenderBackend_UnloadGlyph(RenderBackend_Glyph *glyph); void RenderBackend_UnloadGlyph(RenderBackend_Glyph *glyph);
void RenderBackend_PrepareToDrawGlyphs(RenderBackend_Surface *destination_surface, const unsigned char *colour_channels); void RenderBackend_PrepareToDrawGlyphs(RenderBackend_Surface *destination_surface, const unsigned char *colour_channels);

View file

@ -3,7 +3,6 @@
#include "../Rendering.h" #include "../Rendering.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -584,7 +583,7 @@ static void PostGLCallCallback(const char *name, void *function_pointer, int len
// Render-backend initialisation // Render-backend initialisation
// ==================== // ====================
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen) RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, bool fullscreen)
{ {
#ifndef USE_OPENGLES2 #ifndef USE_OPENGLES2
glad_set_post_callback(PostGLCallCallback); glad_set_post_callback(PostGLCallCallback);
@ -855,11 +854,11 @@ void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
free(surface); free(surface);
} }
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface) bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
{ {
(void)surface; (void)surface;
return FALSE; return false;
} }
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface) void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
@ -897,7 +896,7 @@ void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int wi
// Drawing // Drawing
// ==================== // ====================
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key) void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{ {
if (source_surface == NULL || destination_surface == NULL) if (source_surface == NULL || destination_surface == NULL)
return; return;
@ -976,7 +975,7 @@ void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect,
} }
} }
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue) void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
{ {
static unsigned char last_red; static unsigned char last_red;
static unsigned char last_green; static unsigned char last_green;

View file

@ -7,8 +7,6 @@
#include "SDL.h" #include "SDL.h"
#include "../../WindowsWrapper.h"
#include "../Misc.h" #include "../Misc.h"
#include "../SDL2/Window.h" #include "../SDL2/Window.h"
@ -31,7 +29,7 @@ static RenderBackend_Surface framebuffer;
static unsigned char glyph_colour_channels[3]; static unsigned char glyph_colour_channels[3];
static SDL_Surface *glyph_destination_sdlsurface; static SDL_Surface *glyph_destination_sdlsurface;
static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect) static void RectToSDLRect(const RenderBackend_Rect *rect, SDL_Rect *sdl_rect)
{ {
sdl_rect->x = (int)rect->left; sdl_rect->x = (int)rect->left;
sdl_rect->y = (int)rect->top; sdl_rect->y = (int)rect->top;
@ -45,7 +43,7 @@ static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect)
sdl_rect->h = 0; sdl_rect->h = 0;
} }
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen) RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, bool fullscreen)
{ {
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0); window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);
@ -130,11 +128,11 @@ void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
free(surface); free(surface);
} }
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface) bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
{ {
(void)surface; (void)surface;
return FALSE; return false;
} }
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface) void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
@ -161,7 +159,7 @@ void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int wi
(void)height; (void)height;
} }
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key) void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{ {
if (source_surface == NULL || destination_surface == NULL) if (source_surface == NULL || destination_surface == NULL)
return; return;
@ -183,7 +181,7 @@ void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect,
Backend_PrintError("Couldn't blit surface: %s", SDL_GetError()); Backend_PrintError("Couldn't blit surface: %s", SDL_GetError());
} }
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue) void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
{ {
if (surface == NULL) if (surface == NULL)
return; return;

View file

@ -1,7 +1,6 @@
#include "../Rendering.h" #include "../Rendering.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <string> #include <string>
@ -26,7 +25,7 @@ typedef struct RenderBackend_Surface
unsigned char *pixels; unsigned char *pixels;
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
BOOL lost; bool lost;
struct RenderBackend_Surface *next; struct RenderBackend_Surface *next;
struct RenderBackend_Surface *prev; struct RenderBackend_Surface *prev;
@ -51,7 +50,7 @@ static unsigned char glyph_colour_channels[3];
static spritebatch_t glyph_batcher; static spritebatch_t glyph_batcher;
static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect) static void RectToSDLRect(const RenderBackend_Rect *rect, SDL_Rect *sdl_rect)
{ {
sdl_rect->x = (int)rect->left; sdl_rect->x = (int)rect->left;
sdl_rect->y = (int)rect->top; sdl_rect->y = (int)rect->top;
@ -126,7 +125,7 @@ static void GlyphBatch_DestroyTexture(SPRITEBATCH_U64 texture_id, void *udata)
SDL_DestroyTexture((SDL_Texture*)texture_id); SDL_DestroyTexture((SDL_Texture*)texture_id);
} }
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen) RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, bool fullscreen)
{ {
Backend_PrintInfo("Available SDL render drivers:"); Backend_PrintInfo("Available SDL render drivers:");
@ -254,7 +253,7 @@ RenderBackend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned
surface->width = width; surface->width = width;
surface->height = height; surface->height = height;
surface->lost = FALSE; surface->lost = false;
// Add to linked-list // Add to linked-list
surface->prev = NULL; surface->prev = NULL;
@ -282,14 +281,14 @@ void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
free(surface); free(surface);
} }
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface) bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
{ {
return surface->lost; return surface->lost;
} }
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface) void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
{ {
surface->lost = FALSE; surface->lost = false;
} }
unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height) unsigned char* RenderBackend_LockSurface(RenderBackend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
@ -349,7 +348,7 @@ void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int wi
free(buffer); free(buffer);
} }
void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key) void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{ {
if (source_surface == NULL || destination_surface == NULL) if (source_surface == NULL || destination_surface == NULL)
return; return;
@ -370,7 +369,7 @@ void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect,
Backend_PrintError("Couldn't copy part of texture to rendering target: %s", SDL_GetError()); Backend_PrintError("Couldn't copy part of texture to rendering target: %s", SDL_GetError());
} }
void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue) void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
{ {
if (surface == NULL) if (surface == NULL)
return; return;
@ -474,7 +473,7 @@ void RenderBackend_FlushGlyphs(void)
void RenderBackend_HandleRenderTargetLoss(void) void RenderBackend_HandleRenderTargetLoss(void)
{ {
for (RenderBackend_Surface *surface = surface_list_head; surface != NULL; surface = surface->next) for (RenderBackend_Surface *surface = surface_list_head; surface != NULL; surface = surface->next)
surface->lost = TRUE; surface->lost = true;
} }
void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height) void RenderBackend_HandleWindowResize(unsigned int width, unsigned int height)

View file

@ -4,8 +4,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "../../WindowsWrapper.h"
#include "../Misc.h" #include "../Misc.h"
#include "../Window-Software.h" #include "../Window-Software.h"
#include "../../Attributes.h" #include "../../Attributes.h"
@ -33,7 +31,7 @@ static RenderBackend_Surface framebuffer;
static unsigned char glyph_colour_channels[3]; static unsigned char glyph_colour_channels[3];
static RenderBackend_Surface *glyph_destination_surface; static RenderBackend_Surface *glyph_destination_surface;
RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen) RenderBackend_Surface* RenderBackend_Init(const char *window_title, int screen_width, int screen_height, bool fullscreen)
{ {
size_t pitch; size_t pitch;
framebuffer.pixels = WindowBackend_Software_CreateWindow(window_title, screen_width, screen_height, fullscreen, &pitch); framebuffer.pixels = WindowBackend_Software_CreateWindow(window_title, screen_width, screen_height, fullscreen, &pitch);
@ -91,11 +89,11 @@ void RenderBackend_FreeSurface(RenderBackend_Surface *surface)
free(surface); free(surface);
} }
BOOL RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface) bool RenderBackend_IsSurfaceLost(RenderBackend_Surface *surface)
{ {
(void)surface; (void)surface;
return FALSE; return false;
} }
void RenderBackend_RestoreSurface(RenderBackend_Surface *surface) void RenderBackend_RestoreSurface(RenderBackend_Surface *surface)
@ -122,12 +120,12 @@ void RenderBackend_UnlockSurface(RenderBackend_Surface *surface, unsigned int wi
(void)height; (void)height;
} }
ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RECT *rect, RenderBackend_Surface *destination_surface, long x, long y, BOOL colour_key) ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, const RenderBackend_Rect *rect, RenderBackend_Surface *destination_surface, long x, long y, bool colour_key)
{ {
if (source_surface == NULL || destination_surface == NULL) if (source_surface == NULL || destination_surface == NULL)
return; return;
RECT rect_clamped; RenderBackend_Rect rect_clamped;
rect_clamped.left = rect->left; rect_clamped.left = rect->left;
rect_clamped.top = rect->top; rect_clamped.top = rect->top;
@ -205,12 +203,12 @@ ATTRIBUTE_HOT void RenderBackend_Blit(RenderBackend_Surface *source_surface, con
} }
} }
ATTRIBUTE_HOT void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue) ATTRIBUTE_HOT void RenderBackend_ColourFill(RenderBackend_Surface *surface, const RenderBackend_Rect *rect, unsigned char red, unsigned char green, unsigned char blue)
{ {
if (surface == NULL) if (surface == NULL)
return; return;
RECT rect_clamped; RenderBackend_Rect rect_clamped;
rect_clamped.left = rect->left; rect_clamped.left = rect->left;
rect_clamped.top = rect->top; rect_clamped.top = rect->top;

View file

@ -2,7 +2,6 @@
#include "Controller.h" #include "Controller.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h>
#include "SDL.h" #include "SDL.h"

View file

@ -2,7 +2,5 @@
#include "SDL.h" #include "SDL.h"
#include "../../WindowsWrapper.h"
void ControllerBackend_JoystickConnect(Sint32 joystick_id); void ControllerBackend_JoystickConnect(Sint32 joystick_id);
void ControllerBackend_JoystickDisconnect(Sint32 joystick_id); void ControllerBackend_JoystickDisconnect(Sint32 joystick_id);

View file

@ -1,15 +1,12 @@
#include "../Misc.h" #include "../Misc.h"
#include <stddef.h> #include <stddef.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <string> #include <string>
#include "SDL.h" #include "SDL.h"
#include "../../WindowsWrapper.h"
#include "Controller.h" #include "Controller.h"
#include "Window.h" #include "Window.h"
#include "../Rendering.h" #include "../Rendering.h"
@ -23,13 +20,13 @@
keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \ keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \
break; break;
static BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL]; static bool keyboard_state[BACKEND_KEYBOARD_TOTAL];
static unsigned char *cursor_surface_pixels; static unsigned char *cursor_surface_pixels;
static SDL_Surface *cursor_surface; static SDL_Surface *cursor_surface;
static SDL_Cursor *cursor; static SDL_Cursor *cursor;
BOOL Backend_Init(void) bool Backend_Init(void)
{ {
if (SDL_Init(SDL_INIT_EVENTS) == 0) if (SDL_Init(SDL_INIT_EVENTS) == 0)
{ {
@ -46,7 +43,7 @@ BOOL Backend_Init(void)
{ {
Backend_PrintInfo("Selected SDL video driver: %s", driver); Backend_PrintInfo("Selected SDL video driver: %s", driver);
return TRUE; return true;
} }
else else
{ {
@ -67,7 +64,7 @@ BOOL Backend_Init(void)
Backend_ShowMessageBox("Fatal error", error_message.c_str()); Backend_ShowMessageBox("Fatal error", error_message.c_str());
} }
return FALSE; return false;
} }
void Backend_Deinit(void) void Backend_Deinit(void)
@ -88,11 +85,11 @@ void Backend_PostWindowCreation(void)
} }
BOOL Backend_GetBasePath(char *string_buffer) bool Backend_GetBasePath(char *string_buffer)
{ {
char *base_path = SDL_GetBasePath(); char *base_path = SDL_GetBasePath();
if (base_path == NULL) if (base_path == NULL)
return FALSE; return false;
// Trim the trailing '/' // Trim the trailing '/'
size_t base_path_length = strlen(base_path); size_t base_path_length = strlen(base_path);
@ -100,7 +97,7 @@ BOOL Backend_GetBasePath(char *string_buffer)
strcpy(string_buffer, base_path); strcpy(string_buffer, base_path);
SDL_free(base_path); SDL_free(base_path);
return TRUE; return true;
} }
void Backend_HideMouse(void) void Backend_HideMouse(void)
@ -155,14 +152,14 @@ void PlaybackBackend_EnableDragAndDrop(void)
SDL_EventState(SDL_DROPFILE, SDL_ENABLE); SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
} }
BOOL Backend_SystemTask(BOOL active) bool Backend_SystemTask(bool active)
{ {
if (SDL_PollEvent(NULL) || !active) if (SDL_PollEvent(NULL) || !active)
{ {
SDL_Event event; SDL_Event event;
if (!SDL_WaitEvent(&event)) if (!SDL_WaitEvent(&event))
return FALSE; return false;
switch (event.type) switch (event.type)
{ {
@ -286,7 +283,7 @@ BOOL Backend_SystemTask(BOOL active)
case SDL_QUIT: case SDL_QUIT:
StopOrganyaMusic(); StopOrganyaMusic();
return FALSE; return false;
case SDL_RENDER_TARGETS_RESET: case SDL_RENDER_TARGETS_RESET:
RenderBackend_HandleRenderTargetLoss(); RenderBackend_HandleRenderTargetLoss();
@ -295,10 +292,10 @@ BOOL Backend_SystemTask(BOOL active)
} }
} }
return TRUE; return true;
} }
void Backend_GetKeyboardState(BOOL *out_keyboard_state) void Backend_GetKeyboardState(bool *out_keyboard_state)
{ {
memcpy(out_keyboard_state, keyboard_state, sizeof(keyboard_state)); memcpy(out_keyboard_state, keyboard_state, sizeof(keyboard_state));
} }

View file

@ -11,8 +11,6 @@
#endif #endif
#include "SDL.h" #include "SDL.h"
#include "../../WindowsWrapper.h"
#include "../Misc.h" #include "../Misc.h"
#include "../../Resource.h" #include "../../Resource.h"
@ -20,7 +18,7 @@ SDL_Window *window;
static SDL_GLContext context; static SDL_GLContext context;
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen) bool WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, bool fullscreen)
{ {
#ifdef USE_OPENGLES2 #ifdef USE_OPENGLES2
if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES) < 0) if (SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES) < 0)
@ -67,7 +65,7 @@ BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_wid
#endif #endif
Backend_PostWindowCreation(); Backend_PostWindowCreation();
return TRUE; return true;
#ifndef USE_OPENGLES2 #ifndef USE_OPENGLES2
} }
else else
@ -103,7 +101,7 @@ BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_wid
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", error_message.c_str()); Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", error_message.c_str());
} }
return FALSE; return false;
} }
void WindowBackend_OpenGL_DestroyWindow(void) void WindowBackend_OpenGL_DestroyWindow(void)

View file

@ -7,8 +7,6 @@
#include "SDL.h" #include "SDL.h"
#include "../../WindowsWrapper.h"
#include "../Misc.h" #include "../Misc.h"
SDL_Window *window; SDL_Window *window;
@ -16,7 +14,7 @@ SDL_Window *window;
static SDL_Surface *window_sdlsurface; static SDL_Surface *window_sdlsurface;
static SDL_Surface *framebuffer_sdlsurface; static SDL_Surface *framebuffer_sdlsurface;
unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, BOOL fullscreen, size_t *pitch) unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen, size_t *pitch)
{ {
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0); window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screen_width, screen_height, 0);

View file

@ -2,6 +2,6 @@
#include "../WindowsWrapper.h" #include "../WindowsWrapper.h"
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen); bool WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, bool fullscreen);
void WindowBackend_OpenGL_DestroyWindow(void); void WindowBackend_OpenGL_DestroyWindow(void);
void WindowBackend_OpenGL_Display(void); void WindowBackend_OpenGL_Display(void);

View file

@ -2,9 +2,7 @@
#include <stddef.h> #include <stddef.h>
#include "../WindowsWrapper.h" unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen, size_t *pitch);
unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, BOOL fullscreen, size_t *pitch);
void WindowBackend_Software_DestroyWindow(void); void WindowBackend_Software_DestroyWindow(void);
void WindowBackend_Software_Display(void); void WindowBackend_Software_Display(void);
void WindowBackend_Software_HandleWindowResize(unsigned int width, unsigned int height); void WindowBackend_Software_HandleWindowResize(unsigned int width, unsigned int height);

View file

@ -412,7 +412,7 @@ BOOL MakeSurface_Generic(int bxsize, int bysize, SurfaceID surf_no, BOOL bSystem
void BackupSurface(SurfaceID surf_no, const RECT *rect) void BackupSurface(SurfaceID surf_no, const RECT *rect)
{ {
static RECT scaled_rect; static RenderBackend_Rect scaled_rect;
scaled_rect.left = rect->left * magnification; scaled_rect.left = rect->left * magnification;
scaled_rect.top = rect->top * magnification; scaled_rect.top = rect->top * magnification;
scaled_rect.right = rect->right * magnification; scaled_rect.right = rect->right * magnification;
@ -423,9 +423,12 @@ void BackupSurface(SurfaceID surf_no, const RECT *rect)
void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // Transparency void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // Transparency
{ {
static RECT rcWork; static RenderBackend_Rect rcWork;
rcWork = *rect; rcWork.left = rect->left;
rcWork.top = rect->top;
rcWork.right = rect->right;
rcWork.bottom = rect->bottom;
if (x + rect->right - rect->left > rcView->right) if (x + rect->right - rect->left > rcView->right)
rcWork.right -= (x + rect->right - rect->left) - rcView->right; rcWork.right -= (x + rect->right - rect->left) - rcView->right;
@ -455,9 +458,12 @@ void PutBitmap3(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID surf_no) // No Transparency
{ {
static RECT rcWork; static RenderBackend_Rect rcWork;
rcWork = *rect; rcWork.left = rect->left;
rcWork.top = rect->top;
rcWork.right = rect->right;
rcWork.bottom = rect->bottom;
if (x + rect->right - rect->left > rcView->right) if (x + rect->right - rect->left > rcView->right)
rcWork.right -= (x + rect->right - rect->left) - rcView->right; rcWork.right -= (x + rect->right - rect->left) - rcView->right;
@ -487,7 +493,7 @@ void PutBitmap4(const RECT *rcView, int x, int y, const RECT *rect, SurfaceID su
void Surface2Surface(int x, int y, const RECT *rect, int to, int from) void Surface2Surface(int x, int y, const RECT *rect, int to, int from)
{ {
static RECT rcWork; static RenderBackend_Rect rcWork;
rcWork.left = rect->left * magnification; rcWork.left = rect->left * magnification;
rcWork.top = rect->top * magnification; rcWork.top = rect->top * magnification;
@ -505,7 +511,7 @@ unsigned long GetCortBoxColor(unsigned long col)
void CortBox(const RECT *rect, unsigned long col) void CortBox(const RECT *rect, unsigned long col)
{ {
static RECT dst_rect; static RenderBackend_Rect dst_rect;
dst_rect.left = rect->left * magnification; dst_rect.left = rect->left * magnification;
dst_rect.top = rect->top * magnification; dst_rect.top = rect->top * magnification;
dst_rect.right = rect->right * magnification; dst_rect.right = rect->right * magnification;
@ -520,7 +526,7 @@ void CortBox(const RECT *rect, unsigned long col)
void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no) void CortBox2(const RECT *rect, unsigned long col, SurfaceID surf_no)
{ {
static RECT dst_rect; static RenderBackend_Rect dst_rect;
dst_rect.left = rect->left * magnification; dst_rect.left = rect->left * magnification;
dst_rect.top = rect->top * magnification; dst_rect.top = rect->top * magnification;
dst_rect.right = rect->right * magnification; dst_rect.right = rect->right * magnification;

View file

@ -19,7 +19,7 @@ BOOL InitDirectInput(void)
BOOL GetJoystickStatus(JOYSTICK_STATUS *status) BOOL GetJoystickStatus(JOYSTICK_STATUS *status)
{ {
BOOL *buttons; bool *buttons;
unsigned int button_count; unsigned int button_count;
short *axes; short *axes;
@ -63,7 +63,7 @@ BOOL GetJoystickStatus(JOYSTICK_STATUS *status)
BOOL ResetJoystickStatus(void) BOOL ResetJoystickStatus(void)
{ {
BOOL *buttons; bool *buttons;
unsigned int button_count; unsigned int button_count;
short *axes; short *axes;

View file

@ -395,7 +395,7 @@ BOOL SystemTask(void)
return FALSE; return FALSE;
} while(!bActive); } while(!bActive);
BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL]; bool keyboard_state[BACKEND_KEYBOARD_TOTAL];
Backend_GetKeyboardState(keyboard_state); Backend_GetKeyboardState(keyboard_state);
for (unsigned int i = 0; i < BACKEND_KEYBOARD_TOTAL; ++i) for (unsigned int i = 0; i < BACKEND_KEYBOARD_TOTAL; ++i)

View file

@ -398,6 +398,11 @@ void PlayDramObject(unsigned char key, int mode, signed char track)
ORGDATA org_data; ORGDATA org_data;
static void OrganyaCallback(void)
{
org_data.PlayData();
}
OrgData::OrgData(void) OrgData::OrgData(void)
{ {
for (int i = 0; i < MAXTRACK; i++) for (int i = 0; i < MAXTRACK; i++)
@ -830,7 +835,7 @@ void PlayOrganyaMusic(void)
if (!audio_backend_initialised) if (!audio_backend_initialised)
return; return;
AudioBackend_SetOrganyaTimer(org_data.info.wait); AudioBackend_SetOrganyaCallback(OrganyaCallback, org_data.info.wait);
} }
BOOL ChangeOrganyaVolume(signed int volume) BOOL ChangeOrganyaVolume(signed int volume)
@ -850,7 +855,7 @@ void StopOrganyaMusic(void)
if (!audio_backend_initialised) if (!audio_backend_initialised)
return; return;
AudioBackend_SetOrganyaTimer(0); AudioBackend_SetOrganyaCallback(NULL, 0);
// Stop notes // Stop notes
for (int i = 0; i < MAXMELODY; i++) for (int i = 0; i < MAXMELODY; i++)
@ -873,7 +878,7 @@ void EndOrganya(void)
if (!audio_backend_initialised) if (!audio_backend_initialised)
return; return;
AudioBackend_SetOrganyaTimer(0); AudioBackend_SetOrganyaCallback(NULL, 0);
// Release everything related to org // Release everything related to org
org_data.ReleaseNote(); org_data.ReleaseNote();
@ -884,8 +889,3 @@ void EndOrganya(void)
ReleaseOrganyaObject(i); ReleaseOrganyaObject(i);
} }
} }
void UpdateOrganya(void)
{
org_data.PlayData();
}

View file

@ -20,4 +20,3 @@ void StopOrganyaMusic(void);
void SetOrganyaFadeout(void); void SetOrganyaFadeout(void);
BOOL StartOrganya(const char *wave_filename); BOOL StartOrganya(const char *wave_filename);
void EndOrganya(void); void EndOrganya(void);
void UpdateOrganya(void);