all repos — mgba @ 2006f27d6da1fba91f4ec2e34a9fa736c3af07f6

mGBA Game Boy Advance Emulator

src/ds/ds.h (view raw)

  1/* Copyright (c) 2013-2016 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_H
  7#define DS_H
  8
  9#include "util/common.h"
 10
 11#include "arm/arm.h"
 12#include "core/log.h"
 13
 14#include "ds/memory.h"
 15#include "ds/video.h"
 16
 17extern const uint32_t DS_ARM946ES_FREQUENCY;
 18extern const uint32_t DS_ARM7TDMI_FREQUENCY;
 19
 20enum DSIRQ {
 21	DS_IRQ_VBLANK = 0x0,
 22	DS_IRQ_HBLANK = 0x1,
 23	DS_IRQ_VCOUNTER = 0x2,
 24	DS_IRQ_TIMER0 = 0x3,
 25	DS_IRQ_TIMER1 = 0x4,
 26	DS_IRQ_TIMER2 = 0x5,
 27	DS_IRQ_TIMER3 = 0x6,
 28	DS_IRQ_SIO = 0x7,
 29	DS_IRQ_DMA0 = 0x8,
 30	DS_IRQ_DMA1 = 0x9,
 31	DS_IRQ_DMA2 = 0xA,
 32	DS_IRQ_DMA3 = 0xB,
 33	DS_IRQ_KEYPAD = 0xC,
 34	DS_IRQ_SLOT2 = 0xD,
 35	DS_IRQ_IPC_SYNC = 0x10,
 36	DS_IRQ_IPC_EMPTY = 0x11,
 37	DS_IRQ_IPC_NOT_EMPTY = 0x12,
 38	DS_IRQ_SLOT1_TRANS = 0x13,
 39	DS_IRQ_SLOT1 = 0x14,
 40	DS_IRQ_GEOM_FIFO = 0x15,
 41	DS_IRQ_LID = 0x16,
 42	DS_IRQ_SPI = 0x17,
 43	DS_IRQ_WIFI = 0x18,
 44};
 45
 46struct DS;
 47struct Patch;
 48struct VFile;
 49struct mDebugger;
 50
 51mLOG_DECLARE_CATEGORY(DS);
 52
 53struct DS {
 54	struct mCPUComponent d;
 55
 56	struct ARMCore* arm7;
 57	struct ARMCore* arm9;
 58	struct DSMemory memory;
 59	struct DSVideo video;
 60
 61	struct mCoreSync* sync;
 62
 63	struct ARMDebugger* debugger;
 64
 65	int springIRQ7;
 66	int springIRQ9;
 67
 68	uint32_t bios7Checksum;
 69	uint32_t bios9Checksum;
 70	int* keySource;
 71	struct mRTCSource* rtcSource;
 72	struct mRumble* rumble;
 73
 74	struct VFile* romVf;
 75	struct VFile* bios7Vf;
 76	struct VFile* bios9Vf;
 77
 78	struct mKeyCallback* keyCallback;
 79};
 80
 81struct DSCartridge {
 82	char title[12];
 83	uint32_t id;
 84
 85	uint16_t maker;
 86	uint8_t type;
 87	uint8_t encryptionSeed;
 88	uint8_t size;
 89	uint8_t reserved[8];
 90	uint8_t region;
 91	uint8_t version;
 92	uint8_t autostart;
 93	uint32_t arm9Offset;
 94	uint32_t arm9Entry;
 95	uint32_t arm9Base;
 96	uint32_t arm9Size;
 97	uint32_t arm7Offset;
 98	uint32_t arm7Entry;
 99	uint32_t arm7Base;
100	uint32_t arm7Size;
101	uint32_t fntOffset;
102	uint32_t fntSize;
103	uint32_t fatOffset;
104	uint32_t fatSize;
105	uint32_t arm9FileOverlayOffset;
106	uint32_t arm9FileOverlaySize;
107	uint32_t arm7FileOverlayOffset;
108	uint32_t arm7FileOverlaySize;
109	uint32_t busTiming;
110	uint32_t busKEY1Timing;
111	uint32_t iconOffset;
112	uint16_t secureAreaCrc16;
113	uint16_t secureAreaDelay;
114	// TODO: Fill in more
115	// And ROM data...
116};
117
118void DSCreate(struct DS* ds);
119void DSDestroy(struct DS* ds);
120
121void DSAttachDebugger(struct DS* ds, struct mDebugger* debugger);
122void DSDetachDebugger(struct DS* ds);
123
124bool DSLoadROM(struct DS* ds, struct VFile* vf);
125void DSUnloadROM(struct DS* ds);
126void DSApplyPatch(struct DS* ds, struct Patch* patch);
127
128bool DSLoadBIOS(struct DS* ds, struct VFile* vf);
129
130bool DSIsROM(struct VFile* vf);
131void DSGetGameCode(struct DS* ds, char* out);
132void DSGetGameTitle(struct DS* ds, char* out);
133
134#endif