src/core1: various video/screen/framebuffer related documentations
neue Datei: include/core1/vimgr.h
umbenannt: src/core1/code_E360.c -> src/core1/vimgr.c
This commit is contained in:
@@ -36,8 +36,6 @@ static u64 sDebugVar_8027BEF0; // never used
|
||||
|
||||
extern u8 core2_TEXT_START[];
|
||||
|
||||
extern u16 D_803A5D00[2][0x1ECC0/2];
|
||||
|
||||
void func_8023DA20(s32 arg0){
|
||||
bzero(&D_8027A130, core2_TEXT_START - (u8*)&D_8027A130);
|
||||
osWriteBackDCacheAll();
|
||||
@@ -53,7 +51,7 @@ void func_8023DA74(void){
|
||||
|
||||
void func_8023DA9C(s32 arg0){
|
||||
func_80254008();
|
||||
func_8024C428();
|
||||
viMgr_clearFramebuffers();
|
||||
if (D_8027A130 == 4){
|
||||
func_802E3580();
|
||||
}
|
||||
@@ -108,7 +106,7 @@ void core1_init(void) {
|
||||
ucode_load();
|
||||
setBootMap(getDefaultBootMap());
|
||||
rarezip_init(); //initialize decompressor's huft table
|
||||
func_8024BE30();
|
||||
viMgr_init();
|
||||
overlayManagerloadCore2();
|
||||
sDebugVar_8027BEF0 = sDebugVar_8027A538;
|
||||
heap_init();
|
||||
@@ -183,7 +181,7 @@ void mainLoop(void){
|
||||
){
|
||||
s32 offset;
|
||||
//render weird CRC failure image
|
||||
for(y= 0x1e; y < framebuffer_height - 0x1e; y++){//L8023DEB4
|
||||
for(y= 0x1e; y < gFramebufferHeight - 0x1e; y++){//L8023DEB4
|
||||
for(x = 0x14; x < 0xeb; x++){
|
||||
tmp = ((8 * globalTimer_getTime()) + ((x*x) + (y*y)));
|
||||
|
||||
@@ -194,9 +192,9 @@ void mainLoop(void){
|
||||
|
||||
rgba = b | r | g | a;
|
||||
|
||||
offset = ((framebuffer_width - 0xFF) / 2) + x + (y*framebuffer_width);
|
||||
D_803A5D00[0][offset] = (s32) rgba;
|
||||
D_803A5D00[1][offset] = (s32) rgba;
|
||||
offset = ((gFramebufferWidth - 0xFF) / 2) + x + (y*gFramebufferWidth);
|
||||
gFramebuffers[0][offset] = (s32) rgba;
|
||||
gFramebuffers[1][offset] = (s32) rgba;
|
||||
}
|
||||
}
|
||||
}//L8023DF70
|
||||
|
||||
@@ -4,72 +4,67 @@
|
||||
#include "variables.h"
|
||||
|
||||
struct {
|
||||
u16 *data;
|
||||
void *data;
|
||||
int unk4;
|
||||
} gzBuffer;
|
||||
} sDepthBuffer;
|
||||
|
||||
extern u8 D_8000E800;
|
||||
extern u16 D_803A5D00[2][0xF660];
|
||||
|
||||
void func_80253208(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer);
|
||||
|
||||
void func_80253190(Gfx **gdl){
|
||||
func_80253208(gdl, 0, 0, framebuffer_width, framebuffer_height, D_803A5D00[getActiveFramebuffer()]);
|
||||
void func_80253190(Gfx **gfx) {
|
||||
func_80253208(gfx, 0, 0, gFramebufferWidth, gFramebufferHeight, gFramebuffers[getActiveFramebuffer()]);
|
||||
}
|
||||
|
||||
void func_80253208(Gfx **gdl, s32 x, s32 y, s32 w, s32 h, void *color_buffer){
|
||||
if( gzBuffer.data != NULL && (getGameMode() != GAME_MODE_4_PAUSED || func_80335134())){
|
||||
void func_80253208(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, void *color_buffer){
|
||||
if( sDepthBuffer.data != NULL && (getGameMode() != GAME_MODE_4_PAUSED || func_80335134())){
|
||||
//draw z_buffer
|
||||
gDPPipeSync((*gdl)++);
|
||||
gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_K0_TO_PHYSICAL(gzBuffer.data));
|
||||
gDPSetCycleType((*gdl)++, G_CYC_FILL);
|
||||
gDPSetRenderMode((*gdl)++, G_RM_NOOP, G_RM_NOOP2);
|
||||
gDPSetFillColor((*gdl)++, 0xFFFCFFFC);
|
||||
gDPScisFillRectangle((*gdl)++, x, y, x + w - 1, y + h - 1);
|
||||
gDPPipeSync((*gfx)++);
|
||||
gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_K0_TO_PHYSICAL(sDepthBuffer.data));
|
||||
gDPSetCycleType((*gfx)++, G_CYC_FILL);
|
||||
gDPSetRenderMode((*gfx)++, G_RM_NOOP, G_RM_NOOP2);
|
||||
gDPSetFillColor((*gfx)++, 0xFFFCFFFC);
|
||||
gDPScisFillRectangle((*gfx)++, x, y, x + w - 1, y + h - 1);
|
||||
|
||||
//draw color_buffer
|
||||
gDPPipeSync((*gdl)++);
|
||||
gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_K0_TO_PHYSICAL(color_buffer));
|
||||
gDPPipeSync((*gfx)++);
|
||||
gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_K0_TO_PHYSICAL(color_buffer));
|
||||
}
|
||||
}
|
||||
|
||||
int func_80253400(void){
|
||||
return gzBuffer.unk4;
|
||||
return sDepthBuffer.unk4;
|
||||
}
|
||||
|
||||
int func_8025340C(void){
|
||||
return gzBuffer.data != NULL;
|
||||
bool depthBuffer_isPointerSet(void) {
|
||||
return sDepthBuffer.data != NULL;
|
||||
}
|
||||
|
||||
void dummy_func_80253420(void){}
|
||||
void depthBuffer_stub(void) {}
|
||||
|
||||
void func_80253428(int arg0) {
|
||||
u16 *var_v0;
|
||||
int new_var;
|
||||
if (arg0) {
|
||||
var_v0 = (gzBuffer.data = &D_8000E800);
|
||||
while (((s32) gzBuffer.data) % 0x40) {\
|
||||
var_v0 = (gzBuffer.data = var_v0 + 1);
|
||||
var_v0 = (sDepthBuffer.data = &D_8000E800);
|
||||
while (((s32) sDepthBuffer.data) % 0x40) {
|
||||
var_v0 = (sDepthBuffer.data = var_v0 + 1);
|
||||
}
|
||||
|
||||
do { } while ((&D_8000E800 && 1) * 0); //remove this
|
||||
}else{
|
||||
gzBuffer.data = 0;
|
||||
sDepthBuffer.data = NULL;
|
||||
}
|
||||
gzBuffer.unk4 = 0;
|
||||
sDepthBuffer.unk4 = FALSE;
|
||||
}
|
||||
|
||||
void func_802534A8(int arg0){
|
||||
gzBuffer.unk4 = (gzBuffer.data != NULL && arg0);
|
||||
void func_802534A8(int arg0) {
|
||||
sDepthBuffer.unk4 = (sDepthBuffer.data != NULL && arg0);
|
||||
}
|
||||
|
||||
void zBuffer_set(Gfx **gdl){
|
||||
if(gzBuffer.data && getGameMode() != GAME_MODE_4_PAUSED){
|
||||
gDPPipeSync((*gdl)++);
|
||||
gDPSetDepthImage((*gdl)++, gzBuffer.data);
|
||||
void zBuffer_set(Gfx **gfx) {
|
||||
if (sDepthBuffer.data && getGameMode() != GAME_MODE_4_PAUSED) {
|
||||
gDPPipeSync((*gfx)++);
|
||||
gDPSetDepthImage((*gfx)++, sDepthBuffer.data);
|
||||
}
|
||||
}
|
||||
|
||||
void *zBuffer_get(void){
|
||||
return gzBuffer.data;
|
||||
void *zBuffer_get(void) {
|
||||
return sDepthBuffer.data;
|
||||
}
|
||||
|
||||
@@ -1,29 +1,13 @@
|
||||
#include <ultra64.h>
|
||||
#include "core1/core1.h"
|
||||
#include "functions.h"
|
||||
#include "variables.h"
|
||||
|
||||
static Gfx *sGfxStack[2] = { NULL, NULL };
|
||||
s32 gFramebufferWidth = DEFAULT_FRAMEBUFFER_WIDTH;
|
||||
s32 gFramebufferHeight = DEFAULT_FRAMEBUFFER_HEIGHT;
|
||||
|
||||
typedef struct {
|
||||
s32 unk0;
|
||||
s32 unk4;
|
||||
Gfx *unk8;
|
||||
Gfx *unkC;
|
||||
s32 unk10;
|
||||
s32 unk14;
|
||||
}Struct_Core1_15B30;
|
||||
|
||||
extern u8 D_803A5D00[2][0x1ecc0];
|
||||
|
||||
/* .data */
|
||||
Gfx *gGfxStack[2] = {NULL, NULL};
|
||||
s32 framebuffer_width = 292;
|
||||
s32 framebuffer_height = 216;
|
||||
|
||||
/* .bss */
|
||||
Mtx *gMtxStack[2];
|
||||
Vtx *gVtxStack[2];
|
||||
s32 gStackSelector;
|
||||
static Mtx *sMtxStack[2];
|
||||
static Vtx *sVtxStack[2];
|
||||
static s32 sStackSelector;
|
||||
s32 gTextureFilterPoint;
|
||||
Struct_Core1_15B30 D_80283008[20];
|
||||
s32 D_802831E8;
|
||||
@@ -35,11 +19,6 @@ u16 gScissorBoxTop;
|
||||
u16 gScissorBoxBottom;
|
||||
Gfx *D_80283214;
|
||||
|
||||
/* .h */
|
||||
void scissorBox_setDefault(void);
|
||||
void dummy_func_80254464(void);
|
||||
|
||||
/* .code */
|
||||
void func_80253550(void){
|
||||
osRecvMesg(&D_802831F0, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
@@ -74,8 +53,8 @@ void func_80253640(Gfx ** gdl, void *arg1){
|
||||
gDPSetAlphaCompare((*gdl)++, G_AC_NONE);
|
||||
gDPSetColorDither((*gdl)++, G_CD_MAGICSQ);
|
||||
gDPSetScissor((*gdl)++, G_SC_NON_INTERLACE, gScissorBoxLeft, gScissorBoxRight, gScissorBoxTop, gScissorBoxBottom);
|
||||
func_80253208(gdl, 0, 0, framebuffer_width, framebuffer_height, arg1);
|
||||
gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_K0_TO_PHYSICAL(arg1));
|
||||
func_80253208(gdl, 0, 0, gFramebufferWidth, gFramebufferHeight, arg1);
|
||||
gDPSetColorImage((*gdl)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_K0_TO_PHYSICAL(arg1));
|
||||
gDPSetCycleType((*gdl)++, G_CYC_1CYCLE);
|
||||
gDPSetTextureConvert((*gdl)++, G_TC_FILT);
|
||||
gDPSetTextureDetail((*gdl)++, G_TD_CLAMP);
|
||||
@@ -98,13 +77,13 @@ void scissorBox_SetForGameMode(Gfx **gdl, s32 framebuffer_idx) {
|
||||
}
|
||||
else{
|
||||
scissorBox_setDefault();
|
||||
func_80253640(gdl, D_803A5D00[framebuffer_idx]);
|
||||
func_80253640(gdl, gFramebuffers[framebuffer_idx]);
|
||||
}
|
||||
}
|
||||
|
||||
void setupScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_address){
|
||||
gSPSegment((*gfx)++, 0x00, 0x00000000);
|
||||
gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, framebuffer_width, OS_PHYSICAL_TO_K0(framebuffer_address));
|
||||
gDPSetColorImage((*gfx)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, gFramebufferWidth, OS_PHYSICAL_TO_K0(framebuffer_address));
|
||||
gSPClearGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_CULL_BOTH | G_FOG | G_LIGHTING | G_TEXTURE_GEN | G_TEXTURE_GEN_LINEAR | G_LOD | G_SHADING_SMOOTH);
|
||||
gSPTexture((*gfx)++, 0, 0, 0, G_TX_RENDERTILE, G_OFF);
|
||||
gSPSetGeometryMode((*gfx)++, G_ZBUFFER | G_SHADE | G_SHADING_SMOOTH);
|
||||
@@ -121,7 +100,7 @@ void setupScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_address){
|
||||
|
||||
void setupDefaultScissorBoxAndFramebuffer(Gfx **gfx, s32 framebuffer_idx){
|
||||
scissorBox_setDefault();
|
||||
setupScissorBoxAndFramebuffer(gfx, D_803A5D00[framebuffer_idx]);
|
||||
setupScissorBoxAndFramebuffer(gfx, gFramebuffers[framebuffer_idx]);
|
||||
}
|
||||
|
||||
void func_80253DC0(Gfx **gfx){
|
||||
@@ -184,7 +163,7 @@ void scissorBox_get(u32 *left, u32 *top, u32 *right, u32 *bottom){
|
||||
}
|
||||
|
||||
void func_80253FE8(void){
|
||||
func_8024BFAC();
|
||||
viMgr_func_8024BFAC();
|
||||
}
|
||||
|
||||
void func_80254008(void){
|
||||
@@ -208,29 +187,29 @@ void drawRectangle2D(Gfx **gfx, s32 x, s32 y, s32 w, s32 h, s32 r, s32 g, s32 b)
|
||||
gDPScisFillRectangle((*gfx)++, x, y, x + w -1, y + h -1);
|
||||
}
|
||||
|
||||
void graphicsCache_release(void){
|
||||
if(gGfxStack[0]){
|
||||
free(gGfxStack[0]);
|
||||
free(gGfxStack[1]);
|
||||
free(gMtxStack[0]);
|
||||
free(gMtxStack[1]);
|
||||
free(gVtxStack[0]);
|
||||
free(gVtxStack[1]);
|
||||
gGfxStack[0] = NULL;
|
||||
void graphicsCache_release(void) {
|
||||
if (sGfxStack[0]) {
|
||||
free(sGfxStack[0]);
|
||||
free(sGfxStack[1]);
|
||||
free(sMtxStack[0]);
|
||||
free(sMtxStack[1]);
|
||||
free(sVtxStack[0]);
|
||||
free(sVtxStack[1]);
|
||||
sGfxStack[0] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void graphicsCache_init(void){
|
||||
if(gGfxStack[0] == NULL){
|
||||
gGfxStack[0] = (Gfx *)malloc(29600); // 3700 dlist commands
|
||||
gGfxStack[1] = (Gfx *)malloc(29600);
|
||||
gMtxStack[0] = (Mtx *)malloc(44800); // 700 matrices
|
||||
gMtxStack[1] = (Mtx *)malloc(44800);
|
||||
gVtxStack[0] = (Vtx *)malloc(6880); // 430 vertices
|
||||
gVtxStack[1] = (Vtx *)malloc(6880);
|
||||
if(sGfxStack[0] == NULL){
|
||||
sGfxStack[0] = (Gfx *)malloc(29600); // 3700 dlist commands
|
||||
sGfxStack[1] = (Gfx *)malloc(29600);
|
||||
sMtxStack[0] = (Mtx *)malloc(44800); // 700 matrices
|
||||
sMtxStack[1] = (Mtx *)malloc(44800);
|
||||
sVtxStack[0] = (Vtx *)malloc(6880); // 430 vertices
|
||||
sVtxStack[1] = (Vtx *)malloc(6880);
|
||||
dummy_func_80254464();
|
||||
}
|
||||
gStackSelector = 0;
|
||||
sStackSelector = 0;
|
||||
gTextureFilterPoint = 0;
|
||||
}
|
||||
|
||||
@@ -239,8 +218,8 @@ void scissorBox_set(s32 left, s32 top, s32 right, s32 bottom) {
|
||||
gScissorBoxTop = top;
|
||||
gScissorBoxRight = right;
|
||||
gScissorBoxBottom = bottom;
|
||||
framebuffer_width = top - left;
|
||||
framebuffer_height = bottom - right;
|
||||
gFramebufferWidth = top - left;
|
||||
gFramebufferHeight = bottom - right;
|
||||
viewport_pushFramebufferExtendsToVpStack();
|
||||
}
|
||||
|
||||
@@ -253,7 +232,7 @@ void func_80254374(s32 arg0) {
|
||||
Struct_Core1_15B30 *sp1C;
|
||||
|
||||
func_80253550();
|
||||
func_8024C2A0(arg0);
|
||||
viMgr_setActiveFramebuffer(arg0);
|
||||
sp1C = &D_80283008[D_802831E8];
|
||||
D_802831E8 = (s32) (D_802831E8 + 1) % 20;
|
||||
func_8025357C();
|
||||
@@ -267,10 +246,10 @@ void toggleTextureFilterPoint(void){
|
||||
}
|
||||
|
||||
void getGraphicsStacks(Gfx **gfx, Mtx **mtx, Vtx **vtx){
|
||||
gStackSelector = (1 - gStackSelector);
|
||||
*gfx = gGfxStack[gStackSelector];
|
||||
*mtx = gMtxStack[gStackSelector];
|
||||
*vtx = gVtxStack[gStackSelector];
|
||||
sStackSelector = (1 - sStackSelector);
|
||||
*gfx = sGfxStack[sStackSelector];
|
||||
*mtx = sMtxStack[sStackSelector];
|
||||
*vtx = sVtxStack[sStackSelector];
|
||||
}
|
||||
|
||||
void dummy_func_80254464(void){}
|
||||
void dummy_func_80254464(void) {}
|
||||
|
||||
@@ -219,7 +219,7 @@ void func_80246C2C(void){
|
||||
if((D_8027FC14 << 1) < 0){
|
||||
osDpSetStatus(DPC_SET_FREEZE);
|
||||
D_80280688 = osViGetCurrentFramebuffer();
|
||||
func_8024BFAC();
|
||||
viMgr_func_8024BFAC();
|
||||
}
|
||||
D_8027FC14 = D_8027FC18 = 2;
|
||||
D_80275998 = 0;
|
||||
@@ -474,7 +474,7 @@ void func_80247560(void){
|
||||
osSetEventMesg(OS_EVENT_SP, &D_8027FB60, CORE1_8C50_EVENT_SP);
|
||||
osSetEventMesg(OS_EVENT_FAULT, &D_8027FB60, CORE1_8C50_EVENT_FAULT);
|
||||
osSetEventMesg(OS_EVENT_PRENMI, &D_8027FB60, CORE1_8C50_EVENT_PRENMI);
|
||||
func_8024BDAC(&D_8027FB60, 5);
|
||||
viMgr_func_8024BDAC(&D_8027FB60, 5);
|
||||
D_8027FC0C = 0;
|
||||
D_8027FC10 = 0;
|
||||
D_8027FC14 = D_8027FC18 = 2;
|
||||
|
||||
@@ -6,9 +6,6 @@
|
||||
#include "version.h"
|
||||
|
||||
#if VERSION == VERSION_USA_1_0
|
||||
extern u16 D_803A5D00[2][0xF660]; //framebuffer
|
||||
extern s32 framebuffer_width; //framebuffer width
|
||||
extern s32 framebuffer_height; //framebuffer height
|
||||
|
||||
/* .data */
|
||||
u8 D_80275A50[8][3] = {
|
||||
@@ -96,11 +93,11 @@ void func_80247750(s32 r, s32 g, s32 b){
|
||||
|
||||
void func_8024776C(s32 x, s32 y) {
|
||||
s32 rgba16;
|
||||
if( ((x >= 0) && (x < framebuffer_width))
|
||||
&& ((y >= 0) && (y < framebuffer_height))
|
||||
if( ((x >= 0) && (x < gFramebufferWidth))
|
||||
&& ((y >= 0) && (y < gFramebufferHeight))
|
||||
) {
|
||||
D_803A5D00[0][x + y*framebuffer_width] = _SHIFTL(D_80275A68 >> 3, 11, 5) | _SHIFTL(D_80275A6C >> 3, 6, 5) | _SHIFTL(D_80275A70 >> 3, 1, 5) | _SHIFTL(1, 0, 1);
|
||||
D_803A5D00[1][x + y*framebuffer_width] = _SHIFTL(D_80275A68 >> 3, 11, 5) | _SHIFTL(D_80275A6C >> 3, 6, 5) | _SHIFTL(D_80275A70 >> 3, 1, 5) | _SHIFTL(1, 0, 1);
|
||||
gFramebuffers[0][x + y*gFramebufferWidth] = _SHIFTL(D_80275A68 >> 3, 11, 5) | _SHIFTL(D_80275A6C >> 3, 6, 5) | _SHIFTL(D_80275A70 >> 3, 1, 5) | _SHIFTL(1, 0, 1);
|
||||
gFramebuffers[1][x + y*gFramebufferWidth] = _SHIFTL(D_80275A68 >> 3, 11, 5) | _SHIFTL(D_80275A6C >> 3, 6, 5) | _SHIFTL(D_80275A70 >> 3, 1, 5) | _SHIFTL(1, 0, 1);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -120,7 +117,7 @@ void func_80247818(s32 x, s32 y, s32 w, s32 h) {
|
||||
|
||||
void func_802478C0(s32 r, s32 g, s32 b) {
|
||||
func_80247750(r, g, b);
|
||||
func_80247818((framebuffer_width - 128) / 2, (framebuffer_height - 100) / 2, 128, 100);
|
||||
func_80247818((gFramebufferWidth - 128) / 2, (gFramebufferHeight - 100) / 2, 128, 100);
|
||||
}
|
||||
|
||||
void func_8024792C(void){}
|
||||
@@ -207,9 +204,9 @@ void func_80247C20(void) {
|
||||
}
|
||||
|
||||
if (D_80275BE0) {
|
||||
for(i = 0; i < framebuffer_width * framebuffer_height; i++){
|
||||
D_803A5D00[0][i] = 0;
|
||||
D_803A5D00[1][i] = 0;
|
||||
for(i = 0; i < gFramebufferWidth * gFramebufferHeight; i++){
|
||||
gFramebuffers[0][i] = 0;
|
||||
gFramebuffers[1][i] = 0;
|
||||
}
|
||||
osWriteBackDCacheAll();
|
||||
}
|
||||
|
||||
@@ -21,11 +21,6 @@ void draw_prim_rect(s32 x, s32 y, s32 w, s32 h);
|
||||
void set_prim_color(s32 r, s32 g, s32 b);
|
||||
void func_8024A85C(s32 buffer_indx);
|
||||
|
||||
|
||||
extern u16 D_803A5D00[2][0xF660]; //framebuffer
|
||||
extern s32 framebuffer_width; //framebuffer width
|
||||
extern s32 framebuffer_height; //framebuffer height
|
||||
|
||||
/* .bss */
|
||||
s32 D_802806E0;
|
||||
s32 D_802806E4;
|
||||
@@ -51,7 +46,7 @@ void draw_sprite_ci4(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enable
|
||||
s32 color1;
|
||||
s32 color2;
|
||||
|
||||
framebuffer = D_803A5D00[D_802806EC];
|
||||
framebuffer = gFramebuffers[D_802806EC];
|
||||
sprite_frame = spriteGetFramePtr(sprite, (u32) frame);
|
||||
if (!alpha_enabled){
|
||||
set_prim_color(0, 0, 0x80);
|
||||
@@ -79,12 +74,12 @@ void draw_sprite_ci4(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enable
|
||||
indx1 = ((*tmem) >> 4) & 0xF;
|
||||
indx2 = *tmem & 0xF;
|
||||
fb_x = (chunk->x + x) + ix;
|
||||
if ((0 <= fb_x) && (fb_x < framebuffer_width))
|
||||
if ((0 <= fb_x) && (fb_x < gFramebufferWidth))
|
||||
{
|
||||
fb_y = (chunk->y + y) + iy;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height))
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight))
|
||||
{
|
||||
pxl_ptr = (framebuffer + fb_x) + (fb_y * framebuffer_width);
|
||||
pxl_ptr = (framebuffer + fb_x) + (fb_y * gFramebufferWidth);
|
||||
color1 = palette[indx1];
|
||||
if (color1 & 1) {
|
||||
*pxl_ptr = color1;
|
||||
@@ -127,7 +122,7 @@ void draw_sprite_ci8(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enable
|
||||
if (D_80275C00 == 0xA) {
|
||||
D_80275C00 = 0;
|
||||
}
|
||||
framebuffer = D_803A5D00[D_802806EC];
|
||||
framebuffer = gFramebuffers[D_802806EC];
|
||||
sprite_frame = spriteGetFramePtr(sprite, (u32) frame);
|
||||
if (!alpha_enabled){
|
||||
set_prim_color(0, 0, 0x80);
|
||||
@@ -150,12 +145,12 @@ void draw_sprite_ci8(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enable
|
||||
for (iy = 0; iy < chunk->h; iy++){
|
||||
for (ix = 0; ix < chunk->w; ix++){
|
||||
fb_x = (chunk->x + x) + ix;
|
||||
if ((0 <= fb_x) && (fb_x < framebuffer_width))
|
||||
if ((0 <= fb_x) && (fb_x < gFramebufferWidth))
|
||||
{
|
||||
fb_y = (chunk->y + y) + iy;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height))
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight))
|
||||
{
|
||||
pxl_ptr = (framebuffer + fb_x) + (fb_y * framebuffer_width);
|
||||
pxl_ptr = (framebuffer + fb_x) + (fb_y * gFramebufferWidth);
|
||||
if (palette[*tmem] & 1){
|
||||
*pxl_ptr = palette[*tmem];
|
||||
}
|
||||
@@ -193,7 +188,7 @@ void draw_sprite_rgba16(s32 x, s32 y, BKSprite *sprite, s32 frame, bool alpha_en
|
||||
u16 *pxl_ptr;
|
||||
u16 rgba;
|
||||
|
||||
framebuffer_ptr = &D_803A5D00[D_802806EC][0];
|
||||
framebuffer_ptr = &gFramebuffers[D_802806EC][0];
|
||||
sprite_ptr = spriteGetFramePtr(sprite, frame);
|
||||
if (!alpha_enabled) {
|
||||
set_prim_color(0, 0, 0x80);
|
||||
@@ -206,10 +201,10 @@ void draw_sprite_rgba16(s32 x, s32 y, BKSprite *sprite, s32 frame, bool alpha_en
|
||||
for(txtr_y = 0; txtr_y < chunk_ptr->h; txtr_y++) {
|
||||
for(txtr_x = 0; txtr_x < chunk_ptr->w; txtr_x++) {
|
||||
fb_x = chunk_ptr->x + x + txtr_x;
|
||||
if ((fb_x >= 0) && (fb_x < framebuffer_width)) {
|
||||
if ((fb_x >= 0) && (fb_x < gFramebufferWidth)) {
|
||||
fb_y = chunk_ptr->y + y + txtr_y;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height)) {
|
||||
pxl_ptr = framebuffer_ptr + fb_x + (fb_y * framebuffer_width);
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight)) {
|
||||
pxl_ptr = framebuffer_ptr + fb_x + (fb_y * gFramebufferWidth);
|
||||
rgba = *tmem;
|
||||
if (rgba & 1) {
|
||||
*pxl_ptr = rgba;
|
||||
@@ -240,7 +235,7 @@ void draw_sprite_i4(s32 x, s32 y, BKSprite *sprite, s32 frame, bool aplha_enable
|
||||
s32 txtr_x;
|
||||
u16 *fb_pxl_ptr;
|
||||
|
||||
framebuffer_ptr = &D_803A5D00[D_802806EC][0];
|
||||
framebuffer_ptr = &gFramebuffers[D_802806EC][0];
|
||||
frame_ptr = spriteGetFramePtr(sprite, frame);
|
||||
if (!aplha_enabled) {
|
||||
set_prim_color(0, 0, 0x80);
|
||||
@@ -253,12 +248,12 @@ void draw_sprite_i4(s32 x, s32 y, BKSprite *sprite, s32 frame, bool aplha_enable
|
||||
for(txtr_y = 0; txtr_y < chunk_ptr->h; txtr_y++) {
|
||||
for(txtr_x = 0; txtr_x < chunk_ptr->w; txtr_x += 2) {
|
||||
fb_x = chunk_ptr->x + x + txtr_x;
|
||||
if ((fb_x >= 0) && (fb_x < framebuffer_width)) {
|
||||
if ((fb_x >= 0) && (fb_x < gFramebufferWidth)) {
|
||||
fb_y = chunk_ptr->y + y + txtr_y;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height)) {
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight)) {
|
||||
p1 = (*tmem >> 4);
|
||||
p2 = (*tmem & 0xF);
|
||||
fb_pxl_ptr = framebuffer_ptr + fb_x + (fb_y * framebuffer_width);
|
||||
fb_pxl_ptr = framebuffer_ptr + fb_x + (fb_y * gFramebufferWidth);
|
||||
if (p1) {
|
||||
*fb_pxl_ptr = (p1 << 0xC) | (p1 << 0x7) | (p1 << 0x2) | 1;
|
||||
} else if (!aplha_enabled) {
|
||||
@@ -297,7 +292,7 @@ void draw_sprite_ia4(s32 x, s32 y, BKSprite *sprite, s32 frame, bool aplha_enabl
|
||||
s32 txtr_x;
|
||||
u16 *fb_pxl_ptr;
|
||||
|
||||
framebuffer_ptr = &D_803A5D00[D_802806EC][0];
|
||||
framebuffer_ptr = &gFramebuffers[D_802806EC][0];
|
||||
frame_ptr = spriteGetFramePtr(sprite, frame);
|
||||
if (!aplha_enabled) {
|
||||
set_prim_color(0, 0, 0x80);
|
||||
@@ -310,10 +305,10 @@ void draw_sprite_ia4(s32 x, s32 y, BKSprite *sprite, s32 frame, bool aplha_enabl
|
||||
for(txtr_y = 0; txtr_y < chunk_ptr->h; txtr_y++) {
|
||||
for(txtr_x = 0; txtr_x < chunk_ptr->w; txtr_x += 2) {
|
||||
fb_x = chunk_ptr->x + x + txtr_x;
|
||||
if ((fb_x >= 0) && (fb_x < framebuffer_width)) {
|
||||
if ((fb_x >= 0) && (fb_x < gFramebufferWidth)) {
|
||||
fb_y = chunk_ptr->y + y + txtr_y;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height)) {
|
||||
fb_pxl_ptr = framebuffer_ptr + fb_x + (fb_y * framebuffer_width);\
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight)) {
|
||||
fb_pxl_ptr = framebuffer_ptr + fb_x + (fb_y * gFramebufferWidth);\
|
||||
p1 = (*tmem >> 4);
|
||||
p2 = (*tmem & 0xF);
|
||||
p1_i = p1 & 0xE;
|
||||
@@ -352,7 +347,7 @@ void draw_sprite_i8(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enabled
|
||||
s32 i_chunk;
|
||||
s32 txtr_y;
|
||||
|
||||
framebuffer_ptr = &D_803A5D00[D_802806EC][0];
|
||||
framebuffer_ptr = &gFramebuffers[D_802806EC][0];
|
||||
frame_ptr = spriteGetFramePtr(sprite, frame);
|
||||
if (!alpha_enabled) {
|
||||
set_prim_color(0, 0, 0x80);
|
||||
@@ -367,10 +362,10 @@ void draw_sprite_i8(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_enabled
|
||||
for(txtr_x = 0; txtr_x < chunk_ptr->w; txtr_x++){
|
||||
fb_x = chunk_ptr->x + x + txtr_x;
|
||||
if (fb_x >= 0) {
|
||||
if (fb_x < framebuffer_width) {
|
||||
if (fb_x < gFramebufferWidth) {
|
||||
fb_y = chunk_ptr->y + y + txtr_y;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height)) {
|
||||
pixel_ptr = framebuffer_ptr + fb_x + fb_y * framebuffer_width;
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight)) {
|
||||
pixel_ptr = framebuffer_ptr + fb_x + fb_y * gFramebufferWidth;
|
||||
intensity = (s32) *txtr_ptr >> 3;
|
||||
if (intensity != 0) {
|
||||
*pixel_ptr = (intensity << 0xB) | (intensity << 6) | (intensity << 1) | 1;
|
||||
@@ -401,7 +396,7 @@ void draw_sprite_ia8(s32 x, s32 y, BKSprite *sprite, s32 frame, bool alpha_enabl
|
||||
s32 var_t3;
|
||||
u32 temp_a2;
|
||||
|
||||
framebuffer_ptr = &D_803A5D00[D_802806EC][0];
|
||||
framebuffer_ptr = &gFramebuffers[D_802806EC][0];
|
||||
sprite_frame = spriteGetFramePtr(sprite, frame);
|
||||
if (!alpha_enabled) {
|
||||
//draw blue rect over display area
|
||||
@@ -415,10 +410,10 @@ void draw_sprite_ia8(s32 x, s32 y, BKSprite *sprite, s32 frame, bool alpha_enabl
|
||||
for(var_t3 = 0; var_t3 < chunk_ptr->h; var_t3++){
|
||||
for(var_a3 = 0; var_a3 < chunk_ptr->w; var_a3++) {
|
||||
fb_x = chunk_ptr->x + x + var_a3;
|
||||
if ((fb_x >= 0) && (fb_x < framebuffer_width)) {
|
||||
if ((fb_x >= 0) && (fb_x < gFramebufferWidth)) {
|
||||
fb_y = chunk_ptr->y + y + var_t3;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height)) {
|
||||
temp_a1 = framebuffer_ptr + fb_x + fb_y * framebuffer_width;
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight)) {
|
||||
temp_a1 = framebuffer_ptr + fb_x + fb_y * gFramebufferWidth;
|
||||
temp_a2 = *var_t2;
|
||||
if (IA8_A(temp_a2)) {
|
||||
*temp_a1 = I4_2_RGBA16(IA8_I(temp_a2), 1);
|
||||
@@ -456,7 +451,7 @@ void draw_sprite_rgba32(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_ena
|
||||
s32 blue8;
|
||||
|
||||
|
||||
framebuffer = &D_803A5D00[D_802806EC][0];
|
||||
framebuffer = &gFramebuffers[D_802806EC][0];
|
||||
sprite_frame = spriteGetFramePtr(sprite, frame);
|
||||
if (!alpha_enabled) {
|
||||
set_prim_color(0, 0, 0x80);
|
||||
@@ -478,13 +473,13 @@ void draw_sprite_rgba32(s32 x, s32 y, BKSprite *sprite, s32 frame, s32 alpha_ena
|
||||
for (ix = 0; ix < chunk_ptr->w; ix++)
|
||||
{
|
||||
fb_x = (chunk_ptr->x + x) + ix;
|
||||
if ((fb_x >= 0) && (fb_x < framebuffer_width))
|
||||
if ((fb_x >= 0) && (fb_x < gFramebufferWidth))
|
||||
{
|
||||
fb_y = (chunk_ptr->y + y) + iy;
|
||||
if ((fb_y >= 0) && (fb_y < framebuffer_height))
|
||||
if ((fb_y >= 0) && (fb_y < gFramebufferHeight))
|
||||
{
|
||||
txtr_value = *tmem;
|
||||
pxl_ptr = (framebuffer + fb_x) + (fb_y * framebuffer_width);
|
||||
pxl_ptr = (framebuffer + fb_x) + (fb_y * gFramebufferWidth);
|
||||
fb_value = (unsigned int) (*pxl_ptr);
|
||||
alpha = _SHIFTR(txtr_value, 0, 8);
|
||||
if (alpha) {//blend texture with existing pixel color
|
||||
@@ -524,7 +519,7 @@ void draw_texture_ci4(s32 x, s32 y, void *tmem, s32 w, s32 h, bool alpha_enabled
|
||||
|
||||
palette_ptr = (u16*)tmem;
|
||||
pixel_ptr = (u8*)&palette_ptr[0x10];
|
||||
framebuffer_ptr = &D_803A5D00[D_802806EC][x + y * framebuffer_width];
|
||||
framebuffer_ptr = &gFramebuffers[D_802806EC][x + y * gFramebufferWidth];
|
||||
for(iy = 0; iy < h; iy++){
|
||||
for(ix = 0; ix < w; ix++){
|
||||
icolor = (ix & 1)? pixel_ptr[ix/2 + (iy*w)/2] & 0xF
|
||||
@@ -532,7 +527,7 @@ void draw_texture_ci4(s32 x, s32 y, void *tmem, s32 w, s32 h, bool alpha_enabled
|
||||
*framebuffer_ptr = palette_ptr[icolor];
|
||||
framebuffer_ptr++;
|
||||
}
|
||||
framebuffer_ptr += (framebuffer_width - w);
|
||||
framebuffer_ptr += (gFramebufferWidth - w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -576,7 +571,7 @@ void func_80249DE0(s32 x, s32 y, s16 *arg2, s32 arg3, s32 arg4) {
|
||||
return;
|
||||
}
|
||||
//otherwise RGBA16
|
||||
framebuffer_ptr = &D_803A5D00[D_802806EC][x + y*framebuffer_width];
|
||||
framebuffer_ptr = &gFramebuffers[D_802806EC][x + y*gFramebufferWidth];
|
||||
for(iy = 0; iy < temp_v0->h; iy++){
|
||||
for(ix = 0; ix < temp_v0->w; ix++){
|
||||
temp_v1 = *texture_ptr;
|
||||
@@ -588,7 +583,7 @@ void func_80249DE0(s32 x, s32 y, s16 *arg2, s32 arg3, s32 arg4) {
|
||||
texture_ptr++;
|
||||
framebuffer_ptr++;
|
||||
}
|
||||
framebuffer_ptr += (framebuffer_width - temp_v0->w);
|
||||
framebuffer_ptr += (gFramebufferWidth - temp_v0->w);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,7 +596,7 @@ void func_80249F34(s32 x, s32 y, Struct84s* maskList, s32 maskIndex, s32 mX, s32
|
||||
|
||||
mask_texture = func_8033EFB0(maskList, maskIndex);
|
||||
mask_ptr = (u16*)(mask_texture + 1) + mX + mY * mask_texture->w;
|
||||
color_ptr = &D_803A5D00[D_802806EC][x + y * framebuffer_width];
|
||||
color_ptr = &gFramebuffers[D_802806EC][x + y * gFramebufferWidth];
|
||||
for(iy = 0; iy < mH; iy += mStride){
|
||||
for(ix = 0; ix < mW; ix++){
|
||||
|
||||
@@ -619,7 +614,7 @@ void func_80249F34(s32 x, s32 y, Struct84s* maskList, s32 maskIndex, s32 mX, s32
|
||||
mask_ptr++;
|
||||
}
|
||||
mask_ptr += ((mStride * mask_texture->w) - mW);
|
||||
color_ptr += (framebuffer_width - mW);
|
||||
color_ptr += (gFramebufferWidth - mW);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,14 +623,14 @@ void func_8024A284(s32 x, s32 y, s32 arg2, s32 arg3, s32 horz_spacing, s32 vert_
|
||||
s32 var_s2;
|
||||
s32 var_s3;
|
||||
|
||||
for(var_s2 = 0; var_s2 < framebuffer_width; var_s2 += horz_spacing){
|
||||
for(var_s3 = 0; var_s3 < framebuffer_height; var_s3++){
|
||||
for(var_s2 = 0; var_s2 < gFramebufferWidth; var_s2 += horz_spacing){
|
||||
for(var_s3 = 0; var_s3 < gFramebufferHeight; var_s3++){
|
||||
func_8024A3C8(x + var_s2, y + var_s3);
|
||||
|
||||
}
|
||||
}
|
||||
for(var_s3 = 0; var_s3 < framebuffer_height; var_s3 += vert_spacing) {
|
||||
for(var_s2 = 0; var_s2 < framebuffer_width; var_s2++){
|
||||
for(var_s3 = 0; var_s3 < gFramebufferHeight; var_s3 += vert_spacing) {
|
||||
for(var_s2 = 0; var_s2 < gFramebufferWidth; var_s2++){
|
||||
func_8024A3C8(x + var_s2, y + var_s3);
|
||||
}
|
||||
}
|
||||
@@ -646,8 +641,8 @@ void func_8024A3C8(s32 x, s32 y) {
|
||||
s32 temp_v0;
|
||||
|
||||
if (x >= 0) {
|
||||
if ((x < framebuffer_width) && (y >= 0) && (y < framebuffer_height)) {
|
||||
D_803A5D00[D_802806EC][x + y * framebuffer_width] = _SHIFTL(D_802806E0 >> 3, 11, 5) | _SHIFTL(D_802806E4 >> 3, 6, 5) | _SHIFTL(D_802806E8 >> 3, 1, 5) | _SHIFTL(1, 0, 1);
|
||||
if ((x < gFramebufferWidth) && (y >= 0) && (y < gFramebufferHeight)) {
|
||||
gFramebuffers[D_802806EC][x + y * gFramebufferWidth] = _SHIFTL(D_802806E0 >> 3, 11, 5) | _SHIFTL(D_802806E4 >> 3, 6, 5) | _SHIFTL(D_802806E8 >> 3, 1, 5) | _SHIFTL(1, 0, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -688,8 +683,8 @@ void func_8024A564(s32 x, s32 y, u16 *arg2, s32 arg3, s32 arg4, f32 arg5, f32 ar
|
||||
s16 *var_t0;
|
||||
s16 *var_t2;
|
||||
var_v0 = 0;
|
||||
var_v1 = framebuffer_width;
|
||||
var_t0 = &D_803A5D00[D_802806EC][x + (y * framebuffer_width)];
|
||||
var_v1 = gFramebufferWidth;
|
||||
var_t0 = &gFramebuffers[D_802806EC][x + (y * gFramebufferWidth)];
|
||||
new_var = (s32) (((f64) (256.0f / (new_var3 = arg6))) + 0.5);
|
||||
new_var2 = (s32) (((f64) (256.0f / arg5)) + 0.5);
|
||||
for (var_t1 = (arg4 * arg6) + 0.5; var_t1 != 0; var_t1--)
|
||||
@@ -704,7 +699,7 @@ void func_8024A564(s32 x, s32 y, u16 *arg2, s32 arg3, s32 arg4, f32 arg5, f32 ar
|
||||
var_t2++;
|
||||
}
|
||||
|
||||
var_t0 += framebuffer_width;
|
||||
var_t0 += gFramebufferWidth;
|
||||
var_v0 += new_var;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ typedef struct{
|
||||
|
||||
extern struct49s D_803FFE10[];
|
||||
|
||||
extern u8 D_8000E800;
|
||||
extern u8 D_8002D500;
|
||||
extern u32 D_8027BF2C;
|
||||
extern u32 D_8027BF30;
|
||||
|
||||
@@ -18,7 +18,6 @@ typedef struct struct_2a_s{
|
||||
} OverlayAddressMap;
|
||||
|
||||
|
||||
extern u8 D_803A5D00;
|
||||
|
||||
#define SEGMENT_EXTERNS(segname) \
|
||||
extern u8 segname##_VRAM[]; \
|
||||
@@ -112,7 +111,7 @@ s32 __overlayManager80251178(void){
|
||||
sp18 = func_802546DC();
|
||||
sp1C = __overlayManager80251170();
|
||||
|
||||
return ((sp1C + &D_803A5D00) - largest_overlay->ram_end) + sp18;
|
||||
return ((sp1C + (u8 *)gFramebuffers) - largest_overlay->ram_end) + sp18;
|
||||
}
|
||||
|
||||
void __overlayManager802511C4(void){
|
||||
|
||||
@@ -126,7 +126,7 @@ void rumbleManager_init(void) {
|
||||
osCreateMesgQueue(&D_80282390, &D_802823A8, 1);
|
||||
osCreateThread(&sRumbleThread, 8, rumbleThread_entry, NULL, sRumbleThreadStack + RUMBLE_THREAD_STACK_SIZE, 25);
|
||||
osStartThread(&sRumbleThread);
|
||||
func_8024BDAC(&D_80282390, 0);
|
||||
viMgr_func_8024BDAC(&D_80282390, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ void viewport_getRotation_f3(f32 *pitch, f32 *yaw, f32 *roll) {
|
||||
void viewport_setRenderViewportAndOrthoMatrix(Gfx **gfx, Mtx **mtx) {
|
||||
gSPViewport((*gfx)++, &sViewportStack[sViewportStackIndex]);
|
||||
|
||||
guOrtho(*mtx, -(2*(f32)framebuffer_width), (2*(f32)framebuffer_width), -(2*(f32)framebuffer_height), (2*(f32)framebuffer_height), 1.0f, 20.0f, 1.0f);
|
||||
guOrtho(*mtx, -(2*(f32)gFramebufferWidth), (2*(f32)gFramebufferWidth), -(2*(f32)gFramebufferHeight), (2*(f32)gFramebufferHeight), 1.0f, 20.0f, 1.0f);
|
||||
gSPMatrix((*gfx)++, OS_K0_TO_PHYSICAL((*mtx)++), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
|
||||
|
||||
guTranslate(*mtx, 0.0f, 0.0f, 0.0f);
|
||||
@@ -133,7 +133,7 @@ f32 viewport_debug3(void) {
|
||||
}
|
||||
|
||||
void viewport_pushFramebufferExtendsToVpStack(void) {
|
||||
viewport_pushVpScaleAndTranslation((s32) ((f32)framebuffer_width/2), (s32) ((f32)framebuffer_height/2), (s32) ((f32)framebuffer_width/2), (s32) ((f32)framebuffer_height/2));
|
||||
viewport_pushVpScaleAndTranslation((s32) ((f32)gFramebufferWidth/2), (s32) ((f32)gFramebufferHeight/2), (s32) ((f32)gFramebufferWidth/2), (s32) ((f32)gFramebufferHeight/2));
|
||||
}
|
||||
|
||||
void viewport_reset(void) {
|
||||
@@ -427,13 +427,13 @@ f32 viewport_transformCoordinate(f32 x, f32 y, f32 viewport_translation[3], f32
|
||||
|
||||
if ((sViewportFOVy != fovy) || (sViewportNear != near)) {
|
||||
fovy_rad = (sViewportFOVy * M_PI) / 360.0;
|
||||
scale = (500.0 + sViewportNear) / (((framebuffer_height / (f32)2) / sinf(fovy_rad)) * cosf(fovy_rad));
|
||||
scale = (500.0 + sViewportNear) / (((gFramebufferHeight / (f32)2) / sinf(fovy_rad)) * cosf(fovy_rad));
|
||||
fovy = sViewportFOVy;
|
||||
near = sViewportNear;
|
||||
}
|
||||
|
||||
x = x - (framebuffer_width / (f32)2);
|
||||
y = (framebuffer_height / (f32)2) - y;
|
||||
x = x - (gFramebufferWidth / (f32)2);
|
||||
y = (gFramebufferHeight / (f32)2) - y;
|
||||
|
||||
viewport_rotation[0] = sViewportRotation[0];
|
||||
viewport_rotation[1] = sViewportRotation[1];
|
||||
@@ -481,16 +481,16 @@ bool viewport_func_8024E030(f32 pos[3], f32 *arg1)
|
||||
}
|
||||
|
||||
temp_f2 = gu_sqrtf((delta[1] * delta[1]) + (delta[2] * delta[2])) * sinf(fovy_radians);
|
||||
temp_f2_2 = (((f32) framebuffer_width) / ((f32) framebuffer_height)) * temp_f2;
|
||||
temp_f2_2 = (((f32) gFramebufferWidth) / ((f32) gFramebufferHeight)) * temp_f2;
|
||||
|
||||
arg1[0] = (f32) (((delta[0] / temp_f2_2) + 1) * (((f32) framebuffer_width) / 2));
|
||||
arg1[1] = (f32) ((1 - (delta[1] / temp_f2)) * (((f32) framebuffer_height) / 2));
|
||||
arg1[0] = (f32) (((delta[0] / temp_f2_2) + 1) * (((f32) gFramebufferWidth) / 2));
|
||||
arg1[1] = (f32) ((1 - (delta[1] / temp_f2)) * (((f32) gFramebufferHeight) / 2));
|
||||
|
||||
if ((arg1[0] < (-((f32) framebuffer_width))) || ((((f32) framebuffer_width) * 2) < arg1[0])) {
|
||||
if ((arg1[0] < (-((f32) gFramebufferWidth))) || ((((f32) gFramebufferWidth) * 2) < arg1[0])) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((arg1[1] < (-((f32) framebuffer_height))) || ((((f32) framebuffer_height) * 2) < arg1[1])) {
|
||||
if ((arg1[1] < (-((f32) gFramebufferHeight))) || ((((f32) gFramebufferHeight) * 2) < arg1[1])) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,18 +4,10 @@
|
||||
#include "variables.h"
|
||||
#include "version.h"
|
||||
|
||||
#define VIMANAGER_THREAD_STACK_SIZE 0x400
|
||||
|
||||
void func_8024BF94(s32 arg0);
|
||||
void func_8024C2F8(void *);
|
||||
|
||||
typedef struct struct_1_s{
|
||||
OSMesgQueue *messageQueue;
|
||||
OSMesg message;
|
||||
} struct1;
|
||||
|
||||
extern u32 D_80000300;
|
||||
|
||||
OSViMode D_80275C80 = {
|
||||
// Used in US 1.0 NTSC
|
||||
static OSViMode sViMode_US10_NTSC = {
|
||||
OS_VI_NTSC_LPN1,
|
||||
{
|
||||
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | 0x3200, /*ctrl*/
|
||||
@@ -34,7 +26,8 @@ OSViMode D_80275C80 = {
|
||||
}
|
||||
};
|
||||
|
||||
OSViMode D_80275CD0 = {
|
||||
// Used in US 1.0 MPAL (N64 SDK says: "mainly brazil")
|
||||
static OSViMode sViMode_US10_MPAL = {
|
||||
OS_VI_MPAL_LPN1,
|
||||
{
|
||||
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | 0x3200, /*ctrl*/
|
||||
@@ -54,7 +47,8 @@ OSViMode D_80275CD0 = {
|
||||
};
|
||||
|
||||
#if VERSION == VERSION_PAL
|
||||
OSViMode D_PAL_80275CD0 = {
|
||||
// Used in PAL
|
||||
static OSViMode sViMode_PAL = {
|
||||
OS_VI_PAL_LPN1,
|
||||
{
|
||||
VI_CTRL_TYPE_16 | VI_CTRL_GAMMA_DITHER_ON | VI_CTRL_GAMMA_ON | VI_CTRL_DIVOT_ON | 0x3100, /*ctrl*/
|
||||
@@ -77,43 +71,34 @@ OSViMode D_PAL_80275CD0 = {
|
||||
// 42200000 3FAD097B 41F00000 457A0000
|
||||
// C3A68832 DDC3A724 00000000 00000000
|
||||
|
||||
|
||||
u32 gActiveFramebuffer;
|
||||
static u32 sActiveFramebuffer;
|
||||
u32 D_80280724;
|
||||
u32 D_80280728;
|
||||
struct1 D_80280730[8];
|
||||
OSMesgQueue D_80280770;
|
||||
OSMesg D_80280788[10];
|
||||
OSMesgQueue D_802807B0;
|
||||
OSMesg D_802807C8[1];
|
||||
OSMesgQueue D_802807D0;
|
||||
OSMesg D_802807E8[FRAMERATE];
|
||||
static OSMesgQueue sMesgQueue1;
|
||||
static OSMesg sMesgBuffer1[10];
|
||||
static OSMesgQueue sMesgQueue2;
|
||||
static OSMesg sMesgBuffer2[1];
|
||||
static OSMesgQueue sMesgQueue3;
|
||||
static OSMesg sMesgBuffer3[FRAMERATE];
|
||||
volatile s32 D_802808D8;
|
||||
s32 D_802808DC;
|
||||
OSThread D_802808E0;
|
||||
#define THREAD0_STACK_SIZE 0x400
|
||||
u8 thread0_stack[THREAD0_STACK_SIZE];
|
||||
static OSThread sViManagerThread;
|
||||
static u8 sViManagerThreadStack[VIMANAGER_THREAD_STACK_SIZE];
|
||||
|
||||
|
||||
extern u8 D_803A5D00[2][0x1ECC0]; //framebuffer
|
||||
|
||||
void func_8024C428(void);
|
||||
|
||||
/* .code */
|
||||
bool func_8024BD80(void){
|
||||
sizeof(OSThread);
|
||||
return NOT(gActiveFramebuffer);
|
||||
u32 getOtherFramebuffer(void) {
|
||||
return NOT(sActiveFramebuffer);
|
||||
}
|
||||
|
||||
s32 func_8024BD94(void){
|
||||
s32 viMgr_func_8024BD94(void){
|
||||
return D_80280724;
|
||||
}
|
||||
|
||||
s32 getActiveFramebuffer(void){
|
||||
return gActiveFramebuffer;
|
||||
return sActiveFramebuffer;
|
||||
}
|
||||
|
||||
void func_8024BDAC(OSMesgQueue *mq, OSMesg msg){
|
||||
void viMgr_func_8024BDAC(OSMesgQueue *mq, OSMesg msg){
|
||||
s32 i;
|
||||
for(i = 0; i < 8; i++){
|
||||
if(D_80280730[i].messageQueue == NULL){
|
||||
@@ -125,72 +110,79 @@ void func_8024BDAC(OSMesgQueue *mq, OSMesg msg){
|
||||
|
||||
}
|
||||
|
||||
void func_8024BE30(void){
|
||||
void viMgr_init(void) {
|
||||
s32 i;
|
||||
|
||||
func_8024C428();
|
||||
viMgr_clearFramebuffers();
|
||||
|
||||
osCreateViManager(OS_PRIORITY_VIMGR);
|
||||
#if VERSION == VERSION_USA_1_0
|
||||
if(osTvType != OS_TV_NTSC)
|
||||
osViSetMode(&D_80275CD0); //PAL
|
||||
osViSetMode(&sViMode_US10_MPAL);
|
||||
else
|
||||
osViSetMode(&D_80275C80); //NTSC
|
||||
osViSetMode(&sViMode_US10_NTSC);
|
||||
#elif VERSION == VERSION_PAL
|
||||
osViSetMode(&D_PAL_80275CD0); //PAL
|
||||
osViSetMode(&sViMode_PAL);
|
||||
#endif
|
||||
|
||||
osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON);
|
||||
osViSetSpecialFeatures(OS_VI_GAMMA_OFF);
|
||||
osViSwapBuffer(&D_803A5D00);
|
||||
osCreateMesgQueue(&D_80280770, D_80280788, 10);
|
||||
osCreateMesgQueue(&D_802807B0, D_802807C8, 1);
|
||||
osCreateMesgQueue(&D_802807D0, D_802807E8, FRAMERATE);
|
||||
osViSetEvent(&D_80280770,NULL,1);
|
||||
gActiveFramebuffer = 0;
|
||||
osViSwapBuffer(&gFramebuffers[0]);
|
||||
|
||||
osCreateMesgQueue(&sMesgQueue1, sMesgBuffer1, 10);
|
||||
osCreateMesgQueue(&sMesgQueue2, sMesgBuffer2, 1);
|
||||
osCreateMesgQueue(&sMesgQueue3, sMesgBuffer3, FRAMERATE);
|
||||
osViSetEvent(&sMesgQueue1, NULL, 1);
|
||||
|
||||
sActiveFramebuffer = 0;
|
||||
D_80280724 = 1;
|
||||
D_80280728 = 0;
|
||||
for(i = 0; i<8; i++){
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
D_80280730[i].messageQueue = NULL;
|
||||
}
|
||||
|
||||
D_802808D8 = 0;
|
||||
func_8024BF94(2);
|
||||
osCreateThread(&D_802808E0,0,func_8024C2F8,NULL, thread0_stack + THREAD0_STACK_SIZE, 80);
|
||||
osStartThread(&D_802808E0);
|
||||
viMgr_func_8024BF94(2);
|
||||
|
||||
osCreateThread(&sViManagerThread, 0, viMgr_entry, NULL, sViManagerThreadStack + VIMANAGER_THREAD_STACK_SIZE, 80);
|
||||
osStartThread(&sViManagerThread);
|
||||
}
|
||||
|
||||
void func_8024BF94(s32 arg0){
|
||||
void viMgr_func_8024BF94(s32 arg0){
|
||||
D_802808DC = arg0;
|
||||
}
|
||||
|
||||
s32 func_8024BFA0(void){
|
||||
s32 viMgr_func_8024BFA0(void){
|
||||
return D_802808DC;
|
||||
}
|
||||
|
||||
void func_8024BFAC(void){
|
||||
osSendMesg(&D_802807B0, 0, OS_MESG_NOBLOCK);
|
||||
void viMgr_func_8024BFAC(void){
|
||||
osSendMesg(&sMesgQueue2, 0, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
void func_8024BFD8(s32 arg0){
|
||||
void viMgr_func_8024BFD8(s32 arg0){
|
||||
static s32 D_80280E90;
|
||||
|
||||
osSetThreadPri(NULL, 0x7f);
|
||||
defragManager_setPriority(0x1E);
|
||||
defragManager_80240874();
|
||||
if(arg0){
|
||||
osRecvMesg(&D_802807B0, NULL, OS_MESG_BLOCK);
|
||||
osRecvMesg(&sMesgQueue2, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
while(D_802808D8 < func_8024BFA0() - D_80280E90){
|
||||
osRecvMesg(&D_802807D0, NULL, OS_MESG_BLOCK);
|
||||
while(D_802808D8 < viMgr_func_8024BFA0() - D_80280E90){
|
||||
osRecvMesg(&sMesgQueue3, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
while(D_802807D0.validCount){
|
||||
osRecvMesg(&D_802807D0, NULL, OS_MESG_NOBLOCK);
|
||||
while(sMesgQueue3.validCount){
|
||||
osRecvMesg(&sMesgQueue3, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
osViSwapBuffer(D_803A5D00[gActiveFramebuffer = func_8024BD80()]);
|
||||
osViSwapBuffer(gFramebuffers[sActiveFramebuffer = getOtherFramebuffer()]);
|
||||
D_80280E90 = 0;
|
||||
while(!(osDpGetStatus() & 2) && osViGetCurrentFramebuffer() != osViGetNextFramebuffer()){
|
||||
osRecvMesg(&D_802807D0, NULL, OS_MESG_BLOCK);
|
||||
osRecvMesg(&sMesgQueue3, NULL, OS_MESG_BLOCK);
|
||||
D_80280E90++;
|
||||
}//L8024C178
|
||||
D_80280724 = D_802808D8;
|
||||
@@ -200,35 +192,36 @@ void func_8024BFD8(s32 arg0){
|
||||
defragManager_setPriority(0xA);
|
||||
}
|
||||
|
||||
void func_8024C1B4(void){
|
||||
func_8024BFD8(0);
|
||||
void viMgr_func_8024C1B4(void){
|
||||
viMgr_func_8024BFD8(0);
|
||||
dummy_func_8025AFB8();
|
||||
}
|
||||
|
||||
void func_8024C1DC(void){
|
||||
func_8024BFD8(1);
|
||||
void viMgr_func_8024C1DC(void){
|
||||
viMgr_func_8024BFD8(1);
|
||||
}
|
||||
|
||||
void func_8024C1FC(OSMesgQueue *mq, OSMesg msg){
|
||||
void viMgr_func_8024C1FC(OSMesgQueue *mq, OSMesg msg) {
|
||||
s32 i;
|
||||
for(i = 0; i < 8; i++){
|
||||
if(D_80280730[i].messageQueue == mq && D_80280730[i].message == msg){
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
if (D_80280730[i].messageQueue == mq && D_80280730[i].message == msg) {
|
||||
D_80280730[i].messageQueue = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void func_8024C2A0(s32 arg0) {
|
||||
gActiveFramebuffer = arg0;
|
||||
osViSwapBuffer(D_803A5D00[gActiveFramebuffer]);
|
||||
void viMgr_setActiveFramebuffer(s32 fb_idx) {
|
||||
sActiveFramebuffer = fb_idx;
|
||||
osViSwapBuffer(gFramebuffers[sActiveFramebuffer]);
|
||||
}
|
||||
|
||||
void func_8024C2F8(void *arg0){
|
||||
void viMgr_entry(void *arg0){
|
||||
s32 i;
|
||||
OSMesg sp48;
|
||||
do{
|
||||
osRecvMesg(&D_80280770, &sp48, OS_MESG_BLOCK);
|
||||
osRecvMesg(&sMesgQueue1, &sp48, OS_MESG_BLOCK);
|
||||
func_80247380();
|
||||
D_802808D8++;
|
||||
if(D_802808D8 == 420){
|
||||
@@ -236,7 +229,7 @@ void func_8024C2F8(void *arg0){
|
||||
func_802485BC();
|
||||
#endif
|
||||
}
|
||||
osSendMesg(&D_802807D0, NULL, OS_MESG_NOBLOCK);
|
||||
osSendMesg(&sMesgQueue3, NULL, OS_MESG_NOBLOCK);
|
||||
|
||||
for(i = 0; i < 8; i++){
|
||||
if(D_80280730[i].messageQueue != NULL){
|
||||
@@ -246,20 +239,19 @@ void func_8024C2F8(void *arg0){
|
||||
}while(1);
|
||||
}
|
||||
|
||||
void func_8024C408(s32 arg0){
|
||||
osViBlack(arg0);
|
||||
void viMgr_setScreenBlack(s32 active) {
|
||||
osViBlack(active);
|
||||
}
|
||||
|
||||
void func_8024C428(void) {
|
||||
//zeros all both framebuffers
|
||||
func_80253034(&D_803A5D00, 0, (s32) ((f32)framebuffer_width*2*framebuffer_height*2));
|
||||
osWritebackDCache(&D_803A5D00, (s32) ((f32)framebuffer_width*2* framebuffer_height*2));
|
||||
void viMgr_clearFramebuffers(void) {
|
||||
func_80253034(&gFramebuffers, 0, (s32) ((f32)gFramebufferWidth*2*gFramebufferHeight*2)); // TODO: This function does not exist in source code, why does it work?
|
||||
osWritebackDCache(&gFramebuffers, (s32) ((f32)gFramebufferWidth*2*gFramebufferHeight*2));
|
||||
}
|
||||
|
||||
s32 func_8024C4E8(void){
|
||||
s32 viMgr_func_8024C4E8(void) {
|
||||
return D_802808D8;
|
||||
}
|
||||
|
||||
void func_8024C4F8(s32 arg0){
|
||||
void viMgr_func_8024C4F8(s32 arg0) {
|
||||
D_802808D8 = arg0;
|
||||
}
|
||||
Reference in New Issue
Block a user