00001 #ifndef _PA_GENERAL
00002 #define _PA_GENERAL
00003
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007
00008
00009
00010
00011 #include <nds.h>
00012 #include <nds/memory.h>
00013 #include <nds/bios.h>
00014 #include <malloc.h>
00015
00016 #include <stdarg.h>
00017 #include <string.h>
00018
00019
00020 extern u8 PA_Screen;
00021
00022 typedef struct {
00023 u8 NoIdea;
00024 u8 Year;
00025 u8 Month;
00026 u8 Day;
00027 u8 NoIdea2;
00028 u8 Hour;
00029 u8 Minutes;
00030 u8 Seconds;
00031 } RTC;
00032 extern RTC PA_RTC;
00033
00034 extern inline void PA_WaitForVBL(void);
00035
00036 extern s16 PA_ScreenSpace;
00037
00038 #define BG_GFX1 0x6000000
00039 #define BG_GFX2 0x6200000
00040 #define SPRITE_GFX1 0x6400000
00041 #define SPRITE_GFX2 0x6600000
00042
00043
00044
00045 #define REG_DMA3SRC *(volatile u32*)0x040000D4
00046 #define REG_DMA3DST *(volatile u32*)0x040000D8
00047 #define REG_DMA3CNT *(volatile u32*)0x040000DC
00048 #define DMA_ON 0x80000000
00049 #define DMA_NOW 0x00000000
00050 #define DMA_16 0x00000000
00051 #define DMA_32 0x04000000
00052 #define DMA_16NOW (DMA_ON | DMA_NOW | DMA_16)
00053 #define DMA_32NOW (DMA_ON | DMA_NOW | DMA_32)
00054 #define DMA_Copy(source, dest, count, mode) {REG_DMA3SRC = (u32)source; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) | (mode);}
00055
00056 #define DMA_Clear(dest, count, mode) {REG_DMA3SRC = (u32)Blank; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) | (mode);}
00057
00058 #define DMA_Force(ulVal,dest, count, mode) {REG_DMA3SRC=(u32)&ulVal; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) |(mode) | DMA_SRC_FIX;}
00059
00060
00061 #define BACKLIGHT(screen) BIT(2+screen)
00062
00063 #define ALWAYSINLINE __attribute__((always_inline)) static inline
00064
00065
00066
00067
00068
00069
00070
00071
00072 #define _REG8 *(volatile u16 *)
00073 #define _REG16 *(volatile u16 *)
00074 #define _REG32 *(volatile u32 *)
00075
00076
00077 #define SWITCH_SCREENS (1<<15)
00078
00079
00080
00081 #define N_HBLS 263
00082
00083
00084
00093
00094 extern u32 Blank[130000>>2];
00095
00096
00097
00098
00099
00100
00102
00104
00105 #define SIZEOF_8BIT(x) (sizeof(x))
00106 #define SIZEOF_16BIT(x) (sizeof(x)>>1)
00107 #define SIZEOF_32BIT(x) (sizeof(x)>>2)
00108
00109
00110
00111
00112 #define CODE_IN_IWRAM __attribute__ ((section (".iwram"), long_call))
00113 #define IN_IWRAM __attribute__ ((section (".iwram")))
00114 #define CODE_IN_EWRAM __attribute__ ((section (".ewram"), long_call))
00115 #define IN_EWRAM __attribute__ ((section (".ewram")))
00116 #define PACKED __attribute__ ((packed))
00117
00118
00119
00120
00121
00122
00123
00124
00125 void PA_jpeg_GetImageSize(char* name, int* width, int* height);
00126 void PA_jpeg_BltImage(char* name, u16* vram, int output_width, int output_height);
00127
00128 extern const s16 PA_SIN[512];
00129
00130
00131
00132 typedef struct {
00133 u8 Color;
00134 u8 BdayMonth;
00135 u8 BdayDay;
00136 u8 AlarmHour;
00137 u8 AlarmMinute;
00138 u8 Name[21];
00139 u8 NameLength;
00140 u8 Message[53];
00141 u8 MessageLength;
00142 u8 Language;
00143 } infos;
00144 extern infos PA_UserInfo;
00145
00146 #define INFO_COLOR *(u8*)0x027FFC82
00147 #define INFO_BDAY_MONTH *(u8*)0x027FFC83
00148 #define INFO_BDAY_DAY *(u8*)0x027FFC84
00149 #define INFO_ALARM_HOUR *(u8*)0x027FFCD2
00150 #define INFO_ALARM_MINUTE *(u8*)0x027FFCD3
00151 #define INFO_NAME *(u8*)0x027FFC86
00152 #define INFO_NAME_LENGTH *(u8*)0x027FFC9A
00153 #define INFO_MESSAGE *(u8*)0x027FFC9C
00154 #define INFO_MESSAGE_LENGTH *(u8*)0x027FFCD0
00155 #define INFO_LANGUAGE *(u8*)(0x027FFCE4)
00156
00157
00169 void PA_Init(void);
00170
00171
00172
00184 extern inline void PA_SetVideoMode(u8 screen, u8 mode) {
00185 (*(vuint32*)(0x04000000 + (0x1000 * screen))) &= ~7;
00186 (*(vuint32*)(0x04000000 + (0x1000 * screen))) |= mode;
00187 }
00188
00189
00190
00196 void PA_UpdateUserInfo(void);
00197
00198
00204 void PA_UpdateRTC(void);
00205
00206
00214 void PA_LoadSplash(void);
00215
00216
00222 void PA_NeoSplash(void);
00223
00224
00225
00231 extern inline void PA_WaitForVBL(void){
00232 swiWaitForVBlank();
00233 }
00234
00235
00236
00242 extern inline void PA_SwitchScreens(void) {
00243 POWER_CR ^= SWITCH_SCREENS;
00244 PA_Screen = !PA_Screen;
00245 }
00246
00247
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00270 #define PA_LidClosed() (IPC->buttons>>7)
00271
00272
00278 extern inline u8 PA_CheckLid(void) {
00279
00280 if (!PA_LidClosed()) return 0;
00281 else {
00282 u16 power_cr = POWER_CR;
00283 POWER_CR = 0;
00284
00285
00286 while(PA_LidClosed()) PA_WaitForVBL();
00287
00288
00289 POWER_CR = power_cr;
00290 return 1;
00291 }
00292
00293 }
00294
00295
00296
00308 extern inline void PA_SetScreenLight(u8 screen, u8 light){
00309 IPC->aux &= ~(1<<(2+screen));
00310 IPC->aux |= light<<(2+screen);
00311 }
00312
00313
00325 extern inline void PA_SetLedBlink(u8 blink, u8 speed){
00326 IPC->aux &= ~(3<<4);
00327 IPC->aux |= (blink + (speed<<1))<<4;
00328 }
00329
00330
00340 #define PA_WaitFor(something) {while(!(something)){PA_WaitForVBL(); }}
00341
00342
00343
00344
00345
00346
00347
00349
00350
00351 void PA_Nothing(void);
00352
00353
00354 #ifdef __cplusplus
00355 }
00356 #endif
00357 #endif
00358
00359
00360