Created
February 28, 2011 00:52
-
-
Save robotarmy/846755 to your computer and use it in GitHub Desktop.
..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.arm | |
.align | |
.global initSystem | |
.global main | |
.mdata: | |
@ 4bytes *8 | |
.word 0x4430 | |
.word 0x4430 | |
.word 0x4430 | |
.word 0x0800 | |
.align | |
.music: | |
.word .mdata | |
initSystem: | |
bx lr | |
main: | |
mov r0,#0x04000000 @ I/O space offset | |
mov r1,#0x3 @ Both screens on | |
mov r2,#0x00020000 @ Framebuffer mode | |
mov r3,#0x80 @ VRAM bank A enabled, LCD - bit 8 on | |
str r1,[r0, #0x304] @ Set POWERCNT # couldn't find reference to this in gbatek | |
str r2,[r0] @ DISPCNT # | |
str r3,[r0, #0x240] @ VRAMCNT_A # | |
ldr r10,=0x04000410 @channel 1 sound | |
mov r11,#0x00000032 @vol 50 | |
str r11,[r10] | |
ldr r11, .music @ address of .mdata | |
ldr r12,=0x04000414 @channel 1 data source register | |
str r11,[r12] | |
ldr r12,=0x04000418 @channel 1 timer register | |
mov r11,#0x00000200 @ dunno - data for timer value??? | |
str r11,[r12] | |
ldr r12,=0x0400041A @channel 1 loopstart register | |
mov r11,#0x00000001 @ loop start position | |
str r11,[r12] | |
ldr r12,=0x0400041C @channel 1 length register | |
mov r11,#0x00000008 @ mdata length N * 4 bytes | |
str r11,[r12] | |
@Bit0-6 Master Volume (0..127=silent..loud) | |
@Bit7 Not used (always zero) | |
@Bit8-9 Left Output from (0=Left Mixer, 1=Ch1, 2=Ch3, 3=Ch1+Ch3) | |
@Bit10-11 Right Output from (0=Right Mixer, 1=Ch1, 2=Ch3, 3=Ch1+Ch3) | |
@Bit12 Output Ch1 to Mixer (0=Yes, 1=No) (both Left/Right) | |
@Bit13 Output Ch3 to Mixer (0=Yes, 1=No) (both Left/Right) | |
@Bit14 Not used (always zero) | |
@Bit15 Master Enable (0=Disable, 1=Enable) | |
@Bit16-31 Not used (always zero) | |
ldr r12,=0x04000500 @ sound control register | |
ldr r11,=0x0000B032 @ master vol at 50 - master enable | |
str r11,[r12] | |
mov r11,#0x00000032 @ master vol at 50 | |
str r11,[r12] | |
@Bit0-6 Volume Mul (0..127=silent..loud) | |
@Bit7 Not used (always zero) | |
@Bit8-9 Volume Div (0=Normal, 1=Div2, 2=Div4, 3=Div16) | |
@Bit10-14 Not used (always zero) | |
@Bit15 Hold (0=Normal, 1=Hold last sample after one-shot sound) | |
@Bit16-22 Panning (0..127=left..right) (64=half volume on both speakers) | |
@Bit23 Not used (always zero) | |
@Bit24-26 Wave Duty (0..7) ;HIGH=(N+1)*12.5%, LOW=(7-N)*12.5% (PSG only) | |
@Bit27-28 Repeat Mode (0=Manual, 1=Loop Infinite, 2=One-Shot, 3=Prohibited) | |
@Bit29-30 Format (0=PCM8, 1=PCM16, 2=IMA-ADPCM, 3=PSG/Noise) | |
@Bit31 Start/Status (0=Stop, 1=Start/Busy) | |
@ vol 50 => 0x32 | |
@ desmune lcd seems to be 512 pixels across (contrary to wiki specifying 256) | |
@#262144 @ color to use 18bit max | |
mov r6, #32 @ Color change delay | |
mov r7, #262144 @ color to start with | |
mov r8, #0x16000 @ number of pixels of the screen occupied by animation | |
mov r9, #0x08 @ color delta | |
mov r1, r7 @ Writing pixel | |
event: mov r4, #512 @ number of frames 512=0x200 | |
mov r2, r8 @ number of pxels for lp loop | |
mov r3, r6 @ r3 is how often to change color | |
nf: | |
mov r0, #0x06800000 @ VRAM offset #reset each loop | |
lp: | |
strh r1, [r0], #1 @ Write r1 into in and increment r0 by 1 | |
subs r2, r2, #1 @ decrement number of pixels to write | |
bne lp @ branch if not equal (is it checking the flags??) | |
mov r2, r8 @ resest number of pixel counter | |
@@ Delay r6 / r3 | |
@@ Between color change | |
subs r3, r3, #4 @ if color change delay reaches zero then change color | |
bne after | |
next_color: | |
mov r3, r6 @ reset the color change amount | |
sub r1, r1, r9 @ modify color by color change amount | |
after: | |
subs r4, r4, #1 @ number of loops | |
bne nf @ branch on zero back to r4 | |
b event | |
inf: b inf | |
@ blue gradient | |
@ mov r0, #0x06800000 @ VRAM offset | |
@ mov r1, #0x00 @ Writing pixel value | |
@ mov r2, #0x18000 @ number of pxels | |
@ mov r3, #0x800 | |
@lp: strh r1, [r0], #1 @ Write a pixel in - increment r0 by #128 | |
@ subs r3,r3, #1 | |
@ bne next_px | |
@next_color: adds r1, r1, # | |
@ mov r3, #0x800 | |
@next_px : subs r2, r2, #1 @ decrement r2 - update flags | |
@ bne lp @ branch if not equal (is it checking the flags??) | |
@white lemon blue | |
@ mov r0, #0x06800000 @ VRAM offset | |
@ mov r1, #0x00 @ Writing pixel value | |
@ mov r2, #0x18000 @ number of pxels | |
@ mov r3, #0x1600 | |
@lp: strh r1, [r0], #1 @ Write a pixel in - increment r0 by #128 | |
@ subs r3,r3, #1 | |
@ bne next_px | |
@next_color: adds r1, r1, #0xffffffff | |
@ mov r3, #0x1600 | |
@next_px : subs r2, r2, #1 @ decrement r2 - update flags | |
@ bne lp @ branch if not equal (is it checking the flags??) | |
@ | |
@nf: b nf @ Sit in an infinite loop to finish |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment