mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2024-11-14 21:37:42 -07:00
Compare commits
3 Commits
e30e68e6cf
...
4d4db1c5ce
Author | SHA1 | Date | |
---|---|---|---|
|
4d4db1c5ce | ||
|
5e8beb3ab7 | ||
|
47b4df3d63 |
2
BUILD.md
2
BUILD.md
@ -47,7 +47,7 @@
|
|||||||
1. Install Qt: `pacman -S <prefix>-{qt6-base,qt6-svg,qt6-multimedia,qt6-svg,qt6-tools}`
|
1. Install Qt: `pacman -S <prefix>-{qt6-base,qt6-svg,qt6-multimedia,qt6-svg,qt6-tools}`
|
||||||
2. Set up the build directory with `cmake -B build`
|
2. Set up the build directory with `cmake -B build`
|
||||||
* Static builds (without DLLs, standalone executable)
|
* Static builds (without DLLs, standalone executable)
|
||||||
1. Install Qt: `pacman -S <prefi>-qt5-static`
|
1. Install Qt: `pacman -S <prefix>-qt5-static`
|
||||||
(Note: As of writing, the `qt6-static` package does not work.)
|
(Note: As of writing, the `qt6-static` package does not work.)
|
||||||
2. Set up the build directory with `cmake -B build -DBUILD_STATIC=ON -DUSE_QT6=OFF -DCMAKE_PREFIX_PATH=$MSYSTEM_PREFIX/qt5-static`
|
2. Set up the build directory with `cmake -B build -DBUILD_STATIC=ON -DUSE_QT6=OFF -DCMAKE_PREFIX_PATH=$MSYSTEM_PREFIX/qt5-static`
|
||||||
7. Compile: `cmake --build build`
|
7. Compile: `cmake --build build`
|
||||||
|
@ -88,6 +88,8 @@ void DSi_TSC::SetTouchCoords(u16 x, u16 y)
|
|||||||
TouchX = x;
|
TouchX = x;
|
||||||
TouchY = y;
|
TouchY = y;
|
||||||
|
|
||||||
|
DeltaX = DeltaY = 0;
|
||||||
|
|
||||||
u8 oldpress = Bank3Regs[0x0E] & 0x01;
|
u8 oldpress = Bank3Regs[0x0E] & 0x01;
|
||||||
|
|
||||||
if (y == 0xFFF)
|
if (y == 0xFFF)
|
||||||
@ -121,6 +123,22 @@ void DSi_TSC::SetTouchCoords(u16 x, u16 y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DSi_TSC::MoveTouchCoords(u16 x, u16 y)
|
||||||
|
{
|
||||||
|
if (TSCMode == 0x00) return TSC::MoveTouchCoords(x, y);
|
||||||
|
|
||||||
|
if (Bank3Regs[0x0E] & 0x01)
|
||||||
|
{
|
||||||
|
return SetTouchCoords(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeltaX = (x << 4) - (TouchX & ~0x8000);
|
||||||
|
DeltaY = (y << 4) - (TouchY & ~0x8000);
|
||||||
|
|
||||||
|
Bank3Regs[0x09] = 0x80;
|
||||||
|
Bank3Regs[0x0E] &= ~0x01;
|
||||||
|
}
|
||||||
|
|
||||||
void DSi_TSC::MicInputFrame(const s16* data, int samples)
|
void DSi_TSC::MicInputFrame(const s16* data, int samples)
|
||||||
{
|
{
|
||||||
if (TSCMode == 0x00) return TSC::MicInputFrame(data, samples);
|
if (TSCMode == 0x00) return TSC::MicInputFrame(data, samples);
|
||||||
@ -162,8 +180,9 @@ void DSi_TSC::Write(u8 val)
|
|||||||
{
|
{
|
||||||
// X coordinates
|
// X coordinates
|
||||||
|
|
||||||
if (id & 0x01) Data = TouchX >> 8;
|
u16 touchX = TouchX + CreateTouchOffset(DeltaX);
|
||||||
else Data = TouchX & 0xFF;
|
if (id & 0x01) Data = touchX >> 8;
|
||||||
|
else Data = touchX & 0xFF;
|
||||||
|
|
||||||
TouchX &= 0x7FFF;
|
TouchX &= 0x7FFF;
|
||||||
}
|
}
|
||||||
@ -171,8 +190,9 @@ void DSi_TSC::Write(u8 val)
|
|||||||
{
|
{
|
||||||
// Y coordinates
|
// Y coordinates
|
||||||
|
|
||||||
if (id & 0x01) Data = TouchY >> 8;
|
u16 touchY = TouchY + CreateTouchOffset(DeltaY);
|
||||||
else Data = TouchY & 0xFF;
|
if (id & 0x01) Data = touchY >> 8;
|
||||||
|
else Data = touchY & 0xFF;
|
||||||
|
|
||||||
TouchY &= 0x7FFF; // checkme
|
TouchY &= 0x7FFF; // checkme
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,7 @@ public:
|
|||||||
void SetMode(u8 mode);
|
void SetMode(u8 mode);
|
||||||
|
|
||||||
void SetTouchCoords(u16 x, u16 y) override;
|
void SetTouchCoords(u16 x, u16 y) override;
|
||||||
|
void MoveTouchCoords(u16 x, u16 y) override;
|
||||||
void MicInputFrame(const s16* data, int samples) override;
|
void MicInputFrame(const s16* data, int samples) override;
|
||||||
|
|
||||||
void Write(u8 val) override;
|
void Write(u8 val) override;
|
||||||
|
@ -1122,6 +1122,11 @@ void NDS::TouchScreen(u16 x, u16 y)
|
|||||||
SPI.GetTSC()->SetTouchCoords(x, y);
|
SPI.GetTSC()->SetTouchCoords(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NDS::MoveTouch(u16 x, u16 y)
|
||||||
|
{
|
||||||
|
SPI.GetTSC()->MoveTouchCoords(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void NDS::ReleaseScreen()
|
void NDS::ReleaseScreen()
|
||||||
{
|
{
|
||||||
SPI.GetTSC()->SetTouchCoords(0x000, 0xFFF);
|
SPI.GetTSC()->SetTouchCoords(0x000, 0xFFF);
|
||||||
|
@ -392,6 +392,7 @@ public: // TODO: Encapsulate the rest of these members
|
|||||||
bool IsRunning() const noexcept { return Running; }
|
bool IsRunning() const noexcept { return Running; }
|
||||||
|
|
||||||
void TouchScreen(u16 x, u16 y);
|
void TouchScreen(u16 x, u16 y);
|
||||||
|
void MoveTouch(u16 x, u16 y);
|
||||||
void ReleaseScreen();
|
void ReleaseScreen();
|
||||||
|
|
||||||
void SetKeyMask(u32 mask);
|
void SetKeyMask(u32 mask);
|
||||||
|
23
src/SPI.cpp
23
src/SPI.cpp
@ -352,6 +352,12 @@ void PowerMan::Write(u8 val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
s16 TSC::CreateTouchOffset(s16 delta) const
|
||||||
|
{
|
||||||
|
// 560190 cycles per frame
|
||||||
|
s64 cyclepos = (s64)NDS.GetSysClockCycles(2);
|
||||||
|
return (cyclepos * delta) / 560190;
|
||||||
|
}
|
||||||
|
|
||||||
TSC::TSC(melonDS::NDS& nds) : SPIDevice(nds)
|
TSC::TSC(melonDS::NDS& nds) : SPIDevice(nds)
|
||||||
{
|
{
|
||||||
@ -392,6 +398,8 @@ void TSC::SetTouchCoords(u16 x, u16 y)
|
|||||||
TouchX = x;
|
TouchX = x;
|
||||||
TouchY = y;
|
TouchY = y;
|
||||||
|
|
||||||
|
DeltaX = DeltaY = 0;
|
||||||
|
|
||||||
if (y == 0xFFF)
|
if (y == 0xFFF)
|
||||||
{
|
{
|
||||||
// released
|
// released
|
||||||
@ -404,6 +412,17 @@ void TSC::SetTouchCoords(u16 x, u16 y)
|
|||||||
NDS.KeyInput &= ~(1 << (16+6));
|
NDS.KeyInput &= ~(1 << (16+6));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TSC::MoveTouchCoords(u16 x, u16 y)
|
||||||
|
{
|
||||||
|
if (NDS.KeyInput & (1 << (16+6)))
|
||||||
|
{
|
||||||
|
return SetTouchCoords(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeltaX = (x << 4) - TouchX;
|
||||||
|
DeltaY = (y << 4) - TouchY;
|
||||||
|
}
|
||||||
|
|
||||||
void TSC::MicInputFrame(const s16* data, int samples)
|
void TSC::MicInputFrame(const s16* data, int samples)
|
||||||
{
|
{
|
||||||
if (!data)
|
if (!data)
|
||||||
@ -433,8 +452,8 @@ void TSC::Write(u8 val)
|
|||||||
|
|
||||||
switch (ControlByte & 0x70)
|
switch (ControlByte & 0x70)
|
||||||
{
|
{
|
||||||
case 0x10: ConvResult = TouchY; break;
|
case 0x10: ConvResult = TouchY + CreateTouchOffset(DeltaY); break;
|
||||||
case 0x50: ConvResult = TouchX; break;
|
case 0x50: ConvResult = TouchX + CreateTouchOffset(DeltaX); break;
|
||||||
|
|
||||||
case 0x60:
|
case 0x60:
|
||||||
{
|
{
|
||||||
|
@ -121,6 +121,7 @@ public:
|
|||||||
virtual void DoSavestate(Savestate* file) override;
|
virtual void DoSavestate(Savestate* file) override;
|
||||||
|
|
||||||
virtual void SetTouchCoords(u16 x, u16 y);
|
virtual void SetTouchCoords(u16 x, u16 y);
|
||||||
|
virtual void MoveTouchCoords(u16 x, u16 y);
|
||||||
virtual void MicInputFrame(const s16* data, int samples);
|
virtual void MicInputFrame(const s16* data, int samples);
|
||||||
|
|
||||||
virtual void Write(u8 val) override;
|
virtual void Write(u8 val) override;
|
||||||
@ -131,9 +132,12 @@ protected:
|
|||||||
u16 ConvResult;
|
u16 ConvResult;
|
||||||
|
|
||||||
u16 TouchX, TouchY;
|
u16 TouchX, TouchY;
|
||||||
|
s16 DeltaX, DeltaY;
|
||||||
|
|
||||||
s16 MicBuffer[1024];
|
s16 MicBuffer[1024];
|
||||||
int MicBufferLen;
|
int MicBufferLen;
|
||||||
|
|
||||||
|
s16 CreateTouchOffset(s16 delta) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user