Revision: 18879
http://vice-emu.svn.sourceforge.net/vice-emu/?rev=18879&view=rev
Author: strik
Date: 2008-06-21 09:30:36 -0700 (Sat, 21 Jun 2008)
Log Message:
-----------
Reactived snapshot writing and reading.
Modified Paths:
--------------
branches/spiro/vice-1.22.18-reu/vice/src/c64/reu.c
Modified: branches/spiro/vice-1.22.18-reu/vice/src/c64/reu.c
===================================================================
--- branches/spiro/vice-1.22.18-reu/vice/src/c64/reu.c 2008-06-21 15:53:57 UTC (rev 18878)
+++ branches/spiro/vice-1.22.18-reu/vice/src/c64/reu.c 2008-06-21 16:30:36 UTC (rev 18879)
@@ -401,30 +401,15 @@
}
/* ------------------------------------------------------------------------- */
+/* helper functions */
-BYTE REGPARM1 reu_read(WORD addr)
+static BYTE reu_read_without_sideeffects(WORD addr)
{
BYTE retval = 0xff;
- addr &= REU_REG_LAST_REG;
-
- if (addr < 0x0b) { /*! \TODO remove magic number! */
- io_source = IO_SOURCE_REU;
- }
-
switch (addr) {
case REU_REG_R_STATUS:
retval = rec.status;
-
- /* Bits 7-5 are cleared when register is read, and pending IRQs are
- removed. */
- rec.status &=
- ~(REU_REG_R_STATUS_VERIFY_ERROR
- | REU_REG_R_STATUS_END_OF_BLOCK
- | REU_REG_R_STATUS_INTERRUPT_PENDING
- );
-
- maincpu_set_irq(reu_int_num, 0);
break;
case REU_REG_RW_COMMAND:
@@ -470,17 +455,11 @@
break;
}
-#ifdef REU_DEBUG
- log_message(reu_log, "read [$%02X] => $%02X.", addr, retval);
-#endif
return retval;
}
-
-void REGPARM2 reu_store(WORD addr, BYTE byte)
+static void reu_store_without_sideeffects(WORD addr, BYTE byte)
{
- addr &= REU_REG_LAST_REG;
-
switch (addr)
{
case REU_REG_R_STATUS:
@@ -537,8 +516,52 @@
default:
break;
}
+}
+/* ------------------------------------------------------------------------- */
+
+BYTE REGPARM1 reu_read(WORD addr)
+{
+ BYTE retval;
+
+ addr &= REU_REG_LAST_REG;
+
+ if (addr < 0x0b) { /*! \TODO remove magic number! */
+ io_source = IO_SOURCE_REU;
+ }
+
+ retval = reu_read_without_sideeffects(addr);
+
+ switch (addr) {
+ case REU_REG_R_STATUS:
+ /* Bits 7-5 are cleared when register is read, and pending IRQs are
+ removed. */
+ rec.status &=
+ ~(REU_REG_R_STATUS_VERIFY_ERROR
+ | REU_REG_R_STATUS_END_OF_BLOCK
+ | REU_REG_R_STATUS_INTERRUPT_PENDING
+ );
+
+ maincpu_set_irq(reu_int_num, 0);
+ break;
+ default:
+ break;
+ }
+
#ifdef REU_DEBUG
+ log_message(reu_log, "read [$%02X] => $%02X.", addr, retval);
+#endif
+ return retval;
+}
+
+
+void REGPARM2 reu_store(WORD addr, BYTE byte)
+{
+ addr &= REU_REG_LAST_REG;
+
+ reu_store_without_sideeffects(addr, byte);
+
+#ifdef REU_DEBUG
log_message(reu_log, "store [$%02X] <= $%02X.", addr, (int)byte);
#endif
@@ -775,13 +798,21 @@
#define SNAP_MAJOR 0
#define SNAP_MINOR 0
+typedef BYTE reu_as_stored_in_snapshot_t[16];
+
int reu_write_snapshot_module(snapshot_t *s)
{
snapshot_module_t *m;
- BYTE reu[16];
+ reu_as_stored_in_snapshot_t reu;
+ WORD reu_address;
+
memset(reu, 0xff, sizeof reu);
+ for (reu_address = 0; reu_address < sizeof(reu); reu_address++) {
+ reu[reu_address] = reu_read_without_sideeffects(reu_address);
+ }
+
m = snapshot_module_create(s, snap_module_name, SNAP_MAJOR, SNAP_MINOR);
if (m == NULL)
return -1;
@@ -802,8 +833,10 @@
BYTE major_version, minor_version;
snapshot_module_t *m;
DWORD size;
- BYTE reu[16];
+ reu_as_stored_in_snapshot_t reu;
+ WORD reu_address;
+
memset(reu, 0xff, sizeof reu);
m = snapshot_module_open(s, snap_module_name,
@@ -839,8 +872,11 @@
else
interrupt_restore_irq(maincpu_int_status, reu_int_num, 0);
- /*! \TODO restore the reu registers */
+ for (reu_address = 0; reu_address < sizeof(reu); reu_address++) {
+ reu_store_without_sideeffects(reu_address, reu[reu_address]);
+ }
+
snapshot_module_close(m);
return 0;
@@ -848,4 +884,3 @@
snapshot_module_close(m);
return -1;
}
-
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|