Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion include/fast/interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "fast/resource/type/Texture.h"
#include "ship/resource/Resource.h"

// TODO figure out why changing these to 640x480 makes the game only render in a quarter of the window
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240

Expand Down Expand Up @@ -257,6 +256,10 @@ struct RSP {

struct RDP {
const uint8_t* palettes[2];
// CI4 palette staging buffer: N64 TMEM holds up to 16 CI4 palettes (16 entries x 2 bytes each = 32 bytes per
// palette). palettes[0] covers indices 0-7 (256 bytes), palettes[1] covers 8-15 (256 bytes). GfxDpLoadTlut copies
// TLUT data here at the correct offset so multi-palette CI4 models work.
uint8_t palette_staging[2][256];
struct {
const uint8_t* addr;
uint8_t siz;
Expand Down Expand Up @@ -517,6 +520,12 @@ class Interpreter {
std::vector<std::string> shader_ids;
int mInterpolationIndex;
int mInterpolationIndexTarget;

// When true, GfxDpSetTile will derive loaded_texture[1] from loaded_texture[0]
// for tiles at tmem != 0 when no separate texture has been loaded there.
// Needed for games that load a single texture block at TMEM 0 and reference
// sub-regions via tile descriptors at different TMEM offsets.
bool mDeriveTmemFromLoadedTexture{};
};

void gfx_set_target_ucode(UcodeHandlers ucode);
Expand Down
4 changes: 2 additions & 2 deletions include/fast/lus_gbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ constexpr int8_t RDP_G_SETTARGETINTERPINDEX = OPCODE(0x45);
*/
#define G_MAXFBZ 0x3fff /* 3b exp, 11b mantissa */

#define GPACK_RGBA5551(r, g, b, a) ((((r) << 8) & 0xf800) | (((g) << 3) & 0x7c0) | (((b) >> 2) & 0x3e) | ((a)&0x1))
#define GPACK_RGBA5551(r, g, b, a) ((((r) << 8) & 0xf800) | (((g) << 3) & 0x7c0) | (((b) >> 2) & 0x3e) | ((a) & 0x1))
#define GPACK_ZDZ(z, dz) ((z) << 2 | (dz))

/*
Expand Down Expand Up @@ -1336,7 +1336,7 @@ typedef struct {
} F3DuObjTxtrTile_t; /* 24 bytes */

#define GS_PAL_HEAD(head) ((head) + 256)
#define GS_PAL_NUM(num) ((num)-1)
#define GS_PAL_NUM(num) ((num) - 1)

typedef struct {
unsigned int type; /* G_OBJLT_TLUT divided into types */
Expand Down
829 changes: 385 additions & 444 deletions include/libultraship/libultra/gbi.h

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions include/libultraship/libultra/gs2dex.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ typedef struct {
} uObjTxtrTile_t; /* 24 bytes */

#define GS_PAL_HEAD(head) ((head) + 256)
#define GS_PAL_NUM(num) ((num)-1)
#define GS_PAL_NUM(num) ((num) - 1)

typedef struct {
u32 type; /* G_OBJLT_TLUT divided into types */
Expand Down Expand Up @@ -294,22 +294,22 @@ typedef struct {
*---------------------------------------------------------------------------*/
#define gSPSelectDL(pkt, mptr, sid, flag, mask) \
{ \
gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr)&0xffff, (sid)); \
gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \
gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); \
}
#define gsSPSelectDL(mptr, sid, flag, mask) \
{ \
gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr)&0xffff, (sid)); \
gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \
gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_PUSH); \
}
#define gSPSelectBranchDL(pkt, mptr, sid, flag, mask) \
{ \
gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr)&0xffff, (sid)); \
gDma1p((pkt), G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \
gDma1p((pkt), G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); \
}
#define gsSPSelectBranchDL(mptr, sid, flag, mask) \
{ \
gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr)&0xffff, (sid)); \
gsDma1p(G_RDPHALF_0, (flag), (u32)(mptr) & 0xffff, (sid)); \
gsDma1p(G_SELECT_DL, (mask), (u32)(mptr) >> 16, G_DL_NOPUSH); \
}

Expand Down
2 changes: 1 addition & 1 deletion include/libultraship/libultra/gu.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#define GU_PI 3.1415926

#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x)-0.5))
#define ROUND(x) (s32)(((x) >= 0.0) ? ((x) + 0.5) : ((x) - 0.5))

#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
Expand Down
2 changes: 1 addition & 1 deletion include/libultraship/libultra/mbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "abi.h"

#define NUM_SEGMENTS (16)
#define SEGMENT_OFFSET(a) ((u32)(a)&0x00FFFFFF)
#define SEGMENT_OFFSET(a) ((u32)(a) & 0x00FFFFFF)
#define SEGMENT_NUMBER(a) (((u32)(a) << 4) >> 28)
#define SEGMENT_ADDR(num, off) (((num) << 24) + (off))

Expand Down
4 changes: 4 additions & 0 deletions src/fast/backends/gfx_direct3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,10 @@ static D3D11_TEXTURE_ADDRESS_MODE gfx_cm_to_d3d11(uint32_t val) {
}

void GfxRenderingAPIDX11::UploadTexture(const uint8_t* rgba32_buf, uint32_t width, uint32_t height) {
if (width == 0 || height == 0) {
return;
}

// Create texture

TextureData* texture_data = &mTextures[mCurrentTextureIds[mCurrentTile]];
Expand Down
3 changes: 3 additions & 0 deletions src/fast/backends/gfx_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,9 @@ void GfxRenderingAPIOGL::SelectTexture(int tile, GLuint texture_id) {
}

void GfxRenderingAPIOGL::UploadTexture(const uint8_t* rgba32_buf, uint32_t width, uint32_t height) {
if (width == 0 || height == 0) {
return;
}
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, rgba32_buf);
textures[mCurrentTextureIds[mCurrentTile]].width = width;
textures[mCurrentTextureIds[mCurrentTile]].height = height;
Expand Down
Loading
Loading