mirror of
https://github.com/SwareJonge/mkdd.git
synced 2024-11-27 23:30:38 +00:00
WIPs
This commit is contained in:
parent
0ab571770f
commit
ad4684ed25
58
include/JSystem/JKernel/JKRDecomp.h
Normal file
58
include/JSystem/JKernel/JKRDecomp.h
Normal file
@ -0,0 +1,58 @@
|
||||
#ifndef JSYSTEM_JKRDECOMP_H
|
||||
#define JSYSTEM_JKRDECOMP_H
|
||||
|
||||
#include "dolphin/OS.h"
|
||||
#include "JSystem/JKernel/JKRThread.h"
|
||||
#include "types.h"
|
||||
|
||||
enum CompressionMethod {
|
||||
TYPE_UNK,
|
||||
TYPE_YAY0,
|
||||
TYPE_YAZ0,
|
||||
TYPE_ASR
|
||||
};
|
||||
|
||||
class JKRDecomp : public JKRThread {
|
||||
public:
|
||||
static void create();
|
||||
|
||||
JKRDecomp(s32);
|
||||
virtual ~JKRDecomp();
|
||||
virtual void *run();
|
||||
|
||||
static void sendCommand(JKRDecompCommand *);
|
||||
static int orderSync(u8 *, u8 *, u32, u32);
|
||||
static void decode(u8 *, u8 *, u32, u32);
|
||||
static void decodeSZP(u8 *, u8 *, u32, u32);
|
||||
static void decodeSZS(u8 *, u8 *, u32, u32);
|
||||
static CompressionMethod checkCompressed(unsigned char *);
|
||||
|
||||
static OSMessage sMessageBuffer[8];
|
||||
static OSMessageQueue sMessageQueue;
|
||||
static JKRDecomp *sDecompObject;
|
||||
private:
|
||||
OSThread * mThread;
|
||||
|
||||
};
|
||||
|
||||
struct JKRDecompCommand {
|
||||
typedef void DecompCmdCb();
|
||||
|
||||
JKRDecompCommand();
|
||||
~JKRDecompCommand();
|
||||
|
||||
u8 _0[4]; //
|
||||
u8 *mSrc; // 4
|
||||
u8 *mDst; // 8
|
||||
u32 mCompressedSize; // C
|
||||
u32 mDecompressedSize; // 10
|
||||
DecompCmdCb *mCb;
|
||||
JKRDecompCommand *mChild; // 18
|
||||
OSMessageQueue * _1C;
|
||||
u32 _20;
|
||||
void* mAramCmd; // 24
|
||||
OSMessageQueue mMessageQueue; // 28
|
||||
OSMessage mMessageBuf;
|
||||
};
|
||||
|
||||
#endif
|
@ -40,9 +40,10 @@ private:
|
||||
int _50;
|
||||
u8 _54[4];
|
||||
int _58;
|
||||
|
||||
public: // i guess a workaround
|
||||
DVDFileInfo mDvdFileInfo; // 5C
|
||||
// 98, not sure if there's padding or if DVDFileInfo has an extra field? gets recasted in doneProcess
|
||||
public: // i guess a workaround
|
||||
OSMessageQueue mMessageQueue; // 9C
|
||||
OSMessage mMessage; // BC
|
||||
OSMessageQueue mMessageQueue_C0;
|
||||
|
@ -47,7 +47,7 @@
|
||||
#define JUT_CONFIRM_MESSAGE(...)
|
||||
#define JUT_ASSERT(...)
|
||||
#define JUT_ASSERT_F(...)
|
||||
#define JUT_PANIC_MSG(...)
|
||||
#define JUT_ASSERT_MSG(...)
|
||||
#define JUT_MINMAX_ASSERT(...)
|
||||
#define JUT_MAX_ASSERT(...)
|
||||
#endif
|
||||
|
@ -108,6 +108,7 @@ public:
|
||||
|
||||
void clear();
|
||||
u32 update(s8 x, s8 y, JUTGamePad::EStickMode, JUTGamePad::EWhichStick);
|
||||
u32 update(s8 x, s8 y, JUTGamePad::EStickMode, JUTGamePad::EWhichStick, u32);
|
||||
u32 getButton();
|
||||
|
||||
f32 mStickX;
|
||||
@ -138,6 +139,8 @@ public:
|
||||
static s32 sResetPattern;
|
||||
};
|
||||
|
||||
static EStickMode sStickMode;
|
||||
|
||||
CButton mButtons; // _18
|
||||
CStick mControlStick; // _48
|
||||
CStick mCStick; // _58
|
||||
|
25
include/Osako/KartPadData.h
Normal file
25
include/Osako/KartPadData.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef KARTPADDATA_H
|
||||
#define KARTPADDATA_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define KARTBTN_A 1
|
||||
#define KARTBTN_B 2
|
||||
#define KARTBTN_X 4
|
||||
#define KARTBTN_Y 8
|
||||
#define KARTBTN_L 16
|
||||
#define KARTBTN_R 32
|
||||
#define KARTBTN_Z 64
|
||||
#define KARTBTN_START 128
|
||||
|
||||
// AND input and mask, if result is not 0, OR output with output/target mask
|
||||
#define ConvertBtn(output, input, inputmask, outputmask) \
|
||||
output |= (input & inputmask) ? outputmask : 0;
|
||||
|
||||
struct KartPadData {
|
||||
int mStickX : 5;
|
||||
int mStickY : 3;
|
||||
u8 mButtons;
|
||||
};
|
||||
|
||||
#endif
|
@ -2,50 +2,38 @@
|
||||
#define KARTPAD_H
|
||||
|
||||
#include "types.h"
|
||||
#include "dolphin/lg.h"
|
||||
#include "JSystem/JUtility/JUTGamePad.h"
|
||||
#include "Osako/KartPadData.h"
|
||||
|
||||
class KartGamePad : public JUTGamePad
|
||||
{
|
||||
public:
|
||||
// placeholder Enums
|
||||
enum PadPort
|
||||
{
|
||||
enum PadPort {
|
||||
PORT_1 = 0,
|
||||
PORT_2 = 1,
|
||||
PORT_3 = 2,
|
||||
PORT_4 = 3,
|
||||
};
|
||||
|
||||
enum PadType
|
||||
{
|
||||
enum PadType { };
|
||||
enum PadState { };
|
||||
|
||||
};
|
||||
|
||||
enum PadState
|
||||
{
|
||||
|
||||
};
|
||||
KartGamePad(JUTGamePad::EPadPort ePadPort, PadPort padPort, PadType padType, PadState padState) : JUTGamePad(ePadPort)
|
||||
{
|
||||
KartGamePad(EPadPort ePadPort, PadPort padPort, PadType padType, PadState padState) : JUTGamePad(ePadPort) {
|
||||
mPadType = padType;
|
||||
mPadPort = padPort;
|
||||
mPadState = padState;
|
||||
}
|
||||
virtual ~KartGamePad() {}
|
||||
|
||||
PadType getPadType()
|
||||
{
|
||||
return mPadType;
|
||||
}
|
||||
static void compress(PADStatus const &padStatus, KartPadData *kartPadData);
|
||||
static void compress(LGPosition const &lgPosition, KartPadData *kartPadData);
|
||||
void expand(KartPadData const &);
|
||||
|
||||
PadPort getPadPort()
|
||||
{
|
||||
return mPadPort;
|
||||
}
|
||||
PadState getPadState()
|
||||
{
|
||||
return mPadState;
|
||||
}
|
||||
PadType getPadType() { return mPadType; }
|
||||
PadPort getPadPort() { return mPadPort; }
|
||||
PadState getPadState() { return mPadState;}
|
||||
|
||||
private:
|
||||
PadType mPadType;
|
||||
|
@ -14,15 +14,15 @@ extern "C" {
|
||||
struct PADStatus
|
||||
{
|
||||
u16 mButton; // _0
|
||||
u8 mStickX; // _2
|
||||
u8 mStickY; // _3
|
||||
u8 mSubStickX; // C Stick X (_4)
|
||||
u8 mSubStickY; // C Stick Y (_5)
|
||||
s8 mStickX; // _2
|
||||
s8 mStickY; // _3
|
||||
s8 mSubStickX; // C Stick X (_4)
|
||||
s8 mSubStickY; // C Stick Y (_5)
|
||||
u8 mTriggerLeft; // Left trigger pressure (_6)
|
||||
u8 mTriggerRight; // Right trigger pressure (_7)
|
||||
u8 mAnalogA; // _8
|
||||
u8 mAnalogB; // _9
|
||||
u8 mCurError; // Some odd number based on some constant (_10)
|
||||
s8 mCurError; // Some odd number based on some constant (_10)
|
||||
};
|
||||
|
||||
bool PADReset(u32 mask);
|
||||
|
@ -83,12 +83,12 @@ extern "C"
|
||||
BOOL DVDOpen(const char *, DVDFileInfo *);
|
||||
BOOL DVDFastOpen(long, DVDFileInfo *);
|
||||
BOOL DVDClose(DVDFileInfo *);
|
||||
int DVDCancel(struct DVDPlayer *); // Definitely int; returns -1 on failure.
|
||||
int DVDCancel(DVDFileInfo *); // Definitely int; returns -1 on failure.
|
||||
void DVDResume();
|
||||
void DVDReset();
|
||||
int DVDReadPrio(struct DVDPlayer *player, void *readBuffer, s32 byteCount, u32 startOffset, s32 queueIndex);
|
||||
int DVDReadPrio(DVDFileInfo *, void *readBuffer, s32 byteCount, u32 startOffset, s32 queueIndex);
|
||||
BOOL DVDReadAsyncPrio(DVDFileInfo *, void *, long, long, DVDDoneReadCallback *, int);
|
||||
BOOL DVDReadAbsAsyncPrio(struct DVDPlayer *player, void *readBuffer, long byteCount, u8 *startAddress,
|
||||
BOOL DVDReadAbsAsyncPrio(DVDFileInfo *, void *readBuffer, long byteCount, u8 *startAddress,
|
||||
DVDDoneReadCallback *doneReadCallback, int queueIndex);
|
||||
|
||||
BOOL DVDConvertEntrynumToPath(int, char *);
|
||||
|
27
include/dolphin/lg.h
Normal file
27
include/dolphin/lg.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef DOLPHIN_LG_H
|
||||
#define DOLPHIN_LG_H
|
||||
|
||||
#include <dolphin/types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif // ifdef __cplusplus
|
||||
|
||||
struct LGPosition { // seems really similar to PADStatus but is slightly different
|
||||
u16 input; // includes also up and down on the stick it seems
|
||||
s8 _2;
|
||||
s8 stick3;
|
||||
u8 analogA;
|
||||
u8 analogB;
|
||||
u8 _6; // unknown, are there any other analog buttons?(start maybe)
|
||||
u8 analogL;
|
||||
u8 analogR;
|
||||
s8 err; // -1 probably means disconnected?
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
66
src/JSystem/JKernel/JKRDecomp.cpp
Normal file
66
src/JSystem/JKernel/JKRDecomp.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
#include "JSystem/JUtility/JUTDbg.h"
|
||||
#include "JSystem/JKernel/JKRHeap.h"
|
||||
#include "JSystem/JKernel/JKRDecomp.h"
|
||||
|
||||
// WIP, missing classes
|
||||
|
||||
JKRDecomp::JKRDecomp(s32 threadPriority) : JKRThread(0x4000, 16, threadPriority) {
|
||||
OSResumeThread(mThread);
|
||||
}
|
||||
|
||||
JKRDecomp::~JKRDecomp() {}
|
||||
|
||||
void * JKRDecomp::run() {
|
||||
OSMessage msg;
|
||||
JKRDecompCommand *decompCmd;
|
||||
OSInitMessageQueue(&sMessageQueue, sMessageBuffer, 8);
|
||||
while (true) {
|
||||
while(true) {
|
||||
OSReceiveMessage(&sMessageQueue, &msg, OS_MESSAGE_BLOCK);
|
||||
decompCmd = reinterpret_cast<JKRDecompCommand*>(&msg);
|
||||
decode(decompCmd->mSrc, decompCmd->mDst, decompCmd->mCompressedSize, decompCmd->mDecompressedSize);
|
||||
if (decompCmd->_20 == 0)
|
||||
break;
|
||||
if (decompCmd->_20 == 1) {
|
||||
decompCmd->_24->sendCommand();
|
||||
}
|
||||
}
|
||||
if (decompCmd->mCb == nullptr)
|
||||
break;
|
||||
decompCmd->mCb();
|
||||
}
|
||||
if (decompCmd->_1C == nullptr) {
|
||||
OSSendMessage(&decompCmd->mMessageQueue, (void*)1, 0);
|
||||
}
|
||||
else {
|
||||
OSSendMessage(decompCmd->_1C, (void *)1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void JKRDecomp::sendCommand(JKRDecompCommand * decompCmd) {
|
||||
BOOL msgret = OSSendMessage(&sMessageQueue, decompCmd, 0);
|
||||
JUT_ASSERT_MSG(142, msgret, "Decomp MesgBuf FULL!");
|
||||
}
|
||||
|
||||
int JKRDecomp::orderSync(u8 * src, u8 * dst, u32 srcSize, u32 dstSize) {
|
||||
JKRDecompCommand *decompCmd = new(JKRHeap::getSystemHeap(), -4);
|
||||
decompCmd->mSrc = src;
|
||||
decompCmd->mDst = dst;
|
||||
decompCmd->mCompressedSize = srcSize;
|
||||
decompCmd->mDecompressedSize = dstSize;
|
||||
decompCmd->mCb = nullptr;
|
||||
sendCommand(decompCmd);
|
||||
|
||||
OSMessage* msg;
|
||||
OSReceiveMessage(&decompCmd->mMessageQueue, msg, OS_MESSAGE_BLOCK);
|
||||
delete decompCmd;
|
||||
}
|
||||
|
||||
void JKRDecomp::decode(u8 *src, u8 *dst, u32 srcSize, u32 dstSize) {
|
||||
switch(checkCompressed(src)) {
|
||||
case TYPE_YAY0:
|
||||
decodeSZP(src, dst, srcSize, dstSize);
|
||||
case TYPE_YAZ0:
|
||||
decodeSZS(src, dst, srcSize, dstSize);
|
||||
}
|
||||
}
|
42
src/JSystem/JKernel/JKRDvdRipper.cpp
Normal file
42
src/JSystem/JKernel/JKRDvdRipper.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
#include "JSystem/JKernel/JKRDvdRipper.h"
|
||||
|
||||
// WIP, missing classes
|
||||
|
||||
namespace JKRDvdRipper {
|
||||
|
||||
void *loadToMainRAM(const char *fileName, u8 *ptr, JKRExpandSwitch expSwitch, u32 p4, JKRHeap *heap, EAllocDirection allocDirection, u32 p7, int *p8, u32 *p9) {
|
||||
void * file;
|
||||
JKRDvdFile dvdFile;
|
||||
if (dvdFile.open(fileName)) {
|
||||
file = loadToMainRAM(&dvdFile, ptr, expSwitch, p4, heap, allocDirection, p7, p8, p9);
|
||||
delete &dvdFile;
|
||||
}
|
||||
else {
|
||||
delete &dvdFile;
|
||||
file = nullptr;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
void *loadToMainRAM(s32 entryNum, u8 *ptr, JKRExpandSwitch expSwitch, u32 p4, JKRHeap *heap, EAllocDirection allocDirection, u32 p7, int *p8, u32 *p9) {
|
||||
void * file;
|
||||
JKRDvdFile dvdFile;
|
||||
if (dvdFile.open(entryNum)) {
|
||||
file = loadToMainRAM(&dvdFile, ptr, expSwitch, p4, heap, allocDirection, p7, p8, p9);
|
||||
delete &dvdFile;
|
||||
}
|
||||
else {
|
||||
delete &dvdFile;
|
||||
file = nullptr;
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
void *loadToMainRAM(JKRDvdFile * jkrDvdFile, u8 * file, JKRExpandSwitch expandSwitch, u32 p4, JKRHeap * heap, EAllocDirection allocDirection, u32 p7, int * p8, u32 *p9) {
|
||||
if (expandSwitch == Switch_1) {
|
||||
DVDReadPrio(&jkrDvdFile->mDvdFileInfo, , 0x20, 0, 2);
|
||||
}
|
||||
|
||||
return file;
|
||||
}
|
||||
}
|
140
src/Osako/kartPad.cpp
Normal file
140
src/Osako/kartPad.cpp
Normal file
@ -0,0 +1,140 @@
|
||||
#include "Osako/kartPad.h"
|
||||
#include "Osako/KartPadData.h"
|
||||
|
||||
// TODO: add KartGamePad instances
|
||||
|
||||
void KartGamePad::compress(PADStatus const &padStatus, KartPadData *kartPadData) {
|
||||
s8 stickX, stickY;
|
||||
u8 buttons = 0;
|
||||
|
||||
if (padStatus.mCurError == -1) {
|
||||
stickX = 0;
|
||||
stickY = 0;
|
||||
}
|
||||
else {
|
||||
stickX = (padStatus.mStickX / 4.0f);
|
||||
stickY = (padStatus.mStickY / 18.0f);
|
||||
|
||||
if (stickX > 15)
|
||||
stickX = 15;
|
||||
if (stickX < -15)
|
||||
stickX = -15;
|
||||
if (stickY > 3)
|
||||
stickY = 3;
|
||||
if (stickY < -3)
|
||||
stickY = -3;
|
||||
|
||||
// maybe there's a cleaner way to write this?
|
||||
ConvertBtn(buttons, padStatus.mButton, A, KARTBTN_A);
|
||||
ConvertBtn(buttons, padStatus.mButton, B, KARTBTN_B);
|
||||
ConvertBtn(buttons, padStatus.mButton, X, KARTBTN_X);
|
||||
ConvertBtn(buttons, padStatus.mButton, Y, KARTBTN_Y);
|
||||
ConvertBtn(buttons, padStatus.mButton, L, KARTBTN_L);
|
||||
ConvertBtn(buttons, padStatus.mButton, R, KARTBTN_R);
|
||||
ConvertBtn(buttons, padStatus.mButton, Z, KARTBTN_Z);
|
||||
ConvertBtn(buttons, padStatus.mButton, START, KARTBTN_START);
|
||||
}
|
||||
kartPadData->mStickX = stickX;
|
||||
kartPadData->mStickY = stickY;
|
||||
kartPadData->mButtons = buttons;
|
||||
}
|
||||
|
||||
void KartGamePad::compress(LGPosition const &lgPosition, KartPadData *kartPadData)
|
||||
{
|
||||
s8 stickX, stickY;
|
||||
u8 buttons = 0;
|
||||
|
||||
if (lgPosition.err == -1)
|
||||
{
|
||||
stickX = 0;
|
||||
stickY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
s8 lgStick = lgPosition.stick3;
|
||||
int iVar2 = (lgStick * lgStick) / 30;
|
||||
;
|
||||
if (lgStick > 0)
|
||||
{
|
||||
if (iVar2 < 127)
|
||||
lgStick = iVar2;
|
||||
else
|
||||
lgStick = 127;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lgStick < 0)
|
||||
{
|
||||
if (iVar2 < 127)
|
||||
lgStick = -iVar2;
|
||||
else
|
||||
lgStick = -127;
|
||||
}
|
||||
}
|
||||
stickX = (lgStick / 3.7f);
|
||||
|
||||
if (stickX > 15)
|
||||
stickX = 15;
|
||||
if (stickX < -15)
|
||||
stickX = -15;
|
||||
|
||||
u16 input = lgPosition.input;
|
||||
ConvertBtn(buttons, input, A, KARTBTN_A);
|
||||
ConvertBtn(buttons, input, B, KARTBTN_B);
|
||||
ConvertBtn(buttons, input, X, KARTBTN_X);
|
||||
ConvertBtn(buttons, input, Y, KARTBTN_Y);
|
||||
ConvertBtn(buttons, input, L, KARTBTN_L);
|
||||
ConvertBtn(buttons, input, R, KARTBTN_R);
|
||||
ConvertBtn(buttons, input, Z, KARTBTN_Z);
|
||||
ConvertBtn(buttons, input, START, KARTBTN_START);
|
||||
|
||||
if (input & 8)
|
||||
stickY = 3;
|
||||
else if (input & 4)
|
||||
stickY = -3;
|
||||
else
|
||||
stickY = 0;
|
||||
|
||||
if (input & 1)
|
||||
stickX = -15;
|
||||
else if (input & 2)
|
||||
stickX = 15;
|
||||
|
||||
// analog input detection(i thought the buttons were digital but ok)
|
||||
if (lgPosition.analogL > 175)
|
||||
buttons |= KARTBTN_L;
|
||||
if (lgPosition.analogR > 175)
|
||||
buttons |= KARTBTN_R;
|
||||
|
||||
if (lgPosition.analogA > 80)
|
||||
buttons |= KARTBTN_A;
|
||||
if (lgPosition.analogB > 80)
|
||||
buttons |= KARTBTN_B;
|
||||
}
|
||||
kartPadData->mStickX = stickX;
|
||||
kartPadData->mStickY = stickY;
|
||||
kartPadData->mButtons = buttons;
|
||||
}
|
||||
|
||||
// Not tested
|
||||
void KartGamePad::expand(KartPadData const &kartPadData) {
|
||||
u16 btn;
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_A, A);
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_B, B);
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_X, X);
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_Y, Y);
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_L, L);
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_R, R);
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_Z, Z);
|
||||
ConvertBtn(btn, kartPadData.mButtons, KARTBTN_START, START);
|
||||
PADStatus padStatus;
|
||||
padStatus.mStickX = (s8)(kartPadData.mStickX * 4.0f);
|
||||
padStatus.mStickY = (s8)(kartPadData.mStickY * 18.0f);
|
||||
padStatus.mButton = btn;
|
||||
padStatus.mAnalogA = 0;
|
||||
padStatus.mTriggerLeft = 0;
|
||||
padStatus.mTriggerRight = 0;
|
||||
|
||||
u32 btnret = mCStick.update(padStatus.mStickX, padStatus.mStickY, sStickMode, WhichStick_ControlStick, mButtons.mInput);
|
||||
mButtons.update(&padStatus, btnret);
|
||||
}
|
Loading…
Reference in New Issue
Block a user