summaryrefslogtreecommitdiff
path: root/src/JSystem/JHostIO/JHIRMcc.cpp
blob: d4728fe4996c9bf1ad0bed54f20e4b80be0fbd9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Debug-only file. This file is known to have existed for TWW based on the debug maps.
// The contents of this are based on the TP debug build decomp and may or may not match the actual TWW debug build.

#include "JSystem/JSystem.h" // IWYU pragma: keep

#include "JSystem/JHostIO/JHIMccBuf.h"
#include "dolphin/hio.h"

s32 gExiChannel = -1;

JHIMccContext tContext_old;
JHIMccContext tContext_new;
bool initialized_;
u8 negotiate_;

BOOL JHIhioCallbackEnum(s32 type) {
    gExiChannel = type;
    return 0;
}

void JHIEnumDevices(s32*, u32*) {
    /* Nonmatching */
}

u32 JHIInitInterface() {
    /* Nonmatching */
    return 1;
}

bool JHINegotiateInterface(u32) {
    /* Nonmatching */
    return 0;
}

JHIMccContext JHIGetHiSpeedContext() {
    if (tContext_new.mp_reader == NULL) {
        tContext_new.mp_reader = new JHIMccBufReader(1, 0x18, 0x6000);
    }
    
    if (tContext_new.mp_writer == NULL) {
        tContext_new.mp_writer = new JHIMccBufWriter(1, 0x18, 0x6000);
    }

    return tContext_new;
}

JHIMccContext JHIGetLowSpeedContext() {
    if (tContext_old.mp_reader == NULL) {
        tContext_old.mp_reader = new JHIMccBufReader(1, 2, 0);
    }
    
    if (tContext_old.mp_writer == NULL) {
        tContext_old.mp_writer = new JHIMccBufWriter(1, 2, 0);
    }

    return tContext_old;
}

BOOL JHIInitMCC(JHIMccContext* pCtx, bool* param_1) {
    JHIGetHiSpeedContext();
    JHIGetLowSpeedContext();

    if (!JHIInitInterface()) {
        *pCtx = tContext_old;
        return FALSE;
    }

    initialized_ = JHINegotiateInterface(800);
    if (initialized_) {
        tContext_new.mp_reader->enablePort();
        tContext_new.mp_writer->enablePort();
        tContext_new.mp_reader->init();
        tContext_new.mp_writer->init();
    } else {
        tContext_old.mp_reader->enablePort();
        tContext_old.mp_writer->enablePort();
        tContext_old.mp_reader->init();
        tContext_old.mp_writer->init();
    }

    if (param_1 != NULL) {
        *param_1 = initialized_;
    }

    if (initialized_) {
        *pCtx = tContext_new;
    } else {
        *pCtx = tContext_old;
    }

    return TRUE;
}