Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The following function calculates and saves the checksum of a save file in the game Gladius (GC version, PowerPC architecture)
- # A save game on the memory card consists of 3 save files and one general part that saves the information that is displayed in the load/save screen.
- # The general data and the save file data doesn't have to be the same.
- # You can load a save file that shows an Ursula playthrough that actually loads a Valens file.
- # But if the checksum of the save file is wrong the game won't load it and will show an error message.
- # There can be other values that have to be correct, like a time stamp at the start of the file, but I haven't tested that much.
- # r3 = start address (points to the save file data that will be written to the memory card (or hdd on XBox)
- # r4 = lengh
- # r5 = address to save the checksum to
- .globl Function_0x80212004
- Function_0x80212004: # 0x80212004
- stwu sp, -0x180(sp)
- lis r6, unk_802e30c0@h
- lis r7, 0x802e
- stmw r14, 0x138(sp)
- addi r14, r6, unk_802e30c0@l
- li r15, 0x0
- lwz r16, 0x20(r14)
- lwzu r0, 0x3080(r7)
- stw r16, 0x128(sp)
- lwz r16, 0x24(r14)
- stw r0, 0x108(sp)
- lwz r0, 0x4(r7)
- stw r16, 0x110(sp)
- lwz r16, 0x28(r14)
- stw r0, 0x10c(sp)
- lwz r18, 0x8(r7)
- stw r16, 0x114(sp)
- lwz r16, 0x2c(r14)
- lwz r19, 0xc(r7)
- stw r16, 0x118(sp)
- lwz r16, 0x30(r14)
- lwz r20, 0x10(r7)
- stw r16, 0x11c(sp)
- lwz r16, 0x34(r14)
- lwz r21, 0x14(r7)
- stw r16, 0x120(sp)
- lwz r16, 0x38(r14)
- lwz r22, 0x18(r7)
- stw r16, 0x124(sp)
- lwz r16, 0x108(sp)
- lwz r23, 0x1c(r7)
- stw r16, 0x48(sp)
- lwz r16, 0x10c(sp)
- lwz r24, 0x20(r7)
- stw r16, 0x4c(sp)
- lwz r16, 0x128(sp)
- lwz r25, 0x24(r7)
- stw r16, 0x28(sp)
- lwz r16, 0x110(sp)
- lwz r26, 0x28(r7)
- stw r16, 0x2c(sp)
- lwz r16, 0x114(sp)
- lwz r27, 0x2c(r7)
- stw r16, 0x30(sp)
- lwz r16, 0x118(sp)
- lwz r28, 0x30(r7)
- stw r16, 0x34(sp)
- lwz r16, 0x11c(sp)
- lwz r29, 0x34(r7)
- stw r16, 0x38(sp)
- lwz r16, 0x120(sp)
- lwz r30, 0x38(r7)
- lwz r31, 0x3c(r7)
- lwz r12, 0x0(r14)
- lwz r11, 0x4(r14)
- lwz r10, 0x8(r14)
- lwz r9, 0xc(r14)
- lwz r8, 0x10(r14)
- lwz r7, 0x14(r14)
- lwz r6, 0x18(r14)
- lwz r0, 0x1c(r14)
- lwz r14, 0x3c(r14)
- stw r16, 0x3c(sp)
- lwz r16, 0x124(sp)
- stw r18, 0x50(sp)
- stw r19, 0x54(sp)
- stw r20, 0x58(sp)
- stw r21, 0x5c(sp)
- stw r22, 0x60(sp)
- stw r23, 0x64(sp)
- stw r24, 0x68(sp)
- stw r25, 0x6c(sp)
- stw r26, 0x70(sp)
- stw r27, 0x74(sp)
- stw r28, 0x78(sp)
- stw r29, 0x7c(sp)
- stw r30, 0x80(sp)
- stw r31, 0x84(sp)
- stw r12, 0x8(sp)
- stw r11, 0xc(sp)
- stw r10, 0x10(sp)
- stw r9, 0x14(sp)
- stw r8, 0x18(sp)
- stw r7, 0x1c(sp)
- stw r6, 0x20(sp)
- stw r0, 0x24(sp)
- stw r16, 0x40(sp)
- stw r14, 0x44(sp)
- mtctr r4
- cmpwi r4, 0x0
- beq- branch_0x80212248
- branch_0x80212170:
- lbz r16, 0x0(r3)
- srwi r17, r15, 8
- lwz r4, 0x108(sp)
- addi r3, r3, 0x1
- stw r18, 0x90(sp)
- stw r4, 0x88(sp)
- xor r4, r15, r16
- lwz r15, 0x10c(sp)
- clrlslwi r16, r4, 28, 2
- stw r19, 0x94(sp)
- stw r15, 0x8c(sp)
- rlwinm r15, r4, 30, 26, 29
- addi r4, sp, 0x88
- stw r20, 0x98(sp)
- stw r21, 0x9c(sp)
- stw r22, 0xa0(sp)
- stw r23, 0xa4(sp)
- stw r24, 0xa8(sp)
- stw r25, 0xac(sp)
- stw r26, 0xb0(sp)
- stw r27, 0xb4(sp)
- stw r28, 0xb8(sp)
- stw r29, 0xbc(sp)
- stw r30, 0xc0(sp)
- stw r31, 0xc4(sp)
- lwzx r15, r4, r15
- lwz r4, 0x128(sp)
- stw r12, 0xc8(sp)
- stw r4, 0xe8(sp)
- lwz r4, 0x110(sp)
- stw r11, 0xcc(sp)
- stw r4, 0xec(sp)
- lwz r4, 0x114(sp)
- stw r10, 0xd0(sp)
- stw r4, 0xf0(sp)
- lwz r4, 0x118(sp)
- stw r9, 0xd4(sp)
- stw r4, 0xf4(sp)
- lwz r4, 0x11c(sp)
- stw r8, 0xd8(sp)
- stw r4, 0xf8(sp)
- lwz r4, 0x120(sp)
- stw r7, 0xdc(sp)
- stw r4, 0xfc(sp)
- lwz r4, 0x124(sp)
- stw r6, 0xe0(sp)
- stw r4, 0x100(sp)
- addi r4, sp, 0xc8
- stw r0, 0xe4(sp)
- stw r14, 0x104(sp)
- lwzx r4, r4, r16
- xor r4, r15, r4
- xor r15, r17, r4
- bdnz+ branch_0x80212170
- branch_0x80212248:
- stw r15, 0x0(r5) # save checksum
- lwz r0, 0x0(r5)
- cmplwi r0, 0x0
- bne- branch_0x80212260
- li r0, 0x1
- stw r0, 0x0(r5)
- branch_0x80212260:
- lwz r3, 0x0(r5)
- addis r0, r3, 0x1
- cmplwi r0, 0xffff
- bne- branch_0x80212278
- li r0, 0x2
- stw r0, 0x0(r5)
- branch_0x80212278:
- li r3, 0x1
- lmw r14, 0x138(sp)
- addi sp, sp, 0x180
- blr
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement