all repos — mgba @ 60b59ae3123b8419372cd75e600ca5bda1240121

mGBA Game Boy Advance Emulator

GBA Hardware: Unpack RTC struct
Vicki Pfau vi@endrift.com
Sun, 29 Nov 2020 13:35:21 -0800
commit

60b59ae3123b8419372cd75e600ca5bda1240121

parent

bcad1494541fd163edde5fd588f5399fdb43e0d3

M include/mgba/internal/gba/hardware.hinclude/mgba/internal/gba/hardware.h

@@ -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 @@ RTCCommandData command;

RTCControl control; uint8_t time[7]; }; -#pragma pack(pop) -#else -struct GBATRC; -#endif struct GBAGBPKeyCallback { struct mKeyCallback d;
M include/mgba/internal/gba/serialize.hinclude/mgba/internal/gba/serialize.h

@@ -316,7 +316,14 @@

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;
M src/gba/hardware.csrc/gba/hardware.c

@@ -623,14 +623,14 @@ STORE_16(hw->pinState, 0, &state->hw.pinState);

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 @@ LOAD_16(hw->pinState, 0, &state->hw.pinState);

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);
M src/platform/python/_builder.pysrc/platform/python/_builder.py

@@ -66,18 +66,6 @@ continue

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 = []