Country Flag Randomizer [Sponge]
#1
Country Flag Randomizer [Sponge]

Constantly randomizes the country flag you have set. Only countries with actual flags are set, countries without are ignored.

PAL
C0000000 00000018
7D8802A6 9421FF78
BC610008 38600001
38800089 3D80800F
618C2EE0 7D8803A6
4E800021 5460C00E
64000001 9001007C
38610080 3C808089
60845388 38A40063
38800007 5406463E
4CC63182 3D808001
618C1938 7D8803A6
4E800021 3D80809C
818C1E38 2C0C0000
41820048 818C0000
2C0C0000 4182003C
818C025C 2C0C0000
41820030 386C01C8
38810080 3D808063
618CE328 7D8803A6
4E800021 2C030000
41820010 8161007C
3D808043 916CABD8
B8610008 38210088
7D8803A6 4E800020

NTSC-U
C0000000 00000018
7D8802A6 9421FF78
BC610008 38600001
38800089 3D80800F
618C2E40 7D8803A6
4E800021 5460C00E
64000001 9001007C
38610080 3C808088
6084FA90 38A40063
38800007 5406463E
4CC63182 3D808001
618C0DD8 7D8803A6
4E800021 3D80809C
818CD508 2C0C0000
41820048 818C0000
2C0C0000 4182003C
818C025C 2C0C0000
41820030 386C01C8
38810080 3D808060
618CCF08 7D8803A6
4E800021 2C030000
41820010 8161007C
3D808042 916C6858
B8610008 38210088
7D8803A6 4E800020

NTSC-J
C0000000 00000018
7D8802A6 9421FF78
BC610008 38600001
38800089 3D80800F
618C2E00 7D8803A6
4E800021 5460C00E
64000001 9001007C
38610080 3C808089
608449D8 38A40063
38800007 5406463E
4CC63182 3D808001
618C185C 7D8803A6
4E800021 3D80809C
818C0E98 2C0C0000
41820048 818C0000
2C0C0000 4182003C
818C025C 2C0C0000
41820030 386C01C8
38810080 3D808063
618CD994 7D8803A6
4E800021 2C030000
41820010 8161007C
3D808043 916CA558
B8610008 38210088
7D8803A6 4E800020

NTSC-K
C0000000 00000018
7D8802A6 9421FF78
BC610008 38600001
38800089 3D80800F
618C2F58 7D8803A6
4E800021 5460C00E
64000001 9001007C
38610080 3C808088
60843798 38A40063
38800007 5406463E
4CC63182 3D808001
618C19A0 7D8803A6
4E800021 3D80809B
818C0478 2C0C0000
41820048 818C0000
2C0C0000 4182003C
818C025C 2C0C0000
41820030 386C01C8
38810080 3D808062
618CC640 7D8803A6
4E800021 2C030000
41820010 8161007C
3D808042 916C8BF8
B8610008 38210088
7D8803A6 4E800020

Code:
.set region, '' # Specify which region to compile for
.if    (region == 'P' || region == 'p') # RMCP
    .set utilRandom, 0x800F2EE0
    .set flagString, 0x80895388
    .set snprintf, 0x80011938
    .set menuData, 0x809C1E38
    .set iconPaneExists, 0x8062E328
    .set flagLoc, 0x8042ABD8
.elseif (region == 'E' || region == 'e' || region == 'U' || region == 'u') # RMCE
    .set utilRandom, 0x800F2E40
    .set flagString, 0x8088FA90
    .set snprintf, 0x80010DD8
    .set menuData, 0x809BD508
    .set iconPaneExists, 0x805FCF08
    .set flagLoc, 0x80426858
.elseif (region == 'J' || region == 'j') # RMCJ
    .set utilRandom, 0x800F2E00
    .set flagString, 0x808949D8
    .set snprintf, 0x8001185C
    .set menuData, 0x809C0E98
    .set iconPaneExists, 0x8062D994
    .set flagLoc, 0x8042A558
.elseif (region == 'K' || region == 'k') # RMCK
    .set utilRandom, 0x800F2F58
    .set flagString, 0x80883798
    .set snprintf, 0x800119A0
    .set menuData, 0x809B0478
    .set iconPaneExists, 0x8061C640
    .set flagLoc, 0x80418BF8
.else # Invalid Region
        .abort
.endif

mflr r12
stwu sp, -0x88 (sp)
stmw r3, 0x8 (sp) # Push the stack

li r3, 0x1 # First valid flag entry
li r4, 0x89 # One above the last valid flag entry
lis r12, utilRandom@ha
ori r12, r12, utilRandom@l
mtlr r12
blrl # Call utilRandom to randomize the country byte

slwi r0, r3, 0x18 # Shift the byte 24 bits to the left
oris r0, r0, 0x0001 # Set the city to 1 in order for it to appear
stw r0, 0x7C (sp) # Store for later use
addi r3, sp, 0x80
lis r4, flagString@h
ori r4, r4, flagString@l # Load flag string for printf call
addi r5, r4, 0x63
li r4, 0x7
rlwinm r6, r0, 8, 24, 31
crclr 6
lis r12, snprintf@ha
ori r12, r12, snprintf@l
mtlr r12
blrl # Call snprintf

lis r12, menuData@ha
lwz r12, menuData@l (r12)
cmpwi r12, 0
beq end
lwz r12, 0 (r12)
cmpwi r12, 0
beq end
lwz r12, 0x25C (r12)
cmpwi r12, 0
beq end # Three checks are needed as all three will cause null pointers due to the C0 codetype executing before they're setup
addi r3, r12, 0x1C8
addi r4, sp, 0x80
lis r12, iconPaneExists@ha
ori r12, r12, iconPaneExists@l
mtlr r12
blrl # Call the pane function

cmpwi r3, 0
beq end # Exit if no flag can be found, we only want to write valid countries
lwz r11, 0x7C (sp) # Load the country value we stored earlier
lis r12, flagLoc@ha
stw r11, flagLoc@l(r12) # Overwrite any previously set country

end:
lmw r3, 0x8 (sp) # Pop the stack
addi sp, sp, 0x88
mtlr r12
#blr # (Uncomment if not compiling with PyiiASMH)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)