PAlib: PA9.h Source File

Main Page | Modules | File List | Globals | Search for

# PA9.h

Go to the documentation of this file.

    00001 #ifndef _PA_Main
    00002 #define _PA_Main
    00003
    00004 #ifdef __cplusplus
    00005 extern "C" {
    00006 #endif
    00007
    00008
    00009 #include "../../PA_Config.h"
    00010
    00011
    00012 #ifdef USE_8BITTEXT
    00013        #define TEXT_ALLSIZES
    00014 #endif
    00015
    00016
    00017 #include <nds.h>
    00018 #include <nds/memory.h>
    00019 #include <nds/bios.h>
    00020 #include <malloc.h>
    00021
    00022 extern u8 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 extern s16 PA_ScreenSpace; // Espace entre les 2 écrans...+192
    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 // Commandes pour la lumière des écrans
    00063 #define BACKLIGHT(screen)   BIT(2+screen)
    00064
    00065 #define ALWAYSINLINE __attribute__((always_inline)) static inline
    00066
    00067
    00068
    00069
    00070
    00071 #include <stdarg.h> // Pour le système de text
    00072 #include <string.h>
    00073
    00074 #include "gbfs.h"
    00075 #include "gba-jpeg-decode.h"
    00076 #include "Sound9.h"
    00077
    00078
    00079 #define _REG8 *(volatile u16 *)
    00080 #define _REG16 *(volatile u16 *)
    00081 #define _REG32 *(volatile u32 *)
    00082
    00083 #include "arm9/vidfile.h"
    00084 #include "arm9/PA_Sprite.h"
    00085 #include "arm9/PA_SpriteDual.h"
    00086 #include "arm9/PA_Sound.h"
    00087 #include "arm9/PA_Micro.h"
    00088 #include "arm9/PA_Draw.h"
    00089 #include "arm9/PA_Interrupt.h"
    00090 #include "arm9/PA_Keys.h"
    00091
    00092 #include "arm9/PA_Timer.h"
    00093
    00094 #ifdef TEXT_ALLSIZES
    00095        #include "arm9/PA_API.h"  // API only if has text...
    00096 #endif
    00097
    00098 #include "arm9/PA_Math.h"
    00099 #include "arm9/PA_Palette.h"
    00100 #include "arm9/PA_PaletteDual.h"
    00101 #include "arm9/PA_Save.h"
    00102 #include "arm9/PA_FS.h"
    00103 #include "arm9/PA_GBFS.h"
    00104 #include "arm9/PA_SpecialFx.h"
    00105
    00106 #include "arm9/PA_Tile.h"
    00107 #include "arm9/PA_TileDual.h"
    00108
    00109 #include "arm9/PA_FAT.h"  // fat driver by chrishm
    00110
    00111 #ifdef USE_KEYBOARD
    00112        #include "arm9/PA_Keyboard.h"
    00113 #endif
    00114
    00115 #include "arm9/PA_Text.h"
    00116 #include "arm9/PA_Window.h"
    00117
    00118 #include "arm9/PA_Mode7.h"
    00119
    00120 #ifdef USE_3D
    00121        #include "arm9/PA_3D.h"
    00122 #endif
    00123
    00124
    00125 #include "arm9/PA_IA.h"
    00126 #include "arm9/PA_Reco.h"
    00127
    00128
    00129 #include "arm9/PA_16c.h"
    00130
    00131
    00132 #define SWITCH_SCREENS  (1<<15)
    00133
    00134
    00135
    00136 #define N_HBLS 263
    00137
    00138
    00139
    00148 //extern u32 *Blank;
    00149 extern u32 Blank[130000>>2];
    00150
    00151
    00152
    00153
    00154
    00155
    00157 // Général
    00159
    00160 #define SIZEOF_8BIT(x)          (sizeof(x))
    00161 #define SIZEOF_16BIT(x)         (sizeof(x)>>1)
    00162 #define SIZEOF_32BIT(x)         (sizeof(x)>>2)
    00163
    00164
    00165
    00166
    00167 #define CODE_IN_IWRAM __attribute__ ((section (".iwram"), long_call))
    00168 #define IN_IWRAM __attribute__ ((section (".iwram")))
    00169 #define CODE_IN_EWRAM __attribute__ ((section (".ewram"), long_call))
    00170 #define IN_EWRAM __attribute__ ((section (".ewram")))
    00171 #define PACKED __attribute__ ((packed))
    00172
    00173
    00174
    00175
    00176
    00177
    00178
    00179 // Jpeg functions :
    00180 void PA_jpeg_GetImageSize(char* name, int* width, int* height);
    00181 void PA_jpeg_BltImage(char* name, u16* vram, int output_width, int output_height);
    00182
    00183 extern const s16 PA_SIN[512];
    00184
    00185
    00186
    00187 typedef struct {
    00188    u8 Color;  // Favorite Color
    00189    u8 BdayMonth; // Mois d'anniversaire
    00190    u8 BdayDay;  // Jour de naissance
    00191    u8 AlarmHour;
    00192    u8 AlarmMinute;
    00193    u8 Name[21];
    00194    u8 NameLength;
    00195    u8 Message[53];
    00196    u8 MessageLength;
    00197    u8 Language; // Langue... 0 pour Jap, 1 pour anglais, 2 pour francais...
    00198 } infos;
    00199 extern infos PA_UserInfo;
    00200
    00201 #define INFO_COLOR *(u8*)0x027FFC82
    00202 #define INFO_BDAY_MONTH *(u8*)0x027FFC83
    00203 #define INFO_BDAY_DAY *(u8*)0x027FFC84
    00204 #define INFO_ALARM_HOUR *(u8*)0x027FFCD2
    00205 #define INFO_ALARM_MINUTE *(u8*)0x027FFCD3
    00206 #define INFO_NAME *(u8*)0x027FFC86
    00207 #define INFO_NAME_LENGTH *(u8*)0x027FFC9A
    00208 #define INFO_MESSAGE *(u8*)0x027FFC9C
    00209 #define INFO_MESSAGE_LENGTH *(u8*)0x027FFCD0
    00210 #define INFO_LANGUAGE  *(u8*)(0x027FFCE4)
    00211
    00212
    00224 void PA_Init(void);
    00225
    00226
    00227
    00239 extern inline void PA_SetVideoMode(u8 screen, u8 mode) {
    00240        (*(vuint32*)(0x04000000 + (0x1000 * screen))) &= ~7;
    00241        (*(vuint32*)(0x04000000 + (0x1000 * screen))) |= mode;
    00242 }
    00243
    00244
    00245
    00251 void PA_UpdateUserInfo(void);
    00252
    00253
    00259 void PA_UpdateRTC(void);
    00260
    00261
    00269 void PA_LoadSplash(void);
    00270
    00271
    00277 void PA_NeoSplash(void);
    00278
    00279
    00280
    00286 extern inline void PA_WaitForVBL(void){
    00287 swiWaitForVBlank();
    00288 }
    00289
    00290
    00291
    00297 extern inline void PA_SwitchScreens(void) {
    00298 POWER_CR ^= SWITCH_SCREENS;
    00299 PA_Screen = !PA_Screen;
    00300 }
    00301
    00302
    00308 extern inline void PA_InitCPUMeter() {
    00309        PA_CPU = 0;
    00310        PA_MaxCPU = 0;
    00311        PA_lines = 0;
    00312        PA_VBLCount = 0;
    00313        PA_nVBLs = 0;
    00314 }
    00315
    00316
    00317
    00318
    00319
    00325 #define PA_LidClosed() (IPC->buttons>>7)
    00326
    00327
    00333 extern inline u8 PA_CheckLid(void) {
    00334
    00335 if (!PA_LidClosed()) return 0;
    00336 else {
    00337        u16 power_cr = POWER_CR; // backup the power...
    00338        POWER_CR = 0; // Shutdown everything :p
    00339
    00340        // Wait for the lid to be opened again...
    00341        while(PA_LidClosed()) PA_WaitForVBL();
    00342
    00343        // Return the power !
    00344        POWER_CR = power_cr;
    00345        return 1;
    00346 }
    00347
    00348 }
    00349
    00350
    00351
    00352
    00353
    00381 void PA_Splash(void* tiles0, void* map0, void* tiles1, void* map1, s16 color0, s16 color1, s16 time);
    00382
    00383
    00395 extern inline void PA_SetScreenLight(u8 screen, u8 light){
    00396        IPC->aux &= ~(1<<(2+screen));
    00397        IPC->aux |= light<<(2+screen);
    00398 }
    00399
    00400
    00412 extern inline void PA_SetLedBlink(u8 blink, u8 speed){
    00413        IPC->aux &= ~(3<<4);
    00414        IPC->aux |= (blink + (speed<<1))<<4;
    00415 }
    00416
    00417
    00418
    00419  // end of General
    00421
    00422
    00423 void PA_Nothing(void);
    00424
    00425
    00426 #ifdef __cplusplus
    00427 }
    00428 #endif
    00429 #endif
    00430
    00431
    00432