View Single Post
  #154    
Old August 20th, 2011 (4:21 PM). Edited August 20th, 2011 by Missingyep.
Missingyep Missingyep is offline
     
    Join Date: Jul 2010
    Posts: 275
    I have managed to create ASM code that successfully displays a secondary message box with header text and body text.


    The capabilities and limitations of the code that I know of are as follows:
    • It has header and body text. You can specify strings for both, but you can't, say, display only a header.
    • The position and size cannot yet be changed. The underlying code is capable of taking single-byte X and Y arguments, but currently I just force them both to 0. SEE NEW CODE AT BOTTOM
    • I don't know if it works with \n, \l, \p, or any other formatting control codes. I didn't try any.
    • To hide the box, you can call hidecoins. It requires X and Y arguments, but doesn't appear to use them; it will hide the secondary box regardless of position and size.
    Here's an example script to demonstrate how you would load your strings and call the ASM:

    Spoiler:
    Code:
    #dynamic 0x800000
    
    #org @start
    lock
    loadpointer 0x0 @sHeader // Header text
    loadpointer 0x1 @sBody // Body text
    callasm 0x8780001 // Change this to wherever you place the ASM
    release
    end
    
    #org @sHeader
    = HEAD
    
    #org @sBody
    = BODY


    And finally, the ASM:

    Spoiler:
    Code:
    .align 2
    .thumb
    
    SHOWCOINS:
    push {lr}
    push {r0-r7}
    mov r5, #0x0
    mov r4, #0x0
    ldr r0, UNKNOWN_DATA_0
    ldr r1, SHOWCOINS_UNK_1
    bl CALL_R1
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    cmp r0, #0x1
    beq SHOWCOINS_RETURN
    mov r1, r5
    mov r2, r4
    bl SECONDARY
    b SHOWCOINS_RETURN
    
    SHOWCOINS_RETURN:
    pop {r0-r7}
    pop {pc}
    
    
    
    SECONDARY:
    push {lr}
    push {r0-r7}
    add sp, #-0x20
    mov r6, r0
    mov r4, r1
    mov r3, r2
    lsl r4, r4, #0x18
    lsl r3, r3, #0x18
    mov r0, #0x80
    lsl r0, r0, #0x11
    add r4, r4, r0
    lsr r4, r4, #0x18
    add r3, r3, r0
    lsr r3, r3, #0x18
    mov r0, #0x8
    str r0, [sp]
    mov r0, #0x3
    str r0, [sp, #0x4]
    mov r0, #0xF
    str r0, [sp, #0x8]
    mov r0, #0x20
    str r0, [sp, #0xC]
    add r0, sp, #0x10
    mov r1, #0x0
    mov r2, r4
    ldr r4, UNKNOWN_FUNCTION_0
    bl CALL_R4
    ldr r0, [sp, #0x10]
    ldr r1, [sp, #0x14]
    str r0, [sp, #0x18]
    str r1, [sp, #0x1C]
    ldr r4, UNKNOWN_DATA_1
    add r0, sp, #0x18
    ldr r5, UNKNOWN_FUNCTION_1
    bl CALL_R5
    strb r0, [r4]
    ldrb r0, [r4]
    mov r1, #0x0
    ldr r2, UNKNOWN_FUNCTION_2
    bl CALL_R2
    ldrb r0, [r4]
    ldr r5, UNKNOWN_FUNCTION_3
    bl CALL_R5
    ldrb r0, [r4]
    ldr r5, UNKNOWN_DATA_2
    mov r1, r5
    mov r2, #0xD0
    ldr r3, UNKNOWN_FUNCTION_4
    bl CALL_R3
    ldrb r0, [r4]
    mov r1, #0x0
    mov r2, r5
    mov r3, #0xD
    ldr r6, UNKNOWN_FUNCTION_5
    bl CALL_R6
    ldrb r0, [r4]
    ldr r2, SCRIPT_BANK_0
    ldr r2, [r2]
    mov r3, #0x0
    str r3, [sp]
    mov r1, #0xFF
    str r1, [sp, #0x4]
    str r3, [sp, #0x8]
    mov r1, #0x2
    ldr r7, UNKNOWN_FUNCTION_6
    bl CALL_R7
    mov r0, r6
    bl SECONDARY_LOAD_BODY
    add sp, #0x20
    pop {r0-r7}
    pop {pc}
    
    
    
    SECONDARY_LOAD_BODY:
    push {lr}
    push {r0-r7}
    add sp, #-0xC
    mov r1, r0
    ldr r0, BUFFER_RAM_OFFSET
    mov r2, #0x1
    mov r3, #0x4
    ldr r6, UNKNOWN_FUNCTION_7
    bl CALL_R6
    ldr r4, STRING_RAM_OFFSET
    ldr r1, SCRIPT_BANK_1
    ldr r1, [r1]
    mov r0, r4
    ldr r6, BODY_STRING_LOADER
    bl CALL_R6
    mov r0, #0x0
    mov r1, r4
    mov r2, #0x0
    ldr r6, UNKNOWN_FUNCTION_8
    bl CALL_R6
    ldr r1, UNKNOWN_DATA_1
    ldrb r1, [r1]
    mov r3, #0x40
    sub r3, r3, r0
    lsl r3, r3, #0x18
    lsr r3, r3, #0x18
    mov r0, #0xC
    str r0, [sp]
    mov r0, #0x0
    str r0, [sp, #0x4]
    str r0, [sp, #0x8]
    mov r0, r1
    mov r1, #0x0
    mov r2, r4
    ldr r6, UNKNOWN_FUNCTION_6
    bl CALL_R6
    add sp, #0xC
    pop {r0-r7}
    pop {pc}
    
    CALL_R1:
    bx r1
    bx lr
    
    CALL_R2:
    bx r2
    bx lr
    
    CALL_R3:
    bx r3
    bx lr
    
    CALL_R4:
    bx r4
    bx lr
    
    CALL_R5:
    bx r5
    bx lr
    
    CALL_R6:
    bx r6
    bx lr
    
    CALL_R7:
    bx r7
    bx lr
    
    .align 2
    SCRIPT_BANK_0:
    .word 0x03000F14
    
    SCRIPT_BANK_1:
    .word 0x03000F18
    
    UNKNOWN_DATA_0:
    .word 0x0809D6D5
    
    UNKNOWN_DATA_1:
    .word 0x02039A28
    
    UNKNOWN_DATA_2:
    .word 0x0000021D
    
    SHOWCOINS_UNK_1:
    .word 0x081119D5
    
    UNKNOWN_FUNCTION_0:
    .word 0x0810FE51
    
    UNKNOWN_FUNCTION_1:
    .word 0x08003CE5
    
    UNKNOWN_FUNCTION_2:
    .word 0x0800445D
    
    UNKNOWN_FUNCTION_3:
    .word 0x08003FA1
    
    UNKNOWN_FUNCTION_4:
    .word 0x0814FF2D
    
    UNKNOWN_FUNCTION_5:
    .word 0x0810F2E9
    
    UNKNOWN_FUNCTION_6:
    .word 0x08002C49
    
    UNKNOWN_FUNCTION_7:
    .word 0x08008E79
    
    UNKNOWN_FUNCTION_8:
    .word 0x08005ED5
    
    BUFFER_RAM_OFFSET:
    .word 0x02021CD0
    
    STRING_RAM_OFFSET:
    .word 0x02021D18
    
    BODY_STRING_LOADER:
    .word 0x08008FCD


    This is the first fully-functional ASM code I have ever written. There is still much to be done, but this is a big step. C:

    EDIT: New code. This one allows you to specify the box X, Y, width, and height using script variables.


    Script:
    Spoiler:
    Code:
    #dynamic 0x800000
    
    #org @start
    lock
    loadpointer 0x0 @sHeader // Header text
    loadpointer 0x1 @sBody // Body text
    setvar 0x8000 0x0003 // X -- single-byte!
    setvar 0x8001 0x0001 // Y -- single-byte!
    setvar 0x8002 0x000A // Width -- single-byte!
    setvar 0x8003 0x0002 // Height -- single-byte!
    callasm 0x8780001 // Change this to wherever you place the ASM
    
    msgbox @sStandard 0x2 // just as a demonstration.
    
    hidecoins 0x00 0x00 // hides secondary box.
    release
    end
    
    #org @sHeader
    = HEAD
    
    #org @sBody
    = BODY
    
    #org @sStandard
    = STANDARD


    And new assembly:
    Spoiler:
    Code:
    .align 2
    .thumb
    
    SHOWCOINS:
    push {lr}
    push {r0-r7}
    ldr r5, SCRIPT_VAR_8000
    ldrh r5, [r5]
    ldr r4, SCRIPT_VAR_8001
    ldrh r4, [r4]
    ldr r0, UNKNOWN_DATA_0
    ldr r1, SHOWCOINS_UNK_1
    bl CALL_R1
    lsl r0, r0, #0x10
    lsr r0, r0, #0x10
    cmp r0, #0x1
    beq SHOWCOINS_RETURN
    mov r1, r5
    mov r2, r4
    bl SECONDARY
    b SHOWCOINS_RETURN
    
    SHOWCOINS_RETURN:
    pop {r0-r7}
    pop {pc}
    
    
    
    SECONDARY:
    push {lr}
    push {r0-r7}
    add sp, #-0x20
    mov r6, r0
    mov r4, r1
    mov r3, r2
    lsl r4, r4, #0x18
    lsl r3, r3, #0x18
    mov r0, #0x80
    lsl r0, r0, #0x11
    add r4, r4, r0
    lsr r4, r4, #0x18
    add r3, r3, r0
    lsr r3, r3, #0x18
    ldr r0, SCRIPT_VAR_8002
    ldrh r0, [r0]
    str r0, [sp]
    ldr r0, SCRIPT_VAR_8003
    ldrh r0, [r0]
    str r0, [sp, #0x4]
    mov r0, #0xF
    str r0, [sp, #0x8]
    mov r0, #0x20
    str r0, [sp, #0xC]
    add r0, sp, #0x10
    mov r1, #0x0
    mov r2, r4
    ldr r4, UNKNOWN_FUNCTION_0
    bl CALL_R4
    ldr r0, [sp, #0x10]
    ldr r1, [sp, #0x14]
    str r0, [sp, #0x18]
    str r1, [sp, #0x1C]
    ldr r4, UNKNOWN_DATA_1
    add r0, sp, #0x18
    ldr r5, UNKNOWN_FUNCTION_1
    bl CALL_R5
    strb r0, [r4]
    ldrb r0, [r4]
    mov r1, #0x0
    ldr r2, UNKNOWN_FUNCTION_2
    bl CALL_R2
    ldrb r0, [r4]
    ldr r5, UNKNOWN_FUNCTION_3
    bl CALL_R5
    ldrb r0, [r4]
    ldr r5, UNKNOWN_DATA_2
    mov r1, r5
    mov r2, #0xD0
    ldr r3, UNKNOWN_FUNCTION_4
    bl CALL_R3
    ldrb r0, [r4]
    mov r1, #0x0
    mov r2, r5
    mov r3, #0xD
    ldr r6, UNKNOWN_FUNCTION_5
    bl CALL_R6
    ldrb r0, [r4]
    ldr r2, SCRIPT_BANK_0
    ldr r2, [r2]
    mov r3, #0x0
    str r3, [sp]
    mov r1, #0xFF
    str r1, [sp, #0x4]
    str r3, [sp, #0x8]
    mov r1, #0x2
    ldr r7, UNKNOWN_FUNCTION_6
    bl CALL_R7
    mov r0, r6
    bl SECONDARY_LOAD_BODY
    add sp, #0x20
    pop {r0-r7}
    pop {pc}
    
    
    
    SECONDARY_LOAD_BODY:
    push {lr}
    push {r0-r7}
    add sp, #-0xC
    mov r1, r0
    ldr r0, BUFFER_RAM_OFFSET
    mov r2, #0x1
    mov r3, #0x4
    ldr r6, UNKNOWN_FUNCTION_7
    bl CALL_R6
    ldr r4, STRING_RAM_OFFSET
    ldr r1, SCRIPT_BANK_1
    ldr r1, [r1]
    mov r0, r4
    ldr r6, BODY_STRING_LOADER
    bl CALL_R6
    mov r0, #0x0
    mov r1, r4
    mov r2, #0x0
    ldr r6, UNKNOWN_FUNCTION_8
    bl CALL_R6
    ldr r1, UNKNOWN_DATA_1
    ldrb r1, [r1]
    mov r3, #0x40
    sub r3, r3, r0
    lsl r3, r3, #0x18
    lsr r3, r3, #0x18
    mov r0, #0xC
    str r0, [sp]
    mov r0, #0x0
    str r0, [sp, #0x4]
    str r0, [sp, #0x8]
    mov r0, r1
    mov r1, #0x0
    mov r2, r4
    ldr r6, UNKNOWN_FUNCTION_6
    bl CALL_R6
    add sp, #0xC
    pop {r0-r7}
    pop {pc}
    
    CALL_R1:
    bx r1
    bx lr
    
    CALL_R2:
    bx r2
    bx lr
    
    CALL_R3:
    bx r3
    bx lr
    
    CALL_R4:
    bx r4
    bx lr
    
    CALL_R5:
    bx r5
    bx lr
    
    CALL_R6:
    bx r6
    bx lr
    
    CALL_R7:
    bx r7
    bx lr
    
    .align 2
    SCRIPT_BANK_0:
    .word 0x03000F14
    
    SCRIPT_BANK_1:
    .word 0x03000F18
    
    SCRIPT_VAR_8000:
    .word 0x020370B8
    
    SCRIPT_VAR_8001:
    .word 0x020370BA
    
    SCRIPT_VAR_8002:
    .word 0x020370BC
    
    SCRIPT_VAR_8003:
    .word 0x020370BE
    
    UNKNOWN_DATA_0:
    .word 0x0809D6D5
    
    UNKNOWN_DATA_1:
    .word 0x02039A28
    
    UNKNOWN_DATA_2:
    .word 0x0000021D
    
    SHOWCOINS_UNK_1:
    .word 0x081119D5
    
    UNKNOWN_FUNCTION_0:
    .word 0x0810FE51
    
    UNKNOWN_FUNCTION_1:
    .word 0x08003CE5
    
    UNKNOWN_FUNCTION_2:
    .word 0x0800445D
    
    UNKNOWN_FUNCTION_3:
    .word 0x08003FA1
    
    UNKNOWN_FUNCTION_4:
    .word 0x0814FF2D
    
    UNKNOWN_FUNCTION_5:
    .word 0x0810F2E9
    
    UNKNOWN_FUNCTION_6:
    .word 0x08002C49
    
    UNKNOWN_FUNCTION_7:
    .word 0x08008E79
    
    UNKNOWN_FUNCTION_8:
    .word 0x08005ED5
    
    BUFFER_RAM_OFFSET:
    .word 0x02021CD0
    
    STRING_RAM_OFFSET:
    .word 0x02021D18
    
    BODY_STRING_LOADER:
    .word 0x08008FCD
    Reply With Quote