From 696bf4a4aa1a04ed9e436efcc8d23781a60adc4e Mon Sep 17 00:00:00 2001 From: dinkc64 Date: Fri, 14 Jun 2024 00:29:59 -0400 Subject: [PATCH] viostorm, add color improvement DIP --- src/burn/drv/konami/d_mystwarr.cpp | 123 ++++++++++++++++++++--------- 1 file changed, 86 insertions(+), 37 deletions(-) diff --git a/src/burn/drv/konami/d_mystwarr.cpp b/src/burn/drv/konami/d_mystwarr.cpp index c91c0a7c9..643886cbb 100644 --- a/src/burn/drv/konami/d_mystwarr.cpp +++ b/src/burn/drv/konami/d_mystwarr.cpp @@ -98,6 +98,9 @@ static INT32 z80_bank; static INT32 nGame = 0; static INT32 viostormubbl = 0; +static void gamma_init(); +static void gamma_exit(); + static struct BurnInputInfo MystwarrInputList[] = { {"P1 Coin", BIT_DIGITAL, DrvJoy1 + 0, "p1 coin"}, {"P1 Start", BIT_DIGITAL, DrvJoy3 + 7, "p1 start"}, @@ -239,6 +242,7 @@ static struct BurnInputInfo ViostormInputList[] = { {"Service 1", BIT_DIGITAL, DrvJoy1 + 4, "service"}, {"Service 2", BIT_DIGITAL, DrvJoy1 + 5, "service"}, {"Dip A", BIT_DIPSWITCH, DrvDips + 0, "dip"}, + {"Dip B", BIT_DIPSWITCH, DrvDips + 1, "dip"}, }; STDINPUTINFO(Viostorm) @@ -342,47 +346,49 @@ STDINPUTINFO(Martchmp) static struct BurnDIPInfo MystwarrDIPList[]= { - {0x26, 0xff, 0xff, 0xe0, NULL }, - {0x27, 0xff, 0xff, 0x00, NULL }, + DIP_OFFSET(0x26) + {0x00, 0xff, 0xff, 0xe0, NULL }, + {0x01, 0xff, 0xff, 0x00, NULL }, {0 , 0xfe, 0 , 2, "Sound Output" }, - {0x26, 0x01, 0x10, 0x10, "Mono" }, - {0x26, 0x01, 0x10, 0x00, "Stereo" }, + {0x00, 0x01, 0x10, 0x10, "Mono" }, + {0x00, 0x01, 0x10, 0x00, "Stereo" }, {0 , 0xfe, 0 , 2, "Coin Mechanism" }, - {0x26, 0x01, 0x20, 0x20, "Common" }, - {0x26, 0x01, 0x20, 0x00, "Independent" }, + {0x00, 0x01, 0x20, 0x20, "Common" }, + {0x00, 0x01, 0x20, 0x00, "Independent" }, {0 , 0xfe, 0 , 2, "Number of Players" }, - {0x26, 0x01, 0x40, 0x00, "4" }, - {0x26, 0x01, 0x40, 0x40, "2" }, + {0x00, 0x01, 0x40, 0x00, "4" }, + {0x00, 0x01, 0x40, 0x40, "2" }, {0 , 0xfe, 0 , 2, "Debug Alpha Mode (debug console/logfile)" }, - {0x27, 0x01, 0x01, 0x00, "Off" }, - {0x27, 0x01, 0x01, 0x01, "On" }, + {0x01, 0x01, 0x01, 0x00, "Off" }, + {0x01, 0x01, 0x01, 0x01, "On" }, }; STDDIPINFO(Mystwarr) static struct BurnDIPInfo MetamrphDIPList[]= { - {0x26, 0xff, 0xff, 0xe0, NULL }, + DIP_OFFSET(0x26) + {0x00, 0xff, 0xff, 0xe0, NULL }, {0 , 0xfe, 0 , 2, "Sound Output" }, - {0x26, 0x01, 0x10, 0x10, "Mono" }, - {0x26, 0x01, 0x10, 0x00, "Stereo" }, + {0x00, 0x01, 0x10, 0x10, "Mono" }, + {0x00, 0x01, 0x10, 0x00, "Stereo" }, {0 , 0xfe, 0 , 2, "Coin Mechanism" }, - {0x26, 0x01, 0x20, 0x20, "Common" }, - {0x26, 0x01, 0x20, 0x00, "Independent" }, + {0x00, 0x01, 0x20, 0x20, "Common" }, + {0x00, 0x01, 0x20, 0x00, "Independent" }, {0 , 0xfe, 0 , 2, "Number of Players" }, - {0x26, 0x01, 0x40, 0x00, "4" }, - {0x26, 0x01, 0x40, 0x40, "2" }, + {0x00, 0x01, 0x40, 0x00, "4" }, + {0x00, 0x01, 0x40, 0x40, "2" }, {0 , 0xfe, 0 , 2, "Continuous Energy Increment" }, - {0x26, 0x01, 0x80, 0x80, "No" }, - {0x26, 0x01, 0x80, 0x00, "Yes" }, + {0x00, 0x01, 0x80, 0x80, "No" }, + {0x00, 0x01, 0x80, 0x00, "Yes" }, }; STDDIPINFO(Metamrph) @@ -390,38 +396,45 @@ STDDIPINFO(Metamrph) static struct BurnDIPInfo ViostormDIPList[]= { - {0x26, 0xff, 0xff, 0xe0, NULL }, + DIP_OFFSET(0x26) + {0x00, 0xff, 0xff, 0xe0, NULL }, + {0x01, 0xff, 0xff, 0x00, NULL }, {0 , 0xfe, 0 , 2, "Sound Output" }, - {0x26, 0x01, 0x10, 0x10, "Mono" }, - {0x26, 0x01, 0x10, 0x00, "Stereo" }, + {0x00, 0x01, 0x10, 0x10, "Mono" }, + {0x00, 0x01, 0x10, 0x00, "Stereo" }, {0 , 0xfe, 0 , 2, "Flip Screen" }, - {0x26, 0x01, 0x20, 0x20, "Off" }, - {0x26, 0x01, 0x20, 0x00, "On" }, + {0x00, 0x01, 0x20, 0x20, "Off" }, + {0x00, 0x01, 0x20, 0x00, "On" }, {0 , 0xfe, 0 , 2, "Coin Mechanism" }, - {0x26, 0x01, 0x40, 0x40, "Common" }, - {0x26, 0x01, 0x40, 0x00, "Independent" }, + {0x00, 0x01, 0x40, 0x40, "Common" }, + {0x00, 0x01, 0x40, 0x00, "Independent" }, - {0 , 0xfe, 0 , 2, "Number of Players" }, - {0x26, 0x01, 0x80, 0x00, "3" }, - {0x26, 0x01, 0x80, 0x80, "2" }, + {0 , 0xfe, 0 , 2, "Number of Players"}, + {0x00, 0x01, 0x80, 0x00, "3" }, + {0x00, 0x01, 0x80, 0x80, "2" }, + + {0 , 0xfe, 0 , 2, "Color Improvement"}, + {0x01, 0x01, 0x40, 0x40, "On" }, + {0x01, 0x01, 0x40, 0x00, "Off" }, }; STDDIPINFO(Viostorm) static struct BurnDIPInfo DadandrnDIPList[]= { - {0x26, 0xff, 0xff, 0xe0, NULL }, + DIP_OFFSET(0x26) + {0x00, 0xff, 0xff, 0xe0, NULL }, {0 , 0xfe, 0 , 2, "Sound Output" }, - {0x26, 0x01, 0x10, 0x10, "Mono" }, - {0x26, 0x01, 0x10, 0x00, "Stereo" }, + {0x00, 0x01, 0x10, 0x10, "Mono" }, + {0x00, 0x01, 0x10, 0x00, "Stereo" }, {0 , 0xfe, 0 , 2, "Flip Screen" }, - {0x26, 0x01, 0x20, 0x20, "Off" }, - {0x26, 0x01, 0x20, 0x00, "On" }, + {0x00, 0x01, 0x20, 0x20, "Off" }, + {0x00, 0x01, 0x20, 0x00, "On" }, }; STDDIPINFO(Dadandrn) @@ -2793,6 +2806,8 @@ static INT32 DadandrnInit() static INT32 DrvExit() { + gamma_exit(); + GenericTilesExit(); KonamiICExit(); @@ -2815,15 +2830,49 @@ static INT32 DrvExit() return 0; } +static UINT8 *gamma = NULL; +static UINT8 last_gamma_dip = ~0; + +static void gamma_init() +{ + if (gamma == NULL) { + gamma = (UINT8*)BurnMalloc(0x100); + last_gamma_dip = ~0; + } + + if (last_gamma_dip == (DrvDips[1] & 0x40)) return; + + if (nGame == 3 && DrvDips[1] & 0x40) { // only applied to viostorm, gamma 0.650 (expressed as 1/0.650) + bprintf(0, _T("viostorm: apply gamma 1.0 / 0.650\n")); + for (INT32 i = 0; i < 0x100; i++) { + gamma[i] = (UINT8)(pow((double)i / 255.0, 1.0 / 0.650) * 255.0); + } + } else { + bprintf(0, _T("no gamma\n")); + for (INT32 i = 0; i < 0x100; i++) { + gamma[i] = i; + } + } + last_gamma_dip = DrvDips[1] & 0x40; +} + +static void gamma_exit() { + BurnFree(gamma); + + gamma = NULL; +} + static void DrvPaletteRecalc() { + gamma_init(); + UINT16 *pal = (UINT16*)DrvPalRAM; for (INT32 i = 0; i < 0x2000/2; i+=2) { - INT32 r = BURN_ENDIAN_SWAP_INT16(pal[i+0]) & 0xff; - INT32 g = BURN_ENDIAN_SWAP_INT16(pal[i+1]) >> 8; - INT32 b = BURN_ENDIAN_SWAP_INT16(pal[i+1]) & 0xff; + INT32 r = gamma[BURN_ENDIAN_SWAP_INT16(pal[i+0]) & 0xff]; + INT32 g = gamma[BURN_ENDIAN_SWAP_INT16(pal[i+1]) >> 8]; + INT32 b = gamma[BURN_ENDIAN_SWAP_INT16(pal[i+1]) & 0xff]; DrvPalette[i/2] = (r << 16) + (g << 8) + b; }