#68580 - nmain - Wed Jan 25, 2006 9:02 pm
Code: |
// priority 0, tile base: 0600c000 // 16 color, map base: 06005000 // 512x256 REG_BG1CNT = 0x4a0c; u32 scratch = 0; DMA3COPY (&scratch, 0x06005000, DMA_IMMEDIATE | DMA32 | DMA_SRC_FIXED | (4096 / 4)); |
This should set every entry in the BG1 tilemap to tile 0, palette 0, and no h or vflip. But it doesn't; instead the tilemap is populated by a repeating 32 bit non-zero value. Debugging it; the DMA registers appear to be populated properly, but derefrencing the pointer for source address leads to a iwram memory location whose value is not 0. So the DMA is doing exactly what I expect it to, but scratch isn't 0?
edit: this is what gcc generates. I can't write assembly and can barely read it, but as best as I can tell scratch never seems to be initialized? The first strh is BG1CNT; the second is BG1HOFS (not in the C fragment; but just set to 0), and the three str are the three DMA3 registers.
Code: |
.file "menu.c" .text .align 2 .global clearmenubg .type clearmenubg, %function clearmenubg: @ args = 0, pretend = 0, frame = 4 @ frame_needed = 0, uses_anonymous_args = 0 @ link register save eliminated. mov r3, #18944 mov r1, #67108864 add r3, r3, #12 strh r3, [r1, #10] @ movhi mov r3, #100663296 add r3, r3, #20480 sub sp, sp, #4 mov r2, #-2063597568 str sp, [r1, #212] add r2, r2, #1024 str r3, [r1, #216] mov r3, #0 @ movhi str r2, [r1, #220] @ lr needed for prologue strh r3, [r1, #20] @ movhi add sp, sp, #4 bx lr .size clearmenubg, .-clearmenubg .ident "GCC: (GNU) 4.0.2" |