- Main Page
- Classes
- Files

- File List

# C:/Documents and Settings/Administrator/Desktop/woopsi-src-0.39/Woopsi/woopsi/woopsifuncs.h

    00001 /* Contributed by Steven
    00002  * 20071213
    00003  * - Minor modifications and SDL code by Ant
    00004  */
    00005
    00006 #ifndef _WOOPSIFUNCS_H_
    00007 #define _WOOPSIFUNCS_H_
    00008
    00009 #include <nds.h>
    00010
    00011 #ifdef USING_SDL
    00012
    00013 #include <stdio.h>
    00014 #include <stdlib.h>
    00015 #include <string.h>
    00016 #include <math.h>
    00017
    00018 #define woopsiRGB(r, g, b) (((b) << 10) | ((g) << 5) | (r) | (1 << 15))
    00019
    00020 #define DMA_ON 0x80000000
    00021 #define DMA_NOW 0x00000000
    00022 #define DMA_16 0x00000000
    00023 #define DMA_32 0x04000000
    00024 #define DMA_16NOW (DMA_ON | DMA_NOW | DMA_16)
    00025 #define DMA_32NOW (DMA_ON | DMA_NOW | DMA_32)
    00026
    00027 void DMA_Copy(u16* source, u16* dest, u32 count, u32 mode);
    00028 void DMA_Force(u16 source, u16* dest, u32 count, u32 mode);
    00029 void DMA_Copy2(u16* source, u16* dest, u32 count, u32 mode);
    00030 void DMA_Force2(u16 source, u16* dest, u32 count, u32 mode);
    00031 bool DMA_Active();
    00032 bool DMA_Active2();
    00033
    00034 typedef struct PAD
    00035 {
    00036         union
    00037         {
    00038                 struct
    00039                 {
    00040                         u16 A:1;
    00041                         u16 B:1;
    00042                         u16 Select:1;
    00043                         u16 Start:1;
    00044                         u16 Right:1;
    00045                         u16 Left:1;
    00046                         u16 Up:1;
    00047                         u16 Down:1;
    00048                         u16 R:1;
    00049                         u16 L:1;
    00050                         u16 X:1;
    00051                         u16 Y:1;
    00052                         u16 Touch:1;
    00053                         u16 Lid:1;
    00054                 };
    00055                 u16 AllKeys;
    00056         };
    00057 } _pad;
    00058
    00059 typedef struct PADS {
    00060    _pad Held, Released, Newpress;
    00061 } _pads;
    00062
    00063 typedef struct STYLUS {
    00064         u8 Held:1, Released:1, Newpress:1, unused:5;
    00065         s16 X, Y, Vx, Vy, oldVx, oldVy, Downtime, Uptime, DblClick;
    00066 } _stylus;
    00067
    00068 extern _pads Pad;
    00069 extern _stylus Stylus;
    00070
    00071 void woopsiUpdateInput();
    00072 void putPixel(SDL_Surface *surface, int x, int y, Uint32 pixel);
    00073
    00074 // Generic functions
    00075 extern u16* DrawBg[2];
    00076
    00077 void initWoopsiGfxMode();
    00078 void woopsiWaitVBL();
    00079 bool woopsiLidClosed();
    00080
    00081 // Simulate some features of libnds
    00082 void DC_FlushRange(const void *base, u32 size);
    00083
    00084 #else
    00085
    00094 #define woopsiRGB(r, g, b) (((b) << 10) | ((g) << 5) | (r) | (1 << 15))
    00095
    00096 // Extra DMA defines
    00097 #define REG_DMA2SRC *(volatile u32*)0x040000C8
    00098 #define REG_DMA2DST *(volatile u32*)0x040000CC
    00099 #define REG_DMA2CNT *(volatile u32*)0x040000D0
    00100
    00109 #define DMA_Copy2(source, dest, count, mode) {REG_DMA2SRC = (u32)source; REG_DMA2DST = (u32)dest; REG_DMA2CNT = (count) | (mode);}
    00110
    00120 #define DMA_Force2(ulVal, dest, count, mode) {REG_DMA2SRC=(u32)&ulVal; REG_DMA2DST = (u32)dest; REG_DMA2CNT = (count) | (mode) | DMA_SRC_FIX;}
    00121
    00128 #define DMA_Active() (!(!(REG_DMA3CNT & DMA_ON)))
    00129
    00135 #define DMA_Active2() (!(!(REG_DMA2CNT & DMA_ON)))
    00136
    00137 #ifdef USING_PALIB
    00138 #include <PA9.h>
    00139 #else
    00140
    00141 #include <nds/memory.h>
    00142 #include <nds/bios.h>
    00143
    00144 #define REG_DMA3SRC *(volatile u32*)0x040000D4
    00145 #define REG_DMA3DST *(volatile u32*)0x040000D8
    00146 #define REG_DMA3CNT *(volatile u32*)0x040000DC
    00147 #define DMA_ON 0x80000000
    00148 #define DMA_NOW 0x00000000
    00149 #define DMA_16 0x00000000
    00150 #define DMA_32 0x04000000
    00151 #define DMA_16NOW (DMA_ON | DMA_NOW | DMA_16)
    00152 #define DMA_32NOW (DMA_ON | DMA_NOW | DMA_32)
    00153
    00162 #define DMA_Copy(source, dest, count, mode) {REG_DMA3SRC = (u32)source; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) | (mode);}
    00163
    00171 #define DMA_Clear(dest, count, mode) {REG_DMA3SRC = (u32)Blank; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) | (mode);}
    00172
    00181 #define DMA_Force(ulVal, dest, count, mode) {REG_DMA3SRC=(u32)&ulVal; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) | (mode) | DMA_SRC_FIX;}
    00182
    00186 #define DMA_CopyEx(type, source, dest, count, mode) {DMA_SRC(type) = (u32)source; DMA_DEST(type) = (u32)dest; DMA_CR(type) = (count) | (mode);}
    00187
    00191 typedef struct PAD
    00192 {
    00193         union
    00194         {
    00195                 struct
    00196                 {
    00197                         u16 A : 1;
    00198                         u16 B : 1;
    00199                         u16 Select : 1;
    00200                         u16 Start : 1;
    00201                         u16 Right : 1;
    00202                         u16 Left : 1;
    00203                         u16 Up : 1;
    00204                         u16 Down : 1;
    00205                         u16 R : 1;
    00206                         u16 L : 1;
    00207                         u16 X : 1;
    00208                         u16 Y : 1;
    00209                         u16 Touch : 1;
    00210                         u16 Lid : 1;
    00211                 };
    00212                 u16 AllKeys;
    00213         };
    00214 } _pad;
    00215
    00219 typedef struct PADS {
    00220    _pad Held, Released, Newpress;
    00221 } _pads;
    00222
    00226 typedef struct STYLUS {
    00227         u8 Held : 1, Released : 1, Newpress : 1, unused : 5;
    00228         s16 X, Y, Vx, Vy, oldVx, oldVy, Downtime, Uptime, DblClick;
    00229 } _stylus;
    00230
    00234 extern _pads Pad;
    00235
    00239 extern _stylus Stylus;
    00240
    00246 void woopsiUpdateInput();
    00247
    00248 #endif
    00249
    00253 extern u16* DrawBg[2];
    00254
    00259 void initWoopsiGfxMode();
    00260
    00264 void woopsiWaitVBL();
    00265
    00270 bool woopsiLidClosed();
    00271
    00272 #endif
    00273 #endif

All Classes Functions Variables Enumerations Enumerator