NDS Homebrew Application Framework

From KBase

(Redirected from GNHAF)
Jump to: navigation, search


[edit] Introduction

GNHAF is GyonG's NDS Homebrew Application Framework.

[edit] Why I made this Library

This framework is what I wrote to make nds applications. There are already many good libraries like PALib, I just wanted to make my own library, because I want to modify and develop the framework the way I like.

[edit] Too few features

If the current version of the library is missing some feature you want, that's why I just haven't needed it yet. I am adding more features while I'm making more applications.

[edit] Framebuffer Mode Only

This Library (currently) doesn't support Sprites, nor 3D graphics. It only supports Framebuffer Mode. This can cause the application runs slower than those with sprites. Applications I have made are not such games that require speed, so I have not added sprite feature. I (surely) think someday I'll need the fast sprite functions, then I'll add the function to the future version of this library.

(This document is being written. Please wait)

[edit] Features

[edit] Graphics classes

[edit] Graphics

A singleton class for the frame buffer and the graphical operations.

To use this Graphics, you should get the singleton instance

   static Graphics *getSingleton();

Set LCD Type

   enum LcdType {
   LcdType getActiveLcd();
   void setActiveLcd(LcdType lcd);

Set color

   void setColor(nds_color color);
   nds_color getColor();

Draw String

   void setFont(FontIndex fontIndex);
   void drawString(int x, int y, const char *str);

Or Draw Something Else

   void dim();
   void clearScreen();
   void drawBackgroundImage(Image *img);
   void drawImage(int x, int y, Image *img);
   void fillRectangle(int x, int y, int w, int h);
   void drawRectangle(int x, int y, int w, int h);
  • drawRectangle currently doesn't work.
  • drawImage() is for 32 bit alpha-blended image, and drawBackgroundImage is for 16-bit full-screen (256x192) image. I don't think this is good, so this shall be modified in the near future. See also #Image for more information.
  • Drawing String doesn't automatically invalidate the screen. invalidate() should be called after drawing string, or it is not required if you called fillRectangle to draw background rectangle.

Invalidated rectangle area is copied to the LCD buffer on flush. Functions related to the invalidation are:

   void getInvalidRect(int iLcd, RectS16 &rect);
   bool isInvalidated(int iLcd = -1);
   void invalidate(const RectS16 &rect);
   void invalidate(int x, int y, int w, int h);
   void flush();

[edit] Image

Image has just one pointer to a byte array of GPN file format. GPN file format is like this:

 struct Gpn {
   int signature;
   int version;
   short width;
   short height;
   int size;
   unsigned int data[1];

A Scene can have images like this:

 class SomeScene : public Scene {
   Image m_imgArrow;

And then specify the data

 #include "arrow_gpn.h"
 SomeScene::SomeScene() : m_imgArrow(arrow_gpn)

Now you can use m_imgArrow in your SomeScene member functions

[edit] Font

[edit] Primitives

  • Event
    • KeyEvent
    • TouchEvent
  • Simple Structures
    • Point
      • PointU8
      • PointS16
    • Rectangle
      • RectU8
      • RectS16
  • Color

[edit] Framework

  • Event
  • EventManager
  • Button
  • Scene
  • main

[edit] Tools

[edit] GPN

[edit] GFN

[edit] Usage

[edit] Hello world

[edit] Makefile

[edit] TODO

Ordered by Importance. Things that appears first should be implemented first.

  • Clipping for graphics oprations
  • Translation (offset)
  • drawText in a Rectangle, with alignment
  • Copy area from/to the graphics buffer
  • sleep/wait for battery saving
  • Drawing GPN with 16/32 bit, fullscreen, partly
  • Drawing variable width font
  • Mandating InitScene
  • Win32 GpnMaker
  • Drawing and filling more graphical primitives like line, box, ellipse, polygon, ...
  • Buttons with frame images (arbitrary size with one border image)
  • Decompression support
  • UI Components
    • ScrollBar
    • List
  • Drawing Background of text (TRANSPARENT/OPAQUE in Win32)
Personal tools
Wiki Help (mediawiki.org)