all repos — mgba @ 290d5b77dd4f47e7f96981728eea5dc33bd29f1d

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