mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-12 09:06:55 -04:00
Gamecube/Wii: Fix textures not being animated (sorta), fix see-through blocks being drawn opaquely, fix backfaces of blocks (e.g. leaves) not being culled, fix sockets not connecting
This commit is contained in:
parent
fd6301a840
commit
e87b3fe1dc
@ -22,6 +22,12 @@ Copyright 2014-2022 ClassiCube | Licensed under BSD-3
|
||||
#elif defined CC_BUILD_3DS
|
||||
#define GAME_APP_NAME "ClassiCube 1.3.5 3DS"
|
||||
#define GAME_APP_TITLE "ClassiCube 1.3.5 3DS"
|
||||
#elif defined CC_BUILD_PSP
|
||||
#define GAME_APP_NAME "ClassiCube 1.3.5 PSP"
|
||||
#define GAME_APP_TITLE "ClassiCube 1.3.5 PSP"
|
||||
#elif defined CC_BUILD_GCWII
|
||||
#define GAME_APP_NAME "ClassiCube 1.3.5 GC/Wii"
|
||||
#define GAME_APP_TITLE "ClassiCube 1.3.5 GC/Wii"
|
||||
#else
|
||||
#define GAME_APP_NAME "ClassiCube 1.3.5"
|
||||
#define GAME_APP_TITLE "ClassiCube 1.3.5"
|
||||
|
@ -93,19 +93,23 @@ typedef struct CCTexture_ {
|
||||
// GX RGBA8 textures
|
||||
// - store pixels in 4x4 tiles
|
||||
// - store all of the AR values of the tile's pixels, then store all of the GB values
|
||||
static void ReorderPixels(cc_uint32* pixels, struct Bitmap* bmp,
|
||||
static void ReorderPixels(CCTexture* tex, struct Bitmap* bmp,
|
||||
int originX, int originY, int rowWidth) {
|
||||
int size = bmp->width * bmp->height * 4;
|
||||
int stride = GX_GetTexObjWidth(&tex->obj) * 4;
|
||||
// TODO not really right
|
||||
// TODO originX ignored
|
||||
originX &= ~0x03;
|
||||
originY &= ~0x03;
|
||||
|
||||
// http://hitmen.c02.at/files/yagcd/yagcd/chap15.html
|
||||
// section 15.35 TPL (Texture Palette)
|
||||
// "RGBA8 (4x4 tiles in two cache lines - first is AR and second is GB"
|
||||
uint8_t *src = (uint8_t*)bmp->scan0;
|
||||
uint8_t *dst = (uint8_t*)pixels;
|
||||
uint8_t *dst = (uint8_t*)tex->pixels + stride * originY;
|
||||
int srcWidth = bmp->width, srcHeight = bmp->height;
|
||||
|
||||
for (int tileY = originY; tileY < originY + srcHeight; tileY += 4)
|
||||
for (int tileX = originX; tileX < originX + srcWidth; tileX += 4)
|
||||
for (int tileY = 0; tileY < srcHeight; tileY += 4)
|
||||
for (int tileX = 0; tileX < srcWidth; tileX += 4)
|
||||
{
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
@ -140,7 +144,7 @@ GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipm
|
||||
GX_TF_RGBA8, GX_REPEAT, GX_REPEAT, GX_FALSE);
|
||||
GX_InitTexObjFilterMode(&tex->obj, GX_NEAR, GX_NEAR);
|
||||
|
||||
ReorderPixels(tex->pixels, bmp, 0, 0, bmp->width);
|
||||
ReorderPixels(tex, bmp, 0, 0, bmp->width);
|
||||
DCFlushRange(tex->pixels, size);
|
||||
return tex;
|
||||
}
|
||||
@ -148,7 +152,7 @@ GfxResourceID Gfx_CreateTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipm
|
||||
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
|
||||
CCTexture* tex = (CCTexture*)texId;
|
||||
// TODO: wrong behaviour if x/y/part isn't multiple of 4 pixels
|
||||
//ReorderPixels(tex->pixels, part, x, y, rowWidth);
|
||||
ReorderPixels(tex, part, x, y, rowWidth);
|
||||
GX_InvalidateTexAll();
|
||||
}
|
||||
|
||||
@ -179,6 +183,8 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
||||
static GXColor gfx_clearColor = { 0, 0, 0, 255 };
|
||||
|
||||
void Gfx_SetFaceCulling(cc_bool enabled) {
|
||||
// NOTE: seems like ClassiCube's triangle ordering is opposite of what GX considers front facing
|
||||
GX_SetCullMode(enabled ? GX_CULL_FRONT : GX_CULL_NONE);
|
||||
}
|
||||
|
||||
void Gfx_SetAlphaBlending(cc_bool enabled) {
|
||||
@ -370,10 +376,16 @@ void Gfx_SetFogMode(FogFunc func) {
|
||||
|
||||
void Gfx_SetAlphaTest(cc_bool enabled) {
|
||||
if (enabled) {
|
||||
GX_SetAlphaCompare(GX_GREATER,127,GX_AOP_AND,GX_ALWAYS,0);
|
||||
GX_SetAlphaCompare(GX_GREATER, 127, GX_AOP_AND, GX_ALWAYS, 0);
|
||||
} else {
|
||||
GX_SetAlphaCompare(GX_ALWAYS,0,GX_AOP_AND,GX_ALWAYS,0);
|
||||
GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0);
|
||||
}
|
||||
|
||||
// See explanation from libGX headers
|
||||
// Normally, Z buffering should happen before texturing, as this enables better performance by not texturing pixels that are not visible;
|
||||
// however, when alpha compare is used, Z buffering must be done after texturing
|
||||
// Parameter[0] = Enables Z-buffering before texturing when set to GX_TRUE; otherwise, Z-buffering takes place after texturing.
|
||||
GX_SetZCompLoc(!enabled);
|
||||
}
|
||||
|
||||
void Gfx_DepthOnlyRendering(cc_bool depthOnly) {
|
||||
|
@ -416,7 +416,7 @@ cc_result Socket_Connect(cc_socket* s, const cc_string* address, int port, cc_bo
|
||||
*s = -1;
|
||||
if (!ParseAddress(&addr, address)) return ERR_INVALID_ARGUMENT;
|
||||
|
||||
*s = net_socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
*s = net_socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (*s < 0) return *s;
|
||||
|
||||
if (nonblocking) {
|
||||
@ -506,10 +506,10 @@ static void InitSockets(void) {
|
||||
#else
|
||||
// https://github.com/devkitPro/wii-examples/blob/master/devices/network/sockettest/source/sockettest.c
|
||||
char localip[16] = {0};
|
||||
char gateway[16] = {0};
|
||||
char netmask[16] = {0};
|
||||
char gateway[16] = {0};
|
||||
|
||||
int ret = if_config(localip, gateway, netmask, TRUE, 20);
|
||||
int ret = if_config(localip, netmask, gateway, TRUE, 20);
|
||||
if (ret >= 0) {
|
||||
Platform_Log3("Network ip: %c, gw: %c, mask %c", localip, gateway, netmask);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user