Python: Add DS skeleton

This commit is contained in:
Vicki Pfau 2017-07-16 23:28:09 -07:00
parent d75f43f779
commit 2f8a9b742e
9 changed files with 51 additions and 9 deletions

View File

@ -186,7 +186,6 @@ void DSDetachDebugger(struct DS* ds);
bool DSLoadROM(struct DS* ds, struct VFile* vf);
bool DSLoadSave(struct DS* ds, struct VFile* vf);
void DSUnloadROM(struct DS* ds);
void DSApplyPatch(struct DS* ds, struct Patch* patch);
bool DSIsBIOS7(struct VFile* vf);
bool DSIsBIOS9(struct VFile* vf);

View File

@ -564,9 +564,6 @@ enum DS9IORegisters {
mLOG_DECLARE_CATEGORY(DS_IO);
extern const char* const DS7IORegisterNames[];
extern const char* const DS9IORegisterNames[];
DECL_BITFIELD(DSRegisterRTC, uint16_t);
DECL_BIT(DSRegisterRTC, Data, 0);
DECL_BIT(DSRegisterRTC, Clock, 1);

View File

@ -89,8 +89,8 @@ struct DSMemory {
uint32_t* wramBase9;
uint32_t* wram7;
uint32_t* rom;
uint16_t io7[DS7_REG_MAX >> 1];
uint16_t io9[DS9_REG_MAX >> 1] ATTRIBUTE_ALIGN(8);
uint16_t io7[0x28F];
uint16_t io9[0x837] ATTRIBUTE_ALIGN(8);
struct DSSlot1 slot1;
struct DSSPIBus spiBus;

View File

@ -22,13 +22,13 @@ enum {
DS_VIDEO_HBLANK_PIXELS = 99,
DS7_VIDEO_HBLANK_LENGTH = 1613,
DS9_VIDEO_HBLANK_LENGTH = 1606,
DS_VIDEO_HORIZONTAL_LENGTH = (DS_VIDEO_HORIZONTAL_PIXELS + DS_VIDEO_HBLANK_PIXELS) * 6,
DS_VIDEO_HORIZONTAL_LENGTH = 2130,
DS_VIDEO_VERTICAL_PIXELS = 192,
DS_VIDEO_VBLANK_PIXELS = 71,
DS_VIDEO_VERTICAL_TOTAL_PIXELS = DS_VIDEO_VERTICAL_PIXELS + DS_VIDEO_VBLANK_PIXELS,
DS_VIDEO_VERTICAL_TOTAL_PIXELS = 263,
DS_VIDEO_TOTAL_LENGTH = DS_VIDEO_HORIZONTAL_LENGTH * DS_VIDEO_VERTICAL_TOTAL_PIXELS,
DS_VIDEO_TOTAL_LENGTH = 560190,
};
union DSOAM {

View File

@ -35,6 +35,10 @@
#cmakedefine M_CORE_GB
#endif
#ifndef M_CORE_DS
#cmakedefine M_CORE_DS
#endif
// USE flags
#ifndef MINIMAL_CORE

View File

@ -10,6 +10,7 @@
#define DECL_BITFIELD(newtype, oldtype) typedef oldtype newtype
#define DECL_BIT(type, name, bit)
#define DECL_BITS(type, name, bit, nbits)
#define ATTRIBUTE_ALIGN(align)
#define CXX_GUARD_START
#define CXX_GUARD_END
@ -56,6 +57,11 @@ void free(void*);
#include <mgba/internal/gba/input.h>
#include <mgba/internal/gb/renderers/tile-cache.h>
#endif
#ifdef M_CORE_DS
#include <mgba/internal/arm/arm.h>
#include <mgba/internal/ds/ds.h>
#include <mgba/internal/ds/input.h>
#endif
#ifdef USE_DEBUGGERS
#include <mgba/debugger/debugger.h>
#include <mgba/internal/debugger/cli-debugger.h>

View File

@ -29,6 +29,8 @@ ffi.set_source("mgba._pylib", """
#include <mgba/debugger/debugger.h>
#include <mgba/internal/arm/arm.h>
#include <mgba/internal/debugger/cli-debugger.h>
#include <mgba/internal/ds/ds.h>
#include <mgba/internal/ds/input.h>
#include <mgba/internal/gba/gba.h>
#include <mgba/internal/gba/input.h>
#include <mgba/internal/gba/renderers/tile-cache.h>

View File

@ -97,6 +97,9 @@ class Core(object):
if hasattr(lib, 'PLATFORM_GB'):
PLATFORM_GB = lib.PLATFORM_GB
if hasattr(lib, 'PLATFORM_DS'):
PLATFORM_GB = lib.PLATFORM_DS
def __init__(self, native):
self._core = native
self._wasReset = False
@ -128,6 +131,9 @@ class Core(object):
if hasattr(cls, 'PLATFORM_GB') and core.platform(core) == cls.PLATFORM_GB:
from .gb import GB
return GB(core)
if hasattr(cls, 'PLATFORM_DS') and core.platform(core) == cls.PLATFORM_DS:
from .ds import DS
return DS(core)
return Core(core)
def loadFile(self, path):

View File

@ -0,0 +1,28 @@
# Copyright (c) 2013-2017 Jeffrey Pfau
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from ._pylib import ffi, lib
from .arm import ARMCore
from .core import Core
class DS(Core):
KEY_A = lib.DS_KEY_A
KEY_B = lib.DS_KEY_B
KEY_SELECT = lib.DS_KEY_SELECT
KEY_START = lib.DS_KEY_START
KEY_DOWN = lib.DS_KEY_DOWN
KEY_UP = lib.DS_KEY_UP
KEY_LEFT = lib.DS_KEY_LEFT
KEY_RIGHT = lib.DS_KEY_RIGHT
KEY_L = lib.DS_KEY_L
KEY_R = lib.DS_KEY_R
KEY_X = lib.DS_KEY_X
KEY_Y = lib.DS_KEY_Y
def __init__(self, native):
super(DS, self).__init__(native)
self._native = ffi.cast("struct DS*", native.board)
self.arm7 = ARMCore(self._native.ds7.cpu)
self.arm9 = ARMCore(self._native.ds9.cpu)