Skip to content

Commit

Permalink
merge in JSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
shibbo committed Feb 12, 2025
1 parent bb69738 commit 014a9a5
Show file tree
Hide file tree
Showing 29 changed files with 4,810 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/JSystem/J3DGraphBase/J3DMaterial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "JSystem/J3DGraphBase/J3DMaterial.hpp"

J3DAlphaComp::J3DAlphaComp() {
u16 val = sUnk;
_2 = 0;
_0 = val;
_3 = 0;
}

#ifdef NON_MATCHING
// some scheduling issues
void J3DCurrentMtx::setCurrentTexMtx(u8 a1, u8 a2, u8 a3, u8 a4, u8 a5, u8 a6, u8 a7, u8 a8) {
_0 = (a4 << 24) | (a3 << 18) & 0x3FC0000 | (a1 << 6) & 0x3FC0 | (a2 << 12) & 0xFF000;
_4 = (a8 << 18) | (a7 << 12) & 0xFF000 | a5 & 0xFFF00FFF | (a6 << 6) & 0x3FC0;
}
#endif

11 changes: 11 additions & 0 deletions src/JSystem/J3DGraphBase/J3DVertex.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "JSystem/J3DGraphBase/J3DVertex.hpp"

J3DDrawMtxData::J3DDrawMtxData() {
mDrawMatrixCount = 0;
_4 = 0;
mDrawMtxArray = nullptr;
}

J3DDrawMtxData::~J3DDrawMtxData() {

}
115 changes: 115 additions & 0 deletions src/JSystem/JAudio2/JASSeqCtrl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#include "JSystem/JAudio2/JASSeqCtrl.hpp"
#include "JSystem/JAudio2/JASTrack.hpp"

JASSeqParser JASSeqCtrl::sDefaultParser = JASSeqParser();

JASSeqCtrl::JASSeqCtrl() {
JASSeqReader::init();
mParser = &sDefaultParser;
mTimer = 0;
mCursorSwap = nullptr;
_48 = 0;
_4C = 0;
_4E = 0;
mIntTimer = 0;
_51 = false;
_54 = 0;
_58 = 0;
JASSeqReader::init();
}

void JASSeqCtrl::init() {
JASSeqReader::init();
mParser = &sDefaultParser;
mTimer = 0;
mCursorSwap = nullptr;
_48 = 0;
_4C = 0;
_4E = 0;
mIntTimer = 0;
_54 = 0;
_58 = 0;
_51 = false;
}

void JASSeqCtrl::start(void *, u32 offset) {
JASSeqReader::init();
mSeqCursor = (void *)((u8 *)mSeqBuff + offset);
}

int JASSeqCtrl::tickProc(JASTrack *track) {
if(!mSeqBuff) return 0;
interrupt(JASSeqCtrl::INTR_6);
timerProcess();
if(_51) {
if(!track->checkNoteStop(0)) return 0;
_51 = false;
}
if(mTimer > 0) mTimer--;
checkIntr();

while((!mTimer || mCursorSwap) && !_51) {
if(mParser->parse(track) < 0) return -1;
}

return 0;
}

void JASSeqCtrl::interrupt(JASSeqCtrl::IntrType interrupt) {
u32 mask = 1 << interrupt;
if(!(_4E & mask)) return;
_4C |= mask;
}

void JASSeqCtrl::setIntrMask(u32 mask) {
_4E |= mask;
}

void JASSeqCtrl::clrIntrMask(u32 mask) {
_4E &= ~mask;
}

bool JASSeqCtrl::retIntr() {
if(!mCursorSwap) return false;
mSeqCursor = mCursorSwap;
mCursorSwap = nullptr;
return true;
}

s32 JASSeqCtrl::findIntr() {
u32 intr = _4E & _4C;
for(u32 i = 0; intr != 0; i++) {
if(intr & 1) {
_4C &= ~(1 << i);
return i;
}
else intr >>= 1;
}
return -1;
}

void JASSeqCtrl::checkIntr() {
s32 intr;
if(!mCursorSwap && (intr = findIntr()) >= 0) {
intr = intr * 3 + _48;
u32 offset = calcSeekAmt(intr);
mCursorSwap = mSeqCursor;
mSeqCursor = (void *)((u8 *)mSeqBuff + offset);
}
}

void JASSeqCtrl::timerProcess() {
if(_54 != 0) {
if(!--_54) {
interrupt(INTR_5);
if(mIntTimer) {
if(--mIntTimer) {
_54 = _58;
}
}
else _54 = _58;
}
}
}

JASSeqParser::JASSeqParser() {}
Loading

0 comments on commit 014a9a5

Please sign in to comment.