no loading between levels, many improvements in code

This commit is contained in:
Ondřej Novák 2025-01-31 18:54:59 +01:00
parent 77f1700902
commit a8a87d514c
55 changed files with 628 additions and 763 deletions

View file

@ -89,13 +89,13 @@ int DxGetResY() {
void setvesa_displaystart(int x,int y){
}
void StripBlt(void *data, unsigned int startline, uint32_t width) {
void StripBlt(const void *data, unsigned int startline, uint32_t width) {
unsigned short *start=startline*GetScreenPitch()+GetScreenAdr();
while (width--)
{
memcpy(start,data,640*2);
data=(void *)(reinterpret_cast<short *>(data)+GetScreenPitch());
data=(void *)(reinterpret_cast<const short *>(data)+GetScreenPitch());
start=start+GetScreenPitch();
}
@ -214,6 +214,12 @@ void DxDoneTurn(void *handle) {
sdl.swap_display_buffers(); //present hidden buffer
}
void DxTurnLeftRight(char right, float phase, int border, int ypos, int *last) {
char game_display_is_quit_requested() {
return get_sdl_global_context().is_quit_requested()?1:0;
}
void game_display_cancel_quit_request() {
return get_sdl_global_context().cancel_quit_request();
}

View file

@ -21,8 +21,8 @@ void RedirectScreenBufferSecond(void);
char game_display_init(const INI_CONFIG_SECTION *display_section, const char *title);
void game_display_close(void);
void game_display_update_rect(unsigned short x,unsigned short y,unsigned short xs,unsigned short ys);
char game_display_is_quit_requested();
void game_display_cancel_quit_request();
void *DxPrepareWalk(int ypos);
void DxZoomWalk(void *handle, int ypos, int *points,float phase, void *lodka);
@ -49,7 +49,7 @@ void DXMouseTransform(unsigned short *x, unsigned short *y);
//HWND GetGameWindow();
//void DxLockBuffers(BOOL lock);
void StripBlt(void *data, unsigned int startline, uint32_t width);
void StripBlt(const void *data, unsigned int startline, uint32_t width);
#ifdef __cplusplus

View file

@ -125,7 +125,8 @@ constexpr auto sdl_keycode_map = KeyCodeMap({
{SDL_SCANCODE_KP_8,0x4838,0x4800,0x8D00},
{SDL_SCANCODE_KP_9,0x4939,0x4900,0x8400},
{SDL_SCANCODE_KP_0,0x5230,0x5200,0x9200},
{SDL_SCANCODE_KP_PERIOD,0x532E,0x5300,0x9300}
{SDL_SCANCODE_KP_PERIOD,0x532E,0x5300,0x9300},
{SDL_SCANCODE_KP_ENTER,0x1C0D,0x1C0D,0x1C0D}
});

View file

@ -186,16 +186,13 @@ void SDLContext::event_loop(std::stop_token stp) {
SDL_Event e;
while (SDL_WaitEvent(&e)) {
if (e.type == SDL_QUIT) {
return;
}
if (e.type == exit_loop_event) {
return;
}
if (e.type == _update_request_event) {
_quit_requested = true;
if (_quit_callback) _quit_callback();
} else if (e.type == exit_loop_event) {
break;
} else if (e.type == _update_request_event) {
update_screen();
}
if (e.type == SDL_WINDOWEVENT) {
} else if (e.type == SDL_WINDOWEVENT) {
if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
_crt_effect.reset();
}
@ -501,7 +498,7 @@ SDL_Rect SDLContext::to_window_rect(const SDL_Rect &winrc, const SDL_Rect &sourc
SDL_Point wpt1(to_window_point(winrc, pt1));
SDL_Point wpt2(to_window_point(winrc, pt2));
return {wpt1.x, wpt1.y, wpt2.x - wpt1.x, wpt2.y - wpt1.y};
}
void SDLContext::set_quit_callback(std::function<void()> fn) {
_quit_callback = std::move(fn);
}

View file

@ -6,6 +6,7 @@
#include <thread>
#include <vector>
#include <libs/mouse.h>
#include <functional>
#include <queue>
@ -38,6 +39,7 @@ public:
void show_slide_transition(const SDL_Rect &visible_from, const SDL_Rect &visible_where,
const SDL_Rect &hidden_from, const SDL_Rect &hidden_where);
void set_quit_callback(std::function<void()> fn);
MS_EVENT getMsEvent() {
std::lock_guard _(_mx);
MS_EVENT out = ms_event;
@ -58,6 +60,12 @@ public:
bool is_keyboard_ready() const;
std::uint16_t pop_keyboard_code() ;
bool is_quit_requested() const {
return _quit_requested;
}
void cancel_quit_request() {
_quit_requested = false;
}
protected:
@ -97,6 +105,7 @@ protected:
int aspect_x = 4;
int aspect_y = 3;
bool crt_filter_enabled = false;
std::function<void()> _quit_callback;
std::unique_ptr<SDL_Window, SDL_Deleter> _window;
std::unique_ptr<SDL_Renderer, SDL_Deleter> _renderer;
@ -108,12 +117,12 @@ protected:
std::jthread _render_thread;
bool _quit_requested = false;
bool _fullscreen_mode = false;
bool _present = false;
std::atomic<bool> _key_control = false;
std::atomic<bool> _key_shift = false;
std::atomic<bool> _key_capslock = false;
std::atomic<bool> _quit_requested = false;
std::vector<char> _display_update_queue;

View file

@ -11,7 +11,7 @@ char start_mixing() {
void stop_mixing() {
}
void play_sample(int channel,void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type) {
void play_sample(int channel,const void *sample,int32_t size,int32_t lstart,int32_t sfreq,int type) {
}
void set_channel_volume(int channel,int left,int right) {
@ -50,7 +50,7 @@ void mute_channel(int channel) {
void chan_break_loop(int channel) {
}
void chan_break_ext(int channel,void *org_sample,int32_t size_sample) {
void chan_break_ext(int channel,const void *org_sample,int32_t size_sample) {
}
@ -67,7 +67,7 @@ int get_snd_effect(int funct) {
void *PrepareVideoSound(int mixfreq, int buffsize) {
return 0;
}
char LoadNextVideoFrame(void *buffer, char *data, int size, short *xlat, short *accnums, int32_t *writepos) {
char LoadNextVideoFrame(void *buffer, const char *data, int size, const short *xlat, short *accnums, int32_t *writepos) {
std::this_thread::sleep_for(std::chrono::milliseconds(20));
return 1;