• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[ASM & Hex] [EM] MWisBest's colored stats display

8
Posts
4
Years
    • Seen Dec 28, 2020
    I combined this into 1 routine and cut the total size down a lot. All credit to DizzyEgg of course, this is nothing compared to creating the mod in the first place.

    Code:
    .text
    .thumb
    .thumb_func
    .align 2
    
    @ [B][COLOR="Red"]0x1C379E: 02 30 00 4A 10 47 XX+1 XX XX 08[/COLOR][/B]
    @ [B][COLOR="Red"]0x1C3864: 00 4A 10 47 XX+1 XX XX 08[/COLOR][/B]
    
    main:
    	@ at this point... r0 contains our return address (- 8). Convenient!
    	push {r5-r7}
    	
    	@ save return address for later.
    	mov r6, r0
    	add r6, #0x8
    	
    	@ to determine what function we were called from:
    	@ if it was right stats, r9 is 0. if it was left stats, r9 has something in it.
    	mov r7, r9 @ can't really use hi registers in thumb, mov it down.
    	@ so, to check the function type: cmp r7, #0. eq means right stats.
    	
    	sub sp, sp, #0x20
    	ldr r0, [r4] @pokemon summary pointer. we're free to use r4 after this.
    	add r0, #0xA3 @poke nature
    	ldrb r1, [r0]
    	ldr r0, nature_stat_table
    	
    	mov r2, #5
    	mul r2, r1
    	
    	mov r1, sp
    	mov r5, #0
    	
    	add r2, r2, r0 @r2 contains nature info
    	cmp r7, #0
    	beq right_stats_begin
    
    
    @@ LEFT STAT COLORING BEGIN @@@
    
    left_stats_begin:
    	ldr r3, left_stats_string
    
    handle_hp:
    	ldrb r0, [r3, r5]
    	strb r0, [r1, r5]
    	add r5, #1
    	cmp r5, #6
    	bne handle_hp
    	add r3, #6
    	add r1, #6
    	mov r5, #0
    
    handle_atk:
    	ldrb r0, [r2]
    	cmp r0, #1
    	beq red_font_atk
    	cmp r0, #0xFF
    	bne copy_atk
    	bl blue_font
    	b copy_atk
    
    red_font_atk:
    	bl red_font
    
    copy_atk:
    	ldrb r0, [r3, r5]
    	strb r0, [r1, r5]
    	add r5, #1
    	cmp r5, #3
    	bne copy_atk
    	add r3, #3
    	add r1, #3
    	mov r5, #0
    
    handle_def:
    	add r2, #1
    	ldrb r0, [r2]
    	cmp r0, #1
    	beq red_font_def
    	cmp r0, #0xFF
    	beq blue_font_def
    	bl default_font
    	b copy_def
    
    red_font_def:
    	bl red_font
    	b copy_def
    
    blue_font_def:
    	bl blue_font
    
    copy_def:
    	ldrb r0, [r3, r5]
    	strb r0, [r1, r5]
    	add r5, #1
    	cmp r5, #3
    	bne copy_def
    	b return
    
    @@@ LEFT STAT COLORING END @@
    
    
    @@@ RIGHT STAT COLORING BEGIN @@@
    
    right_stats_begin:
    	add r2, #3 @r2 contains beg of spatk stat
    	ldr r3, right_stats_string
    
    handle_spatk:
    	ldrb r0, [r2]
    	cmp r0, #1
    	beq red_font_spatk
    	cmp r0, #0xFF
    	bne copy_spatk
    	bl blue_font
    	b copy_spatk
    
    red_font_spatk:
    	bl red_font
    
    copy_spatk:
    	ldrb r0, [r3, r5]
    	strb r0, [r1, r5]
    	add r5, #1
    	cmp r5, #3
    	bne copy_spatk
    	add r3, #3
    	add r1, #3
    	mov r5, #0
    
    handle_spdef:
    	add r2, #1
    	ldrb r0, [r2]
    	cmp r0, #1
    	beq red_font_spdef
    	cmp r0, #0xFF
    	beq blue_font_spdef
    	bl default_font
    	b copy_spdef
    
    red_font_spdef:
    	bl red_font
    	b copy_spdef
    
    blue_font_spdef:
    	bl blue_font
    
    copy_spdef:
    	ldrb r0, [r3, r5]
    	strb r0, [r1, r5]
    	add r5, #1
    	cmp r5, #3
    	bne copy_spdef
    	add r3, #3
    	add r1, #3
    	mov r5, #0
    
    handle_spd:
    	sub r2, #2
    	ldrb r0, [r2]
    	cmp r0, #1
    	beq red_font_spd
    	cmp r0, #0xFF
    	beq blue_font_spd
    	bl default_font
    	b copy_spd
    
    red_font_spd:
    	bl red_font
    	b copy_spd
    
    blue_font_spd:
    	bl blue_font
    
    copy_spd:
    	ldrb r0, [r3, r5]
    	strb r0, [r1, r5]
    	add r5, #1
    	cmp r5, #3
    	bne copy_spd
    	b return
    
    @@@ RIGHT STAT COLORING END @@@
    
    
    @@@ FONT FUNCTIONS BEGIN @@@
    
    blue_font: @FC 01 07
    	mov r4, #7 @color of the lowered stat
    	b font_common
    
    red_font: @FC 01 05
    	mov r4, #5 @color of the raised stat
    	b font_common
    
    default_font: @FC 01 01
    	mov r4, #1 @color of the regular stats
    	@ just fall through to font_common (no need to branch)
    
    font_common:
    	mov r0, #0xFC
    	strb r0, [r1]
    	add r1, #1
    	mov r0, #1
    	strb r0, [r1]
    	add r1, #1
    	strb r4, [r1]
    	add r1, #1
    	bx lr
    
    @@@ FONT FUNCTIONS END @@@
    
    
    return:
    	ldr r0, displayed_string
    	mov r1, sp
    	ldr r2, special_f7_string_fct
    	bl x_r2
    	cmp r7, #0
    	beq skip_mov_r0_r9
    	mov r0, r9
    skip_mov_r0_r9:
    	add sp, sp, #0x20
    	mov r2, r6
    	pop {r5-r7}
    x_r2:
    	bx r2
    
    
    .align 2
    nature_stat_table: .word 0x0831E818
    left_stats_string: .word 0x0861CE82
    right_stats_string: .word 0x0861CE8E
    displayed_string: .word 0x02021FC4
    special_f7_string_fct: .word 0x081AFC29

    /showpost.php?p=9611218&postcount=1140

    This routine highlights the numeric values of increasing/decreasing stats, but I would like for it to highlight the stat labels instead (ex. ATTACK, DEFENSE etc). How can I approach this? I will also donate to anyone who can do this for me.
     
    Back
    Top