introducing: burn_shift.cpp / h. enabled in chqflag for now.

This commit is contained in:
dinkc64 2016-12-18 14:28:14 +00:00
parent 85fcee64b9
commit a5391013ac
12 changed files with 375 additions and 1 deletions

View File

@ -89,7 +89,7 @@ endif
depobj := $(drvobj) \
\
burn.o burn_gun.o burn_led.o burn_memory.o burn_sound.o burn_sound_c.o cheat.o debug_track.o hiscore.o load.o tilemap_generic.o \
burn.o burn_gun.o burn_led.o burn_shift.o burn_memory.o burn_sound.o burn_sound_c.o cheat.o debug_track.o hiscore.o load.o tilemap_generic.o \
tiles_generic.o timer.o vector.o \
\
6821pia.o 8255ppi.o 8257dma.o eeprom.o joyprocess.o nmk004.o nmk112.o kaneko_tmap.o mermaid.o pandora.o seibusnd.o sknsspr.o slapstic.o \

320
src/burn/burn_shift.cpp Normal file
View File

@ -0,0 +1,320 @@
// FBAlpha Shifter / Gear Display
#include "burnint.h"
#include "burn_shift.h"
INT32 BurnShiftEnabled = 1;
static INT32 shift_status;
static INT32 shift_alpha_level;
static INT32 shift_alpha_level2;
static INT32 shift_color;
static INT32 shift_size;
static INT32 shift_position0;
static INT32 shift_position;
static INT32 shift_xpos;
static INT32 shift_ypos;
static INT32 shift_xadv;
static INT32 shift_yadv;
static INT32 nScreenWidth, nScreenHeight;
static INT32 screen_flipped;
static INT32 flipscreen = -1;
#define a 0,
#define b 1,
UINT8 BurnGearRender[8*8];
UINT8 BurnGearL[8*8] = {
a b a a a a a a
a b b a a a a a
a b b a a a a a
a b b a a a a a
a b b a a a a a
a b b b b b b a
a b b b b b b a
a a a a a a a a };
UINT8 BurnGearL_V[8*8] = {
a a a a a a a a
a b b b b b b b
a b b b b b b a
a b b a a a a a
a b b a a a a a
a b b a a a a a
a b b a a a a a
a a a a a a a a };
UINT8 BurnGearL_V2[8*8] = {
a a a a a a a a
a a a a a a a a
a a a a a b b a
a a a a a b b a
a a a a a b b a
a b b b b b b a
a b b b b b b a
a a a a a a a a };
UINT8 BurnGearH[8*8] = {
a a a a a b b a
a b b a a b b a
a b b a a b b a
a b b b b b b a
a b b b b b b a
a b b a a b b a
a b a a a b b a
a a a a a a a a };
UINT8 BurnGearH_V[8*8] = {
a a a a a a a a
a b b b b b b a
a b b b b b b a
a a a b b a a a
a a a b b a a a
a b b b b b b a
a b b b b b b a
a a a a a a a a };
#undef b
#undef a
static inline UINT32 alpha_blend32(UINT32 d)
{
return (((((shift_color & 0xff00ff) * shift_alpha_level) + ((d & 0xff00ff) * shift_alpha_level2)) & 0xff00ff00) |
((((shift_color & 0x00ff00) * shift_alpha_level) + ((d & 0x00ff00) * shift_alpha_level2)) & 0x00ff0000)) >> 8;
}
static void set_shift_draw_position()
{
shift_position = shift_position0;
if (screen_flipped ^ flipscreen) {
switch (shift_position & 3) {
case SHIFT_POSITION_TOP_LEFT: shift_position = SHIFT_POSITION_BOTTOM_RIGHT; break;
case SHIFT_POSITION_TOP_RIGHT: shift_position = SHIFT_POSITION_BOTTOM_LEFT; break;
case SHIFT_POSITION_BOTTOM_LEFT: shift_position = SHIFT_POSITION_TOP_RIGHT; break;
case SHIFT_POSITION_BOTTOM_RIGHT: shift_position = SHIFT_POSITION_TOP_LEFT; break;
}
}
if (BurnDrvGetFlags() & BDF_ORIENTATION_VERTICAL) {
BurnDrvGetVisibleSize(&nScreenHeight, &nScreenWidth);
shift_xadv = 0;
shift_yadv = shift_size + 1;
switch (shift_position & 3)
{
case SHIFT_POSITION_TOP_LEFT:
shift_xpos = (nScreenWidth - 1) - shift_size;
shift_ypos = 1;
break;
case SHIFT_POSITION_BOTTOM_RIGHT:
shift_xpos = 1;
shift_ypos = (nScreenHeight - 1) - (shift_yadv * 1);
break;
case SHIFT_POSITION_BOTTOM_LEFT:
shift_xpos = 1;
shift_ypos = 1;
break;
case SHIFT_POSITION_TOP_RIGHT:
default:
shift_xpos = (nScreenWidth - 1) - shift_size;
shift_ypos = (nScreenHeight - 1) - (shift_yadv * 1);
break;
}
} else {
BurnDrvGetVisibleSize(&nScreenWidth, &nScreenHeight);
shift_xadv = shift_size + 1;
shift_yadv = 0;
switch (shift_position & 3)
{
case SHIFT_POSITION_BOTTOM_LEFT:
shift_xpos = 1;
shift_ypos = (nScreenHeight - 1) - shift_size;
// shift_ypos;
break;
case SHIFT_POSITION_TOP_RIGHT:
shift_xpos = (nScreenWidth - 1) - (shift_xadv * 1);
shift_ypos = 1;
break;
case SHIFT_POSITION_TOP_LEFT:
shift_xpos = 1;
shift_ypos = 1;
break;
case SHIFT_POSITION_BOTTOM_RIGHT:
default:
shift_xpos = (nScreenWidth - 1) - (shift_xadv * 1);
shift_ypos = (nScreenHeight - 1) - shift_size;
break;
}
}
}
void BurnShiftSetFlipscreen(INT32 flip)
{
#if defined FBA_DEBUG
if (!Debug_BurnShiftInitted) bprintf(PRINT_ERROR, _T("BurnShiftSetFlipscreen called without init\n"));
#endif
flip = flip ? 1 : 0;
if (flipscreen != flip) {
flipscreen = flip;
set_shift_draw_position();
}
}
void BurnShiftReset()
{
#if defined FBA_DEBUG
if (!Debug_BurnShiftInitted) bprintf(PRINT_ERROR, _T("BurnShiftReset called without init\n"));
#endif
BurnShiftSetStatus(0);
BurnShiftSetFlipscreen(0);
}
void BurnShiftInit(INT32 position, INT32 color, INT32 transparency)
{
Debug_BurnShiftInitted = 1;
shift_color = color;
shift_size = 8;
shift_position0 = position;
shift_alpha_level = (255 * transparency) / 100;
shift_alpha_level2 = 256 - shift_alpha_level;
screen_flipped = (BurnDrvGetFlags() & BDF_ORIENTATION_FLIPPED) ? 1 : 0;
BurnShiftReset();
}
void BurnShiftSetStatus(UINT32 status)
{
#if defined FBA_DEBUG
if (!Debug_BurnShiftInitted) bprintf(PRINT_ERROR, _T("BurnShiftSetStatus called without init\n"));
#endif
shift_status = status ? 1 : 0;
if (status) { // HIGH
if (shift_position0 & SHIFT_POSITION_ROTATE_CCW) {
//bprintf(0, _T("ro-H!"));
memcpy(&BurnGearRender, &BurnGearH_V, sizeof(BurnGearRender));
} else {
memcpy(&BurnGearRender, &BurnGearH, sizeof(BurnGearRender));
}
} else { // LOW
if (shift_position0 & SHIFT_POSITION_ROTATE_CCW) {
//bprintf(0, _T("ro-L!"));
memcpy(&BurnGearRender, &BurnGearL_V2, sizeof(BurnGearRender));
} else {
memcpy(&BurnGearRender, &BurnGearL, sizeof(BurnGearRender));
}
}
}
void BurnShiftExit()
{
#if defined FBA_DEBUG
if (!Debug_BurnShiftInitted) bprintf(PRINT_ERROR, _T("BurnShiftExit called without init\n"));
#endif
BurnShiftReset();
shift_alpha_level = 0;
shift_alpha_level2 = 0;
shift_color = 0;
shift_size = 0;
shift_position = 0;
shift_position0 = 0;
shift_xpos = 0;
shift_ypos = 0;
screen_flipped = 0;
nScreenWidth = 0;
nScreenHeight = 0;
flipscreen = -1;
Debug_BurnShiftInitted = 0;
}
void BurnShiftRender()
{
#if defined FBA_DEBUG
if (!Debug_BurnShiftInitted) bprintf(PRINT_ERROR, _T("BurnShiftRender called without init\n"));
#endif
if (!BurnShiftEnabled) return;
INT32 xpos = shift_xpos;
INT32 ypos = shift_ypos;
INT32 color = BurnHighCol((shift_color >> 16) & 0xff, (shift_color >> 8) & 0xff, (shift_color >> 0) & 0xff, 0);
{
if (xpos < 0 || xpos > (nScreenWidth - shift_size)) return;
{
for (INT32 y = 0; y < 8; y++)
{
UINT8 *ptr = pBurnDraw + (((ypos + y) * nScreenWidth) + xpos) * nBurnBpp;
for (INT32 x = 0; x < 8; x++) {
if (BurnGearRender[(y*8)+x])
{
if (nBurnBpp >= 4)
{
*((UINT32*)ptr) = alpha_blend32(*((UINT32*)ptr));
}
else if (nBurnBpp == 3)
{
UINT32 t = alpha_blend32((ptr[2] << 16) | (ptr[1] << 8) | ptr[0]);
ptr[2] = t >> 16;
ptr[1] = t >> 8;
ptr[0] = t >> 0;
}
else if (nBurnBpp == 2) // alpha blend not supported for 16-bit
{
*((UINT16*)ptr) = color;
}
}
ptr += nBurnBpp;
}
}
}
xpos += shift_xadv;
ypos += shift_yadv;
}
}
INT32 BurnShiftScan(INT32 nAction, INT32 *pnMin)
{
#if defined FBA_DEBUG
if (!Debug_BurnShiftInitted) bprintf(PRINT_ERROR, _T("BurnShiftScan called without init\n"));
#endif
if (pnMin != NULL) {
*pnMin = 0x029707;
}
if (nAction & ACB_DRIVER_DATA) {
SCAN_VAR(shift_status);
}
return 0;
}

25
src/burn/burn_shift.h Normal file
View File

@ -0,0 +1,25 @@
#define SHIFT_COLOR_RED 0xff0000
#define SHIFT_COLOR_GREEN 0x00ff00
#define SHIFT_COLOR_BLUE 0x0000ff
#define SHIFT_COLOR_WHITE 0xffffff
#define SHIFT_COLOR_YELLOW 0xffff00
#define SHIFT_POSITION_TOP_LEFT 0
#define SHIFT_POSITION_TOP_RIGHT 1
#define SHIFT_POSITION_BOTTOM_LEFT 2
#define SHIFT_POSITION_BOTTOM_RIGHT 3
#define SHIFT_POSITION_ROTATE_CCW 0x10
// transparency is a percentage 0 - 100
void BurnShiftInit(INT32 position, INT32 color, INT32 transparency);
void BurnShiftReset();
void BurnShiftSetFlipscreen(INT32 flip);
void BurnShiftRender();
void BurnShiftSetStatus(UINT32 status);
void BurnShiftExit();
INT32 BurnShiftScan(INT32 nAction, INT32 *pnMin);
extern INT32 BurnShiftEnabled;

View File

@ -169,6 +169,7 @@ void BurnExitMemoryManager();
extern UINT8 Debug_BurnTransferInitted;
extern UINT8 Debug_BurnGunInitted;
extern UINT8 Debug_BurnLedInitted;
extern UINT8 Debug_BurnShiftInitted;
extern UINT8 Debug_HiscoreInitted;
extern UINT8 Debug_GenericTilesInitted;

View File

@ -5,6 +5,7 @@
UINT8 Debug_BurnTransferInitted;
UINT8 Debug_BurnGunInitted;
UINT8 Debug_BurnLedInitted;
UINT8 Debug_BurnShiftInitted;
UINT8 Debug_HiscoreInitted;
UINT8 Debug_GenericTilesInitted;
@ -81,6 +82,7 @@ void DebugTrackerExit()
if (Debug_BurnTransferInitted) bprintf(PRINT_ERROR, _T("BurnTransfer Not Exited\n"));
if (Debug_BurnGunInitted) bprintf(PRINT_ERROR, _T("BurnGun Not Exited\n"));
if (Debug_BurnLedInitted) bprintf(PRINT_ERROR, _T("BurnLed Not Exited\n"));
if (Debug_BurnShiftInitted) bprintf(PRINT_ERROR, _T("BurnShit Not Exited\n"));
if (Debug_HiscoreInitted) bprintf(PRINT_ERROR, _T("Hiscore Not Exited\n"));
if (Debug_GenericTilesInitted) bprintf(PRINT_ERROR, _T("GenericTiles Not Exited\n"));

View File

@ -7,6 +7,7 @@
#include "konamiic.h"
#include "burn_ym2151.h"
#include "k007232.h"
#include "burn_shift.h"
static UINT8 *AllMem;
static UINT8 *MemEnd;
@ -441,6 +442,8 @@ static INT32 DrvDoReset(INT32 clear_mem)
gearshifter = 1; // because active low, start in low gear.
watchdog = 0;
BurnShiftReset();
BurnShiftSetStatus(!gearshifter);
HiscoreReset();
@ -555,6 +558,10 @@ static INT32 DrvInit()
K051316Init(1, DrvGfxROM2, DrvGfxROM2, 0xfffff, K051316Callback1, 8, 0xc0 | 0x200);
K051316SetOffset(1, -96, -16);
konami_set_highlight_over_sprites_mode(1);
BurnShiftInit(SHIFT_POSITION_BOTTOM_RIGHT | SHIFT_POSITION_ROTATE_CCW, SHIFT_COLOR_GREEN, 80);
DrvDoReset(1);
return 0;
@ -572,6 +579,8 @@ static INT32 DrvExit()
K007232Exit();
BurnYM2151Exit();
BurnShiftExit();
BurnFree (AllMem);
return 0;
@ -622,6 +631,8 @@ static INT32 DrvDraw()
KonamiBlendCopy(DrvPalette);
BurnShiftRender();
return 0;
}
@ -649,6 +660,7 @@ static INT32 DrvFrame()
{ // gear shifter stuff
if (prevshift != DrvJoy2[0] && DrvJoy2[0]) {
gearshifter = !gearshifter;
BurnShiftSetStatus(!gearshifter); // active-low
}
DrvInputs[1] &= ~1;
DrvInputs[1] |= gearshifter;

View File

@ -1031,6 +1031,7 @@ BEGIN
#endif
MENUITEM "Save High Scores when supported", MENU_SAVEHISCORES
MENUITEM "Use alpha blend effects when supported", MENU_USEBLEND
MENUITEM "Display Gear-Shift Indicator when supported", MENU_GEARSHIFT
#ifdef INCLUDE_AVI_RECORDING
POPUP "AVI Writer Output size"
BEGIN

View File

@ -213,6 +213,9 @@ int DrvInit(int nDrvNum, bool bRestore);
int DrvInitCallback(); // Used when Burn library needs to load a game. DrvInit(nBurnSelect, false)
int DrvExit();
// burn_shift
extern INT32 BurnShiftEnabled;
// run.cpp
extern int bRunPause;
extern int bAltPause;

View File

@ -243,6 +243,7 @@ int ConfigAppLoad()
VAR(EnableHiscores);
VAR(bBurnUseBlend);
VAR(BurnShiftEnabled);
#ifdef INCLUDE_AVI_RECORDING
VAR(nAvi3x);
@ -631,6 +632,9 @@ int ConfigAppSave()
_ftprintf(h, _T("\n// If non-zero, enable alpha blending support.\n"));
VAR(bBurnUseBlend);
_ftprintf(h, _T("\n// If non-zero, enable gear shifter display support.\n"));
VAR(BurnShiftEnabled);
#ifdef INCLUDE_AVI_RECORDING
_ftprintf(h, _T("\n// If non-zero, enable 1x - 3x pixel output for the AVI writer.\n"));

View File

@ -975,6 +975,7 @@ void MenuUpdate()
CheckMenuItem(hMenu, MENU_CREATEDIRS, bAlwaysCreateSupportFolders ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hMenu, MENU_SAVEHISCORES, EnableHiscores ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hMenu, MENU_USEBLEND, bBurnUseBlend ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(hMenu, MENU_GEARSHIFT, BurnShiftEnabled ? MF_CHECKED : MF_UNCHECKED);
#ifdef INCLUDE_AVI_RECORDING
if (nAvi3x <= 1) {

View File

@ -639,6 +639,7 @@
#define MENU_AVI1X 10724
#define MENU_AVI2X 10725
#define MENU_AVI3X 10726
#define MENU_GEARSHIFT 10727
#define MENU_BASIC_NORMAL 11001
#define MENU_BASIC_SCAN 11002

View File

@ -1845,6 +1845,10 @@ static void OnCommand(HWND /*hDlg*/, int id, HWND /*hwndCtl*/, UINT codeNotify)
case MENU_USEBLEND:
bBurnUseBlend = !bBurnUseBlend;
break;
case MENU_GEARSHIFT:
BurnShiftEnabled = !BurnShiftEnabled;
break;
#ifdef INCLUDE_AVI_RECORDING
case MENU_AVI1X: