GFXFLIP2.BAS – scrolling a PMODE 4 screen.

In a post to the CoCo mailing list, Juan Castro said this:

“… I was trying to comment on this post – https://subethasoftware.com/2026/05/19/where-does-cocos-pmode-graphics-memory-start/#comment-42465 – and I was trying to say this:

In GFXFLIP.BAS, instead of the ‘flip through them’ code, try this:

1000 ‘GO DO THE ROTATION
1010 GOTO 1050
1020 FOR P=2 TO 5:GOSUB 1070:PMODE 4,P:SCREEN1:NEXT
1030 IF INKEY$=”” THEN 1030
1040 FOR P=4 TO 1 STEP -1:GOSUB 1070:PMODE 4,P:SCREEN1:NEXT
1050 IF INKEY$=”” THEN 1050
1060 GOTO 1020
1070 FOR TT=0 TO 40:NEXT:RETURN

– Juan Casto via CoCo Mailing list

So let’s take a look and see what it does. Replacing my code from 70-110 with a GOSUB to this routine gives us this:

0 'GFXFLIP2.BAS
1 'Juan Castro
10 PCLEAR 8
15 ' DRAW FIRST SCREEN
20 PMODE 4,1:PCLS:SCREEN 1,1
30 CIRCLE(128,96),50
35 ' DRAW SECOND SCREEN
40 PMODE 4,5:PCLS:SCREEN 1,1
50 LINE (10,10)-(245,171),PSET,B
60 ' FLIP THROUGH THEM
70 GOSUB 1000
110 GOTO 70

1000 'GO DO THE ROTATION
1010 GOTO 1050
1020 FOR P=2 TO 5:GOSUB 1070:PMODE 4,P:SCREEN1:NEXT
1030 IF INKEY$="" THEN 1030
1040 FOR P=4 TO 1 STEP -1:GOSUB 1070:PMODE 4,P:SCREEN1:NEXT
1050 IF INKEY$="" THEN 1050
1060 GOTO 1020
1070 FOR TT=0 TO 40:NEXT:RETURN

…and when you run it, you will see it takes the PMODE 4 screen (which is 4 blocks of graphics memory) then goes in a loop where it starts the displayed screen at block 2, then 3, then 4, then 5. With a small delay in-between each change, it shows (initially) the first PMODE 4 screen (blocks 1-4), then it toggles the memory displayed through each block until the start is block 5. This makes the screen appear to scroll up in chunks (1/4th of the screen each time). The process is then reversed to scroll back down.

Neat trick.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.