Skip to content

Commit

Permalink
Try to stabilize the terribly jumpy BOP helmet lamps
Browse files Browse the repository at this point in the history
  • Loading branch information
volkenborn committed Jan 30, 2024
1 parent eff7ff0 commit 708b337
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/wpc/sims/wpc/full/bop.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,27 +710,36 @@ static int bop_getMech(int mechNo) {
}

static WRITE_HANDLER(parallel_0_out) {
coreGlobals.lampMatrix[8] = coreGlobals.tmpLampMatrix[8] = data ^ 0xff;
coreGlobals.tmpLampMatrix[8] = data ^ 0xff;
core_write_pwm_output_8b(CORE_MODOUT_LAMP0 + 8 * 8, data ^ 0xff);
}
static WRITE_HANDLER(parallel_1_out) {
coreGlobals.lampMatrix[9] = coreGlobals.tmpLampMatrix[9] = data ^ 0xff;
coreGlobals.tmpLampMatrix[9] = data ^ 0xff;
core_write_pwm_output_8b(CORE_MODOUT_LAMP0 + 9 * 8, data ^ 0xff);
}

static WRITE_HANDLER(bop_wpc_w) {
static UINT16 lamps;
static UINT16 prev[64], lamps;
int i;
wpc_w(offset, data);
if (offset == WPC_SOLENOID1) {
if (offset == WPC_SOLENOID1 && (data & 3)) {
if (GET_BIT1) {
lamps <<= 1;
}
if (GET_BIT0) {
lamps |= 1;
}
}
parallel_0_out(0, lamps & 0xff);
parallel_1_out(0, lamps >> 8);
for (i = 0; i < 64; i++) {
// if the lamp state is not stable for some minimal time, deny the update
if (prev[i] != lamps) break;
if (i >= 63) {
parallel_0_out(0, lamps & 0xff);
parallel_1_out(0, lamps >> 8);
}
}
for (i = 63; i > 0; i--) prev[i] = prev[i-1];
prev[0] = lamps;
}

#ifdef PROC_SUPPORT
Expand Down

0 comments on commit 708b337

Please sign in to comment.