diff options
author | Treeki <treeki@gmail.com> | 2011-06-15 04:24:48 +0200 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-06-15 04:24:48 +0200 |
commit | a36737f8a870182a69b67282a4a41ea5e056c8dd (patch) | |
tree | 7519166c3a232e5a5438105c660229e1a1f2e402 | |
parent | ba9d9bf56844028cbb227a8d1985a11446a022de (diff) | |
download | kamek-a36737f8a870182a69b67282a4a41ea5e056c8dd.tar.gz kamek-a36737f8a870182a69b67282a4a41ea5e056c8dd.zip |
also, I still don't know how to use git
-rw-r--r-- | include/g3dhax.h | 268 | ||||
-rw-r--r-- | kamek_ntsc.x | 6 | ||||
-rw-r--r-- | kamek_ntsc2.x | 6 | ||||
-rw-r--r-- | kamek_pal.x | 6 | ||||
-rw-r--r-- | kamek_pal2.x | 6 | ||||
-rwxr-xr-x | make_map_model.rb | 31 | ||||
-rw-r--r-- | src/wm_map.cpp | 83 | ||||
-rw-r--r-- | src/wm_map.h | 6 |
8 files changed, 262 insertions, 150 deletions
diff --git a/include/g3dhax.h b/include/g3dhax.h index 125a93f..ac5ba80 100644 --- a/include/g3dhax.h +++ b/include/g3dhax.h @@ -4,194 +4,206 @@ // nw4r::g3d wrapper namespace nw4r { -namespace g3d { + namespace g3d { -class ResName { -public: - const char *name; + class ResName { + public: + const char *name; + + ResName(const char *p = NULL) { + name = p; + } + }; - ResName(const char *p = NULL) { - name = p; - } -}; + class ResMdl { + public: + void * /*ResMdlData*/ data; -class ResFile { -public: - void * /*ResFileData*/ data; + ResMdl(void *p = NULL) { + data = p; + } - ResFile(void *p = NULL) { - data = p; - } + void * /*ResMat*/ GetResMat(const char *str) const; + }; - void Init(); - bool CheckRevision() const; - - void * /*ResMdl*/ GetResMdl(const char *str) const; - void * /*ResPltt*/ GetResPltt(const ResName n) const; - void * /*ResTex*/ GetResTex(const char *str) const; - void * /*ResTex*/ GetResTex(const ResName n) const; - void * /*ResTex*/ GetResTex(u32 idx) const; - void * /*ResAnmChr*/ GetResAnmChr(const char *str) const; - void * /*ResAnmVis*/ GetResAnmVis(const char *str) const; - void * /*ResAnmClr*/ GetResAnmClr(const char *str) const; - void * /*ResAnmTexPat*/ GetResAnmTexPat(const char *str) const; - void * /*ResAnmTexSrt*/ GetResAnmTexSrt(const char *str) const; - void * /*ResAnmScn*/ GetResAnmScn(const char *str) const; - - bool Bind(ResFile rhs); -}; + class ResFile { + public: + void * /*ResFileData*/ data; -void *__ScnMdlSimple__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResMdl*/ mdl, - int nView = 1); + ResFile(void *p = NULL) { + data = p; + } + void Init(); + bool CheckRevision() const; -void *__ScnMdl__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResMdl*/ mdl, - u32 bufferOption, - int nView = 1); + ResMdl GetResMdl(const char *str) const; + void * /*ResPltt*/ GetResPltt(const ResName n) const; + void * /*ResTex*/ GetResTex(const char *str) const; + void * /*ResTex*/ GetResTex(const ResName n) const; + void * /*ResTex*/ GetResTex(u32 idx) const; + void * /*ResAnmChr*/ GetResAnmChr(const char *str) const; + void * /*ResAnmVis*/ GetResAnmVis(const char *str) const; + void * /*ResAnmClr*/ GetResAnmClr(const char *str) const; + void * /*ResAnmTexPat*/ GetResAnmTexPat(const char *str) const; + void * /*ResAnmTexSrt*/ GetResAnmTexSrt(const char *str) const; + void * /*ResAnmScn*/ GetResAnmScn(const char *str) const; + bool Bind(ResFile rhs); + }; -void *__AnmObjChrRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmChr*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__ScnMdlSimple__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResMdl*/ mdl, + int nView = 1); -void *__AnmObjVisRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmVis*/ resAnm, - void * /*ResMdl*/ resMdl); + void *__ScnMdl__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResMdl*/ mdl, + u32 bufferOption, + int nView = 1); -void *__AnmObjTexPatRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmTexPat*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjChrRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmChr*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -void *__AnmObjTexSrtRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmTexSrt*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjVisRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmVis*/ resAnm, + void * /*ResMdl*/ resMdl); -void *__AnmObjMatClrRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmMatClr*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjTexPatRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmTexPat*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -void *__AnmObjShpRes__Construct( - void * /*MEMAllocator*/ pHeap, - u32 *pSize, - void * /*ResAnmShp*/ resAnm, - void * /*ResMdl*/ resMdl, - bool bHasCache); + void *__AnmObjTexSrtRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmTexSrt*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); + void *__AnmObjMatClrRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmMatClr*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -bool InsertIntoScene(void *scnObj); // 80164F90 -extern void *g3dMemAllocator; // 8042A6A8 + void *__AnmObjShpRes__Construct( + void * /*MEMAllocator*/ pHeap, + u32 *pSize, + void * /*ResAnmShp*/ resAnm, + void * /*ResMdl*/ resMdl, + bool bHasCache); -inline void *ConstructScnMdlSimple(void *mdl, int nView = 1) { - return __ScnMdlSimple__Construct(g3dMemAllocator, 0, mdl, nView); -} -inline void *ConstructScnMdl(void *mdl, u32 bufferOption, int nView = 1) { - return __ScnMdl__Construct(g3dMemAllocator, 0, mdl, bufferOption, nView); -} + bool InsertIntoScene(void *scnObj); // 80164F90 + extern void *g3dMemAllocator; // 8042A6A8 -} + inline void *ConstructScnMdlSimple(void *mdl, int nView = 1) { + return __ScnMdlSimple__Construct(g3dMemAllocator, 0, mdl, nView); + } + + inline void *ConstructScnMdl(void *mdl, u32 bufferOption, int nView = 1) { + return __ScnMdl__Construct(g3dMemAllocator, 0, mdl, bufferOption, nView); + } + + + + } } class mHeapAllocator_c { // Actually that weird subclass. INCOMPLETE!! -public: - char data1[0x10]; + public: + char data1[0x10]; - mHeapAllocator_c(); - virtual ~mHeapAllocator_c(); - virtual void *alloc(u32 size); - virtual void free(void *block); + mHeapAllocator_c(); + virtual ~mHeapAllocator_c(); + virtual void *alloc(u32 size); + virtual void free(void *block); - bool link(s32 size, void *heap, const char *name, int align); - u32 unlink(); + bool link(s32 size, void *heap, const char *name, int align); + u32 unlink(); - char data2[8]; + char data2[8]; }; namespace m3d { // random, just dumped it here because I dunno where else void DisableIndirectTexturing(); + void InitTexObjWithResTex(GXTexObj *obj, /* ResTex */ void *resTex, GXTexWrapMode wrapS, GXTexWrapMode wrapT, GXTexFilter minFilt, GXTexFilter magFilt); // I need to do scnLeaf_c some time... class proc_c { - public: - proc_c(); - virtual ~proc_c(); + public: + proc_c(); + virtual ~proc_c(); - void setup(void *allocator = 0, u32 *size = 0); - virtual int returnUnknown(); - virtual void free(); - virtual bool scheduleForDrawing(); - virtual void drawOpa(); - virtual void drawXlu(); + void setup(void *allocator = 0, u32 *size = 0); + virtual int returnUnknown(); + virtual void free(); + virtual bool scheduleForDrawing(); + virtual void drawOpa(); + virtual void drawXlu(); - void setScnObjOption(ulong, ulong); - bool getScnObjOption(ulong, ulong*); + void setScnObjOption(ulong, ulong); + bool getScnObjOption(ulong, ulong*); - void setScale(float x, float y, float z); - void setScale(Vec vec); + void setScale(float x, float y, float z); + void setScale(Vec vec); - void setDrawMatrix(Mtx *mtx); - void getLocalMatrix(Mtx *mtx); - void getViewMatrix(Mtx *mtx); + void setDrawMatrix(Mtx *mtx); + void getLocalMatrix(Mtx *mtx); + void getViewMatrix(Mtx *mtx); - void calcWorld(bool); - void calcView(bool); + void calcWorld(bool); + void calcView(bool); - void setDrawPriorities(int opa, int xlu); + void setDrawPriorities(int opa, int xlu); - void *scnObj; + void *scnObj; }; class mdl_c { - public: - mdl_c(); - virtual ~mdl_c(); + public: + mdl_c(); + virtual ~mdl_c(); - virtual void _vf0C(); - virtual void _vf10(); - virtual bool scheduleForDrawing(); - virtual void bindAnim(void *anim, float boo); - virtual void _vf1C(); + virtual void _vf0C(); + virtual void _vf10(); + virtual bool scheduleForDrawing(); + virtual void bindAnim(void *anim, float boo); + virtual void _vf1C(); - bool setup(void *model, void *allocator, u32 bufferOption, int nView, u32 *size); - void oneSetupType(); - void sub_80064BF0(); + bool setup(nw4r::g3d::ResMdl model, void *allocator, u32 bufferOption, int nView, u32 *size); + void oneSetupType(); + void sub_80064BF0(); - void setDrawMatrix(const Mtx matrix); + void setDrawMatrix(const Mtx matrix); - char data[0x3C]; + char data[0x3C]; }; }; diff --git a/kamek_ntsc.x b/kamek_ntsc.x index 6e9b201..d2becfb 100644 --- a/kamek_ntsc.x +++ b/kamek_ntsc.x @@ -218,12 +218,16 @@ SECTIONS { Init__Q34nw4r3g3d7ResFileFv = 0x8023A590; Bind__Q34nw4r3g3d7ResFileFQ34nw4r3g3d7ResFile = 0x8023A350; GetResMdl__Q34nw4r3g3d7ResFileCFPCc = 0x80239E30; + GetResTex__Q34nw4r3g3d7ResFileCFPCc = 0x80239F20; g3dMemAllocator__Q24nw4r3g3d = 0x8042A3C8; __ScnMdl__Construct__Q24nw4r3g3dFPvPUiPvUii = 0x8025CA20; __ScnMdlSimple__Construct__Q24nw4r3g3dFPvPUiPvi = 0x8025A380; InsertIntoScene__Q24nw4r3g3dFPv = 0x80164E50; + GetResMat__Q34nw4r3g3d6ResMdlCFPCc = 0x8023B760; + DisableIndirectTexturing__3m3dFv = 0x80164F50; + InitTexObjWithResTex__3m3dFP9_GXTexObjPv14_GXTexWrapMode14_GXTexWrapMode12_GXTexFilter12_GXTexFilter = 0x802C7C70; /* This is preliminary and kinda strange, most of these just point to ScnLeaf for now */ setup__Q23m3d6proc_cFPvPUi = 0x80164FD0; @@ -237,7 +241,7 @@ SECTIONS { __ct__Q23m3d5mdl_cFv = 0x80169CD0; __dt__Q23m3d5mdl_cFv = 0x80169D20; - setup__Q23m3d5mdl_cFPvPvUiiPUi = 0x80169D90; + setup__Q23m3d5mdl_cFQ34nw4r3g3d6ResMdlPvUiiPUi = 0x80169D90; oneSetupType__Q23m3d5mdl_cFv = 0x80064C10; sub_80064BF0__Q23m3d5mdl_cFv = 0x80064BF0; setDrawMatrix__Q23m3d5mdl_cFPA4_Cf = 0x8016A170; diff --git a/kamek_ntsc2.x b/kamek_ntsc2.x index 1d3822d..ea679bd 100644 --- a/kamek_ntsc2.x +++ b/kamek_ntsc2.x @@ -218,12 +218,16 @@ SECTIONS { Init__Q34nw4r3g3d7ResFileFv = 0x8023A590; Bind__Q34nw4r3g3d7ResFileFQ34nw4r3g3d7ResFile = 0x8023A350; GetResMdl__Q34nw4r3g3d7ResFileCFPCc = 0x80239E30; + GetResTex__Q34nw4r3g3d7ResFileCFPCc = 0x80239F20; g3dMemAllocator__Q24nw4r3g3d = 0x8042A3C8; __ScnMdl__Construct__Q24nw4r3g3dFPvPUiPvUii = 0x8025CA20; __ScnMdlSimple__Construct__Q24nw4r3g3dFPvPUiPvi = 0x8025A380; InsertIntoScene__Q24nw4r3g3dFPv = 0x80164E50; + GetResMat__Q34nw4r3g3d6ResMdlCFPCc = 0x8023B760; + DisableIndirectTexturing__3m3dFv = 0x80164F50; + InitTexObjWithResTex__3m3dFP9_GXTexObjPv14_GXTexWrapMode14_GXTexWrapMode12_GXTexFilter12_GXTexFilter = 0x802C7C70; /* This is preliminary and kinda strange, most of these just point to ScnLeaf for now */ setup__Q23m3d6proc_cFPvPUi = 0x80164FD0; @@ -237,7 +241,7 @@ SECTIONS { __ct__Q23m3d5mdl_cFv = 0x80169CD0; __dt__Q23m3d5mdl_cFv = 0x80169D20; - setup__Q23m3d5mdl_cFPvPvUiiPUi = 0x80169D90; + setup__Q23m3d5mdl_cFQ34nw4r3g3d6ResMdlPvUiiPUi = 0x80169D90; oneSetupType__Q23m3d5mdl_cFv = 0x80064C10; sub_80064BF0__Q23m3d5mdl_cFv = 0x80064BF0; setDrawMatrix__Q23m3d5mdl_cFPA4_Cf = 0x8016A170; diff --git a/kamek_pal.x b/kamek_pal.x index c70729d..88ca453 100644 --- a/kamek_pal.x +++ b/kamek_pal.x @@ -218,12 +218,16 @@ SECTIONS { Init__Q34nw4r3g3d7ResFileFv = 0x8023A6D0;
Bind__Q34nw4r3g3d7ResFileFQ34nw4r3g3d7ResFile = 0x8023A490;
GetResMdl__Q34nw4r3g3d7ResFileCFPCc = 0x80239F70;
+ GetResTex__Q34nw4r3g3d7ResFileCFPCc = 0x8023A060;
g3dMemAllocator__Q24nw4r3g3d = 0x8042A6A8;
__ScnMdl__Construct__Q24nw4r3g3dFPvPUiPvUii = 0x8025CB60;
__ScnMdlSimple__Construct__Q24nw4r3g3dFPvPUiPvi = 0x8025A4C0;
InsertIntoScene__Q24nw4r3g3dFPv = 0x80164F90;
+ GetResMat__Q34nw4r3g3d6ResMdlCFPCc = 0x8023B8A0;
+
DisableIndirectTexturing__3m3dFv = 0x80165090;
+ InitTexObjWithResTex__3m3dFP9_GXTexObjPv14_GXTexWrapMode14_GXTexWrapMode12_GXTexFilter12_GXTexFilter = 0x802C7F60;
/* This is preliminary and kinda strange, most of these just point to ScnLeaf for now */
setup__Q23m3d6proc_cFPvPUi = 0x80165110;
@@ -237,7 +241,7 @@ SECTIONS { __ct__Q23m3d5mdl_cFv = 0x80169E10;
__dt__Q23m3d5mdl_cFv = 0x80169E60;
- setup__Q23m3d5mdl_cFPvPvUiiPUi = 0x80169ED0;
+ setup__Q23m3d5mdl_cFQ34nw4r3g3d6ResMdlPvUiiPUi = 0x80169ED0;
oneSetupType__Q23m3d5mdl_cFv = 0x80064C10;
sub_80064BF0__Q23m3d5mdl_cFv = 0x80064BF0;
setDrawMatrix__Q23m3d5mdl_cFPA4_Cf = 0x8016A2B0;
diff --git a/kamek_pal2.x b/kamek_pal2.x index 66bf7a0..9d4a810 100644 --- a/kamek_pal2.x +++ b/kamek_pal2.x @@ -218,12 +218,16 @@ SECTIONS { Init__Q34nw4r3g3d7ResFileFv = 0xDEADBEEF; Bind__Q34nw4r3g3d7ResFileFQ34nw4r3g3d7ResFile = 0xDEADBEEF; GetResMdl__Q34nw4r3g3d7ResFileCFPCc = 0xDEADBEEF; + GetResTex__Q34nw4r3g3d7ResFileCFPCc = 0xDEADBEEF; g3dMemAllocator__Q24nw4r3g3d = 0xDEADBEEF; __ScnMdl__Construct__Q24nw4r3g3dFPvPUiPvUii = 0xDEADBEEF; __ScnMdlSimple__Construct__Q24nw4r3g3dFPvPUiPvi = 0xDEADBEEF; InsertIntoScene__Q24nw4r3g3dFPv = 0xDEADBEEF; + GetResMat__Q34nw4r3g3d6ResMdlCFPCc = 0xDEADBEEF; + DisableIndirectTexturing__3m3dFv = 0xDEADBEEF; + InitTexObjWithResTex__3m3dFP9_GXTexObjPv14_GXTexWrapMode14_GXTexWrapMode12_GXTexFilter12_GXTexFilter = 0xDEADBEEF; /* This is preliminary and kinda strange, most of these just point to ScnLeaf for now */ setup__Q23m3d6proc_cFPvPUi = 0xDEADBEEF; @@ -237,7 +241,7 @@ SECTIONS { __ct__Q23m3d5mdl_cFv = 0xDEADBEEF; __dt__Q23m3d5mdl_cFv = 0xDEADBEEF; - setup__Q23m3d5mdl_cFPvPvUiiPUi = 0xDEADBEEF; + setup__Q23m3d5mdl_cFQ34nw4r3g3d6ResMdlPvUiiPUi = 0xDEADBEEF; oneSetupType__Q23m3d5mdl_cFv = 0xDEADBEEF; sub_80064BF0__Q23m3d5mdl_cFv = 0xDEADBEEF; setDrawMatrix__Q23m3d5mdl_cFPA4_Cf = 0xDEADBEEF; diff --git a/make_map_model.rb b/make_map_model.rb index bae1cd0..55560ff 100755 --- a/make_map_model.rb +++ b/make_map_model.rb @@ -27,11 +27,34 @@ brres.get_texture_group.add 'alphaBlender', alpha_tex # yay #model.shapes["World2_PathsPlumbing__World2_PathsPlumbing"].clr_data[0].raw_data = System::Array[Byte].new([255, 255, 255, 128]) +# move paths into DrawXlu +opa = model.bytecode["DrawOpa"] +if model.bytecode.contains_key("DrawXlu") + xlu = model.bytecode["DrawXlu"] +else + xlu = ByteCode.new + xlu.instructions = System::Collections::Generic::List[ByteCode::Instruction].new + xlu.instructions << ByteCode::DoneInstruction.new + model.bytecode["DrawXlu"] = xlu +end + +shape_array = model.shapes.to_a + +to_be_moved = opa.instructions.select do |insn| + insn.is_a?(ByteCode::DrawShapeInstruction) and + shape_array[insn.shape_i_d].key =~ /path/i +end + +to_be_moved.each do |insn| + opa.instructions.remove insn + xlu.instructions.insert 0, insn +end + # how's this for hackiness? model.materials.each do |kvp| next unless kvp.key =~ /path/i - if true + if false mat = kvp.value # update the material @@ -135,9 +158,9 @@ model.materials.each do |kvp| sh.pad_to_size 0x1E0 sh.end shad.display_list = sh.get_buffer - end - next + next + end if false mat = kvp.value @@ -203,6 +226,8 @@ model.materials.each do |kvp| dl.pad_to_size 0x1E0 dl.end shad.display_list = dl.get_buffer + + next end diff --git a/src/wm_map.cpp b/src/wm_map.cpp index a4b8a48..c84ff18 100644 --- a/src/wm_map.cpp +++ b/src/wm_map.cpp @@ -10,8 +10,15 @@ #include <rvl/GXPixel.h> #include <rvl/GXTransform.h> +void dPathTest_c::loadTex() { + nw4r::g3d::ResFile rf(dScNewerWorldMap_c::instance->resMng['3D00']); + resTex = rf.GetResTex("W2Road"); + alpha = 255; +} + +void dPathTest_c::drawOpa() { } -void dPathTest_c::drawOpa() { +void dPathTest_c::drawXlu() { GXClearVtxDesc(); GXSetVtxDesc(GX_VA_POS, GX_DIRECT); GXSetVtxDesc(GX_VA_TEX0, GX_DIRECT); @@ -23,7 +30,8 @@ void dPathTest_c::drawOpa() { GXSetNumChans(0); GXSetNumTexGens(1); - GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_NRM, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY); + //GXSetTexCoordGen2(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_NRM, GX_IDENTITY, GX_FALSE, GX_PTIDENTITY); + GXSetTexCoordGen(GX_TEXCOORD0, GX_TG_MTX2x4, GX_TG_TEX0, GX_IDENTITY); GXSetNumTevStages(0); GXSetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); @@ -40,7 +48,7 @@ void dPathTest_c::drawOpa() { GXSetZCompLoc(0); GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET); GXSetZMode(GX_TRUE, GX_LEQUAL, GX_FALSE); - GXSetAlphaCompare(GX_GREATER, 0, GX_AOP_OR, GX_GREATER, 0); + GXSetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); GXSetFog(GX_FOG_NONE, 0.0f, 0.0f, 0.0f, 0.0f, (GXColor){0,0,0,0}); GXSetFogRangeAdj(0, 0, 0); @@ -64,25 +72,42 @@ void dPathTest_c::drawOpa() { //camMtx[2][3] = 0.0f; //MTXConcat(viewMatrix, camMtx, viewMatrix); + + // TESTING CRAP!! + // Just copying what my old 3D engine had for now + GXSetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_SET); + GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE); + GXSetZCompLoc(GX_TRUE); + GXSetNumTevStages(1); + GXSetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetTevSwapMode(GX_TEVSTAGE1, GX_TEV_SWAP0, GX_TEV_SWAP0); + GXSetNumChans(1); + //GXSetChanAmbColor(GX_COLOR0A0, (GXColor){128,128,128,255}); + GXSetChanMatColor(GX_COLOR0A0, (GXColor){0,0,0,(u8)alpha}); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_REG, GX_SRC_REG, GX_LIGHT_NULL, GX_DF_CLAMP, GX_AF_NONE); + GXSetNumTexGens(1); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD0, GX_TEXMAP0, GX_COLOR0A0); + GXSetTevOp(GX_TEVSTAGE0, GX_BLEND); + + GXTexObj to; + m3d::InitTexObjWithResTex(&to, &resTex, GX_REPEAT, GX_REPEAT, GX_LINEAR, GX_LINEAR); + GXLoadTexObj(&to, GX_TEXMAP0); GXLoadPosMtxImm(camMtx, GX_PNMTX0); GXSetCurrentMtx(GX_PNMTX0); GXBegin(GX_QUADS, GX_VTXFMT0, 4); - GXPosition3f32(-400, 0, -400); + GXPosition3f32(-400, 90, -400); GXTexCoord2f32(0, 0); - GXPosition3f32(400, 0, -400); + GXPosition3f32(400, 90, -400); GXTexCoord2f32(1, 0); - GXPosition3f32(400, 0, 400); + GXPosition3f32(400, 90, 400); GXTexCoord2f32(1, 1); - GXPosition3f32(-400, 0, 400); + GXPosition3f32(-400, 90, 400); GXTexCoord2f32(0, 1); GXEnd(); } -void dPathTest_c::drawXlu() { -} - dWMMap_c *dWMMap_c::instance = 0; @@ -131,6 +156,7 @@ int dWMMap_c::onCreate() { } SpammyReport("Making path test\n"); + pathTest.loadTex(); pathTest.setup(&allocator); SpammyReport("Unlinking allocator\n"); @@ -151,6 +177,14 @@ int dWMMap_c::onDelete() { int dWMMap_c::onExecute() { + /* TESTING */ + int heldButtons = Remocon_GetButtons(GetActiveRemocon()); + if (heldButtons & WPAD_UP) + pathTest.alpha += 8; + if (heldButtons & WPAD_DOWN) + pathTest.alpha -= 8; + nodes[0].updateAlpha("World2_PathsSinkytoPyramid", pathTest.alpha); + return true; } @@ -158,12 +192,12 @@ int dWMMap_c::onExecute() { int dWMMap_c::onDraw() { SpammyReport("dWMMap_c::onDraw() called\n"); + //pathTest.scheduleForDrawing(); for (int i = 0; i < data->nodeCount; i++) { SpammyReport("Drawing node %d\n", i); nodes[i].draw(); } - pathTest.scheduleForDrawing(); SpammyReport("dWMMap_c::onDraw() completed\n"); return true; @@ -184,10 +218,10 @@ void WMSceneNode::loadFrom(WMSceneDataNode *data, mHeapAllocator_c *allocator) { void *brres = dScNewerWorldMap_c::instance->resMng[data->brresKey]; nw4r::g3d::ResFile resfile(brres); - void *mdl = resfile.GetResMdl(data->modelName); - MapReport("Obtained ResMdl: %p\n", mdl); + resMdl = resfile.GetResMdl(data->modelName); + MapReport("Obtained ResMdl: %p\n", resMdl); - MapReport(model.setup(&mdl, allocator, 0, 1, 0) ? "Success\n" : "Fail\n"); + MapReport(model.setup(resMdl, allocator, 0, 1, 0) ? "Success\n" : "Fail\n"); // todo: more types SpammyReport("Setting up lightmaps\n"); @@ -204,7 +238,26 @@ void WMSceneNode::loadFrom(WMSceneDataNode *data, mHeapAllocator_c *allocator) { } +void WMSceneNode::updateAlpha(const char *materialName, u8 alpha) { + // get the material + // too lazy to use dynamic buffers for the ResMatTevColor stuff... + //OSReport("trying to update %s to %d\n", materialName, alpha); + u8 *mat = (u8*)resMdl.GetResMat(materialName); + //OSReport("got mat: %p\n", mat); + + s32 *matDLOffsetPtr = (s32*)(mat + 0x3C); + s32 matDLOffset = *matDLOffsetPtr; + + u8 *matTevColorDL = mat + matDLOffset + 0x20; + u8 *setTevKonst4Cmd = matTevColorDL + 0x5E; + //OSReport("got DL offset: %d. DL is at %p. cmd is at %p.\n", matDLOffset, matTevColorDL, setTevKonst4Cmd); + + setTevKonst4Cmd[2] = (setTevKonst4Cmd[2] & 0xF0) | (alpha >> 4); + setTevKonst4Cmd[3] = (setTevKonst4Cmd[3] & 0x0F) | (alpha & 0xF0); +} + + void WMSceneNode::draw() { - //model.scheduleForDrawing(); + model.scheduleForDrawing(); } diff --git a/src/wm_map.h b/src/wm_map.h index 9fd269c..da392bf 100644 --- a/src/wm_map.h +++ b/src/wm_map.h @@ -22,16 +22,22 @@ struct WMSceneDataHeader { class WMSceneNode { public: WMSceneDataNode *baseData; + nw4r::g3d::ResMdl resMdl; m3d::mdl_c model; void loadFrom(WMSceneDataNode *data, mHeapAllocator_c *allocator); void draw(); + void updateAlpha(const char *materialName, u8 alpha); }; class dPathTest_c : public m3d::proc_c { public: + void loadTex(); void drawOpa(); void drawXlu(); + + void *resTex; + u8 alpha; }; |