From 8bf0b4eebf5d06a4daefefcf3d6dd7491c2cd1f9 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 15 May 2016 12:02:56 -0700 Subject: Fixed a really egregious bug in the arena implementation. Not sure how this even worked at all before. --- arena.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arena.c b/arena.c index 6bc50e0..50a5594 100644 --- a/arena.c +++ b/arena.c @@ -17,6 +17,8 @@ struct arena { size_t free_storage; }; +#define DEFAULT_STORAGE_SIZE 8 + static arena *current_arena; arena *get_current_arena() @@ -45,7 +47,11 @@ void track_block(void *block) { arena *cur = get_current_arena(); if (cur->used_count == cur->used_storage) { - cur->used_storage *= 2; + if (cur->used_storage) { + cur->used_storage *= 2; + } else { + cur->used_storage = DEFAULT_STORAGE_SIZE; + } cur->used_blocks = realloc(cur->used_blocks, cur->used_storage * sizeof(void *)); } cur->used_blocks[cur->used_count++] = block; -- cgit v1.2.3 From fa1f11299e32d7886ef05bd9ff453a963069bbaa Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 15 May 2016 12:10:49 -0700 Subject: Fixed a bug in get_header_name that results in a crash if the "International Name" field is blank --- romdb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/romdb.c b/romdb.c index 149814c..7fba5ef 100644 --- a/romdb.c +++ b/romdb.c @@ -418,7 +418,7 @@ char *get_header_name(uint8_t *rom) } } else { last++; - char *ret = malloc(last - (rom + TITLE_START) + 1); + char *ret = malloc(last - src + 1); uint8_t *dst; uint8_t last_was_space = 1; for (dst = ret; src < last; src++) -- cgit v1.2.3 From b4a36c0ef9d6563b9b247c697c250bc2633f39f1 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 15 May 2016 16:22:45 -0700 Subject: Fix bug in vflip implementation when in double resolution interlace mode --- vdp.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/vdp.c b/vdp.c index 1b3007a..2f87edf 100644 --- a/vdp.c +++ b/vdp.c @@ -826,20 +826,18 @@ void read_map_scroll_b(uint16_t column, uint32_t line, vdp_context * context) void render_map(uint16_t col, uint8_t * tmp_buf, uint8_t offset, vdp_context * context) { uint16_t address; - uint8_t shift, add; + uint16_t vflip_base; if (context->double_res) { address = ((col & 0x3FF) << 6); - shift = 1; - add = context->framebuf != context->oddbuf ? 1 : 0; + vflip_base = 60; } else { address = ((col & 0x7FF) << 5); - shift = 0; - add = 0; + vflip_base = 28; } if (col & MAP_BIT_V_FLIP) { - address += 28 - 4 * context->v_offset/*((context->v_offset << shift) + add)*/; + address += vflip_base - 4 * context->v_offset; } else { - address += 4 * context->v_offset/*((context->v_offset << shift) + add)*/; + address += 4 * context->v_offset; } uint16_t pal_priority = (col >> 9) & 0x70; int32_t dir; -- cgit v1.2.3 From 73cd2eca0ecead1cc8341305a6eb1988f818526e Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Sun, 15 May 2016 17:53:56 -0700 Subject: Complete SDL to Saturn scan code mapping --- render_sdl.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/render_sdl.c b/render_sdl.c index e27b5e8..dcd6ffc 100755 --- a/render_sdl.c +++ b/render_sdl.c @@ -596,25 +596,40 @@ uint8_t scancode_map[SDL_NUM_SCANCODES] = { [SDL_SCANCODE_SPACE] = 0x29, [SDL_SCANCODE_TAB] = 0x0D, [SDL_SCANCODE_BACKSPACE] = 0x66, + [SDL_SCANCODE_MINUS] = 0x4E, + [SDL_SCANCODE_EQUALS] = 0x55, + [SDL_SCANCODE_LEFTBRACKET] = 0x54, + [SDL_SCANCODE_RIGHTBRACKET] = 0x5B, + [SDL_SCANCODE_BACKSLASH] = 0x5D, + [SDL_SCANCODE_SEMICOLON] = 0x4C, + [SDL_SCANCODE_APOSTROPHE] = 0x52, + [SDL_SCANCODE_GRAVE] = 0x0E, + [SDL_SCANCODE_COMMA] = 0x41, + [SDL_SCANCODE_PERIOD] = 0x49, + [SDL_SCANCODE_SLASH] = 0x4A, + [SDL_SCANCODE_CAPSLOCK] = 0x58, [SDL_SCANCODE_F1] = 0x05, - [SDL_SCANCODE_F2] = 0x06, - [SDL_SCANCODE_F3] = 0x04, - [SDL_SCANCODE_F4] = 0x0C, - [SDL_SCANCODE_F5] = 0x03, - [SDL_SCANCODE_F6] = 0x0B, - [SDL_SCANCODE_F7] = 0x83, - [SDL_SCANCODE_F8] = 0x0A, - [SDL_SCANCODE_F9] = 0x01, - [SDL_SCANCODE_F10] = 0x09, - [SDL_SCANCODE_F11] = 0x78, - [SDL_SCANCODE_F12] = 0x07, + [SDL_SCANCODE_F2] = 0x06, + [SDL_SCANCODE_F3] = 0x04, + [SDL_SCANCODE_F4] = 0x0C, + [SDL_SCANCODE_F5] = 0x03, + [SDL_SCANCODE_F6] = 0x0B, + [SDL_SCANCODE_F7] = 0x83, + [SDL_SCANCODE_F8] = 0x0A, + [SDL_SCANCODE_F9] = 0x01, + [SDL_SCANCODE_F10] = 0x09, + [SDL_SCANCODE_F11] = 0x78, + [SDL_SCANCODE_F12] = 0x07, [SDL_SCANCODE_LCTRL] = 0x14, - [SDL_SCANCODE_LSHIFT] = 0x12, - [SDL_SCANCODE_LALT] = 0x11, + [SDL_SCANCODE_LSHIFT] = 0x12, + [SDL_SCANCODE_LALT] = 0x11, + [SDL_SCANCODE_RCTRL] = 0x18, [SDL_SCANCODE_RSHIFT] = 0x59, + [SDL_SCANCODE_RALT] = 0x17, [SDL_SCANCODE_INSERT] = 0x81, [SDL_SCANCODE_PAUSE] = 0x82, [SDL_SCANCODE_PRINTSCREEN] = 0x84, + [SDL_SCANCODE_SCROLLLOCK] = 0x7E, [SDL_SCANCODE_DELETE] = 0x85, [SDL_SCANCODE_LEFT] = 0x86, [SDL_SCANCODE_HOME] = 0x87, @@ -623,7 +638,24 @@ uint8_t scancode_map[SDL_NUM_SCANCODES] = { [SDL_SCANCODE_DOWN] = 0x8A, [SDL_SCANCODE_PAGEUP] = 0x8B, [SDL_SCANCODE_PAGEDOWN] = 0x8C, - [SDL_SCANCODE_RIGHT] = 0x8D + [SDL_SCANCODE_RIGHT] = 0x8D, + [SDL_SCANCODE_NUMLOCKCLEAR] = 0x77, + [SDL_SCANCODE_KP_DIVIDE] = 0x80, + [SDL_SCANCODE_KP_MULTIPLY] = 0x7C, + [SDL_SCANCODE_KP_MINUS] = 0x7B, + [SDL_SCANCODE_KP_PLUS] = 0x79, + [SDL_SCANCODE_KP_ENTER] = 0x19, + [SDL_SCANCODE_KP_1] = 0x69, + [SDL_SCANCODE_KP_2] = 0x72, + [SDL_SCANCODE_KP_3] = 0x7A, + [SDL_SCANCODE_KP_4] = 0x6B, + [SDL_SCANCODE_KP_5] = 0x73, + [SDL_SCANCODE_KP_6] = 0x74, + [SDL_SCANCODE_KP_7] = 0x6C, + [SDL_SCANCODE_KP_8] = 0x75, + [SDL_SCANCODE_KP_9] = 0x7D, + [SDL_SCANCODE_KP_0] = 0x70, + [SDL_SCANCODE_KP_PERIOD] = 0x71, }; int32_t handle_event(SDL_Event *event) -- cgit v1.2.3