gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

ASM > backbuffer - again

#37049 - anoneem - Sat Mar 05, 2005 6:23 pm

Sorry if there was topic like this, but in my country internet is still so expensive, that I wasn't able to check... Don't kick me, please.

Now the main message:

Hi! Problems again...
I am working in Mode 3 and trying to:
a)clear backbuffer (located at $02000000)
b)plot in it pixel
c)copy buffer to vram

Problems are:
1.if procedure czysc (clearbuff) is included, screen is black
2.if the procedure isn't called, effect is better, but not the best, becaouse 3.plotted dot is flashing - i tought that maybe vblnk could fix it, but I was wrong
4.when i tried to draw a simple horizontal line by that way:
Code:
rysuj:
   stmfd r13!, {r14}
   ldr r6, =#10
   ldr r0, =$02000000
   ldr r1, =#120
   ldr r2, =#80
   ldr r3, =#240
   ldr r4, =$ffff
.plot   mla r5, r2, r3, r1
   add r0, r0, r5, lsl#1
   strh r4, [r0]
   add r1, r1, #1
   sub r6, r6, #1
   bne plot
   ldmfd r13!, {r14}

...the screen was all filled by $ffff.

WHY?!?

Here goes the code. Please, help me to fix bugs listed above.

Code:
@textarea

   ldr r0, =0x403
   ldr r1, =0x4000000
   str r0, [r1]         ;mode 3
main:
   stmfd r13!, {r14}
   bl czysc         ;clear backbuffer
   bl rysuj         ;plot a point
   bl vblnk         ;wait for vblank
   bl naekr         ;copy backbuff to vram
   ldmfd r13!, {r14}

   b main
czysc:
   stmfd r13!, {r14}
   ldr r0, =$02000000
   ldr r1, =$0000
   ldr r2, =#38400

.clear   strh r1, [r0, #2]!
   sub r2, r2, #1

   bne clear
   ldmfd r13!, {r14}
rysuj:
   stmfd r13!, {r14}
   ldr r0, =$02000000
   ldr r1, =#120
   ldr r2, =#80
   ldr r3, =#240
   ldr r4, =$ffff

   mla r5, r2, r3, r1
   add r0, r0, r5, lsl#1
   strh r4, [r0]

   ldmfd r13!, {r14}
naekr:
   stmfd r13!, {r14}
   ldr r0, =$02000000
   ldr r1, =$06000000
   ldr r2, =#38400

.onscr   ldrh r3, [r0, #2]!
   strh r3, [r1, #2]!
   sub r2, r2, #1

   bne onscr
   ldmfd r13!, {r14}
vblnk:
   stmfd r13!, {r14}
   ldr r0, =#$04000000
.wait1
   ldrh r1, [r0, #4]
   tst r1, #1
   bne wait1
.wait2
   ldrh r1, [r0, #4]
   tst r1, #1
   beq wait2
   ldmfd r14!, {r14}

@pool
@endarea

As always sorry for my english bugs :p.

#37055 - ector - Sat Mar 05, 2005 9:05 pm

use subs instead of sub, sub doesn't set the flags

#37087 - anoneem - Sun Mar 06, 2005 7:39 pm

Oh man... What a shame. :)

Anyway, THX (or even THC :))!

But when I was trying to fix problems on my own by experimenting with dma, another thing started to making me sick. Can You or someone have a look?

Code:
naekr:
   stmfd r13!, {r14}
.srcrg
   ldr r0, =$040000d4
   ldr r1, =$02000000
   str r1, [r0]+4!
.dstrg
   ldr r1, =$06000000
   str r1. [r0]+4!
.cntrg
   ldr r1, =#19200
   strh r1, [r0]+2!
.dmarg
   ldr r1, =$940      ;bit 12 set - start in a v-blank interval
   strh r1, [r0]
   ldmfd r13!, {r14}


And the screen is dark...