Mercurial > repos > simple16
comparison src/cpu.c @ 20:a9364f5ee81a
Fix timing of port IO
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 29 Mar 2016 19:57:34 -0700 |
parents | d8ae30286d17 |
children | fb14515266f4 |
comparison
equal
deleted
inserted
replaced
19:04fc17376999 | 20:a9364f5ee81a |
---|---|
98 } | 98 } |
99 } | 99 } |
100 | 100 |
101 uint16_t cpu_read_port(cpu *context, uint8_t port) | 101 uint16_t cpu_read_port(cpu *context, uint8_t port) |
102 { | 102 { |
103 context->cycles += context->clock_inc; | |
103 port &= 0xF; | 104 port &= 0xF; |
104 if (context->port_handlers[port].read) { | 105 if (context->port_handlers[port].read) { |
105 return context->port_handlers[port].read(context, port); | 106 return context->port_handlers[port].read(context, port); |
106 } | 107 } |
107 return 0xFFFF; | 108 return 0xFFFF; |
108 } | 109 } |
109 | 110 |
110 void cpu_write_port(cpu *context, uint8_t port, uint16_t value) | 111 void cpu_write_port(cpu *context, uint8_t port, uint16_t value) |
111 { | 112 { |
113 context->cycles += context->clock_inc; | |
112 port &= 0xF; | 114 port &= 0xF; |
113 if (context->port_handlers[port].write) { | 115 if (context->port_handlers[port].write) { |
114 context->port_handlers[port].write(context, port, value); | 116 context->port_handlers[port].write(context, port, value); |
115 } | 117 } |
116 } | 118 } |