mirror of
https://github.com/aap/librw.git
synced 2024-11-29 07:05:42 +00:00
texture mapping in ps2 test
This commit is contained in:
parent
df419c63ef
commit
c6589f55de
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#include "rw.h"
|
#include "rw.h"
|
||||||
@ -34,8 +33,6 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
rw::Clump *c;
|
rw::Clump *c;
|
||||||
|
|
||||||
// ifstream in(argv[1], ios::binary);
|
|
||||||
|
|
||||||
// rw::StreamFile in;
|
// rw::StreamFile in;
|
||||||
// in.open(argv[1], "rb");
|
// in.open(argv[1], "rb");
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
@ -347,7 +346,7 @@ static int32
|
|||||||
getSizeEnvMat(void *object, int32 offset, int32)
|
getSizeEnvMat(void *object, int32 offset, int32)
|
||||||
{
|
{
|
||||||
EnvMat *env = *PLUGINOFFSET(EnvMat*, object, offset);
|
EnvMat *env = *PLUGINOFFSET(EnvMat*, object, offset);
|
||||||
return env ? sizeof(EnvStream) : -1;
|
return env ? (int)sizeof(EnvStream) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specular mat
|
// Specular mat
|
||||||
@ -417,7 +416,7 @@ static int32
|
|||||||
getSizeSpecMat(void *object, int32 offset, int32)
|
getSizeSpecMat(void *object, int32 offset, int32)
|
||||||
{
|
{
|
||||||
SpecMat *spec = *PLUGINOFFSET(SpecMat*, object, offset);
|
SpecMat *spec = *PLUGINOFFSET(SpecMat*, object, offset);
|
||||||
return spec ? sizeof(SpecStream) : -1;
|
return spec ? (int)sizeof(SpecStream) : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
@ -10,12 +9,6 @@
|
|||||||
#include "rwplugin.h"
|
#include "rwplugin.h"
|
||||||
#include "rwobjects.h"
|
#include "rwobjects.h"
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
#define PACKED_STRUCT __attribute__((__packed__))
|
|
||||||
#else
|
|
||||||
#define PACKED_STRUCT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
@ -291,6 +284,9 @@ Image::getFilename(const char *name)
|
|||||||
#ifndef RW_PS2
|
#ifndef RW_PS2
|
||||||
#pragma pack(push)
|
#pragma pack(push)
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
#define PACKED_STRUCT
|
||||||
|
#else
|
||||||
|
#define PACKED_STRUCT __attribute__((__packed__))
|
||||||
#endif
|
#endif
|
||||||
struct PACKED_STRUCT TGAHeader
|
struct PACKED_STRUCT TGAHeader
|
||||||
{
|
{
|
||||||
@ -319,9 +315,12 @@ readTGA(const char *afilename)
|
|||||||
filename = Image::getFilename(afilename);
|
filename = Image::getFilename(afilename);
|
||||||
if(filename == NULL)
|
if(filename == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
StreamFile file;
|
uint32 length;
|
||||||
assert(file.open(filename, "rb") != NULL);
|
uint8 *data = getFileContents(filename, &length);
|
||||||
|
assert(data != NULL);
|
||||||
free(filename);
|
free(filename);
|
||||||
|
StreamMemory file;
|
||||||
|
file.open(data, length);
|
||||||
file.read(&header, sizeof(header));
|
file.read(&header, sizeof(header));
|
||||||
|
|
||||||
assert(header.imageType == 1 || header.imageType == 2);
|
assert(header.imageType == 1 || header.imageType == 2);
|
||||||
@ -380,6 +379,7 @@ readTGA(const char *afilename)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
delete[] data;
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
@ -311,4 +310,18 @@ found:
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8*
|
||||||
|
getFileContents(char *name, uint32 *len)
|
||||||
|
{
|
||||||
|
FILE *cf = fopen(name, "rb");
|
||||||
|
assert(cf != NULL);
|
||||||
|
fseek(cf, 0, SEEK_END);
|
||||||
|
*len = ftell(cf);
|
||||||
|
fseek(cf, 0, SEEK_SET);
|
||||||
|
uint8 *data = new uint8[*len];
|
||||||
|
fread(data, *len, 1, cf);
|
||||||
|
fclose(cf);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
17
src/rwbase.h
17
src/rwbase.h
@ -1,5 +1,20 @@
|
|||||||
|
#ifndef RW_PS2
|
||||||
|
#include <stdint.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace rw {
|
namespace rw {
|
||||||
|
|
||||||
|
#ifdef RW_PS2
|
||||||
|
typedef char int8;
|
||||||
|
typedef short int16;
|
||||||
|
typedef int int32;
|
||||||
|
typedef long long int64;
|
||||||
|
typedef unsigned char uint8;
|
||||||
|
typedef unsigned short uint16;
|
||||||
|
typedef unsigned int uint32;
|
||||||
|
typedef unsigned long long uint64;
|
||||||
|
typedef unsigned int uintptr;
|
||||||
|
#else
|
||||||
/* get rid of the stupid _t */
|
/* get rid of the stupid _t */
|
||||||
typedef int8_t int8;
|
typedef int8_t int8;
|
||||||
typedef int16_t int16;
|
typedef int16_t int16;
|
||||||
@ -10,6 +25,7 @@ typedef uint16_t uint16;
|
|||||||
typedef uint32_t uint32;
|
typedef uint32_t uint32;
|
||||||
typedef uint64_t uint64;
|
typedef uint64_t uint64;
|
||||||
typedef uintptr_t uintptr;
|
typedef uintptr_t uintptr;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef float float32;
|
typedef float float32;
|
||||||
typedef int32 bool32;
|
typedef int32 bool32;
|
||||||
@ -165,4 +181,5 @@ bool readChunkHeaderInfo(Stream *s, ChunkHeaderInfo *header);
|
|||||||
bool findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
|
bool findChunk(Stream *s, uint32 type, uint32 *length, uint32 *version);
|
||||||
|
|
||||||
int32 findPointer(void *p, void **list, int32 num);
|
int32 findPointer(void *p, void **list, int32 num);
|
||||||
|
uint8 *getFileContents(char *name, uint32 *len);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ LIBPATH=-L$(PS2SDK)/ee/lib
|
|||||||
INCPATH=-I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I../..
|
INCPATH=-I$(PS2SDK)/ee/include -I$(PS2SDK)/common/include -I../..
|
||||||
LIBS=../../librw-ps2.a -lc -lc -lkernel -lmf # g++ throws one -lc away, why? (unless -nostdlib)
|
LIBS=../../librw-ps2.a -lc -lc -lkernel -lmf # g++ throws one -lc away, why? (unless -nostdlib)
|
||||||
|
|
||||||
CFLAGS = -c -Wall -nostdlib -fno-common -DPS2_EE $(INCPATH)
|
CFLAGS = -c -Wall -nostdlib -fno-common -DRW_PS2 -DPS2_EE $(INCPATH)
|
||||||
ASFLAGS = -c -xassembler-with-cpp
|
ASFLAGS = -c -xassembler-with-cpp
|
||||||
LDFLAGS = -mno-crt0 $(LIBPATH)
|
LDFLAGS = -mno-crt0 $(LIBPATH)
|
||||||
OUT=test
|
OUT=test
|
||||||
@ -19,7 +19,7 @@ C_SRC=main.cpp gs.cpp dma.cpp math.cpp
|
|||||||
HEADER=dma.h ee_regs.h gif.h gs.h mips_regs.h ps2.h math.h mesh.h
|
HEADER=dma.h ee_regs.h gif.h gs.h mips_regs.h ps2.h math.h mesh.h
|
||||||
OBJ=$(C_SRC:.cpp=.o) $(S_SRC:.s=.o) vu.o defaultpipe.o skinpipe.o
|
OBJ=$(C_SRC:.cpp=.o) $(S_SRC:.s=.o) vu.o defaultpipe.o skinpipe.o
|
||||||
|
|
||||||
$(OUT).elf: $(OBJ) $(HEADER)
|
$(OUT).elf: $(OBJ) ../../librw-ps2.a $(HEADER)
|
||||||
$(LD) $(LDFLAGS) $(LINK) $(PS2SDK)/ee/startup/crt0.o \
|
$(LD) $(LDFLAGS) $(LINK) $(PS2SDK)/ee/startup/crt0.o \
|
||||||
$(OBJ) $(LIBS) -o $(OUT).elf
|
$(OBJ) $(LIBS) -o $(OUT).elf
|
||||||
|
|
||||||
|
@ -47,35 +47,36 @@ Cnt:
|
|||||||
|
|
||||||
Loop:
|
Loop:
|
||||||
NOP LQI VF01, (VI02++) ; vertex
|
NOP LQI VF01, (VI02++) ; vertex
|
||||||
NOP LQI VF02, (VI02++) ; UV - ignore
|
NOP LQI VF02, (VI02++) ; UV
|
||||||
NOP LQI VF02, (VI02++) ; color
|
NOP LQI VF03, (VI02++) ; color
|
||||||
NOP LQI VF03, (VI02++) ; normal
|
NOP LQI VF04, (VI02++) ; normal
|
||||||
|
|
||||||
MULAw.xyzw ACC, VF31, VF00w NOP ; transform vertex
|
MULAw.xyzw ACC, VF31, VF00w NOP ; transform vertex
|
||||||
MADDAx.xyzw ACC, VF28, VF01x NOP
|
MADDAx.xyzw ACC, VF28, VF01x NOP
|
||||||
MADDAy.xyzw ACC, VF29, VF01y NOP
|
MADDAy.xyzw ACC, VF29, VF01y NOP
|
||||||
MADDz.xyzw VF01, VF30, VF01z NOP
|
MADDz.xyzw VF01, VF30, VF01z NOP
|
||||||
ITOF0 VF02, VF02 NOP
|
ITOF0 VF03, VF03 NOP
|
||||||
ITOF0[I] VF03, VF03 LOI 0.0078125 ; - normal scale
|
ITOF0[I] VF04, VF04 LOI 0.0078125 ; - normal scale
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP DIV Q, VF00w, VF01w
|
NOP DIV Q, VF00w, VF01w
|
||||||
NOP WAITQ
|
NOP WAITQ
|
||||||
MULq VF01, VF01, Q NOP ; perspective division
|
MULq VF01, VF01, Q NOP ; perspective division
|
||||||
MULi VF03, VF03, I NOP ; scale normal
|
MULi VF04, VF04, I NOP ; scale normal
|
||||||
NOP NOP
|
NOP MR32.z VF02, VF00
|
||||||
NOP NOP
|
NOP NOP
|
||||||
SUB.w VF01, VF01, VF01 NOP
|
SUB.w VF01, VF01, VF01 NOP
|
||||||
MULAx.xyz ACC, VF18, VF03x NOP ; transform normal
|
MULAx.xyz ACC, VF18, VF04x NOP ; transform normal
|
||||||
MADDAy.xyz ACC, VF19, VF03y NOP
|
MADDAy.xyz ACC, VF19, VF04y NOP
|
||||||
MADDz.xyz VF03, VF20, VF03z NOP
|
MADDz.xyz VF04, VF20, VF04z NOP
|
||||||
ADD.xy VF01, VF01, VF25 NOP
|
ADD.xy VF01, VF01, VF25 NOP
|
||||||
|
MULq VF02, VF02, Q NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
FTOI0 VF03, VF03 NOP
|
||||||
FTOI0 VF02, VF02 NOP
|
|
||||||
FTOI4 VF01, VF01 NOP
|
FTOI4 VF01, VF01 NOP
|
||||||
NOP SQ VF03, -1(VI02) ; store normal
|
NOP SQ VF04, -1(VI02) ; store normal
|
||||||
NOP IADDI VI01, VI01, -1
|
NOP IADDI VI01, VI01, -1
|
||||||
NOP SQI VF02, (VI03++) ; color
|
NOP SQI VF02, (VI03++) ; STQ
|
||||||
|
NOP SQI VF03, (VI03++) ; color
|
||||||
NOP SQI VF01, (VI03++) ; vertex
|
NOP SQI VF01, (VI03++) ; vertex
|
||||||
NOP IBNE VI01, VI00, Loop
|
NOP IBNE VI01, VI00, Loop
|
||||||
NOP NOP
|
NOP NOP
|
||||||
|
@ -200,7 +200,7 @@ void drawrect(uint16 x1, uint16 y1, uint16 x2, uint16 y2, uint32 col);
|
|||||||
BIT64(CPSM, 51) | \
|
BIT64(CPSM, 51) | \
|
||||||
BIT64(CSM, 55) | \
|
BIT64(CSM, 55) | \
|
||||||
BIT64(CSA, 56) | \
|
BIT64(CSA, 56) | \
|
||||||
BIT64(CSD, 61))
|
BIT64(CLD, 61))
|
||||||
|
|
||||||
#define MAKE_GS_CLAMP(WMS,WMT,MINU,MAXU,MINV,MAXV) \
|
#define MAKE_GS_CLAMP(WMS,WMT,MINU,MAXU,MINV,MAXV) \
|
||||||
(BIT64(WMS, 0) | \
|
(BIT64(WMS, 0) | \
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
; Ambient light:
|
; Ambient light:
|
||||||
NOP LQ VF26, ambientLight(VI00)
|
NOP LQ VF26, ambientLight(VI00)
|
||||||
NOP XITOP VI01
|
NOP XITOP VI01
|
||||||
NOP IADDIU VI03, VI12, 1
|
NOP IADDIU VI03, VI12, 2
|
||||||
Ambloop:
|
Ambloop:
|
||||||
NOP LQ VF03, 0(VI03) ; output color
|
NOP LQ VF03, 0(VI03) ; output color
|
||||||
NOP NOP
|
NOP NOP
|
||||||
@ -17,16 +17,16 @@ Ambloop:
|
|||||||
NOP NOP
|
NOP NOP
|
||||||
FTOI0 VF03, VF03 NOP
|
FTOI0 VF03, VF03 NOP
|
||||||
NOP IADDI VI01, VI01, -1
|
NOP IADDI VI01, VI01, -1
|
||||||
NOP IADDIU VI03, VI03, 2 ; numOutAttribs
|
NOP IADDIU VI03, VI03, numOutAttribs
|
||||||
NOP IBNE VI01, VI00, Ambloop
|
NOP IBNE VI01, VI00, Ambloop
|
||||||
NOP SQ VF03, -2(VI03) ; numOutAttribs
|
NOP SQ VF03, -numOutAttribs(VI03)
|
||||||
; end amblight
|
; end amblight
|
||||||
|
|
||||||
; Direct Light
|
; Direct Light
|
||||||
NOP LQ VF26, lightDir(VI00)
|
NOP LQ VF26, lightDir(VI00)
|
||||||
NOP XITOP VI01
|
NOP XITOP VI01
|
||||||
NOP XTOP VI02
|
NOP XTOP VI02
|
||||||
NOP IADDIU VI03, VI12, 1
|
NOP IADDIU VI03, VI12, 2
|
||||||
SUB.xyz VF26, VF00, VF26 NOP
|
SUB.xyz VF26, VF00, VF26 NOP
|
||||||
Dirloop:
|
Dirloop:
|
||||||
NOP LQ VF01, 3(VI02); ; normal
|
NOP LQ VF01, 3(VI02); ; normal
|
||||||
@ -60,15 +60,15 @@ Dirloop:
|
|||||||
FTOI0 VF02, VF02 NOP
|
FTOI0 VF02, VF02 NOP
|
||||||
NOP IADDI VI01, VI01, -1
|
NOP IADDI VI01, VI01, -1
|
||||||
NOP IADDIU VI02, VI02, numInAttribs
|
NOP IADDIU VI02, VI02, numInAttribs
|
||||||
NOP IADDIU VI03, VI03, 2 ; numOutAttribs
|
NOP IADDIU VI03, VI03, numOutAttribs
|
||||||
NOP IBNE VI01, VI00, Dirloop
|
NOP IBNE VI01, VI00, Dirloop
|
||||||
NOP SQ VF02, -2(VI03) ; numOutAttribs
|
NOP SQ VF02, -numOutAttribs(VI03)
|
||||||
; end dirlight
|
; end dirlight
|
||||||
|
|
||||||
; Material color and clamp
|
; Material color and clamp
|
||||||
NOP LQ VF27, matColor(VI00)
|
NOP LQ VF27, matColor(VI00)
|
||||||
NOP XITOP VI01
|
NOP XITOP VI01
|
||||||
NOP IADDIU VI03, VI12, 1
|
NOP IADDIU VI03, VI12, 2
|
||||||
Colorloop:
|
Colorloop:
|
||||||
NOP LQ VF03, 0(VI03)
|
NOP LQ VF03, 0(VI03)
|
||||||
NOP NOP
|
NOP NOP
|
||||||
@ -88,7 +88,7 @@ Colorloop:
|
|||||||
NOP NOP
|
NOP NOP
|
||||||
FTOI0 VF03, VF03 NOP
|
FTOI0 VF03, VF03 NOP
|
||||||
NOP IADDI VI01, VI01, -1
|
NOP IADDI VI01, VI01, -1
|
||||||
NOP IADDIU VI03, VI03, 2 ; numOutAttribs
|
NOP IADDIU VI03, VI03, numOutAttribs
|
||||||
NOP IBNE VI01, VI00, Colorloop
|
NOP IBNE VI01, VI00, Colorloop
|
||||||
NOP SQ VF03, -2(VI03) ; numOutAttribs
|
NOP SQ VF03, -numOutAttribs(VI03)
|
||||||
; end material color
|
; end material color
|
||||||
|
@ -48,19 +48,23 @@ drawAtomic(rw::Atomic *atomic)
|
|||||||
matCopy(vuLightMat, atomic->frame->ltm);
|
matCopy(vuLightMat, atomic->frame->ltm);
|
||||||
matMult(vuMat, atomic->frame->ltm);
|
matMult(vuMat, atomic->frame->ltm);
|
||||||
rw::Skin *skin = *PLUGINOFFSET(rw::Skin*, geo, rw::skinGlobals.offset);
|
rw::Skin *skin = *PLUGINOFFSET(rw::Skin*, geo, rw::skinGlobals.offset);
|
||||||
for(int i = 0; i < instData->numMeshes; i++){
|
for(uint i = 0; i < instData->numMeshes; i++){
|
||||||
if(instData->instanceMeshes[i].arePointersFixed == 0)
|
if(instData->instanceMeshes[i].arePointersFixed == 0)
|
||||||
rw::ps2::fixDmaOffsets(&instData->instanceMeshes[i]);
|
rw::ps2::fixDmaOffsets(&instData->instanceMeshes[i]);
|
||||||
geometryCall[1] = (uint32)instData->instanceMeshes[i].data;
|
geometryCall[1] = (uint32)instData->instanceMeshes[i].data;
|
||||||
mesh = &meshHeader->mesh[i];
|
mesh = &meshHeader->mesh[i];
|
||||||
color = mesh->material->color;
|
color = mesh->material->color;
|
||||||
|
|
||||||
vuGIFtag[0] = MAKE_GIF_TAG(0,1,1,0xC,0,2);
|
vuGIFtag[0] = MAKE_GIF_TAG(0,1,1,0xC|0x10,0,3);
|
||||||
vuGIFtag[1] = 0x41;
|
vuGIFtag[1] = 0x412;
|
||||||
vuMatcolor[0] = color[0]/255.0f;
|
vuMatcolor[0] = color[0]/255.0f;
|
||||||
vuMatcolor[1] = color[1]/255.0f;
|
vuMatcolor[1] = color[1]/255.0f;
|
||||||
vuMatcolor[2] = color[2]/255.0f;
|
vuMatcolor[2] = color[2]/255.0f;
|
||||||
vuMatcolor[3] = color[3]/2.0f/255.0f;
|
vuMatcolor[3] = color[3]/2.0f/255.0f;
|
||||||
|
// only when modulating textures actually
|
||||||
|
vuMatcolor[0] /= 2.0f;
|
||||||
|
vuMatcolor[1] /= 2.0f;
|
||||||
|
vuMatcolor[2] /= 2.0f;
|
||||||
if(rw::skinGlobals.offset && skin){
|
if(rw::skinGlobals.offset && skin){
|
||||||
geometryCall[3] = 0x020000DC;
|
geometryCall[3] = 0x020000DC;
|
||||||
mpgCall[1] = (uint32)skinPipe;
|
mpgCall[1] = (uint32)skinPipe;
|
||||||
@ -112,6 +116,60 @@ draw(void)
|
|||||||
rot -= 2*M_PI;
|
rot -= 2*M_PI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GIF_DECLARE_PACKET(gifDmaBuf2, 256)
|
||||||
|
|
||||||
|
uint32
|
||||||
|
uploadTGA(rw::Image *tga)
|
||||||
|
{
|
||||||
|
GsState *g = gsCurState;
|
||||||
|
uint32 destAddr = g->currentMemPtr;
|
||||||
|
uint32 size = tga->width*tga->height*4;
|
||||||
|
g->currentMemPtr += size;
|
||||||
|
|
||||||
|
printf("image @ %x\n", destAddr);
|
||||||
|
|
||||||
|
GIF_BEGIN_PACKET(gifDmaBuf2);
|
||||||
|
GIF_TAG(gifDmaBuf2, 4, 1, 0, 0, 0, 1, 0x0e);
|
||||||
|
GIF_DATA_AD(gifDmaBuf2, GS_BITBLTBUF,
|
||||||
|
MAKE_GS_BITBLTBUF(0, 0, 0,
|
||||||
|
destAddr/4/64, tga->width/64, PSMCT32));
|
||||||
|
GIF_DATA_AD(gifDmaBuf2, GS_TRXPOS,
|
||||||
|
MAKE_GS_TRXPOS(0, 0, 0, 0, 0));
|
||||||
|
GIF_DATA_AD(gifDmaBuf2, GS_TRXREG,
|
||||||
|
MAKE_GS_TRXREG(tga->width, tga->height));
|
||||||
|
GIF_DATA_AD(gifDmaBuf2, GS_TRXDIR, 0);
|
||||||
|
GIF_SEND_PACKET(gifDmaBuf2);
|
||||||
|
|
||||||
|
GIF_BEGIN_PACKET(gifDmaBuf2);
|
||||||
|
GIF_TAG(gifDmaBuf2, size/0x10, 1, 0, 0, 2, 0, 0);
|
||||||
|
GIF_SEND_PACKET(gifDmaBuf2);
|
||||||
|
|
||||||
|
FlushCache(0);
|
||||||
|
SET_REG32(D2_QWC, MAKE_DN_QWC(size/0x10));
|
||||||
|
SET_REG32(D2_MADR, MAKE_DN_MADR(tga->pixels, 0));
|
||||||
|
SET_REG32(D2_CHCR, MAKE_DN_CHCR(1, 0, 0, 0, 0, 1));
|
||||||
|
DMA_WAIT(D2_CHCR);
|
||||||
|
|
||||||
|
int logw = 0, logh = 0;
|
||||||
|
int s;
|
||||||
|
for(s = 1; s < tga->width; s *= 2)
|
||||||
|
logw++;
|
||||||
|
for(s = 1; s < tga->height; s *= 2)
|
||||||
|
logh++;
|
||||||
|
|
||||||
|
GIF_BEGIN_PACKET(gifDmaBuf2);
|
||||||
|
GIF_TAG(gifDmaBuf2, 3, 1, 0, 0, 0, 1, 0x0e);
|
||||||
|
GIF_DATA_AD(gifDmaBuf2, GS_TEXFLUSH, 1);
|
||||||
|
GIF_DATA_AD(gifDmaBuf2, GS_TEX0_1,
|
||||||
|
MAKE_GS_TEX0(destAddr/4/64, tga->width/64, PSMCT32,
|
||||||
|
logw, logh, 0, 0, 0, 0, 0, 0, 0));
|
||||||
|
GIF_DATA_AD(gifDmaBuf2, GS_TEX1_1,
|
||||||
|
MAKE_GS_TEX1(0, 0, 1, 1, 0, 0, 0));
|
||||||
|
GIF_SEND_PACKET(gifDmaBuf2);
|
||||||
|
|
||||||
|
return destAddr;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
@ -141,29 +199,15 @@ main()
|
|||||||
// rw::ps2::registerNativeDataPlugin();
|
// rw::ps2::registerNativeDataPlugin();
|
||||||
rw::registerMeshPlugin();
|
rw::registerMeshPlugin();
|
||||||
|
|
||||||
// rw::StreamFile in;
|
rw::uint32 len;
|
||||||
// in.open("host:player-vc-ps2.dff", "rb");
|
rw::uint8 *data = rw::getFileContents("host:player-vc-ps2.dff", &len);
|
||||||
|
// rw::uint8 *data = rw::getFileContents("host:od_newscafe_dy-ps2.dff", &len);
|
||||||
FILE *cf = fopen("host:player-vc-ps2.dff", "rb");
|
// rw::uint8 *data = rw::getFileContents("host:admiral-ps2.dff", &len);
|
||||||
// FILE *cf = fopen("host:od_newscafe_dy-ps2.dff", "rb");
|
|
||||||
// FILE *cf = fopen("host:admiral-ps2.dff", "rb");
|
|
||||||
assert(cf != NULL);
|
|
||||||
fseek(cf, 0, SEEK_END);
|
|
||||||
rw::uint32 len = ftell(cf);
|
|
||||||
fseek(cf, 0, SEEK_SET);
|
|
||||||
rw::uint8 *data = new rw::uint8[len];
|
|
||||||
fread(data, len, 1, cf);
|
|
||||||
fclose(cf);
|
|
||||||
rw::StreamMemory in;
|
rw::StreamMemory in;
|
||||||
in.open(data, len);
|
in.open(data, len);
|
||||||
|
|
||||||
printf("opened file\n");
|
|
||||||
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
|
rw::findChunk(&in, rw::ID_CLUMP, NULL, NULL);
|
||||||
printf("found chunk\n");
|
|
||||||
clump = rw::Clump::streamRead(&in);
|
clump = rw::Clump::streamRead(&in);
|
||||||
printf("read file\n");
|
|
||||||
in.close();
|
in.close();
|
||||||
printf("closed file\n");
|
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
||||||
data = new rw::uint8[256*1024];
|
data = new rw::uint8[256*1024];
|
||||||
@ -177,12 +221,15 @@ main()
|
|||||||
out.close();
|
out.close();
|
||||||
delete[] data;
|
delete[] data;
|
||||||
|
|
||||||
// rw::StreamFile out;
|
rw::Image *tga = rw::readTGA("host:player_.tga");
|
||||||
// out.open("host:out-ps2.dff", "wb");
|
printf("read tga\n");
|
||||||
// c->streamWrite(&out);
|
|
||||||
// out.close();
|
uint32 destAddr = uploadTGA(tga);
|
||||||
//
|
/*
|
||||||
// printf("wrote file\n");
|
rw::writeTGA(tga, "host:out.tga");
|
||||||
|
printf("wrote tga\n");
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
vuOffset[0] = 2048.0f;
|
vuOffset[0] = 2048.0f;
|
||||||
vuOffset[1] = 2048.0f;
|
vuOffset[1] = 2048.0f;
|
||||||
|
@ -47,36 +47,37 @@ Cnt:
|
|||||||
|
|
||||||
Loop:
|
Loop:
|
||||||
NOP LQI VF01, (VI02++) ; vertex
|
NOP LQI VF01, (VI02++) ; vertex
|
||||||
NOP LQI VF02, (VI02++) ; UV - skip
|
NOP LQI VF02, (VI02++) ; UV
|
||||||
NOP LQI VF02, (VI02++) ; color
|
NOP LQI VF03, (VI02++) ; color
|
||||||
NOP LQI VF03, (VI02++) ; normal
|
NOP LQI VF04, (VI02++) ; normal
|
||||||
NOP IADDIU VI02, VI02, 1 ; skip weights
|
NOP IADDIU VI02, VI02, 1 ; skip weights
|
||||||
|
|
||||||
MULAw.xyzw ACC, VF31, VF00w NOP
|
MULAw.xyzw ACC, VF31, VF00w NOP ; transform vertex
|
||||||
MADDAx.xyzw ACC, VF28, VF01x NOP
|
MADDAx.xyzw ACC, VF28, VF01x NOP
|
||||||
MADDAy.xyzw ACC, VF29, VF01y NOP
|
MADDAy.xyzw ACC, VF29, VF01y NOP
|
||||||
MADDz.xyzw VF01, VF30, VF01z NOP
|
MADDz.xyzw VF01, VF30, VF01z NOP
|
||||||
ITOF0 VF02, VF02 NOP
|
ITOF0 VF03, VF03 NOP
|
||||||
ITOF0[I] VF03, VF03 LOI 0.0078125 ; - normal scale
|
ITOF0[I] VF04, VF04 LOI 0.0078125 ; - normal scale
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP DIV Q, VF00w, VF01w
|
NOP DIV Q, VF00w, VF01w
|
||||||
NOP WAITQ
|
NOP WAITQ
|
||||||
MULq VF01, VF01, Q NOP ; perspective division
|
MULq VF01, VF01, Q NOP ; perspective division
|
||||||
MULi VF03, VF03, I NOP ; scale normal
|
MULi VF04, VF04, I NOP ; scale normal
|
||||||
NOP NOP
|
NOP MR32.z VF02, VF00
|
||||||
NOP NOP
|
NOP NOP
|
||||||
SUB.w VF01, VF01, VF01 NOP
|
SUB.w VF01, VF01, VF01 NOP
|
||||||
MULAx.xyz ACC, VF18, VF03x NOP ; transform normal
|
MULAx.xyz ACC, VF18, VF04x NOP ; transform normal
|
||||||
MADDAy.xyz ACC, VF19, VF03y NOP
|
MADDAy.xyz ACC, VF19, VF04y NOP
|
||||||
MADDz.xyz VF03, VF20, VF03z NOP
|
MADDz.xyz VF04, VF20, VF04z NOP
|
||||||
ADD.xy VF01, VF01, VF25 NOP
|
ADD.xy VF01, VF01, VF25 NOP
|
||||||
|
MULq VF02, VF02, Q NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
NOP NOP
|
FTOI0 VF03, VF03 NOP
|
||||||
FTOI0 VF02, VF02 NOP
|
|
||||||
FTOI4 VF01, VF01 NOP
|
FTOI4 VF01, VF01 NOP
|
||||||
NOP SQ VF03, -2(VI02) ; store normal
|
NOP SQ VF04, -2(VI02) ; store normal
|
||||||
NOP IADDI VI01, VI01, -1
|
NOP IADDI VI01, VI01, -1
|
||||||
NOP SQI VF02, (VI03++) ; color
|
NOP SQI VF02, (VI03++) ; STQ
|
||||||
|
NOP SQI VF03, (VI03++) ; color
|
||||||
NOP SQI VF01, (VI03++) ; vertex
|
NOP SQI VF01, (VI03++) ; vertex
|
||||||
NOP IBNE VI01, VI00, Loop
|
NOP IBNE VI01, VI00, Loop
|
||||||
NOP NOP
|
NOP NOP
|
||||||
|
@ -42,7 +42,7 @@ vuMat:
|
|||||||
vuOffset:
|
vuOffset:
|
||||||
.float 0.0, 0.0, 0.0, 0.0
|
.float 0.0, 0.0, 0.0, 0.0
|
||||||
vuGIFtag:
|
vuGIFtag:
|
||||||
.int 0x00008000, 0x2005C000, 0x0000000041, 0x00000000
|
.int 0x00008000, 0x3005C000, 0x0000000412, 0x00000000
|
||||||
vuMatcolor:
|
vuMatcolor:
|
||||||
.float 1.0, 1.0, 1.0, 0.5
|
.float 1.0, 1.0, 1.0, 0.5
|
||||||
vuSurfProps:
|
vuSurfProps:
|
||||||
|
Loading…
Reference in New Issue
Block a user