TwlIPL/build/libraries_sysmenu/sysmenu/ARM9/src/ninLogoFunc.c
yosiokat 6034261796 Nintendoロゴデータ処理の整理。
git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/trunk@192 b08762b0-b915-fc4b-9d8c-17b2551a87ff
2007-11-16 03:34:45 +00:00

196 lines
6.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*---------------------------------------------------------------------------*
Project: TwlIPL
File: ninLogoFunc.c
Copyright 2007 Nintendo. All rights reserved.
These coded instructions, statements, and computer programs contain
proprietary information of Nintendo of America Inc. and/or Nintendo
Company Ltd., and are protected by Federal copyright law. They may
not be disclosed to third parties or copied or duplicated in any form,
in whole or in part, without the prior written consent of Nintendo.
$Date:: $
$Rev$
$Author$
*---------------------------------------------------------------------------*/
#include <twl.h>
#include <sysmenu/sysmenu_lib/ARM9/sysmenu_api.h>
#include <sysmenu/memorymap.h>
// define data-----------------------------------------------------------
// extern data-----------------------------------------------------------
// function's prototype--------------------------------------------------
static void UnCompNintendoLogo2(u16 *pLogoData, u16 *pDst, u32 *pTemp );
static void SVC_DiffUnFilter16_16_2( u16 *pSrc, u16 *pDst );
static s32 MEMBm_InitFunc( const u8 *pDevice, void *pRAM, const void *pParam );
static s32 MEMBm_TerminateFunc( const u8 *pDevice );
static u8 MEMBm_ByteStreamFunc( const u8 *pDevice );
static u32 MEMBm_WordStreamFunc( const u8 *pDevice );
// global variable-------------------------------------------------------
// static variable-------------------------------------------------------
static MIUnpackBitsParam Nin_UnPackBitsParam2 = { (8 * 8 / 2) * ( 7 * 2 ),
1,
4, // ƒJƒ‰<C692>[bit<69>”(4=4bit=16<31>F, 8=8bit=256<35>F)
0,
0 };
// const data------------------------------------------------------------
static const u8 Nin_Char_Diff_Huff_Table2[]={
0x24,0xd4,0x00,0x00,
0x0f,0x40,0x00,0x00,0x00,0x01,0x81,0x82,0x82,0x83,0x0f,0x83,0x0c,0xc3,0x03,0x83,
0x01,0x83,0x04,0xc3,0x08,0x0e,0x02,0xc2,0x0d,0xc2,0x07,0x0b,0x06,0x0a,0x05,0x09,
};
const MIReadStreamCallbacks memb_ifp2={
MEMBm_InitFunc,
MEMBm_TerminateFunc,
MEMBm_ByteStreamFunc,
NULL,
MEMBm_WordStreamFunc,
};
// function's description--------------------------------------------
// Nintendoƒ<6F>ƒSƒ`ƒFƒbƒN <09>uƒŠƒ^<5E>[ƒ“<C692>@1:Nintendoƒ<6F>ƒS”Fޝ<C5BD>¬Œ÷<C592>@0<>¸”s<E2809D>v
BOOL SYSM_CheckNintendoLogo( u16 *pLogoData )
{
u16 *pLogoOrg = (u16 *)SYSROM9_NINLOGO_ADR; // ARM9̃VƒXƒeƒ€ROM̃<C38C>ƒSƒf<C692>[ƒ^ƃJ<C692>[ƒgƒŠƒbƒW“àÌàÌð”äŠr
u16 length = NINTENDO_LOGO_DATA_LENGTH >> 1;
while( length-- ) {
if( *pLogoOrg++ != *pLogoData++ ) {
return FALSE;
}
}
return TRUE;
}
// Nintendoƒ<6F>ƒSƒf<C692>[ƒ^Ì“WŠJƒ<C692>[ƒ`ƒ“<C692>iOBJ2Dƒ}ƒbƒvƒ<C692>[ƒhÅ“WŠJ<C5A0>j
// <20>¦tempBuffpÉÍ<E2809A>A0x700byte•K—vÅ·<E2809A>B
void SYSM_LoadNintendoLogo2D( u16 *pLogoData, u16 *pDst, int paletteColorIndex )
{
u32 work[ 0x100 / sizeof(u32) ];
u16 *pBuffer = SYSM_Alloc( 0x700 );
if( pBuffer == NULL ) {
OS_Panic( "memory allocation failed.\n" );
}
Nin_UnPackBitsParam2.destOffset = paletteColorIndex - 1;
UnCompNintendoLogo2( pLogoData, (u16 *)pBuffer, work );
MI_CpuCopy16( (u16 *)( (u32)pBuffer + 0 ), pDst + 0x0000 / sizeof(u16), 0x1a0 );
MI_CpuCopy16( (u16 *)( (u32)pBuffer + 0x1a0), pDst + 0x0400 / sizeof(u16), 0x1a0 );
SYSM_Free( pBuffer );
}
void SYSM_LoadNintendoLogo1D( u16 *pLogoData, u16 *pDst, int paletteColorIndex )
{
u32 work[ 0x100 / sizeof(u32) ];
u16 *pBuffer = SYSM_Alloc( 0x700 );
if( pBuffer == NULL ) {
OS_Panic( "memory allocation failed.\n" );
}
Nin_UnPackBitsParam2.destOffset = paletteColorIndex - 1;
UnCompNintendoLogo2( pLogoData, (u16 *)pBuffer, work );
MI_CpuCopy16( (u16 *)pBuffer, pDst, 0x340 );
SYSM_Free( pBuffer );
}
/* UnCompNintendoLogo2ƒ<32><C692>[ƒN“àó
<09>ƒ”zu<E28099>æ<EFBFBD>„ dstp(0x700) temp(0x100)
Nintendoƒ<6F>ƒS<C692>{ƒwƒbƒ_ 0x0c0
ƒnƒtƒ}ƒ““WŠJƒoƒbƒtƒ@ 0x200
ƒnƒtƒ}ƒ““WŠJŒã̃oƒbƒtƒ@ 0x0d0
diffŒã̃f<C692>[ƒ^ 0x0d0
UnpackBitsŒã̃f<C692>[ƒ^ 0x700
*/
//<2F>@Nintendoƒ<6F>ƒS“WŠJƒ<C692>[ƒ`ƒ“<C692>@(r0=ƒ<>ƒSˆ³<CB86>kƒf<C692>[ƒ^ r1=“WŠJ<C5A0>æƒAƒhƒŒƒX)
#include <twl/code16.h>
static asm void UnCompNintendoLogo2( u16 *pLogoData, u16 *pDst, u32 *pTemp )
{
push {r0-r2,r4, lr}
ldr r0, =Nin_Char_Diff_Huff_Table2
mov r1, r2 // r1 <- temp
mov r4, r1 // r4 <- temp
mov r2, #36
bl MIi_CpuCopy16 // Nintendoƒ<6F>ƒS̈³<CB86>kƒe<C692>[ƒuƒ•”•ªÌÝðƒRƒs<C692>[‚µ‚Ä‚­‚é
ldr r0, [sp, #0] // r0 <- NintendoLogoDatap
mov r2, #36
add r1, r4, r2 // r1 <- temp + 36
mov r2, #NINTENDO_LOGO_DATA_LENGTH
bl MIi_CpuCopy16 // NintendoLogoDatap©çNintendoƒ<6F>ƒSƒf<C692>[ƒ^{ÌðƒRƒs<C692>[‚µ‚Ä‚­‚é
mov r0, r4 // r0 <- temp
ldr r1, [sp, #4] // r1 <- dstp
mov r2, #1
lsl r2, r2, #8
add r2, r2, r1 // r2 <- dstp + 0x100
ldr r3, =memb_ifp2 // r3 <- memb_ifp2
bl SVC_UncompressHuffmanFromDevice // ƒnƒtƒ}ƒ““WŠJ
ldr r0, [sp, #4]
ldr r2, =0x0000d082
str r2, [r0,#0]
mov r1, r4 // temp
bl SVC_DiffUnFilter16_16_2 // Diff“WŠJ
mov r0, r4 // temp
ldr r1, [sp, #4] // dstp
ldr r2, =Nin_UnPackBitsParam2
bl SVC_UnpackBits // ƒrƒbƒg“WŠJ
pop {r0-r2,r4, pc}
}
// <20>·•ªƒtƒBƒƒ^“WŠJƒVƒXƒeƒ€ƒR<C692><C692>i16Bit<69>¨16Bit<69>j (r0=Srcp, r1=Destp)
static asm void SVC_DiffUnFilter16_16_2( u16 *pSrc, u16 *pDst )
{
swi 24
bx lr
}
#include <twl/codereset.h>
// ============================================================================
// ƒoƒCƒgƒAƒNƒZƒX‰Â”\ƒ<>ƒƒŠ—pƒAƒNƒZƒXƒ<C692>[ƒ`ƒ“ŒQ
// ============================================================================
static s32 MEMBm_InitFunc( const u8 *pDevice, void *pRAM, const void *pParam )
{
#pragma unused(pRAM)
if(pParam) return (s32)MEMBm_WordStreamFunc(pDevice);
else return 0;
}
static s32 MEMBm_TerminateFunc( const u8 *pDevice )
{
#pragma unused(pDevice)
return 0;
}
static u8 MEMBm_ByteStreamFunc( const u8 *pDevice )
{
return *pDevice;
}
static u32 MEMBm_WordStreamFunc( const u8 *pDevice )
{
return *(u32 *)pDevice;
}