mirror of
https://github.com/Gericom/FastVideoDSPlayer.git
synced 2025-06-18 10:35: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 "adpcm.h"
|
||||
#include "irqWait.h"
|
||||
#include "../../common/twlwram.h"
|
||||
#include "fvPlayer7.h"
|
||||
|
||||
#define FV_AUDIO_START_OFFSET 12
|
||||
@ -324,8 +325,13 @@ static void handleFifo(u32 value)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,8 +114,14 @@ int main(void)
|
||||
|
||||
if (isDSiMode())
|
||||
{
|
||||
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);
|
||||
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_C, 0x03140000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||
}
|
||||
|
||||
// switch to 47kHz output
|
||||
REG_SNDEXTCNT = 0;
|
||||
|
@ -199,10 +199,10 @@ static u32* makeMbRenderDl(u32* displayList, int height, u32 texParam)
|
||||
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));
|
||||
if (isDSiMode())
|
||||
if (isDSiMode() && twr_isUnlocked() && useWram)
|
||||
player->dataBuffer = (u8*)twr_getBlockAddress(TWR_WRAM_BLOCK_B);
|
||||
else
|
||||
player->dataBuffer = memalign(32, FV_PLAYER_DATA_BUFFER_SIZE * FV_PLAYER_DATA_BUFFER_COUNT);
|
||||
|
@ -46,7 +46,7 @@ typedef struct
|
||||
extern "C" {
|
||||
#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_startPlayer(fv_player_t* player);
|
||||
void fv_updatePlayer(fv_player_t* player);
|
||||
|
@ -20,12 +20,14 @@ int main(int argc, char** argv)
|
||||
|
||||
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_B, 0x03100000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||
twr_setBlockMapping(TWR_WRAM_BLOCK_C, 0x03140000, 0x40000, TWR_WRAM_BLOCK_IMAGE_SIZE_256K);
|
||||
mpu_enableTwlWramCache();
|
||||
canUseWram = true;
|
||||
}
|
||||
|
||||
fifoSetValue32Handler(FIFO_USER_01, NULL, NULL);
|
||||
@ -33,7 +35,10 @@ int main(int argc, char** argv)
|
||||
// handshake
|
||||
fifoSendValue32(FIFO_USER_01, IPC_CMD_PACK(IPC_CMD_HANDSHAKE, 0));
|
||||
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())
|
||||
{
|
||||
@ -72,7 +77,7 @@ int main(int argc, char** argv)
|
||||
filePath = argv[1];
|
||||
|
||||
// iprintf("Playing %s\n", filePath);
|
||||
if (fv_initPlayer(&sPlayer, filePath))
|
||||
if (fv_initPlayer(&sPlayer, filePath, canUseWram))
|
||||
{
|
||||
sPlayerController = new PlayerController(&sPlayer);
|
||||
sPlayerController->Initialize();
|
||||
|
@ -93,6 +93,22 @@ void twr_mapWramCSlot(int slot, TWRWramCSlotMaster master, int offset, bool enab
|
||||
|
||||
#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
|
||||
}
|
||||
#endif
|
@ -66,3 +66,14 @@ void twr_mapWramCSlot(int slot, TWRWramCSlotMaster master, int offset, bool enab
|
||||
}
|
||||
|
||||
#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