Se ha cambiado de template al de NightFox Lib.

parent 9fe447af
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
# nds_vscode_template
[![License: CC0-1.0](https://img.shields.io/badge/License-CC0%201.0-lightgrey.svg)](http://creativecommons.org/publicdomain/zero/1.0/)
Develop Nintendo DS homebrew in a modern Visual Studio Code development environment.
* ARM [devkitPro](https://devkitpro.org) toolchain
* Emulation and debugging with [DeSmuME](https://desmume.org/)
* Working IntelliSense in [VS Code](https://code.visualstudio.com/)
## Getting Started
Before this template will work, we need to do some homework and install the compiler toolchian, the emulator, and the necessary extensions for our development environment.
**NOTE**: These instructions are for Windows!
### devkitPro
**devkitPro** provides a set of compilers and tools so that we can create programs that are compatible with the ARM 7 and ARM 9 processors in the Nintendo DS.
Follow the instructions on the [Getting Started](https://devkitpro.org/wiki/Getting_Started) page to download the Windows graphical installer.
When you run the installer, make sure to leave the default options as is so that the paths in this template point to the correct place.
You can verify that the installation completed successfully by making sure you can see **devkitPro**>**MYSYS** in your Start Menu.
### DeSmuME
**DeSmuME** is a very stable Nintendo DS emulator that also provides basic tools for debugging our homebrew programs. Per the [DeSmuME FAQ](http://wiki.desmume.org/index.php?title=Faq#Does_the_GDB_stub_still_work.3F), the debugging functions in DeSmuME aren't completely fleshed out, but it works well enough to set breakpoints, step through code, watch memory locations for read/write operations, and other basic operations.
For this template we are going to download 2 separate versions of DeSmuME: one for release builds and one for debugging.
* [DeSmuME 0.9.11 x32](http://sourceforge.net/projects/desmume/files/desmume/0.9.11/desmume-0.9.11-win32.zip/download) (Release emulator)
* [DeSmuME 0.9.11 x32 Dev](https://sourceforge.net/projects/desmume/files/desmume/0.9.11/desmume-0.9.11-win32-dev.zip/download) (Development emulator)
To install, unzip the release emulator to `C:\desmume`. When the unzip is complete, you should have the executable at `C:\desmume\DeSmuME_0.9.11_x86.exe`.
Now for the development emulator, extract it to the same path: `C:\desmume`. Click the "Replace files at the destination" button when it prompts you. When the unzip is complete, the executable should be at `C:\desmume\DeSmuME_0.9.11_x86_dev+.exe`.
Double-click both the release and development emulators to make sure they work correctly. If you get an error about missing `MSVCP100.DLL`, you probably also need to install the x86 version of the [Microsoft Visual C++ 2010 Redistributable Package](http://www.microsoft.com/en-in/download/details.aspx?id=5555).
### VS Code
Install a copy of [Visual Studio Code](https://code.visualstudio.com/) if you don't have it already, and also install the following extensions:
* [ARM](https://marketplace.visualstudio.com/items?itemName=dan-c-underwood.arm)
* [C/C++](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools)
* [C++ Intellisense](https://marketplace.visualstudio.com/items?itemName=austin.code-gnu-global)
* [Make](https://marketplace.visualstudio.com/items?itemName=technosophos.vscode-make)
## Using this template
The C++ source code for your Nintendo DS program will go into the `source` directory. The `main.cpp` file in this template is from the `nds/hello_world` example that comes with devkitPro. You can use this as a starting point for your own program.
The `include` directory has a `vscode_fix.h` file that is used to fix IntelliSense behavior in Visual Studio Code. At the moment IntelliSense isn't smart enough to detect the feature flags that would be set by the compiler, so we add any interfaces that IntelliSense doesn't understand to this file.
For example, the `main.cpp` example code uses the `iprintf` function to print text to the screen. The `iprintf` function is defined in `C:\devkitPro\devkitARM\arm-none-eabi\include\stdio.h`, but it is protected by the `__MISC_VISIBLE` compiler feature. Since IntelliSense doesn't know what features our compiler has, we have to help it along by copying the interface from the `stdio.h` file and into `vscode_fix.h`.
The `vscode_fix.h` file is _only_ used by IntelliSense and will not compile with your code!
The `.vscode` directory holds the settings that VS Code should use for the project. The `c_cpp_properties.json` file determines what directories IntelliSense searches in to find code for your project. The `tasks.json` file defines useful tasks like `make` and `make clean` so you don't have to switch to your terminal application to run them. The `launch.json` file defines the `(gdb) Launch` task for running the debugger.
Running the `make` build task will create an `.nds` file at the root of the project. You can run this file in the emulator by running the `run` task.
---
To the extent possible under law, [cuibonobo](https://github.com/cuibonobo/) has [waived all copyright](https://creativecommons.org/publicdomain/zero/1.0/) and related or neighboring rights to this work.
\ No newline at end of file
/*
Used to get VS Code Intellisense working correctly for header definitions
protected by compiler-specific feature flags.
*/
#ifdef __GNUC__
#define _ATTRIBUTE(attrs) __attribute__ (attrs)
#else
#define _ATTRIBUTE(attrs)
#endif
int iprintf (const char *, ...)
_ATTRIBUTE ((__format__ (__printf__, 1, 2)));
......@@ -35,3 +35,9 @@ wf-pacman -S blocksds-nflib
echo "export BLOCKSDS=/opt/wonderful/thirdparty/blocksds/core" >> ~/.bashrc
echo "export BLOCKSDSEXT=/opt/wonderful/thirdparty/blocksds/external" >> ~/.bashrc
ln -sT /opt/wonderful/thirdparty/blocksds/external/nflib/ /opt/devkitpro/nflib
wf-pacman -S toolchain-gcc-arm-none-eabi-binutils
wf-pacman -S toolchain-gcc-arm-none-eabi-gcc
wf-pacman -S toolchain-gcc-arm-none-eabi-gcc-libs
wf-pacman -S toolchain-gcc-arm-none-eabi-libstdcxx-picolibc
wf-pacman -S toolchain-gcc-arm-none-eabi-picolibc-generic
// SPDX-License-Identifier: CC0-1.0
//
// SPDX-FileContributor: NightFox & Co., 2009-2011
//
// NightFox's Lib Template
// http://www.nightfoxandco.com
#include <stdio.h>
#include <nds.h>
#include <filesystem.h>
#include <nf_lib.h>
int main(int argc, char **argv) {
NF_Set2D(0, 0);
NF_Set2D(1, 0);
consoleDemoInit();
printf("Inicializando el isstema de archivos nitroglicerina\n");
swiWaitForVBlank();
nitroFSInit(NULL);
NF_SetRootFolder("NITROFS");
NF_Set2D(0, 5);
NF_Set2D(1, 5);
NF_InitBitmapBgSys(0, 0);
NF_InitBitmapBgSys(1, 0);
NF_Init8bitsBgBuffers();
NF_Init8bitsBackBuffer(0);
NF_Init8bitsBackBuffer(1);
NF_Enable8bitsBackBuffer(0);
NF_Enable8bitsBackBuffer(1);
NF_Load8bitsBg("bmp/img8b_1", 0);
NF_Load8bitsBg("bmp/img8b_2", 1);
NF_Load8bitsBg("bmp/img8b_3", 2);
// Pantalla 0, capa 2, numero de bitmap?
NF_Copy8bitsBuffer(0, 2, 1);
NF_Copy8bitsBuffer(0, 1, 0);
NF_Copy8bitsBuffer(1, 1, 2);
for (int n = 0; n < 256; n++) {
NF_8BITS_BACKBUFFER[1].pal[n] = *((u16 *)(0x05000400 + (n*2)));
}
NF_8BITS_BACKBUFFER[1].pal[255] = RGB15(31, 0, 0);
bool show = true;
while (1)
{
// Read keys and touchscreen
scanKeys();
touchPosition touchscreen;
touchRead(&touchscreen);
u16 keys_held = keysHeld();
u16 keys_down = keysDown();
// Check if the touch screen is pressed
if (keys_held & KEY_TOUCH)
{
int x = touchscreen.px;
if (x > 247)
x = 247;
int y = touchscreen.py;
if (y > 183)
y = 183;
// Draw a 8x8 block in both screens
for (int dy = 0; dy < 9; dy++)
{
for (int dx = 0; dx < 9; dx++)
{
u32 idx = ((y + dy) << 8) + (x + dx);
NF_8BITS_BACKBUFFER[0].data[idx] = 0; // Top screen
NF_8BITS_BACKBUFFER[1].data[idx] = 255; // Bottom screen
}
}
}
// Press A to hide or show layer 3 of the bottom screen
if (keys_down & KEY_A)
{
show = !show;
if (show)
NF_ShowBg(1, 3);
else
NF_HideBg(1, 3);
}
// Press X to restore the image in the top screen
if (keys_down & KEY_X)
NF_Copy8bitsBuffer(0, 2, 1);
// Press B to delete the drawing layer
if (keys_down & KEY_B)
memset(NF_8BITS_BACKBUFFER[1].data, 0, 65536);
// Copy backbuffer of the top screen to layer 2
NF_Flip8bitsBackBuffer(0, 0);
// Copy backbuffer of the bottom screen to layer 2
NF_Flip8bitsBackBuffer(1, 0);
// Wait for the screen refresh
swiWaitForVBlank();
}
return 0;
}
/*---------------------------------------------------------------------------------
$Id: main.cpp,v 1.13 2008-12-02 20:21:20 dovoto Exp $
Simple console print demo
-- dovoto
---------------------------------------------------------------------------------*/
#include <nds.h>
#include <stdio.h>
volatile int frame = 0;
//---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
frame++;
}
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
touchPosition touchXY;
irqSet(IRQ_VBLANK, Vblank);
consoleDemoInit();
iprintf(" Hello DS dev'rs\n");
iprintf(" \x1b[32mwww.devkitpro.org\n");
iprintf(" \x1b[32;1mwww.drunkencoders.com\x1b[39m");
while(1) {
swiWaitForVBlank();
scanKeys();
int keys = keysDown();
if (keys & KEY_START) break;
touchRead(&touchXY);
// print at using ansi escape sequence \x1b[line;columnH
iprintf("\x1b[10;0HFrame = %d",frame);
iprintf("\x1b[16;0HTouch x = %04X, %04X\n", touchXY.rawx, touchXY.px);
iprintf("Touch y = %04X, %04X\n", touchXY.rawy, touchXY.py);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment