Please don't let them make me be a monkey butler
Posts: 12380
|
in C:
void world_rect(u8 type, u16 rgb, u8 overwrite, u16 x1, u16 y1, u16 x2, u16 y2, touchpad* tp) { u8 check = (type == WORLD_EMPTY) ? WORLD_SCENERY : WORLD_EMPTY; u16 x, y; u32 xy = x1 + (y1 << WORLD_SHIFT); for (y = y1; y < y2; y++) { for (x = x1; x < x2; x++) { if (overwrite == 0 || world[xy] == check) { world[xy] = type; touchpadWorld[xy] = tp; VRAM_A[xy] = rgb; } xy++; } xy += WORLD_WIDTH - x2 + x1; } }
Compiled with -O2:
.global world_rect .code 16 .thumb_func .type world_rect, %function world_rect: .LFB61: .file 1 "/Users/phil/Documents/NintendoDS/particles/source/world.c" .loc 1 33 0 push {r4, r5, r6, r7, lr} .LCFI0: mov r7, fp mov r6, sl mov r5, r9 mov r4, r8 push {r4, r5, r6, r7} .LCFI1: .LVL0: sub sp, sp, #20 .LCFI2: .loc 1 33 0 str r1, [sp, #4] ldr r1, [sp, #68] .LVL1: mov r9, r3 .LVL2: str r1, [r3, #12] add r3, sp, #56 mov r8, r2 ldrh r2, [r3] .LVL3: add r3, sp, #60 ldrh r3, [r3] mov fp, r0 mov sl, r3 add r3, sp, #64 ldrh r1, [r3] .loc 1 34 0 cmp r0, #0 beq .L2 .LVL4: mov r3, #0 str r3, [sp, #8] .LVL5: .L4: .loc 1 37 0 cmp r2, r1 bcs .L17 .loc 1 36 0 lsl r3, r2, #8 add r3, r3, r9 mov ip, r3 .LVL6: sub r1, r1, r2 .LVL7: mov r3, #0 str r3, [sp, #12] str r1, [sp] .LVL8: .L7: .loc 1 39 0 cmp r9, sl bcs .L14 mov r3, ip mov r1, #208 lsl r1, r1, #19 lsl r5, r3, #2 lsl r3, r3, #1 add r4, r3, r1 mov r2, sl mov r3, r9 ldr r6, .L23 mov r1, ip .LVL9: mov r0, #0 .LVL10: sub r7, r2, r3 b .L8 .L22: .loc 1 41 0 ldr r3, [r6] ldr r2, [sp, #8] ldrb r3, [r3, r1] cmp r3, r2 beq .L11 .L12: .loc 1 47 0 add r3, r0, #1 lsl r3, r3, #16 .loc 1 39 0 lsl r2, r7, #16 .loc 1 47 0 add r1, r1, #1 add r5, r5, #4 add r4, r4, #2 .loc 1 39 0 lsr r0, r3, #16 cmp r2, r3 beq .L21 .L8: .loc 1 41 0 mov r2, r8 cmp r2, #0 bne .L22 .L11: .loc 1 43 0 ldr r3, [r6] .LVL11: mov r2, fp strb r2, [r3, r1] .loc 1 44 0 ldr r3, .L23+4 ldr r3, [r3] ldr r2, [r3, #12] str r2, [r3, r5] .loc 1 45 0 mov r3, sp ldrh r3, [r3, #4] strh r3, [r4] b .L12 .LVL12: .L21: .loc 1 39 0 sub r3, r0, #1 lsl r3, r3, #16 lsr r3, r3, #16 add r3, r3, ip add r3, r3, #1 mov ip, r3 .LVL13: .L14: ldr r3, [sp, #12] .loc 1 37 0 ldr r1, [sp] .LVL14: .loc 1 39 0 add r3, r3, #1 lsl r3, r3, #16 .loc 1 37 0 lsl r2, r1, #16 lsr r1, r3, #16 str r1, [sp, #12] cmp r2, r3 beq .L17 .loc 1 49 0 mov r2, r9 mov r1, sl sub r3, r2, r1 mov r2, #128 lsl r2, r2, #1 add r3, r3, r2 add ip, ip, r3 b .L7 .LVL15: .L17: .loc 1 51 0 add sp, sp, #20 @ sp needed for prologue .LVL16: .LVL17: .LVL18: pop {r2, r3, r4, r5} mov r8, r2 mov r9, r3 mov sl, r4 mov fp, r5 pop {r4, r5, r6, r7} pop {r0} bx r0 .LVL19: .L2: .loc 1 34 0 mov r3, #3 str r3, [sp, #8] .LVL20: b .L4 .L24: .align 2 .L23: .word world .word touchpadWorld
|