mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-10 23:22:33 -04:00
a1f0d32d66
* Update menus.c (#634) * Update common_data.yml (#635) * Renames for screenId and other changes (#636) * screenId renames * Rename surface map to collision mesh (#637) * Rename some stack vars (#638) * Fix syntax error (#639) * Rename some stack vars * Update collision.c * Collision Documentation (#640) * Collision related renames * update doxygen (#649) * change bool (#644) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * Update (#642) * Delete trig_tables_bss.c (#650) * fix typo audio (#656) * fix typo src actor (#657) Co-authored-by: MegaMech <MegaMech@users.noreply.github.com> * fix typo include (#658) * fix course (#659) * fix typo debug (#660) * fix typo data (#661) * replace number with const (#665) * fix typo buffers (#655) * fix typo buffers * tweak ld file * rename to sMemoryPool * add a warning --------- * fix typo src (#654) * fix typo src * fix non matcing * Update code_80091750.c --------- * fix typo racing (#653) * fix typo racing * get it match * replace G_LINE3D to G_QUAD --------- * fix typo src (#652) * fix ending typo (#651) * Action more info when it doesn't match and fix first diff (#662) * Update linux-compile.yml * fix first-diff * Update first-diff.py --------- * document texture of kart (#663) * document texture of kart * change screenPlayerId to screenId * some documentation around object * Revert "some documentation around object" This reverts commit cbb39078e036bf2a417bed67359e910213acab28. * more rename --------- * Make evaluate_collision_players_palm_tree better (#667) This matches just the same as before, but using those two casts instead of shifts seems more likely to be accurate to the original source code Signed-off-by: Gabriel Ravier <gabravier@gmail.com> * add fedora instruciton (#666) * start documenting animation (#668) * start documenting animation * Update course_data.c * change comment * update libultra asm (#648) * update libultra asm * fix gcc __osThreadTail --------- * Document Vehicles (#641) * start doc collision * fix merge * finish rename fonction related to vehicle * document around waypoint of vehicle * make some modification * make some change and rename one * copy_ to oldPos * doc smoke ferry and train * some rename * fix some renaming * precise index * rename a funciton * simplify waypoint_vehicles * change some name * change some name * rename move_to_point_direction * fix some conflict * Update code_80005FD0.c * Update code_80005FD0.h --------- * Label a save info loop (#645) * save info * more gcc progress * fix a value and do a rename (#669) * update clang and add action (#664) * update clang and add action * try clang on course folder only * forget two file * Update course_displaylists.inc.c * forget few other file * Update course_vertices.inc.c * format all code while get it match * second pass * format other dir * disable clang format on bad ido code * fix some tabulation * revert format on tool dir * Update clang-format.yml * ignore gbi.h * add some read me instruction * fix error * format and fixing error * Update README.md --------- * Update linkonly_generator.py (#670) * format more file * update * fix compilation issue * remove course_metadata folder * re add course metadata folder * fix banshee bordwalk crash * fix windows eurk * Update CMakeLists.txt ---------
97 lines
2.8 KiB
C
97 lines
2.8 KiB
C
#include "libultra_internal.h"
|
|
|
|
#include <PR/os_pi.h>
|
|
#include "controller.h"
|
|
|
|
OSPifRam __osPfsPifRam;
|
|
|
|
s32 osPfsIsPlug(OSMesgQueue* queue, u8* pattern) {
|
|
s32 ret;
|
|
OSMesg dummy;
|
|
u8 bitpattern;
|
|
OSContStatus data[MAXCONTROLLERS];
|
|
int channel;
|
|
u8 bits;
|
|
int crc_error_cnt;
|
|
ret = 0;
|
|
bits = 0;
|
|
crc_error_cnt = 3;
|
|
__osSiGetAccess();
|
|
while (true) {
|
|
__osPfsRequestData(CONT_CMD_REQUEST_STATUS);
|
|
ret = __osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
|
osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
|
|
ret = __osSiRawStartDma(OS_READ, &__osPfsPifRam);
|
|
osRecvMesg(queue, &dummy, OS_MESG_BLOCK);
|
|
__osPfsGetInitData(&bitpattern, data);
|
|
for (channel = 0; channel < _osContNumControllers; channel++) {
|
|
if ((data[channel].status & CONT_ADDR_CRC_ER) == 0) {
|
|
crc_error_cnt--;
|
|
break;
|
|
}
|
|
}
|
|
if (_osContNumControllers == channel) {
|
|
crc_error_cnt = 0;
|
|
}
|
|
if (crc_error_cnt < 1) {
|
|
for (channel = 0; channel < _osContNumControllers; channel++) {
|
|
if (data[channel].errnum == 0 && (data[channel].status & CONT_CARD_ON) != 0) {
|
|
bits |= 1 << channel;
|
|
}
|
|
}
|
|
__osSiRelAccess();
|
|
*pattern = bits;
|
|
return ret;
|
|
}
|
|
}
|
|
}
|
|
|
|
void __osPfsRequestData(u8 cmd) {
|
|
u8* ptr;
|
|
__OSContRequesFormat requestformat;
|
|
int i;
|
|
|
|
__osContLastCmd = cmd;
|
|
|
|
for (i = 0; i < ARRLEN(__osPfsPifRam.ramarray) + 1; i++) { // also clear pifstatus
|
|
__osPfsPifRam.ramarray[i] = 0;
|
|
}
|
|
|
|
__osPfsPifRam.pifstatus = CONT_CMD_EXE;
|
|
|
|
ptr = (u8*) &__osPfsPifRam;
|
|
requestformat.dummy = CONT_CMD_NOP;
|
|
requestformat.txsize = CONT_CMD_REQUEST_STATUS_TX;
|
|
requestformat.rxsize = CONT_CMD_REQUEST_STATUS_RX;
|
|
requestformat.cmd = cmd;
|
|
requestformat.typeh = CONT_CMD_NOP;
|
|
requestformat.typel = CONT_CMD_NOP;
|
|
requestformat.status = CONT_CMD_NOP;
|
|
requestformat.dummy1 = CONT_CMD_NOP;
|
|
for (i = 0; i < _osContNumControllers; i++) {
|
|
*(__OSContRequesFormat*) ptr = requestformat;
|
|
ptr += sizeof(__OSContRequesFormat);
|
|
}
|
|
*ptr = CONT_CMD_END;
|
|
}
|
|
|
|
void __osPfsGetInitData(u8* pattern, OSContStatus* data) {
|
|
u8* ptr;
|
|
__OSContRequesFormat requestformat;
|
|
int i;
|
|
u8 bits;
|
|
bits = 0;
|
|
ptr = (u8*) &__osPfsPifRam;
|
|
for (i = 0; i < _osContNumControllers; i++, ptr += sizeof(__OSContRequesFormat)) {
|
|
requestformat = *(__OSContRequesFormat*) ptr;
|
|
data->errnum = CHNL_ERR(requestformat);
|
|
if (data->errnum == 0) {
|
|
data->type = (requestformat.typel << 8) | (requestformat.typeh);
|
|
data->status = requestformat.status;
|
|
bits |= 1 << i;
|
|
}
|
|
data++;
|
|
}
|
|
*pattern = bits;
|
|
}
|