diff --git a/include/mgba/internal/ds/ds.h b/include/mgba/internal/ds/ds.h index baa2b4a17..a6e3b1bcb 100644 --- a/include/mgba/internal/ds/ds.h +++ b/include/mgba/internal/ds/ds.h @@ -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); diff --git a/include/mgba/internal/ds/io.h b/include/mgba/internal/ds/io.h index ed38681da..f4c5b7121 100644 --- a/include/mgba/internal/ds/io.h +++ b/include/mgba/internal/ds/io.h @@ -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); diff --git a/include/mgba/internal/ds/memory.h b/include/mgba/internal/ds/memory.h index 1ec48a86e..8f5eb4314 100644 --- a/include/mgba/internal/ds/memory.h +++ b/include/mgba/internal/ds/memory.h @@ -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; diff --git a/include/mgba/internal/ds/video.h b/include/mgba/internal/ds/video.h index 978d31eb8..b3f042050 100644 --- a/include/mgba/internal/ds/video.h +++ b/include/mgba/internal/ds/video.h @@ -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 { diff --git a/src/core/flags.h.in b/src/core/flags.h.in index 4e9105b83..d569545fc 100644 --- a/src/core/flags.h.in +++ b/src/core/flags.h.in @@ -35,6 +35,10 @@ #cmakedefine M_CORE_GB #endif +#ifndef M_CORE_DS +#cmakedefine M_CORE_DS +#endif + // USE flags #ifndef MINIMAL_CORE diff --git a/src/platform/python/_builder.h b/src/platform/python/_builder.h index 19842c402..525937078 100644 --- a/src/platform/python/_builder.h +++ b/src/platform/python/_builder.h @@ -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 #include #endif +#ifdef M_CORE_DS +#include +#include +#include +#endif #ifdef USE_DEBUGGERS #include #include diff --git a/src/platform/python/_builder.py b/src/platform/python/_builder.py index de45d6bbf..e16903a40 100644 --- a/src/platform/python/_builder.py +++ b/src/platform/python/_builder.py @@ -29,6 +29,8 @@ ffi.set_source("mgba._pylib", """ #include #include #include +#include +#include #include #include #include diff --git a/src/platform/python/mgba/core.py b/src/platform/python/mgba/core.py index 6f9897439..b2272a4dd 100644 --- a/src/platform/python/mgba/core.py +++ b/src/platform/python/mgba/core.py @@ -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): diff --git a/src/platform/python/mgba/ds.py b/src/platform/python/mgba/ds.py new file mode 100644 index 000000000..afcd61370 --- /dev/null +++ b/src/platform/python/mgba/ds.py @@ -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)