mirror of
https://gitee.com/anod/open_agb_firm.git
synced 2025-05-06 05:44:11 +08:00
Compare commits
14 Commits
207506c1bb
...
b190f926ff
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b190f926ff | ||
![]() |
f33516ed94 | ||
![]() |
ad0163bbf4 | ||
![]() |
273463f658 | ||
![]() |
4be3f76c6d | ||
![]() |
ffa83e8ccc | ||
![]() |
f203e49d52 | ||
![]() |
1de88cdea7 | ||
![]() |
93dfe10f7a | ||
![]() |
3f2a8d9c16 | ||
![]() |
9844baa017 | ||
![]() |
9207c47e9b | ||
![]() |
bb24201a43 | ||
![]() |
4165fb6160 |
13
include/arm11/anopatch.h
Normal file
13
include/arm11/anopatch.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef __ANO_PATCH_H__
|
||||||
|
#define __ANO_PATCH_H__
|
||||||
|
|
||||||
|
#include "types.h"
|
||||||
|
|
||||||
|
#define INPUT(type) type
|
||||||
|
#define OUTPUT(type) type*
|
||||||
|
|
||||||
|
extern void setBrightness(
|
||||||
|
INPUT(u16) brightness
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif//__ANO_PATCH_H__
|
12
source/arm11/anopatch.c
Normal file
12
source/arm11/anopatch.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
// 因为原作者对libn3ds做出了许多大调整,可能去掉了一些
|
||||||
|
// 原来使用的代码,但我修改的内容又用到了,所以我就得
|
||||||
|
// 在这里自己实现一份
|
||||||
|
#include "arm11/anopatch.h"
|
||||||
|
#include "arm11/drivers/lcd.h"
|
||||||
|
|
||||||
|
void setBrightness(u16 brightness)
|
||||||
|
{
|
||||||
|
LcdRegs *const lcd = getLcdRegs();
|
||||||
|
lcd->abl0.bl_pwm_duty = brightness;
|
||||||
|
lcd->abl1.bl_pwm_duty = brightness;
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
// @MERGE 231006 START
|
// @MERGE 231006 START
|
||||||
#include "drivers/lgy11.h"
|
#include "drivers/lgy11.h"
|
||||||
// @MERGE 231006 END
|
// @MERGE 231006 END
|
||||||
|
#include "arm11/anopatch.h"
|
||||||
#include "arm11/keyremix.h"
|
#include "arm11/keyremix.h"
|
||||||
|
|
||||||
key_remix_t g_keyremixConfig[KEY_REMIX_LIMIT];
|
key_remix_t g_keyremixConfig[KEY_REMIX_LIMIT];
|
||||||
@ -43,7 +44,7 @@ static void update_brightness()
|
|||||||
val_3dslider = val;
|
val_3dslider = val;
|
||||||
backlightNow = 48000 * val / 256;
|
backlightNow = 48000 * val / 256;
|
||||||
backlightNow = (backlightNow%50) > 50 ? 101+backlightNow/100 : 100+backlightNow/100;
|
backlightNow = (backlightNow%50) > 50 ? 101+backlightNow/100 : 100+backlightNow/100;
|
||||||
GFX_setBrightness(backlightNow, backlightNow);
|
setBrightness(backlightNow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
// @MERGE 231006 START
|
// @MERGE 231006 START
|
||||||
#include "oaf_error_codes.h"
|
#include "oaf_error_codes.h"
|
||||||
// @MERGE 231006 END
|
// @MERGE 231006 END
|
||||||
|
#include "arm11/anopatch.h"
|
||||||
|
|
||||||
static void setBacklight(void)
|
static void setBacklight(void)
|
||||||
{
|
{
|
||||||
@ -45,10 +46,10 @@ static void setBacklight(void)
|
|||||||
backlightMin=20;
|
backlightMin=20;
|
||||||
}
|
}
|
||||||
|
|
||||||
const u16 backlight = oafGetBacklightConfig();
|
u16 backlight = oafGetBacklightConfig();
|
||||||
if (backlight > backlightMax) GFX_setBrightness(backlightMax, backlightMax);
|
if (backlight > backlightMax) backlight = backlightMax;
|
||||||
else if (backlight < backlightMin) GFX_setBrightness(backlightMin, backlightMin);
|
else if (backlight < backlightMin) backlight = backlightMin;
|
||||||
else GFX_setBrightness(backlight, backlight);
|
setBrightness( backlight );
|
||||||
}
|
}
|
||||||
|
|
||||||
Result fReadSize( FHandle file, void *buff, unsigned size, uint32_t *readout )
|
Result fReadSize( FHandle file, void *buff, unsigned size, uint32_t *readout )
|
||||||
@ -78,9 +79,9 @@ int main()
|
|||||||
Result res = fMount(FS_DRIVE_SDMC);
|
Result res = fMount(FS_DRIVE_SDMC);
|
||||||
bool direct_off = false;
|
bool direct_off = false;
|
||||||
if(res == RES_OK) res = oafParseConfigEarly();
|
if(res == RES_OK) res = oafParseConfigEarly();
|
||||||
GFX_init(GFX_BGR8, GFX_RGB565);
|
GFX_init(GFX_BGR8, GFX_BGR565, GFX_TOP_2D);
|
||||||
setBacklight();
|
setBacklight();
|
||||||
consoleInit(SCREEN_BOT, NULL);
|
consoleInit(GFX_LCD_BOT, NULL);
|
||||||
//CODEC_init();
|
//CODEC_init();
|
||||||
|
|
||||||
if(res == RES_OK && (res = oafInitAndRun(firm_path, &direct_off)) == RES_OK)
|
if(res == RES_OK && (res = oafInitAndRun(firm_path, &direct_off)) == RES_OK)
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
// @MERGE 231006 START
|
// @MERGE 231006 START
|
||||||
#include "drivers/lgy_common.h"
|
#include "drivers/lgy_common.h"
|
||||||
#include "drivers/lgy11.h"
|
#include "drivers/lgy11.h"
|
||||||
|
#include "drivers/gx.h"
|
||||||
|
#include "drivers/lgycap.h"
|
||||||
// @MERGE 231006 END
|
// @MERGE 231006 END
|
||||||
#include "arm11/drivers/lgyfb.h"
|
#include "arm11/drivers/lgyfb.h"
|
||||||
#include "arm11/console.h"
|
#include "arm11/console.h"
|
||||||
@ -646,6 +648,9 @@ static void adjustGammaTableForGba(void)
|
|||||||
const float lcdGamma = g_oafConfig.lcdGamma;
|
const float lcdGamma = g_oafConfig.lcdGamma;
|
||||||
const float contrast = g_oafConfig.contrast;
|
const float contrast = g_oafConfig.contrast;
|
||||||
const float brightness = g_oafConfig.brightness;
|
const float brightness = g_oafConfig.brightness;
|
||||||
|
|
||||||
|
vu32 *const REG_LCD_PDC0_GTBL_FIFO = &getGxRegs()->pdc0.color_lut_data;
|
||||||
|
vu32 *const REG_LCD_PDC1_GTBL_FIFO = &getGxRegs()->pdc1.color_lut_data;
|
||||||
for(u32 i = 0; i < 256; i++)
|
for(u32 i = 0; i < 256; i++)
|
||||||
{
|
{
|
||||||
// Credits for this algo go to Extrems.
|
// Credits for this algo go to Extrems.
|
||||||
@ -654,8 +659,8 @@ static void adjustGammaTableForGba(void)
|
|||||||
1.0f / lcdGamma) * 255.0f;
|
1.0f / lcdGamma) * 255.0f;
|
||||||
|
|
||||||
// Same adjustment for red/green/blue.
|
// Same adjustment for red/green/blue.
|
||||||
REG_LCD_PDC0_GTBL_FIFO = res<<16 | res<<8 | res;
|
*REG_LCD_PDC0_GTBL_FIFO = res<<16 | res<<8 | res;
|
||||||
REG_LCD_PDC1_GTBL_FIFO = res<<16 | res<<8 | res;
|
*REG_LCD_PDC1_GTBL_FIFO = res<<16 | res<<8 | res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,21 +732,21 @@ static void gbaGfxHandler(void *args)
|
|||||||
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_getBuffer(GFX_LCD_TOP, GFX_SIDE_LEFT) + base_offset, 240u<<16 | 240u, 1u<<12 | 1u<<8);
|
||||||
}
|
}
|
||||||
else GX_displayTransfer((u32*)(0x18180000), 400u<<16 | 240u,
|
else GX_displayTransfer((u32*)(0x18180000), 400u<<16 | 240u,
|
||||||
GFX_getFramebuffer(SCREEN_TOP), 400u<<16 | 240u, 1u<<12 | 1u<<8);
|
GFX_getBuffer(GFX_LCD_TOP, GFX_SIDE_LEFT), 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;
|
||||||
GX_displayTransfer((u32*)(0x18180000), 240u<<16 | 240u,
|
GX_displayTransfer((u32*)(0x18180000), 240u<<16 | 240u,
|
||||||
GFX_getFramebuffer(SCREEN_BOT) + base_offset, 240u<<16 | 240u, 1u<<12 | 1u<<8);
|
GFX_getBuffer(GFX_LCD_BOT, GFX_SIDE_LEFT) + base_offset, 240u<<16 | 240u, 1u<<12 | 1u<<8);
|
||||||
}
|
}
|
||||||
else GX_displayTransfer((u32*)(0x18180000 + 16*240*3), 368u<<16 | 240u,
|
else GX_displayTransfer((u32*)(0x18180000 + 16*240*3), 368u<<16 | 240u,
|
||||||
GFX_getFramebuffer(SCREEN_TOP) + 16*240*3, 368u<<16 | 240u, 1u<<12 | 1u<<8);
|
GFX_getBuffer(GFX_LCD_TOP, GFX_SIDE_LEFT) + 16*240*3, 368u<<16 | 240u, 1u<<12 | 1u<<8);
|
||||||
GFX_waitForPPF();
|
GFX_waitForPPF();
|
||||||
GFX_swapFramebufs();
|
GFX_swapBuffers();
|
||||||
|
|
||||||
//if(hidKeysDown() == (KEY_Y | KEY_SELECT)) dumpFrameTex();
|
//if(hidKeysDown() == (KEY_Y | KEY_SELECT)) dumpFrameTex();
|
||||||
// @MERGE 231006 START
|
// @MERGE 231006 START
|
||||||
@ -948,7 +953,7 @@ KHandle setupFrameCapture(const u8 scaler)
|
|||||||
0, 0, 0, 0, 0, 0, 0, 0
|
0, 0, 0, 0, 0, 0, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
ScalerCfg gbaCfg;
|
LgyCapCfg gbaCfg;
|
||||||
gbaCfg.w = (is240x160 ? 240 : 360);
|
gbaCfg.w = (is240x160 ? 240 : 360);
|
||||||
gbaCfg.h = (is240x160 ? 160 : 240);
|
gbaCfg.h = (is240x160 ? 160 : 240);
|
||||||
gbaCfg.vLen = 6;
|
gbaCfg.vLen = 6;
|
||||||
@ -972,7 +977,7 @@ KHandle setupFrameCapture(const u8 scaler)
|
|||||||
memcpy(gbaCfg.hMatrix, &matrix[6 * 8], 6 * 8 * 2);
|
memcpy(gbaCfg.hMatrix, &matrix[6 * 8], 6 * 8 * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return LGYFB_init(&gbaCfg);
|
return LGYCAP_init(LGYCAP_DEV_TOP, &gbaCfg);
|
||||||
}
|
}
|
||||||
// @MERGE 231006 END
|
// @MERGE 231006 END
|
||||||
|
|
||||||
@ -1045,7 +1050,7 @@ Result oafInitAndRun( char *firm_path, bool *direct_off )
|
|||||||
if(g_oafConfig.scaler == 0) // No borders for scaled modes.
|
if(g_oafConfig.scaler == 0) // No borders for scaled modes.
|
||||||
{
|
{
|
||||||
// Abuse currently invisible frame buffer as temporary buffer.
|
// Abuse currently invisible frame buffer as temporary buffer.
|
||||||
void *const borderBuf = GFX_getFramebuffer(SCREEN_TOP);
|
void *const borderBuf = GFX_getBuffer(GFX_LCD_TOP, GFX_SIDE_LEFT);
|
||||||
if(fsQuickRead("border.bgr", borderBuf, 400 * 240 * 3) == RES_OK)
|
if(fsQuickRead("border.bgr", borderBuf, 400 * 240 * 3) == RES_OK)
|
||||||
{
|
{
|
||||||
// Copy border in swizzled form to GPU render buffer.
|
// Copy border in swizzled form to GPU render buffer.
|
||||||
@ -1057,8 +1062,8 @@ Result oafInitAndRun( char *firm_path, bool *direct_off )
|
|||||||
else if( g_oafConfig.scaler == 3u )
|
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( GFX_LCD_BOT, true );
|
||||||
GFX_setFramebufFmt(GFX_BGR8, GFX_BGR8);
|
GFX_setFormat(GFX_BGR8, GFX_BGR8, GFX_TOP_2D);
|
||||||
}
|
}
|
||||||
patchGbaGpuCmdList(g_oafConfig.scaler, use_border);
|
patchGbaGpuCmdList(g_oafConfig.scaler, use_border);
|
||||||
// @MERGE 231006 END
|
// @MERGE 231006 END
|
||||||
@ -1089,7 +1094,7 @@ void oafUpdate(void)
|
|||||||
|
|
||||||
void oafFinish(void)
|
void oafFinish(void)
|
||||||
{
|
{
|
||||||
LGYFB_deinit();
|
LGYCAP_deinit(LGYCAP_DEV_TOP);
|
||||||
// @MERGE 231006 START
|
// @MERGE 231006 START
|
||||||
// if(g_frameReadyEvent != 0)
|
// if(g_frameReadyEvent != 0)
|
||||||
// {
|
// {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include "fsutil.h"
|
#include "fsutil.h"
|
||||||
|
#include "arm11/anopatch.h"
|
||||||
#include "arm11/pages.h"
|
#include "arm11/pages.h"
|
||||||
#include "arm11/drivers/mcu.h"
|
#include "arm11/drivers/mcu.h"
|
||||||
#include "arm11/fmt.h"
|
#include "arm11/fmt.h"
|
||||||
@ -253,7 +254,7 @@ atp_error_t use_config_page( OafConfig *g_oafConfig )
|
|||||||
else if( res == ATP_SUCCESS )
|
else if( res == ATP_SUCCESS )
|
||||||
{
|
{
|
||||||
if( prev->backlight != g_oafConfig->backlight )
|
if( prev->backlight != g_oafConfig->backlight )
|
||||||
GFX_setBrightness(g_oafConfig->backlight, g_oafConfig->backlight);
|
setBrightness(g_oafConfig->backlight);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@ -456,7 +457,7 @@ static atp_error_t handle_onoff_entry( acl_entryid_t id, acl_elemlen_t codelen,
|
|||||||
// more than two address, should not overwrite values
|
// more than two address, should not overwrite values
|
||||||
else return DEFAULT_ONOFF_HANDLER;
|
else return DEFAULT_ONOFF_HANDLER;
|
||||||
|
|
||||||
atp_error_t res = atp_select( "选择此项目对应的设置", 3, select_onoff, NULL, targetval << 16 | id, 0, 0, item );
|
atp_error_t res = atp_select( "选择此项目对应的设置", 3, select_onoff, NULL, (atp_callerdata_t)(targetval << 16 | id), 0, 0, item );
|
||||||
if( res == ATP_SUCCESS && *item == 0 )
|
if( res == ATP_SUCCESS && *item == 0 )
|
||||||
{
|
{
|
||||||
ee_snprintf( page_strbuf, sizeof(page_strbuf), "默认值:%d", targetval );
|
ee_snprintf( page_strbuf, sizeof(page_strbuf), "默认值:%d", targetval );
|
||||||
@ -858,7 +859,7 @@ atp_error_t use_keyremix_page( char *file )
|
|||||||
else if( status == DISP_KMAP )
|
else if( status == DISP_KMAP )
|
||||||
{
|
{
|
||||||
key_remix_t *cur = &g_keyremixConfig[position];
|
key_remix_t *cur = &g_keyremixConfig[position];
|
||||||
res = atp_select( "配置键位功能", REMIX_TYPE_COUNT, select_remixtype, NULL, cur->remix_type, 0, 0, &value );
|
res = atp_select( "配置键位功能", REMIX_TYPE_COUNT, select_remixtype, NULL, (atp_callerdata_t)cur->remix_type, 0, 0, &value );
|
||||||
if( res == ATP_SUCCESS )
|
if( res == ATP_SUCCESS )
|
||||||
{
|
{
|
||||||
if( cur->remix_type != value )
|
if( cur->remix_type != value )
|
||||||
@ -900,7 +901,7 @@ atp_error_t use_keyremix_page( char *file )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( keys_count == 1 ) res = atp_select("选择实机键位(单选)", 1, select_unikey, NULL, text, 0, 0, &value);
|
if( keys_count == 1 ) res = atp_select("选择实机键位(单选)", 1, select_unikey, NULL, text, 0, 0, &value);
|
||||||
else res = atp_select( "选择实机键位(单选)", keys_count, select_hostkey, NULL, cur->device_keys, selected>keys_count?0:selected, 0, &value);
|
else res = atp_select( "选择实机键位(单选)", keys_count, select_hostkey, NULL, (atp_callerdata_t)cur->device_keys, selected>keys_count?0:selected, 0, &value);
|
||||||
if( res == ATP_SUCCESS )
|
if( res == ATP_SUCCESS )
|
||||||
{
|
{
|
||||||
cur->device_keys = value;
|
cur->device_keys = value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user