Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Added gray and random palettes.
  • Loading branch information
Vladimir Kryvian committed Jun 16, 2018
1 parent 756f7d3 commit 9ccfd3f
Show file tree
Hide file tree
Showing 7 changed files with 1,183 additions and 1,029 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,6 +13,7 @@
*.db-shm
*.db-wal
*.ipch
*.aps
Gensida/asm/main68k.asm
Gensida/asm/sub68k.asm
Debug86_68/
Expand Down
2 changes: 1 addition & 1 deletion Gensida/ida/ida_plugin.h
@@ -1,4 +1,4 @@
#pragma once

#define NAME "GensIDA"
#define VERSION "1.11"
#define VERSION "1.12"
1 change: 1 addition & 0 deletions Gensida/include/resource.h
Expand Up @@ -735,6 +735,7 @@
#define IDC_VDP_PAL_LOAD 51100
#define IDC_VDP_PAL_DUMP 51101
#define IDC_VDP_PAL_YY 51102
#define IDC_VDP_PAL_RNB 51103
#define IDC_PLANEEXPLORER_MAIN 54001
#define IDC_PLANEEXPLORER_TILEINFO 54002
#define IDC_PLANEEXPLORER_TRANS 54003
Expand Down
2,066 changes: 1,040 additions & 1,026 deletions Gensida/resource/gens.rc

Large diffs are not rendered by default.

138 changes: 138 additions & 0 deletions Gensida/src/vdp_ram.cpp
Expand Up @@ -941,6 +941,95 @@ BOOL CALLBACK MoveGroupCallback(HWND hChild, LPARAM lParam)
return TRUE;
}

typedef struct RgbColor
{
unsigned char red;
unsigned char green;
unsigned char blue;
} RgbColor;

typedef struct HsvColor
{
int16_t hue; // hue = 0 to 3600 (i.e. 1/10 of a degree)
int16_t saturation; // saturation = 0 to 1000
int16_t value; // value = 0 to 1000
} HsvColor;

static RgbColor hsv2rgb(HsvColor hsv)
{
RgbColor rgb;
//---------------------------------------------------------------------
// convert hue, saturation and value (HSV) to red, green and blue
//---------------------------------------------------------------------

rgb.red = 0;
rgb.green = 0;
rgb.blue = 0;

if (hsv.saturation == 0)
{
rgb.red = (uint8_t)((255 * hsv.value) / 1000);
rgb.green = rgb.red;
rgb.blue = rgb.red;
}
else
{
int16_t h = hsv.hue / 600;
int16_t f = ((hsv.hue % 600) * 1000) / 600;
int16_t p = (hsv.value*(1000 - hsv.saturation)) / 1000;
int16_t q = (hsv.value*(1000 - ((hsv.saturation*f) / 1000))) / 1000;
int16_t t = (hsv.value*(1000 - ((hsv.saturation*(1000 - f)) / 1000))) / 1000;

switch (h)
{
case 0:

rgb.red = (uint8_t)((255 * hsv.value) / 1000);
rgb.green = (uint8_t)((255 * t) / 1000);
rgb.blue = (uint8_t)((255 * p) / 1000);
break;

case 1:

rgb.red = (uint8_t)((255 * q) / 1000);
rgb.green = (uint8_t)((255 * hsv.value) / 1000);
rgb.blue = (uint8_t)((255 * p) / 1000);
break;

case 2:

rgb.red = (uint8_t)((255 * p) / 1000);
rgb.green = (uint8_t)((255 * hsv.value) / 1000);
rgb.blue = (uint8_t)((255 * t) / 1000);
break;

case 3:

rgb.red = (uint8_t)((255 * p) / 1000);
rgb.green = (uint8_t)((255 * q) / 1000);
rgb.blue = (uint8_t)((255 * hsv.value) / 1000);
break;

case 4:

rgb.red = (uint8_t)((255 * t) / 1000);
rgb.green = (uint8_t)((255 * p) / 1000);
rgb.blue = (uint8_t)((255 * hsv.value) / 1000);
break;

case 5:

rgb.red = (uint8_t)((255 * hsv.value) / 1000);
rgb.green = (uint8_t)((255 * p) / 1000);
rgb.blue = (uint8_t)((255 * q) / 1000);
break;

}
}

return rgb;
}

LRESULT CALLBACK ButtonsProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData)
{
switch (uMsg)
Expand Down Expand Up @@ -1012,6 +1101,54 @@ LRESULT CALLBACK ButtonsProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam,
}
return FALSE;
} break;
case IDC_VDP_PAL_RNB:
{
for (int i = 0; i < VDP_PAL_COLORS; ++i)
{
uint16_t w = 0;
uint8_t c = (i * VDP_PAL_COLORS) & 0xFF;
w |= (uint16_t)(((c >> 4) & 0xE) << 0);
w |= (uint16_t)(((c >> 4) & 0xE) << 4);
w |= (uint16_t)(((c >> 4) & 0xE) << 8);
((char*)&CRam)[i * 2 + 0] = (w >> 0) & 0xFF;
((char*)&CRam)[i * 2 + 1] = (w >> 8) & 0xFF;
}

for (int i = 0; i < VDP_PAL_COLORS; ++i)
{
uint16_t w = 0;
uint8_t c = ((255 - i) * VDP_PAL_COLORS) & 0xFF;
w |= (uint16_t)(((c >> 4) & 0xE) << 0);
w |= (uint16_t)(((c >> 4) & 0xE) << 4);
w |= (uint16_t)(((c >> 4) & 0xE) << 8);
((char*)&CRam)[(VDP_PAL_COLORS + i) * 2 + 0] = (w >> 0) & 0xFF;
((char*)&CRam)[(VDP_PAL_COLORS + i) * 2 + 1] = (w >> 8) & 0xFF;
}

for (int i = 0; i < VDP_PAL_COLORS; ++i)
{
HsvColor _hsv;
_hsv.hue = (((double)i / (double)VDP_PAL_COLORS)) * 3600;
_hsv.saturation = 850;
_hsv.value = 1000;
RgbColor _rgb = hsv2rgb(_hsv);

uint16_t w = 0;
w |= (uint16_t)((((int)_rgb.red >> 4) & 0xE) << 0);
w |= (uint16_t)((((int)_rgb.green >> 4) & 0xE) << 4);
w |= (uint16_t)((((int)_rgb.blue >> 4) & 0xE) << 8);
((char*)&CRam)[(VDP_PAL_COLORS * 2 + i) * 2 + 0] = (w >> 0) & 0xFF;
((char*)&CRam)[(VDP_PAL_COLORS * 2 + i) * 2 + 1] = (w >> 8) & 0xFF;
}

if (Game)
{
CRam_Flag = 1;
Show_Genesis_Screen(HWnd);
}

return FALSE;
} break;
case IDC_VDP_VRAM_DUMP:
{
char fname[2048];
Expand Down Expand Up @@ -1161,6 +1298,7 @@ LRESULT CALLBACK VDPRamProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
SetParent(GetDlgItem(hDlg, IDC_VDP_PAL_DUMP), hPalGroup);
SetParent(GetDlgItem(hDlg, IDC_VDP_PAL_LOAD), hPalGroup);
SetParent(GetDlgItem(hDlg, IDC_VDP_PAL_YY), hPalGroup);
SetParent(GetDlgItem(hDlg, IDC_VDP_PAL_RNB), hPalGroup);

SetWindowPos(hPalGroup, NULL,
r.right + 5,
Expand Down
2 changes: 1 addition & 1 deletion smd_loader/smd_loader.cpp
Expand Up @@ -5,7 +5,7 @@
*
*/

#define VERSION "1.11"
#define VERSION "1.12"
/*
* SEGA MEGA DRIVE/GENESIS ROMs Loader (Modified/Updated HardwareMan's source)
* Author: Dr. MefistO [Lab 313] <meffi@lab313.ru>
Expand Down
2 changes: 1 addition & 1 deletion z80_loader/z80_loader.cpp
Expand Up @@ -5,7 +5,7 @@
*
*/

#define VERSION "1.11"
#define VERSION "1.12"
/*
* SEGA MEGA DRIVE/GENESIS Z80 Drivers Loader
* Author: Dr. MefistO [Lab 313] <meffi@lab313.ru>
Expand Down

0 comments on commit 9ccfd3f

Please sign in to comment.