mirror of
https://github.com/HarbourMasters/2ship2harkinian.git
synced 2024-11-24 06:29:59 +00:00
Yet another libultra cleanup (#1384)
* os symbols * various variables * more variables * more cleanup * yeet HW_REG * OS_PHYSICAL_TO_K0 and other cleanups * Rename r4300.h * migrate pimgr data and cleanup on initialize.c * rename osFlash symbols * cleanup gu * vimodes * yeet rmon, do libc files * some os files * hardwareinterrupt * cleanup a lot of os files * cleanup osVirtualToPhysical * various io files * another io chunk * final io chunk * yeet hardware.h * yeet PHYSICAL_TO_VIRTUAL and VIRTUAL_TO_PHYSICAL * fix typo * fix merge * remove global.h from libultra files * fixes and format * brief explanation * review * review * review * review * SEGMENTED_TO_K0 * Revert "SEGMENTED_TO_K0" This reverts commit f8d62d670f91af401feb56489e1cbc45a1260049. * take two * bss * bss
This commit is contained in:
parent
6aaeb80f99
commit
6475196f0f
@ -142,8 +142,6 @@ typedef struct {
|
||||
/* 0x7 */ s8 stick_y;
|
||||
} __OSContReadFormat;
|
||||
|
||||
|
||||
// Original name: __OSContRequesFormat
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 align;
|
||||
/* 0x01 */ u8 txsize;
|
||||
@ -153,7 +151,7 @@ typedef struct {
|
||||
/* 0x05 */ u8 typel;
|
||||
/* 0x06 */ u8 status;
|
||||
/* 0x07 */ u8 align1;
|
||||
} __OSContRequestHeader; // size = 0x8
|
||||
} __OSContRequesFormat; // size = 0x8
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 txsize;
|
||||
|
@ -1,36 +0,0 @@
|
||||
#ifndef _ULTRA64_HARDWARE_H_
|
||||
#define _ULTRA64_HARDWARE_H_
|
||||
|
||||
// TODO: not real libultra header. Refactor to R4300.h
|
||||
|
||||
// Segment Wrapper
|
||||
// Uncached RDRAM
|
||||
#define KSEG1 0xA0000000 // 0xA0000000 - 0xBFFFFFFF Physical memory, uncached, unmapped
|
||||
#define RDRAM_UNCACHED KSEG1
|
||||
|
||||
// Cached RDRAM
|
||||
#define KSEG0 0x80000000 // 0x80000000 - 0x9FFFFFFF Physical memory, cached, unmapped
|
||||
#define RDRAM_CACHED KSEG0
|
||||
|
||||
// Volatile access wrapper, enforcing uncached memory
|
||||
#define HW_REG(reg, type) *(volatile type*)((reg) | KSEG1)
|
||||
|
||||
#define TMEM_SIZE 0x1000
|
||||
|
||||
#define MI_INIT_MODE_REG 0x04300000
|
||||
#define MI_MODE_REG MI_INIT_MODE_REG
|
||||
#define MI_VERSION_REG 0x04300004
|
||||
#define MI_INTR_REG 0x04300008
|
||||
#define MI_INTR_MASK_REG 0x0430000C
|
||||
|
||||
/* Interrupt pending bits */
|
||||
#define CAUSE_IP8 0x00008000 /* External level 8 pending - COMPARE */
|
||||
#define CAUSE_IP7 0x00004000 /* External level 7 pending - INT4 */
|
||||
#define CAUSE_IP6 0x00002000 /* External level 6 pending - INT3 */
|
||||
#define CAUSE_IP5 0x00001000 /* External level 5 pending - INT2 */
|
||||
#define CAUSE_IP4 0x00000800 /* External level 4 pending - INT1 */
|
||||
#define CAUSE_IP3 0x00000400 /* External level 3 pending - INT0 */
|
||||
#define CAUSE_SW2 0x00000200 /* Software level 2 pending */
|
||||
#define CAUSE_SW1 0x00000100 /* Software level 1 pending */
|
||||
|
||||
#endif
|
@ -24,4 +24,15 @@
|
||||
#include "os_vi.h"
|
||||
#include "os_voice.h"
|
||||
|
||||
/*
|
||||
* Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager),
|
||||
* SIM (SI Manager)
|
||||
*
|
||||
*/
|
||||
#define OS_PIM_STACKSIZE 4096
|
||||
#define OS_VIM_STACKSIZE 4096
|
||||
#define OS_SIM_STACKSIZE 4096
|
||||
|
||||
#define OS_MIN_STACKSIZE 72
|
||||
|
||||
#endif
|
||||
|
@ -7,13 +7,41 @@
|
||||
typedef u32 OSIntMask;
|
||||
typedef u32 OSHWIntr;
|
||||
|
||||
/* Flags for debugging purpose */
|
||||
|
||||
#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */
|
||||
#define OS_FLAG_FAULT 2 /* CPU fault has occurred */
|
||||
|
||||
/* Interrupt masks */
|
||||
|
||||
#define OS_IM_NONE 0x00000001
|
||||
#define OS_IM_RCP 0x00000401
|
||||
#define OS_IM_SW1 0x00000501
|
||||
#define OS_IM_SW2 0x00000601
|
||||
#define OS_IM_CART 0x00000c01
|
||||
#define OS_IM_PRENMI 0x00001401
|
||||
#define OS_IM_RDBWRITE 0x00002401
|
||||
#define OS_IM_RDBREAD 0x00004401
|
||||
#define OS_IM_COUNTER 0x00008401
|
||||
#define OS_IM_CPU 0x0000FF01
|
||||
#define OS_IM_SP 0x00010401
|
||||
#define OS_IM_SI 0x00020401
|
||||
#define OS_IM_AI 0x00040401
|
||||
#define OS_IM_VI 0x00080401
|
||||
#define OS_IM_PI 0x00100401
|
||||
#define OS_IM_DP 0x00200401
|
||||
#define OS_IM_ALL 0x003FFF01
|
||||
#define RCP_IMASK 0x003F0000
|
||||
#define RCP_IMASKSHIFT 16
|
||||
|
||||
|
||||
OSIntMask osGetIntMask(void);
|
||||
OSIntMask osSetIntMask(OSIntMask im);
|
||||
|
||||
|
||||
// Internal
|
||||
void __osSetHWIntrRoutine(OSHWIntr idx, OSMesgQueue* queue, OSMesg msg);
|
||||
void __osGetHWIntrRoutine(OSHWIntr idx, OSMesgQueue** outQueue, OSMesg* outMsg);
|
||||
void __osSetHWIntrRoutine(OSHWIntr interrupt, s32 (*handler)(void), void* stackEnd);
|
||||
void __osGetHWIntrRoutine(OSHWIntr interrupt, s32 (**handler)(void), void** stackEnd);
|
||||
void __osSetGlobalIntMask(OSHWIntr mask);
|
||||
void __osResetGlobalIntMask(OSHWIntr mask);
|
||||
|
||||
|
@ -7,18 +7,8 @@
|
||||
#include "os_internal_rsp.h"
|
||||
|
||||
typedef struct __osHwInt {
|
||||
/* 0x00 */ OSMesgQueue* queue;
|
||||
/* 0x04 */ OSMesg msg;
|
||||
/* 0x00 */ s32 (*handler)(void);
|
||||
/* 0x04 */ void* stackEnd;
|
||||
} __osHwInt; // size = 0x08
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u32 initialized;
|
||||
/* 0x04 */ OSThread* mgrThread;
|
||||
/* 0x08 */ OSMesgQueue* cmdQueue;
|
||||
/* 0x0C */ OSMesgQueue* eventQueue;
|
||||
/* 0x10 */ OSMesgQueue* accessQueue;
|
||||
/* 0x14 */ s32 (*piDmaCallback)(s32, uintptr_t, void*, size_t);
|
||||
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, uintptr_t, void*, size_t);
|
||||
} OSMgrArgs; // size = 0x1C
|
||||
|
||||
#endif
|
||||
|
@ -5,7 +5,7 @@
|
||||
|
||||
u32 __osSpGetStatus(void);
|
||||
void __osSpSetStatus(u32 data);
|
||||
s32 __osSpSetPc(void* pc);
|
||||
s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size);
|
||||
s32 __osSpSetPc(u32 pc);
|
||||
s32 __osSpRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size);
|
||||
|
||||
#endif
|
||||
|
@ -18,7 +18,7 @@ typedef struct OSTimer_s {
|
||||
|
||||
OSTime osGetTime(void);
|
||||
void osSetTime(OSTime ticks);
|
||||
s32 osSetTimer(OSTimer* t, OSTime value, OSTime interval, OSMesgQueue* mq, OSMesg msg);
|
||||
s32 osSetTimer(OSTimer* t, OSTime countdown, OSTime interval, OSMesgQueue* mq, OSMesg msg);
|
||||
s32 osStopTimer(OSTimer* t);
|
||||
|
||||
|
||||
|
@ -115,6 +115,12 @@ typedef struct {
|
||||
|
||||
#define OS_VI_UNK28 28
|
||||
|
||||
extern OSViMode osViModeNtscHpf1;
|
||||
extern OSViMode osViModePalLan1;
|
||||
extern OSViMode osViModeNtscHpn1;
|
||||
extern OSViMode osViModeNtscLan1;
|
||||
extern OSViMode osViModeMpalLan1;
|
||||
extern OSViMode osViModeFpalLan1;
|
||||
|
||||
extern OSViMode osViModeNtscHpf1;
|
||||
extern OSViMode osViModePalLan1;
|
||||
@ -127,7 +133,7 @@ void* osViGetCurrentFramebuffer(void);
|
||||
void* osViGetNextFramebuffer(void);
|
||||
void osViSetXScale(f32 value);
|
||||
void osViSetYScale(f32 value);
|
||||
void osViExtendVStart(u32 a0);
|
||||
void osViExtendVStart(u32 value);
|
||||
void osViSetSpecialFeatures(u32 func);
|
||||
void osViSetMode(OSViMode* modep);
|
||||
void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount);
|
||||
|
@ -5,6 +5,81 @@
|
||||
#include "os_pi.h"
|
||||
#include "libc/stdint.h"
|
||||
|
||||
#define LEO_BASE_REG 0x05000000
|
||||
|
||||
#define LEO_CMD (LEO_BASE_REG + 0x508)
|
||||
#define LEO_STATUS (LEO_BASE_REG + 0x508)
|
||||
|
||||
#define LEO_BM_CTL (LEO_BASE_REG + 0x510)
|
||||
#define LEO_BM_STATUS (LEO_BASE_REG + 0x510)
|
||||
|
||||
#define LEO_SEQ_CTL (LEO_BASE_REG + 0x518)
|
||||
#define LEO_SEQ_STATUS (LEO_BASE_REG + 0x518)
|
||||
|
||||
#define LEO_C2_BUFF (LEO_BASE_REG + 0x000) // C2 Sector Buffer
|
||||
#define LEO_SECTOR_BUFF (LEO_BASE_REG + 0x400) // Data Sector Buffer
|
||||
#define LEO_DATA (LEO_BASE_REG + 0x500) // Data
|
||||
#define LEO_MISC_REG (LEO_BASE_REG + 0x504) // Misc Register
|
||||
#define LEO_CUR_TK (LEO_BASE_REG + 0x50C) // Current Track
|
||||
#define LEO_ERR_SECTOR (LEO_BASE_REG + 0x514) // Sector Error Status
|
||||
#define LEO_CUR_SECTOR (LEO_BASE_REG + 0x51C) // Current Sector
|
||||
#define LEO_HARD_RESET (LEO_BASE_REG + 0x520) // Hard Reset
|
||||
#define LEO_C1_S0 (LEO_BASE_REG + 0x524) // C1
|
||||
#define LEO_HOST_SECBYTE (LEO_BASE_REG + 0x528) // Sector Size (in bytes)
|
||||
#define LEO_C1_S2 (LEO_BASE_REG + 0x52C) // C1
|
||||
#define LEO_SEC_BYTE (LEO_BASE_REG + 0x530) // Sectors per Block, Full Size
|
||||
#define LEO_C1_S4 (LEO_BASE_REG + 0x534) // C1
|
||||
#define LEO_C1_S6 (LEO_BASE_REG + 0x538) // C1
|
||||
#define LEO_CUR_ADDR (LEO_BASE_REG + 0x53C) // Current Address?
|
||||
#define LEO_ID_REG (LEO_BASE_REG + 0x540) // ID
|
||||
#define LEO_TEST_REG (LEO_BASE_REG + 0x544) // Test Read
|
||||
#define LEO_TEST_PIN_SEL (LEO_BASE_REG + 0x548) // Test Write
|
||||
#define LEO_RAM_ADDR (LEO_BASE_REG + 0x580) // Microsequencer RAM
|
||||
|
||||
#define LEO_STATUS_PRESENCE_MASK 0xFFFF
|
||||
|
||||
#define LEO_STATUS_DATA_REQUEST 0x40000000
|
||||
#define LEO_STATUS_C2_TRANSFER 0x10000000
|
||||
#define LEO_STATUS_BUFFER_MANAGER_ERROR 0x08000000
|
||||
#define LEO_STATUS_BUFFER_MANAGER_INTERRUPT 0x04000000
|
||||
#define LEO_STATUS_MECHANIC_INTERRUPT 0x02000000
|
||||
#define LEO_STATUS_DISK_PRESENT 0x01000000
|
||||
#define LEO_STATUS_BUSY_STATE 0x00800000
|
||||
#define LEO_STATUS_RESET_STATE 0x00400000
|
||||
#define LEO_STATUS_MOTOR_NOT_SPINNING 0x00100000
|
||||
#define LEO_STATUS_HEAD_RETRACTED 0x00080000
|
||||
#define LEO_STATUS_WRITE_PROTECT_ERROR 0x00040000
|
||||
#define LEO_STATUS_MECHANIC_ERROR 0x00020000
|
||||
#define LEO_STATUS_DISK_CHANGE 0x00010000
|
||||
|
||||
#define LEO_STATUS_MODE_MASK (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED)
|
||||
#define LEO_STATUS_MODE_SLEEP (LEO_STATUS_MOTOR_NOT_SPINNING | LEO_STATUS_HEAD_RETRACTED)
|
||||
#define LEO_STATUS_MODE_STANDBY (LEO_STATUS_HEAD_RETRACTED)
|
||||
#define LEO_STATUS_MODE_ACTIVE 0
|
||||
|
||||
#define LEO_CUR_TK_INDEX_LOCK 0x60000000
|
||||
|
||||
#define LEO_BM_STATUS_RUNNING 0x80000000 // Running
|
||||
#define LEO_BM_STATUS_ERROR 0x04000000 // Error
|
||||
#define LEO_BM_STATUS_MICRO 0x02000000 // Micro Status?
|
||||
#define LEO_BM_STATUS_BLOCK 0x01000000 // Block Transfer
|
||||
#define LEO_BM_STATUS_C1CORRECTION 0x00800000 // C1 Correction
|
||||
#define LEO_BM_STATUS_C1DOUBLE 0x00400000 // C1 Double
|
||||
#define LEO_BM_STATUS_C1SINGLE 0x00200000 // C1 Single
|
||||
#define LEO_BM_STATUS_C1ERROR 0x00010000 // C1 Error
|
||||
|
||||
#define LEO_BM_CTL_START 0x80000000 // Start Buffer Manager
|
||||
#define LEO_BM_CTL_MODE 0x40000000 // Buffer Manager Mode
|
||||
#define LEO_BM_CTL_IMASK 0x20000000 // BM Interrupt Mask
|
||||
#define LEO_BM_CTL_RESET 0x10000000 // Buffer Manager Reset
|
||||
#define LEO_BM_CTL_DISABLE_OR 0x08000000 // Disable OR Check?
|
||||
#define LEO_BM_CTL_DISABLE_C1 0x04000000 // Disable C1 Correction
|
||||
#define LEO_BM_CTL_BLOCK 0x02000000 // Block Transfer
|
||||
#define LEO_BM_CTL_CLR_MECHANIC_INTR 0x01000000 // Mechanic Interrupt Reset
|
||||
|
||||
#define LEO_BM_CTL_CONTROL_MASK 0xFF000000
|
||||
#define LEO_BM_CTL_SECTOR_MASK 0x00FF0000
|
||||
#define LEO_BM_CTL_SECTOR_SHIFT 16
|
||||
|
||||
extern OSDevMgr __osPiDevMgr;
|
||||
extern OSPiHandle* __osCurrentHandle[];
|
||||
|
@ -1,16 +1,16 @@
|
||||
#ifndef ALIGNMENT_H
|
||||
#define ALIGNMENT_H
|
||||
|
||||
#include "attributes.h"
|
||||
|
||||
#define ALIGN8(val) (((val) + 7) & ~7)
|
||||
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
|
||||
#define ALIGN32(val) (((val) + 0x1F) & ~0x1F)
|
||||
#define ALIGN64(val) (((val) + 0x3F) & ~0x3F)
|
||||
#define ALIGN256(val) (((val) + 0xFF) & ~0xFF)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define ALIGNED8 __attribute__ ((aligned (8)))
|
||||
#else
|
||||
#define ALIGNED8
|
||||
#ifndef ALIGNED
|
||||
#define ALIGNED(x) __attribute__ ((aligned (x)))
|
||||
#endif
|
||||
|
||||
#ifdef __sgi /* IDO compiler */
|
||||
|
15
include/attributes.h
Normal file
15
include/attributes.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef ATTRIBUTES_H
|
||||
#define ATTRIBUTES_H
|
||||
|
||||
// If not building with a modern GCC-like compiler then make any use of __attribute__ a no-op
|
||||
#if (!defined(__GNUC__) && !defined(__clang__)) || defined(M2CTX) || defined(__sgi)
|
||||
#ifndef __attribute__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define UNUSED __attribute__((unused))
|
||||
#define FALLTHROUGH __attribute__((fallthrough))
|
||||
#define NORETURN __attribute__((noreturn))
|
||||
|
||||
#endif
|
@ -9,6 +9,8 @@
|
||||
|
||||
struct GameState;
|
||||
|
||||
#define TMEM_SIZE 0x1000
|
||||
|
||||
typedef enum SetupDL {
|
||||
/* 0x00 */ SETUPDL_0,
|
||||
/* 0x01 */ SETUPDL_1,
|
||||
|
@ -21,10 +21,7 @@
|
||||
|
||||
#define ARRAY_COUNT_2D(arr) (ARRAY_COUNT(arr) * ARRAY_COUNT(arr[0]))
|
||||
|
||||
// TODO: After uintptr_t cast change should have an AVOID_UB target that just toggles the KSEG0 bit in the address rather than add/sub 0x80000000
|
||||
#define PHYSICAL_TO_VIRTUAL(addr) ((uintptr_t)(addr) + RDRAM_CACHED)
|
||||
#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - RDRAM_CACHED)
|
||||
#define SEGMENTED_TO_VIRTUAL(addr) (void*)(PHYSICAL_TO_VIRTUAL(gSegments[SEGMENT_NUMBER(addr)]) + SEGMENT_OFFSET(addr))
|
||||
#define SEGMENTED_TO_K0(addr) (void*)((gSegments[SEGMENT_NUMBER(addr)] + K0BASE) + SEGMENT_OFFSET(addr))
|
||||
|
||||
#define GET_ACTIVE_CAM(play) ((play)->cameraPtrs[(play)->activeCamId])
|
||||
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "PR/gu.h"
|
||||
#include "PR/guint.h"
|
||||
#include "PR/controller_voice.h"
|
||||
#include "PR/hardware.h"
|
||||
#include "PR/os.h"
|
||||
#include "PR/osint.h"
|
||||
#include "PR/piint.h"
|
||||
@ -15,7 +14,7 @@
|
||||
#include "PR/sptask.h"
|
||||
#include "PR/rcp.h"
|
||||
#include "PR/rdp.h"
|
||||
#include "PR/r4300.h"
|
||||
#include "PR/R4300.h"
|
||||
#include "PR/ucode.h"
|
||||
#include "PR/viint.h"
|
||||
#include "PR/xstdio.h"
|
||||
|
28
spec
28
spec
@ -42,21 +42,21 @@ beginseg
|
||||
include "build/src/boot/O2/system_malloc.o"
|
||||
include "build/src/boot/O2/rand.o"
|
||||
include "build/src/boot/O2/__osMalloc.o"
|
||||
include "build/src/libultra/rmon/sprintf.o"
|
||||
include "build/src/libultra/libc/sprintf.o"
|
||||
include "build/src/boot/O2/printutils.o"
|
||||
include "build/src/boot/O2/sleep.o"
|
||||
include "build/asm/boot/setcause.text.o"
|
||||
include "build/src/libultra/os/sendmesg.o"
|
||||
include "build/src/libultra/io/pfsfreeblocks.o"
|
||||
include "build/src/libultra/os/viextend.o"
|
||||
include "build/src/libultra/io/viextendvstart.o"
|
||||
include "build/src/libultra/os/stopthread.o"
|
||||
include "build/src/libultra/os/recvmesg.o"
|
||||
include "build/asm/boot/setintmask.text.o"
|
||||
include "build/data/boot/setintmask.rodata.o"
|
||||
include "build/asm/boot/getintmask.text.o"
|
||||
include "build/src/libultra/voice/voicesetword.o"
|
||||
include "build/src/libultra/io/osViModeNtscHpf1.o"
|
||||
include "build/src/libultra/io/osViModePalLan1.o"
|
||||
include "build/src/libultra/vimodes/vimodentschpf1.o"
|
||||
include "build/src/libultra/vimodes/vimodepallan1.o"
|
||||
include "build/asm/boot/guScale.text.o"
|
||||
include "build/src/libultra/gu/sinf.o"
|
||||
include "build/src/libultra/gu/sins.o"
|
||||
@ -108,11 +108,11 @@ beginseg
|
||||
include "build/src/libultra/os/stoptimer.o"
|
||||
include "build/asm/boot/probetlb.text.o"
|
||||
include "build/src/libultra/io/pimgr.o"
|
||||
include "build/data/boot/pimgr.data.o"
|
||||
include "build/src/libultra/io/piacs.o"
|
||||
pad_text
|
||||
include "build/src/libultra/io/devmgr.o"
|
||||
include "build/src/libultra/io/pirawdma.o"
|
||||
include "build/src/libultra/vimodes/vimodentschpn1.o"
|
||||
include "build/src/libultra/io/contpfs.o"
|
||||
include "build/asm/boot/getcount.text.o"
|
||||
pad_text
|
||||
@ -124,7 +124,7 @@ beginseg
|
||||
include "build/src/libultra/os/afterprenmi.o"
|
||||
include "build/src/libultra/io/contquery.o"
|
||||
include "build/src/libultra/gu/lookathil.o"
|
||||
include "build/src/libultra/rmon/xprintf.o"
|
||||
include "build/src/libultra/libc/xprintf.o"
|
||||
include "build/src/libultra/voice/voicecleardictionary.o"
|
||||
include "build/asm/boot/unmaptlball.text.o"
|
||||
include "build/src/libultra/io/epidma.o"
|
||||
@ -169,8 +169,8 @@ beginseg
|
||||
include "build/src/libultra/io/pfsdeletefile.o"
|
||||
include "build/src/libultra/gu/ortho.o"
|
||||
include "build/asm/boot/interrupt.text.o"
|
||||
include "build/src/libultra/io/osViModeNtscLan1.o"
|
||||
include "build/src/libultra/io/osViModeMpalLan1.o"
|
||||
include "build/src/libultra/vimodes/vimodentsclan1.o"
|
||||
include "build/src/libultra/vimodes/vimodempallan1.o"
|
||||
include "build/src/libultra/io/vi.o"
|
||||
include "build/src/libultra/io/viswapcontext.o"
|
||||
include "build/src/libultra/io/pigetcmdq.o"
|
||||
@ -180,12 +180,12 @@ beginseg
|
||||
include "build/src/libultra/gu/coss.o"
|
||||
include "build/src/libultra/os/settime.o"
|
||||
include "build/src/libultra/voice/voicestopread.o"
|
||||
include "build/src/libultra/gu/visetevent.o"
|
||||
include "build/src/libultra/io/visetevent.o"
|
||||
include "build/src/libultra/io/pfsisplug.o"
|
||||
include "build/src/libultra/voice/voicegetstatus.o"
|
||||
include "build/src/libultra/io/cartrominit.o"
|
||||
include "build/src/libultra/gu/guS2DInitBg.o"
|
||||
include "build/data/boot/guS2DInitBg.data.o"
|
||||
include "build/src/libultra/gu/us2dex.o"
|
||||
include "build/src/libultra/vimodes/vimodefpallan1.o"
|
||||
include "build/src/libultra/io/pfsselectbank.o"
|
||||
include "build/src/libultra/io/contsetch.o"
|
||||
include "build/asm/boot/setfpccsr.text.o"
|
||||
@ -203,10 +203,10 @@ beginseg
|
||||
include "build/src/libultra/io/contramwrite.o"
|
||||
include "build/src/libultra/io/epirawwrite.o"
|
||||
include "build/src/libultra/os/settimer.o"
|
||||
include "build/data/boot/__libm_qnan_f.rodata.o"
|
||||
include "build/src/libultra/rmon/xldtob.o"
|
||||
include "build/data/boot/libm_vals.rodata.o"
|
||||
include "build/src/libultra/libc/xldtob.o"
|
||||
include "build/src/libultra/libc/ldiv.o"
|
||||
include "build/src/libultra/rmon/xlitob.o"
|
||||
include "build/src/libultra/libc/xlitob.o"
|
||||
include "build/src/libultra/io/sirawwrite.o"
|
||||
include "build/src/libultra/io/spgetstat.o"
|
||||
include "build/src/libultra/io/spsetstat.o"
|
||||
|
@ -18,15 +18,15 @@ s32 osAiSetNextBuffer(void* buf, u32 size) {
|
||||
}
|
||||
|
||||
// Originally a call to __osAiDeviceBusy
|
||||
status = HW_REG(AI_STATUS_REG, s32);
|
||||
status = IO_READ(AI_STATUS_REG);
|
||||
if (status & AI_STATUS_FIFO_FULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// OS_K0_TO_PHYSICAL replaces osVirtualToPhysical, this replacement
|
||||
// assumes that only KSEG0 addresses are given
|
||||
HW_REG(AI_DRAM_ADDR_REG, u32) = OS_K0_TO_PHYSICAL(bufAdjusted);
|
||||
HW_REG(AI_LEN_REG, u32) = size;
|
||||
IO_WRITE(AI_DRAM_ADDR_REG, OS_K0_TO_PHYSICAL(bufAdjusted));
|
||||
IO_WRITE(AI_LEN_REG, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,15 @@
|
||||
|
||||
#include "fault_internal.h"
|
||||
#include "fault.h"
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "prevent_bss_reordering2.h"
|
||||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "PR/osint.h"
|
||||
#include "stackcheck.h"
|
||||
#include "z64thread.h"
|
||||
#include "main.h"
|
||||
#include "macros.h"
|
||||
#include "global.h"
|
||||
|
||||
FaultMgr* sFaultInstance;
|
||||
f32 sFaultTimeTotal; // read but not set anywhere
|
||||
|
@ -74,14 +74,14 @@ void Sched_HandleAudioCancel(SchedContext* sched) {
|
||||
osSyncPrintf("AUDIO SP キャンセルします\n");
|
||||
|
||||
if ((sched->curRSPTask != NULL) && (sched->curRSPTask->list.t.type == M_AUDTASK)) {
|
||||
if (!(HW_REG(SP_STATUS_REG, u32) & SP_STATUS_HALT)) {
|
||||
if (!(IO_READ(SP_STATUS_REG) & SP_STATUS_HALT)) {
|
||||
// Attempts to stop AUDIO SP
|
||||
osSyncPrintf("AUDIO SP止めようとします\n");
|
||||
|
||||
HW_REG(SP_STATUS_REG, u32) = SP_SET_HALT;
|
||||
IO_WRITE(SP_STATUS_REG, SP_SET_HALT);
|
||||
|
||||
i = 0;
|
||||
while (!(HW_REG(SP_STATUS_REG, u32) & SP_STATUS_HALT)) {
|
||||
while (!(IO_READ(SP_STATUS_REG) & SP_STATUS_HALT)) {
|
||||
if (i++ > 100) {
|
||||
// AUDIO SP did not stop (10ms timeout)
|
||||
osSyncPrintf("AUDIO SP止まりませんでした(10msタイムアウト)\n");
|
||||
@ -136,14 +136,14 @@ void Sched_HandleGfxCancel(SchedContext* sched) {
|
||||
osSyncPrintf("GRAPH SP キャンセルします\n");
|
||||
|
||||
if ((sched->curRSPTask != NULL) && (sched->curRSPTask->list.t.type == M_GFXTASK)) {
|
||||
if (!(HW_REG(SP_STATUS_REG, u32) & SP_STATUS_HALT)) {
|
||||
if (!(IO_READ(SP_STATUS_REG) & SP_STATUS_HALT)) {
|
||||
// GRAPH SP tries to stop
|
||||
osSyncPrintf("GRAPH SP止めようとします\n");
|
||||
|
||||
HW_REG(SP_STATUS_REG, u32) = SP_SET_HALT;
|
||||
IO_WRITE(SP_STATUS_REG, SP_SET_HALT);
|
||||
|
||||
i = 0;
|
||||
while (!(HW_REG(SP_STATUS_REG, u32) & SP_STATUS_HALT)) {
|
||||
while (!(IO_READ(SP_STATUS_REG) & SP_STATUS_HALT)) {
|
||||
if (i++ > 100) {
|
||||
// GRAPH SP did not stop (10ms timeout)
|
||||
osSyncPrintf("GRAPH SP止まりませんでした(10msタイムアウト)\n");
|
||||
|
@ -1098,7 +1098,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
|
||||
}
|
||||
|
||||
void Actor_SetObjectDependency(PlayState* play, Actor* actor) {
|
||||
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment);
|
||||
gSegments[0x06] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment);
|
||||
}
|
||||
|
||||
void Actor_Init(Actor* actor, PlayState* play) {
|
||||
|
@ -3957,7 +3957,7 @@ s32 BgCheck_SphVsFirstDynaPoly(CollisionContext* colCtx, u16 xpFlags, CollisionP
|
||||
}
|
||||
|
||||
/**
|
||||
* SEGMENTED_TO_VIRTUAL CollisionHeader members
|
||||
* SEGMENTED_TO_K0 CollisionHeader members
|
||||
*/
|
||||
void CollisionHeader_SegmentedToVirtual(CollisionHeader* colHeader) {
|
||||
colHeader->vtxList = Lib_SegmentedToVirtual(colHeader->vtxList);
|
||||
|
@ -50,7 +50,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, TexturePtr texture) {
|
||||
SkinMatrix_SetScale(&mfScale, scale, scale, scale);
|
||||
SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTrans11DA0);
|
||||
SkinMatrix_MtxFMtxFMult(&mfTrans11DA0, &mfScale, &mfResult);
|
||||
gSegments[0x06] = VIRTUAL_TO_PHYSICAL(objectPtr);
|
||||
gSegments[0x06] = OS_K0_TO_PHYSICAL(objectPtr);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr);
|
||||
|
||||
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult);
|
||||
|
@ -133,7 +133,7 @@ EnDoor* EnHy_FindNearestDoor(Actor* actor, PlayState* play) {
|
||||
}
|
||||
|
||||
void EnHy_ChangeObjectAndAnim(EnHy* enHy, PlayState* play, s16 animIndex) {
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjectSlot].segment);
|
||||
gSegments[6] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjectSlot].segment);
|
||||
EnHy_ChangeAnim(&enHy->skelAnime, animIndex);
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ s32 EnHy_UpdateSkelAnime(EnHy* enHy, PlayState* play) {
|
||||
s32 isUpdated = false;
|
||||
|
||||
if (enHy->actor.draw != NULL) {
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjectSlot].segment);
|
||||
gSegments[6] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[enHy->animObjectSlot].segment);
|
||||
SkelAnime_Update(&enHy->skelAnime);
|
||||
isUpdated = true;
|
||||
}
|
||||
@ -168,7 +168,7 @@ s32 EnHy_Init(EnHy* enHy, PlayState* play, FlexSkeletonHeader* skeletonHeaderSeg
|
||||
enHy->actor.objectSlot = enHy->skelLowerObjectSlot;
|
||||
isInitialized = true;
|
||||
ActorShape_Init(&enHy->actor.shape, 0.0f, NULL, 0.0f);
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[enHy->actor.objectSlot].segment);
|
||||
gSegments[6] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[enHy->actor.objectSlot].segment);
|
||||
SkelAnime_InitFlex(play, &enHy->skelAnime, skeletonHeaderSeg, NULL, enHy->jointTable, enHy->morphTable,
|
||||
ENHY_LIMB_MAX);
|
||||
EnHy_ChangeObjectAndAnim(enHy, play, animIndex);
|
||||
|
@ -699,14 +699,14 @@ void Lib_Nop801004FC(void) {
|
||||
}
|
||||
|
||||
void* Lib_SegmentedToVirtual(void* ptr) {
|
||||
return SEGMENTED_TO_VIRTUAL(ptr);
|
||||
return SEGMENTED_TO_K0(ptr);
|
||||
}
|
||||
|
||||
void* Lib_SegmentedToVirtualNull(void* ptr) {
|
||||
if (((uintptr_t)ptr >> 28) == 0) {
|
||||
return ptr;
|
||||
} else {
|
||||
return SEGMENTED_TO_VIRTUAL(ptr);
|
||||
return SEGMENTED_TO_K0(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -719,7 +719,7 @@ void* Lib_VirtualToPhysical(void* ptr) {
|
||||
if (ptr == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (void*)VIRTUAL_TO_PHYSICAL(ptr);
|
||||
return (void*)OS_K0_TO_PHYSICAL(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -732,6 +732,6 @@ void* Lib_PhysicalToVirtual(void* ptr) {
|
||||
if (ptr == NULL) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (void*)PHYSICAL_TO_VIRTUAL(ptr);
|
||||
return OS_PHYSICAL_TO_K0(ptr);
|
||||
}
|
||||
}
|
||||
|
@ -923,9 +923,9 @@ void Play_UpdateMain(PlayState* this) {
|
||||
u8 freezeFlashTimer;
|
||||
s32 sp5C = false;
|
||||
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);
|
||||
gSegments[4] = OS_K0_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSegments[5] = OS_K0_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSegments[2] = OS_K0_TO_PHYSICAL(this->sceneSegment);
|
||||
|
||||
if (R_PICTO_PHOTO_STATE == PICTO_PHOTO_STATE_PROCESS) {
|
||||
R_PICTO_PHOTO_STATE = PICTO_PHOTO_STATE_READY;
|
||||
@ -1155,9 +1155,9 @@ void Play_DrawMain(PlayState* this) {
|
||||
|
||||
OPEN_DISPS(gfxCtx);
|
||||
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSegments[5] = VIRTUAL_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);
|
||||
gSegments[4] = OS_K0_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSegments[5] = OS_K0_TO_PHYSICAL(this->objectCtx.slots[this->objectCtx.subKeepSlot].segment);
|
||||
gSegments[2] = OS_K0_TO_PHYSICAL(this->sceneSegment);
|
||||
|
||||
gSPSegment(POLY_OPA_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x04, this->objectCtx.slots[this->objectCtx.mainKeepSlot].segment);
|
||||
@ -1605,7 +1605,7 @@ void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn) {
|
||||
this->sceneConfig = scene->drawConfig;
|
||||
this->sceneSegment = Play_LoadFile(this, &scene->segment);
|
||||
scene->unk_D = 0;
|
||||
gSegments[2] = VIRTUAL_TO_PHYSICAL(this->sceneSegment);
|
||||
gSegments[2] = OS_K0_TO_PHYSICAL(this->sceneSegment);
|
||||
Play_InitScene(this, spawn);
|
||||
Room_AllocateAndLoad(this, &this->roomCtx);
|
||||
}
|
||||
|
@ -2590,7 +2590,7 @@ void Player_DrawGetItemImpl(PlayState* play, Player* player, Vec3f* refPos, s32
|
||||
|
||||
OPEN_DISPS(play->state.gfxCtx);
|
||||
|
||||
gSegments[6] = VIRTUAL_TO_PHYSICAL(player->giObjectSegment);
|
||||
gSegments[6] = OS_K0_TO_PHYSICAL(player->giObjectSegment);
|
||||
|
||||
gSPSegment(POLY_OPA_DISP++, 0x06, player->giObjectSegment);
|
||||
gSPSegment(POLY_XLU_DISP++, 0x06, player->giObjectSegment);
|
||||
@ -2852,7 +2852,7 @@ void func_80127488(PlayState* play, Player* player, u8 alpha) {
|
||||
}
|
||||
|
||||
void Player_DrawCouplesMask(PlayState* play, Player* player) {
|
||||
gSegments[0xA] = VIRTUAL_TO_PHYSICAL(player->maskObjectSegment);
|
||||
gSegments[0xA] = OS_K0_TO_PHYSICAL(player->maskObjectSegment);
|
||||
AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_meoto_Matanimheader_001CD8));
|
||||
}
|
||||
|
||||
@ -2884,7 +2884,7 @@ void Player_DrawCircusLeadersMask(PlayState* play, Player* player) {
|
||||
Matrix_Scale(scaleXZ, scaleY, scaleXZ, MTXMODE_APPLY);
|
||||
|
||||
gSPMatrix(&gfx[0], Matrix_NewMtx(play->state.gfxCtx), G_MTX_PUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
|
||||
gSPSegment(&gfx[1], 0x08, VIRTUAL_TO_PHYSICAL(SEGMENTED_TO_VIRTUAL(gEffBubble1Tex)));
|
||||
gSPSegment(&gfx[1], 0x08, OS_K0_TO_PHYSICAL(SEGMENTED_TO_K0(gEffBubble1Tex)));
|
||||
gDPSetPrimColor(&gfx[2], 0, 0, 255, 255, 255, 255);
|
||||
gDPSetEnvColor(&gfx[3], 150, 150, 150, 0);
|
||||
gSPDisplayList(&gfx[4], gEffBubbleDL);
|
||||
@ -2940,7 +2940,7 @@ void Player_DrawBlastMask(PlayState* play, Player* player) {
|
||||
if (player->blastMaskTimer != 0) {
|
||||
s32 alpha;
|
||||
|
||||
gSegments[0xA] = VIRTUAL_TO_PHYSICAL(player->maskObjectSegment);
|
||||
gSegments[0xA] = OS_K0_TO_PHYSICAL(player->maskObjectSegment);
|
||||
|
||||
AnimatedMat_DrawOpa(play, Lib_SegmentedToVirtual(&object_mask_bakuretu_Matanimheader_0011F8));
|
||||
|
||||
|
@ -574,7 +574,7 @@ s32 Room_HandleLoadCallbacks(PlayState* play, RoomContext* roomCtx) {
|
||||
if (osRecvMesg(&roomCtx->loadQueue, NULL, OS_MESG_NOBLOCK) == 0) {
|
||||
roomCtx->status = 0;
|
||||
roomCtx->curRoom.segment = roomCtx->activeRoomVram;
|
||||
gSegments[3] = VIRTUAL_TO_PHYSICAL(roomCtx->activeRoomVram);
|
||||
gSegments[3] = OS_K0_TO_PHYSICAL(roomCtx->activeRoomVram);
|
||||
|
||||
Scene_ExecuteCommands(play, roomCtx->curRoom.segment);
|
||||
func_80123140(play, GET_PLAYER(play));
|
||||
@ -605,7 +605,7 @@ RoomDrawHandler sRoomDrawHandlers[] = {
|
||||
|
||||
void Room_Draw(PlayState* play, Room* room, u32 flags) {
|
||||
if (room->segment != NULL) {
|
||||
gSegments[3] = VIRTUAL_TO_PHYSICAL(room->segment);
|
||||
gSegments[3] = OS_K0_TO_PHYSICAL(room->segment);
|
||||
sRoomDrawHandlers[room->roomShape->base.type](play, room, flags);
|
||||
}
|
||||
return;
|
||||
|
@ -65,7 +65,7 @@ void Object_InitContext(GameState* gameState, ObjectContext* objectCtx) {
|
||||
objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize);
|
||||
objectCtx->mainKeepSlot = Object_SpawnPersistent(objectCtx, GAMEPLAY_KEEP);
|
||||
|
||||
gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->slots[objectCtx->mainKeepSlot].segment);
|
||||
gSegments[4] = OS_K0_TO_PHYSICAL(objectCtx->slots[objectCtx->mainKeepSlot].segment);
|
||||
}
|
||||
|
||||
void Object_UpdateEntries(ObjectContext* objectCtx) {
|
||||
@ -240,7 +240,7 @@ void Scene_CommandSpecialFiles(PlayState* play, SceneCmd* cmd) {
|
||||
if (cmd->specialFiles.subKeepId != 0) {
|
||||
play->objectCtx.subKeepSlot = Object_SpawnPersistent(&play->objectCtx, cmd->specialFiles.subKeepId);
|
||||
// TODO: Segment number enum?
|
||||
gSegments[0x05] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[play->objectCtx.subKeepSlot].segment);
|
||||
gSegments[0x05] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[play->objectCtx.subKeepSlot].segment);
|
||||
}
|
||||
|
||||
if (cmd->specialFiles.naviQuestHintFileId != NAVI_QUEST_HINTS_NONE) {
|
||||
|
@ -1,19 +1,25 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "PR/os_internal_flash.h"
|
||||
#include "alignment.h"
|
||||
#include "macros.h"
|
||||
|
||||
u32 __osFlashID[4];
|
||||
OSIoMesg __osFlashMsg;
|
||||
OSMesgQueue __osFlashMessageQ;
|
||||
OSPiHandle __osFlashHandler;
|
||||
u32 __osFlashID[4] ALIGNED(8);
|
||||
OSIoMesg __osFlashMsg ALIGNED(8);
|
||||
OSMesgQueue __osFlashMessageQ ALIGNED(8);
|
||||
OSPiHandle __osFlashHandler ALIGNED(8);
|
||||
OSMesg __osFlashMsgBuf[1];
|
||||
s32 __osFlashVersion;
|
||||
static s32 sBssPad[5];
|
||||
|
||||
uintptr_t osFlashGetAddr(u32 pageNum) {
|
||||
// Account for hadware bug in old flash where the address bits are shifted 1-off where they should be
|
||||
uintptr_t addr = (__osFlashVersion == OLD_FLASH) ? pageNum * (FLASH_BLOCK_SIZE >> 1) : pageNum * FLASH_BLOCK_SIZE;
|
||||
uintptr_t addr;
|
||||
|
||||
if (__osFlashVersion == OLD_FLASH) {
|
||||
// Account for hardware bug in old flash where the address bits are shifted 1-off where they should be
|
||||
addr = pageNum * (FLASH_BLOCK_SIZE >> 1);
|
||||
} else {
|
||||
addr = pageNum * FLASH_BLOCK_SIZE;
|
||||
}
|
||||
|
||||
return addr;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
/**
|
||||
* Compute the sine of a hex angle and return a short, using the formula cos(x) = sin(x+pi).
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "macros.h"
|
||||
|
||||
void guLookAtF(f32 mf[4][4], f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt, f32 xUp, f32 yUp, f32 zUp) {
|
||||
f32 length;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "macros.h"
|
||||
|
||||
void guLookAtHiliteF(f32 mf[4][4], LookAt* l, Hilite* h, f32 xEye, f32 yEye, f32 zEye, f32 xAt, f32 yAt, f32 zAt,
|
||||
f32 xUp, f32 yUp, f32 zUp, f32 xl1, f32 yl1, f32 zl1, /* light 1 direction */
|
||||
|
@ -1,8 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void guOrthoF(float m[4][4], float l, float r, float b, float t, float n, float f, float scale) {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
guMtxIdentF(m);
|
||||
m[0][0] = 2 / (r - l);
|
||||
m[1][1] = 2 / (t - b);
|
||||
@ -20,6 +21,7 @@ void guOrthoF(float m[4][4], float l, float r, float b, float t, float n, float
|
||||
|
||||
void guOrtho(Mtx* m, float l, float r, float b, float t, float n, float f, float scale) {
|
||||
float mf[4][4];
|
||||
|
||||
guOrthoF(mf, l, r, b, t, n, f, scale);
|
||||
guMtxF2L(mf, m);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
|
||||
float cot;
|
||||
@ -36,6 +36,7 @@ void guPerspectiveF(float mf[4][4], u16* perspNorm, float fovy, float aspect, fl
|
||||
|
||||
void guPerspective(Mtx* m, u16* perspNorm, float fovy, float aspect, float near, float far, float scale) {
|
||||
float mf[4][4];
|
||||
|
||||
guPerspectiveF(mf, perspNorm, fovy, aspect, near, far, scale);
|
||||
guMtxF2L(mf, m);
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
/**
|
||||
* guPositionF
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
void guRotateF(float m[4][4], float a, float x, float y, float z) {
|
||||
static float D_80097F90 = M_PI / 180.0f;
|
||||
static float dtor = M_PI / 180.0f;
|
||||
float sine;
|
||||
float cosine;
|
||||
float ab;
|
||||
@ -14,7 +15,7 @@ void guRotateF(float m[4][4], float a, float x, float y, float z) {
|
||||
|
||||
guNormalize(&x, &y, &z);
|
||||
|
||||
a = a * D_80097F90;
|
||||
a *= dtor;
|
||||
|
||||
sine = sinf(a);
|
||||
cosine = cosf(a);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __builtin_sqrtf sqrtf
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/gs2dex.h"
|
||||
|
||||
void guS2DInitBg(uObjBg* bg) {
|
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
u32 osAiGetLength(void) {
|
||||
return HW_REG(AI_LEN_REG, u32);
|
||||
return IO_READ(AI_LEN_REG);
|
||||
}
|
||||
|
@ -1,20 +1,20 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 osAiSetFrequency(u32 frequency) {
|
||||
u8 bitrate;
|
||||
f32 dacRateF = ((f32)osViClock / frequency) + 0.5f;
|
||||
u32 dacRate = dacRateF;
|
||||
|
||||
if (dacRate < 132) {
|
||||
if (dacRate < AI_MIN_DAC_RATE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
bitrate = (dacRate / 66);
|
||||
if (bitrate > 16) {
|
||||
bitrate = 16;
|
||||
if (bitrate > AI_MAX_BIT_RATE) {
|
||||
bitrate = AI_MAX_BIT_RATE;
|
||||
}
|
||||
|
||||
HW_REG(AI_DACRATE_REG, u32) = dacRate - 1;
|
||||
HW_REG(AI_BITRATE_REG, u32) = bitrate - 1;
|
||||
IO_WRITE(AI_DACRATE_REG, dacRate - 1);
|
||||
IO_WRITE(AI_BITRATE_REG, bitrate - 1);
|
||||
return osViClock / (s32)dacRate;
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "libc/stdbool.h"
|
||||
#include "alignment.h"
|
||||
|
||||
OSPiHandle __CartRomHandle;
|
||||
OSPiHandle __CartRomHandle ALIGNED(8);
|
||||
|
||||
OSPiHandle* osCartRomInit(void) {
|
||||
register u32 initialConfig;
|
||||
@ -22,36 +24,36 @@ OSPiHandle* osCartRomInit(void) {
|
||||
|
||||
sCartRomNeedsInit = false;
|
||||
__CartRomHandle.type = DEVICE_TYPE_CART;
|
||||
__CartRomHandle.baseAddress = 0xB0000000;
|
||||
__CartRomHandle.domain = 0;
|
||||
__CartRomHandle.baseAddress = PHYS_TO_K1(PI_DOM1_ADDR2);
|
||||
__CartRomHandle.domain = PI_DOMAIN1;
|
||||
__CartRomHandle.speed = 0;
|
||||
bzero(&__CartRomHandle.transferInfo, sizeof(__OSTranxInfo));
|
||||
|
||||
/* Uses `status & PI_STATUS_ERROR` in OoT */
|
||||
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
|
||||
while (status = IO_READ(PI_STATUS_REG), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
|
||||
;
|
||||
}
|
||||
|
||||
lastLatency = HW_REG(PI_BSD_DOM1_LAT_REG, u32);
|
||||
lastPageSize = HW_REG(PI_BSD_DOM1_PGS_REG, u32);
|
||||
lastRelDuration = HW_REG(PI_BSD_DOM1_RLS_REG, u32);
|
||||
lastPulse = HW_REG(PI_BSD_DOM1_PWD_REG, u32);
|
||||
lastLatency = IO_READ(PI_BSD_DOM1_LAT_REG);
|
||||
lastPageSize = IO_READ(PI_BSD_DOM1_PGS_REG);
|
||||
lastRelDuration = IO_READ(PI_BSD_DOM1_RLS_REG);
|
||||
lastPulse = IO_READ(PI_BSD_DOM1_PWD_REG);
|
||||
|
||||
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = 0xFF;
|
||||
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = 0;
|
||||
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = 3;
|
||||
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = 0xFF;
|
||||
IO_WRITE(PI_BSD_DOM1_LAT_REG, 0xFF);
|
||||
IO_WRITE(PI_BSD_DOM1_PGS_REG, 0);
|
||||
IO_WRITE(PI_BSD_DOM1_RLS_REG, 3);
|
||||
IO_WRITE(PI_BSD_DOM1_PWD_REG, 0xFF);
|
||||
|
||||
initialConfig = HW_REG(__CartRomHandle.baseAddress, u32);
|
||||
initialConfig = IO_READ(__CartRomHandle.baseAddress);
|
||||
__CartRomHandle.latency = initialConfig & 0xFF;
|
||||
__CartRomHandle.pageSize = (initialConfig >> 0x10) & 0xF;
|
||||
__CartRomHandle.relDuration = (initialConfig >> 0x14) & 0xF;
|
||||
__CartRomHandle.pulse = (initialConfig >> 8) & 0xFF;
|
||||
|
||||
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = lastLatency;
|
||||
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = lastPageSize;
|
||||
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = lastRelDuration;
|
||||
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = lastPulse;
|
||||
IO_WRITE(PI_BSD_DOM1_LAT_REG, lastLatency);
|
||||
IO_WRITE(PI_BSD_DOM1_PGS_REG, lastPageSize);
|
||||
IO_WRITE(PI_BSD_DOM1_RLS_REG, lastRelDuration);
|
||||
IO_WRITE(PI_BSD_DOM1_PWD_REG, lastPulse);
|
||||
|
||||
prevInt = __osDisableInt();
|
||||
__CartRomHandle.next = __osPiTable;
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 __osContChannelReset(OSMesgQueue* mq, s32 channel) {
|
||||
s32 i;
|
||||
@ -7,13 +8,13 @@ s32 __osContChannelReset(OSMesgQueue* mq, s32 channel) {
|
||||
|
||||
__osSiGetAccess();
|
||||
|
||||
__osPfsPifRam.status = 1;
|
||||
__osPfsPifRam.status = CONT_CMD_EXE;
|
||||
|
||||
for (i = 0; i < channel; i++) {
|
||||
*bufptr++ = 0;
|
||||
*bufptr++ = CONT_CMD_REQUEST_STATUS;
|
||||
}
|
||||
|
||||
*bufptr++ = 0xFD;
|
||||
*bufptr++ = CONT_CMD_CHANNEL_RESET;
|
||||
*bufptr = CONT_CMD_END;
|
||||
|
||||
__osSiRawStartDma(OS_WRITE, &__osPfsPifRam);
|
||||
|
@ -1,39 +1,9 @@
|
||||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "PR/controller.h"
|
||||
#include "alignment.h"
|
||||
|
||||
__OSInode __osPfsInodeCache ALIGNED(8);
|
||||
|
||||
__OSInode __osPfsInodeCache;
|
||||
OSViMode osViModeNtscHpn1 = {
|
||||
8, // type
|
||||
{
|
||||
// comRegs
|
||||
0x324E, // ctrl
|
||||
0x500, // width
|
||||
0x3E52239, // burst
|
||||
0x20C, // vSync
|
||||
0xC15, // hSync
|
||||
0xC150C15, // leap
|
||||
0x6C02EC, // hStart
|
||||
0x400, // xScale
|
||||
0, // vCurrent
|
||||
},
|
||||
{ // fldRegs
|
||||
{
|
||||
// [0]
|
||||
0x500, // origin
|
||||
0x400, // yScale
|
||||
0x2301FD, // vStart
|
||||
0xE0204, // vBurst
|
||||
2, // vIntr
|
||||
},
|
||||
{
|
||||
// [1]
|
||||
0xA00, // origin
|
||||
0x400, // yScale
|
||||
0x2501FF, // vStart
|
||||
0xE0204, // vBurst
|
||||
2, // vIntr
|
||||
} },
|
||||
};
|
||||
s32 __osPfsInodeCacheChannel = -1;
|
||||
u8 __osPfsInodeCacheBank = 250;
|
||||
|
||||
|
@ -1,19 +1,20 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 osContStartQuery(OSMesgQueue* mq) {
|
||||
s32 ret;
|
||||
|
||||
__osSiGetAccess();
|
||||
|
||||
if (__osContLastPoll != 0) {
|
||||
__osPackRequestData(0);
|
||||
if (__osContLastPoll != CONT_CMD_REQUEST_STATUS) {
|
||||
__osPackRequestData(CONT_CMD_REQUEST_STATUS);
|
||||
__osSiRawStartDma(OS_WRITE, &__osContPifRam);
|
||||
osRecvMesg(mq, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
ret = __osSiRawStartDma(OS_READ, &__osContPifRam);
|
||||
|
||||
__osContLastPoll = 0;
|
||||
__osContLastPoll = CONT_CMD_REQUEST_STATUS;
|
||||
|
||||
__osSiRelAccess();
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "PR/voice_internal.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
#include "PR/voiceinternal.h"
|
||||
|
||||
#define BLOCKSIZE 32
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ultra64.h"
|
||||
#include "PR/voice_internal.h"
|
||||
#include "global.h"
|
||||
#include "PR/controller.h"
|
||||
#include "PR/voiceinternal.h"
|
||||
|
||||
s32 __osContRamWrite(OSMesgQueue* mq, s32 channel, u16 address, u8* buffer, s32 force) {
|
||||
s32 ret = 0;
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
#include "macros.h"
|
||||
|
||||
void __osPackReadData(void);
|
||||
|
||||
|
@ -1,13 +1,16 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
#include "alignment.h"
|
||||
#include "macros.h"
|
||||
|
||||
s32 __osContinitialized = false;
|
||||
|
||||
OSPifRam __osContPifRam;
|
||||
OSPifRam __osContPifRam ALIGNED(16);
|
||||
u8 __osContLastPoll;
|
||||
u8 __osMaxControllers;
|
||||
|
||||
OSTimer __osEepromTimer;
|
||||
OSMesgQueue __osEepromTimerQ;
|
||||
OSMesgQueue __osEepromTimerQ ALIGNED(8);
|
||||
OSMesg __osEepromTimerMsg[1];
|
||||
|
||||
s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
|
||||
@ -24,15 +27,15 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
|
||||
__osContinitialized = true;
|
||||
|
||||
t = osGetTime();
|
||||
if (t < 0x165A0BC) {
|
||||
if (t < OS_USEC_TO_CYCLES(500000)) {
|
||||
osCreateMesgQueue(&timerMesgQueue, &dummy, 1);
|
||||
osSetTimer(&mytimer, 0x165A0BC - t, 0, &timerMesgQueue, &dummy);
|
||||
osSetTimer(&mytimer, OS_USEC_TO_CYCLES(500000) - t, 0, &timerMesgQueue, &dummy);
|
||||
osRecvMesg(&timerMesgQueue, &dummy, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
__osMaxControllers = 4;
|
||||
|
||||
__osPackRequestData(0);
|
||||
__osPackRequestData(CONT_CMD_REQUEST_STATUS);
|
||||
|
||||
ret = __osSiRawStartDma(OS_WRITE, &__osContPifRam);
|
||||
osRecvMesg(mq, &dummy, OS_MESG_BLOCK);
|
||||
@ -50,15 +53,16 @@ s32 osContInit(OSMesgQueue* mq, u8* bitpattern, OSContStatus* data) {
|
||||
|
||||
void __osContGetInitData(u8* pattern, OSContStatus* data) {
|
||||
u8* ptr;
|
||||
__OSContRequestHeader requestHeader;
|
||||
__OSContRequesFormat requestHeader;
|
||||
s32 i;
|
||||
u8 bits;
|
||||
|
||||
bits = 0;
|
||||
ptr = (u8*)__osContPifRam.ramarray;
|
||||
for (i = 0; i < __osMaxControllers; i++, ptr += sizeof(requestHeader), data++) {
|
||||
requestHeader = *(__OSContRequestHeader*)ptr;
|
||||
data->errno = (requestHeader.rxsize & 0xC0) >> 4;
|
||||
requestHeader = *(__OSContRequesFormat*)ptr;
|
||||
data->errno = CHNL_ERR(requestHeader);
|
||||
|
||||
if (data->errno == 0) {
|
||||
data->type = requestHeader.typel << 8 | requestHeader.typeh;
|
||||
data->status = requestHeader.status;
|
||||
@ -71,7 +75,7 @@ void __osContGetInitData(u8* pattern, OSContStatus* data) {
|
||||
|
||||
void __osPackRequestData(u8 poll) {
|
||||
u8* ptr;
|
||||
__OSContRequestHeader requestHeader;
|
||||
__OSContRequesFormat requestHeader;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(__osContPifRam.ramarray); i++) {
|
||||
@ -80,18 +84,18 @@ void __osPackRequestData(u8 poll) {
|
||||
|
||||
__osContPifRam.status = CONT_CMD_READ_BUTTON;
|
||||
ptr = (u8*)__osContPifRam.ramarray;
|
||||
requestHeader.align = 255;
|
||||
requestHeader.txsize = 1;
|
||||
requestHeader.rxsize = 3;
|
||||
requestHeader.align = CONT_CMD_NOP;
|
||||
requestHeader.txsize = CONT_CMD_RESET_TX;
|
||||
requestHeader.rxsize = CONT_CMD_RESET_RX;
|
||||
requestHeader.poll = poll;
|
||||
requestHeader.typeh = 255;
|
||||
requestHeader.typel = 255;
|
||||
requestHeader.status = 255;
|
||||
requestHeader.align1 = 255;
|
||||
requestHeader.typeh = CONT_CMD_NOP;
|
||||
requestHeader.typel = CONT_CMD_NOP;
|
||||
requestHeader.status = CONT_CMD_NOP;
|
||||
requestHeader.align1 = CONT_CMD_NOP;
|
||||
|
||||
for (i = 0; i < __osMaxControllers; i++) {
|
||||
*(__OSContRequestHeader*)ptr = requestHeader;
|
||||
*(__OSContRequesFormat*)ptr = requestHeader;
|
||||
ptr += sizeof(requestHeader);
|
||||
}
|
||||
*ptr = 254;
|
||||
*ptr = CONT_CMD_END;
|
||||
}
|
||||
|
@ -1,14 +1,15 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 osContSetCh(u8 ch) {
|
||||
__osSiGetAccess();
|
||||
|
||||
if (4 < ch) {
|
||||
__osMaxControllers = 4;
|
||||
if (ch > MAXCONTROLLERS) {
|
||||
__osMaxControllers = MAXCONTROLLERS;
|
||||
} else {
|
||||
__osMaxControllers = ch;
|
||||
}
|
||||
__osContLastPoll = -2;
|
||||
__osContLastPoll = CONT_CMD_END;
|
||||
|
||||
__osSiRelAccess();
|
||||
return 0;
|
||||
|
@ -69,7 +69,7 @@
|
||||
* implementing CRC (Cyclic Redundancy Check) calculation
|
||||
* ](http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html)
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
#define ADDRESS_CRC_MESSAGE_LENGTH 10
|
||||
#define ADDRESS_CRC_LENGTH 5
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "libc/stdbool.h"
|
||||
|
||||
void __osDevMgrMain(void* arg) {
|
||||
OSIoMesg* ioMesg;
|
||||
@ -34,31 +35,32 @@ void __osDevMgrMain(void* arg) {
|
||||
}
|
||||
|
||||
osRecvMesg(devMgr->acsQueue, &sp6C, OS_MESG_BLOCK);
|
||||
__osResetGlobalIntMask(0x00100401);
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x80000000);
|
||||
__osResetGlobalIntMask(OS_IM_PI);
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, LEO_BM_CTL, transfer->bmCtlShadow | LEO_BM_CTL_START);
|
||||
|
||||
label:
|
||||
readblock1:
|
||||
osRecvMesg(devMgr->evtQueue, &sp70, OS_MESG_BLOCK);
|
||||
transfer = &ioMesg->piHandle->transferInfo;
|
||||
block = &transfer->block[transfer->blockNum];
|
||||
if (block->errStatus == 0x1D) {
|
||||
u32 status;
|
||||
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x10000000);
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow);
|
||||
__osEPiRawReadIo(ioMesg->piHandle, 0x05000508, &status);
|
||||
if (status & 0x02000000) {
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, 0x05000510, transfer->bmCtlShadow | 0x1000000);
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, LEO_BM_CTL, transfer->bmCtlShadow | LEO_BM_CTL_RESET);
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, LEO_BM_CTL, transfer->bmCtlShadow);
|
||||
__osEPiRawReadIo(ioMesg->piHandle, LEO_STATUS, &status);
|
||||
if (status & LEO_STATUS_MECHANIC_INTERRUPT) {
|
||||
__osEPiRawWriteIo(ioMesg->piHandle, LEO_BM_CTL,
|
||||
transfer->bmCtlShadow | LEO_BM_CTL_CLR_MECHANIC_INTR);
|
||||
}
|
||||
block->errStatus = 4;
|
||||
HW_REG(PI_STATUS_REG, u32) = PI_CLR_INTR;
|
||||
__osSetGlobalIntMask(0x00100C01);
|
||||
IO_WRITE(PI_STATUS_REG, PI_CLR_INTR);
|
||||
__osSetGlobalIntMask(OS_IM_PI | SR_IBIT4);
|
||||
}
|
||||
osSendMesg(ioMesg->hdr.retQueue, (OSMesg)ioMesg, OS_MESG_NOBLOCK);
|
||||
|
||||
if ((msgVar == 1) && (ioMesg->piHandle->transferInfo.block[0].errStatus == 0)) {
|
||||
msgVar = 0;
|
||||
goto label;
|
||||
goto readblock1;
|
||||
}
|
||||
|
||||
osSendMesg(devMgr->acsQueue, NULL, OS_MESG_NOBLOCK);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
u32 osDpGetStatus(void) {
|
||||
return HW_REG(DPC_STATUS_REG, u32);
|
||||
return IO_READ(DPC_STATUS_REG);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void osDpSetStatus(u32 data) {
|
||||
HW_REG(DPC_STATUS_REG, u32) = data;
|
||||
IO_WRITE(DPC_STATUS_REG, data);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
|
||||
register s32 result;
|
||||
@ -9,13 +9,13 @@ s32 osEPiStartDma(OSPiHandle* pihandle, OSIoMesg* mb, s32 direction) {
|
||||
|
||||
mb->piHandle = pihandle;
|
||||
|
||||
if (direction == 0) {
|
||||
mb->hdr.type = 15;
|
||||
if (direction == OS_READ) {
|
||||
mb->hdr.type = OS_MESG_TYPE_EDMAREAD;
|
||||
} else {
|
||||
mb->hdr.type = 16;
|
||||
mb->hdr.type = OS_MESG_TYPE_EDMAWRITE;
|
||||
}
|
||||
|
||||
if (mb->hdr.pri == 1) {
|
||||
if (mb->hdr.pri == OS_MESG_PRI_HIGH) {
|
||||
result = osJamMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK);
|
||||
} else {
|
||||
result = osSendMesg(osPiGetCmdQueue(), mb, OS_MESG_NOBLOCK);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 osEPiLinkHandle(OSPiHandle* handle) {
|
||||
u32 saveMask = __osDisableInt();
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, void* dramAddr, size_t size) {
|
||||
s32 status;
|
||||
OSPiHandle* curHandle;
|
||||
|
||||
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
|
||||
while (status = IO_READ(PI_STATUS_REG), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
|
||||
;
|
||||
}
|
||||
|
||||
@ -13,35 +13,35 @@ s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, vo
|
||||
|
||||
if (handle->domain == 0) {
|
||||
if (curHandle->latency != handle->latency) {
|
||||
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency;
|
||||
IO_WRITE(PI_BSD_DOM1_LAT_REG, handle->latency);
|
||||
}
|
||||
|
||||
if (curHandle->pageSize != handle->pageSize) {
|
||||
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize;
|
||||
IO_WRITE(PI_BSD_DOM1_PGS_REG, handle->pageSize);
|
||||
}
|
||||
|
||||
if (curHandle->relDuration != handle->relDuration) {
|
||||
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration;
|
||||
IO_WRITE(PI_BSD_DOM1_RLS_REG, handle->relDuration);
|
||||
}
|
||||
|
||||
if (curHandle->pulse != handle->pulse) {
|
||||
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse;
|
||||
IO_WRITE(PI_BSD_DOM1_PWD_REG, handle->pulse);
|
||||
}
|
||||
} else {
|
||||
if (curHandle->latency != handle->latency) {
|
||||
HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency;
|
||||
IO_WRITE(PI_BSD_DOM2_LAT_REG, handle->latency);
|
||||
}
|
||||
|
||||
if (curHandle->pageSize != handle->pageSize) {
|
||||
HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize;
|
||||
IO_WRITE(PI_BSD_DOM2_PGS_REG, handle->pageSize);
|
||||
}
|
||||
|
||||
if (curHandle->relDuration != handle->relDuration) {
|
||||
HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration;
|
||||
IO_WRITE(PI_BSD_DOM2_RLS_REG, handle->relDuration);
|
||||
}
|
||||
|
||||
if (curHandle->pulse != handle->pulse) {
|
||||
HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse;
|
||||
IO_WRITE(PI_BSD_DOM2_PWD_REG, handle->pulse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,15 +52,15 @@ s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, uintptr_t cartAddr, vo
|
||||
curHandle->pulse = handle->pulse;
|
||||
}
|
||||
|
||||
HW_REG(PI_DRAM_ADDR_REG, void*) = (void*)osVirtualToPhysical(dramAddr);
|
||||
HW_REG(PI_CART_ADDR_REG, void*) = (void*)((handle->baseAddress | cartAddr) & 0x1FFFFFFF);
|
||||
IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
|
||||
IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS(handle->baseAddress | cartAddr));
|
||||
|
||||
switch (direction) {
|
||||
case OS_READ:
|
||||
HW_REG(PI_WR_LEN_REG, u32) = size - 1;
|
||||
IO_WRITE(PI_WR_LEN_REG, size - 1);
|
||||
break;
|
||||
case OS_WRITE:
|
||||
HW_REG(PI_RD_LEN_REG, u32) = size - 1;
|
||||
IO_WRITE(PI_RD_LEN_REG, size - 1);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data) {
|
||||
s32 status;
|
||||
OSPiHandle* curHandle;
|
||||
|
||||
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
|
||||
while (status = IO_READ(PI_STATUS_REG), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {
|
||||
;
|
||||
}
|
||||
|
||||
@ -13,35 +13,35 @@ s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data) {
|
||||
|
||||
if (handle->domain == 0) {
|
||||
if (curHandle->latency != handle->latency) {
|
||||
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency;
|
||||
IO_WRITE(PI_BSD_DOM1_LAT_REG, handle->latency);
|
||||
}
|
||||
|
||||
if (curHandle->pageSize != handle->pageSize) {
|
||||
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize;
|
||||
IO_WRITE(PI_BSD_DOM1_PGS_REG, handle->pageSize);
|
||||
}
|
||||
|
||||
if (curHandle->relDuration != handle->relDuration) {
|
||||
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration;
|
||||
IO_WRITE(PI_BSD_DOM1_RLS_REG, handle->relDuration);
|
||||
}
|
||||
|
||||
if (curHandle->pulse != handle->pulse) {
|
||||
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse;
|
||||
IO_WRITE(PI_BSD_DOM1_PWD_REG, handle->pulse);
|
||||
}
|
||||
} else {
|
||||
if (curHandle->latency != handle->latency) {
|
||||
HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency;
|
||||
IO_WRITE(PI_BSD_DOM2_LAT_REG, handle->latency);
|
||||
}
|
||||
|
||||
if (curHandle->pageSize != handle->pageSize) {
|
||||
HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize;
|
||||
IO_WRITE(PI_BSD_DOM2_PGS_REG, handle->pageSize);
|
||||
}
|
||||
|
||||
if (curHandle->relDuration != handle->relDuration) {
|
||||
HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration;
|
||||
IO_WRITE(PI_BSD_DOM2_RLS_REG, handle->relDuration);
|
||||
}
|
||||
|
||||
if (curHandle->pulse != handle->pulse) {
|
||||
HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse;
|
||||
IO_WRITE(PI_BSD_DOM2_PWD_REG, handle->pulse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,6 @@ s32 __osEPiRawReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data) {
|
||||
curHandle->pulse = handle->pulse;
|
||||
}
|
||||
|
||||
*data = HW_REG(handle->baseAddress | devAddr, u32);
|
||||
*data = IO_READ(handle->baseAddress | devAddr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,45 +1,45 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osEPiRawWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data) {
|
||||
s32 status;
|
||||
OSPiHandle* curHandle;
|
||||
|
||||
while (status = HW_REG(PI_STATUS_REG, u32), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {}
|
||||
while (status = IO_READ(PI_STATUS_REG), status & (PI_STATUS_DMA_BUSY | PI_STATUS_IO_BUSY)) {}
|
||||
|
||||
if (__osCurrentHandle[handle->domain]->type != handle->type) {
|
||||
curHandle = __osCurrentHandle[handle->domain];
|
||||
|
||||
if (handle->domain == 0) {
|
||||
if (curHandle->latency != handle->latency) {
|
||||
HW_REG(PI_BSD_DOM1_LAT_REG, u32) = handle->latency;
|
||||
IO_WRITE(PI_BSD_DOM1_LAT_REG, handle->latency);
|
||||
}
|
||||
|
||||
if (curHandle->pageSize != handle->pageSize) {
|
||||
HW_REG(PI_BSD_DOM1_PGS_REG, u32) = handle->pageSize;
|
||||
IO_WRITE(PI_BSD_DOM1_PGS_REG, handle->pageSize);
|
||||
}
|
||||
|
||||
if (curHandle->relDuration != handle->relDuration) {
|
||||
HW_REG(PI_BSD_DOM1_RLS_REG, u32) = handle->relDuration;
|
||||
IO_WRITE(PI_BSD_DOM1_RLS_REG, handle->relDuration);
|
||||
}
|
||||
|
||||
if (curHandle->pulse != handle->pulse) {
|
||||
HW_REG(PI_BSD_DOM1_PWD_REG, u32) = handle->pulse;
|
||||
IO_WRITE(PI_BSD_DOM1_PWD_REG, handle->pulse);
|
||||
}
|
||||
} else {
|
||||
if (curHandle->latency != handle->latency) {
|
||||
HW_REG(PI_BSD_DOM2_LAT_REG, u32) = handle->latency;
|
||||
IO_WRITE(PI_BSD_DOM2_LAT_REG, handle->latency);
|
||||
}
|
||||
|
||||
if (curHandle->pageSize != handle->pageSize) {
|
||||
HW_REG(PI_BSD_DOM2_PGS_REG, u32) = handle->pageSize;
|
||||
IO_WRITE(PI_BSD_DOM2_PGS_REG, handle->pageSize);
|
||||
}
|
||||
|
||||
if (curHandle->relDuration != handle->relDuration) {
|
||||
HW_REG(PI_BSD_DOM2_RLS_REG, u32) = handle->relDuration;
|
||||
IO_WRITE(PI_BSD_DOM2_RLS_REG, handle->relDuration);
|
||||
}
|
||||
|
||||
if (curHandle->pulse != handle->pulse) {
|
||||
HW_REG(PI_BSD_DOM2_PWD_REG, u32) = handle->pulse;
|
||||
IO_WRITE(PI_BSD_DOM2_PWD_REG, handle->pulse);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,6 +50,6 @@ s32 __osEPiRawWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data) {
|
||||
curHandle->pulse = handle->pulse;
|
||||
}
|
||||
|
||||
HW_REG(handle->baseAddress | devAddr, u32) = data;
|
||||
IO_WRITE(handle->baseAddress | devAddr, data);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 osEPiReadIo(OSPiHandle* handle, uintptr_t devAddr, u32* data) {
|
||||
register s32 ret;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 osEPiWriteIo(OSPiHandle* handle, uintptr_t devAddr, u32 data) {
|
||||
register s32 ret;
|
||||
|
@ -1,7 +1,6 @@
|
||||
#include "ultra64.h"
|
||||
#include "PR/os_motor.h"
|
||||
|
||||
#include "PR/controller.h"
|
||||
#include "functions.h"
|
||||
|
||||
#define BANK_ADDR 0x400
|
||||
#define MOTOR_ID 0x80
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 osPfsAllocateFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32 fileSize, s32* fileNo) {
|
||||
s32 startPage;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "PR/os_pfs.h"
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
#define CHECK_IPAGE(p) \
|
||||
(((p).ipage >= pfs->inodeStartPage) && ((p).inode_t.bank < pfs->banks) && ((p).inode_t.page >= 0x01) && \
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "PR/os_pfs.h"
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 __osPfsReleasePages(OSPfs* pfs, __OSInode* inode, u8 initialPage, u8 bank, __OSInodeUnit* finalPage);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "PR/os_pfs.h"
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
#include "libc/stdbool.h"
|
||||
|
||||
s32 osPfsFileState(OSPfs* pfs, s32 fileNo, OSPfsState* state) {
|
||||
s32 ret;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "PR/os_pfs.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 osPfsFreeBlocks(OSPfs* pfs, s32* leftoverBytes) {
|
||||
s32 j;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
void __osPfsRequestOneChannel(s32 channel, u8 poll);
|
||||
void __osPfsGetOneChannelData(s32 channel, OSContStatus* contData);
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "PR/os_pfs.h"
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 __osPfsCheckRamArea(OSPfs* pfs);
|
||||
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include "PR/os_pfs.h"
|
||||
#include "PR/controller.h"
|
||||
#include "global.h"
|
||||
#include "PR/siint.h"
|
||||
#include "alignment.h"
|
||||
|
||||
OSPifRam __osPfsPifRam ALIGNED(16);
|
||||
|
||||
void __osPfsRequestData(u8 poll);
|
||||
void __osPfsGetInitData(u8* pattern, OSContStatus* contData);
|
||||
@ -50,40 +53,40 @@ s32 osPfsIsPlug(OSMesgQueue* mq, u8* pattern) {
|
||||
|
||||
void __osPfsRequestData(u8 poll) {
|
||||
u8* bufPtr = (u8*)&__osPfsPifRam;
|
||||
__OSContRequestHeader req;
|
||||
__OSContRequesFormat req;
|
||||
s32 i;
|
||||
|
||||
__osContLastPoll = poll;
|
||||
|
||||
__osPfsPifRam.status = 1;
|
||||
__osPfsPifRam.status = CONT_CMD_EXE;
|
||||
|
||||
req.align = 0xFF;
|
||||
req.txsize = 1;
|
||||
req.rxsize = 3;
|
||||
req.align = CONT_CMD_NOP;
|
||||
req.txsize = CONT_CMD_REQUEST_STATUS_TX;
|
||||
req.rxsize = CONT_CMD_REQUEST_STATUS_RX;
|
||||
req.poll = poll;
|
||||
req.typeh = 0xFF;
|
||||
req.typel = 0xFF;
|
||||
req.status = 0xFF;
|
||||
req.align1 = 0xFF;
|
||||
req.typeh = CONT_CMD_NOP;
|
||||
req.typel = CONT_CMD_NOP;
|
||||
req.status = CONT_CMD_NOP;
|
||||
req.align1 = CONT_CMD_NOP;
|
||||
|
||||
for (i = 0; i < __osMaxControllers; i++) {
|
||||
*((__OSContRequestHeader*)bufPtr) = req;
|
||||
bufPtr += sizeof(req);
|
||||
*(__OSContRequesFormat*)bufPtr = req;
|
||||
bufPtr += sizeof(__OSContRequesFormat);
|
||||
}
|
||||
*((u8*)bufPtr) = CONT_CMD_END;
|
||||
*bufPtr = CONT_CMD_END;
|
||||
}
|
||||
|
||||
void __osPfsGetInitData(u8* pattern, OSContStatus* contData) {
|
||||
u8* bufptr;
|
||||
__OSContRequestHeader req;
|
||||
__OSContRequesFormat req;
|
||||
s32 i;
|
||||
u8 bits = 0;
|
||||
|
||||
bufptr = (u8*)&__osPfsPifRam;
|
||||
|
||||
for (i = 0; i < __osMaxControllers; i++, bufptr += sizeof(req), contData++) {
|
||||
req = *((__OSContRequestHeader*)bufptr);
|
||||
contData->errno = ((req.rxsize & 0xC0) >> 4);
|
||||
req = *(__OSContRequesFormat*)bufptr;
|
||||
contData->errno = CHNL_ERR(req);
|
||||
|
||||
if (contData->errno) {
|
||||
continue;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
#define CHECK_IPAGE(p, pfs) \
|
||||
(((p).ipage >= (pfs).inodeStartPage) && ((p).inode_t.bank < (pfs).banks) && ((p).inode_t.page >= 0x01) && \
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 osPfsFindFile(OSPfs* pfs, u16 companyCode, u32 gameCode, u8* gameName, u8* extName, s32* fileNo) {
|
||||
s32 j;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "PR/os_pfs.h"
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/controller.h"
|
||||
|
||||
s32 __osPfsSelectBank(OSPfs* pfs, u8 bank) {
|
||||
u8 buf[BLOCKSIZE];
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "macros.h"
|
||||
|
||||
u32 __osPiAccessQueueEnabled = 0;
|
||||
|
||||
@ -13,6 +14,7 @@ void __osPiCreateAccessQueue(void) {
|
||||
|
||||
void __osPiGetAccess(void) {
|
||||
OSMesg dummyMesg;
|
||||
|
||||
if (!__osPiAccessQueueEnabled) {
|
||||
__osPiCreateAccessQueue();
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
OSMesgQueue* osPiGetCmdQueue(void) {
|
||||
if (!__osPiDevMgr.active) {
|
||||
|
@ -1,13 +1,19 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "alignment.h"
|
||||
#include "stack.h"
|
||||
#include "macros.h"
|
||||
|
||||
OSPiHandle __Dom1SpeedParam;
|
||||
OSPiHandle __Dom2SpeedParam;
|
||||
OSPiHandle __Dom1SpeedParam ALIGNED(8);
|
||||
OSPiHandle __Dom2SpeedParam ALIGNED(8);
|
||||
OSThread sPiMgrThread;
|
||||
STACK(sPiMgrStack, 0x1000);
|
||||
OSMesgQueue piEventQueue;
|
||||
OSMesgQueue piEventQueue ALIGNED(8);
|
||||
OSMesg piEventBuf[1];
|
||||
|
||||
OSDevMgr __osPiDevMgr = { 0 };
|
||||
OSPiHandle* __osPiTable = NULL;
|
||||
OSPiHandle* __osCurrentHandle[2] ALIGNED(8) = { &__Dom1SpeedParam, &__Dom2SpeedParam };
|
||||
|
||||
void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgCnt) {
|
||||
u32 savedMask;
|
||||
OSPri oldPri;
|
||||
|
@ -1,22 +1,22 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osPiRawStartDma(s32 direction, uintptr_t devAddr, void* dramAddr, size_t size) {
|
||||
register int status = HW_REG(PI_STATUS_REG, u32);
|
||||
register int status = IO_READ(PI_STATUS_REG);
|
||||
|
||||
while (status & (PI_STATUS_IO_BUSY | PI_STATUS_DMA_BUSY)) {
|
||||
status = HW_REG(PI_STATUS_REG, u32);
|
||||
status = IO_READ(PI_STATUS_REG);
|
||||
}
|
||||
|
||||
HW_REG(PI_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr);
|
||||
IO_WRITE(PI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
|
||||
|
||||
HW_REG(PI_CART_ADDR_REG, u32) = (((uintptr_t)osRomBase | devAddr) & 0x1FFFFFFF);
|
||||
IO_WRITE(PI_CART_ADDR_REG, K1_TO_PHYS((uintptr_t)osRomBase | devAddr));
|
||||
|
||||
switch (direction) {
|
||||
case OS_READ:
|
||||
HW_REG(PI_WR_LEN_REG, u32) = size - 1;
|
||||
IO_WRITE(PI_WR_LEN_REG, size - 1);
|
||||
break;
|
||||
case OS_WRITE:
|
||||
HW_REG(PI_RD_LEN_REG, u32) = size - 1;
|
||||
IO_WRITE(PI_RD_LEN_REG, size - 1);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "libc/stdbool.h"
|
||||
|
||||
s32 __osSiDeviceBusy() {
|
||||
register u32 status = HW_REG(SI_STATUS_REG, u32);
|
||||
register u32 status = IO_READ(SI_STATUS_REG);
|
||||
|
||||
if (status & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) {
|
||||
return true;
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "alignment.h"
|
||||
#include "macros.h"
|
||||
|
||||
u32 __osSiAccessQueueEnabled = 0;
|
||||
|
||||
OSMesg siAccessBuf[1];
|
||||
OSMesgQueue __osSiAccessQueue;
|
||||
OSMesg siAccessBuf[1] ALIGNED(8);
|
||||
OSMesgQueue __osSiAccessQueue ALIGNED(8);
|
||||
|
||||
void __osSiCreateAccessQueue() {
|
||||
__osSiAccessQueueEnabled = 1;
|
||||
@ -13,6 +15,7 @@ void __osSiCreateAccessQueue() {
|
||||
|
||||
void __osSiGetAccess(void) {
|
||||
OSMesg dummyMesg;
|
||||
|
||||
if (!__osSiAccessQueueEnabled) {
|
||||
__osSiCreateAccessQueue();
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "alignment.h"
|
||||
|
||||
s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
|
||||
if (HW_REG(SI_STATUS_REG, u32) & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) {
|
||||
if (IO_READ(SI_STATUS_REG) & (SI_STATUS_DMA_BUSY | SI_STATUS_IO_READ_BUSY)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -9,12 +10,12 @@ s32 __osSiRawStartDma(s32 direction, void* dramAddr) {
|
||||
osWritebackDCache(dramAddr, ALIGN16(PIF_RAM_END - PIF_RAM_START));
|
||||
}
|
||||
|
||||
HW_REG(SI_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr);
|
||||
IO_WRITE(SI_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
|
||||
|
||||
if (direction == OS_READ) {
|
||||
HW_REG(SI_PIF_ADDR_RD64B_REG, void*) = (void*)PIF_RAM_START;
|
||||
IO_WRITE(SI_PIF_ADDR_RD64B_REG, PIF_RAM_START);
|
||||
} else {
|
||||
HW_REG(SI_PIF_ADDR_WR64B_REG, void*) = (void*)PIF_RAM_START;
|
||||
IO_WRITE(SI_PIF_ADDR_WR64B_REG, PIF_RAM_START);
|
||||
}
|
||||
|
||||
if (direction == OS_READ) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osSiRawReadIo(uintptr_t devAddr, u32* data) {
|
||||
if (__osSiDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
*data = *(u32*)(devAddr | 0xA0000000);
|
||||
*data = IO_READ(devAddr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osSiRawWriteIo(uintptr_t devAddr, u32 data) {
|
||||
if (__osSiDeviceBusy() != 0) {
|
||||
if (__osSiDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*(u32*)(devAddr | 0xA0000000) = data;
|
||||
IO_WRITE(devAddr, data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "libc/stdbool.h"
|
||||
|
||||
s32 __osSpDeviceBusy(void) {
|
||||
register u32 status = HW_REG(SP_STATUS_REG, u32);
|
||||
register u32 status = IO_READ(SP_STATUS_REG);
|
||||
|
||||
if (status & (SP_STATUS_DMA_BUSY | SP_STATUS_DMA_FULL | SP_STATUS_IO_FULL)) {
|
||||
return true;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
u32 __osSpGetStatus() {
|
||||
return HW_REG(SP_STATUS_REG, u32);
|
||||
return IO_READ(SP_STATUS_REG);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osSpRawStartDma(s32 direction, void* devAddr, void* dramAddr, size_t size) {
|
||||
s32 __osSpRawStartDma(s32 direction, u32 devAddr, void* dramAddr, size_t size) {
|
||||
if (__osSpDeviceBusy()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
HW_REG(SP_MEM_ADDR_REG, u32) = devAddr;
|
||||
HW_REG(SP_DRAM_ADDR_REG, u32) = osVirtualToPhysical(dramAddr);
|
||||
IO_WRITE(SP_MEM_ADDR_REG, devAddr);
|
||||
IO_WRITE(SP_DRAM_ADDR_REG, osVirtualToPhysical(dramAddr));
|
||||
|
||||
if (direction == OS_READ) {
|
||||
HW_REG(SP_WR_LEN_REG, u32) = size - 1;
|
||||
IO_WRITE(SP_WR_LEN_REG, size - 1);
|
||||
} else {
|
||||
HW_REG(SP_RD_LEN_REG, u32) = size - 1;
|
||||
IO_WRITE(SP_RD_LEN_REG, size - 1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1,13 +1,12 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
s32 __osSpSetPc(void* pc) {
|
||||
register u32 spStatus = HW_REG(SP_STATUS_REG, u32);
|
||||
s32 __osSpSetPc(u32 pc) {
|
||||
register u32 spStatus = IO_READ(SP_STATUS_REG);
|
||||
|
||||
if (!(spStatus & SP_STATUS_HALT)) {
|
||||
return -1;
|
||||
} else {
|
||||
HW_REG(SP_PC_REG, void*) = pc;
|
||||
}
|
||||
IO_WRITE(SP_PC_REG, pc);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void __osSpSetStatus(u32 data) {
|
||||
HW_REG(SP_STATUS_REG, u32) = data;
|
||||
IO_WRITE(SP_STATUS_REG, data);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
#define _osVirtualToPhysical(ptr) \
|
||||
if (ptr != NULL) { \
|
||||
@ -33,19 +33,20 @@ void osSpTaskLoad(OSTask* intp) {
|
||||
intp->t.flags &= ~OS_TASK_YIELDED;
|
||||
|
||||
if (tp->t.flags & OS_TASK_LOADABLE) {
|
||||
tp->t.ucode = HW_REG((uintptr_t)intp->t.yieldDataPtr + OS_YIELD_DATA_SIZE - 4, u32);
|
||||
tp->t.ucode = IO_READ((uintptr_t)intp->t.yieldDataPtr + OS_YIELD_DATA_SIZE - 4);
|
||||
}
|
||||
}
|
||||
|
||||
osWritebackDCache(tp, sizeof(OSTask));
|
||||
__osSpSetStatus(SP_CLR_SIG0 | SP_CLR_SIG1 | SP_CLR_SIG2 | SP_SET_INTR_BREAK);
|
||||
|
||||
while (__osSpSetPc((void*)SP_IMEM_START) == -1) {}
|
||||
while (__osSpSetPc(SP_IMEM_START) == -1) {}
|
||||
|
||||
while (__osSpRawStartDma(1, (void*)(SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) {}
|
||||
while (__osSpRawStartDma(1, (SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) {}
|
||||
|
||||
while (__osSpDeviceBusy()) {}
|
||||
|
||||
while (__osSpRawStartDma(1, (void*)SP_IMEM_START, tp->t.ucodeBoot, tp->t.ucodeBootSize) == -1) {}
|
||||
while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucodeBoot, tp->t.ucodeBootSize) == -1) {}
|
||||
}
|
||||
|
||||
void osSpTaskStartGo(OSTask* tp) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void osSpTaskYield(void) {
|
||||
__osSpSetStatus(0x400);
|
||||
__osSpSetStatus(SP_SET_YIELD);
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
OSYieldResult osSpTaskYielded(OSTask* task) {
|
||||
s32 status;
|
||||
s32 status = __osSpGetStatus();
|
||||
OSYieldResult result;
|
||||
status = __osSpGetStatus();
|
||||
if (status & 0x100) {
|
||||
result = 1;
|
||||
|
||||
if (status & SP_STATUS_YIELDED) {
|
||||
result = OS_TASK_YIELDED;
|
||||
} else {
|
||||
result = 0;
|
||||
}
|
||||
if (status & 0x80) {
|
||||
if (status & SP_STATUS_YIELD) {
|
||||
task->t.flags |= result;
|
||||
task->t.flags &= ~(2);
|
||||
task->t.flags &= ~OS_TASK_DP_WAIT;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "alignment.h"
|
||||
|
||||
static __OSViContext vi[2] = { 0 };
|
||||
static __OSViContext vi[2] ALIGNED(8) = { 0 };
|
||||
__OSViContext* __osViCurr = &vi[0];
|
||||
__OSViContext* __osViNext = &vi[1];
|
||||
|
||||
@ -10,8 +11,8 @@ void __osViInit(void) {
|
||||
__osViNext = &vi[1];
|
||||
__osViNext->retraceCount = 1;
|
||||
__osViCurr->retraceCount = 1;
|
||||
__osViNext->buffer = (void*)0x80000000;
|
||||
__osViCurr->buffer = (void*)0x80000000;
|
||||
__osViNext->buffer = (void*)K0BASE;
|
||||
__osViCurr->buffer = (void*)K0BASE;
|
||||
|
||||
if (osTvType == OS_TV_PAL) {
|
||||
__osViNext->modep = &osViModePalLan1;
|
||||
@ -24,9 +25,9 @@ void __osViInit(void) {
|
||||
__osViNext->state = 0x20;
|
||||
__osViNext->features = __osViNext->modep->comRegs.ctrl;
|
||||
|
||||
while (HW_REG(VI_CURRENT_REG, u32) > 10) {}
|
||||
while (IO_READ(VI_CURRENT_REG) > 10) {}
|
||||
|
||||
HW_REG(VI_STATUS_REG, u32) = 0;
|
||||
IO_WRITE(VI_STATUS_REG, 0);
|
||||
|
||||
__osViSwapContext();
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void osViBlack(u8 active) {
|
||||
register u32 saveMask;
|
||||
|
||||
saveMask = __osDisableInt();
|
||||
register u32 saveMask = __osDisableInt();
|
||||
|
||||
if (active) {
|
||||
__osViNext->state |= 0x20;
|
||||
__osViNext->state |= VI_STATE_BLACK;
|
||||
} else {
|
||||
__osViNext->state &= ~0x20;
|
||||
__osViNext->state &= ~VI_STATE_BLACK;
|
||||
}
|
||||
|
||||
__osRestoreInt(saveMask);
|
||||
|
5
src/libultra/io/viextendvstart.c
Normal file
5
src/libultra/io/viextendvstart.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include "ultra64.h"
|
||||
|
||||
void osViExtendVStart(u32 value) {
|
||||
__additional_scanline = value;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
__OSViContext* __osViGetCurrentContext(void) {
|
||||
return __osViCurr;
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void* osViGetCurrentFramebuffer(void) {
|
||||
register u32 prevInt = __osDisableInt();
|
||||
|
@ -1,11 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void* osViGetNextFramebuffer(void) {
|
||||
register u32 saveMask;
|
||||
register u32 saveMask = __osDisableInt();
|
||||
void* buffer;
|
||||
|
||||
saveMask = __osDisableInt();
|
||||
|
||||
buffer = __osViNext->buffer;
|
||||
|
||||
__osRestoreInt(saveMask);
|
||||
|
@ -1,14 +1,17 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "PR/osint.h"
|
||||
#include "stack.h"
|
||||
#include "PR/osint.h"
|
||||
#include "libc/stdbool.h"
|
||||
#include "macros.h"
|
||||
#include "alignment.h"
|
||||
|
||||
OSThread viThread;
|
||||
STACK(sViStack, 0x1000);
|
||||
OSMesgQueue viEventQueue;
|
||||
OSMesg viEventBuf[6];
|
||||
OSIoMesg viRetraceMsg;
|
||||
OSIoMesg viCounterMsg;
|
||||
STACK(sViStack, OS_VIM_STACKSIZE) ALIGNED(16);
|
||||
OSMesgQueue viEventQueue ALIGNED(8);
|
||||
OSMesg viEventBuf[6] ALIGNED(8);
|
||||
OSIoMesg viRetraceMsg ALIGNED(8);
|
||||
OSIoMesg viCounterMsg ALIGNED(8);
|
||||
OSDevMgr __osViDevMgr = { 0 };
|
||||
u32 __additional_scanline = 0;
|
||||
|
||||
@ -57,8 +60,8 @@ void osCreateViManager(OSPri pri) {
|
||||
}
|
||||
}
|
||||
|
||||
void viMgrMain(void* vargs) {
|
||||
OSMgrArgs* args;
|
||||
void viMgrMain(void* arg) {
|
||||
OSDevMgr* dmArgs;
|
||||
static u16 viRetrace;
|
||||
u32 addTime;
|
||||
OSIoMesg* mesg;
|
||||
@ -70,10 +73,10 @@ void viMgrMain(void* vargs) {
|
||||
viRetrace = 1;
|
||||
}
|
||||
|
||||
args = (OSMgrArgs*)vargs;
|
||||
dmArgs = (OSDevMgr*)arg;
|
||||
|
||||
while (true) {
|
||||
osRecvMesg(args->eventQueue, (OSMesg*)&mesg, OS_MESG_BLOCK);
|
||||
osRecvMesg(dmArgs->evtQueue, (OSMesg*)&mesg, OS_MESG_BLOCK);
|
||||
switch (mesg->hdr.type) {
|
||||
case OS_MESG_TYPE_VRETRACE:
|
||||
__osViSwapContext();
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void osViSetEvent(OSMesgQueue* mq, OSMesg m, u32 retraceCount) {
|
||||
register u32 saveMask = __osDisableInt();
|
@ -1,12 +1,10 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void osViSetMode(OSViMode* modep) {
|
||||
register u32 saveMask;
|
||||
|
||||
saveMask = __osDisableInt();
|
||||
register u32 saveMask = __osDisableInt();
|
||||
|
||||
__osViNext->modep = modep;
|
||||
__osViNext->state = 1;
|
||||
__osViNext->state = VI_STATE_MODE_UPDATED;
|
||||
__osViNext->features = __osViNext->modep->comRegs.ctrl;
|
||||
|
||||
__osRestoreInt(saveMask);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
|
||||
void osViSetSpecialFeatures(u32 func) {
|
||||
register u32 saveMask = __osDisableInt();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user