12-28-2021, 08:10 PM
So in regards to the original C0 code, not the random pin C0:
I understand the 06 serial write. Pretty slick.
I'm assuming this would be a great way to replace in game text???
On to the C0 portion:
We used (-) ---> 0x1000 for activator
lis r3, 0x8071 #Get button(s) pressed, check against desired activator---> (I understand)
lhz r0, 0xFFFF8D40 (r3)---> (I understand)
andi. r0, r0, 0x1000 #Your desired button(s)-------> (Here's where you start to lose me. At this point r0 should be holding 0x1000 if pressed)
lis r3, 0x8000 #Before taking the branch, set r3 to its new value, upper 16 bits of EVA---> (I understand)
bne- button_has_been_pressed ----> (If r0 is holding 0x1000, and we AND it with 0x1000 shouldn't this be a beq- button_has_been_pressed?)
???Because they are equal, your code as it's written brings it to the next line:
I understand what the rest of it is doing pretty much, it's just the andi. conditional part and the bne- button_has_been_pressed that has me puzzled???
li r0, 0 #Nothing Pressed, Reset Button Status
stb r0, 0x3FF (r3)
blr #End C0
button_has_been_pressed: #Button Pressed, Adjust Button Status
lbz r0, 0x3FF (r3) #0 = Not Pressed #1 = Pressed
cmpwi r0, 1
beqlr- #End C0
li r0, 1
stb r0, 0x3FF (r3)
lbz r5, 0x03FE (r3) #Update Pin Config tracker
addi r5, r5, 1
cmplwi r5, 10 #Check if we went beyond 9
blt+ store_tracker
li r5, 0 #Reset tracker byte
store_tracker:
stb r5, 0x03FE (r3)
Now I think I understand what the blr's are doing. simply going to the next instruction in the LR, which is the next instruction after the C0 insert, which effectively ends the C0.
Is this correct?
Which btw, when you do a C0, where exactly in memory is it writing the code being inserted? Is this a static place where the code handler stores it?
Another question, right off the bat you begin using r3 and r5? Why those and not r12 and r11?
Thanks for your help!
Got to untie this brain knot.
I understand the 06 serial write. Pretty slick.
I'm assuming this would be a great way to replace in game text???
On to the C0 portion:
We used (-) ---> 0x1000 for activator
lis r3, 0x8071 #Get button(s) pressed, check against desired activator---> (I understand)
lhz r0, 0xFFFF8D40 (r3)---> (I understand)
andi. r0, r0, 0x1000 #Your desired button(s)-------> (Here's where you start to lose me. At this point r0 should be holding 0x1000 if pressed)
lis r3, 0x8000 #Before taking the branch, set r3 to its new value, upper 16 bits of EVA---> (I understand)
bne- button_has_been_pressed ----> (If r0 is holding 0x1000, and we AND it with 0x1000 shouldn't this be a beq- button_has_been_pressed?)
???Because they are equal, your code as it's written brings it to the next line:
I understand what the rest of it is doing pretty much, it's just the andi. conditional part and the bne- button_has_been_pressed that has me puzzled???
li r0, 0 #Nothing Pressed, Reset Button Status
stb r0, 0x3FF (r3)
blr #End C0
button_has_been_pressed: #Button Pressed, Adjust Button Status
lbz r0, 0x3FF (r3) #0 = Not Pressed #1 = Pressed
cmpwi r0, 1
beqlr- #End C0
li r0, 1
stb r0, 0x3FF (r3)
lbz r5, 0x03FE (r3) #Update Pin Config tracker
addi r5, r5, 1
cmplwi r5, 10 #Check if we went beyond 9
blt+ store_tracker
li r5, 0 #Reset tracker byte
store_tracker:
stb r5, 0x03FE (r3)
Now I think I understand what the blr's are doing. simply going to the next instruction in the LR, which is the next instruction after the C0 insert, which effectively ends the C0.
Is this correct?
Which btw, when you do a C0, where exactly in memory is it writing the code being inserted? Is this a static place where the code handler stores it?
Another question, right off the bat you begin using r3 and r5? Why those and not r12 and r11?
Thanks for your help!
Got to untie this brain knot.