diff --git a/src/machines/m_at_opti495.c b/src/machines/m_at_opti495.c index d5e3de6..7955a90 100644 --- a/src/machines/m_at_opti495.c +++ b/src/machines/m_at_opti495.c @@ -312,13 +312,13 @@ opti495_write(uint16_t addr, uint8_t val, void *p) { switch (addr) { case 0x22: - optireg=val; + optireg = val; break; case 0x24: - pclog("OPTI: writing reg %02X %02X\n",optireg,val); - if (optireg>=0x20 && optireg<=0x2C) { - optiregs[optireg-0x20]=val; + pclog("OPTI: writing reg %02X %02X\n", optireg, val); + if (optireg >= 0x20 && optireg <= 0x2C) { + optiregs[optireg - 0x20] = val; if (optireg == 0x21) { cpu_cache_ext_enabled = val & 0x10; cpu_update_waitstates(); @@ -342,8 +342,8 @@ opti495_read(uint16_t addr, void *p) { switch (addr) { case 0x24: - if (optireg>=0x20 && optireg<=0x2c) - return(optiregs[optireg-0x20]); + if (optireg >= 0x20 && optireg <= 0x2c) + return(optiregs[optireg - 0x20]); break; } @@ -359,7 +359,7 @@ opti495_init(void) io_sethandler(0x0024, 1, opti495_read,NULL,NULL, opti495_write,NULL,NULL, NULL); - optiregs[0x22-0x20] = 0x80; + optiregs[0x22 - 0x20] = 0x80; } diff --git a/src/ui/lang/VARCem.lang b/src/ui/lang/VARCem.lang index e9b578e..a2efe3e 100644 --- a/src/ui/lang/VARCem.lang +++ b/src/ui/lang/VARCem.lang @@ -8,7 +8,7 @@ # # Supported Languages database. # -# Version: @(#)VARCem.lang 1.0.1 2018/06/14 +# Version: @(#)VARCem.lang 1.0.2 2018/06/19 # # Author: Fred N. van Kempen, # @@ -58,4 +58,4 @@ KZ,043f,LANG_KAZAK,SUBLANG_KAZAK_KAZAKHSTAN LT,0427,LANG_LITHUANIAN,SUBLANG_LITHUANIAN_LITHUANIA RU,0419,LANG_RUSSIAN,SUBLANG_RUSSIAN_RUSSIA SL,0424,LANG_SLOVENIAN,SUBLANG_SLOVENIAN_SLOVENIA -UA,0422,LANG_UKRANIAN,SUBLANG_UKTRANIAN_UKRAINE +UA,0422,LANG_UKRAINIAN,SUBLANG_UKRAINIAN_UKRAINE diff --git a/src/win/VARCem.rpp b/src/win/VARCem.rpp index 479ce2c..6c5188a 100644 --- a/src/win/VARCem.rpp +++ b/src/win/VARCem.rpp @@ -10,7 +10,7 @@ * which require some weird processing. This file allows us * to use a single master for all those languages. * - * Version: @(#)VARCem.rpp 1.0.1 2018/06/16 + * Version: @(#)VARCem.rpp 1.0.1 2018/06/19 * * Author: Fred N. van Kempen, * @@ -49,15 +49,15 @@ PREAMBLE #pragma code_page(65001) PREAMBLE #include PREAMBLE #include -PREAMBLE #include "../../version.h" -PREAMBLE #include "../../ui/ui.h" -PREAMBLE #include "../resource.h" +PREAMBLE #include "../version.h" +PREAMBLE #include "../ui/ui.h" +PREAMBLE #include "resource.h" /* Some MacroMagic(tm) .. */ #define _TEXT_(x) #x #define __HEX4(x) 0x ## x -#define __INCL(a,b,c) _TEXT_(../../ui/lang/ ## a ## - ## b ## . ## c) +#define __INCL(a,b,c) _TEXT_(../ui/lang/ ## a ## - ## b ## . ## c) #define __DLLNM(a,b,c) _TEXT_(a ## - ## b ## . ## c) #define __BLKNM(id) _TEXT_(id ## fde9) #define INCLUDE(l) __INCL(VARCem, l, str) @@ -65,12 +65,17 @@ PREAMBLE #include "../resource.h" #define BLOCKNAME(l) __BLKNM(l) +PREAMBLE #ifndef SUBLANG +PREAMBLE # define SUBLANG 0x01 /* Lithuanian, for example */ +PREAMBLE #endif + + LANGUAGE PRILANG, SUBLANG PREAMBLE #include INCLUDE(LANG) -PREAMBLE #include "../VARCem-common.rc" +PREAMBLE #include "VARCem-common.rc" PREAMBLE #pragma code_page(DEFAULT) diff --git a/src/win/msvc/Makefile.VC b/src/win/msvc/Makefile.VC index 9518440..f9a4516 100644 --- a/src/win/msvc/Makefile.VC +++ b/src/win/msvc/Makefile.VC @@ -8,7 +8,7 @@ # # Makefile for Windows using Visual Studio 2015. # -# Version: @(#)Makefile.VC 1.0.34 2018/06/02 +# Version: @(#)Makefile.VC 1.0.36 2018/06/19 # # Author: Fred N. van Kempen, # @@ -259,7 +259,7 @@ RFLAGS := /n COPTS := -W3 CXXOPTS := -EHsc DOPTS := -LOPTS := -LIBPATH:win\msvc\Lib\$(ARCH) +LOPTS := -MACHINE:$(ARCH) -LIBPATH:win\msvc\Lib\$(ARCH) LOPTS_C := -SUBSYSTEM:CONSOLE,5.01 LOPTS_W := -SUBSYSTEM:WINDOWS,5.01 ifdef BUILD @@ -508,6 +508,8 @@ CXXFLAGS := $(WX_FLAGS) $(OPTS) $(CXXOPTS) $(COPTS) $(DOPTS) $(AOPTIM) $(AFLAGS) # Create the (final) list of objects to build. # ######################################################################### +RESDLL := VARCem-$(LANG) + MAINOBJ := pc.obj config.obj misc.obj random.obj timer.obj io.obj \ mem.obj rom.obj rom_load.obj device.obj nvr.obj \ $(VNCOBJ) $(RDPOBJ) @@ -692,18 +694,43 @@ endif all: $(PREBUILD) $(PROG).exe pcap_if.exe $(POSTBUILD) - -Mklang.cmd: - @echo @SET PATH=$(PATH) >Mklang.cmd - @echo @cd win\lang >>Mklang.cmd - @echo @$(MAKE) -fMakefile.VC "RFLAGS=$(RFLAGS) $(EXTRAS)" %%1% >>Mklang.cmd - @echo @cd ..\.. >>Mklang.cmd +# +# This rule creates a script (command file) that figures out which +# language we want to make (its argument is the 2-letter language +# name, or none) by looking it up in the database of supported ones, +# and then it calls the (this) Makefile back with the proper args +# for that target. +# +# We do it this way so it can also be used by the VC project files. +# +win/Mklang.cmd: win/msvc/Makefile.VC + @echo @SET PATH=$(PATH) >>win\Mklang.cmd + @echo @SETLOCAL >>win\Mklang.cmd + @echo @SET LANG=none >>win\Mklang.cmd + @echo @FOR /F "eol=# tokens=1,2,3,4* delims=, " %%%%i in (ui\lang\VARCem.lang) do @if "%%1"=="%%%%i" set LANG=%%%%i LANGID=%%%%j PRILANG=%%%%k SUBLANG=%%%%l >>win\Mklang.cmd + @echo @IF NOT "%%LANG%%"=="none" @$(MAKE) -fwin/msvc/Makefile.VC "RFLAGS=$(RFLAGS) $(EXTRAS)" LANG=%%LANG%% VARCem-%%1.dll >>win\Mklang.cmd -lang: Mklang.cmd win/VARCem-common.rc +lang: win/Mklang.cmd +ifdef LANG + @echo Generating localization $(LANG) .. +else @echo Generating localizations.. - @Mklang.cmd all - @-del Mklang.cmd + @FOR /F "eol=# tokens=1 delims=, " %%i in (ui\lang\VARCem.lang) do @win\Mklang %%i +endif + @-del win\Mklang.cmd + +win/$(RESDLL).rc: VARCem.rpp VARCem-common.rc + @$(PREPROC) -DPREAMBLE= -DLANG=$(LANG) -DLANGID=$(LANGID) -DPRILANG=$(PRILANG) -DSUBLANG=$(SUBLANG) $< >win\$(RESDLL).rc 2>NUL + +$(RESDLL).res: win/$(RESDLL).rc VARCem-common.rc + @echo Processing $(RESDLL).rc .. + @$(WINDRES) $(RFLAGS) -fo$@ $< + +$(RESDLL).dll: $(RESDLL).res + @echo Linking $(RESDLL).dll .. + @$(LINK) /DLL /NOENTRY $(LDFLAGS) -OUT:$@ $(RESDLL).res + @-del win\$(RESDLL).rc VARCem.res: win/VARCem.rc win/VARCem.mpp @echo Generating Manifest file.. @@ -733,23 +760,22 @@ hello.exe: hello.obj clean: @echo Cleaning objects.. - @del *.obj 2>NUL - @del *.res 2>NUL + @-del *.obj 2>NUL + @-del *.res 2>NUL clobber: Mklang.cmd clean @echo Cleaning executables.. - @del *.d 2>NUL - @del *.exe 2>NUL + @-del *.d 2>NUL + @-del *.exe 2>NUL ifeq ($(DEBUG), y) - @del *.ilk 2>NUL - @del *.pdb 2>NUL + @-del *.ilk 2>NUL + @-del *.pdb 2>NUL endif ifeq ($(PROFILER), y) - @del *.map 2>NUL + @-del *.map 2>NUL endif - @del win\*.manifest 2>NUL - @Mklang.cmd clobber - @-del Mklang.cmd + @-del win\*.manifest 2>NUL + @-del *.dll 2>NUL # @del $(DEPFILE) 2>NUL ifneq ($(AUTODEP), y) @@ -776,4 +802,4 @@ include $(wildcard $(DEPFILE)) endif -# End of Makefile.VS. +# End of Makefile.VC. diff --git a/src/win/win_ddraw.cpp b/src/win/win_ddraw.cpp index 80d399b..3e58b39 100644 --- a/src/win/win_ddraw.cpp +++ b/src/win/win_ddraw.cpp @@ -13,7 +13,7 @@ * the original mode, which uses the Windows/DDraw built-in BMP * format. * - * Version: @(#)win_ddraw.cpp 1.0.15 2018/06/11 + * Version: @(#)win_ddraw.cpp 1.0.16 2018/06/18 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -644,29 +644,6 @@ ddraw_init(int fs) #ifdef USE_LIBPNG -static void -bgra_to_rgb(png_bytep *b_rgb, uint8_t *bgra, int width, int height) -{ - int h, w; - uint8_t *r, *b; - - for (h = 0; h < height; h++) { - for (w = 0; w < width; w++) { - /* Get pointer to pixel in bitmap data. */ - b = &bgra[((h * width) + w) * 4]; - - /* Get pointer to png row data. */ - r = &b_rgb[(height - 1) - h][w * 3]; - - /* Copy the pixel data. */ - r[0] = b[2]; - r[1] = b[1]; - r[2] = b[0]; - } - } -} - - static void error_handler(png_structp arg, const char *str) { @@ -686,8 +663,8 @@ SavePNG(const wchar_t *fn, BITMAPINFO *bmi, uint8_t *pixels) { png_structp png = NULL; png_infop info = NULL; + png_bytepp rows; uint8_t *r, *b; - png_bytep row; FILE *fp; int h, w; @@ -724,49 +701,52 @@ error: PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); -pclog("PNG: write_info\n"); PNGFUNC(write_info)(png, info); - /* Create a buffer for one scanline of pixels. */ - row = (png_bytep)malloc(PNGFUNC(get_rowbytes)(png, info)); - - /* Process all scanlines in the image. */ -pclog("PNG: convert\n"); + /* Create a buffer for scanlines of pixels. */ + rows = (png_bytepp)malloc(sizeof(png_bytep) * bmi->bmiHeader.biHeight); + for (h = 0; h < bmi->bmiHeader.biHeight; h++) { + /* Create a buffer for this scanline. */ + rows[h] = (png_bytep)malloc(PNGFUNC(get_rowbytes)(png, info)); + } + + /* + * Process all scanlines in the image. + * + * Since the bitmap is un bottom-up mode, we have to convert + * all pixels to RGB mode, but also 'flip' the image to the + * normal top-down mode. + */ for (h = 0; h < bmi->bmiHeader.biHeight; h++) { - r = row; for (w = 0; w < bmi->bmiHeader.biWidth; w++) { /* Get pointer to pixel in bitmap data. */ b = &pixels[((h * bmi->bmiHeader.biWidth) + w) * 4]; + /* Get pointer to png row data. */ + r = &rows[(bmi->bmiHeader.biHeight - 1) - h][w * 3]; + /* Copy the pixel data. */ r[0] = b[2]; r[1] = b[1]; r[2] = b[0]; - - /* Next pixel on scanline. */ - r += 3; } - - /* Write this row to the file. */ -// png_write_row(png, row); } - /* No longer need the row buffer. */ - free(row); + /* Write image to the file. */ + PNGFUNC(write_image)(png, rows); + + /* No longer need the row buffers. */ + for (h = 0; h < bmi->bmiHeader.biHeight; h++) + free(rows[h]); + free(rows); -#if 0 -pclog("PNG: write_end\n"); PNGFUNC(write_end)(png, NULL); -#endif -pclog("PNG: destroy\n"); PNGFUNC(destroy_write_struct)(&png, &info); /* Clean up. */ -pclog("PNG: fclose\n"); (void)fclose(fp); -pclog("PNG: done!\n"); return(1); } #endif