mirror of
https://github.com/Gericom/FastVideoDSPlayer.git
synced 2025-06-19 11:05:34 -04:00
Added check if twl wram is unlocked
This commit is contained in:
parent
d0ea2b603e
commit
15d28caed1
@ -5,6 +5,7 @@
|
|||||||
#include "fat.h"
|
#include "fat.h"
|
||||||
#include "adpcm.h"
|
#include "adpcm.h"
|
||||||
#include "irqWait.h"
|
#include "irqWait.h"
|
||||||
|
#include "../../common/twlwram.h"
|
||||||
#include "fvPlayer7.h"
|
#include "fvPlayer7.h"
|
||||||
|
|
||||||
#define FV_AUDIO_START_OFFSET 12
|
#define FV_AUDIO_START_OFFSET 12
|
||||||
@ -324,9 +325,14 @@ static void handleFifo(u32 value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case IPC_CMD_HANDSHAKE:
|
case IPC_CMD_HANDSHAKE:
|
||||||
fifoSendValue32(FIFO_USER_01, IPC_CMD_PACK(IPC_CMD_HANDSHAKE, 0));
|
{
|
||||||
|
bool canUseWram = false;
|
||||||
|
if (isDSiMode())
|
||||||
|
canUseWram = twr_isUnlocked();
|
||||||
|
fifoSendValue32(FIFO_USER_01, IPC_CMD_PACK(IPC_CMD_HANDSHAKE, canUseWram ? 1 : 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void fv_main(void)
|
void fv_main(void)
|
||||||
|
@ -113,9 +113,15 @@ int main(void)
|
|||||||
dmaFillWords(0, (void*)0x04000400, 0x100);
|
dmaFillWords(0, (void*)0x04000400, 0x100);
|
||||||
|
|
||||||
if (isDSiMode())
|
if (isDSiMode())
|
||||||
|
{
|
||||||
|
if (twr_isUnlockable())
|
||||||
|
twr_unlockAll();
|
||||||
|
|
||||||
|
if (twr_isUnlocked())
|
||||||
{
|
{
|
||||||
twr_setBlockMapping(TWR_WRAM_BLOCK_B, 0x03100000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
twr_setBlockMapping(TWR_WRAM_BLOCK_B, 0x03100000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||||
twr_setBlockMapping(TWR_WRAM_BLOCK_C, 0x03140000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
twr_setBlockMapping(TWR_WRAM_BLOCK_C, 0x03140000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||||
|
}
|
||||||
|
|
||||||
// switch to 47kHz output
|
// switch to 47kHz output
|
||||||
REG_SNDEXTCNT = 0;
|
REG_SNDEXTCNT = 0;
|
||||||
|
@ -199,10 +199,10 @@ static u32* makeMbRenderDl(u32* displayList, int height, u32 texParam)
|
|||||||
return displayList;
|
return displayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fv_initPlayer(fv_player_t* player, const char* filePath)
|
bool fv_initPlayer(fv_player_t* player, const char* filePath, bool useWram)
|
||||||
{
|
{
|
||||||
memset(player, 0, sizeof(fv_player_t));
|
memset(player, 0, sizeof(fv_player_t));
|
||||||
if (isDSiMode())
|
if (isDSiMode() && twr_isUnlocked() && useWram)
|
||||||
player->dataBuffer = (u8*)twr_getBlockAddress(TWR_WRAM_BLOCK_B);
|
player->dataBuffer = (u8*)twr_getBlockAddress(TWR_WRAM_BLOCK_B);
|
||||||
else
|
else
|
||||||
player->dataBuffer = memalign(32, FV_PLAYER_DATA_BUFFER_SIZE * FV_PLAYER_DATA_BUFFER_COUNT);
|
player->dataBuffer = memalign(32, FV_PLAYER_DATA_BUFFER_SIZE * FV_PLAYER_DATA_BUFFER_COUNT);
|
||||||
|
@ -46,7 +46,7 @@ typedef struct
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool fv_initPlayer(fv_player_t* player, const char* filePath);
|
bool fv_initPlayer(fv_player_t* player, const char* filePath, bool useWram);
|
||||||
void fv_destroyPlayer(fv_player_t* player);
|
void fv_destroyPlayer(fv_player_t* player);
|
||||||
void fv_startPlayer(fv_player_t* player);
|
void fv_startPlayer(fv_player_t* player);
|
||||||
void fv_updatePlayer(fv_player_t* player);
|
void fv_updatePlayer(fv_player_t* player);
|
||||||
|
@ -20,12 +20,14 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
mpu_enableVramCache();
|
mpu_enableVramCache();
|
||||||
|
|
||||||
if (isDSiMode())
|
bool canUseWram = false;
|
||||||
|
if (isDSiMode() && twr_isUnlocked())
|
||||||
{
|
{
|
||||||
twr_setBlockMapping(TWR_WRAM_BLOCK_A, 0x03000000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
twr_setBlockMapping(TWR_WRAM_BLOCK_A, 0x03000000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||||
twr_setBlockMapping(TWR_WRAM_BLOCK_B, 0x03100000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
twr_setBlockMapping(TWR_WRAM_BLOCK_B, 0x03100000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||||
twr_setBlockMapping(TWR_WRAM_BLOCK_C, 0x03140000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
twr_setBlockMapping(TWR_WRAM_BLOCK_C, 0x03140000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||||
mpu_enableTwlWramCache();
|
mpu_enableTwlWramCache();
|
||||||
|
canUseWram = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
fifoSetValue32Handler(FIFO_USER_01, NULL, NULL);
|
fifoSetValue32Handler(FIFO_USER_01, NULL, NULL);
|
||||||
@ -33,7 +35,10 @@ int main(int argc, char** argv)
|
|||||||
// handshake
|
// handshake
|
||||||
fifoSendValue32(FIFO_USER_01, IPC_CMD_PACK(IPC_CMD_HANDSHAKE, 0));
|
fifoSendValue32(FIFO_USER_01, IPC_CMD_PACK(IPC_CMD_HANDSHAKE, 0));
|
||||||
fifoWaitValue32(FIFO_USER_01);
|
fifoWaitValue32(FIFO_USER_01);
|
||||||
fifoGetValue32(FIFO_USER_01);
|
u32 handShake = fifoGetValue32(FIFO_USER_01);
|
||||||
|
|
||||||
|
if (canUseWram && (handShake & IPC_CMD_ARG_MASK) == 0)
|
||||||
|
canUseWram = false;
|
||||||
|
|
||||||
if (!isDSiMode())
|
if (!isDSiMode())
|
||||||
{
|
{
|
||||||
@ -72,7 +77,7 @@ int main(int argc, char** argv)
|
|||||||
filePath = argv[1];
|
filePath = argv[1];
|
||||||
|
|
||||||
// iprintf("Playing %s\n", filePath);
|
// iprintf("Playing %s\n", filePath);
|
||||||
if (fv_initPlayer(&sPlayer, filePath))
|
if (fv_initPlayer(&sPlayer, filePath, canUseWram))
|
||||||
{
|
{
|
||||||
sPlayerController = new PlayerController(&sPlayer);
|
sPlayerController = new PlayerController(&sPlayer);
|
||||||
sPlayerController->Initialize();
|
sPlayerController->Initialize();
|
||||||
|
@ -93,6 +93,22 @@ void twr_mapWramCSlot(int slot, TWRWramCSlotMaster master, int offset, bool enab
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool twr_isUnlocked(void);
|
||||||
|
|
||||||
|
#ifdef ARM7
|
||||||
|
|
||||||
|
static inline bool twr_isUnlockable(void)
|
||||||
|
{
|
||||||
|
return (REG_SCFG_EXT & 0x80000000) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void twr_unlockAll(void)
|
||||||
|
{
|
||||||
|
REG_MBK9 = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -66,3 +66,14 @@ void twr_mapWramCSlot(int slot, TWRWramCSlotMaster master, int offset, bool enab
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool twr_isUnlocked(void)
|
||||||
|
{
|
||||||
|
if ((REG_SCFG_EXT & 0x80000000) == 0)
|
||||||
|
return false; // SCFG and MBK registers are permanently locked
|
||||||
|
|
||||||
|
if ((REG_MBK9 & 0xFFFF0F) != 0)
|
||||||
|
return false; // One or more MBK registers are locked
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user