mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 13:54:09 +08:00
为上屏无缩放添加边框
This commit is contained in:
parent
4d9d006bf7
commit
15c1959fed
@ -26,4 +26,4 @@ extern const u8 gbaGpuList2[448];
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void patchGbaGpuCmdList(u8 scaleType);
|
void patchGbaGpuCmdList(u8 scaleType, bool border);
|
||||||
|
@ -862,7 +862,7 @@ static void setQuadRect( u16 left, u16 right, u16 top, u16 bottom )
|
|||||||
xyToWzyx(right, top, (u32*)&gbaGpuList2[RT_INDEX2]);
|
xyToWzyx(right, top, (u32*)&gbaGpuList2[RT_INDEX2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void patchGbaGpuCmdList(u8 scaleType)
|
void patchGbaGpuCmdList(u8 scaleType, bool border)
|
||||||
{
|
{
|
||||||
// 73 75 77 79 | 19 21 23 25 coord
|
// 73 75 77 79 | 19 21 23 25 coord
|
||||||
// 74 76 78 80 | 20 22 24 26 texuv
|
// 74 76 78 80 | 20 22 24 26 texuv
|
||||||
@ -883,7 +883,8 @@ void patchGbaGpuCmdList(u8 scaleType)
|
|||||||
gbaGpuList2[360] = 0x40u; // 25
|
gbaGpuList2[360] = 0x40u; // 25
|
||||||
gbaGpuList2[365] = 0x40u; // 25
|
gbaGpuList2[365] = 0x40u; // 25
|
||||||
*/
|
*/
|
||||||
setQuadRect( 0, 240, 200, 40 );
|
if( border ) setQuadRect( 80, 320, 200, 40 );
|
||||||
|
else setQuadRect( 0, 240, 200, 40 );
|
||||||
|
|
||||||
// 以下8行代码修正纹理坐标
|
// 以下8行代码修正纹理坐标
|
||||||
gbaGpuInitList[968] = 0x60u; // 74
|
gbaGpuInitList[968] = 0x60u; // 74
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "fs.h"
|
#include "fs.h"
|
||||||
#include "fsutil.h"
|
#include "fsutil.h"
|
||||||
|
#include "drivers/gfx.h"
|
||||||
|
#include "arm11/drivers/mcu.h"
|
||||||
// @MERGE 231006 START
|
// @MERGE 231006 START
|
||||||
#include "drivers/lgy11.h"
|
#include "drivers/lgy11.h"
|
||||||
// @MERGE 231006 END
|
// @MERGE 231006 END
|
||||||
@ -12,6 +14,7 @@ static key_remix_t *frozen_start, *frozen_end;
|
|||||||
static phykey_t prev_phykey = 0;
|
static phykey_t prev_phykey = 0;
|
||||||
static conkey_t prev_conkey = 0;
|
static conkey_t prev_conkey = 0;
|
||||||
static conkey_t blind_conkey;
|
static conkey_t blind_conkey;
|
||||||
|
static u8 val_3dslider;
|
||||||
static u16 flags_holding = 0;
|
static u16 flags_holding = 0;
|
||||||
|
|
||||||
#define DIR_SEPARATOR "/"
|
#define DIR_SEPARATOR "/"
|
||||||
@ -30,6 +33,19 @@ uint16_t keyremix_cheatkey()
|
|||||||
return DEFAULT_CHEATKEY;
|
return DEFAULT_CHEATKEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void update_brightness()
|
||||||
|
{
|
||||||
|
u16 backlightNow;
|
||||||
|
u16 val = (u16)MCU_get3dSliderPosition();
|
||||||
|
if( val != val_3dslider )
|
||||||
|
{
|
||||||
|
val_3dslider = val;
|
||||||
|
backlightNow = 48000 * val / 256;
|
||||||
|
backlightNow = (backlightNow%50) > 50 ? 101+backlightNow/100 : 100+backlightNow/100;
|
||||||
|
GFX_setBrightness(backlightNow, backlightNow);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void keyremix_freeze()
|
void keyremix_freeze()
|
||||||
{
|
{
|
||||||
// 空白选项忽略,填充blind_conkey,金手指放首位,REMAP紧跟金手指,HOLD在后面
|
// 空白选项忽略,填充blind_conkey,金手指放首位,REMAP紧跟金手指,HOLD在后面
|
||||||
@ -87,6 +103,8 @@ void keyremix_freeze()
|
|||||||
memcpy( g_keyremixConfig, temp, sizeof(g_keyremixConfig) );
|
memcpy( g_keyremixConfig, temp, sizeof(g_keyremixConfig) );
|
||||||
frozen_start = &g_keyremixConfig[has_cheat];
|
frozen_start = &g_keyremixConfig[has_cheat];
|
||||||
frozen_end = &g_keyremixConfig[has_cheat+valid_count];
|
frozen_end = &g_keyremixConfig[has_cheat+valid_count];
|
||||||
|
|
||||||
|
val_3dslider = MCU_get3dSliderPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
void keyremix_update( uint16_t active_cheatkey )
|
void keyremix_update( uint16_t active_cheatkey )
|
||||||
@ -164,13 +182,15 @@ void keyremix_update( uint16_t active_cheatkey )
|
|||||||
}
|
}
|
||||||
prev_phykey = now;
|
prev_phykey = now;
|
||||||
prev_conkey = cur;
|
prev_conkey = cur;
|
||||||
|
|
||||||
|
update_brightness();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* keyremix_load( const char *file )
|
const char* keyremix_load( const char *file )
|
||||||
{
|
{
|
||||||
char output[512];
|
char output[512];
|
||||||
int len = strlen( file ) + strlen(OUTPUT_DIR);
|
int len = strlen( file ) + strlen(OUTPUT_DIR);
|
||||||
if( len+1 > 512 ) return "文件名太长,无法保存";
|
if( len+1 > 512 ) return "文件名太长,无法打开";
|
||||||
strcpy( output, OUTPUT_DIR );
|
strcpy( output, OUTPUT_DIR );
|
||||||
strcpy( &output[strlen(OUTPUT_DIR)], file );
|
strcpy( &output[strlen(OUTPUT_DIR)], file );
|
||||||
output[len] = '\0';
|
output[len] = '\0';
|
||||||
|
@ -109,6 +109,7 @@ static OafConfig g_oafConfig =
|
|||||||
};
|
};
|
||||||
static KHandle g_frameReadyEvent = 0;
|
static KHandle g_frameReadyEvent = 0;
|
||||||
static u16 detect_cheatKey = 0;
|
static u16 detect_cheatKey = 0;
|
||||||
|
static bool use_border = false;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
u8 dump_patched_rom = 0;
|
u8 dump_patched_rom = 0;
|
||||||
@ -710,12 +711,17 @@ static void gbaGfxHandler(void *args)
|
|||||||
// 地址0x18200000保存的是512x512大小的GBA的240x160贴图数据(序列:→↙→)
|
// 地址0x18200000保存的是512x512大小的GBA的240x160贴图数据(序列:→↙→)
|
||||||
// 所以GPU做的事情就是将18200000的数据逆时针旋转90°
|
// 所以GPU做的事情就是将18200000的数据逆时针旋转90°
|
||||||
if( g_oafConfig.scaler == 0 ) // 上屏无缩放
|
if( g_oafConfig.scaler == 0 ) // 上屏无缩放
|
||||||
|
{
|
||||||
|
if ( !use_border )
|
||||||
{
|
{
|
||||||
int base_offset = 57600; // 3ds高240, gba高160,居中需要平移40个像素,rgb888每个像素3字节,共120字节
|
int base_offset = 57600; // 3ds高240, gba高160,居中需要平移40个像素,rgb888每个像素3字节,共120字节
|
||||||
// 但是,gpu的transfer engine只支持16字节对齐的地址。所以只能选择16和3的公约数,就是48,96,144,192,240
|
// 但是,gpu的transfer engine只支持16字节对齐的地址。所以只能选择16和3的公约数,就是48,96,144,192,240
|
||||||
GX_displayTransfer((u32*)(0x18180000), 240u<<16 | 240u,
|
GX_displayTransfer((u32*)(0x18180000), 240u<<16 | 240u,
|
||||||
GFX_getFramebuffer(SCREEN_TOP) + base_offset, 240u<<16 | 240u, 1u<<12 | 1u<<8);
|
GFX_getFramebuffer(SCREEN_TOP) + base_offset, 240u<<16 | 240u, 1u<<12 | 1u<<8);
|
||||||
}
|
}
|
||||||
|
else GX_displayTransfer((u32*)(0x18180000), 400u<<16 | 240u,
|
||||||
|
GFX_getFramebuffer(SCREEN_TOP), 400u<<16 | 240u, 1u<<12 | 1u<<8);
|
||||||
|
}
|
||||||
else if( g_oafConfig.scaler == 3 )//下屏无缩放
|
else if( g_oafConfig.scaler == 3 )//下屏无缩放
|
||||||
{
|
{
|
||||||
int base_offset = 28800;
|
int base_offset = 28800;
|
||||||
@ -1015,13 +1021,26 @@ Result oafInitAndRun(void)
|
|||||||
{
|
{
|
||||||
//LGYFB_init(frameReadyEvent, g_oafConfig.scaler); // 这里把GBA的输出转换成0x18200000处512x512大小的纹理
|
//LGYFB_init(frameReadyEvent, g_oafConfig.scaler); // 这里把GBA的输出转换成0x18200000处512x512大小的纹理
|
||||||
// @MERGE 231006 END
|
// @MERGE 231006 END
|
||||||
patchGbaGpuCmdList(g_oafConfig.scaler);
|
if(g_oafConfig.scaler == 0) // No borders for scaled modes.
|
||||||
if( g_oafConfig.scaler == 3u )
|
{
|
||||||
|
// Abuse currently invisible frame buffer as temporary buffer.
|
||||||
|
void *const borderBuf = GFX_getFramebuffer(SCREEN_TOP);
|
||||||
|
if(fsQuickRead("border.bgr", borderBuf, 400 * 240 * 3) == RES_OK)
|
||||||
|
{
|
||||||
|
// Copy border in swizzled form to GPU render buffer.
|
||||||
|
GX_displayTransfer(borderBuf, 400u<<16 | 240, (u32*)0x18180000, 400u<<16 | 240, 1u<<12 | 1u<<8 | 1u<<1);
|
||||||
|
GFX_waitForPPF();
|
||||||
|
use_border = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if( g_oafConfig.scaler == 3u )
|
||||||
{
|
{
|
||||||
memset(consoleGet()->frameBuffer, 0, 320*240*2);
|
memset(consoleGet()->frameBuffer, 0, 320*240*2);
|
||||||
GFX_setDoubleBuffering( SCREEN_BOT, true );
|
GFX_setDoubleBuffering( SCREEN_BOT, true );
|
||||||
GFX_setFramebufFmt(GFX_BGR8, GFX_BGR8);
|
GFX_setFramebufFmt(GFX_BGR8, GFX_BGR8);
|
||||||
}
|
}
|
||||||
|
patchGbaGpuCmdList(g_oafConfig.scaler, use_border);
|
||||||
|
// @MERGE 231006 END
|
||||||
}
|
}
|
||||||
createTask(0x800, 3, gbaGfxHandler, (void*)frameReadyEvent);
|
createTask(0x800, 3, gbaGfxHandler, (void*)frameReadyEvent);
|
||||||
g_frameReadyEvent = frameReadyEvent;
|
g_frameReadyEvent = frameReadyEvent;
|
||||||
@ -1029,9 +1048,7 @@ Result oafInitAndRun(void)
|
|||||||
// Adjust gamma table and sync LgyFb start with LCD VBlank.
|
// Adjust gamma table and sync LgyFb start with LCD VBlank.
|
||||||
adjustGammaTableForGba();
|
adjustGammaTableForGba();
|
||||||
GFX_waitForVBlank0();
|
GFX_waitForVBlank0();
|
||||||
// @MERGE 231006 START
|
|
||||||
LGY11_switchMode();
|
LGY11_switchMode();
|
||||||
// @MERGE 231006 END
|
|
||||||
}
|
}
|
||||||
} while(0);
|
} while(0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user