comparison io.c @ 2028:e597572f45ce

Add new serial state, and Heartbeat Personal Trainer state to save state serialize/deserialize code and fix bug in IO deserialize implementation
author Michael Pavone <pavone@retrodev.com>
date Mon, 15 Feb 2021 13:17:08 -0800
parents 0f54a898db03
children 93918a6a8ab7
comparison
equal deleted inserted replaced
2027:0f54a898db03 2028:e597572f45ce
1546 if (port->device_type == IO_XBAND_KEYBOARD) { 1546 if (port->device_type == IO_XBAND_KEYBOARD) {
1547 save_int8(buf, port->device.keyboard.mode); 1547 save_int8(buf, port->device.keyboard.mode);
1548 save_int8(buf, port->device.keyboard.cmd); 1548 save_int8(buf, port->device.keyboard.cmd);
1549 } 1549 }
1550 break; 1550 break;
1551 } 1551 case IO_HEARTBEAT_TRAINER:
1552 save_int8(buf, port->device.heartbeat_trainer.bpm);
1553 save_int8(buf, port->device.heartbeat_trainer.cadence);
1554 save_int8(buf, port->device.heartbeat_trainer.param);
1555 save_int8(buf, port->device.heartbeat_trainer.state);
1556 save_int8(buf, port->device.heartbeat_trainer.status);
1557 save_int8(buf, port->device.heartbeat_trainer.cmd);
1558 save_int8(buf, port->device.heartbeat_trainer.remaining_bytes);
1559 break;
1560 }
1561 save_int32(buf, port->serial_cycle);
1562 save_int32(buf, port->transmit_end);
1563 save_int32(buf, port->receive_end);
1564 save_int8(buf, port->serial_transmitting);
1565 save_int8(buf, port->serial_receiving);
1552 } 1566 }
1553 1567
1554 void io_deserialize(deserialize_buffer *buf, void *vport) 1568 void io_deserialize(deserialize_buffer *buf, void *vport)
1555 { 1569 {
1556 io_port *port = vport; 1570 io_port *port = vport;
1557 port->output = load_int8(buf); 1571 port->output = load_int8(buf);
1558 port->control = load_int8(buf); 1572 port->control = load_int8(buf);
1559 port->serial_out = load_int8(buf); 1573 port->serial_out = load_int8(buf);
1560 port->serial_in = load_int8(buf); 1574 port->serial_in = load_int8(buf);
1561 port->serial_ctrl = load_int8(buf); 1575 port->serial_ctrl = load_int8(buf);
1576 set_serial_clock(port);
1562 uint8_t device_type = load_int8(buf); 1577 uint8_t device_type = load_int8(buf);
1578 load_buffer32(buf, port->slow_rise_start, 8);
1563 if (device_type != port->device_type) { 1579 if (device_type != port->device_type) {
1564 warning("Loaded save state has a different device type from the current configuration"); 1580 warning("Loaded save state has a different device type from the current configuration");
1565 return; 1581 return;
1566 } 1582 }
1567 switch (port->device_type) 1583 switch (port->device_type)
1584 if (port->device_type == IO_XBAND_KEYBOARD) { 1600 if (port->device_type == IO_XBAND_KEYBOARD) {
1585 port->device.keyboard.mode = load_int8(buf); 1601 port->device.keyboard.mode = load_int8(buf);
1586 port->device.keyboard.cmd = load_int8(buf); 1602 port->device.keyboard.cmd = load_int8(buf);
1587 } 1603 }
1588 break; 1604 break;
1589 } 1605 case IO_HEARTBEAT_TRAINER:
1590 } 1606 port->device.heartbeat_trainer.bpm = load_int8(buf);
1607 port->device.heartbeat_trainer.cadence = load_int8(buf);
1608 port->device.heartbeat_trainer.param = load_int8(buf);
1609 port->device.heartbeat_trainer.state = load_int8(buf);
1610 port->device.heartbeat_trainer.status = load_int8(buf);
1611 port->device.heartbeat_trainer.cmd = load_int8(buf);
1612 port->device.heartbeat_trainer.remaining_bytes = load_int8(buf);
1613 break;
1614 }
1615 if (buf->cur_pos < buf->size) {
1616 port->serial_cycle = load_int32(buf);
1617 port->transmit_end = load_int32(buf);
1618 port->receive_end = load_int32(buf);
1619 port->serial_transmitting = load_int8(buf);
1620 port->serial_receiving = load_int8(buf);
1621 }
1622 }