[help] using sprites with double buffering in BASIC

Par msxdaisuki

Rookie (18)

Portrait de msxdaisuki

05-05-2020, 03:04

Thanks, for reading this.I am a novice.

I implement "double buffering" with "swap a,b: setpage a,b" like the code below.
I thought this by myself. So, I don't know whether this is a usual way for BASIC. Please, tell me if there are another usual ways for double buffering. That is, what I want is no blinking screen.

By the way, when I use sprites with "swap a,b:setpage a,b" double buffering using page 1, sprites of page 1 show strange stripe patterns. So, I asked a question yesterday in this forum. Sorry, but, despite all your friendly answers, I cannot find ways to solve this problem, yet.

HOW CAN I USE SPRITES WITH DOUBLE BUFFERING SUCCESSFULLY?

10 A=0:B=1:X=0:Y=0
20 SCREEN5,2
30 SPRITE$(0)=STRING$(32,255)
40 SETPAGE A,B:CLS
50 LINE(X,Y)-(X+10,Y+10),9,BF
60 PUTSPRITE 0,(X+20,Y+20),3,0
70 X=X+1:Y=X+1
80 SWAP A,B
90 SETPAGE A,B:CLS
100 GOTO 50
!login ou Inscrivez-vous pour poster

Par Guillian

Prophet (3517)

Portrait de Guillian

05-05-2020, 09:39

Try adding:

35 FOR I=0 TO &hBFF:VPOKE &HF400+I,VPEEK(&H7400+i):NEXT

This copies the sprites you have defined in PAGE 0 to PAGE 1
Another way is initializating the sprites in PAGE 1

Par msxdaisuki

Rookie (18)

Portrait de msxdaisuki

05-05-2020, 10:48

Amazing! It works!!!
thank your for your great advice!
thank you!!!

but, I cannot understand what "initializating the sprites in PAGE 1" means.
does it mean this? for example,

31 setpage 1,1
32 sprite$(0)=stirng$(32,255)

i tried this, but i didn't work. you must not mean this.
sorry, tell me more in detail, please?

Par Guillian

Prophet (3517)

Portrait de Guillian

05-05-2020, 10:58

I wanted to mean something like:

31 setpage 1,1
32 sprite$(0)=string$(32,255)
33 fori=0to31:put spritei,(0,216),0,0:next

That should do the trick.

Par msxdaisuki

Rookie (18)

Portrait de msxdaisuki

06-05-2020, 08:49

thank you!

Par mohai

Paladin (1007)

Portrait de mohai

07-05-2020, 12:28

An easy way to initialize sprites is to set the sprites condition in SCREEN command:

screen 5,2
(do whatever stuff)
screen ,2

If you set screen mode at the beginning of the program, only page 0 is initialized, so if you flip to other page later, you can find some garbage.

A funny example: run an MSX-2 game, then reset and go to BASIC (do not turn off and on, as this erases VRAM). Then show pages one by one. You will be able to see the game graphics.

Par msxdaisuki

Rookie (18)

Portrait de msxdaisuki

07-05-2020, 17:51

thank you. alarming!

Par efforless

Supporter (11)

Portrait de efforless

13-05-2020, 00:00

you are cracks guys, this it really works, thank you