flash · 261528
I take it that the ds stores 2 bytes per pixel, and in that I have multiplied the x by 2 to get a word location.
strh r8,[r0]
ldr r0, =REG_VCOUNT @ This will actually make the assembler put the number REG_VCOUNT in the "pool" and @ the actual operation performed is a load from memory (likely ROM if you're not writting code to be @ copied to RAM). This is an operation you want to avoid if you want speed (in that case, mov 0x4000000 @ and then add 6. The C compiler chooses this over an LDR quite often).waitVBlank:ldrh r1, [r0] @ read REG_VCOUNTcmp r1, #(SCREEN_HEIGHT + 1) @ 193 is, of course, the first scanline of vblankbne waitVBlank @ loop if r1 is not equal to (NE condition) 193 @ (CMP does a compare (it's purpose is to set the status)).b loop @ lets keep doing it!
I was researching this as well and found some example code for generating a random number on the GBA here.I also got the waitvblank code working in your demo just but adding it to the end of your loop
Another thing to consider; it would be much faster to draw the stars once and then use the BG's scroll registers (ie. REG_BGxX & REG_BGxY) to move the stars. You could also have them moving vertically as well as horizontally.Something else I think would be a great effect would be to add a sine LUT and have the starfield move around using it.Attached is a cool program called SINUSLAB which can generate sine LUT's (Save as "Bytes, TassC64-Style" format)
#define POWER_LCD BIT(0)#define POWER_2D_A BIT(1)#define POWER_MATRIX BIT(2)#define POWER_3D_CORE BIT(3)#define POWER_2D_B BIT(9)#define POWER_SWAP_LCDS BIT(15)