From 223da63fe2f2c2947ea2d0d7f8392906e4d85fa1 Mon Sep 17 00:00:00 2001 From: Ilya Shurumov Date: Sun, 29 Mar 2020 02:29:37 +0600 Subject: [PATCH] - implement SetupBackgroundPolys - implement SetupScreenSprts - implement SetFEDrawMode - LoadFrontendScreens done prettier --- src_rebuild/GAME/C/E3STUFF.C | 14 +- src_rebuild/GAME/C/FMVPLAY.C | 2 +- src_rebuild/GAME/C/GLAUNCH.C | 2 +- src_rebuild/GAME/C/MAIN.C | 2 +- src_rebuild/GAME/C/PAD.C | 1 - src_rebuild/GAME/C/SYSTEM.C | 22 +- src_rebuild/GAME/C/SYSTEM.H | 23 ++ src_rebuild/GAME/FRONTEND/FEMAIN.C | 484 ++++++++++++++--------------- 8 files changed, 279 insertions(+), 271 deletions(-) diff --git a/src_rebuild/GAME/C/E3STUFF.C b/src_rebuild/GAME/C/E3STUFF.C index 05d34c6d..237e35ba 100644 --- a/src_rebuild/GAME/C/E3STUFF.C +++ b/src_rebuild/GAME/C/E3STUFF.C @@ -17,12 +17,6 @@ POLYCOORD polycoords[6] = { 512, 256, 896, 256, 128, 256 } }; -DRAW_MODE draw_mode_pal = -{ 0, 0, 0, 0, 512, 256, 0, 16 }; - -DRAW_MODE draw_mode_ntsc = -{ 0, 0, 0, 8, 512, 240, 0, 0 }; - // decompiled code // original method signature: // void /*$ra*/ ShowHiresScreens(char **names /*$s1*/, int delay /*$s4*/, int wait /*$s3*/) @@ -400,15 +394,15 @@ void SetupDefDispEnv(DISPENV *env, int x, int y, int w, int h) if (h < 0x101) { SetDefDispEnv(env, x, y, w, 256); - env->screen.x = draw_mode_pal.framex; - framey = draw_mode_pal.framey; + env->screen.x = draw_mode.framex; + framey = draw_mode.framey; env->screen.h = 255; env->isinter = 0; } else { SetDefDispEnv(env, x, y, w, 512); - env->screen.x = draw_mode_pal.framex; - framey = draw_mode_pal.framey; + env->screen.x = draw_mode.framex; + framey = draw_mode.framey; env->screen.h = 255; env->isinter = 1; } diff --git a/src_rebuild/GAME/C/FMVPLAY.C b/src_rebuild/GAME/C/FMVPLAY.C index 5553a99a..f8a5ef41 100644 --- a/src_rebuild/GAME/C/FMVPLAY.C +++ b/src_rebuild/GAME/C/FMVPLAY.C @@ -45,7 +45,7 @@ void ReInitSystem(void) StopCallback(); ResetCallback(); ResetGraph(1); - SetVideoMode(1); + SetVideoMode(video_mode); InitGeom(); SetGeomOffset(0xa0, 0x80); scr_z = 0x100; diff --git a/src_rebuild/GAME/C/GLAUNCH.C b/src_rebuild/GAME/C/GLAUNCH.C index 3e953f63..417ed010 100644 --- a/src_rebuild/GAME/C/GLAUNCH.C +++ b/src_rebuild/GAME/C/GLAUNCH.C @@ -670,7 +670,7 @@ void LaunchGame(void) fakeOtherPlayer = 0; ResetGraph(1); - SetVideoMode(1); + SetVideoMode(video_mode); gMissionCompletionState = PAUSEMODE_GAMEOVER; gInvincibleCar = (uint)((byte)ActiveCheats >> 2) & 1; gPlayerImmune = (uint)((byte)ActiveCheats >> 3) & 1; diff --git a/src_rebuild/GAME/C/MAIN.C b/src_rebuild/GAME/C/MAIN.C index da6dcd66..1fb75421 100644 --- a/src_rebuild/GAME/C/MAIN.C +++ b/src_rebuild/GAME/C/MAIN.C @@ -2104,7 +2104,7 @@ int redriver2_main(void) SsSetSerialVol(0, 0, 0); SetDispMask(0); SetGraphDebug(0); - SetVideoMode(MODE_PAL); + SetVideoMode(video_mode); CdInit(); SsSetSerialVol(0, 0, 0); SpuInit(); diff --git a/src_rebuild/GAME/C/PAD.C b/src_rebuild/GAME/C/PAD.C index 9c78b4d0..08f1dd3b 100644 --- a/src_rebuild/GAME/C/PAD.C +++ b/src_rebuild/GAME/C/PAD.C @@ -176,7 +176,6 @@ void CloseControllers(void) /* WARNING: Unknown calling convention yet parameter storage is locked */ int pad_connected = 0; -unsigned char NumPlayers = 1; void ReadControllers(void) { diff --git a/src_rebuild/GAME/C/SYSTEM.C b/src_rebuild/GAME/C/SYSTEM.C index aec08529..d9eb65e2 100644 --- a/src_rebuild/GAME/C/SYSTEM.C +++ b/src_rebuild/GAME/C/SYSTEM.C @@ -28,6 +28,25 @@ char* LoadingScreenNames[] = { CdlFILE currentfileinfo; char currentfilename[128] = { 0 }; +DRAW_MODE draw_mode_pal = +{ 0, 0, 0, 0, 512, 256, 0, 16 }; + +DRAW_MODE draw_mode_ntsc = +{ 0, 0, 0, 8, 512, 240, 0, 0 }; + +DB MPBuff[2][2]; +DB* last; +DB* current; + +long _tempOT1[0x10]; +long _tempOT2[0x10]; + +char _tempPrimTab1[0x8000]; // 0xFB400 +char _tempPrimTab2[0x8000]; // 0x119400 + +// TODO: to game vars +unsigned char NumPlayers = 1; + // decompiled code // original method signature: // void /*$ra*/ ClearMem(char *mem /*$a0*/, int size /*$a1*/) @@ -756,13 +775,14 @@ void loadsectors(char *addr, int sector, int nsectors) void EnableDisplay(void) { UNIMPLEMENTED(); + /* ulong **ppuVar1; int iVar2; iVar2 = 0; if (NumPlayers != 0) { - ppuVar1 = &DB_000e0938.ot; + ppuVar1 = &MPBuff[0][1].ot; do { iVar2 = iVar2 + 1; ClearOTagR(ppuVar1[-0x20], (int)&DAT_00001080); diff --git a/src_rebuild/GAME/C/SYSTEM.H b/src_rebuild/GAME/C/SYSTEM.H index 5c7c330d..3b5dfe2c 100644 --- a/src_rebuild/GAME/C/SYSTEM.H +++ b/src_rebuild/GAME/C/SYSTEM.H @@ -4,6 +4,29 @@ extern char _overlay_buffer[0x50000]; // 0x1C0000 extern char _frontend_buffer[0x8000]; // 0xFB400 +extern DRAW_MODE draw_mode_pal; +extern DRAW_MODE draw_mode_ntsc; + +extern DB MPBuff[2][2]; +extern DB* last; +extern DB* current; + +extern long _tempOT1[0x10]; +extern long _tempOT2[0x10]; + +extern char _tempPrimTab1[0x8000]; // 0xFB400 +extern char _tempPrimTab2[0x8000]; // 0x119400 + +extern unsigned char NumPlayers; + +#ifdef PAL +#define draw_mode draw_mode_pal +#define video_mode MODE_PAL +#else +#define draw_mode draw_mode_ntsc +#define video_mode MODE_NTSC +#endif // PAL + extern void ClearMem(char *mem, int size); // 0x0007F3E8 extern void setMem8(unsigned char *mem, unsigned char val, int size); // 0x0007F47C diff --git a/src_rebuild/GAME/FRONTEND/FEMAIN.C b/src_rebuild/GAME/FRONTEND/FEMAIN.C index 5f034047..86945cc2 100644 --- a/src_rebuild/GAME/FRONTEND/FEMAIN.C +++ b/src_rebuild/GAME/FRONTEND/FEMAIN.C @@ -51,6 +51,8 @@ int gIdleReplay = 0; PSXSCREEN* pCurrScreen = NULL; PSXSCREEN* pNewScreen = NULL; + +PSXBUTTON* pNewButton = NULL; PSXBUTTON* pCurrButton = NULL; PSXSCREEN PsxScreens[42] = { 0 }; @@ -58,6 +60,8 @@ struct PSXSCREEN* pScreenStack[10] = { 0 }; struct PSXBUTTON* pButtonStack[10] = { 0 }; char* ScreenNames[12] = { 0 }; +POLY_FT4 BackgroundPolys[6]; + // decompiled code // original method signature: // void /*$ra*/ SetVariable(int var /*$a0*/) @@ -205,9 +209,9 @@ char* ScreenNames[12] = { 0 }; // void /*$ra*/ LoadFrontendScreens() // line 1371, offset 0x001c0c1c /* begin block 1 */ - // Start line: 1373 - // Start offset: 0x001C0C1C - // Variables: + // Start line: 1373 + // Start offset: 0x001C0C1C + // Variables: // int iTpage; // $s0 // int iNumScreens; // $t6 // int i; // $t0 @@ -253,7 +257,7 @@ void LoadFrontendScreens(void) int iVar4; int offset; int iVar5; - uint iNumScreens; + int iNumScreens; int iVar6; int iVar7; int iVar8; @@ -263,71 +267,35 @@ void LoadFrontendScreens(void) ShowLoadingScreen("GFX\\FELOAD.TIM", 1, 0xc); ShowLoading(); Loadfile("DATA\\SCRS.BIN", _frontend_buffer); - ptr = _frontend_buffer + 0x14; - iNumScreens = (uint)(unsigned char*)_frontend_buffer[16]; - if (_frontend_buffer[16] != '\0') { - offset = 0; - iVar7 = 0; - do { - uVar1 = *ptr; - iVar4 = 0; - iVar2 = (offset * 8 + iVar7 * -7) * 4; - iVar5 = iVar7 + 1; - (&PsxScreens[0].numButtons)[iVar2] = uVar1; - (&PsxScreens[0].userFunctionNum)[iVar2] = ((unsigned char *)ptr)[1]; - ptr = (char *)((unsigned char *)ptr + 2); - if (uVar1 != '\0') { - iVar2 = 0; - do { - local_v1_356 = (int *)(&PsxScreens[0].buttons[0].x + - (offset * 8 + iVar7 * -7 + (iVar2 - iVar4)) * 2); - piVar3 = (int *)ptr; - if (((uint)ptr & 3) == 0) { - do { - iVar2 = piVar3[1]; - iVar6 = piVar3[2]; - iVar8 = piVar3[3]; - *local_v1_356 = *piVar3; - local_v1_356[1] = iVar2; - local_v1_356[2] = iVar6; - local_v1_356[3] = iVar8; - piVar3 = piVar3 + 4; - local_v1_356 = local_v1_356 + 4; - } while (piVar3 != (int *)ptr + 0xc); - } - else { - do { - iVar2 = piVar3[1]; - iVar6 = piVar3[2]; - iVar8 = piVar3[3]; - *local_v1_356 = *piVar3; - local_v1_356[1] = iVar2; - local_v1_356[2] = iVar6; - local_v1_356[3] = iVar8; - piVar3 = piVar3 + 4; - local_v1_356 = local_v1_356 + 4; - } while (piVar3 != (int *)ptr + 0xc); - } - ptr = (char *)((int *)ptr + 0xf); - iVar4 = iVar4 + 1; - iVar2 = piVar3[1]; - iVar6 = piVar3[2]; - *local_v1_356 = *piVar3; - local_v1_356[1] = iVar2; - local_v1_356[2] = iVar6; - iVar2 = iVar4 * 0x10; - } while (iVar4 < (int)(uint)(&PsxScreens[0].numButtons) - [(offset * 8 + iVar7 * -7) * 4]); + + ptr = _frontend_buffer + 20; // skip header and number of screens + iNumScreens = (int)_frontend_buffer[16]; + + if (iNumScreens) + { + for (int i = 0; i < iNumScreens; i++) + { + PsxScreens[i].numButtons = *ptr++; + PsxScreens[i].userFunctionNum = *ptr++; + + if (PsxScreens[i].numButtons) + { + for (int j = 0; j < PsxScreens[i].numButtons; j++) + { + memcpy(&PsxScreens[i].buttons[j], ptr, sizeof(PSXBUTTON)); + ptr += sizeof(PSXBUTTON); + } } - offset = iVar5 * 0x10; - iVar7 = iVar5; - } while (iVar5 < (int)iNumScreens); + } } - rect.w = 0x40; - rect.h = 0x100; + + rect.w = 64; + rect.h = 256; + ShowLoading(); LoadBackgroundFile("DATA\\GFX.RAW"); - sVar9 = 0x280; + + sVar9 = 640; offset = 0x30000; iVar7 = 1; do { @@ -338,15 +306,17 @@ void LoadFrontendScreens(void) rect.x = sVar9; LoadImage(&rect, (u_long *)_frontend_buffer); DrawSync(0); - sVar9 = sVar9 + 0x40; + sVar9 = sVar9 + 64; offset = offset + 0x8000; } while (-1 < iVar7); ShowLoading(); + LoadfileSeg("DATA\\GFX.RAW", _frontend_buffer, 0x58000, 0x8000); - rect.x = 0x3c0; - rect.y = 0x100; + rect.x = 960; + rect.y = 256; LoadImage(&rect, (u_long *)_frontend_buffer); DrawSync(0); + Loadfile("DATA\\FEFONT.BNK", _overlay_buffer+0xbdd8); PadChecks(); } @@ -468,134 +438,130 @@ void LoadBackgroundFile(char *name) /* WARNING: Unknown calling convention yet parameter storage is locked */ +// [D] void SetupBackgroundPolys(void) { - UNIMPLEMENTED(); - /* - undefined4 *puVar1; - int iVar2; + POLY_FT4 *poly; + int i; - puVar1 = &DAT_FRNT__001cbcc0; - iVar2 = 5; + poly = BackgroundPolys; + i = 5; do { - *(undefined *)((int)puVar1 + 3) = 9; - *(undefined *)(puVar1 + 1) = 0x80; - *(undefined *)((int)puVar1 + 5) = 0x80; - *(undefined *)((int)puVar1 + 6) = 0x80; - *(undefined *)((int)puVar1 + 7) = 0x2c; - iVar2 = iVar2 + -1; - puVar1 = puVar1 + 10; - } while (-1 < iVar2); - DAT_FRNT__001cbcc8 = 0; - DAT_FRNT__001cbcca = 0; - DAT_FRNT__001cbccc = 0; - DAT_FRNT__001cbccd = 1; - DAT_FRNT__001cbcce = 0x403c; - DAT_FRNT__001cbcd0 = 0x100; - DAT_FRNT__001cbcd2 = 0; - DAT_FRNT__001cbcd4 = 0xff; - DAT_FRNT__001cbcd5 = 1; - DAT_FRNT__001cbcd6 = 10; - DAT_FRNT__001cbcd8 = 0; - DAT_FRNT__001cbcda = 0x100; - DAT_FRNT__001cbcdc = 0; - DAT_FRNT__001cbcdd = 0xff; - DAT_FRNT__001cbce0 = 0x100; - DAT_FRNT__001cbce2 = 0x100; - DAT_FRNT__001cbce4 = 0xff; - DAT_FRNT__001cbce5 = 0xff; - DAT_FRNT__001cbcf0 = 0x100; - DAT_FRNT__001cbcf2 = 0; - DAT_FRNT__001cbcf4 = 0; - DAT_FRNT__001cbcf5 = 1; - DAT_FRNT__001cbcf6 = 0x403c; - DAT_FRNT__001cbcf8 = 0x200; - DAT_FRNT__001cbcfa = 0; - DAT_FRNT__001cbcfc = 0xff; - DAT_FRNT__001cbcfd = 1; - DAT_FRNT__001cbcfe = 0xb; - DAT_FRNT__001cbd00 = 0x100; - DAT_FRNT__001cbd02 = 0x100; - DAT_FRNT__001cbd04 = 0; - DAT_FRNT__001cbd05 = 0xff; - DAT_FRNT__001cbd08 = 0x200; - DAT_FRNT__001cbd0a = 0x100; - DAT_FRNT__001cbd0c = 0xff; - DAT_FRNT__001cbd0d = 0xff; - DAT_FRNT__001cbd18 = 0x200; - DAT_FRNT__001cbd1a = 0; - DAT_FRNT__001cbd1c = 0; - DAT_FRNT__001cbd1d = 1; - DAT_FRNT__001cbd1e = 0x403c; - DAT_FRNT__001cbd20 = 0x280; - DAT_FRNT__001cbd22 = 0; - DAT_FRNT__001cbd24 = 0x80; - DAT_FRNT__001cbd25 = 1; - DAT_FRNT__001cbd26 = 0xc; - DAT_FRNT__001cbd28 = 0x200; - DAT_FRNT__001cbd2a = 0x100; - DAT_FRNT__001cbd2c = 0; - DAT_FRNT__001cbd2d = 0xff; - DAT_FRNT__001cbd30 = 0x280; - DAT_FRNT__001cbd32 = 0x100; - DAT_FRNT__001cbd34 = 0x80; - DAT_FRNT__001cbd35 = 0xff; - DAT_FRNT__001cbd40 = 0; - DAT_FRNT__001cbd42 = 0x100; - DAT_FRNT__001cbd44 = 0; - DAT_FRNT__001cbd45 = 0; - DAT_FRNT__001cbd46 = 0x403c; - DAT_FRNT__001cbd48 = 0x100; - DAT_FRNT__001cbd4a = 0x100; - DAT_FRNT__001cbd4c = 0xff; - DAT_FRNT__001cbd4d = 0; - DAT_FRNT__001cbd4e = 0xd; - DAT_FRNT__001cbd50 = 0; - DAT_FRNT__001cbd52 = 0x200; - DAT_FRNT__001cbd54 = 0; - DAT_FRNT__001cbd55 = 0xff; - DAT_FRNT__001cbd58 = 0x100; - DAT_FRNT__001cbd5a = 0x200; - DAT_FRNT__001cbd5c = 0xff; - DAT_FRNT__001cbd5d = 0xff; - DAT_FRNT__001cbd68 = 0x100; - DAT_FRNT__001cbd6a = 0x100; - DAT_FRNT__001cbd6c = 0; - DAT_FRNT__001cbd6d = 0; - DAT_FRNT__001cbd6e = 0x403c; - DAT_FRNT__001cbd70 = 0x200; - DAT_FRNT__001cbd72 = 0x100; - DAT_FRNT__001cbd74 = 0xff; - DAT_FRNT__001cbd75 = 0; - DAT_FRNT__001cbd76 = 0xe; - DAT_FRNT__001cbd78 = 0x100; - DAT_FRNT__001cbd7a = 0x200; - DAT_FRNT__001cbd7c = 0; - DAT_FRNT__001cbd7d = 0xff; - DAT_FRNT__001cbd80 = 0x200; - DAT_FRNT__001cbd82 = 0x200; - DAT_FRNT__001cbd84 = 0xff; - DAT_FRNT__001cbd85 = 0xff; - DAT_FRNT__001cbd90 = 0x200; - DAT_FRNT__001cbd92 = 0x100; - DAT_FRNT__001cbd94 = 0; - DAT_FRNT__001cbd95 = 0; - DAT_FRNT__001cbd96 = 0x403c; - DAT_FRNT__001cbd98 = 0x280; - DAT_FRNT__001cbd9a = 0x100; - DAT_FRNT__001cbd9c = 0x80; - DAT_FRNT__001cbd9d = 0; - DAT_FRNT__001cbd9e = 0xf; - DAT_FRNT__001cbda0 = 0x200; - DAT_FRNT__001cbda2 = 0x200; - DAT_FRNT__001cbda4 = 0; - DAT_FRNT__001cbda5 = 0xff; - DAT_FRNT__001cbda8 = 0x280; - DAT_FRNT__001cbdaa = 0x200; - DAT_FRNT__001cbdac = 0x80; - DAT_FRNT__001cbdad = 0xff; - return; - */ + setPolyFT4(poly); + setRGB0(poly, 128, 128, 128); + + i--; + poly++; + } while (-1 < i); + + BackgroundPolys[0].x0 = 0; + BackgroundPolys[0].y0 = 0; + BackgroundPolys[0].u0 = '\0'; + BackgroundPolys[0].v0 = '\x01'; + BackgroundPolys[0].clut = getClut(960,256); + BackgroundPolys[0].x1 = 0x100; + BackgroundPolys[0].y1 = 0; + BackgroundPolys[0].u1 = -1; + BackgroundPolys[0].v1 = '\x01'; + BackgroundPolys[0].tpage = getTPage(0,0,960,0); + BackgroundPolys[0].x2 = 0; + BackgroundPolys[0].y2 = 0x100; + BackgroundPolys[0].u2 = '\0'; + BackgroundPolys[0].v2 = -1; + BackgroundPolys[0].x3 = 0x100; + BackgroundPolys[0].y3 = 0x100; + BackgroundPolys[0].u3 = -1; + BackgroundPolys[0].v3 = -1; + BackgroundPolys[1].x0 = 0x100; + BackgroundPolys[1].y0 = 0; + BackgroundPolys[1].u0 = '\0'; + BackgroundPolys[1].v0 = '\x01'; + BackgroundPolys[1].clut = getClut(960, 256); + BackgroundPolys[1].x1 = 0x200; + BackgroundPolys[1].y1 = 0; + BackgroundPolys[1].u1 = -1; + BackgroundPolys[1].v1 = '\x01'; + BackgroundPolys[1].tpage = getTPage(0, 0, 896, 0); + BackgroundPolys[1].x2 = 0x100; + BackgroundPolys[1].y2 = 0x100; + BackgroundPolys[1].u2 = '\0'; + BackgroundPolys[1].v2 = -1; + BackgroundPolys[1].x3 = 0x200; + BackgroundPolys[1].y3 = 0x100; + BackgroundPolys[1].u3 = -1; + BackgroundPolys[1].v3 = -1; + BackgroundPolys[2].x0 = 0x200; + BackgroundPolys[2].y0 = 0; + BackgroundPolys[2].u0 = '\0'; + BackgroundPolys[2].v0 = '\x01'; + BackgroundPolys[2].clut = getClut(960, 256); + BackgroundPolys[2].x1 = 0x280; + BackgroundPolys[2].y1 = 0; + BackgroundPolys[2].u1 = -0x80; + BackgroundPolys[2].v1 = '\x01'; + BackgroundPolys[2].tpage = getTPage(0, 0, 832, 0); + BackgroundPolys[2].x2 = 0x200; + BackgroundPolys[2].y2 = 0x100; + BackgroundPolys[2].u2 = '\0'; + BackgroundPolys[2].v2 = -1; + BackgroundPolys[2].x3 = 0x280; + BackgroundPolys[2].y3 = 0x100; + BackgroundPolys[2].u3 = -0x80; + BackgroundPolys[2].v3 = -1; + BackgroundPolys[3].x0 = 0; + BackgroundPolys[3].y0 = 0x100; + BackgroundPolys[3].u0 = '\0'; + BackgroundPolys[3].v0 = '\0'; + BackgroundPolys[3].clut = getClut(960, 256); + BackgroundPolys[3].x1 = 0x100; + BackgroundPolys[3].y1 = 0x100; + BackgroundPolys[3].u1 = -1; + BackgroundPolys[3].v1 = '\0'; + BackgroundPolys[3].tpage = getTPage(0, 0, 768, 0); + BackgroundPolys[3].x2 = 0; + BackgroundPolys[3].y2 = 0x200; + BackgroundPolys[3].u2 = '\0'; + BackgroundPolys[3].v2 = -1; + BackgroundPolys[3].x3 = 0x100; + BackgroundPolys[3].y3 = 0x200; + BackgroundPolys[3].u3 = -1; + BackgroundPolys[3].v3 = -1; + BackgroundPolys[4].x0 = 0x100; + BackgroundPolys[4].y0 = 0x100; + BackgroundPolys[4].u0 = '\0'; + BackgroundPolys[4].v0 = '\0'; + BackgroundPolys[4].clut = getClut(960, 256); + BackgroundPolys[4].x1 = 0x200; + BackgroundPolys[4].y1 = 0x100; + BackgroundPolys[4].u1 = -1; + BackgroundPolys[4].v1 = '\0'; + BackgroundPolys[4].tpage = getTPage(0, 0, 704, 0); + BackgroundPolys[4].x2 = 0x100; + BackgroundPolys[4].y2 = 0x200; + BackgroundPolys[4].u2 = '\0'; + BackgroundPolys[4].v2 = -1; + BackgroundPolys[4].x3 = 0x200; + BackgroundPolys[4].y3 = 0x200; + BackgroundPolys[4].u3 = -1; + BackgroundPolys[4].v3 = -1; + BackgroundPolys[5].x0 = 0x200; + BackgroundPolys[5].y0 = 0x100; + BackgroundPolys[5].u0 = '\0'; + BackgroundPolys[5].v0 = '\0'; + BackgroundPolys[5].clut = getClut(960, 256); + BackgroundPolys[5].x1 = 0x280; + BackgroundPolys[5].y1 = 0x100; + BackgroundPolys[5].u1 = -0x80; + BackgroundPolys[5].v1 = '\0'; + BackgroundPolys[5].tpage = getTPage(0, 0, 640, 0); + BackgroundPolys[5].x2 = 0x200; + BackgroundPolys[5].y2 = 0x200; + BackgroundPolys[5].u2 = '\0'; + BackgroundPolys[5].v2 = -1; + BackgroundPolys[5].x3 = 0x280; + BackgroundPolys[5].y3 = 0x200; + BackgroundPolys[5].u3 = -0x80; + BackgroundPolys[5].v3 = -1; } @@ -629,58 +595,61 @@ void SetupBackgroundPolys(void) /* end block 4 */ // End Line: 3364 +SPRT HighlightSprt; +POLY_FT4 HighlightDummy; + +// [D] void SetupScreenSprts(PSXSCREEN *pScr) { - UNIMPLEMENTED(); - /* - int iVar1; + int result; - DAT_FRNT__001cc590._3_1_ = 4; - DAT_FRNT__001cc594 = 0x80; - DAT_FRNT__001cc595 = 0x80; - DAT_FRNT__001cc596 = 0x80; - DAT_FRNT__001cc597 = 100; - DAT_FRNT__001cc598 = 0x16c; - DAT_FRNT__001cc59a = 0xc6; - DAT_FRNT__001cc5a0 = 0x100; - DAT_FRNT__001cc59c = 0; - DAT_FRNT__001cc59d = 0; - DAT_FRNT__001cc5a2 = 0x24; - DAT_FRNT__001cc59e = 0x40bc; - DAT_FRNT__001cc5a8._3_1_ = 7; - DAT_FRNT__001cc5af = 0x24; - DAT_FRNT__001cc5b0 = 0xffff; - DAT_FRNT__001cc5b2 = 0xffff; - DAT_FRNT__001cc5b8 = 0xffff; - DAT_FRNT__001cc5ba = 0xffff; - DAT_FRNT__001cc5c0 = 0xffff; - DAT_FRNT__001cc5c2 = 0xffff; - DAT_FRNT__001cc5be = 0x1b; - DAT_FRNT__001c6d48 = 0; + setSprt(&HighlightSprt); + setRGB0(&HighlightSprt, 128, 128, 128); + HighlightSprt.code = 'd'; + HighlightSprt.x0 = 0x16c; + HighlightSprt.y0 = 0xc6; + HighlightSprt.w = 0x100; + HighlightSprt.u0 = '\0'; + HighlightSprt.v0 = '\0'; + HighlightSprt.h = 0x24; + setClut(&HighlightSprt, 960, 258); + + setPolyFT4(&HighlightDummy); + HighlightDummy.code = '$'; + HighlightDummy.x0 = -1; + HighlightDummy.y0 = -1; + HighlightDummy.x1 = -1; + HighlightDummy.y1 = -1; + HighlightDummy.x2 = -1; + HighlightDummy.y2 = -1; + //setTPage(&HighlightDummy, 0,0, 1728, 256); // feels wrong + HighlightDummy.tpage = 0x1b; + + pNewScreen = NULL; pCurrScreen = pScr; + if (pScr->userFunctionNum == 0) { - if (DAT_FRNT__001cbcb8 == (PSXBUTTON *)0x0) { + if (pNewButton == NULL) { pCurrButton = pScr->buttons; } else { - pCurrButton = DAT_FRNT__001cbcb8; - DAT_FRNT__001cbcb8 = (PSXBUTTON *)0x0; + pCurrButton = pNewButton; + pNewButton = NULL; } } else { - iVar1 = (*(code *)(&PTR_CentreScreen_FRNT__001c6a20)[(uint)(byte)pScr->userFunctionNum - 1])(1); - if (iVar1 == 0) { - if (DAT_FRNT__001cbcb8 == (PSXBUTTON *)0x0) { + result = (fpUserFunctions[pScr->userFunctionNum - 1])(1); + if (result == 0) { + if (pNewButton == NULL) { pCurrButton = pCurrScreen->buttons; } else { - pCurrButton = DAT_FRNT__001cbcb8; - DAT_FRNT__001cbcb8 = (PSXBUTTON *)0x0; + pCurrButton = pNewButton; + pNewButton = NULL; } } } return; - */ } @@ -1543,7 +1512,7 @@ void DoFrontEnd(void) SetDispMask(0); ResetGraph(0); SetFEDrawMode(); - SetVideoMode(1); + SetVideoMode(video_mode); EnableDisplay(); DrawScreen(pCurrScreen); EndFrame(); @@ -1643,38 +1612,41 @@ void DoFrontEnd(void) /* WARNING: Unknown calling convention yet parameter storage is locked */ + +// [D] void SetFEDrawMode(void) { - UNIMPLEMENTED(); - /* - SetVideoMode(1); - SetDefDrawEnv(0xe08c8, (int)draw_mode_pal.x1, (int)draw_mode_pal.y1, 0x280, 0x200); - SetDefDispEnv(0xe0924, (int)draw_mode_pal.x1, (int)draw_mode_pal.y1, 0x280, 0x200); - SetDefDrawEnv(0xe0948, (int)draw_mode_pal.x1, (int)draw_mode_pal.y1, 0x280, 0x200); - SetDefDispEnv(0xe09a4, (int)draw_mode_pal.x1, (int)draw_mode_pal.y1, 0x280, 0x200); - MPBuff.draw.isbg = '\0'; - MPBuff.disp.isinter = '\x01'; - MPBuff.draw.dfe = '\x01'; - MPBuff.disp.screen.h = 0x100; - MPBuff.primtab = &DAT_000fb400; - MPBuff.primptr = &DAT_000fb400; - MPBuff.ot = (ulong *)&DAT_000f3000; - DB_000e0938.draw.isbg = '\0'; - DB_000e0938.disp.isinter = '\x01'; - DB_000e0938.draw.dfe = '\x01'; - DB_000e0938.disp.screen.h = 0x100; - DB_000e0938.primtab = &DAT_00119400; - DB_000e0938.primptr = &DAT_00119400; - DB_000e0938.ot = (ulong *)&DAT_000f7200; - last = &DB_000e0938; - current = &MPBuff; - MPBuff.disp.screen.x = draw_mode_pal.framex << 1; - MPBuff.disp.screen.y = draw_mode_pal.framey; - DB_000e0938.disp.screen.y = draw_mode_pal.framey; - DB_000e0938.disp.screen.x = MPBuff.disp.screen.x; - PutDispEnv(&MPBuff.disp); + SetVideoMode(video_mode); + SetDefDrawEnv(&MPBuff[0][0].draw, (int)draw_mode.x1, (int)draw_mode.y1, 0x280, 0x200); + SetDefDispEnv(&MPBuff[0][0].disp, (int)draw_mode.x1, (int)draw_mode.y1, 0x280, 0x200); + SetDefDrawEnv(&MPBuff[0][1].draw, (int)draw_mode.x1, (int)draw_mode.y1, 0x280, 0x200); + SetDefDispEnv(&MPBuff[0][1].disp, (int)draw_mode.x1, (int)draw_mode.y1, 0x280, 0x200); + MPBuff[0][0].draw.isbg = '\0'; + MPBuff[0][0].disp.isinter = '\x01'; + MPBuff[0][0].draw.dfe = '\x01'; + MPBuff[0][0].disp.screen.h = 256; + MPBuff[0][0].primtab = _tempPrimTab1; + MPBuff[0][0].primptr = _tempPrimTab1; + MPBuff[0][0].ot = (ulong *)_tempOT1; + MPBuff[0][1].draw.isbg = '\0'; + MPBuff[0][1].disp.isinter = '\x01'; + MPBuff[0][1].draw.dfe = '\x01'; + MPBuff[0][1].disp.screen.h = 256; + MPBuff[0][1].primtab = _tempPrimTab2; + MPBuff[0][1].primptr = _tempPrimTab2; + MPBuff[0][1].ot = (ulong *)_tempOT2; + + last = &MPBuff[0][1]; + current = &MPBuff[0][0]; + + MPBuff[0][0].disp.screen.x = draw_mode.framex << 1; + MPBuff[0][0].disp.screen.y = draw_mode.framey; + MPBuff[0][1].disp.screen.y = draw_mode.framey; + MPBuff[0][1].disp.screen.x = MPBuff[0][0].disp.screen.x; + + PutDispEnv(&MPBuff[0][0].disp); PutDrawEnv(¤t->draw); - return;*/ + return; }