Files
nunuhara_xsystem4/sdl_video.c
T
Nunuhara Cabbage a9de3b76fb Implement SACT2.Update()
Really lazy implementation for now, just draws all sprites every frame.
In the future should implement proper compositing with damage tracking.

All CG types other than QNT are removed. From what I've seen, System 4
games use QNT, PNG, AJP (encrypted JPEG) and DCF (seems to be a format
for partial CG updates). QNT is by far the most common format.
2019-11-17 21:44:16 -08:00

95 lines
2.4 KiB
C

/* Copyright (C) 2019 Nunuhara Cabbage <nunuhara@haniwa.technology>
* Copyright (C) 2000- Fumihiko Murata <fmurata@p1.tcnet.ne.jp>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://gnu.org/licenses/>.
*/
#include <string.h>
#include <SDL.h>
#include "system4.h"
#include "sdl_core.h"
#include "sdl_private.h"
int sdl_initialize(void)
{
memset(&sdl, 0, sizeof(struct sdl_private_data));
// make toplevel window
SDL_Init(SDL_INIT_VIDEO);
sdl.window = SDL_CreateWindow("XSystem4",
SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED,
config.view_width,
config.view_height,
SDL_WINDOW_RESIZABLE);
sdl.renderer = SDL_CreateRenderer(sdl.window, -1, 0);
// offscreen pixmap
//makeDIB(config.view_width, config.view_height, SYS4_DEFAULT_DEPTH);
// init cursor
//sdl_cursor_init();
sdl_set_window_size(0, 0, config.view_width, config.view_height);
//sdl_shadow_init();
//joy_open();
return 0;
}
void sdl_remove(void)
{
if (!sdl.window)
return;
//SDL_FreeSurface(sdl.dib);
SDL_DestroyRenderer(sdl.renderer);
//joy_close();
SDL_Quit();
}
void sdl_fullscreen(bool on)
{
if (on && !sdl.fs_on) {
sdl.fs_on = true;
SDL_SetWindowFullscreen(sdl.window, SDL_WINDOW_FULLSCREEN_DESKTOP);
} else if (!on && sdl.fs_on) {
sdl.fs_on = false;
SDL_SetWindowFullscreen(sdl.window, 0);
}
}
void sdl_set_window_size(int x, int y, int w, int h)
{
sdl.view.x = x;
sdl.view.y = y;
if (w == sdl.view.w && h == sdl.view.h)
return;
sdl.view.w = w;
sdl.view.h = h;
SDL_SetWindowSize(sdl.window, w, h);
SDL_RenderSetLogicalSize(sdl.renderer, w, h);
if (sdl.display)
SDL_FreeSurface(sdl.display);
if (sdl.texture)
SDL_DestroyTexture(sdl.texture);
sdl.display = SDL_CreateRGBSurface(0, w, h, 32, 0xFF00, 0xFF0000, 0xFF000000, 0xFF);
sdl.texture = SDL_CreateTexture(sdl.renderer, sdl.display->format->format,
SDL_TEXTUREACCESS_STATIC, w, h);
}