Posted on 09-19-16, 01:52 pm (rev. 10 by  skawo on 09-21-16, 03:50 pm)


Karma: 19752
Posts: 690/1100
Since: 04-02-13
Select your own Jyotyu Palette:
#include "nsmb.h" void hook_020A3480_ov_00() { int JyotyuPal = MygetUnk3ForView(((*(getPtrToPlayerActor()+0xAF)>>16)&0xFF)); if (JyotyuPal > 3) JyotyuPal = 3; u8* ptr = (u8*) allocFromGameHeap(1066); switch (JyotyuPal) { case 0: //Normal { loadFileByExtId_LZ_Dest(408-0x83, ptr); break; } case 1: //Underground { loadFileByExtId_LZ_Dest(406-0x83, ptr); break; } case 2: //Lava { loadFileByExtId_LZ_Dest(409-0x83, ptr); break; } case 3: //Snow/Ghost { loadFileByExtId_LZ_Dest(410-0x83, ptr); break; } default: { break; } //You can add more if you want } DC_FlushRangeOrAll(ptr, 0x400); GX_BeginLoadOBJExtPltt(); GX_LoadOBJExtPltt(ptr, 0x0, 0x400); GX_EndLoadOBJExtPltt(); DC_FlushRangeOrAll(ptr, 0x400); GX_BeginLoadBGExtPltt(); GX_LoadBGExtPltt(ptr, 0x4000, 0x400); GX_EndLoadBGExtPltt(); freeToGameHeap(ptr); return; }

Disable broken Unk Setting Functionality:
nsub_0201F0F4_main: nsub_0201F118_main: nsub_0201F13C_main: MOV R0, #0 BX LR .globl MygetUnk1ForView MygetUnk1ForView: STMFD SP!, {LR} SUB SP, SP, #4 MOV R1, #0 BL getPtrToViewById CMP R0, #0 LDRNEB R0, [R0,#0xB] MOVEQ R0, #0 ADD SP, SP, #4 LDMFD SP!, {PC} .globl MygetUnk2ForView MygetUnk2ForView: STMFD SP!, {LR} SUB SP, SP, #4 MOV R1, #0 BL getPtrToViewById CMP R0, #0 LDRNEB R0, [R0,#0xC] MOVEQ R0, #0 ADD SP, SP, #4 LDMFD SP!, {PC} .globl MygetUnk3ForView MygetUnk3ForView: STMFD SP!, {LR} SUB SP, SP, #4 MOV R1, #0 BL getPtrToViewById CMP R0, #0 LDRNEB R0, [R0,#0xD] MOVEQ R0, #0 ADD SP, SP, #4 LDMFD SP!, {PC}

First goes into a .cpp file, the second into an .s file. You will also need to add this to nsmb.h:

void GX_BeginLoadBGExtPltt(void); void GX_LoadBGExtPltt(const void *pSrc, u32 destSlotAddr, u32 szByte); void GX_EndLoadBGExtPltt(void); void GX_BeginLoadOBJExtPltt(void); void GX_LoadOBJExtPltt(const void *pSrc, u32 destSlotAddr, u32 szByte); void GX_EndLoadOBJExtPltt(void); void DC_FlushRangeOrAll(const void *startAddr, u32 nBytes); void MIi_CpuCopy16(const void *srcp, void *destp, u32 size); u32* getPtrToPlayerActor(); //Replace void* getPtrToPlayerActor(); with this. u8 MygetUnk1ForView(u32 viewID); u8 MygetUnk2ForView(u32 viewID); u8 MygetUnk3ForView(u32 viewID);


This hackily lets you choose the Jyotyu palette per view by shamelessly overwriting it directly in VRAM. Simply change the Unk3(B) value in the View settings. 0 = normal, 1 = underground, 2 = lava, 3 = snow/ghost.

EDIT: Minor fix

Posted on 09-19-16, 04:12 pm
Birdo


Karma: 2754
Posts: 1880/2091
Since: 06-26-11
What is this unused Unk3 functionality?
Posted on 09-19-16, 04:16 pm
I Am Not Inteligent

Karma: 979
Posts: 245/380
Since: 03-04-14
IIRC, its original/former function is lost. The final game uses it to prevent the top background from loading. All ghost houses use it, I think.

I could not…
Posted on 09-19-16, 04:16 pm
☭ coffee and cream


Karma: 10398
Posts: 2080/2766
Since: 06-26-11
this, or something close


they had a feature that allowed to select graphics (tileset, BGs, jyotyu palette) for each view. it's incomplete or broken. the only part that works is the Jyotyu palette.
_________________________
Kuribo64 - RH-fucking-cafe - Kafuka

zrghij
Posted on 09-19-16, 04:20 pm (rev. 1 by  skawo on 09-19-16, 04:22 pm)


Karma: 19752
Posts: 691/1100
Since: 04-02-13
Posted by StapleButter
The only part that works is the Jyotyu palette.


Does it? It seemed broken, as well. All I could ever get those unks to do was to disable either just the back bg or both bgs.
Posted on 09-19-16, 04:23 pm (rev. 1 by  Arisotura on 09-19-16, 04:35 pm)
☭ coffee and cream


Karma: 10398
Posts: 2081/2766
Since: 06-26-11
Oh, you're doing it differently, it seems. Your code uses unk3 as the jyotyu palette number.


The unk1/unk2/unk3 were meant as indexes into the background/tileset blocks in the level header-- those blocks could contain multiple entries. You even have one of the unused levels that uses this.

It's broken as hell because several parts of the code read from the first block or the last block no matter what the unk1/2/3 say. But the jyotyu palette part does work right.


Your hax makes it easier to deal with, though. NSMBe doesn't support the 'multiple BG blocks' thing.
_________________________
Kuribo64 - RH-fucking-cafe - Kafuka

zrghij
Posted on 09-20-16, 12:59 pm (rev. 5 by  skawo on 09-28-16, 06:21 pm)


Karma: 19752
Posts: 694/1100
Since: 04-02-13
Level Darkness Setting:
#include "nsmb.h" vu8 *Brightness = (vu8*)(0x400006C); bool *MenuOpen = (bool*)(0x020CA870); void hook_020A2ED0() { int CurrentView = (((*(getPtrToPlayerActor()+0xAF)>>16)&0xFF)); if ((MygetUnk2ForView(CurrentView) != 2)) { if (*Brightness != 0) setBrightness(1,0); return; } if (((*Brightness) < (MygetUnk1ForView((CurrentView)))) && !(*MenuOpen)) { setBrightness(1,-((*Brightness)+1)); } if ((*Brightness) != 0) { if (*MenuOpen) { setBrightness(1,-((*Brightness)-1)); } } return; } void hook_020A134C() // Restore brightness on world map { setBrightness(1, 0); return; }

This goes into a .cpp file. You also need the "Disable broken Unk functionality" from this post.

By setting Unk 2 in view settings to 2, you enable darkness, the intensity of which is controlled by Unk 1.
Posted on 09-21-16, 12:50 pm (rev. 6 by ImageBot on 11-21-16, 03:24 am)
Panser
I AM DERP INCARNATE

Karma: 503
Posts: 139/328
Since: 08-20-16
I've just noticed, W4-5 area 3 does not have any parallax scrolling between the top BG and the bottom BG. Can it be fixed similarly to W8-6?

Also,
Posted by skawo
Select your own Jyotyu Palette:
#include "nsmb.h" void hook_020A3480_ov_00() { int JyotyuPal = MygetUnk3ForView(((*(getPtrToPlayerActor()+579)>>0x10)&0xFF)); if (JyotyuPal > 3) JyotyuPal = 3; u8* ptr = (u8*) allocFromGameHeap(1066); switch (JyotyuPal) { case 0: //Normal { loadFileByExtId_LZ_Dest(408-0x83, ptr); break; } case 1: //Underground { loadFileByExtId_LZ_Dest(406-0x83, ptr); break; } case 2: //Lava { loadFileByExtId_LZ_Dest(409-0x83, ptr); break; } case 3: //Snow/Ghost { loadFileByExtId_LZ_Dest(410-0x83, ptr); break; } default: { break; } //You can add more if you want } DC_FlushRangeOrAll(ptr, 0x400); GX_BeginLoadOBJExtPltt(); GX_LoadOBJExtPltt(ptr, 0x0, 0x400); GX_EndLoadOBJExtPltt(); DC_FlushRangeOrAll(ptr, 0x400); GX_BeginLoadBGExtPltt(); GX_LoadBGExtPltt(ptr, 0x4000, 0x400); GX_EndLoadBGExtPltt(); freeToGameHeap(ptr); return; }




EDIT: Actually it does this with all your CPP code, not just the jyotyu selector
EDIT2: And yes i'm 100% sure i inserted the new functions into nsmb.h
rip signature
Posted on 09-21-16, 02:27 pm (rev. 3 by  skawo on 09-21-16, 02:30 pm)


Karma: 19752
Posts: 695/1100
Since: 04-02-13
First goes into a .cpp file, the second into an .s file.


Meaning, you need both.

Also, I forgot; you need to chane void* getPtrToPlayerActor(); to u32* getPtrToPlayerActor();
Posted on 09-21-16, 03:17 pm (rev. 1 by  MarioKart7z on 09-21-16, 03:18 pm)
Panser
I AM DERP INCARNATE

Karma: 503
Posts: 140/328
Since: 08-20-16
Posted by skawo
Also, I forgot; you need to chane void* getPtrToPlayerActor(); to u32* getPtrToPlayerActor();

So i did that but it still says that "MygetUnk3ForView" wasn't declared
Posted by skawo
First goes into a .cpp file, the second into an .s file.


Meaning, you need both.

I put the jyotyu and level darkness thingys in two separate .cpp files, and the disable Unknown in an .s file. Is that what i needed to do?
rip signature
Posted on 09-21-16, 03:32 pm (rev. 1 by  skawo on 09-21-16, 03:50 pm)


Karma: 19752
Posts: 696/1100
Since: 04-02-13
...oh right,

u8 MygetUnk1ForView(u32 viewID);
u8 MygetUnk2ForView(u32 viewID);
u8 MygetUnk3ForView(u32 viewID);

...add those to nsmb.h too >.>

EDIT: Also, just fixed a bug that caused this not to happen in Ghost Houses.
Posted on 09-21-16, 07:36 pm
Birdo


Karma: 2754
Posts: 1882/2091
Since: 06-26-11
Posted by skawo
[darkness hack]

Neat! Two questions though;
* What does it affect? Everything, or just the non-HUD stuff
* If you set it to full intensity, will all the affected graphics be black?
Posted on 09-21-16, 08:54 pm


Karma: 19752
Posts: 697/1100
Since: 04-02-13
Absolutely everything.
Yes.
Posted on 09-22-16, 10:47 am (rev. 1 by  MarioKart7z on 09-22-16, 10:47 am)
Panser
I AM DERP INCARNATE

Karma: 503
Posts: 141/328
Since: 08-20-16
Posted by skawo
EDIT: Also, just fixed a bug that caused this not to happen in Ghost Houses.

c:/Games/DeSmuME/Roms/source/leveldarkness.cpp:8:63: error: expected ',' or ';' before ')' token int CurrentView = ((*(getPtrToPlayerActor()+0xAF)>>16)&0xFF)); ^

rip signature
Posted on 09-22-16, 10:58 am


Karma: 19752
Posts: 698/1100
Since: 04-02-13
Huh, how did that happen? I copied it properly above. *sigh*

Fixed.
Posted on 09-22-16, 11:47 am
Birdo


Karma: 2754
Posts: 1884/2091
Since: 06-26-11
Posted by skawo
Absolutely everything.
Yes.

Ah. So I guess you can't use it to make DKCR-style "sunset" levels then.
Posted on 09-22-16, 12:22 pm


Karma: 19752
Posts: 699/1100
Since: 04-02-13
Nope.
Posted on 09-23-16, 07:44 pm (rev. 5 by  skawo on 09-23-16, 11:18 pm)


Karma: 19752
Posts: 710/1100
Since: 04-02-13
Extra Flimsy Lift Properties:
repl_0217E084_ov_59: LDR R0, =0x4C4 BX LR repl_0217DDA0_ov_59: MOV R4, R0 MOV R0, #0x20 STR R0, [R4,#0x4C4] MOV R0, R4 BX LR repl_0217DEE0_ov_59: MOV R0, #0x20 STR R0, [R4,#0x4C4] MOV R0, #1 BX LR repl_0217DF20_ov_59: LDR R0, [R4, #8] LSR R0, #8 ANDS R0, R0, #0xF LDREQ R1, =0x217FA48 BXEQ LR LDR R0, [R4,#0x4C4] CMP R0, #0 LDREQ R1, =0x217FA48 BXEQ LR SUB R0, #1 STR R0, [R4,#0x4C4] ANDS R0, #1 LDR R1, [R4, #0x64] ADDEQ R1, #0x1200 SUBNE R1, #0x1200 STR R1, [R4, #0x64] B 0x217DF34 repl_0217DEA4_ov_59: LDR R0, [R4, #8] LSR R0, #4 ANDS R0, R0, #0xF MOVEQ R0, #0x4000 BXEQ LR MOV R1, #0x500 MUL R0, R1 BX LR

Nybble 10: Have a delay. If set, the platform will shake a bit before actually falling.
Nybble 11: Speed. If 0 = default (0x4000). Else, 0x500 * nybble value

Platform Retexture Code:
nsub_020DB4C0_ov_0A: STMFD SP!, {LR} SUB SP, SP, #4 LDR R0, =0x596 MOV R1, #0 BL loadFileByExtId_3dModel @Copy from HERE LDR R0, =FILE ID - 0x83 MOV R1, #0 BL loadFileByExtId_3dModel @To HERE and paste after this line to add more models MOV R0, #1 ADD SP, SP, #4 LDMFD SP!, {PC} nsub_020DB4A8_ov_0A: LDR R12, =0x20DB1B4 LDR R1, [R0, #8] LSR R1, #0xC AND R1, R1, #0xF CMP R1, #0 LDREQ R1, =0x596 BEQ .Load @Copy from HERE CMP R1, #1 LDREQ R1, =FILE ID - 0x83 BEQ .Load @To HERE and paste after this line to add more models, change the CMP value to the nybble setting .Load: ADD R0, R0, #0x3F4 BX R12

Uses nybble 9 and applies to all platforms that use the standard platform texture. Can be used in tandem with the Flimsy Lift code.
Posted on 09-25-16, 12:51 am
Fuzzy
That MvL Hacker

Karma: 1593
Posts: 95/787
Since: 04-11-15
I have a request, skawo, could you make an ASM that makes any boss not spawn a key when killed
_________________________
Here's my MvL Hacking thread

Consider joining the NSMB DS Hacking Discord Server!

#HakingNoMore
Posted on 09-25-16, 01:10 am (rev. 1 by  skawo on 09-25-16, 01:11 am)


Karma: 19752
Posts: 712/1100
Since: 04-02-13
No Boss Key:
repl_02130020_ov_0E: repl_02130B40_ov_0F: repl_021304D8_ov_10: repl_021300C0_ov_11: repl_02130708_ov_12: repl_02135264_ov_13: BX LR

Maybe. I don't guarantee this will work, but it should.