comparison sms.c @ 1154:c83ec07ddbac

Implemented Mode 4 H conter latching
author Michael Pavone <pavone@retrodev.com>
date Thu, 05 Jan 2017 00:36:23 -0800
parents 6b0da6021544
children c4ea535cf57e
comparison
equal deleted inserted replaced
1153:2e3ad914bad3 1154:c83ec07ddbac
10 static void *memory_io_write(uint32_t location, void *vcontext, uint8_t value) 10 static void *memory_io_write(uint32_t location, void *vcontext, uint8_t value)
11 { 11 {
12 z80_context *z80 = vcontext; 12 z80_context *z80 = vcontext;
13 sms_context *sms = z80->system; 13 sms_context *sms = z80->system;
14 if (location & 1) { 14 if (location & 1) {
15 uint8_t fuzzy_ctrl_0 = sms->io.ports[0].control, fuzzy_ctrl_1 = sms->io.ports[1].control;
15 sms->io.ports[0].control = (~value) << 5 & 0x60; 16 sms->io.ports[0].control = (~value) << 5 & 0x60;
17 fuzzy_ctrl_0 |= sms->io.ports[0].control;
16 sms->io.ports[1].control = (~value) << 3 & 0x60; 18 sms->io.ports[1].control = (~value) << 3 & 0x60;
19 fuzzy_ctrl_1 |= sms->io.ports[1].control;
20 if (
21 (fuzzy_ctrl_0 & 0x40 & (sms->io.ports[0].output ^ (value << 1)) & (value << 1))
22 || (fuzzy_ctrl_0 & 0x40 & (sms->io.ports[1].output ^ (value >> 1)) & (value >> 1))
23 ) {
24 //TH is an output and it went from 0 -> 1
25 vdp_run_context(sms->vdp, z80->current_cycle);
26 vdp_latch_hv(sms->vdp);
27 }
17 io_data_write(sms->io.ports, value << 1, z80->current_cycle); 28 io_data_write(sms->io.ports, value << 1, z80->current_cycle);
18 io_data_write(sms->io.ports + 1, value >> 1, z80->current_cycle); 29 io_data_write(sms->io.ports + 1, value >> 1, z80->current_cycle);
19 } else { 30 } else {
20 //TODO: memory control write 31 //TODO: memory control write
21 } 32 }