-snip-
#8
(12-18-2019, 02:40 PM)Vega Wrote: After more analysis, r18 & r22  are some sort of a conditional-status trackers, while r14, r17, & r20 values are being altered depending on the 'status' of the conditional trackers. r15 is used for the mem81 address reference where r14/17/20 are stored and updated at. Other rainbow codes will thus use the mem81 values and adjust accordingly.

It's obviously a no-no to use the global variable registers like this.

I adjusted my source more... After debugging the code a tiny bit, all the global variable registers that are being used always start at 0. So ill just load up unused memory from the vector area for all custom global variable register values. Then update the vector area accordingly. mem81 will not be touched so other rainbow codes should still function right. In between all of this, a stack push will be done so the real variable register values don't get effected. Hopefully this will work unless I'm missing something super obvious here...

Code:
stwu sp, -0x50 (sp) #Stack push
stmw r14, 0x8 (sp) #Backup global variable values

lis r11, 0x8000 #Set vector address
lmw r14, 0x0498 (r11) #Load custom global variable values

addi r22,r22,1
cmpwi r22,5 #XX value in code for user to fill in, 5 used for compilation purposes
blt- 0xA8
cmpwi r18,0
bne- 0x0C
li r20,255
li r18,1
cmpwi r18,1
bne- 0x14
addi r14,r14,1
cmpwi r14,255
bne- 0x08
li r18,2
cmpwi r18,2
bne- 0x14
subi r20,r20,1
cmpwi r20,0
bne- 0x08
li r18,3
cmpwi r18,3
bne- 0x14
addi r17,r17,1
cmpwi r17,255
bne- 0x08
li r18,4
cmpwi r18,4
bne- 0x14
subi r14,r14,1
cmpwi r14,0
bne- 0x08
li r18,5
cmpwi r18,5
bne- 0x14
addi r20,r20,1
cmpwi r20,255
bne- 0x08
li r18,6
cmpwi r18,6
bne- 0x14
subi r17,r17,1
cmpwi r17,0
bne- 0x08
li r18,1
li r22,0

lis r12, 0x8170 #Set mem81 address

stb r20,0(r12) #Update mem81 values
stb r14,1(r12)
stb r17,2(r12)

stmw r14, 0x0498 (r11) #Update custom global variable values

lwz r14, 0x8 (sp) #Recover global variable values
addi sp, sp, 0x50 #Stack pop

cmpwi r0, 0 #Default instruction
The game blackscreens upon booting the Title Screen
Reply


Messages In This Thread
-snip- - by Sponge - 12-03-2019, 11:59 PM
RE: Rainbow Function code - by Vega - 12-04-2019, 01:57 AM
RE: Rainbow Function code - by Sponge - 12-04-2019, 05:46 PM
RE: Rainbow Function code - by Vega - 12-04-2019, 11:47 PM
RE: Rainbow Function code - by Vega - 12-18-2019, 02:31 AM
RE: Rainbow Function code - by Sponge - 12-18-2019, 01:05 PM
RE: Rainbow Function code - by Vega - 12-18-2019, 02:40 PM
RE: Rainbow Function code - by Sponge - 12-18-2019, 03:16 PM
RE: Rainbow Function code - by Vega - 12-18-2019, 04:27 PM
RE: Rainbow Function code - by Sponge - 12-18-2019, 04:52 PM
RE: Rainbow Function code - by Vega - 12-18-2019, 07:48 PM
RE: Rainbow Function code - by Sponge - 12-18-2019, 07:55 PM
RE: Rainbow Function code - by Vega - 12-18-2019, 08:02 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)