Skip to content

Commit

Permalink
DMD: fix backward compatibility (VPX renderer, colorization plugins) …
Browse files Browse the repository at this point in the history
…and clean ups

- change dmd buffer to be linear sized, 0 based
- compute both luminance and bitplane DMD frames for PWM enabled drivers
- overall cleanups
  • Loading branch information
vbousquet committed Sep 8, 2024
1 parent 8de0922 commit d00eaed
Show file tree
Hide file tree
Showing 15 changed files with 800 additions and 647 deletions.
23 changes: 15 additions & 8 deletions ext/dmddevice/usbalphanumeric.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#ifndef LIBPINMAME
static UINT8 AlphaNumericFrameBuffer[2048] = {0};


#if defined(LIBPINMAME) || defined(VPINMAME)
// Encode frame with a UINT8 per dot (0..3 value)
#define ANFB_USE_BITPLANES 0
#define ANFB_USE_LUMINANCE 1
static UINT8 AlphaNumericFrameBuffer[128*32] = {0};
#else
static UINT8 AlphaNumericFrameBuffer[4096] = {0};
// Custom encoding for PinDMD devices, using 4 bit planes to encode dot state
#define ANFB_USE_BITPLANES 1
#define ANFB_USE_LUMINANCE 0
static UINT8 AlphaNumericFrameBuffer[128*32*4/8] = {0};
#endif

static const UINT8 segSizes[8][16] = {
Expand Down Expand Up @@ -172,13 +180,12 @@ static const UINT8 segs[8][17][5][2] = {
//*****************************************************
static UINT8 getPixel(const int x, const int y)
{
#ifndef LIBPINMAME
#if ANFB_USE_BITPLANES
const int v = (y*16)+(x/8);
const int z = 1<<(x%8);
// just check high buff

return ((AlphaNumericFrameBuffer[v+512]&z)!=0);
#else
#elif ANFB_USE_LUMINANCE
return (AlphaNumericFrameBuffer[y * 128 + x] != 0);
#endif
}
Expand All @@ -191,7 +198,7 @@ static UINT8 getPixel(const int x, const int y)
//*****************************************************
static void drawPixel(const int x, const int y, const UINT8 colour)
{
#ifndef LIBPINMAME
#if ANFB_USE_BITPLANES
const int v = (y*16)+(x/8);
const int z = 1<<(x%8);
// clear both low and high buffer pixel
Expand Down Expand Up @@ -221,7 +228,7 @@ static void drawPixel(const int x, const int y, const UINT8 colour)
AlphaNumericFrameBuffer[v+1024] |= z;
AlphaNumericFrameBuffer[v+1536] ^= z;
}
#else
#elif ANFB_USE_LUMINANCE
AlphaNumericFrameBuffer[y * 128 + x] = colour;
#endif
}
Expand Down
25 changes: 9 additions & 16 deletions src/wpc/alvgdmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ static void dmd32_init(struct sndbrdData *brdData) {
dmdlocals.brdData = *brdData;
dmd32_bank_w(0,0); //Set DMD Bank to 0
dmdlocals.selsync = 1; //Start Sync @ 1 (PCA020A only)
core_dmd_pwm_init(&dmdlocals.pwm_state, 128, 32, IS_PCA020 ? CORE_DMD_PWM_FILTER_ALVG1 : CORE_DMD_PWM_FILTER_ALVG2);
core_dmd_pwm_init(&dmdlocals.pwm_state, 128, 32, IS_PCA020 ? CORE_DMD_PWM_FILTER_ALVG1 : CORE_DMD_PWM_FILTER_ALVG2, CORE_DMD_PWM_COMBINER_SUM_4);
}

static void dmd32_exit(int boardNo) {
Expand Down Expand Up @@ -321,17 +321,10 @@ static INTERRUPT_GEN(dmd32_firq1) {
assert((dmdlocals.colstart & 0x07) == 0); // Lowest 3 bits are actually loaded to the shift register, so it is possible to perform a dot shift, but we don't support it
const UINT8* RAM = (UINT8*)dmd32RAM + (dmdlocals.vid_page << 11) + ((dmdlocals.colstart >> 3) & 0x0F);
const unsigned int plan_mask = dmdlocals.plans_enable ? 0x7F : 0x1F; // either render 4 different frames or 4 times the same
if (dmdlocals.pwm_state.legacyColorization) {
// For backwards compatibility regarding colorization, previous implementation submitted first frame with a weight of 1, and second (same as first if plans_enable = 0) with a weight of 2 => 4 shades (with unbalanced luminance between frames)
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x00) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x20) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x20) & plan_mask) << 4));
} else {
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x00) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x20) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x40) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x60) & plan_mask) << 4));
}
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x00) & plan_mask) << 4), 1);
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x20) & plan_mask) << 4), 1);
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x40) & plan_mask) << 4), 1);
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x60) & plan_mask) << 4), 1);
}

static INTERRUPT_GEN(dmd32_firq2) {
Expand All @@ -346,10 +339,10 @@ static INTERRUPT_GEN(dmd32_firq2) {
assert((dmdlocals.colstart & 0x07) == 0); // Lowest 3 bits are actually loaded to the shift register, so it is possible to perform a dot shift, but we don't support it
const UINT8* RAM = (UINT8*)dmd32RAM + (dmdlocals.vid_page << 11) + ((dmdlocals.colstart >> 3) & 0x0F);
const unsigned int plan_mask = dmdlocals.plans_enable ? 0x7F : 0x1F; // either render 4 different frames or 4 times the same
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x20) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x40) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x60) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x00) & plan_mask) << 4));
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x20) & plan_mask) << 4), 1);
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x40) & plan_mask) << 4), 1);
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x60) & plan_mask) << 4), 1);
core_dmd_submit_frame(&dmdlocals.pwm_state, RAM + (((dmdlocals.rowstart + 0x00) & plan_mask) << 4), 1);
}

PINMAME_VIDEO_UPDATE(alvgdmd_update) {
Expand Down
10 changes: 5 additions & 5 deletions src/wpc/capcom.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,8 @@ PINMAME_VIDEO_UPDATE(cc_dmd128x32) {

UINT32 offset = locals.visible_page ? 0x800 * locals.visible_page - 0x10 : 0;
RAM = ramptr+offset;
for (ii = 0; ii <= 32; ii++) {
UINT8 *line = &coreGlobals.dotCol[ii][0];
for (ii = 0; ii < 32; ii++) {
UINT8 *line = &coreGlobals.dmdDotRaw[ii*layout->length];
for (kk = 0; kk < 16; kk++) {
UINT16 intens1 = RAM[0];
for(jj=0;jj<8;jj++) {
Expand All @@ -977,9 +977,9 @@ PINMAME_VIDEO_UPDATE(cc_dmd256x64) {

UINT32 offset = locals.visible_page ? 0x800 * locals.visible_page - 0x20 : 0;
RAM = ramptr+offset;
for (ii = 0; ii <= 64; ii++) {
UINT8 *linel = &coreGlobals.dotCol[ii][0];
UINT8 *liner = &coreGlobals.dotCol[ii][128];
for (ii = 0; ii < 64; ii++) {
UINT8 *linel = &coreGlobals.dmdDotRaw[ii * layout->length];
UINT8 *liner = &coreGlobals.dmdDotRaw[ii * layout->length + 128];
for (kk = 0; kk < 16; kk++) {
UINT16 intensl = RAM[0];
UINT16 intensr = RAM[0x10];
Expand Down
Loading

0 comments on commit d00eaed

Please sign in to comment.