Nintendo DS Interface Simulator DLL

From StoneHome

Interface prototype screenshot
Enlarge
Interface prototype screenshot
So I've been sitting on this DLL for months, thinking I'd let it mature some before I released it. Then, Nintendo announced release plans for the DS earlier than I expected - November 21, to be specific - and I don't really have time to finish this before then. And, frankly, I don't feel like finishing the fake network DLL right now, and this interface thingy is usable, sooooooo...

DsInterfaceDll.dll and example code

Recently, a bunch of people have expressed frustration at the supposed limits of this DLL, that it doesn't do what they expected, that it hasn't yet tied their shoes, and that they want their money back. (Since it's free, that's funny, not a warning sign.) I now feel the need to explain early: this is not an emulator, does not provide DS or GBA-style layered video, and does not emulate the hardware behavior in any way. This is only a way to get some flat video buffers, an interface that handles key and mouse events, and a shitty timer. It's just a way to support game prototyping while we wait for better DS information. Do not get excited.

This is actually a pretty simplistic widget, but it's enough to start development with. This DLL can call or banish a form on which are two correctly sized screens, the bottom of which also takes mouse input and pretends that it's stylus input from a touchscreen. This is not an emulator, and the data formats this uses are not related to those of the DS (I know very little about the DS.) The video does not support sprites or backgrounds or 3D; it's just a big 32-big ARGB buffer for you to write into (and the DS probably doesn't do 32-bit ARGB, so be prepared to replace a draw routine.)

Don't like it? Write your own. It's good enough for me.

Next week, by which I mean in late 2007, I'll release the little wireless network faking DLL that goes with this, once I finish simulating broken connections. For now this is all you get. Love it. Maybe eventually I'll add things like tiled maps, sprite support, whatever, but probably not; this is mostly intended as a tool for programmers who need a quick set of canvasses and for emulator authors which would rather start with a quick prototype and replace it than start from scratch.

This DLL implements the following functions, all of which are under the calling convention stdcall. For fair warning, the pointer passed to SetVClockHandler should be cdecl, not stdcall, and the function should both accept and return void. The DLL should be usable from pretty much any language; the mindset to explain the calling conventions is to make windows development convenient but to cede to behavior that's more easily portable so that on conversion trouble is minimum.

void ShowInterface(void) 
Show the DS Interface Form.
void HideInterface(void) 
Hide the DS Interface Form.
u32* GetHiScreenBuffer(void) 
Get a pointer to the 256x192@32bit buffer for the high screen. This buffer may change between screen updates (Graphics32 doesn't take a formal stance on buffer movement, so I can't.) As a result, be sure to get a new pointer to the buffer each frame, so that updates to Graphics32 and thus to my DLL don't suddenly break your app.
u32* GetLoScreenBuffer(void) 
Get a pointer to the 256x192@32bit buffer for the low screen. This buffer may change between screen updates.
char* GetVersionString(void) 
Return a c-string containing DLL version information.
u32 GetKeyState(void) 
Return a u32 containing the current key state. Key state is as for the GameBoy Advance, with three buttons added to the top of the range - the X and Y buttons, then a "button" for whether the touchscreen is currently pressed, for a total of 15 buttons.
u32 GetInterfaceState(void) 
As GetKeyState, but with byte three filled with the current X position for touchscreen press, and byte four with Y position.
u32 GetTouchX(void) 
Return the byte which represents current touchscreen X press position.
u32 GetTouchY(void) 
Return the byte which represents current touchscreen Y press position.
void SetVClockHandler(cdecl voidFPvoid) 
Set the function pointer to be called as a callback when the simulated video clock fires. Function pointer should be cdecl void(void). Video clock isn't perfectly timed, and gets about 58 frames per second.
void EnableVClock(bool) 
Turn the simulated video clock on or off.
void UpdateDllVideo(void) 
Push the altered video buffer onscreen.

Though the DLL is primarily written for C/C++ programmers (given the compiler available for the real platform (CodeWarrior for ARM, bleah) it's actually written in Delphi, and if I ever bother to clean it up some maybe I'll release its code too. It's really a very simple DLL, given that it's just a quick application of Graphics32 (teh heart;) the whole thing is barely 150 lines long.