From 7813578631e3d55b961b94ba2915c2ec1cf1ba08 Mon Sep 17 00:00:00 2001 From: lif <> Date: Tue, 12 Dec 2023 22:47:11 -0800 Subject: [PATCH] n64 pixel format --- Makefile | 4 ++-- common.h | 3 +++ mips/mips_emit.h | 6 ++++++ mips/mips_stub.S | 2 +- video.cc | 2 +- 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 56e9eaa..132f81c 100644 --- a/Makefile +++ b/Makefile @@ -441,9 +441,9 @@ else ifeq ($(platform), n64) CXX = $(N64_INST)/bin/mips64-elf-g++$(EXE_EXT) AR = $(N64_INST)/bin/mips64-elf-ar$(EXE_EXT) CFLAGS += -fomit-frame-pointer -ffast-math - CFLAGS += -DNINTENDO64 -DUSE_XBGR1555_FORMAT -DSMALL_TRANSLATION_CACHE -DROM_BUFFER_SIZE=4 + CFLAGS += -DNINTENDO64 -DUSE_RGBA5551_FORMAT -DSMALL_TRANSLATION_CACHE -DROM_BUFFER_SIZE=4 CFLAGS += -I$(N64_INST)/include/ - HAVE_DYNAREC = 1 + HAVE_DYNAREC = 0 CPU_ARCH := mips STATIC_LINKING = 1 FRONTEND_SUPPORTS_RGB565 = 0 diff --git a/common.h b/common.h index 3302522..9627c71 100644 --- a/common.h +++ b/common.h @@ -81,6 +81,9 @@ #if defined(USE_XBGR1555_FORMAT) #define convert_palette(value) \ (value & 0x7FFF) +#elif defined(USE_RGBA5551_FORMAT) + #define convert_palette(value) \ + (((value & 0x1F) << 11) | ((value & 0x03E0) << 1) | ((value & 0x7C00) >> 9) | 1) #else #define convert_palette(value) \ (((value & 0x1F) << 11) | ((value & 0x03E0) << 1) | ((value >> 10) & 0x1F)) diff --git a/mips/mips_emit.h b/mips/mips_emit.h index 2500aed..b36d637 100644 --- a/mips/mips_emit.h +++ b/mips/mips_emit.h @@ -2364,6 +2364,12 @@ static void emit_pmemst_stub( /* PS2's native format */ #define palette_convert() \ mips_emit_andi(reg_temp, reg_a1, 0x7FFF); +#elif defined(USE_RGBA5551_FORMAT) + /* N64's native format */ + //#error "TODO" + #define palette_convert() \ + mips_emit_sll(reg_temp, reg_a1, 1); \ + mips_emit_ori(reg_temp, reg_temp, 1); #else /* 0BGR to RGB565 (clobbers a0) */ #ifdef MIPS_HAS_R2_INSTS diff --git a/mips/mips_stub.S b/mips/mips_stub.S index 72974c8..f623ac3 100644 --- a/mips/mips_stub.S +++ b/mips/mips_stub.S @@ -615,7 +615,7 @@ fnptrs: # Make this section executable! .text -#if defined(PSP) || defined(PS2) +#if defined(PSP) || defined(PS2) || defined(NINTENDO64) .section .bss #else # Need to mark the section as awx (for Linux) diff --git a/video.cc b/video.cc index a233fcb..e6f31b0 100644 --- a/video.cc +++ b/video.cc @@ -1655,7 +1655,7 @@ static void order_layers(u32 layer_flags, u32 vcnt) #define BLND_MSK (SATR_MSK | SATG_MSK | SATB_MSK) -#ifdef USE_XBGR1555_FORMAT +#if defined(USE_XBGR1555_FORMAT) || defined(USE_RGBA5551_FORMAT) #define OVFG_MSK 0x04000000 #define OVFR_MSK 0x00008000 #define OVFB_MSK 0x00000020