From: notaz Date: Sat, 10 Sep 2022 13:57:39 +0000 (+0300) Subject: Merge branch 'irixxxx' X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7167e5f3376f0d0692ae102ed2df1ef5d2cc199a;hp=33787db41d955f8dcafe833097f2cc87d70186ec;p=libpicofe.git Merge branch 'irixxxx' --- diff --git a/linux/plat.c b/linux/plat.c index 45ae371..9109a32 100644 --- a/linux/plat.c +++ b/linux/plat.c @@ -192,6 +192,10 @@ void *plat_mmap(unsigned long addr, size_t size, int need_exec, int is_fixed) */ if (size >= HUGETLB_THRESHOLD) flags |= MAP_HUGETLB; +#ifdef MAP_JIT + if (need_exec) + flags |= MAP_JIT; +#endif ret = mmap(req, size, prot, flags, -1, 0); if (ret == MAP_FAILED && (flags & MAP_HUGETLB)) { @@ -223,8 +227,11 @@ void *plat_mremap(void *ptr, size_t oldsize, size_t newsize) { void *ret; +#ifdef MREMAP_MAYMOVE ret = mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE); - if (ret == MAP_FAILED) { + if (ret == MAP_FAILED) +#endif + { fprintf(stderr, "mremap %p %zd %zd: ", ptr, oldsize, newsize); perror(NULL); diff --git a/linux/sndout_alsa.c b/linux/sndout_alsa.c index f1d9ca3..9297967 100644 --- a/linux/sndout_alsa.c +++ b/linux/sndout_alsa.c @@ -51,7 +51,7 @@ int sndout_alsa_start(int rate_, int stereo) ret = snd_pcm_hw_params_any(handle, hwparams); ret |= snd_pcm_hw_params_set_access(handle, hwparams, SND_PCM_ACCESS_RW_INTERLEAVED); - ret |= snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16_LE); + ret |= snd_pcm_hw_params_set_format(handle, hwparams, SND_PCM_FORMAT_S16); ret |= snd_pcm_hw_params_set_channels(handle, hwparams, stereo ? 2 : 1); ret |= snd_pcm_hw_params_set_rate_near(handle, hwparams, &rate, 0); ret |= snd_pcm_hw_params_set_buffer_size_near(handle, hwparams, &buffer_size); diff --git a/menu.c b/menu.c index e91f84a..50138f3 100644 --- a/menu.c +++ b/menu.c @@ -207,10 +207,10 @@ static void smalltext_out16(int x, int y, const char *texto, int color) if (maxw < 0) return; - - strncpy(buffer, texto, sizeof(buffer)); if (maxw > sizeof(buffer) - 1) maxw = sizeof(buffer) - 1; + + strncpy(buffer, texto, maxw); buffer[maxw] = 0; smalltext_out16_(x, y, buffer, color); @@ -494,24 +494,12 @@ static int me_count(const menu_entry *ent) static unsigned int me_read_onoff(const menu_entry *ent) { - // guess var size based on mask to avoid reading too much - if (ent->mask & 0xffff0000) - return *(unsigned int *)ent->var & ent->mask; - else if (ent->mask & 0xff00) - return *(unsigned short *)ent->var & ent->mask; - else - return *(unsigned char *)ent->var & ent->mask; + return *(unsigned int *)ent->var & ent->mask; } static void me_toggle_onoff(menu_entry *ent) { - // guess var size based on mask to avoid reading too much - if (ent->mask & 0xffff0000) - *(unsigned int *)ent->var ^= ent->mask; - else if (ent->mask & 0xff00) - *(unsigned short *)ent->var ^= ent->mask; - else - *(unsigned char *)ent->var ^= ent->mask; + *(unsigned int *)ent->var ^= ent->mask; } static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) @@ -613,7 +601,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) name = ent->generate_name(ent->id, &offs); } if (name != NULL) { - text_out16(x, y, name); + text_out16(x, y, "%s", name); leftname_end = x + (strlen(name) + 1) * me_mfont_w; } @@ -621,7 +609,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) case MB_NONE: break; case MB_OPT_ONOFF: - text_out16(x + col2_offs, y, me_read_onoff(ent) ? "ON" : "OFF"); + text_out16(x + col2_offs, y, "%s", me_read_onoff(ent) ? "ON" : "OFF"); break; case MB_OPT_RANGE: text_out16(x + col2_offs, y, "%i", *(int *)ent->var); @@ -642,10 +630,10 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) offs = x + col2_offs; len = strlen(names[i]); if (len > 10) - offs += (10 - len - 2) * me_mfont_w; + offs += (10 - len) * me_mfont_w; if (offs < leftname_end) offs = leftname_end; - if (i == *(unsigned char *)ent->var) { + if (i == *(int *)ent->var) { text_out16(offs, y, "%s", names[i]); break; } @@ -662,7 +650,7 @@ static void me_draw(const menu_entry *entries, int sel, void (*draw_more)(void)) h = (g_menuscreen_h - h) / 2; // bottom area height if (menu_error_msg[0] != 0) { if (h >= me_mfont_h + 4) - text_out16(5, g_menuscreen_h - me_mfont_h - 4, menu_error_msg); + text_out16(5, g_menuscreen_h - me_mfont_h - 4, "%s", menu_error_msg); else lprintf("menu msg doesn't fit!\n"); @@ -710,11 +698,11 @@ static int me_process(menu_entry *entry, int is_next, int is_lr) names = (const char **)entry->data; for (c = 0; names[c] != NULL; c++) ; - *(signed char *)entry->var += is_next ? 1 : -1; - if (*(signed char *)entry->var < 0) - *(signed char *)entry->var = 0; - if (*(signed char *)entry->var >= c) - *(signed char *)entry->var = c - 1; + *(int *)entry->var += is_next ? 1 : -1; + if (*(int *)entry->var < 0) + *(int *)entry->var = 0; + if (*(int *)entry->var >= c) + *(int *)entry->var = c - 1; return 1; default: return 0; @@ -825,7 +813,7 @@ static void draw_menu_message(const char *msg, void (*draw_more)(void)) menu_draw_begin(1, 0); for (p = msg; *p != 0 && y <= g_menuscreen_h - me_mfont_h; y += me_mfont_h) { - text_out16(x, y, p); + text_out16(x, y, "%s", p); for (; *p != 0 && *p != '\n'; p++) ; @@ -867,7 +855,7 @@ static void do_delete(const char *fpath, const char *fname) snprintf(tmp + len, sizeof(tmp) - len, "%s - cancel)", nm); len = strlen(tmp); - text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, tmp); + text_out16(mid - me_mfont_w * len / 2, 12 * me_mfont_h, "%s", tmp); menu_draw_end(); while (in_menu_wait_any(NULL, 50) & (PBTN_MENU|PBTN_MA2)); @@ -1437,13 +1425,13 @@ static void draw_key_config(const me_bind_action *opts, int opt_cnt, int player_ snprintf(buff2, sizeof(buff2), "%s", in_get_key_name(-1, -PBTN_MOK)); snprintf(buff, sizeof(buff), "%s - bind, %s - clear", buff2, in_get_key_name(-1, -PBTN_MA2)); - text_out16(x, g_menuscreen_h - 4 * me_mfont_h, buff); + text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "%s", buff); } else text_out16(x, g_menuscreen_h - 4 * me_mfont_h, "Press a button to bind/unbind"); if (dev_count > 1) { - text_out16(x, g_menuscreen_h - 3 * me_mfont_h, dev_name); + text_out16(x, g_menuscreen_h - 3 * me_mfont_h, "%s", dev_name); text_out16(x, g_menuscreen_h - 2 * me_mfont_h, "Press left/right for other devs"); } diff --git a/plat_sdl.c b/plat_sdl.c index 97e2d29..530a9d7 100644 --- a/plat_sdl.c +++ b/plat_sdl.c @@ -125,7 +125,9 @@ int plat_sdl_change_video_mode(int w, int h, int force) if (plat_target.vout_method == 0) { SDL_PumpEvents(); -#if defined(SDL_TRIPLEBUF) && defined(SDL_BUFFER_3X) +#if defined SDL_SURFACE_SW + plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_SWSURFACE); +#elif defined(SDL_TRIPLEBUF) && defined(SDL_BUFFER_3X) plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_TRIPLEBUF); #else plat_sdl_screen = SDL_SetVideoMode(w, h, 16, SDL_HWSURFACE | SDL_DOUBLEBUF); diff --git a/posix.h b/posix.h index ca30edb..257c27f 100644 --- a/posix.h +++ b/posix.h @@ -2,7 +2,7 @@ #define LIBPICOFE_POSIX_H /* define POSIX stuff: dirent, scandir, getcwd, mkdir */ -#if defined(__linux__) || defined(__MINGW32__) +#if defined(__MACH__) || defined(__linux__) || defined(__MINGW32__) #include #include diff --git a/readpng.c b/readpng.c index 83936ae..ac24dd4 100644 --- a/readpng.c +++ b/readpng.c @@ -80,12 +80,14 @@ int readpng(void *dest, const char *fname, readpng_what what, int req_w, int req if (width > req_w) { x_ofs = (width - req_w) / 2; width = req_w; - } + } else + dst += (req_w - width) / 2; height = png_get_image_height(png_ptr, info_ptr); if (height > req_h) { y_ofs = (height - req_h) / 2; height = req_h; - } + } else + dst += (req_h - height) / 2 * req_w; for (h = 0; h < height; h++) { diff --git a/sndout_sdl.c b/sndout_sdl.c index a7be5ed..c0c57ab 100644 --- a/sndout_sdl.c +++ b/sndout_sdl.c @@ -62,7 +62,7 @@ int sndout_sdl_init(void) int sndout_sdl_start(int rate, int stereo) { - SDL_AudioSpec desired; + SDL_AudioSpec desired = { 0 }; int samples, shift; int ret; @@ -70,7 +70,7 @@ int sndout_sdl_start(int rate, int stereo) sndout_sdl_stop(); desired.freq = rate; - desired.format = AUDIO_S16LSB; + desired.format = AUDIO_S16SYS; desired.channels = stereo ? 2 : 1; desired.callback = callback; desired.userdata = NULL;