Skip to content

Commit

Permalink
Rewrote SinWobble effect to use DMA
Browse files Browse the repository at this point in the history
  • Loading branch information
benbaker76 committed May 3, 2009
1 parent 651f1c7 commit e8bdf81
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 50 deletions.
Binary file modified WarhawkDS/arm9/data/TitleBottom.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified WarhawkDS/arm9/data/TitleTop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions WarhawkDS/arm9/source/fxColorText.s
Expand Up @@ -170,7 +170,7 @@ fxCopperTextVBlankContinue:
ldr r3, =(FONT_COLOR_OFFSET * 2)
add r2, r3
mov r3, #1 @ Count
ldr r4, =(DMA_ENABLE | DMA_REPEAT | DMA_START_HBL | DMA_DST_FIX)
ldr r4, =(DMA_ENABLE | DMA_REPEAT | DMA_START_HBL | DMA_DST_RESET)

bl dmaTransfer

Expand All @@ -180,7 +180,7 @@ fxCopperTextVBlankContinue:
ldr r3, =(FONT_COLOR_OFFSET * 2)
add r2, r3
mov r3, #1 @ Count
ldr r4, =(DMA_ENABLE | DMA_REPEAT | DMA_START_HBL | DMA_DST_FIX)
ldr r4, =(DMA_ENABLE | DMA_REPEAT | DMA_START_HBL | DMA_DST_RESET)

bl dmaTransfer

Expand Down
8 changes: 4 additions & 4 deletions WarhawkDS/arm9/source/fxControl.s
Expand Up @@ -43,6 +43,8 @@ fxOff:

cmp r0, #0
beq fxOffDone
tst r0, #FX_SINE_WOBBLE
blne fxSineWobbleOff
tst r0, #FX_FADE_IN
blne fxFadeOff
tst r0, #FX_FADE_OUT
Expand Down Expand Up @@ -83,8 +85,6 @@ fxOff:
blne fxStarfieldOff
tst r0, #FX_STARFIELD_MULTI
blne fxStarfieldOff
tst r0, #FX_SINE_WOBBLE
blne fxSineWobbleOff
tst r0, #FX_SCANLINE
blne fxScanlineOff
tst r0, #FX_CROSSWIPE
Expand Down Expand Up @@ -113,6 +113,8 @@ fxVBlank:

cmp r0, #0
beq fxVBlankDone
tst r0, #FX_SINE_WOBBLE
blne fxSineWobbleVBlank
tst r0, #FX_FADE_IN
blne fxFadeInVBlank
tst r0, #FX_FADE_OUT
Expand Down Expand Up @@ -170,8 +172,6 @@ fxHBlank:

cmp r0, #0
beq fxHBlankDone
tst r0, #FX_SINE_WOBBLE
blne fxSineWobbleHBlank
tst r0, #FX_SCANLINE
blne fxScanlineHBlank
tst r0, #FX_CROSSWIPE
Expand Down
151 changes: 109 additions & 42 deletions WarhawkDS/arm9/source/fxSine.s
Expand Up @@ -31,7 +31,7 @@
.text
.global fxSineWobbleOn
.global fxSineWobbleOff
.global fxSineWobbleHBlank
.global fxSineWobbleVBlank

fxSineWobbleOn:

Expand All @@ -42,6 +42,14 @@ fxSineWobbleOn:
orr r1, #FX_SINE_WOBBLE
str r1, [r0]

ldr r0, =sineOfsMain
ldr r1, =192 * 4
str r1, [r0]

ldr r0, =sineOfsSub
ldr r1, =0
str r1, [r0]

ldmfd sp!, {r0-r6, pc}

@ ---------------------------------------
Expand All @@ -55,59 +63,118 @@ fxSineWobbleOff:
and r1, #~(FX_SINE_WOBBLE)
str r1, [r0]

mov r0, #0
mov r1, #0
mov r2, #0
mov r3, #0
mov r4, #0

bl dmaTransfer

mov r0, #1
mov r1, #0
mov r2, #0
mov r3, #0
mov r4, #0

bl dmaTransfer

ldmfd sp!, {r0-r6, pc}

@ ---------------------------------------

fxSineWobbleHBlank:
fxSineWobbleVBlank:

stmfd sp!, {r0-r6, lr}
stmfd sp!, {r0-r7, lr}

ldr r0, =SIN_bin @ Address of sine table
ldr r1, =REG_VCOUNT @ REG_VCOUNT address
ldrh r1, [r1] @ REG_VCOUNT value

add r0, r1, lsl #1 @ Add the REG_VCOUNT * 2 (16 bit values in SIN table)
ldrsh r1, [r0] @ Load the SIN value
asr r1, #6 @ Right shift the SIN value 4 bits plus 2 bits to make it smaller
rsb r1, r1, #0 @ Reverse subtract to make it negative (r1=#0 - r1)

ldr r2, =REG_BG2HOFS_SUB @ Horizontal scroll register offset
strh r1, [r2]
ldr r0, =SIN_bin @ Address of sine table
ldr r1, =hOfsBufMain @ Horizontal scroll register offset
ldr r2, =hOfsBufSub @ Horizontal scroll register offset
ldr r3, =sineOfsMain
ldr r3, [r3]
ldr r4, =sineOfsSub
ldr r4, [r4]
ldr r5, =0x3FF
mov r6, #0

fxSineWobbleVBlankLoop:

add r7, r3, r6, lsl #2
and r7, r5
ldrsh r7, [r0, r7] @ Load the SIN value
asr r7, #8 @ Right shift the SIN value
strh r7, [r1], #2

add r7, r4, r6, lsl #2
and r7, r5
ldrsh r7, [r0, r7] @ Load the SIN value
asr r7, #8 @ Right shift the SIN value
strh r7, [r2], #2

add r6, #1
cmp r6, #192
bne fxSineWobbleVBlankLoop

ldr r1, =hOfsBufMain @ Horizontal scroll register offset
ldr r2, =hOfsBufSub @ Horizontal scroll register offset

ldr r6, =(192 * 2)
ldrh r7, [r1]
strh r7, [r1, r6]

ldrh r7, [r2]
strh r7, [r2, r6]

ldr r0, =sineOfsMain
ldrh r1, [r0]
add r1, #8
strh r1, [r0]

ldr r0, =sineOfsSub
ldrh r1, [r0]
add r1, #8
strh r1, [r0]

bl DC_FlushAll

mov r0, #0 @ Dma channel
ldr r1, =hOfsBufMain @ Source
add r1, #2
ldr r2, =REG_BG1HOFS @ Dest
mov r3, #1 @ Count
ldr r4, =(DMA_ENABLE | DMA_REPEAT | DMA_START_HBL | DMA_DST_RESET)

bl dmaTransfer

mov r0, #1 @ Dma channel
ldr r1, =hOfsBufSub @ Source
add r1, #2
ldr r2, =REG_BG1HOFS_SUB @ Dest
mov r3, #1 @ Count
ldr r4, =(DMA_ENABLE | DMA_REPEAT | DMA_START_HBL | DMA_DST_RESET)

bl dmaTransfer

ldmfd sp!, {r0-r7, pc}

add r0, #(192 * 2) @ Add our Main screen offset (* 2 for 16 bit values)

ldrsh r1, [r0] @ Load the SIN value
asr r1, #6 @ Right shift the SIN value 4 bits plus 2 bits to make it smaller
rsb r1, r1, #0 @ Reverse subtract to make it negative (r1=#0 - r1)

ldr r2, =REG_BG2HOFS @ Horizontal scroll register offset
strh r1, [r2]

@ -------------------------
@ ---------------------------------------

ldr r0, =SIN_bin @ Address of sine table
ldr r1, =REG_VCOUNT @ REG_VCOUNT address
ldrh r1, [r1] @ REG_VCOUNT value

add r0, r1, lsl #1 @ Add the REG_VCOUNT * 2 (16 bit values in SIN table)
ldrsh r1, [r0] @ Load the SIN value
asr r1, #7 @ Right shift the SIN value 4 bits plus 3 bits to make it smaller
.data
.align

ldr r2, =REG_BG3HOFS_SUB @ Horizontal scroll register offset
strh r1, [r2]
sineOfsMain:
.word 0

add r0, #(192 * 2) @ Add our Main screen offset (* 2 for 16 bit values)

ldrsh r1, [r0] @ Load the SIN value
asr r1, #7 @ Right shift the SIN value 4 bits plus 3 bits to make it smaller
sineOfsSub:
.word 0

ldr r2, =REG_BG3HOFS @ Horizontal scroll register offset
strh r1, [r2]

ldmfd sp!, {r0-r6, pc}
.align
hOfsBufMain:
.space ((192+1) * 2)

@ ---------------------------------------
.align
hOfsBufSub:
.space ((192+1) * 2)

.pool
.end
2 changes: 1 addition & 1 deletion WarhawkDS/arm9/source/fxSpotlight.s
Expand Up @@ -488,7 +488,7 @@ radius:

.align
winh:
.space ((192 + 1) * 2) @ Window values to store into REG_WIN0H
.space ((192+1) * 2) @ Window values to store into REG_WIN0H

.pool
.end
2 changes: 1 addition & 1 deletion WarhawkDS/arm9/source/titlescreen.s
Expand Up @@ -164,7 +164,7 @@ showTitleScreen:
bl fxColorPulseOn
bl fxSpotlightIn
bl fxFadeBlackIn

ldr r0, =1000 @ 1 seconds
ldr r1, =showTextScroller @ Callback function address

Expand Down

0 comments on commit e8bdf81

Please sign in to comment.