all repos — mgba @ 2f8a9b742e2d814c755afe09dfaeb553aa04a369

mGBA Game Boy Advance Emulator

Python: Add DS skeleton
Vicki Pfau vi@endrift.com
Sun, 16 Jul 2017 23:28:09 -0700
commit

2f8a9b742e2d814c755afe09dfaeb553aa04a369

parent

d75f43f779194848cc8b74f8ebd4be8369c5ea63

M include/mgba/internal/ds/ds.hinclude/mgba/internal/ds/ds.h

@@ -186,7 +186,6 @@

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);
M include/mgba/internal/ds/io.hinclude/mgba/internal/ds/io.h

@@ -564,9 +564,6 @@ };

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);
M include/mgba/internal/ds/memory.hinclude/mgba/internal/ds/memory.h

@@ -89,8 +89,8 @@ uint32_t* wramBase7;

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;
M include/mgba/internal/ds/video.hinclude/mgba/internal/ds/video.h

@@ -22,13 +22,13 @@ DS_VIDEO_HORIZONTAL_PIXELS = 256,

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 {
M src/core/flags.h.insrc/core/flags.h.in

@@ -35,6 +35,10 @@ #ifndef M_CORE_GB

#cmakedefine M_CORE_GB #endif +#ifndef M_CORE_DS +#cmakedefine M_CORE_DS +#endif + // USE flags #ifndef MINIMAL_CORE
M src/platform/python/_builder.hsrc/platform/python/_builder.h

@@ -10,6 +10,7 @@ #define ATTRIBUTE_FORMAT(X, Y, Z)

#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

@@ -55,6 +56,11 @@ #include <mgba/internal/lr35902/lr35902.h>

#include <mgba/internal/gb/gb.h> #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>
M src/platform/python/_builder.pysrc/platform/python/_builder.py

@@ -29,6 +29,8 @@ #include <mgba/core/version.h>

#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>
M src/platform/python/mgba/core.pysrc/platform/python/mgba/core.py

@@ -97,6 +97,9 @@

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 @@ return GBA(core)

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):
A 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)