Je la trouve bien commenté et puis la démo fait des trucs sympas à l'arrivée.
Pour ceux ki connaissent le 68K (moi pas trop, ou si peu


Le zip avec tous les fichiers :
http://www.gbadev.org/demos/mfade11.zip
Et vala la source en live :
;
; Morph/Fade V1.1 Interlaced
;
; Written by Mike Hawkins DEC 2001
;
; E-mail to: mike@mortuary69.freeserve.co.uk
;
; This program morph/fades a 16-bit RAW graphic file onto the
; screen in mode 3 on the Gameboy Advance. It works by not actually loading
; the picture straight into the video buffer but by comparing the level of
; each colour component for each pixel in the video buffer to that of it's
; corresponding pixel in a raw graphic file and either increasing or
; decreasing it until it's at the same level.
; This version improves on version 1.0 because the effect is interlaced
; (Do alternate scanlines to screen bottom and then go back and fill in the
; missed ones). This gives a smoother transition.
;
; Here's how the colour of each pixel is made up:-
;
; 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00 -Bit
; -- BL BL BL BL BL GR GR GR GR GR RD RD RD RD RD -Colour
;
; NOTE:-Bit 15 not used-BL=BLUE GR=GREEN RD=RED
;
; Assembled using Goldroad ARM assembler v1.5b
;
b start
pic01
@INCBIN pic01.raw
pic02
@INCBIN pic02.raw
pic03
@INCBIN pic03.raw
pic04
@INCBIN pic04.raw
pic05
@INCBIN pic05.raw
pic06
@INCBIN pic06.raw
pic07
@INCBIN pic07.raw
pic08
@INCBIN pic08.raw
REG_DISPCNT
@DCD 0x04000000 ; Address of display control register
MODE_3
@DCD 0x00000403 ; Setup data for MODE 3
VIDEO_RAM
@DCD 0x06000000 ; Address of video buffer
SCANLINE2
@DCD 0x060001e0 ; Address of first byte, 2nd scanline of video buffer
start
ldr r0,[REG_DISPCNT] ; Display control register
ldr r1,[MODE_3] ; Get setup data for mode 3
str r1,[r0] ; Set mode 3
loop
mov r0,pic01 ; Get address of each picture in turn
bl show ; and pass it to show
mov r0,pic02
bl show
mov r0,pic03
bl show
mov r0,pic04
bl show
mov r0,pic05
bl show
mov r0,pic06
bl show
mov r0,pic07
bl show
mov r0,pic08
bl show
b loop
show
mov r6,r0 ; Save address of RAW graphic file
mov r7,0x01f ; Used to mask BGR component (5 bits each)
mov r8,0x080 ; r8=128
add r8,r8,r8 ; r8=256
add r8,r8,r8 ; r8=512
add r8,r8,r8 ; r8=1024
mov r9,32 ; 5 bits per BGR component=32 operations max
loop1
mov r0,r6 ; Restore address of RAW graphic file after BGR pass
ldr r1,[VIDEO_RAM] ; r1=First byte of video ram
mov r10,2 ; Interlacing requires 2 passes
loop2
mov r11,80 ; of 80 scanlines each
loop3
mov r12,240 ; X pixel count=240 pixels
loop4
ldrh r3,[r0] ; Get pixel of picture
and r3,r3,r7 lsl 10 ; Mask BLUE component (Bits 10-14)
ldrh r4,[r1] ; Get corresponding pixel of video buffer
and r4,r4,r7 lsl 10 ; Mask BLUE component
cmp r4,r3 ; and compare whats in video ram to picture pixel
subhi r4,r4,r8 ; BLUE level-=1024*(Video ram BLUE>Picture BLUE)
addlt r4,r4,r8 ; BLUE level+=1024*(Video ram BLUE<Picture BLUE)
ldrh r3,[r0] ; Get pixel of picture
and r3,r3,r7 lsl 5 ; Mask GREEN component (Bits 5-9)
ldrh r5,[r1] ; Get corresponding pixel of video buffer
and r5,r5,r7 lsl 5 ; Mask GREEN component
cmp r5,r3 ; and compare whats in video ram to picture pixel
subhi r5,r5,32 ; GREEN level-=32*(Video ram GREEN>Picture GREEN)
addlt r5,r5,32 ; GREEN level+=32*(Video ram GREEN<Picture GREEN)
orr r4,r4,r5 ; and OR new GREEN level to updated BLUE
ldrh r3,[r0]+2 ! ; Get pixel of picture and move r0 to next pixel
and r3,r3,r7 ; Mask RED component (Bits 0-4)
ldrh r5,[r1] ; Get corresponding pixel of video buffer
and r5,r5,r7 ; Mask RED component
cmp r5,r3 ; and compare whats in video ram to picture pixel
subhi r5,r5,1 ; RED level-=1*(Video ram RED>Picture RED)
addlt r5,r5,1 ; RED level+=1*(Video ram RED<Picture RED)
orr r4,r4,r5 ; and OR new RED to updated BLUE/GREEN
strh r4,[r1]+2 ! ; Write updated pixel to video ram and move to next
subs r12,r12,1 ; Decrement x pixel count
bne loop4 ; and branch if not 0
add r0,r0,240 ; r0 and r1 point to first pixel of next scanline
add r0,r0,240 ; so add 480 (pixel=16 bits=2 bytes 240x2=480) to
add r1,r1,240 ; skip a scanline in RAW file (r0) and video
add r1,r1,240 ; buffer (r1)
subs r11,r11,1 ; Decrement scanline count
bne loop3 ; and loop until all 80 are done
mov r0,r6 ; Restore address of 1st pixel in RAW graphic
add r0,r0,240 ; and move to first byte of 2nd scanline
add r0,r0,240
ldr r1,[SCANLINE2] ; Get address of 2nd scanline of video buffer
subs r10,r10,1 ; Decrement interlace pass counter
bne loop2 ; and loop for 2nd pass
subs r9,r9,1 ; Decrement BGR pass counter
bne loop1 ; and loop if not 0
mov pc,lr ; Done-Return from routine