Mercurial > repos > blastem
comparison vdp.c @ 137:0e7e1ccc0a81
Implemented HV counter
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 30 Dec 2012 22:39:41 -0800 |
parents | a81c548cf353 |
children | aa3e1bb338c9 |
comparison
equal
deleted
inserted
replaced
136:e64554246d11 | 137:0e7e1ccc0a81 |
---|---|
1090 value |= 0x100; | 1090 value |= 0x100; |
1091 } | 1091 } |
1092 if (context->flags & FLAG_DMA_RUN) { | 1092 if (context->flags & FLAG_DMA_RUN) { |
1093 value |= 0x20; | 1093 value |= 0x20; |
1094 } | 1094 } |
1095 uint32_t line= context->cycles / MCLKS_LINE; | |
1096 if (line >= (context->latched_mode & BIT_PAL ? PAL_ACTIVE : NTSC_ACTIVE)) { | |
1097 value |= 0x8; | |
1098 } | |
1095 //TODO: Lots of other bits in status port | 1099 //TODO: Lots of other bits in status port |
1096 return value; | 1100 return value; |
1097 } | 1101 } |
1098 | 1102 |
1099 uint16_t vdp_data_port_read(vdp_context * context) | 1103 uint16_t vdp_data_port_read(vdp_context * context) |
1129 } | 1133 } |
1130 context->address += context->regs[REG_AUTOINC]; | 1134 context->address += context->regs[REG_AUTOINC]; |
1131 return value; | 1135 return value; |
1132 } | 1136 } |
1133 | 1137 |
1138 uint16_t vdp_hv_counter_read(vdp_context * context) | |
1139 { | |
1140 uint32_t line= context->cycles / MCLKS_LINE; | |
1141 if (!line) { | |
1142 line = 0xFF; | |
1143 } else { | |
1144 line--; | |
1145 if (line > 0xEA) { | |
1146 line = (line + 0xFA) & 0xFF; | |
1147 } | |
1148 } | |
1149 uint32_t linecyc = context->cycles % MCLKS_LINE; | |
1150 if (context->latched_mode & BIT_H40) { | |
1151 linecyc /= 8; | |
1152 if (linecyc >= 86) { | |
1153 linecyc -= 86; | |
1154 } else { | |
1155 linecyc += 334; | |
1156 } | |
1157 if (linecyc > 0x16C) { | |
1158 linecyc += 92; | |
1159 } | |
1160 } else { | |
1161 linecyc /= 10; | |
1162 if (linecyc >= 74) { | |
1163 linecyc -= 74; | |
1164 } else { | |
1165 linecyc += 268; | |
1166 } | |
1167 if (linecyc > 0x127) { | |
1168 linecyc += 170; | |
1169 } | |
1170 } | |
1171 linecyc &= 0xFF; | |
1172 return (line << 8) | linecyc; | |
1173 } | |
1174 | |
1134 void vdp_adjust_cycles(vdp_context * context, uint32_t deduction) | 1175 void vdp_adjust_cycles(vdp_context * context, uint32_t deduction) |
1135 { | 1176 { |
1136 context->cycles -= deduction; | 1177 context->cycles -= deduction; |
1137 for(fifo_entry * start = (context->fifo_end - FIFO_SIZE); start < context->fifo_cur; start++) { | 1178 for(fifo_entry * start = (context->fifo_end - FIFO_SIZE); start < context->fifo_cur; start++) { |
1138 if (start->cycle >= deduction) { | 1179 if (start->cycle >= deduction) { |