Improvements to Video Interface related functions and data (#1332)

* Improvements to VI related functions

* Fix

* Suggested changes

* Comment enum values

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>

* Suggested changes, plus comments in visetspecial.c

* Name gViConfigModeType

* Further suggested changes

* Format

* Fix comment on modeLPN2

Co-authored-by: engineer124 <47598039+engineer124@users.noreply.github.com>
This commit is contained in:
Tharo
2022-11-13 23:07:27 +00:00
committed by GitHub
parent abb4201e57
commit c165ed015c
37 changed files with 684 additions and 447 deletions
+4 -4
View File
@@ -78,7 +78,7 @@ void __osPiGetAccess(void);
void __osPiRelAccess(void);
s32 osSendMesg(OSMesgQueue* mq, OSMesg msg, s32 flag);
void osStopThread(OSThread* thread);
void osViExtendVStart(u32 arg0);
void osViExtendVStart(u32 value);
s32 osRecvMesg(OSMesgQueue* mq, OSMesg* msg, s32 flag);
void __osInitialize_common(void);
void __osInitialize_autodetect(void);
@@ -120,7 +120,7 @@ s32 osJamMesg(OSMesgQueue* mq, OSMesg msg, s32 flag);
void osSetThreadPri(OSThread* thread, OSPri pri);
OSPri osGetThreadPri(OSThread* thread);
s32 __osEPiRawReadIo(OSPiHandle* handle, u32 devAddr, u32* data);
void osViSwapBuffer(void* vaddr);
void osViSwapBuffer(void* frameBufPtr);
s32 __osEPiRawStartDma(OSPiHandle* handle, s32 direction, u32 cartAddr, void* dramAddr, size_t size);
u32 bcmp(void* __sl, void* __s2, u32 __n);
OSTime osGetTime(void);
@@ -1291,8 +1291,8 @@ s32 View_UpdateViewingMatrix(View* view);
s32 View_ApplyTo(View* view, s32 mask, Gfx** gfxp);
s32 View_ErrorCheckEyePosition(f32 eyeX, f32 eyeY, f32 eyeZ);
void ViMode_LogPrint(OSViMode* osViMode);
void ViMode_Configure(ViMode* viMode, s32 mode, s32 type, s32 unk_70, s32 unk_74, s32 unk_78, s32 unk_7C, s32 width,
s32 height, s32 unk_left, s32 unk_right, s32 unk_top, s32 unk_bottom);
void ViMode_Configure(ViMode* viMode, s32 type, s32 tvType, s32 loRes, s32 antialiasOff, s32 modeN, s32 fb16Bit,
s32 width, s32 height, s32 leftAdjust, s32 rightAdjust, s32 upperAdjust, s32 lowerAdjust);
void ViMode_Save(ViMode* viMode);
void ViMode_Load(ViMode* viMode);
void ViMode_Init(ViMode* viMode);
+1
View File
@@ -119,6 +119,7 @@
#define LOG_TIME(exp, value, file, line) LOG(exp, value, "%lld", file, line)
#define LOG_NUM(exp, value, file, line) LOG(exp, value, "%d", file, line)
#define LOG_HEX(exp, value, file, line) LOG(exp, value, "%x", file, line)
#define LOG_HEX32(exp, value, file, line) LOG(exp, value, "%08x", file, line)
#define LOG_FLOAT(exp, value, file, line) LOG(exp, value, "%f", file, line)
#define SET_NEXT_GAMESTATE(curState, newInit, newStruct) \
+7
View File
@@ -52,6 +52,13 @@
#define R_ROOM_BG2D_FORCE_SCALEBG SREG(26)
#define R_UPDATE_RATE SREG(30)
#define R_ENABLE_AUDIO_DBG SREG(36)
#define R_VI_MODE_EDIT_STATE SREG(48)
#define R_VI_MODE_EDIT_WIDTH SREG(49)
#define R_VI_MODE_EDIT_HEIGHT SREG(50)
#define R_VI_MODE_EDIT_ULY_ADJ SREG(51)
#define R_VI_MODE_EDIT_LRY_ADJ SREG(52)
#define R_VI_MODE_EDIT_ULX_ADJ SREG(53)
#define R_VI_MODE_EDIT_LRX_ADJ SREG(54)
#define R_FB_FILTER_TYPE SREG(80)
#define R_FB_FILTER_PRIM_COLOR(c) SREG(81 + (c))
#define R_FB_FILTER_A SREG(84)
+1 -1
View File
@@ -65,6 +65,6 @@ typedef struct {
} Scheduler; // size = 0x258
void Sched_Notify(Scheduler* sc);
void Sched_Init(Scheduler* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr);
void Sched_Init(Scheduler* sc, void* stack, OSPri priority, u8 viModeType, UNK_TYPE arg4, IrqMgr* irqMgr);
#endif
+8 -8
View File
@@ -4,21 +4,21 @@
#include "pi.h"
typedef struct {
/* 0x00 */ u32 initialized;
/* 0x04 */ OSThread* mgrThread;
/* 0x00 */ u32 active;
/* 0x04 */ OSThread* thread;
/* 0x08 */ OSMesgQueue* cmdQueue;
/* 0x0C */ OSMesgQueue* eventQueue;
/* 0x10 */ OSMesgQueue* acccessQueue;
/* 0x14 */ s32 (*piDmaCallback)(s32, u32, void*, size_t);
/* 0x18 */ s32 (*epiDmaCallback)(OSPiHandle*, s32, u32, void*, size_t);
} OSMgrArgs; // size = 0x1C
/* 0x0C */ OSMesgQueue* evtQueue;
/* 0x10 */ OSMesgQueue* acsQueue;
/* 0x14 */ s32 (*dma)(s32, u32, void*, size_t);
/* 0x18 */ s32 (*edma)(OSPiHandle*, s32, u32, void*, size_t);
} OSDevMgr; // size = 0x1C
typedef struct {
/* 0x00 */ OSMesgQueue* queue;
/* 0x04 */ OSMesg msg;
} __OSEventState; // size = 0x08
extern OSMgrArgs __osPiDevMgr;
extern OSDevMgr __osPiDevMgr;
extern __OSEventState __osEventStateTab[];
#endif
+47
View File
@@ -0,0 +1,47 @@
#ifndef ULTRA64_LEODRIVE_H
#define ULTRA64_LEODRIVE_H
#include "rcp.h"
#define ASIC_BASE PI_DOM2_ADDR1
#define ASIC_C2_BUFF (ASIC_BASE + 0x000) // C2 Sector Buffer
#define ASIC_SECTOR_BUFF (ASIC_BASE + 0x400) // Data Sector Buffer
#define ASIC_DATA (ASIC_BASE + 0x500) // Data
#define ASIC_MISC_REG (ASIC_BASE + 0x504) // Misc Register
#define ASIC_CMD (ASIC_BASE + 0x508) // Command (write)
#define ASIC_STATUS (ASIC_BASE + 0x508) // Status (read)
#define ASIC_CUR_TK (ASIC_BASE + 0x50C) // Current Track
#define ASIC_BM_CTL (ASIC_BASE + 0x510) // Buffer Manager Control (write)
#define ASIC_BM_STATUS (ASIC_BASE + 0x510) // Buffer Manager Status (read)
#define ASIC_ERR_SECTOR (ASIC_BASE + 0x514) // Sector Error Status
#define ASIC_SEQ_CTL (ASIC_BASE + 0x518) // Sequencer Control (write)
#define ASIC_SEQ_STATUS (ASIC_BASE + 0x518) // Sequencer Status (read)
#define ASIC_CUR_SECTOR (ASIC_BASE + 0x51C) // Current Sector
#define ASIC_HARD_RESET (ASIC_BASE + 0x520) // Hard Reset
#define ASIC_C1_S0 (ASIC_BASE + 0x524) // C1
#define ASIC_HOST_SECBYTE (ASIC_BASE + 0x528) // Sector Size (in bytes)
#define ASIC_C1_S2 (ASIC_BASE + 0x52C) // C1
#define ASIC_SEC_BYTE (ASIC_BASE + 0x530) // Sectors per Block, Full Size
#define ASIC_C1_S4 (ASIC_BASE + 0x534) // C1
#define ASIC_C1_S6 (ASIC_BASE + 0x538) // C1
#define ASIC_CUR_ADDR (ASIC_BASE + 0x53C) // Current Address
#define ASIC_ID_REG (ASIC_BASE + 0x540) // ID
#define ASIC_TEST_REG (ASIC_BASE + 0x544) // Test Read
#define ASIC_TEST_PIN_SEL (ASIC_BASE + 0x548) // Test Write
#define MSEQ_RAM_ADDR (ASIC_BASE + 0x580) // Microsequencer RAM
// ASIC_BM_CTL write bits
#define LEO_BM_START 0x80000000 // Start Buffer Manager
#define LEO_BM_MODE 0x40000000 // Buffer Manager Mode
#define LEO_BM_IMASK 0x20000000 // BM Interrupt Mask
#define LEO_BM_RESET 0x10000000 // Buffer Manager Reset
#define LEO_BM_DISABLE_OR_CHECK 0x08000000 // Disable OR Check
#define LEO_BM_DISABLE_C1 0x04000000 // Disable C1 Correction
#define LEO_BM_XFER_BLOCK 0x02000000 // Block Transfer
#define LEO_BM_CLR_MECHANIC_INTR 0x01000000 // Mechanic Interrupt Reset
// ASIC_STATUS read bits
#define LEO_STATUS_MECHANIC_INTR 0x02000000 // Mechanic Interrupt Raised
#endif
+1 -14
View File
@@ -13,18 +13,6 @@
#define OS_VI_DITHER_FILTER_ON 0x0040
#define OS_VI_DITHER_FILTER_OFF 0x0080
#define OS_VI_GAMMA 0x08
#define OS_VI_GAMMA_DITHER 0x04
#define OS_VI_DIVOT 0x10
#define OS_VI_DITHER_FILTER 0x10000
#define OS_VI_UNK1 0x1
#define OS_VI_UNK2 0x2
#define OS_VI_UNK40 0x40
#define OS_VI_UNK100 0x100
#define OS_VI_UNK200 0x200
#define OS_VI_UNK1000 0x1000
#define OS_VI_UNK2000 0x2000
typedef struct {
/* 0x00 */ u32 ctrl;
/* 0x04 */ u32 width;
@@ -60,7 +48,7 @@ typedef struct {
typedef struct {
/* 0x00 */ u16 state;
/* 0x02 */ u16 retraceCount;
/* 0x04 */ void* buffer;
/* 0x04 */ void* framep;
/* 0x08 */ OSViMode* modep;
/* 0x0C */ u32 features;
/* 0x10 */ OSMesgQueue* mq;
@@ -132,6 +120,5 @@ typedef struct {
#define OS_TV_PAL 0
#define OS_TV_NTSC 1
#define OS_TV_MPAL 2
#define OS_VI_UNK28 28
#endif
+37
View File
@@ -0,0 +1,37 @@
#ifndef ULTRA64_VIINT_H
#define ULTRA64_VIINT_H
#define VI_STATE_MODE_SET (1 << 0)
#define VI_STATE_XSCALE_SET (1 << 1)
#define VI_STATE_YSCALE_FACTOR_SET (1 << 2)
#define VI_STATE_CTRL_SET (1 << 3)
#define VI_STATE_BUFFER_SET (1 << 4)
#define VI_STATE_BLACK (1 << 5)
#define VI_STATE_REPEATLINE (1 << 6)
#define VI_STATE_FADE (1 << 7)
#define VI_SCALE_MASK 0xFFF
#define VI_2_10_FPART_MASK 0x3FF
#define VI_SUBPIXEL_SH 0x10
// For use in initializing OSViMode structures
#define BURST(hsync_width, color_width, vsync_width, color_start) \
(hsync_width | (color_width << 8) | (vsync_width << 16) | (color_start << 20))
#define WIDTH(v) v
#define VSYNC(v) v
#define HSYNC(duration, leap) (duration | (leap << 16))
#define LEAP(upper, lower) ((upper << 16) | lower)
#define START(start, end) ((start << 16) | end)
#define FTOFIX(val, i, f) ((u32)(val * (f32)(1 << f)) & ((1 << (i + f)) - 1))
#define F210(val) FTOFIX(val, 2, 10)
#define SCALE(scaleup, off) (F210((1.0f / (f32)scaleup)) | (F210((f32)off) << 16))
#define VCURRENT(v) v
#define ORIGIN(v) v
#define VINTR(v) v
#define HSTART START
#endif
+1 -1
View File
@@ -45,7 +45,7 @@ extern u8 gBuildDate[];
extern u8 gBuildMakeOption[];
extern OSMesgQueue gPiMgrCmdQueue;
extern OSViMode gViConfigMode;
extern u8 D_80013960;
extern u8 gViConfigModeType;
extern OSMesgQueue __osPiAccessQueue;
extern OSPiHandle __Dom1SpeedParam;
extern OSPiHandle __Dom2SpeedParam;
+17 -10
View File
@@ -1725,20 +1725,27 @@ typedef struct {
/* 0x10 */ s16 unk_10;
} JpegDecoderState; // size = 0x14
typedef enum {
/* 0 */ VI_MODE_EDIT_STATE_INACTIVE,
/* 1 */ VI_MODE_EDIT_STATE_ACTIVE,
/* 2 */ VI_MODE_EDIT_STATE_2, // active, more adjustments
/* 3 */ VI_MODE_EDIT_STATE_3 // active, more adjustments, print comparison with NTSC LAN1 mode
} ViModeEditState;
typedef struct {
/* 0x0000 */ OSViMode customViMode;
/* 0x0050 */ s32 viHeight;
/* 0x0054 */ s32 viWidth;
/* 0x0058 */ s32 unk_58; // Right adjustment?
/* 0x005C */ s32 unk_5C; // Left adjustment?
/* 0x0060 */ s32 unk_60; // Bottom adjustment?
/* 0x0064 */ s32 unk_64; // Top adjustment?
/* 0x0068 */ s32 viModeBase; // enum: {0, 1, 2, 3}
/* 0x006C */ s32 viTvType;
/* 0x0070 */ u32 unk_70; // bool
/* 0x0074 */ u32 unk_74; // bool
/* 0x0078 */ u32 unk_78; // bool
/* 0x007C */ u32 unk_7C; // bool
/* 0x0058 */ s32 rightAdjust;
/* 0x005C */ s32 leftAdjust;
/* 0x0060 */ s32 lowerAdjust;
/* 0x0064 */ s32 upperAdjust;
/* 0x0068 */ s32 editState;
/* 0x006C */ s32 tvType;
/* 0x0070 */ u32 loRes;
/* 0x0074 */ u32 antialiasOff;
/* 0x0078 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution
/* 0x007C */ u32 fb16Bit;
/* 0x0080 */ u32 viFeatures;
/* 0x0084 */ u32 unk_84;
} ViMode;