} else {
_CHARS_PER_LINE = -1;
}
- if(osd->cehck_feature(_T("SCREEN_WIDTH"))) {
+ if(osd->check_feature(_T("SCREEN_WIDTH"))) {
_SCREEN_WIDTH = osd->get_feature_int_value(_T("SCREEN_WIDTH"));
}
- if(osd->cehck_feature(_T("SCREEN_HEIGHT"))) {
+ if(osd->check_feature(_T("SCREEN_HEIGHT"))) {
_SCREEN_HEIGHT = osd->get_feature_int_value(_T("SCREEN_HEIGHT"));
}
if(osd->check_feature(_T("LINES_PER_FRAME"))) {
} else {
_LINES_PER_FRAME = 64;
}
- if(osd->chack_keature(_T("HD46505_CHAR_CLOCK"))) {
+ if(osd->check_feature(_T("HD46505_CHAR_CLOCK"))) {
_E_HD46505_CHAR_CLOCK = true;
_HD46505_CHAR_CLOCK = osd->get_feature_double_value(_T("HD46505_CHAR_CLOCK"));
}
- if(osd->chack_keature(_T("HD46505_HORIZ_FREQ"))) {
+ if(osd->check_feature(_T("HD46505_HORIZ_FREQ"))) {
_E_HD46505_HORIZ_FREQ = true;
_HD46505_HORIZ_FREQ = osd->get_feature_double_value(_T("HD46505_HORIZ_FREQ"));
}
disp_end_clock = 0;
//#if defined(HD46505_CHAR_CLOCK)
- if(_E__HD46505_CHAR_CLOCK) {
+ if(_E_HD46505_CHAR_CLOCK) {
char_clock = 0;
next_char_clock = _HD46505_CHAR_CLOCK;
} else
{
cpu_clocks = new_clocks;
//#if !defined(HD46505_CHAR_CLOCK) && !defined(HD46505_HORIZ_FREQ)
- if((!_E_HD46505_CHAR_CLOCK) && (!_E_HD46505_HORIZ_FREQ) {
+ if((!_E_HD46505_CHAR_CLOCK) && (!_E_HD46505_HORIZ_FREQ)) {
frames_per_sec = new_frames_per_sec;
}
//#endif
void I8253::initialize()
{
+ DEVICE::initialize();
+ __HAS_I8254 = osd->check_feature(_T("HAS_I8254"));
for(int ch = 0; ch < 3; ch++) {
counter[ch].prev_out = true;
counter[ch].prev_in = false;
counter[ch].low_write = counter[ch].high_write = false;
counter[ch].delay = false;
counter[ch].start = false;
-#ifdef HAS_I8254
- // 8254 read-back command
- counter[ch].null_count = true;
- counter[ch].status_latched = false;
-#endif
+//#ifdef HAS_I8254
+ if(__HAS_I8254) {
+ // 8254 read-back command
+ counter[ch].null_count = true;
+ counter[ch].status_latched = false;
+ }
+//#endif
}
}
}
counter[ch].high_write = false;
}
-#ifdef HAS_I8254
- counter[ch].null_count = true;
-#endif
+//#ifdef HAS_I8254
+ if(__HAS_I8254) counter[ch].null_count = true;
+//#endif
// set signal
if(counter[ch].mode == 0) {
set_signal(ch, false);
case 3: // ctrl reg
if((data & 0xc0) == 0xc0) {
-#ifdef HAS_I8254
- // i8254 read-back command
- for(ch = 0; ch < 3; ch++) {
- uint8_t bit = 2 << ch;
- if(!(data & 0x10) && !counter[ch].status_latched) {
- counter[ch].status = counter[ch].ctrl_reg & 0x3f;
- if(counter[ch].prev_out) {
- counter[ch].status |= 0x80;
+//#ifdef HAS_I8254
+ if(__HAS_I8254) {
+ // i8254 read-back command
+ for(ch = 0; ch < 3; ch++) {
+ uint8_t bit = 2 << ch;
+ if(!(data & 0x10) && !counter[ch].status_latched) {
+ counter[ch].status = counter[ch].ctrl_reg & 0x3f;
+ if(counter[ch].prev_out) {
+ counter[ch].status |= 0x80;
+ }
+ if(counter[ch].null_count) {
+ counter[ch].status |= 0x40;
+ }
+ counter[ch].status_latched = true;
}
- if(counter[ch].null_count) {
- counter[ch].status |= 0x40;
+ if(!(data & 0x20) && !counter[ch].count_latched) {
+ latch_count(ch);
}
- counter[ch].status_latched = true;
- }
- if(!(data & 0x20) && !counter[ch].count_latched) {
- latch_count(ch);
}
}
-#endif
+//#endif
break;
}
ch = (data >> 6) & 3;
stop_count(ch);
counter[ch].count_reg = 0;
// }
-#ifdef HAS_I8254
- counter[ch].null_count = true;
-#endif
+//#ifdef HAS_I8254
+ if(__HAS_I8254) counter[ch].null_count = true;
+//#endif
} else if(!counter[ch].count_latched) {
latch_count(ch);
}
case 0:
case 1:
case 2:
-#ifdef HAS_I8254
- if(counter[ch].status_latched) {
- counter[ch].status_latched = false;
- return counter[ch].status;
+//#ifdef HAS_I8254
+ if(__HAS_I8254) {
+ if(counter[ch].status_latched) {
+ counter[ch].status_latched = false;
+ return counter[ch].status;
+ }
}
-#endif
+//#endif
// if not latched, through current count
if(!counter[ch].count_latched) {
if(!counter[ch].low_read && !counter[ch].high_read) {
clock -= 1;
counter[ch].delay = false;
counter[ch].count = COUNT_VALUE(ch);
-#ifdef HAS_I8254
- counter[ch].null_count = false;
-#endif
+//#ifdef HAS_I8254
+ if(__HAS_I8254) counter[ch].null_count = false;
+//#endif
}
// update counter
if(counter[ch].count <= 0) {
if(counter[ch].mode == 0 || counter[ch].mode == 2 || counter[ch].mode == 3) {
counter[ch].count += tmp;
-#ifdef HAS_I8254
- counter[ch].null_count = false;
-#endif
+//#ifdef HAS_I8254
+ if(__HAS_I8254) counter[ch].null_count = false;
+//#endif
goto loop;
} else {
counter[ch].start = false;
state_fio->FputInt32(counter[i].mode);
state_fio->FputBool(counter[i].delay);
state_fio->FputBool(counter[i].start);
-#ifdef HAS_I8254
- state_fio->FputBool(counter[i].null_count);
- state_fio->FputBool(counter[i].status_latched);
- state_fio->FputUint8(counter[i].status);
-#endif
+//#ifdef HAS_I8254
+ if(__HAS_I8254) {
+ state_fio->FputBool(counter[i].null_count);
+ state_fio->FputBool(counter[i].status_latched);
+ state_fio->FputUint8(counter[i].status);
+ }
+//#endif
state_fio->FputUint64(counter[i].freq);
state_fio->FputInt32(counter[i].register_id);
state_fio->FputUint32(counter[i].input_clk);
counter[i].mode = state_fio->FgetInt32();
counter[i].delay = state_fio->FgetBool();
counter[i].start = state_fio->FgetBool();
-#ifdef HAS_I8254
- counter[i].null_count = state_fio->FgetBool();
- counter[i].status_latched = state_fio->FgetBool();
- counter[i].status = state_fio->FgetUint8();
-#endif
+//#ifdef HAS_I8254
+ if(__HAS_I8254) {
+ counter[i].null_count = state_fio->FgetBool();
+ counter[i].status_latched = state_fio->FgetBool();
+ counter[i].status = state_fio->FgetUint8();
+ }
+//#endif
counter[i].freq = state_fio->FgetUint64();
counter[i].register_id = state_fio->FgetInt32();
counter[i].input_clk = state_fio->FgetUint32();
#define EVENT_COUNTER 0
#define EVENT_TIMER 4
+void Z80CTC::initialize()
+{
+ DEVICE::initialize();
+ _E_Z80CTC_CLOCKS = osd->check_feature(_T("Z80CTC_CLOCKS"));
+ if(_E_Z80CTC_CLOCKS) {
+ __Z80CTC_CLOCKS = osd->get_feature_double_value(_T("Z80CTC_CLOCKS"));
+ }
+}
+
void Z80CTC::reset()
{
for(int ch = 0; ch < 4; ch++) {
}
} else if(counter[ch].sysclock_id != -1) {
int passed = get_passed_clock(counter[ch].prev);
-#ifdef Z80CTC_CLOCKS
- uint32_t input = (uint32_t)(passed * Z80CTC_CLOCKS / cpu_clocks);
-#else
- uint32_t input = passed;
-#endif
+ uint32_t input;
+//#ifdef Z80CTC_CLOCKS
+ if(_E_Z80CTC_CLOCKS) {
+ input = (uint32_t)(passed * __Z80CTC_CLOCKS / cpu_clocks);
+ } else {
+//#else
+ input = passed;
+ }
+//#endif
if(counter[ch].input <= input) {
input = counter[ch].input - 1;
}
}
if(counter[ch].sysclock_id == -1) {
counter[ch].input = counter[ch].count * counter[ch].prescaler - counter[ch].clocks;
-#ifdef Z80CTC_CLOCKS
- counter[ch].period = (uint32_t)(counter[ch].input * cpu_clocks / Z80CTC_CLOCKS) + err;
-#else
- counter[ch].period = counter[ch].input + err;
-#endif
+//#ifdef Z80CTC_CLOCKS
+ if(_E_Z80CTC_CLOCKS) {
+ counter[ch].period = (uint32_t)(counter[ch].input * cpu_clocks / __Z80CTC_CLOCKS) + err;
+ } else {
+//#else
+ counter[ch].period = counter[ch].input + err;
+ }
+//#endif
counter[ch].prev = get_current_clock() + err;
register_event_by_clock(this, EVENT_TIMER + ch, counter[ch].period, false, &counter[ch].sysclock_id);
}