Mercurial > repos > blastem
comparison vdp.c @ 503:eee6be465c47
Small optimization for H40 mode
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 31 Oct 2013 00:28:27 -0700 |
parents | 27345a67225d |
children | b7b7a1cab44a |
comparison
equal
deleted
inserted
replaced
502:7fdfcced65b6 | 503:eee6be465c47 |
---|---|
1219 case 170: | 1219 case 170: |
1220 external_slot(context); | 1220 external_slot(context); |
1221 break; | 1221 break; |
1222 } | 1222 } |
1223 } | 1223 } |
1224 | |
1225 void vdp_h40_line(uint32_t line, vdp_context * context) | |
1226 { | |
1227 context->cur_slot = MAX_DRAWS-1; | |
1228 memset(context->linebuf, 0, LINEBUF_SIZE); | |
1229 if (line == 0xFF) { | |
1230 external_slot(context); | |
1231 if (context->flags & FLAG_DMA_RUN) { | |
1232 run_dma_src(context, 0); | |
1233 } | |
1234 external_slot(context); | |
1235 if (context->flags & FLAG_DMA_RUN) { | |
1236 run_dma_src(context, 0); | |
1237 } | |
1238 external_slot(context); | |
1239 if (context->flags & FLAG_DMA_RUN) { | |
1240 run_dma_src(context, 0); | |
1241 } | |
1242 external_slot(context); | |
1243 if (context->flags & FLAG_DMA_RUN) { | |
1244 run_dma_src(context, 0); | |
1245 } | |
1246 } else { | |
1247 render_sprite_cells(context); | |
1248 render_sprite_cells(context); | |
1249 render_sprite_cells(context); | |
1250 render_sprite_cells(context); | |
1251 } | |
1252 context->sprite_index = 0x80; | |
1253 context->slot_counter = MAX_SPRITES_LINE; | |
1254 for (int i = 0; i < 19; i++) | |
1255 { | |
1256 render_sprite_cells(context); | |
1257 scan_sprite_table(line, context); | |
1258 } | |
1259 external_slot(context); | |
1260 for (int i = 0; i < 11; i++) | |
1261 { | |
1262 render_sprite_cells(context); | |
1263 scan_sprite_table(line, context); | |
1264 } | |
1265 uint16_t address; | |
1266 uint32_t mask; | |
1267 address = (context->regs[REG_HSCROLL] & 0x3F) << 10; | |
1268 mask = 0; | |
1269 if (context->regs[REG_MODE_3] & 0x2) { | |
1270 mask |= 0xF8; | |
1271 } | |
1272 if (context->regs[REG_MODE_3] & 0x1) { | |
1273 mask |= 0x7; | |
1274 } | |
1275 address += (line & mask) * 4; | |
1276 context->hscroll_a = context->vdpmem[address] << 8 | context->vdpmem[address+1]; | |
1277 context->hscroll_b = context->vdpmem[address+2] << 8 | context->vdpmem[address+3]; | |
1278 render_sprite_cells(context); | |
1279 scan_sprite_table(line, context); | |
1280 render_sprite_cells(context); | |
1281 scan_sprite_table(line, context); | |
1282 render_sprite_cells(context); | |
1283 scan_sprite_table(line, context); | |
1284 render_sprite_cells(context); | |
1285 scan_sprite_table(line, context); | |
1286 | |
1287 render_sprite_cells(context); | |
1288 scan_sprite_table(line, context); | |
1289 read_map_scroll_a(0, line, context); | |
1290 render_sprite_cells(context); | |
1291 scan_sprite_table(line, context); | |
1292 render_map_1(context); | |
1293 scan_sprite_table(line, context);//Just a guess | |
1294 render_map_2(context); | |
1295 scan_sprite_table(line, context);//Just a guess | |
1296 read_map_scroll_b(0, line, context); | |
1297 render_sprite_cells(context); | |
1298 scan_sprite_table(line, context); | |
1299 render_map_3(context); | |
1300 scan_sprite_table(line, context);//Just a guess | |
1301 render_map_output(line, 0, context); | |
1302 scan_sprite_table(line, context);//Just a guess | |
1303 //reverse context slot counter so it counts the number of sprite slots | |
1304 //filled rather than the number of available slots | |
1305 //context->slot_counter = MAX_SPRITES_LINE - context->slot_counter; | |
1306 context->cur_slot = MAX_SPRITES_LINE-1; | |
1307 context->sprite_draws = MAX_DRAWS; | |
1308 context->flags &= (~FLAG_CAN_MASK & ~FLAG_MASKED); | |
1309 for (int column = 2; column < 42; column += 2) | |
1310 { | |
1311 read_map_scroll_a(column, line, context); | |
1312 external_slot(context); | |
1313 if (context->flags & FLAG_DMA_RUN) { | |
1314 run_dma_src(context, 0); | |
1315 } | |
1316 render_map_1(context); | |
1317 render_map_2(context); | |
1318 read_map_scroll_b(column, line, context); | |
1319 read_sprite_x(line, context); | |
1320 render_map_3(context); | |
1321 render_map_output(line, column, context); | |
1322 | |
1323 column += 2; | |
1324 read_map_scroll_a(column, line, context); | |
1325 external_slot(context); | |
1326 if (context->flags & FLAG_DMA_RUN) { | |
1327 run_dma_src(context, 0); | |
1328 } | |
1329 render_map_1(context); | |
1330 render_map_2(context); | |
1331 read_map_scroll_b(column, line, context); | |
1332 read_sprite_x(line, context); | |
1333 render_map_3(context); | |
1334 render_map_output(line, column, context); | |
1335 | |
1336 column += 2; | |
1337 read_map_scroll_a(column, line, context); | |
1338 external_slot(context); | |
1339 if (context->flags & FLAG_DMA_RUN) { | |
1340 run_dma_src(context, 0); | |
1341 } | |
1342 render_map_1(context); | |
1343 render_map_2(context); | |
1344 read_map_scroll_b(column, line, context); | |
1345 read_sprite_x(line, context); | |
1346 render_map_3(context); | |
1347 render_map_output(line, column, context); | |
1348 | |
1349 column += 2; | |
1350 read_map_scroll_a(column, line, context); | |
1351 render_map_1(context); | |
1352 render_map_2(context); | |
1353 read_map_scroll_b(column, line, context); | |
1354 read_sprite_x(line, context); | |
1355 render_map_3(context); | |
1356 render_map_output(line, column, context); | |
1357 } | |
1358 external_slot(context); | |
1359 if (context->flags & FLAG_DMA_RUN) { | |
1360 run_dma_src(context, 0); | |
1361 } | |
1362 external_slot(context); | |
1363 } | |
1364 | |
1224 void latch_mode(vdp_context * context) | 1365 void latch_mode(vdp_context * context) |
1225 { | 1366 { |
1226 context->latched_mode = (context->regs[REG_MODE_4] & 0x81) | (context->regs[REG_MODE_2] & BIT_PAL); | 1367 context->latched_mode = (context->regs[REG_MODE_4] & 0x81) | (context->regs[REG_MODE_2] & BIT_PAL); |
1227 } | 1368 } |
1228 | 1369 |
1388 //it's used for gathering sprite info for line | 1529 //it's used for gathering sprite info for line |
1389 line = (line - 1) & 0xFF; | 1530 line = (line - 1) & 0xFF; |
1390 | 1531 |
1391 //Convert to slot number | 1532 //Convert to slot number |
1392 if (context->latched_mode & BIT_H40){ | 1533 if (context->latched_mode & BIT_H40){ |
1393 vdp_h40(line, slot, context); | 1534 if (!slot && line != (active_lines-1) && (target_cycles - context->cycles) >= MCLKS_LINE) { |
1535 vdp_h40_line(line, context); | |
1536 inccycles = MCLKS_LINE; | |
1537 } else { | |
1538 vdp_h40(line, slot, context); | |
1539 } | |
1394 } else { | 1540 } else { |
1395 vdp_h32(line, slot, context); | 1541 vdp_h32(line, slot, context); |
1396 } | 1542 } |
1397 } else { | 1543 } else { |
1398 if (!is_refresh(context, slot)) { | 1544 if (!is_refresh(context, slot)) { |