@ Mode 4 clear screen routines
@ by isildur
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

.global Mode4ClsCPUFastSet
.global Mode4ClsSTMIA]
.global Mode4ClsDMA

.arm 
.align 2 
.section .iwram, "ax", %progbits 

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@
@ void Mode4ClsCPUFastSet() using CPUFastSet
@
Mode4ClsCPUFastSet:
	
	ldr	r1, =VideoBuffer	@ VRAM base address depending on page flipping
	ldr	r0, =zeroword		@ load addr of a var set to zero
	ldr r2, =0x1002580		@ (240 * 160 / 4) Or'ed with 0x1000000
	swi 0xc0000                 	@ call CPUFastSet
	bx lr 

	.pool
zeroword:	.word	0x00000000


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@
@ void Mode4ClsSTMIA() using stmia
@
Mode4ClsSTMIA:
		
	stmfd	sp!, {v1-v4, lr}
	
	ldr	a1, =ScreenBank         @ which page flip are we?
	ldr	a2, [a1]
	ldr	lr, [a1, a2, lsl #2]	@ lr now contains the base address of the VRAM page
	
	mov	a1, #0
	mov	a2, #0
	mov	a3, #0
	mov	a4, #0
	mov	v1, #0
	mov	v2, #0
	mov	v3, #0
	mov	v4, #0
	mov v5, #1200
	
Mode4ClsSTMIALoop:
	stmia	lr!, {a1-a4, v1-v4}
	subs v5, v5, #1
	bne Mode4ClsSTMIALoop

	ldmfd	sp!, {v1-v4, lr}
	bx	r14

	.pool

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@
@ void Mode4ClsDMA() using DMA
@
Mode4ClsDMA:
	
	ldr	r2, =VideoBuffer	@ VRAM base address depending on page flipping
	ldr	r0, =0x040000D8
	str r2, [r0]
	ldr	r3, =0x85002580		@ Set control register.
	ldr	r0, =0x040000DC
	str r3, [r0]
	bx	r14

	.pool
   
.end

   

    Source: geocities.com/v_d_d/gba

               ( geocities.com/v_d_d)