2 Skelton for retropc emulator
4 Author : Takeda.Toshiya
17 #define SIG_I8253_CLOCK_0 0
18 #define SIG_I8253_CLOCK_1 1
19 #define SIG_I8253_CLOCK_2 2
20 #define SIG_I8253_GATE_0 3
21 #define SIG_I8253_GATE_1 4
22 #define SIG_I8253_GATE_2 5
24 class I8253 : public DEVICE
36 bool low_read, high_read;
37 bool low_write, high_write;
57 void input_clock(int ch, int clock);
58 void input_gate(int ch, bool signal);
59 void start_count(int ch);
60 void stop_count(int ch);
61 void latch_count(int ch);
62 void set_signal(int ch, bool signal);
63 int get_next_count(int ch);
66 I8253(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
68 for(int i = 0; i < 3; i++) {
69 initialize_output_signals(&counter[i].outputs);
72 set_device_name(_T("i8253 PIT"));
79 void write_io8(uint32_t addr, uint32_t data);
80 uint32_t read_io8(uint32_t addr);
81 void event_callback(int event_id, int err);
82 void write_signal(int id, uint32_t data, uint32_t mask);
83 void update_timing(int new_clocks, double new_frames_per_sec, int new_lines_per_frame)
85 cpu_clocks = new_clocks;
87 void save_state(FILEIO* state_fio);
88 bool load_state(FILEIO* state_fio);
90 void set_context_ch0(DEVICE* device, int id, uint32_t mask)
92 register_output_signal(&counter[0].outputs, device, id, mask);
94 void set_context_ch1(DEVICE* device, int id, uint32_t mask)
96 register_output_signal(&counter[1].outputs, device, id, mask);
98 void set_context_ch2(DEVICE* device, int id, uint32_t mask)
100 register_output_signal(&counter[2].outputs, device, id, mask);
102 void set_constant_clock(int ch, uint32_t hz)
104 counter[ch].freq = hz;