X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Fsh2%2Fsh2.c;h=0e6be67168117d09f82c79e640ef7b3e571861a5;hb=b4db550e41b2aa277f570d7bff890c8e8ee1831f;hp=80c458fcff18ac50e6da2c9b2f2050f2943ce0c5;hpb=a736af3ecf708652f90e9cb05445d984960a0eec;p=picodrive.git diff --git a/cpu/sh2/sh2.c b/cpu/sh2/sh2.c index 80c458f..0e6be67 100644 --- a/cpu/sh2/sh2.c +++ b/cpu/sh2/sh2.c @@ -1,4 +1,6 @@ #include +#include + #include "sh2.h" #include "../debug.h" #include "compiler.h" @@ -85,3 +87,31 @@ void sh2_internal_irq(SH2 *sh2, int level, int vector) sh2->test_irq = 1; } +#define SH2_REG_SIZE (offsetof(SH2, macl) + sizeof(sh2->macl)) + +void sh2_pack(const SH2 *sh2, unsigned char *buff) +{ + unsigned int *p; + + memcpy(buff, sh2, SH2_REG_SIZE); + p = (void *)(buff + SH2_REG_SIZE); + + p[0] = sh2->pending_int_irq; + p[1] = sh2->pending_int_vector; + p[2] = sh2->cycles_aim; + p[3] = sh2->cycles_done; +} + +void sh2_unpack(SH2 *sh2, const unsigned char *buff) +{ + unsigned int *p; + + memcpy(sh2, buff, SH2_REG_SIZE); + p = (void *)(buff + SH2_REG_SIZE); + + sh2->pending_int_irq = p[0]; + sh2->pending_int_vector = p[1]; + sh2->cycles_aim = p[2]; + sh2->cycles_done = p[3]; +} +