Merge branch 'refactor' of github.com:smealum/ctrulib into refactor
This commit is contained in:
commit
f9fbfc3c48
2
libctru/.gitignore
vendored
2
libctru/.gitignore
vendored
@ -1,2 +1,4 @@
|
||||
build
|
||||
lib
|
||||
docs
|
||||
internal_docs
|
||||
|
2303
libctru/Doxyfile
Normal file
2303
libctru/Doxyfile
Normal file
File diff suppressed because it is too large
Load Diff
2303
libctru/Doxyfile.internal
Normal file
2303
libctru/Doxyfile.internal
Normal file
File diff suppressed because it is too large
Load Diff
@ -17,7 +17,7 @@ include $(DEVKITARM)/base_rules
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := ctru
|
||||
BUILD := build
|
||||
SOURCES := source source/services
|
||||
SOURCES := source source/services source/gpu
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
@ -87,6 +87,10 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
dox:
|
||||
@doxygen Doxyfile
|
||||
@doxygen Doxyfile.internal
|
||||
|
||||
lib:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
@ -97,7 +101,7 @@ $(BUILD): lib
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) lib
|
||||
@rm -fr $(BUILD) lib docs internal_docs
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
@ -1,39 +1,146 @@
|
||||
#pragma once
|
||||
#ifndef FS_H
|
||||
#define FS_H
|
||||
|
||||
#define FS_OPEN_READ (1<<0)
|
||||
#define FS_OPEN_WRITE (1<<1)
|
||||
#define FS_OPEN_CREATE (1<<2)
|
||||
/*! @file FS.h
|
||||
*
|
||||
* Filesystem Services
|
||||
*/
|
||||
|
||||
#define FS_ATTRIBUTE_NONE (0x00000000)
|
||||
#define FS_ATTRIBUTE_READONLY (0x00000001)
|
||||
#define FS_ATTRIBUTE_ARCHIVE (0x00000100)
|
||||
#define FS_ATTRIBUTE_HIDDEN (0x00010000)
|
||||
#define FS_ATTRIBUTE_DIRECTORY (0x01000000)
|
||||
#include <string.h>
|
||||
#include <3ds/types.h>
|
||||
|
||||
typedef enum{
|
||||
PATH_INVALID = 0, // Specifies an invalid path.
|
||||
PATH_EMPTY = 1, // Specifies an empty path.
|
||||
PATH_BINARY = 2, // Specifies a binary path, which is non-text based.
|
||||
PATH_CHAR = 3, // Specifies a text based path with a 8-bit byte per character.
|
||||
PATH_WCHAR = 4, // Specifies a text based path with a 16-bit short per character.
|
||||
}FS_pathType;
|
||||
|
||||
typedef struct{
|
||||
FS_pathType type;
|
||||
u32 size;
|
||||
u8* data;
|
||||
}FS_path;
|
||||
|
||||
typedef struct{
|
||||
u32 id;
|
||||
FS_path lowPath;
|
||||
Handle handleLow, handleHigh;
|
||||
}FS_archive;
|
||||
|
||||
static inline FS_path FS_makePath(FS_pathType type, char* path)
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
return (FS_path){type, strlen(path)+1, (u8*)path};
|
||||
#endif
|
||||
|
||||
/*! @defgroup fs_open_flags FS Open Flags
|
||||
*
|
||||
* @sa FSUSER_OpenFile
|
||||
* @sa FSUSER_OpenFileDirectly
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! Open file for read. */
|
||||
#define FS_OPEN_READ (1<<0)
|
||||
/*! Open file for write. */
|
||||
#define FS_OPEN_WRITE (1<<1)
|
||||
/*! Create file if it doesn't exist. */
|
||||
#define FS_OPEN_CREATE (1<<2)
|
||||
/* @} */
|
||||
|
||||
/*! @defgroup fs_create_attributes FS Create Attributes
|
||||
*
|
||||
* @sa FSUSER_OpenFile
|
||||
* @sa FSUSER_OpenFileDirectly
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! No attributes. */
|
||||
#define FS_ATTRIBUTE_NONE (0x00000000)
|
||||
/*! Create with read-only attribute. */
|
||||
#define FS_ATTRIBUTE_READONLY (0x00000001)
|
||||
/*! Create with archive attribute. */
|
||||
#define FS_ATTRIBUTE_ARCHIVE (0x00000100)
|
||||
/*! Create with hidden attribute. */
|
||||
#define FS_ATTRIBUTE_HIDDEN (0x00010000)
|
||||
/*! Create with directory attribute. */
|
||||
#define FS_ATTRIBUTE_DIRECTORY (0x01000000)
|
||||
/*! @} */
|
||||
|
||||
/*! @defgroup fs_write_flush_flags FS Flush Flags
|
||||
*
|
||||
* @sa FSFILE_Write
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*! Don't flush */
|
||||
#define FS_WRITE_NOFLUSH (0x00000000)
|
||||
/*! Flush */
|
||||
#define FS_WRITE_FLUSH (0x00010001)
|
||||
|
||||
/* @} */
|
||||
|
||||
/*! FS path type */
|
||||
typedef enum
|
||||
{
|
||||
PATH_INVALID = 0, //!< Specifies an invalid path.
|
||||
PATH_EMPTY = 1, //!< Specifies an empty path.
|
||||
PATH_BINARY = 2, //!< Specifies a binary path, which is non-text based.
|
||||
PATH_CHAR = 3, //!< Specifies a text based path with a 8-bit byte per character.
|
||||
PATH_WCHAR = 4, //!< Specifies a text based path with a 16-bit short per character.
|
||||
} FS_pathType;
|
||||
|
||||
/*! FS path */
|
||||
typedef struct
|
||||
{
|
||||
FS_pathType type; //!< FS path type.
|
||||
u32 size; //!< FS path size.
|
||||
const u8 *data; //!< Pointer to FS path data.
|
||||
} FS_path;
|
||||
|
||||
/*! FS archive */
|
||||
typedef struct
|
||||
{
|
||||
u32 id; //!< Archive ID.
|
||||
FS_path lowPath; //!< FS path.
|
||||
Handle handleLow; //!< High word of handle.
|
||||
Handle handleHigh; //!< Low word of handle.
|
||||
} FS_archive;
|
||||
|
||||
/*! Directory entry */
|
||||
typedef struct
|
||||
{
|
||||
// 0x00
|
||||
u16 name[0x106]; //!< UTF-16 encoded name
|
||||
// 0x20C
|
||||
u8 shortName[0x09]; //!< 8.3 file name
|
||||
// 0x215
|
||||
u8 unknown1; //!< ???
|
||||
// 0x216
|
||||
u8 shortExt[0x04]; //!< 8.3 file extension (set to spaces for directories)
|
||||
// 0x21A
|
||||
u8 unknown2; //!< ???
|
||||
// 0x21B
|
||||
u8 unknown3; //!< ???
|
||||
// 0x21C
|
||||
u8 isDirectory; //!< 0x00 for files, 0x01 for directories
|
||||
// 0x21D
|
||||
u8 unknown4; //!< ???
|
||||
// 0x21E
|
||||
u8 isFile; //!< 0x01 for files, 0x00 for directories
|
||||
// 0x21F
|
||||
u8 unknown5; //!< ???
|
||||
// 0x220
|
||||
u8 unknown6; //!< ???
|
||||
// 0x221
|
||||
u8 unknown7; //!< ???
|
||||
// 0x222
|
||||
u8 unknown8; //!< ???
|
||||
// 0x223
|
||||
u8 unknown9; //!< ???
|
||||
// 0x224
|
||||
u8 padding[0x04]; //!< ???
|
||||
} FS_dirent;
|
||||
|
||||
/*! Create an FS_path from a type and data pointer.
|
||||
*
|
||||
* @param[in] type Path type.
|
||||
* @param[in] path Pointer to path data.
|
||||
*
|
||||
* @returns FS_path
|
||||
*
|
||||
* @sa FS_pathType
|
||||
*/
|
||||
static inline FS_path
|
||||
FS_makePath(FS_pathType type,
|
||||
const char *path)
|
||||
{
|
||||
return (FS_path){type, strlen(path)+1, (const u8*)path};
|
||||
}
|
||||
|
||||
Result fsInit(void);
|
||||
@ -45,14 +152,24 @@ Result FSUSER_OpenDirectory(Handle* handle, Handle* out, FS_archive archive, FS_
|
||||
Result FSUSER_OpenFile(Handle* handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
|
||||
Result FSUSER_OpenFileDirectly(Handle* handle, Handle* out, FS_archive archive, FS_path fileLowPath, u32 openflags, u32 attributes);
|
||||
Result FSUSER_CloseArchive(Handle* handle, FS_archive* archive);
|
||||
Result FSUSER_CreateDirectory(Handle* handle, FS_archive archive, FS_path dirLowPath);
|
||||
Result FSUSER_DeleteFile(Handle *handle, FS_archive archive, FS_path fileLowPath);
|
||||
Result FSUSER_DeleteDirectory(Handle *handle, FS_archive archive, FS_path dirLowPath);
|
||||
|
||||
Result FSFILE_Close(Handle handle);
|
||||
Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, u32 *buffer, u32 size);
|
||||
Result FSFILE_Write(Handle handle, u32 *bytesWritten, u64 offset, u32 *buffer, u32 size, u32 flushFlags);
|
||||
Result FSFILE_Read(Handle handle, u32 *bytesRead, u64 offset, void *buffer, u32 size);
|
||||
Result FSFILE_Write(Handle handle, u32 *bytesWritten, u64 offset, const void *buffer, u32 size, u32 flushFlags);
|
||||
Result FSFILE_GetSize(Handle handle, u64 *size);
|
||||
Result FSFILE_SetSize(Handle handle, u64 size);
|
||||
Result FSFILE_GetAttributes(Handle handle, u32 *attributes);
|
||||
Result FSFILE_SetAttributes(Handle handle, u32 attributes);
|
||||
Result FSFILE_Flush(Handle handle);
|
||||
|
||||
Result FSDIR_Read(Handle handle, u32 *entriesRead, u32 entrycount, u16 *buffer);
|
||||
Result FSDIR_Read(Handle handle, u32 *entriesRead, u32 entrycount, FS_dirent *buffer);
|
||||
Result FSDIR_Close(Handle handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -79,7 +79,6 @@ Result GSPGPU_ReadHWRegs(Handle *handle, u32 regAddr, u32* data, u8 size);
|
||||
Result GSPGPU_RegisterInterruptRelayQueue(Handle *handle, Handle eventHandle, u32 flags, Handle* outMemHandle, u8* threadID);
|
||||
Result GSPGPU_UnregisterInterruptRelayQueue(Handle* handle);
|
||||
Result GSPGPU_TriggerCmdReqQueue(Handle *handle);
|
||||
|
||||
Result GSPGPU_submitGxCommand(u32* sharedGspCmdBuf, u32 gxCommand[0x8], Handle* handle);
|
||||
Result GSPGPU_SubmitGxCommand(u32* sharedGspCmdBuf, u32 gxCommand[0x8], Handle* handle);
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
gpu.c _ Advanced GPU commands.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <3ds/types.h>
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
shdr.c _ Shader loader.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <3ds/types.h>
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
apt.c _ Applet/NS shell interaction
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <3ds/types.h>
|
||||
@ -15,16 +19,17 @@ Handle aptuHandle;
|
||||
Handle aptEvents[3];
|
||||
|
||||
Handle aptEventHandlerThread;
|
||||
u64 aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]; //u64 so that it's 8-byte aligned
|
||||
u64 aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]; // u64 so that it's 8-byte aligned
|
||||
|
||||
Handle aptStatusMutex;
|
||||
Handle aptStatusEvent = 0;
|
||||
APP_STATUS aptStatus = APP_NOTINITIALIZED;
|
||||
APP_STATUS aptStatus_beforesleepmode = APP_NOTINITIALIZED;
|
||||
APP_STATUS aptStatusBeforeSleep = APP_NOTINITIALIZED;
|
||||
u32 aptStatusPower = 0;
|
||||
|
||||
u32 aptParameters[0x1000/4]; //TEMP
|
||||
|
||||
|
||||
void aptInitCaptureInfo(u32 *ns_capinfo)
|
||||
{
|
||||
u32 tmp=0;
|
||||
@ -33,30 +38,17 @@ void aptInitCaptureInfo(u32 *ns_capinfo)
|
||||
|
||||
memset(&gspcapinfo, 0, sizeof(GSP_CaptureInfo));
|
||||
|
||||
// Get display-capture info from GSP.
|
||||
GSPGPU_ImportDisplayCaptureInfo(NULL, &gspcapinfo);
|
||||
|
||||
// Fill in display-capture info for NS.
|
||||
if(gspcapinfo.screencapture[0].framebuf0_vaddr != gspcapinfo.screencapture[1].framebuf0_vaddr)ns_capinfo[1] = 1;
|
||||
|
||||
ns_capinfo[4] = gspcapinfo.screencapture[0].format & 0x7;
|
||||
ns_capinfo[7] = gspcapinfo.screencapture[1].format & 0x7;
|
||||
|
||||
if(ns_capinfo[4] < 2)
|
||||
{
|
||||
main_pixsz = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
main_pixsz = 2;
|
||||
}
|
||||
|
||||
if(ns_capinfo[7] < 2)
|
||||
{
|
||||
sub_pixsz = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
sub_pixsz = 2;
|
||||
}
|
||||
main_pixsz = (ns_capinfo[4] < 2) ? 3 : 2;
|
||||
sub_pixsz = (ns_capinfo[7] < 2) ? 3 : 2;
|
||||
|
||||
ns_capinfo[2] = sub_pixsz * 0x14000;
|
||||
ns_capinfo[3] = ns_capinfo[2];
|
||||
@ -122,22 +114,27 @@ void aptReturnToMenu()
|
||||
u32 ns_capinfo[0x20>>2];
|
||||
u32 tmp_params[0x20>>2];
|
||||
|
||||
if(aptGetStatusPower()==0)//This is only executed when ret-to-menu was triggered via the home-button, not the power-button.
|
||||
// This is only executed when ret-to-menu was triggered via the home-button, not the power-button.
|
||||
if(aptGetStatusPower() == 0)
|
||||
{
|
||||
aptOpenSession();
|
||||
APT_AppletUtility(NULL, NULL, 0x6, 0x4, (u8*)&tmp0, 0x1, (u8*)&tmp1);
|
||||
aptCloseSession();
|
||||
}
|
||||
|
||||
// Prepare for return to menu
|
||||
aptOpenSession();
|
||||
APT_PrepareToJumpToHomeMenu(NULL); //prepare for return to menu
|
||||
APT_PrepareToJumpToHomeMenu(NULL);
|
||||
aptCloseSession();
|
||||
|
||||
// Set status to SUSPENDED.
|
||||
svcClearEvent(aptStatusEvent);
|
||||
aptSetStatus(APP_SUSPENDED);
|
||||
|
||||
// Save Vram
|
||||
GSPGPU_SaveVramSysArea(NULL);
|
||||
|
||||
// Capture screen.
|
||||
memset(tmp_params, 0, 0x20);
|
||||
memset(ns_capinfo, 0, 0x20);
|
||||
|
||||
@ -145,6 +142,7 @@ void aptReturnToMenu()
|
||||
|
||||
menu_appid = aptGetMenuAppID();
|
||||
|
||||
// Send capture-screen info to menu.
|
||||
aptOpenSession();
|
||||
APT_SendParameter(NULL, currentAppId, menu_appid, 0x20, ns_capinfo, 0x0, 0x10);
|
||||
aptCloseSession();
|
||||
@ -153,17 +151,21 @@ void aptReturnToMenu()
|
||||
APT_SendCaptureBufferInfo(NULL, 0x20, ns_capinfo);
|
||||
aptCloseSession();
|
||||
|
||||
GSPGPU_ReleaseRight(NULL); //disable GSP module access
|
||||
// Release GSP module.
|
||||
GSPGPU_ReleaseRight(NULL);
|
||||
|
||||
// Jump to menu!
|
||||
aptOpenSession();
|
||||
APT_JumpToHomeMenu(NULL, 0x0, 0x0, 0x0); //jump !
|
||||
APT_JumpToHomeMenu(NULL, 0x0, 0x0, 0x0);
|
||||
aptCloseSession();
|
||||
|
||||
// Wait for return to application.
|
||||
aptOpenSession();
|
||||
APT_NotifyToWait(NULL, currentAppId);
|
||||
aptCloseSession();
|
||||
|
||||
if(aptGetStatusPower()==0)//This is only executed when ret-to-menu was triggered via the home-button, not the power-button.
|
||||
// This is only executed when ret-to-menu was triggered via the home-button, not the power-button.
|
||||
if(aptGetStatusPower() == 0)
|
||||
{
|
||||
tmp0 = 0;
|
||||
aptOpenSession();
|
||||
@ -174,100 +176,119 @@ void aptReturnToMenu()
|
||||
aptWaitStatusEvent();
|
||||
}
|
||||
|
||||
static void __handle_notification() {
|
||||
u8 type;
|
||||
|
||||
// Get notification type.
|
||||
aptOpenSession();
|
||||
APT_InquireNotification(NULL, currentAppId, &type);
|
||||
aptCloseSession();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case APTSIGNAL_HOMEBUTTON:
|
||||
case APTSIGNAL_POWERBUTTON:
|
||||
// The main thread should call aptReturnToMenu() when the status gets set to this.
|
||||
if(aptGetStatus() == APP_RUNNING)
|
||||
{
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(NULL, currentAppId, 0x0);
|
||||
aptCloseSession();
|
||||
|
||||
if(type == APTSIGNAL_HOMEBUTTON) aptSetStatusPower(0);
|
||||
if(type == APTSIGNAL_POWERBUTTON) aptSetStatusPower(1);
|
||||
aptSetStatus(APP_SUSPENDING);
|
||||
}
|
||||
break;
|
||||
|
||||
case APTSIGNAL_PREPARESLEEP:
|
||||
// Reply to sleep-request.
|
||||
aptStatusBeforeSleep = aptGetStatus();
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(NULL, currentAppId, 0x1);
|
||||
aptCloseSession();
|
||||
|
||||
aptSetStatus(APP_PREPARE_SLEEPMODE);
|
||||
break;
|
||||
|
||||
case APTSIGNAL_ENTERSLEEP:
|
||||
if(aptGetStatus() == APP_PREPARE_SLEEPMODE)
|
||||
{
|
||||
// Report into sleep-mode.
|
||||
aptOpenSession();
|
||||
APT_ReplySleepNotificationComplete(NULL, currentAppId);
|
||||
aptCloseSession();
|
||||
aptSetStatus(APP_SLEEPMODE);
|
||||
}
|
||||
break;
|
||||
|
||||
// Leaving sleep-mode.
|
||||
case APTSIGNAL_WAKEUP:
|
||||
if(aptGetStatus() == APP_SLEEPMODE)
|
||||
{
|
||||
if(aptStatusBeforeSleep == APP_RUNNING)GSPGPU_SetLcdForceBlack(NULL, 0);
|
||||
|
||||
// Restore old aptStatus.
|
||||
aptSetStatus(aptStatusBeforeSleep);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bool __handle_incoming_parameter() {
|
||||
u8 type;
|
||||
|
||||
aptOpenSession();
|
||||
APT_ReceiveParameter(NULL, currentAppId, 0x1000, aptParameters, NULL, &type);
|
||||
aptCloseSession();
|
||||
|
||||
switch(type)
|
||||
{
|
||||
case 0x1: // Application just started.
|
||||
return true;
|
||||
|
||||
case 0xB: // Just returned from menu.
|
||||
GSPGPU_AcquireRight(NULL, 0x0);
|
||||
GSPGPU_RestoreVramSysArea(NULL);
|
||||
aptAppletUtility_Exit_RetToApp();
|
||||
aptSetStatus(APP_RUNNING);
|
||||
return true;
|
||||
|
||||
case 0xC: // Exiting application.
|
||||
aptSetStatus(APP_EXITING);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void aptEventHandler(u32 arg)
|
||||
{
|
||||
bool runThread=true;
|
||||
bool runThread = true;
|
||||
|
||||
while(runThread)
|
||||
{
|
||||
s32 syncedID=0x0;
|
||||
s32 syncedID = 0;
|
||||
svcWaitSynchronizationN(&syncedID, aptEvents, 2, 0, U64_MAX);
|
||||
svcClearEvent(aptEvents[syncedID]);
|
||||
|
||||
switch(syncedID)
|
||||
{
|
||||
case 0x0: //event 0 means we got a signal from NS (home button, power button etc)
|
||||
{
|
||||
u8 signalType;
|
||||
|
||||
aptOpenSession();
|
||||
APT_InquireNotification(NULL, currentAppId, &signalType); //check signal type
|
||||
aptCloseSession();
|
||||
|
||||
switch(signalType)
|
||||
{
|
||||
case APTSIGNAL_HOMEBUTTON:
|
||||
case APTSIGNAL_POWERBUTTON:
|
||||
if(aptGetStatus()==APP_RUNNING)
|
||||
{
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(NULL, currentAppId, 0x0);
|
||||
aptCloseSession();
|
||||
|
||||
if(signalType==0x1)aptSetStatusPower(0);
|
||||
if(signalType==0x8)aptSetStatusPower(1);
|
||||
aptSetStatus(APP_SUSPENDING);//The main thread should call aptReturnToMenu() when the status gets set to this.
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case APTSIGNAL_PREPARESLEEP:
|
||||
aptStatus_beforesleepmode = aptGetStatus();
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(NULL, currentAppId, 0x1);
|
||||
aptCloseSession();
|
||||
aptSetStatus(APP_PREPARE_SLEEPMODE);
|
||||
break;
|
||||
|
||||
case APTSIGNAL_ENTERSLEEP:
|
||||
if(aptGetStatus()==APP_PREPARE_SLEEPMODE)
|
||||
{
|
||||
aptOpenSession();
|
||||
APT_ReplySleepNotificationComplete(NULL, currentAppId);
|
||||
aptCloseSession();
|
||||
aptSetStatus(APP_SLEEPMODE);
|
||||
}
|
||||
break;
|
||||
|
||||
case APTSIGNAL_WAKEUP: // Leaving sleep-mode.
|
||||
if(aptGetStatus()==APP_SLEEPMODE)
|
||||
{
|
||||
if(aptStatus_beforesleepmode == APP_RUNNING)GSPGPU_SetLcdForceBlack(NULL, 0);
|
||||
aptSetStatus(aptStatus_beforesleepmode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Event 0 means we got a signal from NS (home button, power button etc).
|
||||
case 0x0:
|
||||
__handle_notification();
|
||||
break;
|
||||
case 0x1: //event 1 means app just started, we're returning to app, exiting app etc.
|
||||
{
|
||||
u8 signalType;
|
||||
aptOpenSession();
|
||||
APT_ReceiveParameter(NULL, currentAppId, 0x1000, aptParameters, NULL, &signalType);
|
||||
aptCloseSession();
|
||||
|
||||
switch(signalType)
|
||||
{
|
||||
case 0x1: //application just started
|
||||
break;
|
||||
case 0xB: //just returned from menu
|
||||
GSPGPU_AcquireRight(NULL, 0x0);
|
||||
GSPGPU_RestoreVramSysArea(NULL);
|
||||
aptAppletUtility_Exit_RetToApp();
|
||||
aptSetStatus(APP_RUNNING);
|
||||
break;
|
||||
case 0xC: //exiting application
|
||||
runThread=false;
|
||||
aptSetStatus(APP_EXITING); //app exit signal
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Event 1 means we got an incoming parameter.
|
||||
case 0x1:
|
||||
runThread = __handle_incoming_parameter();
|
||||
break;
|
||||
case 0x2: //event 2 means we should exit the thread (event will be added later)
|
||||
runThread=false;
|
||||
// Event 2 means we should exit the thread (event will be added later).
|
||||
case 0x2:
|
||||
runThread = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
svcExitThread();
|
||||
}
|
||||
|
||||
@ -275,12 +296,12 @@ Result aptInit(NS_APPID appID)
|
||||
{
|
||||
Result ret=0;
|
||||
|
||||
//initialize APT stuff, escape load screen
|
||||
// Initialize APT stuff, escape load screen.
|
||||
srvGetServiceHandle(&aptuHandle, "APT:U");
|
||||
if((ret=APT_GetLockHandle(&aptuHandle, 0x0, &aptLockHandle)))return ret;
|
||||
svcCloseHandle(aptuHandle);
|
||||
|
||||
currentAppId=appID;
|
||||
currentAppId = appID;
|
||||
|
||||
aptOpenSession();
|
||||
if((ret=APT_Initialize(NULL, currentAppId, &aptEvents[0], &aptEvents[1])))return ret;
|
||||
@ -295,7 +316,6 @@ Result aptInit(NS_APPID appID)
|
||||
aptCloseSession();
|
||||
|
||||
svcCreateEvent(&aptStatusEvent, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -303,7 +323,8 @@ void aptExit()
|
||||
{
|
||||
aptAppletUtility_Exit_RetToApp();
|
||||
|
||||
if(aptGetStatusPower()==1)//This is only executed when application-termination was triggered via the home-menu power-off screen.
|
||||
// This is only executed when application-termination was triggered via the home-menu power-off screen.
|
||||
if(aptGetStatusPower() == 1)
|
||||
{
|
||||
aptOpenSession();
|
||||
APT_ReplySleepQuery(NULL, currentAppId, 0x0);
|
||||
@ -319,7 +340,7 @@ void aptExit()
|
||||
aptCloseSession();
|
||||
|
||||
svcCloseHandle(aptStatusMutex);
|
||||
// svcCloseHandle(aptLockHandle);
|
||||
//svcCloseHandle(aptLockHandle);
|
||||
svcCloseHandle(aptStatusEvent);
|
||||
}
|
||||
|
||||
@ -371,15 +392,16 @@ void aptSetupEventHandler()
|
||||
|
||||
aptSetStatus(APP_RUNNING);
|
||||
|
||||
//create thread for stuff handling APT events
|
||||
svcCreateThread(&aptEventHandlerThread, aptEventHandler, 0x0, (u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
|
||||
// Create thread for stuff handling APT events.
|
||||
svcCreateThread(&aptEventHandlerThread, aptEventHandler, 0x0,
|
||||
(u32*)(&aptEventHandlerStack[APT_HANDLER_STACKSIZE/8]), 0x31, 0xfffffffe);
|
||||
}
|
||||
|
||||
APP_STATUS aptGetStatus()
|
||||
{
|
||||
APP_STATUS ret;
|
||||
svcWaitSynchronization(aptStatusMutex, U64_MAX);
|
||||
ret=aptStatus;
|
||||
ret = aptStatus;
|
||||
svcReleaseMutex(aptStatusMutex);
|
||||
return ret;
|
||||
}
|
||||
@ -393,10 +415,10 @@ void aptSetStatus(APP_STATUS status)
|
||||
prevstatus = status;
|
||||
aptStatus = status;
|
||||
|
||||
if(prevstatus!=APP_NOTINITIALIZED)
|
||||
if(prevstatus != APP_NOTINITIALIZED)
|
||||
{
|
||||
if(status==APP_RUNNING)svcSignalEvent(aptStatusEvent);
|
||||
if(status==APP_EXITING)svcSignalEvent(aptStatusEvent);
|
||||
if(status == APP_RUNNING || status == APP_EXITING)
|
||||
svcSignalEvent(aptStatusEvent);
|
||||
}
|
||||
|
||||
svcReleaseMutex(aptStatusMutex);
|
||||
@ -406,7 +428,7 @@ u32 aptGetStatusPower()
|
||||
{
|
||||
u32 ret;
|
||||
svcWaitSynchronization(aptStatusMutex, U64_MAX);
|
||||
ret=aptStatusPower;
|
||||
ret = aptStatusPower;
|
||||
svcReleaseMutex(aptStatusMutex);
|
||||
return ret;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,7 @@
|
||||
/*
|
||||
gsp.c _ Gpu/lcd stuff.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <3ds/types.h>
|
||||
@ -18,6 +22,7 @@ static vu8* gspEventData;
|
||||
|
||||
static void gspEventThreadMain(u32 arg);
|
||||
|
||||
|
||||
Result gspInit()
|
||||
{
|
||||
return srvGetServiceHandle(&gspGpuHandle, "gsp::Gpu");
|
||||
@ -348,7 +353,7 @@ Result GSPGPU_RestoreVramSysArea(Handle* handle)
|
||||
//essentially : get commandIndex and totalCommands, calculate offset of new command, copy command and update totalCommands
|
||||
//use LDREX/STREX because this data may also be accessed by the GSP module and we don't want to break stuff
|
||||
//(mostly, we could overwrite the buffer header with wrong data and make the GSP module reexecute old commands)
|
||||
Result GSPGPU_submitGxCommand(u32* sharedGspCmdBuf, u32 gxCommand[0x8], Handle* handle)
|
||||
Result GSPGPU_SubmitGxCommand(u32* sharedGspCmdBuf, u32 gxCommand[0x8], Handle* handle)
|
||||
{
|
||||
if(!sharedGspCmdBuf || !gxCommand)return -1;
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
/*
|
||||
gx.c _ Sending GPU requests via GSP shared memory.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/GSP.h>
|
||||
@ -13,7 +17,7 @@ Result GX_RequestDma(u32* gxbuf, u32* src, u32* dst, u32 length)
|
||||
gxCommand[3]=length; //size
|
||||
gxCommand[4]=gxCommand[5]=gxCommand[6]=gxCommand[7]=0x0;
|
||||
|
||||
return GSPGPU_submitGxCommand(gxbuf, gxCommand, NULL);
|
||||
return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
|
||||
}
|
||||
|
||||
Result GX_SetCommandList_Last(u32* gxbuf, u32* buf0a, u32 buf0s, u8 flags)
|
||||
@ -26,7 +30,7 @@ Result GX_SetCommandList_Last(u32* gxbuf, u32* buf0a, u32 buf0s, u8 flags)
|
||||
gxCommand[4]=gxCommand[5]=gxCommand[6]=0x0;
|
||||
gxCommand[7]=(flags>>1)&1; //when non-zero, call svcFlushProcessDataCache() with the specified buffer
|
||||
|
||||
return GSPGPU_submitGxCommand(gxbuf, gxCommand, NULL);
|
||||
return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
|
||||
}
|
||||
|
||||
Result GX_SetMemoryFill(u32* gxbuf, u32* buf0a, u32 buf0v, u32* buf0e, u16 width0, u32* buf1a, u32 buf1v, u32* buf1e, u16 width1)
|
||||
@ -42,7 +46,7 @@ Result GX_SetMemoryFill(u32* gxbuf, u32* buf0a, u32 buf0v, u32* buf0e, u16 width
|
||||
gxCommand[6]=(u32)buf1e; //buf1 end addr
|
||||
gxCommand[7]=(width0)|(width1<<16);
|
||||
|
||||
return GSPGPU_submitGxCommand(gxbuf, gxCommand, NULL);
|
||||
return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
|
||||
}
|
||||
|
||||
// Flags, for applications this is 0x1001000 for the main screen, and 0x1000 for the sub screen.
|
||||
@ -57,7 +61,7 @@ Result GX_SetDisplayTransfer(u32* gxbuf, u32* inadr, u32 indim, u32* outadr, u32
|
||||
gxCommand[5]=flags;
|
||||
gxCommand[6]=gxCommand[7]=0x0;
|
||||
|
||||
return GSPGPU_submitGxCommand(gxbuf, gxCommand, NULL);
|
||||
return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
|
||||
}
|
||||
|
||||
Result GX_SetTextureCopy(u32* gxbuf, u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags)
|
||||
@ -72,7 +76,7 @@ Result GX_SetTextureCopy(u32* gxbuf, u32* inadr, u32 indim, u32* outadr, u32 out
|
||||
gxCommand[6]=flags;
|
||||
gxCommand[7]=0x0;
|
||||
|
||||
return GSPGPU_submitGxCommand(gxbuf, gxCommand, NULL);
|
||||
return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
|
||||
}
|
||||
|
||||
Result GX_SetCommandList_First(u32* gxbuf, u32* buf0a, u32 buf0s, u32* buf1a, u32 buf1s, u32* buf2a, u32 buf2s)
|
||||
@ -87,5 +91,5 @@ Result GX_SetCommandList_First(u32* gxbuf, u32* buf0a, u32 buf0s, u32* buf1a, u3
|
||||
gxCommand[6]=(u32)buf2s; //buf2 size
|
||||
gxCommand[7]=0x0;
|
||||
|
||||
return GSPGPU_submitGxCommand(gxbuf, gxCommand, NULL);
|
||||
return GSPGPU_SubmitGxCommand(gxbuf, gxCommand, NULL);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user