From 1ad8d1870b7257b37df41a9cef73e96504fa419e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miran=20Gr=C4=8Da?= Date: Sat, 18 Feb 2023 23:40:17 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 05a2a9ed2..a1e3985e1 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,16 @@ Licensing The emulator can also optionally make use of [munt](https://github.com/munt/munt), [FluidSynth](https://www.fluidsynth.org/), [Ghostscript](https://www.ghostscript.com/) and [Discord Game SDK](https://discord.com/developers/docs/game-sdk/sdk-starter-guide), which are distributed under their respective licenses. +Contribution requirements +------------------------- + Formal codification of the project's emulated hardware contribution requirements, which all have to be met to accept an addition: +* A ROM must be available; +* Documentation must be available or it must be feasible to reverse engineer with a reasonable amount of time and effort; +* It must be feasible to implement with a reasonable amount of time and effort; +* It has to fall inside the project's scope. + +Where unsure or for more details about the project's emulated hardware contribution requirements, contact a Contributor or higher. + Donations --------- We do not charge you for the emulator but donations are still welcome: From 4248d800406f6edde5eec0d3ae102fbeeeb10191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Kn=C3=A1pek?= Date: Sun, 19 Feb 2023 18:47:43 +0100 Subject: [PATCH 2/3] Port PR#199 from pcem to 86Box. Source: https://github.com/sarah-walker-pcem/pcem/pull/199 --- src/video/vid_voodoo_banshee.c | 32 ++++++++++++-------------------- src/video/vid_voodoo_display.c | 16 +++++++--------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/src/video/vid_voodoo_banshee.c b/src/video/vid_voodoo_banshee.c index f451c4b58..6b6af2a09 100644 --- a/src/video/vid_voodoo_banshee.c +++ b/src/video/vid_voodoo_banshee.c @@ -14,6 +14,7 @@ * * Copyright 2008-2020 Sarah Walker. */ +#include #include #include #include @@ -2267,9 +2268,10 @@ banshee_overlay_draw(svga_t *svga, int displine) case VIDPROCCFG_FILTER_MODE_DITHER_4X4: if (banshee->voodoo->scrfilter && banshee->voodoo->scrfilterEnabled) { - uint8_t *fil = malloc((svga->overlay_latch.cur_xsize) * 3); - uint8_t *fil3 = malloc((svga->overlay_latch.cur_xsize) * 3); + uint8_t fil[64 * 3]; + uint8_t fil3[64 * 3]; + assert(svga->overlay_latch.cur_xsize <= 64); if (banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE) /* leilei HACK - don't know of real 4x1 hscaled behavior yet, double for now */ { for (x = 0; x < svga->overlay_latch.cur_xsize; x++) { @@ -2320,9 +2322,6 @@ banshee_overlay_draw(svga_t *svga, int displine) fil[(x) *3 + 2] = vb_filter_v1_rb[fil[x * 3 + 2]][fil3[(x + 1) * 3 + 2]]; p[x] = (fil[x * 3 + 2] << 16) | (fil[x * 3 + 1] << 8) | fil[x * 3]; } - - free(fil); - free(fil3); } else /* filter disabled by emulator option */ { if (banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE) { @@ -2339,15 +2338,16 @@ banshee_overlay_draw(svga_t *svga, int displine) case VIDPROCCFG_FILTER_MODE_DITHER_2X2: if (banshee->voodoo->scrfilter && banshee->voodoo->scrfilterEnabled) { - uint8_t *fil = malloc((svga->overlay_latch.cur_xsize) * 3); - uint8_t *soak = malloc((svga->overlay_latch.cur_xsize) * 3); - uint8_t *soak2 = malloc((svga->overlay_latch.cur_xsize) * 3); + uint8_t fil[64 * 3]; + uint8_t soak[64 * 3]; + uint8_t soak2[64 * 3]; - uint8_t *samp1 = malloc((svga->overlay_latch.cur_xsize) * 3); - uint8_t *samp2 = malloc((svga->overlay_latch.cur_xsize) * 3); - uint8_t *samp3 = malloc((svga->overlay_latch.cur_xsize) * 3); - uint8_t *samp4 = malloc((svga->overlay_latch.cur_xsize) * 3); + uint8_t samp1[64 * 3]; + uint8_t samp2[64 * 3]; + uint8_t samp3[64 * 3]; + uint8_t samp4[64 * 3]; + assert(svga->overlay_latch.cur_xsize <= 64); src = &svga->vram[src_addr2 & svga->vram_mask]; OVERLAY_SAMPLE(banshee->overlay_buffer[1]); for (x = 0; x < svga->overlay_latch.cur_xsize; x++) { @@ -2395,14 +2395,6 @@ banshee_overlay_draw(svga_t *svga, int displine) p[x] = (fil[x * 3 + 2] << 16) | (fil[x * 3 + 1] << 8) | fil[x * 3]; } } - - free(fil); - free(soak); - free(soak2); - free(samp1); - free(samp2); - free(samp3); - free(samp4); } else /* filter disabled by emulator option */ { if (banshee->vidProcCfg & VIDPROCCFG_H_SCALE_ENABLE) { diff --git a/src/video/vid_voodoo_display.c b/src/video/vid_voodoo_display.c index 822085127..34037605a 100644 --- a/src/video/vid_voodoo_display.c +++ b/src/video/vid_voodoo_display.c @@ -14,6 +14,7 @@ * * Copyright 2008-2020 Sarah Walker. */ +#include #include #include #include @@ -373,8 +374,9 @@ voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, int x; // Scratchpad for avoiding feedback streaks - uint8_t *fil3 = malloc((voodoo->h_disp) * 3); + uint8_t fil3[4096 * 3]; + assert(voodoo->h_disp <= 4096); /* 16 to 32-bit */ for (x = 0; x < column; x++) { fil[x * 3] = ((src[x] & 31) << 3); @@ -422,8 +424,6 @@ voodoo_filterline_v1(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, fil[(x) *3 + 1] = voodoo->thefilterg[fil3[x * 3 + 1]][fil3[(x + 1) * 3 + 1]]; fil[(x) *3 + 2] = voodoo->thefilter[fil3[x * 3 + 2]][fil3[(x + 1) * 3 + 2]]; } - - free(fil3); } static void @@ -432,8 +432,9 @@ voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, int x; // Scratchpad for blending filter - uint8_t *fil3 = malloc((voodoo->h_disp) * 3); + uint8_t fil3[4096 * 3]; + assert(voodoo->h_disp <= 4096); /* 16 to 32-bit */ for (x = 0; x < column; x++) { // Blank scratchpads @@ -487,8 +488,6 @@ voodoo_filterline_v2(voodoo_t *voodoo, uint8_t *fil, int column, uint16_t *src, fil3[(column - 1) * 3] = voodoo->thefilterb[fil[(column - 1) * 3]][((src[column] & 31) << 3)]; fil3[(column - 1) * 3 + 1] = voodoo->thefilterg[fil[(column - 1) * 3 + 1]][(((src[column] >> 5) & 63) << 2)]; fil3[(column - 1) * 3 + 2] = voodoo->thefilter[fil[(column - 1) * 3 + 2]][(((src[column] >> 11) & 31) << 3)]; - - free(fil3); } void @@ -537,8 +536,9 @@ voodoo_callback(void *p) monitor->target_buffer->line[voodoo->line + 8][x] = 0x00000000; if (voodoo->scrfilter && voodoo->scrfilterEnabled) { - uint8_t *fil = malloc((voodoo->h_disp) * 3); /* interleaved 24-bit RGB */ + uint8_t fil[4096 * 3]; /* interleaved 24-bit RGB */ + assert(voodoo->h_disp <= 4096); if (voodoo->type == VOODOO_2) voodoo_filterline_v2(voodoo, fil, voodoo->h_disp, src, voodoo->line); else @@ -547,8 +547,6 @@ voodoo_callback(void *p) for (x = 0; x < voodoo->h_disp; x++) { p[x] = (voodoo->clutData256[fil[x * 3]].b << 0 | voodoo->clutData256[fil[x * 3 + 1]].g << 8 | voodoo->clutData256[fil[x * 3 + 2]].r << 16); } - - free(fil); } else { for (x = 0; x < voodoo->h_disp; x++) { p[x] = draw_voodoo->video_16to32[src[x]]; From b8bfaa926937d38ffa0f8a1fcf685312bfb038b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hrdli=C4=8Dka?= Date: Sun, 19 Feb 2023 23:05:16 +0100 Subject: [PATCH 3/3] Fix buffer lengths in `swprintf` calls --- src/86box.c | 6 +++--- src/win/win_about.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/86box.c b/src/86box.c index 11d5c1ff8..f318bcfbc 100644 --- a/src/86box.c +++ b/src/86box.c @@ -853,7 +853,7 @@ pc_init_modules(void) /* Load the ROMs for the selected machine. */ if (!machine_available(machine)) { - swprintf(temp, sizeof(temp), plat_get_string(IDS_2063), machine_getname()); + swprintf(temp, sizeof_w(temp), plat_get_string(IDS_2063), machine_getname()); c = 0; machine = -1; while (machine_get_internal_name_ex(c) != NULL) { @@ -876,7 +876,7 @@ pc_init_modules(void) if (!video_card_available(gfxcard[0])) { memset(tempc, 0, sizeof(tempc)); device_get_name(video_card_getdevice(gfxcard[0]), 0, tempc); - swprintf(temp, sizeof(temp), plat_get_string(IDS_2064), tempc); + swprintf(temp, sizeof_w(temp), plat_get_string(IDS_2064), tempc); c = 0; while (video_get_internal_name(c) != NULL) { gfxcard[0] = -1; @@ -898,7 +898,7 @@ pc_init_modules(void) if (!video_card_available(gfxcard[1])) { char tempc[512] = { 0 }; device_get_name(video_card_getdevice(gfxcard[1]), 0, tempc); - swprintf(temp, sizeof(temp), (wchar_t *) "Video card #2 \"%hs\" is not available due to missing ROMs in the roms/video directory. Disabling the second video card.", tempc); + swprintf(temp, sizeof_w(temp), (wchar_t *) "Video card #2 \"%hs\" is not available due to missing ROMs in the roms/video directory. Disabling the second video card.", tempc); ui_msgbox_header(MBX_INFO, (wchar_t *) IDS_2129, temp); gfxcard[1] = 0; } diff --git a/src/win/win_about.c b/src/win/win_about.c index f0c692b75..82b327d2e 100644 --- a/src/win/win_about.c +++ b/src/win/win_about.c @@ -43,9 +43,9 @@ AboutDialogCreate(HWND hwnd) }; wchar_t emu_version[256]; - i = swprintf(emu_version, sizeof(emu_version), L"%ls v%ls", EMU_NAME_W, EMU_VERSION_FULL_W); + i = swprintf(emu_version, sizeof_w(emu_version), L"%ls v%ls", EMU_NAME_W, EMU_VERSION_FULL_W); #ifdef EMU_GIT_HASH - i += swprintf(&emu_version[i], sizeof(emu_version) - i, L" [%ls]", EMU_GIT_HASH_W); + i += swprintf(&emu_version[i], sizeof_w(emu_version) - i, L" [%ls]", EMU_GIT_HASH_W); #endif #if defined(__arm__) || defined(__TARGET_ARCH_ARM) @@ -59,7 +59,7 @@ AboutDialogCreate(HWND hwnd) #else # define ARCH_STR L"unknown" #endif - swprintf(&emu_version[i], sizeof(emu_version) - i, L" [%ls, %ls]", ARCH_STR, plat_get_string(IDS_DYNAREC)); + swprintf(&emu_version[i], sizeof_w(emu_version) - i, L" [%ls, %ls]", ARCH_STR, plat_get_string(IDS_DYNAREC)); tdconfig.cbSize = sizeof(tdconfig); tdconfig.hwndParent = hwnd;