head 1.1; branch 1.1.1; access ; symbols start:1.1.1.1 PAlibDoc:1.1.1; locks ; strict; comment @# @; 1.1 date 2005.11.02.08.30.24; author jandujar; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2005.11.02.08.30.24; author jandujar; state Exp; branches ; next ; desc @@ 1.1 log @Initial revision @ text @
00001 #ifndef _PA_Main 00002 #define _PA_Main 00003 00004 #ifdef __cplusplus 00005 extern "C" { 00006 #endif 00007 00008 00009 00010 #define USE_PA_SPLASH 00011 00012 // Comment out this line to limit the text sizes to only a single size, size 2... 00013 // This will make you gain 200-300ko 00014 //#define TEXT_ALLSIZES 00015 00016 00017 #include <nds.h> 00018 #include <nds/memory.h> 00019 #include <nds/bios.h> 00020 #include <malloc.h> 00021 00022 extern bool PA_Screen; 00023 00024 typedef struct { 00025 u8 NoIdea; 00026 u8 Year; 00027 u8 Month; 00028 u8 Day; 00029 u8 NoIdea2; 00030 u8 Hour; 00031 u8 Minutes; 00032 u8 Seconds; 00033 } RTC; 00034 extern RTC PA_RTC; 00035 00036 extern inline void PA_WaitForVBL(void); 00037 00038 00039 00040 #define BG_GFX1 0x6000000 00041 #define BG_GFX2 0x6200000 00042 #define SPRITE_GFX1 0x6400000 00043 #define SPRITE_GFX2 0x6600000 00044 00045 00046 //Pour le DMA Copy... 00047 #define REG_DMA3SRC *(volatile u32*)0x040000D4 00048 #define REG_DMA3DST *(volatile u32*)0x040000D8 00049 #define REG_DMA3CNT *(volatile u32*)0x040000DC 00050 #define DMA_ON 0x80000000 00051 #define DMA_NOW 0x00000000 00052 #define DMA_16 0x00000000 00053 #define DMA_32 0x04000000 00054 #define DMA_16NOW (DMA_ON | DMA_NOW | DMA_16) 00055 #define DMA_32NOW (DMA_ON | DMA_NOW | DMA_32) 00056 #define DMA_Copy(source, dest, count, mode) {REG_DMA3SRC = (u32)source; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) | (mode);} 00057 00058 #define DMA_Clear(dest, count, mode) {REG_DMA3SRC = (u32)Blank; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) | (mode);} 00059 00060 #define DMA_Force(ulVal,dest, count, mode) {REG_DMA3SRC=(u32)&ulVal; REG_DMA3DST = (u32)dest; REG_DMA3CNT = (count) |(mode) | DMA_SRC_FIX;} 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 #include <stdarg.h> // Pour le système de text 00071 #include <string.h> 00072 00073 #include "gbfs.h" 00074 #include "gba-jpeg-decode.h" 00075 #include "Sound9.h" 00076 00077 00078 #define _REG8 *(volatile u16 *) 00079 #define _REG16 *(volatile u16 *) 00080 #define _REG32 *(volatile u32 *) 00081 00082 #include "arm9/video.h" 00083 #include "arm9/PA_Sprite.h" 00084 #include "arm9/PA_Sound.h" 00085 #include "arm9/PA_Micro.h" 00086 #include "arm9/PA_Draw.h" 00087 #include "arm9/PA_Interrupt.h" 00088 #include "arm9/PA_Keys.h" 00089 #include "arm9/PA_API.h" 00090 #include "arm9/PA_Math.h" 00091 #include "arm9/PA_Palette.h" 00092 #include "arm9/PA_Save.h" 00093 #include "arm9/PA_GBFS.h" 00094 #include "arm9/PA_SpecialFx.h" 00095 00096 #include "arm9/PA_Tile.h" 00097 #include "arm9/PA_Keyboard.h" 00098 00099 #include "arm9/PA_Text.h" 00100 #include "arm9/PA_Window.h" 00101 00102 #include "arm9/PA_3D.h" 00103 #include "arm9/PA_IA.h" 00104 00105 #include "arm9/splash.h" 00106 #include "arm9/splash2.h" 00107 #include "arm9/PApalet.h" 00108 extern const unsigned short bitmap[768]; 00109 00110 00111 #include "arm9/NeoSplash.h" // Splash NeoFlash 00112 00113 00114 #define SWITCH_SCREENS (1<<15) 00115 00116 00117 00118 #define N_HBLS 263 00119 00120 00121 00130 extern u32 *Blank; 00131 00132 00133 00134 00135 00136 00137 00139 // Général 00141 00142 #define SIZEOF_8BIT(x) (sizeof(x)) 00143 #define SIZEOF_16BIT(x) (sizeof(x)>>1) 00144 #define SIZEOF_32BIT(x) (sizeof(x)>>2) 00145 00146 00147 00148 00149 #define CODE_IN_IWRAM __attribute__ ((section (".iwram"), long_call)) 00150 #define IN_IWRAM __attribute__ ((section (".iwram"))) 00151 #define CODE_IN_EWRAM __attribute__ ((section (".ewram"), long_call)) 00152 #define IN_EWRAM __attribute__ ((section (".ewram"))) 00153 #define PACKED __attribute__ ((packed)) 00154 00155 00156 00157 00158 00159 00160 00161 // Jpeg functions : 00162 void PA_jpeg_GetImageSize(char* name, int* width, int* height); 00163 void PA_jpeg_BltImage(char* name, u16* vram, int output_width, int output_height); 00164 00165 extern const s16 PA_SIN[512]; 00166 00167 00168 00169 typedef struct { 00170 u8 Color; // Favorite Color 00171 u8 BdayMonth; // Mois d'anniversaire 00172 u8 BdayDay; // Jour de naissance 00173 u8 AlarmHour; 00174 u8 AlarmMinute; 00175 u8 Name[21]; 00176 u8 NameLength; 00177 u8 Message[53]; 00178 u8 MessageLength; 00179 u8 Language; // Langue... 0 pour Jap, 1 pour anglais, 2 pour francais... 00180 } infos; 00181 extern infos PA_UserInfo; 00182 00183 #define INFO_COLOR *(u8*)0x027FFC82 00184 #define INFO_BDAY_MONTH *(u8*)0x027FFC83 00185 #define INFO_BDAY_DAY *(u8*)0x027FFC84 00186 #define INFO_ALARM_HOUR *(u8*)0x027FFCD2 00187 #define INFO_ALARM_MINUTE *(u8*)0x027FFCD3 00188 #define INFO_NAME *(u8*)0x027FFC86 00189 #define INFO_NAME_LENGTH *(u8*)0x027FFC9A 00190 #define INFO_MESSAGE *(u8*)0x027FFC9C 00191 #define INFO_MESSAGE_LENGTH *(u8*)0x027FFCD0 00192 #define INFO_LANGUAGE *(u8*)(0x027FFCE4) 00193 00194 00206 void PA_Init(void); 00207 00208 00209 00221 extern inline void PA_SetVideoMode(bool screen, u8 mode) { 00222 (*(vuint32*)(0x04000000 + (0x1000 * screen))) &= ~7; 00223 (*(vuint32*)(0x04000000 + (0x1000 * screen))) |= mode; 00224 } 00225 00226 00227 00233 void PA_UpdateUserInfo(void); 00234 00235 00241 void PA_UpdateRTC(void); 00242 00243 00251 void PA_LoadSplash(void); 00252 00253 00259 void PA_NeoSplash(void); 00260 00261 00262 00268 extern inline void PA_WaitForVBL(void){ 00269 swiWaitForVBlank(); 00270 } 00271 00272 00273 00279 extern inline void PA_SwitchScreens(void) { 00280 POWER_CR ^= SWITCH_SCREENS; 00281 PA_Screen = !PA_Screen; 00282 } 00283 00284 00290 extern inline void PA_InitCPUMeter() { 00291 PA_CPU = 0; 00292 PA_MaxCPU = 0; 00293 PA_lines = 0; 00294 PA_VBLCount = 0; 00295 PA_nVBLs = 0; 00296 } 00297 00298 00299 00300 00301 00307 #define PA_LidClosed() (IPC->buttons>>7) 00308 00309 00315 extern inline bool PA_CheckLid(void) { 00316 00317 if (!PA_LidClosed()) return 0; 00318 else { 00319 u16 power_cr = POWER_CR; // backup the power... 00320 POWER_CR = 0; // Shutdown everything :p 00321 00322 // Wait for the lid to be opened again... 00323 while(PA_LidClosed()) PA_WaitForVBL(); 00324 00325 // Return the power ! 00326 POWER_CR = power_cr; 00327 return 1; 00328 } 00329 00330 } 00331 00332 00333 00334 00335 00363 void PA_Splash(void* tiles0, void* map0, void* tiles1, void* map1, s16 color0, s16 color1, s16 time); 00364 00365 // end of General 00367 00368 00369 void PA_Nothing(void); 00370 00371 #ifdef __cplusplus 00372 } 00373 #endif 00374 #endif 00375 00376 00377