Skip to content

Commit

Permalink
z80ctc.h: if-else brace style
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Nov 6, 2023
1 parent caa8648 commit f2e1194
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions chips/z80ctc.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ static uint64_t _z80ctc_active_edge(z80ctc_t* ctc, uint64_t pins, int chn) {
if (0 == --ctc->down_counter[chn]) {
pins = _z80ctc_counter_zero(ctc, pins, chn);
}
}
else if (ctc->waiting_for_trigger[chn]) {
} else if (ctc->waiting_for_trigger[chn]) {
// timer mode and waiting for trigger?
ctc->waiting_for_trigger[chn] = false;
ctc->down_counter[chn] = ctc->constant[chn];
Expand All @@ -316,33 +315,28 @@ uint64_t _z80ctc_write(z80ctc_t* ctc, uint64_t pins, int chn, uint8_t data) {
if ((ctc->control[chn] & Z80CTC_CTRL_MODE) == Z80CTC_CTRL_MODE_TIMER) {
if ((ctc->control[chn] & Z80CTC_CTRL_TRIGGER) == Z80CTC_CTRL_TRIGGER_WAIT) {
ctc->waiting_for_trigger[chn] = true;
}
else {
} else {
ctc->down_counter[chn] = ctc->constant[chn];
}
}
else {
} else {
ctc->down_counter[chn] = ctc->constant[chn];
}
}
else if (data & Z80CTC_CTRL_CONTROL) {
} else if (data & Z80CTC_CTRL_CONTROL) {
// a control word
const uint8_t old_ctrl = ctc->control[chn];
ctc->control[chn] = data;
ctc->trigger_edge[chn] = (data & Z80CTC_CTRL_EDGE) == Z80CTC_CTRL_EDGE_RISING;
if ((ctc->control[chn] & Z80CTC_CTRL_PRESCALER) == Z80CTC_CTRL_PRESCALER_16) {
ctc->prescaler_mask[chn] = 0x0F;
}
else {
} else {
ctc->prescaler_mask[chn] = 0xFF;
}

// changing the Trigger Slope trigger an 'active edge'
if ((old_ctrl & Z80CTC_CTRL_EDGE) != (ctc->control[chn] & Z80CTC_CTRL_EDGE)) {
pins = _z80ctc_active_edge(ctc, pins, chn);
}
}
else {
} else {
/* the interrupt vector for the entire CTC must be written
to channel 0, the vectors for the following channels
are then computed from the base vector plus 2 bytes per channel
Expand All @@ -362,8 +356,7 @@ static uint64_t _z80ctc_iorq(z80ctc_t* ctc, uint64_t pins) {
if (pins & Z80CTC_RD) {
const uint8_t data = ctc->down_counter[chn];
Z80CTC_SET_DATA(pins, data);
}
else {
} else {
const uint8_t data = Z80CTC_GET_DATA(pins);
pins = _z80ctc_write(ctc, pins, chn, data);
}
Expand All @@ -384,8 +377,7 @@ static uint64_t _z80ctc_tick(z80ctc_t* ctc, uint64_t pins) {
pins = _z80ctc_active_edge(ctc, pins, chn);
}
}
}
else if ((ctc->control[chn] & (Z80CTC_CTRL_MODE|Z80CTC_CTRL_RESET|Z80CTC_CTRL_CONST_FOLLOWS)) == Z80CTC_CTRL_MODE_TIMER) {
} else if ((ctc->control[chn] & (Z80CTC_CTRL_MODE|Z80CTC_CTRL_RESET|Z80CTC_CTRL_CONST_FOLLOWS)) == Z80CTC_CTRL_MODE_TIMER) {
// handle timer mode downcounting
if (0 == ((--ctc->prescaler[chn]) & ctc->prescaler_mask[chn])) {
// prescaler has reached zero, tick the down counter
Expand Down

0 comments on commit f2e1194

Please sign in to comment.