all repos — mgba @ 9639d7ad49ee24ca045c6db170bee825d615538b

mGBA Game Boy Advance Emulator

include/mgba/internal/ds/slot1.h (view raw)

 1/* Copyright (c) 2013-2017 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef DS_SLOT1_H
 7#define DS_SLOT1_H
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/core/log.h>
14#include <mgba/core/timing.h>
15
16mLOG_DECLARE_CATEGORY(DS_SLOT1);
17
18DECL_BITFIELD(DSSlot1AUXSPICNT, uint16_t);
19DECL_BITS(DSSlot1AUXSPICNT, Baud, 0, 2);
20DECL_BIT(DSSlot1AUXSPICNT, CSHold, 6);
21DECL_BIT(DSSlot1AUXSPICNT, Busy, 7);
22DECL_BIT(DSSlot1AUXSPICNT, SPIMode, 13);
23DECL_BIT(DSSlot1AUXSPICNT, DoIRQ, 14);
24DECL_BIT(DSSlot1AUXSPICNT, Enable, 15);
25
26DECL_BITFIELD(DSSlot1ROMCNT, uint32_t);
27DECL_BIT(DSSlot1ROMCNT, WordReady, 23);
28DECL_BITS(DSSlot1ROMCNT, BlockSize, 24, 3);
29DECL_BIT(DSSlot1ROMCNT, BlockBusy, 31);
30
31enum DSSavedataType {
32	DS_SAVEDATA_AUTODETECT = -1,
33	DS_SAVEDATA_FORCE_NONE = 0,
34	DS_SAVEDATA_EEPROM512 = 1,
35	DS_SAVEDATA_EEPROM = 2,
36	DS_SAVEDATA_FLASH = 3
37};
38
39struct VFile;
40struct DSSlot1 {
41	uint8_t command[8];
42	uint32_t address;
43	uint32_t transferSize;
44	uint32_t transferRemaining;
45	uint8_t readBuffer[4];
46
47	enum DSSavedataType savedataType;
48	struct mTimingEvent spiEvent;
49	bool spiHoldEnabled;
50	uint8_t spiCommand;
51	uint8_t statusReg;
52	int spiAddressingRemaining;
53	uint32_t spiAddress;
54	int32_t spiAddressingPc;
55
56	uint8_t* spiData;
57	struct VFile* spiVf;
58	struct VFile* spiRealVf;
59};
60
61struct DS;
62struct DSCommon;
63void DSSlot1SPIInit(struct DS* ds, struct VFile* vf);
64void DSSlot1Reset(struct DS* ds);
65DSSlot1AUXSPICNT DSSlot1Configure(struct DS* ds, DSSlot1AUXSPICNT config);
66DSSlot1ROMCNT DSSlot1Control(struct DS* ds, DSSlot1ROMCNT control);
67void DSSlot1WriteSPI(struct DSCommon* dscore, uint8_t datum);
68uint32_t DSSlot1Read(struct DS* ds);
69
70CXX_GUARD_END
71
72#endif