GBA Hardware: Unpack RTC struct

This commit is contained in:
Vicki Pfau 2020-11-29 13:35:21 -08:00
parent bcad149454
commit 60b59ae312
4 changed files with 24 additions and 35 deletions

View File

@ -71,8 +71,6 @@ DECL_BITS(RTCCommandData, Magic, 0, 4);
DECL_BITS(RTCCommandData, Command, 4, 3);
DECL_BIT(RTCCommandData, Reading, 7);
#ifndef PYCPARSE
#pragma pack(push, 1)
struct GBARTC {
int32_t bytesRemaining;
int32_t transferStep;
@ -83,10 +81,6 @@ struct GBARTC {
RTCControl control;
uint8_t time[7];
};
#pragma pack(pop)
#else
struct GBATRC;
#endif
struct GBAGBPKeyCallback {
struct mKeyCallback d;

View File

@ -316,7 +316,14 @@ struct GBASerializedState {
struct {
uint16_t pinState;
uint16_t pinDirection;
struct GBARTC rtc;
int32_t rtcBytesRemaining;
int32_t rtcTransferStep;
int32_t rtcBitsRead;
int32_t rtcBits;
int32_t rtcCommandActive;
RTCCommandData rtcCommand;
RTCControl rtcControl;
uint8_t time[7];
uint8_t devices;
uint16_t gyroSample;
uint16_t tiltSampleX;

View File

@ -623,14 +623,14 @@ void GBAHardwareSerialize(const struct GBACartridgeHardware* hw, struct GBASeria
STORE_16(hw->direction, 0, &state->hw.pinDirection);
state->hw.devices = hw->devices;
STORE_32(hw->rtc.bytesRemaining, 0, &state->hw.rtc.bytesRemaining);
STORE_32(hw->rtc.transferStep, 0, &state->hw.rtc.transferStep);
STORE_32(hw->rtc.bitsRead, 0, &state->hw.rtc.bitsRead);
STORE_32(hw->rtc.bits, 0, &state->hw.rtc.bits);
STORE_32(hw->rtc.commandActive, 0, &state->hw.rtc.commandActive);
STORE_32(hw->rtc.command, 0, &state->hw.rtc.command);
STORE_32(hw->rtc.control, 0, &state->hw.rtc.control);
memcpy(state->hw.rtc.time, hw->rtc.time, sizeof(state->hw.rtc.time));
STORE_32(hw->rtc.bytesRemaining, 0, &state->hw.rtcBytesRemaining);
STORE_32(hw->rtc.transferStep, 0, &state->hw.rtcTransferStep);
STORE_32(hw->rtc.bitsRead, 0, &state->hw.rtcBitsRead);
STORE_32(hw->rtc.bits, 0, &state->hw.rtcBits);
STORE_32(hw->rtc.commandActive, 0, &state->hw.rtcCommandActive);
STORE_32(hw->rtc.command, 0, &state->hw.rtcCommand);
STORE_32(hw->rtc.control, 0, &state->hw.rtcControl);
memcpy(state->hw.time, hw->rtc.time, sizeof(state->hw.time));
STORE_16(hw->gyroSample, 0, &state->hw.gyroSample);
flags1 = GBASerializedHWFlags1SetGyroEdge(flags1, hw->gyroEdge);
@ -655,14 +655,14 @@ void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, const struct GBASer
LOAD_16(hw->direction, 0, &state->hw.pinDirection);
hw->devices = state->hw.devices;
LOAD_32(hw->rtc.bytesRemaining, 0, &state->hw.rtc.bytesRemaining);
LOAD_32(hw->rtc.transferStep, 0, &state->hw.rtc.transferStep);
LOAD_32(hw->rtc.bitsRead, 0, &state->hw.rtc.bitsRead);
LOAD_32(hw->rtc.bits, 0, &state->hw.rtc.bits);
LOAD_32(hw->rtc.commandActive, 0, &state->hw.rtc.commandActive);
LOAD_32(hw->rtc.command, 0, &state->hw.rtc.command);
LOAD_32(hw->rtc.control, 0, &state->hw.rtc.control);
memcpy(hw->rtc.time, state->hw.rtc.time, sizeof(hw->rtc.time));
LOAD_32(hw->rtc.bytesRemaining, 0, &state->hw.rtcBytesRemaining);
LOAD_32(hw->rtc.transferStep, 0, &state->hw.rtcTransferStep);
LOAD_32(hw->rtc.bitsRead, 0, &state->hw.rtcBitsRead);
LOAD_32(hw->rtc.bits, 0, &state->hw.rtcBits);
LOAD_32(hw->rtc.commandActive, 0, &state->hw.rtcCommandActive);
LOAD_32(hw->rtc.command, 0, &state->hw.rtcCommand);
LOAD_32(hw->rtc.control, 0, &state->hw.rtcControl);
memcpy(hw->rtc.time, state->hw.time, sizeof(hw->rtc.time));
LOAD_16(hw->gyroSample, 0, &state->hw.gyroSample);
hw->gyroEdge = GBASerializedHWFlags1GetGyroEdge(flags1);

View File

@ -66,18 +66,6 @@ for line in preprocessed.splitlines():
lines.append(line)
ffi.cdef('\n'.join(lines))
ffi.cdef("""
struct GBARTC {
int32_t bytesRemaining;
int32_t transferStep;
int32_t bitsRead;
int32_t bits;
int32_t commandActive;
RTCCommandData command;
RTCControl control;
uint8_t time[7];
};""", packed=True)
preprocessed = subprocess.check_output(cpp + ["-fno-inline", "-P"] + cppflags + [os.path.join(pydir, "lib.h")], universal_newlines=True)
lines = []