1
0
mirror of https://github.com/Interlisp/maiko.git synced 2026-05-03 23:09:34 +00:00

Refactor, only bitblt once per "frame".

This commit is contained in:
Peter
2021-10-21 08:48:33 +02:00
parent 333c132e40
commit 7b7db9aac5
3 changed files with 33 additions and 13 deletions

View File

@@ -274,7 +274,7 @@ in_display_segment(baseaddr)
void flush_display_buffer() { void flush_display_buffer() {
// printf("flush_display_buffer\n"); // printf("flush_display_buffer\n");
#ifdef SDL #ifdef SDL
sdl_bitblt_to_screen(0, 0, sdl_displaywidth, sdl_displayheight); // sdl_bitblt_to_screen(0, 0, sdl_displaywidth, sdl_displayheight);
#endif #endif
#ifdef XWINDOW #ifdef XWINDOW
(currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, currentdsp->Visible.x, (currentdsp->bitblt_to_screen)(currentdsp, DisplayRegion68k, currentdsp->Visible.x,
@@ -308,7 +308,7 @@ void flush_display_region(int x, int y, int w, int h)
{ {
// printf("flush_display_region %d %d %d %d\n", x, y, w, h); // printf("flush_display_region %d %d %d %d\n", x, y, w, h);
#ifdef SDL #ifdef SDL
sdl_bitblt_to_screen(x, y, w, h); // sdl_bitblt_to_screen(x, y, w, h);
#endif #endif
#if (defined(XWINDOW) || defined(DOS)) #if (defined(XWINDOW) || defined(DOS))
TPRINT(("Enter flush_display_region x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); TPRINT(("Enter flush_display_region x=%d, y=%d, w=%d, h=%d\n", x, y, w, h));
@@ -354,7 +354,7 @@ void flush_display_lineregion(UNSIGNED x, DLword *ybase, UNSIGNED w, UNSIGNED h)
y = ((DLword *)ybase - DisplayRegion68k) / DLWORD_PERLINE; y = ((DLword *)ybase - DisplayRegion68k) / DLWORD_PERLINE;
// printf("flush_display_lineregion %d %d %d %d\n", x, y, w, h); // printf("flush_display_lineregion %d %d %d %d\n", x, y, w, h);
#ifdef SDL #ifdef SDL
sdl_bitblt_to_screen(x, y, w, h); // sdl_bitblt_to_screen(x, y, w, h);
#endif #endif
#if (defined(XWINDOW) || defined(DOS)) #if (defined(XWINDOW) || defined(DOS))
TPRINT(("Enter flush_display_lineregion x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); TPRINT(("Enter flush_display_lineregion x=%d, y=%d, w=%d, h=%d\n", x, y, w, h));
@@ -388,7 +388,7 @@ void flush_display_ptrregion(DLword *ybase, UNSIGNED bitoffset, UNSIGNED w, UNSI
x = bitoffset + (BITSPERWORD * (baseoffset - (DLWORD_PERLINE * y))); x = bitoffset + (BITSPERWORD * (baseoffset - (DLWORD_PERLINE * y)));
// printf("flush_display_ptrregion %d %d %d %d\n", x, y, w, h); // printf("flush_display_ptrregion %d %d %d %d\n", x, y, w, h);
#ifdef SDL #ifdef SDL
sdl_bitblt_to_screen(x, y, w, h); // sdl_bitblt_to_screen(x, y, w, h);
#endif #endif
#if (defined(XWINDOW) || defined(DOS)) #if (defined(XWINDOW) || defined(DOS))
TPRINT(("Enter flush_display_ptrregion\n x=%d, y=%d, w=%d, h=%d\n", x, y, w, h)); TPRINT(("Enter flush_display_ptrregion\n x=%d, y=%d, w=%d, h=%d\n", x, y, w, h));

View File

@@ -249,7 +249,9 @@ int flushing = FALSE; /* see dbprint.h if set, all debug/trace printing will cal
#include "devif.h" #include "devif.h"
extern DspInterface currentdsp; extern DspInterface currentdsp;
#endif /* DOS || XWINDOW */ #endif /* DOS || XWINDOW */
#ifdef SDL
extern int init_SDL(int, int, int);
#endif
extern time_t MDate; extern time_t MDate;
extern int nokbdflag; extern int nokbdflag;
extern int nomouseflag; extern int nomouseflag;
@@ -516,7 +518,7 @@ int main(int argc, char *argv[])
make_dsp_instance(currentdsp, 0, 0, 0, 1); /* All defaults the first time */ make_dsp_instance(currentdsp, 0, 0, 0, 1); /* All defaults the first time */
#endif /* DOS || XWINDOW */ #endif /* DOS || XWINDOW */
#if defined(SDL) #if defined(SDL)
init_SDL(1600, 1024, 1); init_SDL(1888, 1110, 1);
#endif /* SDL */ #endif /* SDL */
/* Load sysout to VM space and returns real sysout_size(not 0) */ /* Load sysout to VM space and returns real sysout_size(not 0) */
sysout_size = sysout_loader(sysout_name, sysout_size); sysout_size = sysout_loader(sysout_name, sysout_size);

View File

@@ -201,15 +201,21 @@ void set_pixel(SDL_Surface *surface, int x, int y, Uint32 pixel)
+ x * surface->format->BytesPerPixel); + x * surface->format->BytesPerPixel);
*target_pixel = pixel; *target_pixel = pixel;
} }
int should_update_texture = 0;
void sdl_bitblt_to_screen(int _x, int _y, int _w, int _h) { void sdl_bitblt_to_screen(int _x, int _y, int _w, int _h) {
// printf("bitblting\n"); // printf("bitblting\n");
int before = SDL_GetTicks(); int before = SDL_GetTicks();
int width = sdl_displaywidth; int width = sdl_displaywidth;
int height = sdl_displayheight; int height = sdl_displayheight;
int bpw = 32; int bpw = 32;
for(int y = _y; y < _y + _h; y++) { int pitch = sdl_displaywidth / bpw;
for(int x = _x / bpw; x < (_x + _w + bpw - 1) / bpw; x++) { int xlimit = (_x + _w + bpw - 1) / bpw;
int w = DisplayRegion68k[y*(sdl_displaywidth/bpw) + x]; int ylimit = _y + _h;
for(int y = _y; y < ylimit; y++) {
for(int x = _x / bpw; x < xlimit; x++) {
int w = DisplayRegion68k[y * pitch + x];
int thex = x * bpw;
for(int b = 0; b < bpw; b++) { for(int b = 0; b < bpw; b++) {
//printf("%d/%d %d\n", x, y, b); //printf("%d/%d %d\n", x, y, b);
int px = 0; int px = 0;
@@ -219,11 +225,12 @@ void sdl_bitblt_to_screen(int _x, int _y, int _w, int _h) {
px = 0xffffffff; px = 0xffffffff;
} }
//printf("px is %x\n", px); //printf("px is %x\n", px);
int xx = x * bpw + b; int xx = thex + b;
buffer[y * sdl_displaywidth + xx] = px; buffer[y * sdl_displaywidth + xx] = px;
} }
} }
} }
should_update_texture = 1;
int after = SDL_GetTicks(); int after = SDL_GetTicks();
// printf("bitblting took %dms\n", after - before); // printf("bitblting took %dms\n", after - before);
/* before = SDL_GetTicks(); */ /* before = SDL_GetTicks(); */
@@ -401,14 +408,25 @@ void process_SDLevents() {
// handle_keyboard(); // handle_keyboard();
/* sdl_bitblt_to_screen(); */ /* sdl_bitblt_to_screen(); */
// SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32)); // SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32));
int before = SDL_GetTicks(); int before = 0;
SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32)); int after = 0;
int after = SDL_GetTicks(); /* if(should_update_texture) { */
/* before = SDL_GetTicks(); */
/* SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32)); */
/* after = SDL_GetTicks(); */
/* should_update_texture = 0; */
/* } */
// printf("UpdateTexture took %dms\n", after - before); // printf("UpdateTexture took %dms\n", after - before);
int this_draw = SDL_GetTicks(); int this_draw = SDL_GetTicks();
before = SDL_GetTicks(); before = SDL_GetTicks();
// printf("processing events took %dms\n", before - process_events_time); // printf("processing events took %dms\n", before - process_events_time);
if(this_draw - last_draw > 16) { if(this_draw - last_draw > 16) {
before = SDL_GetTicks();
SDL_UpdateTexture(sdl_texture, NULL, buffer, sdl_displaywidth * sizeof(Uint32));
after = SDL_GetTicks();
should_update_texture = 0;
sdl_bitblt_to_screen(0, 0, sdl_displaywidth, sdl_displayheight);
SDL_RenderClear(sdl_renderer); SDL_RenderClear(sdl_renderer);
SDL_Rect r; SDL_Rect r;
r.x = 0; r.x = 0;