basic : screen scroll left and right ,the picture shakes in the first two zeilen

All aspects of programming on the Commander X16.
Post Reply
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

basic : screen scroll left and right ,the picture shakes in the first two zeilen

Post by funkheld »

Hi good afternoon.

when I scroll the screen right and left with R/T with basic
then the graphic shakes in the first two zeilen ( not visible in the photo).

How can I eliminate this please?

Is there a sync for that...?

I set it to -mhz 24.

Code: Select all

SCREEN $80

GOSUB SCRFULL

START:
  GET A$ 
  B=ASC(A$)
  IF B=88 THEN GOTO WEITER
  IF B=82 THEN GOSUB SCRLINKS
  IF B=84 THEN GOSUB SCRRECHTS
GOTO START

WEITER:
END

SCRFULL:
 FOR K=0 TO 128*40 STEP 2		
    VPOKE 1,$B000+K,2   
    VPOKE 1,$B000+K-1,0*16+2  
 NEXT K	
RETURN 

SCRRECHTS:
   I=(I-1) AND $FF
   IF I=255 THEN U=(U-1) AND $FF
   POKE $9F38,U
   POKE $9F37,I
RETURN	

SCRLINKS:
   I=(I+1) AND $FF
   IF I=0 THEN U=(U+1) AND $FF
   POKE $9F38,U
   POKE $9F37,I	  
RETURN
Thanks.
greeting
Attachments
fehler.jpg
fehler.jpg (66.26 KiB) Viewed 906 times
Last edited by funkheld on Fri Apr 05, 2024 1:25 pm, edited 1 time in total.
User avatar
ahenry3068
Posts: 1145
Joined: Tue Apr 04, 2023 9:57 pm

Re: basic : screen scroll left and right ,the picture shakes in the first two zeilen

Post by ahenry3068 »

funkheld wrote: Fri Apr 05, 2024 9:54 am Hi good afternoon.

when I scroll the screen right and left with R/T with basic
then the graphic shakes in the first two zeilen ( not visible in the photo).

How can I eliminate this please?

Is there a sync for that...?

I set it to -mhz 24.

Code: Select all

SCREEN $80

GOSUB SCRFULL

START:
  GET A$ 
  B=ASC(A$)
  IF B=88 THEN GOTO WEITER
  IF B=82 THEN GOSUB SCRLINKS
  IF B=84 THEN GOSUB SCRRECHTS
GOTO START

WEITER:
END

SCRFULL:
 FOR K=0 TO 128*40 STEP 2		
	VPOKE 1,$B000+K,2   
    VPOKE 1,$B000+K-1,0*16+2  
 NEXT K	
RETURN 

SCRRECHTS:
   I=(I-1) AND $FF
   IF I=255 THEN U=(U-1) AND $FF
   POKE $9F38,U
   POKE $9F37,I
RETURN	

SCRLINKS:
   I=(I+1) AND $FF
   IF I=0 THEN U=(U+1) AND $FF
   POKE $9F38,U
   POKE $9F37,I	  
RETURN
Thanks.
greeting
It's really hard to eliminate screen tearing in BASIC. The timing needed isn't there. To eliminate that you have to make sure you only update the registers during VBlank. The required timing is doable in assembly, Probably possible in Prog8 as Well. BASIC it's very difficult. (Without an assembly SUB).
User avatar
desertfish
Posts: 1098
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: basic : screen scroll left and right ,the picture shakes in the first two zeilen

Post by desertfish »

if you do SLEEP 1 in basic, I believe it more or less does a wait for the next vsync. You could try to insert that somewhere just before adjusting the scroll values.
funkheld
Posts: 322
Joined: Mon Feb 26, 2024 11:11 am

Re: basic : screen scroll left and right ,the picture shakes in the first two zeilen

Post by funkheld »

great, works.

With 24 MHz it scrolls in basic without flickering.

---------------------------
SCRRECHTS:
I=(I-1) AND $FF
IF I=255 THEN U=(U-1) AND $FF
SLEEP 1
POKE $9F38,U
POKE $9F37,I
RETURN

SCRLINKS:
I=(I+1) AND $FF
IF I=0 THEN U=(U+1) AND $FF
SLEEP 1
POKE $9F38,U
POKE $9F37,I
RETURN
--------------------------

Thanks.
greeting
mortarm
Posts: 302
Joined: Tue May 16, 2023 6:21 pm

Re: basic : screen scroll left and right ,the picture shakes in the first two zeilen

Post by mortarm »

funkheld wrote: Fri Apr 05, 2024 9:54 am ...the first two zeilen...
Zeilen?
Post Reply