Skip to content

Commit

Permalink
Prevent rendering DMD background too light
Browse files Browse the repository at this point in the history
  • Loading branch information
volkenborn committed Nov 20, 2024
1 parent 0531870 commit 723cf61
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
14 changes: 5 additions & 9 deletions src/wpc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,6 @@ void core_dmd_update_pwm(core_tDMDPWMState* dmd_state) {
void core_dmd_render_internal(struct mame_bitmap *bitmap, const int x, const int y, const int width, const int height, const UINT8* const dmdDotLum, const int apply_aa) {
#define DMD_OFS(row, col) ((row)*width + col)
#define DMD_PAL(x) ((unsigned int)sizeof(core_palette)/3u - 48u + ((unsigned int)(x) * 47u) / 255u) // The trail of PinMAME palette has 48 DMD dot shades
//#define DMD_PAL(x) = Machine->pens[COL_DMDOFF][63 + (x >> 4)]
BMTYPE **lines = ((BMTYPE **)bitmap->line) + (y * locals.displaySize);
for (int ii = 0; ii < height; ii++) {
BMTYPE *line = (*lines) + (x * locals.displaySize);
Expand All @@ -3220,27 +3219,24 @@ void core_dmd_render_internal(struct mame_bitmap *bitmap, const int x, const int
}
// Apply antialiasing if enabled, or clear pixels between dots otherwise
assert((locals.displaySize == 1) || (locals.displaySize == 2));
if (locals.displaySize == 2) {
if (apply_aa && locals.displaySize == 2) {
lines = ((BMTYPE **)bitmap->line) + (y * locals.displaySize);
for (int ii = 0; ii < height * 2 - 1; ii++) {
BMTYPE *line = (*lines) + x;
for (int jj = 0; jj < width * 2 - 1; jj++) {
const int pi = (ii - 1) >> 1, pj = (jj - 1) >> 1;
if (!apply_aa) {
if ((ii & 1) || (jj & 1))
*line = DMD_PAL(0);
} else if ((ii & 1) && (jj & 1)) { // Corner point
if ((ii & 1) && (jj & 1)) { // Corner point
const UINT32 lum = ((UINT32)dmdDotLum[DMD_OFS(pi, pj)] + (UINT32)dmdDotLum[DMD_OFS(pi+1, pj)] + (UINT32)dmdDotLum[DMD_OFS(pi, pj+1)] + (UINT32)dmdDotLum[DMD_OFS(pi+1, pj+1)]) / 6;
assert(0 <= lum && lum <= 255);
*line = DMD_PAL(lum);
*line = lum == 0 ? 0 : DMD_PAL(lum);
} else if (ii & 1) { // Vertical side point
const UINT32 lum = ((UINT32)dmdDotLum[DMD_OFS(pi, pj+1)] + (UINT32)dmdDotLum[DMD_OFS(pi+1, pj+1)]) / 3;
assert(0 <= lum && lum <= 255);
*line = DMD_PAL(lum);
*line = lum == 0 ? 0 : DMD_PAL(lum);
} else if (jj & 1) { // Horizontal side point
const UINT32 lum = ((UINT32)dmdDotLum[DMD_OFS(pi+1, pj)] + (UINT32)dmdDotLum[DMD_OFS(pi+1, pj+1)]) / 3;
assert(0 <= lum && lum <= 255);
*line = DMD_PAL(lum);
*line = lum == 0 ? 0 : DMD_PAL(lum);
}
line++;
}
Expand Down
8 changes: 4 additions & 4 deletions src/wpc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,10 @@ extern void core_getAllPhysicSols(float* const state);

/*-- AC sync and PWM integration --*/
extern void core_update_pwm_outputs(const int startIndex, const int count);
INLINE void core_update_pwm_gis() { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_GI)) core_update_pwm_outputs(CORE_MODOUT_GI0, coreGlobals.nGI); }
INLINE void core_update_pwm_solenoids() { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS | CORE_MODOUT_ENABLE_MODSOL)) core_update_pwm_outputs(CORE_MODOUT_SOL0, coreGlobals.nSolenoids); }
INLINE void core_update_pwm_segments() { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_ALPHASEGS)) core_update_pwm_outputs(CORE_MODOUT_SEG0, coreGlobals.nAlphaSegs); }
INLINE void core_update_pwm_lamps() { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_LAMPS)) core_update_pwm_outputs(CORE_MODOUT_LAMP0, coreGlobals.nLamps); }
INLINE void core_update_pwm_gis(void) { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_GI)) core_update_pwm_outputs(CORE_MODOUT_GI0, coreGlobals.nGI); }
INLINE void core_update_pwm_solenoids(void) { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_SOLENOIDS | CORE_MODOUT_ENABLE_MODSOL)) core_update_pwm_outputs(CORE_MODOUT_SOL0, coreGlobals.nSolenoids); }
INLINE void core_update_pwm_segments(void) { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_ALPHASEGS)) core_update_pwm_outputs(CORE_MODOUT_SEG0, coreGlobals.nAlphaSegs); }
INLINE void core_update_pwm_lamps(void) { if (options.usemodsol & (CORE_MODOUT_FORCE_ON | CORE_MODOUT_ENABLE_PHYSOUT_LAMPS)) core_update_pwm_outputs(CORE_MODOUT_LAMP0, coreGlobals.nLamps); }
extern void core_set_pwm_output_type(int startIndex, int count, int type);
extern void core_set_pwm_output_types(int startIndex, int count, int* outputTypes);
extern void core_set_pwm_output_bulb(int startIndex, int count, int bulb, float U, int isAC, float serial_R, float relative_brightness);
Expand Down

0 comments on commit 723cf61

Please sign in to comment.