How to avoid teering scrolling in Turbo Basic

By AxelStone

Prophet (3119)

AxelStone's picture

12-01-2015, 21:34

Hi people, I'm trying a side scroll in MSX2+ and I've found this info: MSX2+ VDP registers

It seems that with a simple routine like VDP(27)=(N+7)\8: VDP(28)=-N AND 7 I can get a side scroll in MSX2+. However the scroll has teering. How can I avoid it? It seems that these registers can be set to wait. In the spanish forum someone has said me that perhaps the problem is that I've to do it during v-blank, but since I'm newbie I don't know how to see it B-)

Anyone can help? thanks

Login or register to post comments

By Daemos

Paragon (1970)

Daemos's picture

12-01-2015, 21:42

I just send a whole game engine away to someone where this scrolling is done. You have to do it on vblank indeed. So basicly you do something like

ld a,(vblankflag)
inc a
ld (vblankflag),a

on each vblank interrupt

then at the end of each gameloop/frame you wait for this flag to be set.

ld hl,vblankflag)
wait:
ld a,(hl)
cp 1
jp c,wait

xor a
ld (hl),a ;reset flag

jp gameloop

The shift will be outside the visible moment if all your VDP thingies are directly done at the start of each frame and you will get a nice tear free scroll Smile

By AxelStone

Prophet (3119)

AxelStone's picture

13-01-2015, 19:37

Ops, my knwoledge of MSX ASM is null Cool . Someone can make a translation? Thanks!

By flyguille

Prophet (3028)

flyguille's picture

13-01-2015, 20:14

imho, it is even easier.

Just monitor the BIOS's TIMER variable, and you don't needs to hook up the ISR.

IN BASIC

x=TIME

999: .... FRAME GAME.

9999 REM Synchro wait.
10000 if x<>TIME THEN x = TIME : goto 999 else 10000

IN ASSEMBLER

ld a, ($FC9E) ; don't needs to handle the 16bits for this purpose.
ld (LastTime), a
jp .WaitLoop

.Frame:

; // all your game scrolling and visual upgrades here.

.WaitLoop:
ld a, (LastTime)
ld b, a
ld a, ($FC9E)
cp b
jp z, .WaitLoop

ld (LastTime), a
jp .Frame

By anonymous

incognito ergo sum (116)

anonymous's picture

14-01-2015, 04:47

AxelStone wrote:

It seems that with a simple routine like VDP(27)=(N+7)\8: VDP(28)=-N AND 7 I can get a side scroll in MSX2+. However the scroll has teering. How can I avoid it? It seems that these registers can be set to wait. In the spanish forum someone has said me that perhaps the problem is that I've to do it during v-blank, but since I'm newbie I don't know how to see it Cool

The tearing is caused by your program updating the contents of the screen while the VDP is in the middle of drawing a frame. You need to time your program to redraw the screen during the VDP's vblank.

This can't be done in BASIC.

By AxelStone

Prophet (3119)

AxelStone's picture

14-01-2015, 11:15

I got it, thanks.

By ARTRAG

Enlighted (6845)

ARTRAG's picture

20-01-2015, 22:12

Using X basic you can include flyguille lines that poll the time variable.
Due to the fact that time is updated on the isr it will guarantee synchronisation with the vblank

You could also do something like:

...
100 time=0
....
1000 if time=0 goto 1000 else 100

Make sure line from 100 to 1000 are in the same turbo block and you will have correct sync with the vdp