Author Topic: double buffer  (Read 684 times)

0 Members and 1 Guest are viewing this topic.

Offline Fran123

  • CPC464
  • **
  • Posts: 42
  • Country: es
  • Liked: 7
  • Likes Given: 0
double buffer
« on: 13:37, 22 April 21 »

Hello,
I'm doing test with double buffer to avoid some blinks, and I read it will remove the problem, but not


The code I have is:


Code: [Select]

loop:
   ld a, #30
   call set_video_page ; show from #c000 to #FFFF
   ; now, I work on other page


   ; delete previous sprite
   ld de, #8000
   DeleteSprite WIDTH, HEIGHT ; macro that draw a box with background colour


   ; draw the new sprite
   ld de, #8000
   ld hl, sprite
   DrawSprite WIDTH, HEIGHT ; macro that draw the sprite


   ld a, #20
   call set_video_page ; it shows from to #8000 to #BFFF
   ; now, I work on other page


   ; delete previous sprite
   ld de, #c000
   DeleteSprite WIDTH, HEIGHT


   ; draw the sprite
   ld de, #c000
   ld hl, sprite
   DrawSprite WIDTH, HEIGHT


jp loop


I don't understand why I get some blinks. I delete the previous sprite, then I put the new sprite at same position, and finally I change the address of video memory to show the changes.


That function is:


Code: [Select]

set_video_page:
ld bc, #BC0C
out (c), c
inc b
out (c), a
ret


Where is the problem?   What am I doing wrong?
Thank you.


I'm "desperate".

Offline Shining

  • Supporter
  • 464 Plus
  • *
  • Posts: 313
  • Country: de
    • Shinings little CPC page
  • Liked: 444
  • Likes Given: 214
Re: double buffer
« Reply #1 on: 13:51, 22 April 21 »
I did not look into your code. But are you aware, that if you want to avoid blink, you have to swap between the two buffers at VBL (or at a position when nothing is drawn)?
TGS is back

Download my productions at:
cpc.scifinet.org

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.086
  • Country: fr
    • urban exploration
  • Liked: 1498
  • Likes Given: 869
Re: double buffer
« Reply #2 on: 13:59, 22 April 21 »

sure you need to wait vertical blank before changing video offset
Code: [Select]
ld b,#F5
wait_vbl
in a,(c)
rra
jr nc,wait_vbl
ret
use RASM, the best assembler ever made :p

I will survive

Offline Fran123

  • CPC464
  • **
  • Posts: 42
  • Country: es
  • Liked: 7
  • Likes Given: 0
Re: double buffer
« Reply #3 on: 14:16, 22 April 21 »

Sure I need wait vertical sync?  I miss a lot of frames per second.

sure you need to wait vertical blank before changing video offset
Code: [Select]
ld b,#F5
wait_vbl
in a,(c)
rra
jr nc,wait_vbl
ret

Offline roudoudou

  • 6128 Plus
  • ******
  • Posts: 1.086
  • Country: fr
    • urban exploration
  • Liked: 1498
  • Likes Given: 869
Re: double buffer
« Reply #4 on: 14:21, 22 April 21 »
Sure I need wait vertical sync?  I miss a lot of frames per second.
if you do not want to wait VBL, you need triple buffer
with double buffer, you have to wait that screen is fully displayed before erasing/updating your sprite
use RASM, the best assembler ever made :p

I will survive

Offline megachur

  • CPC664
  • ***
  • Posts: 100
  • Country: fr
  • z80 Powaaa !
    • cpc-power
  • Liked: 134
  • Likes Given: 13
Re: double buffer
« Reply #5 on: 19:17, 22 April 21 »
The correct VBL wait is here : - compatibility with all crtcs and GA/ASIC !
Quote
; ---------------------------
wait_vbl:
vbl_wait:
; ---------------------------
    ld b,#f5

wait_vbl_loop
    in a,(c)
    rra
    jr c,wait_vbl_loop

wait_vbl_synchro_loop
    in a,(c)
    rra
    jr nc,wait_vbl_synchro_loop
    ret