Add touch input support, add fast scrolling support for coverflow display mode, fix use after free bug in banner list mode

This commit is contained in:
Gericom
2026-04-04 19:24:39 +02:00
parent 21a8790ebc
commit 97762b14d3
119 changed files with 2251 additions and 762 deletions

View File

@@ -30,6 +30,7 @@
#include "ExitMode.h"
#include "Arm7State.h"
#include "mmc/tmio.h"
#include "touchScreen.h"
static NocashOutputStream sNocashOutputStream;
static PlainLogger sPlainLogger = PlainLogger(LogLevel::All, std::unique_ptr<IOutputStream>(&sNocashOutputStream));
@@ -42,19 +43,14 @@ static RtcIpcService sRtcIpcService;
ILogger* gLogger = &sThreadSafeLogger;
static rtos_event_t sVBlankEvent;
static rtos_event_t sVCountEvent;
static ExitMode sExitMode;
static Arm7State sState;
static volatile u8 sMcuIrqFlag = false;
static void vblankIrq(u32 irqMask)
{
rtos_signalEvent(&sVBlankEvent);
}
static void vcountIrq(u32 irqMask)
{
SHARED_KEY_XY = REG_RCNT0_H;
rtos_signalEvent(&sVCountEvent);
}
static void mcuIrq(u32 irq2Mask)
@@ -88,12 +84,13 @@ static void checkMcuIrq(void)
}
}
static void initializeVBlankIrq()
static void initializeVCountIrq()
{
rtos_createEvent(&sVBlankEvent);
rtos_setIrqFunc(RTOS_IRQ_VBLANK, vblankIrq);
rtos_enableIrqMask(RTOS_IRQ_VBLANK);
gfx_setVBlankIrqEnabled(true);
rtos_createEvent(&sVCountEvent);
gfx_setVCountMatchLine(96);
rtos_setIrqFunc(RTOS_IRQ_VCOUNT, vcountIrq);
rtos_enableIrqMask(RTOS_IRQ_VCOUNT);
gfx_setVCountMatchIrqEnabled(true);
}
static void clearSoundRegisters()
@@ -145,12 +142,7 @@ static void initializeArm7()
sSoundIpcService.Start();
sRtcIpcService.Start();
gfx_setVCountMatchLine(96);
rtos_setIrqFunc(RTOS_IRQ_VCOUNT, vcountIrq);
rtos_enableIrqMask(RTOS_IRQ_VCOUNT);
gfx_setVCountMatchIrqEnabled(true);
initializeVBlankIrq();
initializeVCountIrq();
if (isDSiMode())
{
@@ -158,6 +150,8 @@ static void initializeArm7()
rtos_enableIrq2Mask(RTOS_IRQ2_MCU);
}
touch_init();
ipc_setArm7SyncBits(7);
}
@@ -233,7 +227,16 @@ int main()
while (true)
{
rtos_waitEvent(&sVBlankEvent, true, true);
rtos_waitEvent(&sVCountEvent, true, true);
u16 keys = REG_RCNT0_H | RCNT0_H_DATA_PEN;
touchPosition touchPos;
if (touch_update(touchPos))
{
keys &= ~RCNT0_H_DATA_PEN; // pen down
SHARED_TOUCH_X = touchPos.px;
SHARED_TOUCH_Y = touchPos.py;
}
SHARED_KEY_XY = keys;
updateArm7();
}