This commit is contained in:
Toby Jaffey 2025-12-12 15:02:20 +00:00
parent bba5fa654c
commit 3722e4c267
2 changed files with 4 additions and 5 deletions

View file

@ -9,7 +9,7 @@ LIBS = `pkg-config sdl3 --libs --static`
CFLAGS += `pkg-config sdl3 --cflags` CFLAGS += `pkg-config sdl3 --cflags`
endif endif
#CFLAGS += -Wall -Werror CFLAGS += -Wall -Werror
CFLAGS += -pedantic -std=c99 -O3 CFLAGS += -pedantic -std=c99 -O3
CFLAGS += -DUVM32_MEMORY_SIZE=$(shell echo "1024 * 1024 * 8" | bc) CFLAGS += -DUVM32_MEMORY_SIZE=$(shell echo "1024 * 1024 * 8" | bc)

View file

@ -101,8 +101,6 @@ int main(int argc, char *argv[]) {
SDL_Renderer *renderer = NULL; SDL_Renderer *renderer = NULL;
SDL_Window *screen = NULL; SDL_Window *screen = NULL;
SDL_Event event; SDL_Event event;
SDL_Surface *surface = NULL;
SDL_Texture *tex = NULL;
SDL_Texture *render_target = NULL; SDL_Texture *render_target = NULL;
// memory for vmst is very large, so allocate // memory for vmst is very large, so allocate
@ -263,14 +261,15 @@ int main(int argc, char *argv[]) {
case UVM32_SYSCALL_RENDER: { case UVM32_SYSCALL_RENDER: {
uvm32_evt_syscall_buf_t buf = uvm32_getbuf(vmst, &evt, ARG0, ARG1); uvm32_evt_syscall_buf_t buf = uvm32_getbuf(vmst, &evt, ARG0, ARG1);
// copy into texture
void* dst; void* dst;
const unsigned char* src = buf.ptr; const uint8_t* src = buf.ptr;
int src_pitch = WIDTH * 4; int src_pitch = WIDTH * 4;
int dst_pitch; int dst_pitch;
if (SDL_LockTexture(render_target, NULL, &dst, &dst_pitch)) { if (SDL_LockTexture(render_target, NULL, &dst, &dst_pitch)) {
for (int y = 0; y < HEIGHT; y++) { for (int y = 0; y < HEIGHT; y++) {
memcpy(dst, src, src_pitch); memcpy(dst, src, src_pitch);
dst = (unsigned char*)dst + dst_pitch; dst = (uint8_t*)dst + dst_pitch;
src += src_pitch; src += src_pitch;
} }
SDL_UnlockTexture(render_target); SDL_UnlockTexture(render_target);