PS2: Improve stability a bit

This commit is contained in:
UnknownShadow200 2024-04-14 22:23:48 +10:00
parent e20bf233aa
commit e591bab6e6
5 changed files with 14 additions and 15 deletions

View File

@ -198,10 +198,6 @@ static int BINDS;
void Gfx_BindTexture(GfxResourceID texId) {
if (!texId) texId = white_square;
CCTexture* tex = (CCTexture*)texId;
Platform_Log2("BIND: %i x %i", &tex->width, &tex->height);
// TODO
if (BINDS) return;
BINDS = 1;
texbuffer_t texbuf;
texbuf.width = max(256, tex->width);
@ -209,9 +205,8 @@ void Gfx_BindTexture(GfxResourceID texId) {
// TODO terrible perf
DMATAG_END(dma_tag, (q - current->data) - 1, 0, 0, 0);
dma_wait_fast();
dma_channel_send_chain(DMA_CHANNEL_GIF, current->data, q - current->data, 0, 0);
//
dma_wait_fast();
packet_t *packet = packet_init(200, PACKET_NORMAL);
@ -223,13 +218,11 @@ void Gfx_BindTexture(GfxResourceID texId) {
dma_channel_send_chain(DMA_CHANNEL_GIF,packet->data, Q - packet->data, 0,0);
dma_wait_fast();
//packet_free(packet);
packet_free(packet);
// TODO terrible perf
q = dma_tag + 1;
UpdateTextureBuffer(0, &texbuf, tex);
Platform_LogConst("=====");
}
void Gfx_DeleteTexture(GfxResourceID* texId) {

View File

@ -32,7 +32,6 @@ static void SetHeldModel(struct Model* model) {
}
static void HeldBlockRenderer_RenderModel(void) {
static const cc_string block = String_FromConst("block");
struct Model* model;
Gfx_SetFaceCulling(true);
@ -48,7 +47,7 @@ static void HeldBlockRenderer_RenderModel(void) {
Model_RenderArm(model, &held_entity);
Gfx_SetAlphaTest(false);
} else {
model = Model_Get(&block);
model = Models.Block;
SetHeldModel(model);
Vec3_Set(held_entity.ModelScale, 0.4f,0.4f,0.4f);

View File

@ -2218,6 +2218,7 @@ static void BlockModel_Register(void) {
block_model.pushes = false;
block_model.maxVertices = BLOCKMODEL_MAX_VERTICES;
Model_Register(&block_model);
Models.Block = &block_model;
}

View File

@ -112,8 +112,10 @@ CC_VAR extern struct _ModelsData {
/* Maximum number of vertices that can be stored in Vertices. */
/* NOTE: If you change this, you MUST also destroy and recreate the dynamic VB. */
int MaxVertices;
/* Pointer to humanoid/human model.*/
/* Pointer to humanoid/human model */
struct Model* Human;
/* Pointer to block model */
struct Model* Block;
} Models;
/* Initialises fields of a model to default. */

View File

@ -30,6 +30,7 @@
#include <sbv_patches.h>
#include <netman.h>
#include <ps2ip.h>
#include <dma.h>
#define NEWLIB_PORT_AWARE
#include <fileio.h>
#include <io_common.h>
@ -37,8 +38,8 @@
#include "_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = -ENOENT;
const cc_result ReturnCode_DirectoryExists = -EEXIST;
const cc_result ReturnCode_FileNotFound = -4;
const cc_result ReturnCode_DirectoryExists = -8;
const cc_result ReturnCode_SocketInProgess = EINPROGRESS;
const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK;
@ -235,7 +236,7 @@ static int ExecThread(void* param) {
ee_thread_status_t info;
int res = ReferThreadStatus(thdID, &info);
if (res > 0 && info.stack) Mem_Free(info.stack);
if (res > 0 && info.stack) Mem_Free(info.stack); // TODO is it okay to free stack of running thread ????
return 0; // TODO detach ?
}
@ -705,6 +706,9 @@ void Platform_Init(void) {
// Create root directory
int res = fioMkdir("mass:/ClassiCube");
Platform_Log1("ROOT CREATE %i", &res);
dma_channel_initialize(DMA_CHANNEL_GIF, NULL, 0);
dma_channel_fast_waits(DMA_CHANNEL_GIF);
}
void Platform_Free(void) { }