Merge pull request #1 from h4570/feature/migration-libspacket

Feature/migration libspacket
This commit is contained in:
Sandro Sobczyński
2020-11-27 16:55:17 +01:00
committed by GitHub
19 changed files with 232 additions and 610 deletions
-8
View File
@@ -15,15 +15,8 @@
#include <sifrpc.h>
#include <time.h>
#include <cstdlib>
#include "include/modules/vu1.hpp"
#include "include/utils/debug.hpp"
// VU1 micro program
extern u32 VU1Draw3D_CodeStart __attribute__((section(".vudata")));
extern u32 VU1Draw3D_CodeEnd __attribute__((section(".vudata")));
//
// ----
// Constructors/Destructors
// ----
@@ -84,7 +77,6 @@ void Engine::firePS2()
{
SifInitRpc(0);
srand(time(NULL));
VU1::uploadProgram(0, &VU1Draw3D_CodeStart, &VU1Draw3D_CodeEnd);
fileService.startThread();
audio.startThread(&fileService);
isInitialized = 0;
+3 -5
View File
@@ -16,7 +16,7 @@
#include <draw_types.h>
#include <draw_primitives.h>
#include <math3d.h>
#include <packet.h>
#include <packet2.h>
#include "../models/mesh.hpp"
#include "../models/math/matrix.hpp"
#include "../models/screen_settings.hpp"
@@ -45,10 +45,8 @@ private:
texel_t *st;
u8 isAnyObjectAdded;
ScreenSettings *screen;
u64 *dw;
qword_t *q, *dmatag;
packet_t *packets[2];
packet_t *currentPacket;
packet2_t *packets[2];
packet2_t *currentPacket;
u8 packetsCount;
int packetSize;
float halfScreenW, halfScreenH;
+2 -2
View File
@@ -13,7 +13,7 @@
#include <draw_buffers.h>
#include <draw_primitives.h>
#include <packet.h>
#include <packet2.h>
#include "gif_sender.hpp"
#include "vif_sender.hpp"
#include "../models/math/plane.hpp"
@@ -118,7 +118,7 @@ private:
TextureRepository textureRepo;
GifSender *gifSender;
VifSender *vifSender;
packet_t *flipPacket;
packet2_t *flipPacket;
void allocateBuffers(float t_screenW, float t_screenH);
void initDrawingEnv(float t_screenW, float t_screenH);
void setPrim();
+9 -4
View File
@@ -12,12 +12,12 @@
#define _TYRA_VIF_SENDER_
#include <tamtypes.h>
#include <packet2_utils.h>
#include "../models/render_data.hpp"
#include "../models/light_bulb.hpp"
#include "../models/mesh.hpp"
#include "../models/math/matrix.hpp"
#include "../models/math/vector3.hpp"
#include "vu1.hpp"
/** Class responsible for sending 3D objects via VIF (PATH 1) */
class VifSender
@@ -28,12 +28,17 @@ public:
~VifSender();
// TODO refactor
void drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, const Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
void drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
void sendMatrices(const RenderData &t_renderData, const Vector3 &t_position, const Vector3 &t_rotation);
private:
void drawVertices(const Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *textureBuffer);
VU1 vu1; // TODO
void uploadMicroProgram();
void setDoubleBuffer();
void drawVertices(Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *textureBuffer);
packet2_t *packets[2] __attribute__((aligned(64)));
packet2_t *currPacket;
u8 context;
packet2_t *matricesPacket __attribute__((aligned(64)));
MATRIX localWorld, localScreen;
VECTOR position, rotation;
u32 vertCount;
-98
View File
@@ -1,98 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#ifndef _TYRA_VU1_
#define _TYRA_VU1_
#include "../models/math/matrix.hpp"
#include <draw_buffers.h>
#include <tamtypes.h>
#include <draw_primitives.h>
#include <packet.h>
#include <math3d.h>
const u32 VIF_BUFFER_SIZE = 48 * 1024;
typedef struct VU1BuildList
{
u8 isBuilding;
void *offset;
void *kickBuffer;
u32 dmaSize;
u32 dmaSizeAll;
u32 dmaDestination;
} VU1BuildList;
/** Class responsible for managing VU1 micro programs */
class VU1
{
public:
VU1();
~VU1();
static void uploadProgram(int t_dest, u32 *t_start, u32 *t_end);
void createList();
void sendSingleRefList(int t_destAddress, void *t_data, int t_quadSize);
void addListBeginning();
void continueList();
void addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops);
void addFloat(float v);
void add32(u32 v);
void add64(u64 v);
void add128(u64 v1, u64 v2);
void addListEnding();
void addStartProgram();
void addContinueProgram();
void sendList();
void addDoubleBufferSetting();
void addFlush();
private:
u8 isDoubleBufferSet;
void checkDataAlignment(void *data);
VU1BuildList buildList;
char dmaBuffer1[VIF_BUFFER_SIZE] __attribute__((aligned(16)));
char dmaBuffer2[VIF_BUFFER_SIZE] __attribute__((aligned(16)));
void *currentBuffer;
u32 switchBuffer;
static u32 countProgramSize(u32 *t_start, u32 *t_end);
void checkList();
inline s32 AddUnpack(int format, int addr, int num, int usetops = 0, int nosign = 1, int masking = 0)
{
return (s32)((0x60 << 24) + (format << 24) + (masking << 28) + (usetops << 15) +
(nosign << 14) + (num << 16) + addr);
}
};
#define DMA_REF_TAG(ADDR, COUNT) ((((unsigned long)ADDR) << 32) | (0x3 << 28) | COUNT)
#define DMA_CNT_TAG(COUNT) (((unsigned long)(0x1) << 28) | COUNT)
#define DMA_END_TAG(COUNT) (((unsigned long)(0x7) << 28) | COUNT)
#define VIF_NOP 0x00
#define VIF_STCYL 0x01
#define VIF_OFFSET 0x02
#define VIF_BASE 0x03
#define VIF_FLUSH 0x11
#define VIF_MSCAL 0x14
#define VIF_MSCNT 0x17
#define VIF_MPG 0x4A
#define V4_32 0xC
#define VIF_UNPACK 0x60
#define U128(n) ((u128)(n))
#define VIF_UNPACK_V4_32 (VIF_UNPACK | V4_32)
#define VIF_CODE(CMD, NUM, IMMEDIATE) ((((unsigned int)(CMD)) << 24) | \
(((unsigned int)(NUM)) << 16) | \
((unsigned int)(IMMEDIATE)))
#define GS_PRIM(PRIM, IIP, TME, FGE, ABE, AA1, FST, CTXT, FIX) U128((FIX << 10) | (CTXT << 9) | (FST << 8) | (AA1 << 7) | (ABE << 6) | (FGE << 5) | (TME << 4) | (IIP << 3) | (PRIM))
#define GS_GIFTAG(NLOOP, EOP, PRE, PRIM, FLG, NREG) (((u64)(NREG) << 60) | ((u64)(FLG) << 58) | ((u64)(PRIM) << 47) | ((u64)(PRE) << 46) | (EOP << 15) | (NLOOP << 0))
#define VU1_DMA_CHAN_TIMEOUT -1
#define GS_GIFTAG_PACKED 0
#endif
+3
View File
@@ -147,7 +147,10 @@ void ObjLoader::allocateObjMemory(FILE *t_file, MeshFrame *o_result)
if (strcmp(lineHeader, "usemtl") == 0)
{
if (currentMatI >= 0) // Skip -1
{
o_result->getMaterial(currentMatI).allocateFaces(facesCounter);
facesCounter = 0;
}
currentMatI++;
}
else if (strcmp(lineHeader, "f") == 0)
+1 -1
View File
@@ -117,7 +117,7 @@ audsrv_adpcm_t *Audio::loadADPCM(char *t_path)
char *fullFilename = String::createConcatenated("host:", t_path);
FILE *file = fopen(fullFilename, "rb");
delete[] fullFilename;
fseek(file, 0L, SEEK_END);
fseek(file, 0, SEEK_END);
u32 adpcmFileSize = ftell(file);
u8 data[adpcmFileSize];
rewind(file);
+60 -73
View File
@@ -32,16 +32,16 @@ GifSender::GifSender(u32 t_packetSize, ScreenSettings *t_screen) : screen(t_scre
{
PRINT_LOG("Initializing GifSender");
packetSize = t_packetSize;
packets[0] = packet_init(t_packetSize, PACKET_NORMAL);
packets[1] = packet_init(t_packetSize, PACKET_NORMAL);
packets[0] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
packets[1] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
PRINT_LOG("GifSender initialized!");
}
/** Releases packets memory */
GifSender::~GifSender()
{
packet_free(packets[0]);
packet_free(packets[1]);
packet2_free(packets[0]);
packet2_free(packets[1]);
}
// ----
@@ -54,37 +54,41 @@ GifSender::~GifSender()
/** Send texture via GIF */
void GifSender::sendTexture(MeshTexture &texture, texbuffer_t *t_texBuffer)
{
const u16 packetSize = 40;
packet_t *packet = packet_init(packetSize, PACKET_NORMAL);
qword_t *q = packet->data;
q = draw_texture_transfer(q, texture.getData(), texture.getWidth(), texture.getHeight(), GS_PSM_24, t_texBuffer->address, t_texBuffer->width);
DMATAG_CNT(q, 2, 0, 0, 0);
q++;
q = draw_texture_wrapping(q, 0, texture.getWrapSettings());
q = draw_texture_flush(q);
FlushCache(0);
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
dma_wait_fast();
packet_free(packet);
packet2_t *packet2 = packet2_create(15, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
packet2_update(
packet2,
draw_texture_transfer(
packet2->base,
texture.getData(),
texture.getWidth(),
texture.getHeight(), GS_PSM_24,
t_texBuffer->address,
t_texBuffer->width));
packet2_chain_open_cnt(packet2, 0, 0, 0);
packet2_update(packet2, draw_texture_wrapping(packet2->next, 0, texture.getWrapSettings()));
packet2_chain_close_tag(packet2);
packet2_update(packet2, draw_texture_flush(packet2->next));
dma_channel_wait(DMA_CHANNEL_GIF, 0);
dma_channel_send_packet2(packet2, DMA_CHANNEL_GIF, true);
dma_channel_wait(DMA_CHANNEL_GIF, 0);
packet2_free(packet2);
}
void GifSender::sendClear(zbuffer_t *t_zBuffer)
{
packet_t *packet = packet_init(100, PACKET_NORMAL);
qword_t *q = packet->data;
q++;
q = draw_disable_tests(q, 0, t_zBuffer);
q = draw_clear(q, 0,
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
screen->width, screen->height,
0x10, 0x10, 0x10);
q = draw_enable_tests(q, 0, t_zBuffer);
q = draw_finish(q);
DMATAG_END(packet->data, q - packet->data - 1, 0, 0, 0);
FlushCache(0);
dma_channel_send_chain(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
dma_wait_fast();
packet_free(packet);
packet2_t *packet2 = packet2_create(36, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
packet2_chain_open_end(packet2, 0, 0);
packet2_update(packet2, draw_disable_tests(packet2->next, 0, t_zBuffer));
packet2_update(packet2, draw_clear(packet2->next, 0,
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
screen->width, screen->height,
0x10, 0x10, 0x10));
packet2_update(packet2, draw_enable_tests(packet2->next, 0, t_zBuffer));
packet2_update(packet2, draw_finish(packet2->next));
packet2_chain_close_tag(packet2);
dma_channel_send_packet2(packet2, DMA_CHANNEL_GIF, true);
dma_channel_wait(DMA_CHANNEL_GIF, 0);
packet2_free(packet2);
}
/** Used in game loop.
@@ -93,12 +97,8 @@ void GifSender::sendClear(zbuffer_t *t_zBuffer)
void GifSender::initPacket(u8 t_context)
{
currentPacket = packets[t_context];
if (currentPacket->qwords > (u32)packetSize || currentPacket->qwords < 0)
PRINT_ERR("GifSender packet size error. Please consider to change packet size!\n");
q = currentPacket->data;
dmatag = q;
q++;
isAnyObjectAdded = 0;
packet2_reset(currentPacket, false);
isAnyObjectAdded = false;
}
/** Sends packet to GIF. */
@@ -106,25 +106,25 @@ void GifSender::sendPacket()
{
if (isAnyObjectAdded)
{
dmatag = q;
q++;
packet2_chain_open_end(currentPacket, 0, 0);
packet2_update(currentPacket, draw_finish(currentPacket->next));
packet2_chain_close_tag(currentPacket);
}
q = draw_finish(q);
DMATAG_END(dmatag, q - dmatag - 1, 0, 0, 0);
FlushCache(0);
dma_channel_send_chain(DMA_CHANNEL_GIF, currentPacket->data, q - currentPacket->data, 0, 0);
dma_wait_fast();
dma_channel_wait(DMA_CHANNEL_GIF, 0);
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_GIF, true);
}
/** Adds clear screen to current packet */
void GifSender::addClear(zbuffer_t *t_zBuffer)
{
q = draw_disable_tests(q, 0, t_zBuffer);
q = draw_clear(q, 0,
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
screen->width, screen->height,
0x10, 0x10, 0x10);
q = draw_enable_tests(q, 0, t_zBuffer);
packet2_chain_open_cnt(currentPacket, 0, 0, 0);
packet2_update(currentPacket, draw_disable_tests(currentPacket->next, 0, t_zBuffer));
packet2_update(currentPacket, draw_clear(currentPacket->next, 0,
2048.0F - (screen->width / 2), 2048.0F - (screen->height / 2),
screen->width, screen->height,
0x10, 0x10, 0x10));
packet2_update(currentPacket, draw_enable_tests(currentPacket->next, 0, t_zBuffer));
packet2_chain_close_tag(currentPacket);
}
/** Adds 3D objects to current packet
@@ -135,19 +135,10 @@ void GifSender::addClear(zbuffer_t *t_zBuffer)
*/
void GifSender::addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
{
if (!isAnyObjectAdded)
{
isAnyObjectAdded = true;
DMATAG_CNT(dmatag, q - dmatag - 1, 0, 0, 0); // init tag (before first 3d obj)
}
qword_t *tempDMATag;
tempDMATag = q;
q++;
q = draw_texture_sampling(q, 0, &t_mesh.lod);
q = draw_texturebuffer(q, 0, textureBuffer, &t_mesh.clut);
dw = (u64 *)draw_prim_start(q, 0, t_renderData->prim, &t_mesh.color);
packet2_chain_open_cnt(currentPacket, 0, 0, 0);
packet2_update(currentPacket, draw_texture_sampling(currentPacket->next, 0, &t_mesh.lod));
packet2_update(currentPacket, draw_texturebuffer(currentPacket->next, 0, textureBuffer, &t_mesh.clut));
packet2_update(currentPacket, draw_prim_start(currentPacket->next, 0, t_renderData->prim, &t_mesh.color));
xyz = new xyz_t[vertexCount];
rgbaq = new color_t[vertexCount];
st = new texel_t[vertexCount];
@@ -156,13 +147,8 @@ void GifSender::addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCoun
delete[] xyz;
delete[] rgbaq;
delete[] st;
if ((u32)dw % 16) // if we are in the middle of qw, switch packet
*dw++ = 0;
q = draw_prim_end((qword_t *)dw, 3, DRAW_STQ_REGLIST);
DMATAG_CNT(tempDMATag, q - tempDMATag - 1, 0, 0, 0);
packet2_update(currentPacket, draw_prim_end(currentPacket->next, 3, DRAW_STQ_REGLIST));
packet2_chain_close_tag(currentPacket);
}
/** Calculates 3D object data into xyz, rgbq, st
@@ -266,8 +252,9 @@ void GifSender::addCurrentCalcs(u32 &t_vertexCount)
{
for (u32 i = 0; i < t_vertexCount; i++)
{
*dw++ = rgbaq[i].rgbaq;
*dw++ = st[i].uv;
*dw++ = xyz[i].xyz;
packet2_add_u64(currentPacket, rgbaq[i].rgbaq);
packet2_add_u64(currentPacket, st[i].uv);
packet2_add_u64(currentPacket, xyz[i].xyz);
}
packet2_align_to_qword(currentPacket);
}
+11 -15
View File
@@ -40,7 +40,7 @@ Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
isVSyncEnabled = true;
isFrameEmpty = false;
lastTextureId = 0;
flipPacket = packet_init(3, PACKET_UCAB); // Uncached accelerated
flipPacket = packet2_create(4, P2_TYPE_UNCACHED_ACCL, P2_MODE_NORMAL, 0);
allocateBuffers(t_screen->width, t_screen->height);
initDrawingEnv(t_screen->width, t_screen->height);
setPrim();
@@ -104,17 +104,15 @@ void Renderer::changeTexture(const Mesh &t_mesh, u32 t_materialId)
void Renderer::initDrawingEnv(float t_screenW, float t_screenH)
{
PRINT_LOG("Initializing drawing environment");
packet_t *packet = packet_init(20, PACKET_NORMAL);
u16 halfW = (u16)t_screenW / 2;
u16 halfH = (u16)t_screenH / 2;
qword_t *q = packet->data; // Generic qword pointer.
q = draw_setup_environment(q, 0, frameBuffers, &(zBuffer));
q = draw_primitive_xyoffset(q, 0, (2048 - halfW), (2048 - halfH));
q = draw_finish(q);
// Now send the packet, no need to wait since it's the first.
dma_channel_send_normal(DMA_CHANNEL_GIF, packet->data, q - packet->data, 0, 0);
dma_wait_fast();
packet_free(packet);
packet2_t *packet2 = packet2_create(20, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0);
packet2_update(packet2, draw_setup_environment(packet2->base, 0, frameBuffers, &(zBuffer)));
packet2_update(packet2, draw_primitive_xyoffset(packet2->next, 0, (2048 - halfW), (2048 - halfH)));
packet2_update(packet2, draw_finish(packet2->next));
dma_channel_send_packet2(packet2, DMA_CHANNEL_GIF, true);
dma_channel_wait(DMA_CHANNEL_GIF, 0);
packet2_free(packet2);
PRINT_LOG("Drawing environment initialized!");
}
@@ -277,10 +275,8 @@ void Renderer::flipBuffers()
0);
context ^= 1;
isFrameEmpty = 1;
qword_t *q = flipPacket->data;
q = draw_framebuffer(q, 0, &frameBuffers[context]);
q = draw_finish(q);
dma_wait_fast();
dma_channel_send_normal_ucab(DMA_CHANNEL_GIF, flipPacket->data, q - flipPacket->data, 0);
packet2_update(flipPacket, draw_framebuffer(flipPacket->base, 0, &frameBuffers[context]));
packet2_update(flipPacket, draw_finish(flipPacket->next));
dma_channel_send_packet2(flipPacket, DMA_CHANNEL_GIF, true);
draw_wait_finish();
}
+78 -73
View File
@@ -16,42 +16,79 @@
#include "../include/utils/math.hpp"
#include "../include/utils/debug.hpp"
// Similiar set is in PS2SDK, but for VU1 we have to switch ST with RGBAQ, because VU1 must know Q before sending RGBAQ
#define DRAW_R_STQ_REGLIST ((u64)GIF_REG_ST) << 0 | ((u64)GIF_REG_RGBAQ) << 4 | ((u64)GIF_REG_XYZ2) << 8
const u32 VU1_PACKAGE_VERTS_PER_BUFF = 96; // Remember to modify buffer size in vu1 also
const u32 VU1_PACKAGES_PER_PACKET = 6;
const u32 VU1_PACKET_SIZE = 128;
// ----
// Constructors/Destructors
// ----
// VU1 micro program
extern u32 VU1Draw3D_CodeStart __attribute__((section(".vudata")));
extern u32 VU1Draw3D_CodeEnd __attribute__((section(".vudata")));
//
VifSender::VifSender()
{
PRINT_LOG("Initializing VifSender");
PRINT_LOG("VifSender initialized!");
dma_channel_initialize(DMA_CHANNEL_VIF1, NULL, 0);
dma_channel_fast_waits(DMA_CHANNEL_VIF1);
uploadMicroProgram();
packets[0] = packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
packets[1] = packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
matricesPacket = packet2_create(4, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
context = 0;
setDoubleBuffer();
}
VifSender::~VifSender() {}
VifSender::~VifSender()
{
packet2_free(packets[0]);
packet2_free(packets[1]);
packet2_free(matricesPacket);
}
// ----
// Methods
// ----
void VifSender::uploadMicroProgram()
{
packet2_t *packet2 = packet2_create(
packet2_utils_get_packet_size_for_program(&VU1Draw3D_CodeStart, &VU1Draw3D_CodeEnd) + 1, // + end tag
P2_TYPE_NORMAL,
P2_MODE_CHAIN,
1);
packet2_vif_add_micro_program(packet2, 0, &VU1Draw3D_CodeStart, &VU1Draw3D_CodeEnd);
packet2_utils_vu_add_end_tag(packet2);
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
dma_channel_send_packet2(packet2, DMA_CHANNEL_VIF1, 1);
packet2_free(packet2);
}
void VifSender::sendMatrices(const RenderData &t_renderData, const Vector3 &t_position, const Vector3 &t_rotation)
{
vec3ToNative(position, t_position, 1.0F);
vec3ToNative(rotation, t_rotation, 1.0F);
create_local_world(localWorld, position, rotation);
create_local_screen(localScreen, localWorld, t_renderData.worldView->data, t_renderData.perspective->data);
vu1.sendSingleRefList(0, &localScreen, 8);
packet2_reset(matricesPacket, false);
packet2_utils_vu_add_unpack_data(matricesPacket, 0, &localScreen, 8, 0);
packet2_utils_vu_add_end_tag(matricesPacket);
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
dma_channel_send_packet2(matricesPacket, DMA_CHANNEL_VIF1, 1);
}
void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, const Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
{
// we have to split 3D object into small parts, because of small memory of VU1
for (u32 i = 0; i < vertCount2;)
{
vu1.createList();
currPacket = packets[context];
packet2_reset(currPacket, false);
for (u8 j = 0; j < VU1_PACKAGES_PER_PACKET; j++) // how many "packages" per one packet
{
if (i != 0) // we have to go back to avoid the visual artifacts
@@ -67,74 +104,43 @@ void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 ver
i += (VU1_PACKAGE_VERTS_PER_BUFF - 1);
i++;
}
vu1.sendList();
packet2_utils_vu_add_end_tag(currPacket);
dma_channel_send_packet2(currPacket, DMA_CHANNEL_VIF1, 1);
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
context = !context;
}
}
void VifSender::setDoubleBuffer()
{
packet2_t *settings = packet2_create(2, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
packet2_utils_vu_add_double_buffer(settings, 8, 496);
packet2_utils_vu_add_end_tag(settings);
dma_channel_send_packet2(settings, DMA_CHANNEL_VIF1, 1);
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
packet2_free(settings);
}
/** Draw using PATH1 */
void VifSender::drawVertices(const Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *textureBuffer)
void VifSender::drawVertices(Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *textureBuffer)
{
const u32 vertCount = t_end - t_start;
vu1.addListBeginning();
currPacket->vif_added_bytes = 0;
packet2_utils_vu_open_unpack(currPacket, 0, 1);
// TODO get this via screensettings
vu1.addFloat(2048.0F); // scale
vu1.addFloat(2048.0F); // scale
vu1.addFloat(((float)0xFFFFFF) / 32.0F); // scale
vu1.add32(vertCount); // vertex count
vu1.add128(GIF_SET_TAG(1, 0, 0, 0, GIF_FLG_PACKED, 1), GIF_REG_AD); // 1x set tag
vu1.add128( // tex -> lod
GS_SET_TEX1(
t_mesh.lod.calculation,
t_mesh.lod.max_level,
t_mesh.lod.mag_filter,
t_mesh.lod.min_filter,
t_mesh.lod.mipmap_select,
t_mesh.lod.l,
(int)(t_mesh.lod.k * 16.0F)),
GS_REG_TEX1);
vu1.add128( // tex -> buff + clut
GS_SET_TEX0(
textureBuffer->address >> 6,
textureBuffer->width >> 6,
textureBuffer->psm,
textureBuffer->info.width,
textureBuffer->info.height,
textureBuffer->info.components,
textureBuffer->info.function,
t_mesh.clut.address >> 6,
t_mesh.clut.psm,
t_mesh.clut.storage_mode,
t_mesh.clut.start,
t_mesh.clut.load_method),
GS_REG_TEX0);
vu1.add128(
GS_GIFTAG(
vertCount, // amount of loops
1,
1,
GS_PRIM(
t_prim->type,
t_prim->shading,
t_prim->mapping,
t_prim->fogging,
t_prim->blending,
t_prim->antialiasing,
t_prim->mapping_type,
0, // context
t_prim->colorfix),
GS_GIFTAG_PACKED,
3), // STQ + RGBA + XYZ
DRAW_R_STQ_REGLIST);
packet2_add_float(currPacket, 2048.0F); // scale
packet2_add_float(currPacket, 2048.0F); // scale
packet2_add_float(currPacket, ((float)0xFFFFFF) / 32.0F); // scale
packet2_add_u32(currPacket, vertCount); // vertex count
packet2_utils_gif_add_set(currPacket, 1);
packet2_utils_gs_add_lod(currPacket, &t_mesh.lod);
packet2_utils_gs_add_texbuff_clut(currPacket, textureBuffer, &t_mesh.clut);
packet2_utils_gs_add_prim_giftag(currPacket, t_prim, vertCount, DRAW_STQ2_REGLIST, 3, 0);
for (u8 j = 0; j < 4; j++)
vu1.add32(128);
packet2_add_u32(currPacket, 128);
//// Clipping tests start
// Clipping tests start
// // const float minZ = 1;
// // const float maxZ = 65535;
@@ -169,15 +175,14 @@ void VifSender::drawVertices(const Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR
// // vu1.addFloat(1.0F);
// // vu1.addFloat(500.0F); // far
vu1.addFloat(0.0F);
vu1.addFloat(0.0F);
vu1.addFloat(0.0F);
vu1.addFloat(0.0F);
packet2_add_float(currPacket, 0.0F);
packet2_add_float(currPacket, 0.0F);
packet2_add_float(currPacket, 0.0F);
packet2_add_float(currPacket, 0.0F);
//// Clipping tests end
vu1.addListEnding();
vu1.addReferenceList(0, t_vertices + t_start, 2 * vertCount, 1);
vu1.addReferenceList(0, t_coordinates + t_start, 2 * vertCount, 1);
vu1.addStartProgram();
packet2_utils_vu_close_unpack(currPacket);
packet2_utils_vu_add_unpack_data(currPacket, packet2_get_vif_added_qws(currPacket), t_vertices + t_start, vertCount, 1);
packet2_utils_vu_add_unpack_data(currPacket, packet2_get_vif_added_qws(currPacket), t_coordinates + t_start, vertCount, 1);
packet2_utils_vu_add_start_program(currPacket, 0);
}
-276
View File
@@ -1,276 +0,0 @@
/*
# ______ ____ ___
# | \/ ____| |___|
# | | | \ | |
#-----------------------------------------------------------------------
# Copyright 2020, tyra - https://github.com/h4570/tyra
# Licenced under Apache License 2.0
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
*/
#include "../include/modules/vu1.hpp"
#include "../include/utils/debug.hpp"
#include <dma.h>
#include <string.h>
#include <kernel.h>
// ----
// Constructors/Destructors
// ----
VU1::VU1()
{
PRINT_LOG("Initializing VU1");
currentBuffer = 0;
switchBuffer = 0;
PRINT_LOG("VU1 initialized!");
}
VU1::~VU1() {}
// ----
// Methods
// -
/** Create dynamic list */
void VU1::createList()
{
switchBuffer = !switchBuffer;
memset((char *)&buildList, 0, sizeof(buildList));
if (switchBuffer)
currentBuffer = (char *)&dmaBuffer1;
else
currentBuffer = (char *)&dmaBuffer2;
buildList.kickBuffer = currentBuffer;
}
/** Add reference list and send via VIF1
* Not using TOPS register
* Similar to addReferenceList()
*/
void VU1::sendSingleRefList(int t_destAddress, void *t_data, int t_quadSize)
{
checkDataAlignment(t_data);
u8 tempBuffer[32] __attribute__((aligned(16)));
void *chain = (u64 *)&tempBuffer; // uncached
*((u64 *)chain)++ = DMA_REF_TAG((u32)t_data, t_quadSize);
*((u32 *)chain)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
*((u32 *)chain)++ = VIF_CODE(VIF_UNPACK_V4_32, t_quadSize, t_destAddress);
*((u64 *)chain)++ = DMA_END_TAG(0);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
FlushCache(0);
dma_channel_send_chain(DMA_CHANNEL_VIF1, tempBuffer, 0, DMA_FLAG_TRANSFERTAG, 0);
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT);
}
/** Add list beginning, set's double buffer if not set */
void VU1::addListBeginning()
{
if (buildList.isBuilding == 1)
PRINT_ERR("Please end current list list before adding new one!");
if (isDoubleBufferSet == 0)
addDoubleBufferSetting();
else
addFlush();
buildList.dmaSizeAll += buildList.dmaSize;
buildList.dmaSize = 0;
buildList.offset = currentBuffer;
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0); // placeholder
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_STCYL, 0, 0x0101); // placeholder
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_UNPACK_V4_32, 0, 0); // placeholder
buildList.isBuilding = 1;
}
/** Add list ending and fix unpack size */
void VU1::addListEnding()
{
if (buildList.isBuilding == 0)
{
PRINT_ERR("Please add list beginning first. Nothing to end!");
return;
}
while ((buildList.dmaSize & 0xF))
{
*((u32 *)currentBuffer)++ = 0;
buildList.dmaSize += 4;
}
*((u64 *)buildList.offset)++ = DMA_CNT_TAG(buildList.dmaSize >> 4);
*((u32 *)buildList.offset)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
*((u32 *)buildList.offset)++ = AddUnpack(V4_32, 0, buildList.dmaSize >> 4, 1);
buildList.isBuilding = 0;
}
/** Add list which will load data from given pointer
* A lot faster than standard list.
* @param offset offset before data in quadwords
* @param data data pointer
* @param size in quadwords
* @param useTops when true, data will be loaded at the beginning of buffer (BASE+OFFSET)
*/
void VU1::addReferenceList(u32 t_offset, void *t_data, u32 t_size, u8 t_useTops)
{
checkDataAlignment(t_data);
if (buildList.isBuilding == 1)
PRINT_ERR("Please end current list list before adding new one!");
*((u64 *)currentBuffer)++ = DMA_REF_TAG((u32)t_data, t_size);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_STCYL, 0, 0x0101);
*((u32 *)currentBuffer)++ =
AddUnpack(V4_32, t_useTops == 1 ? buildList.dmaSize >> 4 : t_offset >> 4, t_size, t_useTops);
buildList.dmaSize += t_size * 8;
buildList.dmaSizeAll += buildList.dmaSize;
}
/** Start VU1 program */
void VU1::addStartProgram()
{
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
;
}
/** Continue VU1 program from "--cont" line */
void VU1::addContinueProgram()
{
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_MSCAL, 0, 0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
;
}
/** Add end tag and send packet via VIF1 */
void VU1::sendList()
{
*((u64 *)currentBuffer)++ = DMA_END_TAG(0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
FlushCache(0);
dma_channel_send_chain(DMA_CHANNEL_VIF1, buildList.kickBuffer, (u32 *)currentBuffer - (u32 *)buildList.kickBuffer, DMA_FLAG_TRANSFERTAG, 0);
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT);
}
void VU1::addDoubleBufferSetting()
{
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_BASE, 0, 8);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_OFFSET, 0, 496);
isDoubleBufferSet = 1;
}
void VU1::addFlush()
{
*((u64 *)currentBuffer)++ = DMA_CNT_TAG(8 >> 4);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)currentBuffer)++ = VIF_CODE(VIF_FLUSH, 0, 0);
}
void VU1::checkDataAlignment(void *t_data)
{
if (((u32)t_data & 0xF))
PRINT_ERR("data is not 16 byte aligned!");
}
// ----
// List adding
// ----
void VU1::add128(u64 v1, u64 v2)
{
checkList();
*((u64 *)currentBuffer)++ = v1;
*((u64 *)currentBuffer)++ = v2;
buildList.dmaSize += 16;
}
void VU1::add64(u64 v)
{
checkList();
*((u64 *)currentBuffer)++ = v;
buildList.dmaSize += 8;
}
void VU1::add32(u32 v)
{
checkList();
*((u32 *)currentBuffer)++ = v;
buildList.dmaSize += 4;
}
void VU1::addFloat(float v)
{
checkList();
*((float *)currentBuffer)++ = v;
buildList.dmaSize += 4;
}
void VU1::checkList()
{
if (buildList.isBuilding == 0)
PRINT_ERR("Please add list beginning before adding data!");
if (buildList.dmaSizeAll > VIF_BUFFER_SIZE)
PRINT_ERR("Buffer size exceed!");
}
// ----
// Static
// ----
u8 IS_DMA_VIF1_INITIALIZED = 0;
/** TODO */
void VU1::uploadProgram(int t_dest, u32 *t_start, u32 *t_end)
{
if (!IS_DMA_VIF1_INITIALIZED)
{
IS_DMA_VIF1_INITIALIZED = 1;
dma_channel_initialize(DMA_CHANNEL_VIF1, NULL, 0);
dma_channel_fast_waits(DMA_CHANNEL_VIF1);
}
int count = 0;
u8 tempBuffer[512] __attribute__((aligned(16)));
void *chain = (u64 *)&tempBuffer; // uncached
// get the size of the code as we can only send 256 instructions in each MPGtag
count = VU1::countProgramSize(t_start, t_end);
while (count > 0)
{
u32 currentCount = count > 256 ? 256 : count;
*((u64 *)chain)++ = DMA_REF_TAG((u32)t_start, currentCount / 2);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)chain)++ = VIF_CODE(VIF_MPG, currentCount & 0xFF, t_dest);
t_start += currentCount * 2;
count -= currentCount;
t_dest += currentCount;
}
*((u64 *)chain)++ = DMA_END_TAG(0);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
*((u32 *)chain)++ = VIF_CODE(VIF_NOP, 0, 0);
// Send it to vif1
FlushCache(0);
dma_channel_send_chain(DMA_CHANNEL_VIF1, tempBuffer, 0, DMA_FLAG_TRANSFERTAG, 0);
dma_channel_wait(DMA_CHANNEL_VIF1, VU1_DMA_CHAN_TIMEOUT); // synchronize immediately.
}
u32 VU1::countProgramSize(u32 *t_start, u32 *t_end)
{
u32 size = (t_end - t_start) / 2;
if (size & 1)
size++;
return size;
}
+1 -2
View File
@@ -19,7 +19,6 @@ EE_OBJS = \
../../engine/modules/texture_repository.o \
../../engine/modules/timer.o \
../../engine/modules/vif_sender.o \
../../engine/modules/vu1.o \
../../engine/utils/math.o \
../../engine/utils/string.o \
../../engine/loaders/bmp_loader.o \
@@ -33,7 +32,7 @@ EE_OBJS = \
ari.o \
main.o
EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpad -laudsrv -lc -lstdc++
EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++
EE_INCS := -I./../../engine/include $(EE_INCS)
EE_DVP = dvp-as
EE_VCL = vcl
+40 -37
View File
@@ -33,11 +33,15 @@ Ari::~Ari() {}
void Ari::onInit()
{
engine->renderer->setCameraDefinitions(&camera.worldView, &camera.position, camera.planes);
engine->audio.setSongVolume(60);
engine->audio.loadSong("MOV-CIRC.WAV");
adpcm = engine->audio.loadADPCM("ziobro.adpcm");
texRepo = engine->renderer->getTextureRepository();
engine->audio.setSongVolume(40);
// engine->audio.loadSong("MOV-CIRC.WAV");
engine->audio.loadSong("nob-else.wav");
adpcm1 = engine->audio.loadADPCM("ziobro1.adpcm");
adpcm2 = engine->audio.loadADPCM("ziobro2.adpcm");
texRepo = engine->renderer->getTextureRepository();
engine->renderer->disableVSync();
island.loadDff("sunnyisl/", "sunnyisl", 0.1F, false);
island.rotation.x = -1.6F;
island.position.set(0.0F, 10.0F, 20.0F);
@@ -49,35 +53,32 @@ void Ari::onInit()
islandAddons.rotation.x = -1.6F;
islandAddons.position.set(0.0F, 10.0F, 20.0F);
// skybox.loadObj("skybox/", "skybox", 100.0F, false);
// skybox.shouldBeFrustumCulled = false;
skybox.loadObj("skybox/", "skybox", 100.0F, false);
skybox.shouldBeFrustumCulled = false;
// waterFloors[0].loadObj("water/", "water", 5.0F, false);
// waterFloors[0].position.set(0.0F, 8.0F, 0.0F);
// texRepo->addByMesh("water/", waterFloors[0]);
// for (u8 i = 0; i < WATER_TILES_COUNT; i++)
// {
// spirals[i].x = 1.0F;
// spirals[i].y = 2.0F;
// }
// u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
// calcSpiral(spiralOffset, spiralOffset);
// for (u8 i = 1; i < WATER_TILES_COUNT; i++)
// {
// waterFloors[i].loadFrom(waterFloors[0]);
// waterFloors[i].position.set(10.0F * spirals[i].x, 8.0F, 10.0F * spirals[i].y);
// texRepo->getByMesh(waterFloors[0].getId(), waterFloors[0].getMaterial(0).getId())
// ->addLink(waterFloors[i].getId(), waterFloors[i].getMaterial(0).getId());
// }
waterFloors[0].loadObj("water/", "water", 5.0F, false);
waterFloors[0].position.set(0.0F, 8.0F, 0.0F);
texRepo->addByMesh("water/", waterFloors[0]);
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
{
spirals[i].x = 1.0F;
spirals[i].y = 2.0F;
}
u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
calcSpiral(spiralOffset, spiralOffset);
for (u8 i = 1; i < WATER_TILES_COUNT; i++)
{
waterFloors[i].loadFrom(waterFloors[0]);
waterFloors[i].position.set(10.0F * spirals[i].x, 8.0F, 10.0F * spirals[i].y);
texRepo->getByMesh(waterFloors[0].getId(), waterFloors[0].getMaterial(0).getId())
->addLink(waterFloors[i].getId(), waterFloors[i].getMaterial(0).getId());
}
texRepo->addByMesh("sunnyisl/", island);
// texRepo->addByMesh("sunnyisl/", islandAddons);
// texRepo->addByMesh("skybox/", skybox);
// texRepo->addByMesh("ari/", player.mesh);
engine->audio.playSong();
texRepo->addByMesh("sunnyisl/", islandAddons);
texRepo->addByMesh("skybox/", skybox);
texRepo->addByMesh("ari/", player.mesh);
// engine->audio.playSong();
}
void Ari::initBulb()
@@ -90,17 +91,19 @@ void Ari::onUpdate()
{
if (engine->pad.isCrossClicked)
{
engine->audio.loadSong("nob-else.wav");
engine->audio.playADPCM(adpcm);
// engine->audio.loadSong("nob-else.wav");
engine->audio.playADPCM(adpcm1);
printf("FPS:%f\n", engine->fps);
}
if (engine->pad.isCircleClicked)
engine->audio.playADPCM(adpcm2);
camera.update(engine->pad, player.mesh);
// engine->renderer->draw(skybox);
engine->renderer->draw(skybox);
engine->renderer->draw(island);
// engine->renderer->draw(islandAddons);
// engine->renderer->draw(player.mesh);
// for (u8 i = 0; i < WATER_TILES_COUNT; i++)
// engine->renderer->draw(waterFloors[i]);
engine->renderer->draw(islandAddons);
engine->renderer->draw(player.mesh);
for (u8 i = 0; i < WATER_TILES_COUNT; i++)
engine->renderer->draw(waterFloors[i]);
}
void Ari::calcSpiral(int X, int Y)
+1 -1
View File
@@ -39,7 +39,7 @@ private:
Player player;
Mesh island, islandAddons, skybox;
Mesh *waterFloors;
audsrv_adpcm_t *adpcm;
audsrv_adpcm_t *adpcm1, *adpcm2;
Point *spirals;
Camera camera;
TextureRepository *texRepo;
+1 -1
View File
@@ -14,7 +14,7 @@ int main()
{
Engine engine = Engine();
Ari game = Ari(&engine);
game.engine->init(&game, 40000);
game.engine->init(&game, 128);
SleepThread();
return 0;
}
+10 -10
View File
@@ -22,16 +22,16 @@
Player::Player()
{
// PRINT_LOG("Creating player object");
// this->gravity = 0.1F;
// this->lift = -1.0F;
// this->mesh.loadMD2("ari/", "ari", 0.0001F, true);
// this->mesh.position.set(0.0F, 10.0F, 0.0F);
// this->mesh.shouldBeBackfaceCulled = true;
// this->mesh.shouldBeFrustumCulled = false;
// this->mesh.shouldBeLighted = true;
// this->mesh.setAnimSpeed(0.05F);
// this->mesh.playAnimation(0, 1);
PRINT_LOG("Creating player object");
this->gravity = 0.1F;
this->lift = -1.0F;
this->mesh.loadMD2("ari/", "ari", 0.0001F, true);
this->mesh.position.set(0.0F, 10.0F, 0.0F);
this->mesh.shouldBeBackfaceCulled = true;
this->mesh.shouldBeFrustumCulled = false;
this->mesh.shouldBeLighted = true;
this->mesh.setAnimSpeed(0.05F);
this->mesh.playAnimation(0, 1);
PRINT_LOG("Player object created!");
}
+10 -2
View File
@@ -19,7 +19,6 @@ EE_OBJS = \
../../engine/modules/texture_repository.o \
../../engine/modules/timer.o \
../../engine/modules/vif_sender.o \
../../engine/modules/vu1.o \
../../engine/utils/math.o \
../../engine/utils/string.o \
../../engine/loaders/bmp_loader.o \
@@ -37,7 +36,7 @@ EE_OBJS = \
floors.o \
main.o
EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpad -laudsrv -lc -lstdc++
EE_LIBS = -ldraw -lgraph -lmath3d -lpacket -ldma -lpad -lpacket2 -laudsrv -lc -lstdc++
EE_INCS := -I./../../engine/include $(EE_INCS)
EE_DVP = dvp-as
EE_VCL = openvcl
@@ -56,5 +55,14 @@ all: $(EE_BIN)
clean:
rm -f $(EE_BIN) $(EE_OBJS)
run: $(EE_BIN)
killall -v ps2client || true
ps2client reset
ps2client reset
$(EE_STRIP) --strip-all $(EE_BIN)
mv $(EE_BIN) bin/$(EE_BIN)
rm $(EE_OBJS)
cd bin/ && ps2client execee host:$(EE_BIN)
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal
+1 -1
View File
@@ -51,7 +51,7 @@ void Floors::onUpdate()
camera.update(engine->pad, player.mesh);
floorManager.update(player);
player.update(engine->pad, camera, floorManager);
// engine->renderer->draw(player.mesh);
engine->renderer->draw(player.mesh);
for (u8 i = 0; i < FLOORS_COUNT; i++)
engine->renderer->drawByPath3(floorManager.floors[i].mesh, lightManager.bulbs, lightManager.bulbsCount);
}
+1 -1
View File
@@ -14,7 +14,7 @@ int main()
{
Engine engine = Engine();
Floors game = Floors(&engine);
game.engine->init(&game, 40000);
game.engine->init(&game, 128);
SleepThread();
return 0;
}