From 396276c465d55330e02ca72c89674a2ff78b1526 Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Sat, 26 Jun 2021 22:43:14 -0400 Subject: [PATCH 1/4] Fix video for GameCube --- GRRLIB/GRRLIB/GRRLIB_core.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_core.c b/GRRLIB/GRRLIB/GRRLIB_core.c index 99e7e44..0b9c246 100644 --- a/GRRLIB/GRRLIB/GRRLIB_core.c +++ b/GRRLIB/GRRLIB/GRRLIB_core.c @@ -66,7 +66,8 @@ int GRRLIB_Init (void) { VIDEO_SetBlack(true); // Disable video output during initialisation // Grab a pointer to the video mode attributes - if ( !(rmode = VIDEO_GetPreferredMode(NULL)) ) { + rmode = VIDEO_GetPreferredMode(NULL); + if (rmode == NULL) { return -1; } @@ -76,21 +77,24 @@ int GRRLIB_Init (void) { //rmode = &TVPal574IntDfScale; rmode = &TVPal528IntDf; // BC ...this is still wrong, but "less bad" for now break; + default: +#ifdef HW_DOL + if(VIDEO_HaveComponentCable()) { + rmode = &TVNtsc480Prog; + } +#endif + break; } #if defined(HW_RVL) // 16:9 and 4:3 Screen Adjustment for Wii if (CONF_GetAspectRatio() == CONF_ASPECT_16_9) { rmode->viWidth = 678; - rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 678) / 2; // This probably needs to consider PAL } else { // 4:3 rmode->viWidth = 672; - rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 672) / 2; } -#else - // GameCube - rmode->viWidth = 672; - rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - 672) / 2; + // This probably needs to consider PAL + rmode->viXOrigin = (VI_MAX_WIDTH_NTSC - rmode->viWidth) / 2; #endif #if defined(HW_RVL) From fb568a0e292d25c0db087dd0bd4baa8f8d657ee9 Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Sun, 27 Jun 2021 12:46:12 -0400 Subject: [PATCH 2/4] Installation folders for Wii and GameCube are different --- .github/workflows/ci.yml | 2 +- GRRLIB/GRRLIB/Makefile | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64a8afd..5e22620 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: run: | (cd GRRLIB && make clean all install) (cd examples && make) - (cd GRRLIB && make PLATFORM=cube clean all) + (cd GRRLIB && make PLATFORM=cube clean all install) - uses: actions/upload-artifact@master with: diff --git a/GRRLIB/GRRLIB/Makefile b/GRRLIB/GRRLIB/Makefile index bfb09a7..d06df4b 100644 --- a/GRRLIB/GRRLIB/Makefile +++ b/GRRLIB/GRRLIB/Makefile @@ -12,16 +12,23 @@ endif ifeq ($(PLATFORM),cube) include $(DEVKITPPC)/gamecube_rules + +MACHDEP += -DHW_DOL + +INSTALL_INC := $(DEVKITPRO)/portlibs/gamecube/include +INSTALL_LIB := $(DEVKITPRO)/portlibs/gamecube/lib else include $(DEVKITPPC)/wii_rules + +MACHDEP += -DHW_RVL + +INSTALL_INC := $(DEVKITPRO)/portlibs/wii/include +INSTALL_LIB := $(DEVKITPRO)/portlibs/wii/lib endif NULLSTR := PWD := $(subst $(NULLSTR) ,\ ,$(shell pwd)) -INSTALL_INC := $(DEVKITPRO)/portlibs/ppc/include -INSTALL_LIB := $(DEVKITPRO)/portlibs/ppc/lib - INCLUDE := -I../lib/pngu -I$(PWD) -I$(LIBOGC_INC) -I$(DEVKITPRO)/portlibs/ppc/include -I$(DEVKITPRO)/portlibs/ppc/include/freetype2 CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE) From 9ada5ddf1d4c1a74c9f4f2db4dc8360dd6fef6b3 Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Mon, 5 Jul 2021 00:33:45 -0400 Subject: [PATCH 3/4] Use base_rules to build libpngu --- .github/workflows/ci.yml | 2 +- GRRLIB/lib/pngu/Makefile | 9 +-- GRRLIB/lib/pngu/pngu.c | 136 +++++++++++++++++++-------------------- README.md | 11 +++- 4 files changed, 81 insertions(+), 77 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5e22620..265a257 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,7 +19,7 @@ jobs: run: | (cd GRRLIB && make clean all install) (cd examples && make) - (cd GRRLIB && make PLATFORM=cube clean all install) + (cd GRRLIB/GRRLIB && make PLATFORM=cube clean all install) - uses: actions/upload-artifact@master with: diff --git a/GRRLIB/lib/pngu/Makefile b/GRRLIB/lib/pngu/Makefile index d2a0d50..ef2370f 100644 --- a/GRRLIB/lib/pngu/Makefile +++ b/GRRLIB/lib/pngu/Makefile @@ -10,16 +10,13 @@ ifeq ($(strip $(DEVKITPRO)),) $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitPro) endif -ifeq ($(PLATFORM),cube) -include $(DEVKITPPC)/gamecube_rules -else -include $(DEVKITPPC)/wii_rules -endif +include $(DEVKITPPC)/base_rules +MACHDEP = -DGEKKO -mcpu=750 -meabi -mhard-float INSTALL_INC := $(DEVKITPRO)/portlibs/ppc/include INSTALL_LIB := $(DEVKITPRO)/portlibs/ppc/lib -INCLUDE := -I$(LIBOGC_INC) -I$(DEVKITPRO)/portlibs/ppc/include +INCLUDE := -I$(DEVKITPRO)/portlibs/ppc/include CFLAGS := -O2 -Wall $(MACHDEP) $(INCLUDE) LIB := pngu diff --git a/GRRLIB/lib/pngu/pngu.c b/GRRLIB/lib/pngu/pngu.c index 7a3535c..2b987a8 100644 --- a/GRRLIB/lib/pngu/pngu.c +++ b/GRRLIB/lib/pngu/pngu.c @@ -48,7 +48,7 @@ struct _IMGCTX png_structp png_ptr; png_infop info_ptr; FILE *fd; - + png_bytep *row_pointers; png_bytep img_data; }; @@ -165,7 +165,7 @@ int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff for (x = 0; x < (width / 2); x++) ((PNGU_u32 *)buffer)[y*buffWidth+x] = PNGU_RGB8_TO_YCbYCr (*(ctx->row_pointers[y]+x*6), *(ctx->row_pointers[y]+x*6+1), *(ctx->row_pointers[y]+x*6+2), *(ctx->row_pointers[y]+x*6+3), *(ctx->row_pointers[y]+x*6+4), *(ctx->row_pointers[y]+x*6+5)); - + // Free resources free (ctx->img_data); free (ctx->row_pointers); @@ -179,7 +179,7 @@ int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff { int result; PNGU_u32 x, y, buffWidth; - + result = pngu_decode (ctx, width, height, 1); if (result != PNGU_OK) return result; @@ -189,11 +189,11 @@ int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff // Copy image to the output buffer for (y = 0; y < height; y++) for (x = 0; x < width; x++) - ((PNGU_u16 *)buffer)[y*buffWidth+x] = - (((PNGU_u16) (ctx->row_pointers[y][x*3] & 0xF8)) << 8) | - (((PNGU_u16) (ctx->row_pointers[y][x*3+1] & 0xFC)) << 3) | + ((PNGU_u16 *)buffer)[y*buffWidth+x] = + (((PNGU_u16) (ctx->row_pointers[y][x*3] & 0xF8)) << 8) | + (((PNGU_u16) (ctx->row_pointers[y][x*3+1] & 0xFC)) << 3) | (((PNGU_u16) (ctx->row_pointers[y][x*3+2] & 0xF8)) >> 3); - + // Free resources free (ctx->img_data); free (ctx->row_pointers); @@ -207,7 +207,7 @@ int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe { int result; PNGU_u32 x, y, buffWidth; - + result = pngu_decode (ctx, width, height, 0); if (result != PNGU_OK) return result; @@ -226,13 +226,13 @@ int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe // No alpha channel present, copy image to the output buffer for (y = 0; y < height; y++) for (x = 0; x < width; x++) - ((PNGU_u32 *)buffer)[y*buffWidth+x] = - (((PNGU_u32) ctx->row_pointers[y][x*3]) << 24) | - (((PNGU_u32) ctx->row_pointers[y][x*3+1]) << 16) | - (((PNGU_u32) ctx->row_pointers[y][x*3+2]) << 8) | + ((PNGU_u32 *)buffer)[y*buffWidth+x] = + (((PNGU_u32) ctx->row_pointers[y][x*3]) << 24) | + (((PNGU_u32) ctx->row_pointers[y][x*3+1]) << 16) | + (((PNGU_u32) ctx->row_pointers[y][x*3+2]) << 8) | ((PNGU_u32) default_alpha); } - + // Free resources free (ctx->img_data); free (ctx->row_pointers); @@ -266,37 +266,37 @@ int PNGU_DecodeTo4x4RGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12)); PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase] = - (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | - (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | + ((PNGU_u64 *) buffer)[blockbase] = + (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | + (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+1] = - (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | - (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | + ((PNGU_u64 *) buffer)[blockbase+1] = + (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | + (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+2] = - (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | - (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | + ((PNGU_u64 *) buffer)[blockbase+2] = + (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | + (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+3] = - (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | - (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | + ((PNGU_u64 *) buffer)[blockbase+3] = + (((field64 & 0xF800000000000000ULL) | ((field64 & 0xFC000000000000ULL) << 3) | ((field64 & 0xF80000000000ULL) << 5)) | + (((field64 & 0xF800000000ULL) << 8) | ((field64 & 0xFC000000ULL) << 11) | ((field64 & 0xF80000ULL) << 13)) | (((field64 & 0xF800ULL) << 16) | ((field64 & 0xFCULL) << 19) | ((field32 & 0xF8000000ULL) >> 11)) | (((field32 & 0xF80000ULL) >> 8) | ((field32 & 0xFC00ULL) >> 5) | ((field32 & 0xF8ULL) >> 3))); } - + // Free resources free (ctx->img_data); free (ctx->row_pointers); @@ -337,7 +337,7 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b PNGU_u64 fieldA = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*16)); PNGU_u64 fieldB = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*16+8)); // If first pixel is opaque set MSB to 1 and encode colors in RGB555, else set MSB to 0 and encode colors in ARGB3444 - if ((fieldA & 0xE000000000ULL) == 0xE000000000ULL) + if ((fieldA & 0xE000000000ULL) == 0xE000000000ULL) tmp = 0x8000000000000000ULL | ((fieldA & 0xF800000000000000ULL) >> 1) | ((fieldA & 0xF8000000000000ULL) << 2) | ((fieldA & 0xF80000000000ULL) << 5); else tmp = ((fieldA & 0xE000000000ULL) << 23) | ((fieldA & 0xF000000000000000ULL) >> 4) | (fieldA & 0xF0000000000000ULL) | ((fieldA & 0xF00000000000ULL) << 4); @@ -471,34 +471,34 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12)); PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase] = + ((PNGU_u64 *) buffer)[blockbase] = alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | - ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | + ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+1] = + ((PNGU_u64 *) buffer)[blockbase+1] = alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | - ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | + ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+2] = + ((PNGU_u64 *) buffer)[blockbase+2] = alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | - ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | + ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+3] = + ((PNGU_u64 *) buffer)[blockbase+3] = alphaMask | ((field64 & 0xF800000000000000ULL) >> 1) | ((field64 & 0xF8000000000000ULL) << 2) | ((field64 & 0xF80000000000ULL) << 5) | ((field64 & 0xF800000000ULL) << 7) | ((field64 & 0xF8000000ULL) << 10) | - ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | + ((field64 & 0xF80000ULL) << 13) | ((field64 & 0xF800ULL) << 15) | ((field64 & 0xF8ULL) << 18) | ((field32 & 0xF8000000ULL) >> 11) | ((field32 & 0xF80000ULL) >> 9) | ((field32 & 0xF800ULL) >> 6) | ((field32 & 0xF8ULL) >> 3); } } @@ -516,39 +516,39 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b PNGU_u64 field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4]+x*12)); PNGU_u64 field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase] = - alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | - ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | - ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | + ((PNGU_u64 *) buffer)[blockbase] = + alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | + ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | + ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+1]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+1]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+1] = - alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | - ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | - ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | + ((PNGU_u64 *) buffer)[blockbase+1] = + alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | + ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | + ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+2]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+2]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+2] = - alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | - ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | - ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | + ((PNGU_u64 *) buffer)[blockbase+2] = + alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | + ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | + ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); field64 = *((PNGU_u64 *)(ctx->row_pointers[y*4+3]+x*12)); field32 = (PNGU_u64) *((PNGU_u32 *)(ctx->row_pointers[y*4+3]+x*12+8)); - ((PNGU_u64 *) buffer)[blockbase+3] = - alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | - ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | - ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | + ((PNGU_u64 *) buffer)[blockbase+3] = + alphaMask | ((field64 & 0xF000000000000000ULL) >> 4) | (field64 & 0xF0000000000000ULL) | ((field64 & 0xF00000000000ULL) << 4) | + ((field64 & 0xF000000000ULL) << 4) | ((field64 & 0xF0000000ULL) << 8) | ((field64 & 0xF00000ULL) << 12) | + ((field64 & 0xF000ULL) << 12) | ((field64 & 0xF0ULL) << 16) | ((field32 & 0xF0000000ULL) >> 12) | ((field32 & 0xF00000ULL) >> 12) | ((field32 & 0xF000ULL) >> 8) | ((field32 & 0xF0ULL) >> 4); } } } - + // Free resources free (ctx->img_data); free (ctx->row_pointers); @@ -633,7 +633,7 @@ PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, in y2 = ((y*yRatio)>>16); } - if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA || + if (ctx->prop.imgColorType == PNGU_COLOR_TYPE_GRAY_ALPHA || ctx->prop.imgColorType == PNGU_COLOR_TYPE_RGB_ALPHA) { if(xRatio > 0) @@ -682,7 +682,7 @@ int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe ctx->propRead = 0; // Check if the user has selected a file to write the image - if (ctx->source == PNGU_SOURCE_BUFFER); + if (ctx->source == PNGU_SOURCE_BUFFER); else if (ctx->source == PNGU_SOURCE_DEVICE) { @@ -725,17 +725,17 @@ int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe } // Setup output file properties - png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, + png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); // Allocate memory to store the image in RGB format rowbytes = width * 3; if (rowbytes % 4) rowbytes = ((rowbytes >>2) + 1) <<2; // Add extra padding so each row starts in a 4 byte boundary - + ctx->img_data = malloc(rowbytes * height); memset(ctx->img_data, 0, rowbytes * height); - + if (!ctx->img_data) { png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); @@ -746,7 +746,7 @@ int PNGU_EncodeFromRGB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffe ctx->row_pointers = malloc (sizeof (png_bytep) * height); memset(ctx->row_pointers, 0, sizeof (png_bytep) * height); - + if (!ctx->row_pointers) { png_destroy_write_struct (&(ctx->png_ptr), (png_infopp)NULL); @@ -790,7 +790,7 @@ int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void unsigned char * tmpbuffer = (unsigned char *)malloc(width*height*3); memset(tmpbuffer, 0, width*height*3); png_uint_32 offset; - + for(y=0; y < height; y++) { tmpy1 = y * 640*3; @@ -807,7 +807,7 @@ int PNGU_EncodeFromGXTexture (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void tmpbuffer[tmpxy+2] = ptr[offset+33]; // B } } - + res = PNGU_EncodeFromRGB (ctx, width, height, tmpbuffer, stride); free(tmpbuffer); return res; @@ -852,7 +852,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu ctx->propRead = 0; // Check if the user has selected a file to write the image - if (ctx->source == PNGU_SOURCE_BUFFER); + if (ctx->source == PNGU_SOURCE_BUFFER); else if (ctx->source == PNGU_SOURCE_DEVICE) { @@ -895,7 +895,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu } // Setup output file properties - png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, + png_set_IHDR (ctx->png_ptr, ctx->info_ptr, width, height, 8, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); // Allocate memory to store the image in RGB format @@ -928,7 +928,7 @@ int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *bu ctx->row_pointers[y] = ctx->img_data + (y * rowbytes); for (x = 0; x < (width / 2); x++) - PNGU_YCbYCr_TO_RGB8 ( ((PNGU_u32 *)buffer)[y*buffWidth+x], + PNGU_YCbYCr_TO_RGB8 ( ((PNGU_u32 *)buffer)[y*buffWidth+x], ((PNGU_u8 *) ctx->row_pointers[y]+x*6), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+1), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+2), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+3), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+4), ((PNGU_u8 *) ctx->row_pointers[y]+x*6+5) ); @@ -963,14 +963,14 @@ PNGU_u32 PNGU_RGB8_TO_YCbYCr (PNGU_u8 r1, PNGU_u8 g1, PNGU_u8 b1, PNGU_u8 r2, PN y1 = (299 * r1 + 587 * g1 + 114 * b1) / 1000; cb1 = (-16874 * r1 - 33126 * g1 + 50000 * b1 + 12800000) / 100000; cr1 = (50000 * r1 - 41869 * g1 - 8131 * b1 + 12800000) / 100000; - + y2 = (299 * r2 + 587 * g2 + 114 * b2) / 1000; cb2 = (-16874 * r2 - 33126 * g2 + 50000 * b2 + 12800000) / 100000; cr2 = (50000 * r2 - 41869 * g2 - 8131 * b2 + 12800000) / 100000; - + cb = (cb1 + cb2) >> 1; cr = (cr1 + cr2) >> 1; - + return (PNGU_u32) ((y1 << 24) | (cb << 16) | (y2 << 8) | cr); } @@ -1070,7 +1070,7 @@ int pngu_info (IMGCTX ctx) if (!ctx->propRead) { png_get_IHDR(ctx->png_ptr, ctx->info_ptr, &width, &height, - (int *) &(ctx->prop.imgBitDepth), + (int *) &(ctx->prop.imgBitDepth), (int *) &(ctx->prop.imgColorType), NULL, NULL, NULL); @@ -1148,7 +1148,7 @@ int pngu_info (IMGCTX ctx) ctx->prop.trans = malloc (sizeof (PNGUCOLOR) * ctx->prop.numTrans); if (ctx->prop.trans) for (i = 0; i < ctx->prop.numTrans; i++) - ctx->prop.trans[i].r = ctx->prop.trans[i].g = ctx->prop.trans[i].b = + ctx->prop.trans[i].r = ctx->prop.trans[i].g = ctx->prop.trans[i].b = trans_values[i].gray / scale; else ctx->prop.numTrans = 0; diff --git a/README.md b/README.md index 72ea767..c745047 100644 --- a/README.md +++ b/README.md @@ -102,20 +102,27 @@ libfreetype and libjpeg with there dependencies in a single command: Each library could also be installed individually: -To install libpngu +To install libpngu: ```bash c: cd \grr\GRRLIB\lib\pngu make clean all install ``` -To install libgrrlib: +To install libgrrlib for Wii: ```bash c: cd \grr\GRRLIB\GRRLIB make clean all install ``` +To install libgrrlib for GameCube: +```bash + c: + cd \grr\GRRLIB\GRRLIB + make PLATFORM=cube clean all install +``` + ## Using GRRLIB After everything is installed, simply put From e9ea2802ce542d55cffa684f3823a0c34c18d8d2 Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Mon, 5 Jul 2021 01:00:29 -0400 Subject: [PATCH 4/4] Fix compilation warning --- GRRLIB/lib/pngu/pngu.h | 13 ++++++------- examples/ttf/source/main.c | 1 + 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/GRRLIB/lib/pngu/pngu.h b/GRRLIB/lib/pngu/pngu.h index 24ab272..6070596 100644 --- a/GRRLIB/lib/pngu/pngu.h +++ b/GRRLIB/lib/pngu/pngu.h @@ -62,7 +62,7 @@ typedef struct // Image context, always initialize with SelectImageFrom* and free with ReleaseImageContext struct _IMGCTX; -typedef struct _IMGCTX *IMGCTX; +typedef struct _IMGCTX *IMGCTX; /**************************************************************************** @@ -110,7 +110,7 @@ int PNGU_GetImageProperties (IMGCTX ctx, PNGUPROP *fileproperties); * Image conversion * ****************************************************************************/ -// Expands selected image into an YCbYCr buffer. You need to specify context, image dimensions, +// Expands selected image into an YCbYCr buffer. You need to specify context, image dimensions, // destination address and stride in pixels (stride = buffer width - image width). int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); @@ -120,7 +120,7 @@ int PNGU_DecodeToYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff PNGU_DecodeToYCbYCr (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \ (coordX) * 2, (bufferWidth) - (imgWidth)) -// Expands selected image into a linear RGB565 buffer. You need to specify context, image dimensions, +// Expands selected image into a linear RGB565 buffer. You need to specify context, image dimensions, // destination address and stride in pixels (stride = buffer width - image width). int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); @@ -130,8 +130,8 @@ int PNGU_DecodeToRGB565 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buff PNGU_DecodeToRGB565 (ctx, imgWidth, imgHeight, ((void *) buffer) + (coordY) * (bufferWidth) * 2 + \ (coordX) * 2, (bufferWidth) - (imgWidth)) -// Expands selected image into a linear RGBA8 buffer. You need to specify context, image dimensions, -// destination address, stride in pixels and default alpha value, which is used if the source image +// Expands selected image into a linear RGBA8 buffer. You need to specify context, image dimensions, +// destination address, stride in pixels and default alpha value, which is used if the source image // doesn't have an alpha channel. int PNGU_DecodeToRGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride, PNGU_u8 default_alpha); @@ -153,7 +153,7 @@ int PNGU_DecodeTo4x4RGB5A3 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *b // destination address. PNGU_u8 * PNGU_DecodeTo4x4RGBA8 (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, int * dstWidth, int * dstHeight, PNGU_u8 *dstPtr); -// Encodes an YCbYCr image in PNG format and stores it in the selected device or memory buffer. You need to +// Encodes an YCbYCr image in PNG format and stores it in the selected device or memory buffer. You need to // specify context, image dimensions, destination address and stride in pixels (stride = buffer width - image width). int PNGU_EncodeFromYCbYCr (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, void *buffer, PNGU_u32 stride); @@ -172,4 +172,3 @@ int PNGU_EncodeFromEFB (IMGCTX ctx, PNGU_u32 width, PNGU_u32 height, PNGU_u32 st #endif #endif - diff --git a/examples/ttf/source/main.c b/examples/ttf/source/main.c index 5a70b63..0a7f7d6 100644 --- a/examples/ttf/source/main.c +++ b/examples/ttf/source/main.c @@ -4,6 +4,7 @@ #include #include +#include #include #include // Needed for gettime and ticks_to_millisecs