Lol, look at this source, Does anybody wanna optimize it?
#1
This is for a better color transition in my most recent code that I co-created w/ Sponge, the Mii Head rainbow color cycler.

I was able to achieve Max Color 'Fluidity' with the source below, but it is very unoptimized. The code (C0 type) WORKS btw. I was under the impression that Xor, Xori, and Xoris had RC options, but they don't. So ofc, there's something I'm doing that is not correct for optimization.

The rainbow color spectrum startsand ends at Red. Sorry for lack of notes.

Code:
lis r12, 0x8000
lwz r11, 0x0998 (r12)
srwi r11, r11, 8

lbz r10, 0x099C (r12)

cmpwi r11, 0
bne- skip_initial_setup

lis r11, 0x00FF
li r10, 0

skip_initial_setup:
cmpwi r10, 0
beq- increase_2nd_byte
cmpwi r10, 1
beq- decrease_1st_byte
cmpwi r10, 2
beq- increase_3rd_byte
cmpwi r10, 3
beq- decrease_2nd_byte
cmpwi r10, 4
beq- increase_1st_byte

#decrease_3rd_byte
subi r11, r11, 0x0001
xoris r0, r11, 0x00FF
cmpwi r0, 0
bne- update_then_shift_back

li r10, 0

b update_then_shift_back

increase_2nd_byte:
addi r11, r11, 0x0100
lis r0, 0x00FF
ori r0, r0, 0xFF00
xor r0, r11, r0
cmpwi r0, 0
bne- update_then_shift_back

li r10, 1

b update_then_shift_back

decrease_1st_byte:
subis r11, r11, 0x0001
xori r0, r11, 0xFF00
cmpwi r0, 0
bne- update_then_shift_back

li r10, 2

b update_then_shift_back

increase_3rd_byte:
addi r11, r11, 0x0001
xori r0, r11, 0xFFFF
cmpwi r0, 0
bne- update_then_shift_back

li r10, 3

b update_then_shift_back

decrease_2nd_byte:
subi r11, r11, 0x0100
xori r0, r11, 0x00FF
cmpwi r0, 0
bne- update_then_shift_back

li r10, 4

b update_then_shift_back

increase_1st_byte:
addis r11, r11, 0x0001
lis r0, 0x00FF
ori r0, r0, 0x00FF
xor r0, r11, r0
cmpwi r0, 0
bne- update_then_shift_back

li r10, 5

update_then_shift_back:
slwi r11, r11, 8
ori r11, r11, 0x00FF

stw r11, 0x0998 (r12)
stb r10, 0x099C (r12)

#Find Region of Game

lbz r0, 0x5F27 (r12) #Instruction here is vital. Virtually impossible for this to be modded by something unrelated

lis r9, 0x8024 #All Mii Head Addr's start with this upper 16 bits

cmpwi r0, 0xEC #pal
ori r12, r9, 0xB8B0
beq- set_ctr

cmpwi r0, 0x10 #japan
ori r12, r9, 0xB260
beq- set_ctr

cmpwi r0, 0x54 #korea
ori r12, r9, 0xB688
beq- set_ctr

#usa
ori r12, r9, 0xB598

#Loop Stuff, Write Color

set_ctr:
li r0, 40 #40 (0x28) total consecutive words at memory to be rewritten
mtctr r0

loop:
stw r11, 0 (r12)

dcbst 0, r12 #These 4 instructions for clearing cache, its most likely needed. Too lazy to test w/o, lul.
sync
icbi 0, r12
isync

addi r12, r12, 4
bdnz+ loop
Reply
#2
I may try just for the practice. Also, as far as my testing has gone, the cache only needs to be cleared if instructions are being edited, since the game has these stored in the cache (which it never actually updates on it's own due to the game never dynamically relocating executable code), and the cache thus needs to be updated for new instructions to function properly. If the CPU reads the memory instead of running over it as code, it will read the proper value since it grabs the value from the RAM and not the cache.

At least this is what I've gathered about the cache anyways Tongue
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply
#3
Afaik, cache effects data too, not just instructions.

Fyi, for some reason, this source only works on Dolphin.
Reply
#4
Interesting to know. At least it must be waaaay less likely to fail then cause I've never had issues with memory

EDIT: Maybe the compatibility issue is the same thing that plagued the Code Patcher and RAM Watch codes?
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply
#5
Ye it's something with the gecko code handler for the Wii console. W/e the issue is, somehow Dolphin can 'bypass' it. I had a person on Discord try diff hooktypes and the source would still jack up the colors.
Reply
#6
Which codehandler is being used? Why not try injecting dolphin's codehandler.bin through riivolution? Or if you'd like, I can patch it into a main.dol for you to try. Because it's time for us big boiz to figure this crap out. It's time to stop working around it, and to stop discontinuing support for codes because of this problem.
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply
#7
I'm out of town for a few days without my laptop so there's not much I can do. Work will take up the bulk of my time. First I think we should try running this source on the memcpy address via standard C2 ASM code. If it works on that then we know for certain it's a code handler issue and another issue to chalk down with C0 codetype.

We could... rewrite the Gecko code handler and get rid of all bugs with C0 and F6 codes. Plus get rid of unused stuff. The only problem is we need the dev of USB loader gx (cyan on gbatemp iirc) to update the code handler in the next version update or add our modified one as an option in ocarina. Hell, at that point we could write a new code handler from scratch, one made just for mkwii.
Reply
#8
(01-28-2020, 03:10 PM)Vega Wrote: I'm out of town for a few days without my laptop so there's not much I can do. Work will take up the bulk of my time. First I think we should try running this source on the memcpy address via standard C2 ASM code. If it works on that then we know for certain it's a code handler issue and another issue to chalk down with C0 codetype.

We could... rewrite the Gecko code handler and get rid of all bugs with C0 and F6 codes. Plus get rid of unused stuff. The only problem is we need the dev of USB loader gx (cyan on gbatemp iirc) to update the code handler in the next version update or add our modified one as an option in ocarina. Hell, at that point we could write a new code handler from scratch, one made just for mkwii.
I think it's a project worth taking up. I don't know why people haven't tried to fix it sooner Tongue I think if we cleaned up the code handler, got rid of the unused codetypes (like you said), and added a way (which I have some ideas) to have HUUUGE code space, I think a lot of people would be thankful/happy. Ofc we would use the one found in Dolphin as a base to work from since it seems to be the least buggy.

Also, for any code types that edit instructions/memory mid game (00, 02, 04, 06, 08, so on) we would have it properly update the cache. Because when I was using the Wiimm's SZS Tools codehandler in a modified DOL on Dolphin, the instructions weren't working properly and it was very frustrating lol.
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)