Pixel by Pixel Scrolling in QBasic 
Author Message
 Pixel by Pixel Scrolling in QBasic

I'm making a Dragon Warrior clone and can't figure out how to get pixel by
pixel scrolling.  I can get tile by tile, but not pixel by pixel.  I'm
using 20X20 tiles.
-Apester001



Sun, 12 Dec 1999 03:00:00 GMT  
 Pixel by Pixel Scrolling in QBasic

Quote:

> I'm making a Dragon Warrior clone and can't figure out how to get pixel by
> pixel scrolling.  I can get tile by tile, but not pixel by pixel.  I'm
> using 20X20 tiles.
> -Apester001

I hate giving away my newest programs, but if you mention me in your
credits, here it is.  What this does is do perfect hardware panning on
the entire screen.  So you'll have to create a virtual screen bigger
than your normal resolution (e.g. 640x480 virtual screen for SCREEN
13).  But it's an awesome effect that works in all VGA modes, and plus,
it's way faster than GET/PUT.
--from Toshi

DECLARE SUB Setstart (N%)
DECLARE SUB VPan (N%)
DECLARE SUB HPan (N%)
DECLARE SUB WaitInRetrace ()
DECLARE SUB WaitInDisplay ()
DEFINT A-Z
'Pixel panning in text mode and graphics modes
'by Toshihiro Horie
'References: Victor Yiu's VERTPAN.BAS
'            PC_Underground (c)1995 Abacus
COMMON SHARED XDIR, YDIR, SC

'screen mode
SC = 0
'speed and direction adjustment here
'default is 1,0 which is SLOWEST! :)
'one of the directions must be 0!
XDIR = 1
YDIR = 0
IF XDIR THEN YDIR = 0: 'use legal values
IF (SC AND (YDIR < 8) AND (YDIR > 0)) THEN YDIR = 16
SCREEN SC

FOR t = 1 TO 25
PRINT "This is some real smooth scrolling"; t
NEXT

IF SC = 0 THEN
a$ = "Copyright 1997 Toshihiro Horie"
DEF SEG = &HB800
FOR l = 1 TO LEN(a$)
        POKE 5600 + l * 2, ASC(MID$(a$, l, 1))
        POKE 5600 + l * 2 + 1, 31
NEXT l
DEF SEG
END IF

'the next two lines change the size of the virtual screen
OUT &H3D4, &H13
OUT &H3D5, 40: 'try other values like 80

x = 0: y = 0: 'origin
DO
        k$ = INKEY$
        IF k$ = CHR$(27) THEN EXIT DO
        x = x + XDIR
        y = y + YDIR
        IF x <= 0 OR x >= (80 * 9) THEN XDIR = -XDIR
        IF y <= 0 OR y >= (25 * 16) THEN YDIR = -YDIR
        yy = y \ 16
        start = x \ 9 + 80 * yy
        CALL Setstart(start)
        CALL WaitInRetrace
        CALL HPan((x - 1) MOD 9)
        IF SC = 0 THEN CALL VPan(y MOD 16)
LOOP
SCREEN 0
'the next two lines change the size of the virtual screen
OUT &H3D4, &H13
OUT &H3D5, 40: 'keep number of bytes per line normal
CALL Setstart(0)
CALL HPan(8)
CALL VPan(0)
END

SUB fillscreen
'FOR i = 0 TO (160 * 50)
'        IF ((i MOD 10) <> 0) THEN
'                DEF SEG = &HB800
'                POKE (i * 2), ASC("-")
'                POKE (i * 2 + 1), 7
'        ELSE
'                DEF SEG = &HB800
'                POKE (i * 2), (((i \ 160) MOD 10) + ASC("0"))
'                POKE (i * 2 + 1), 3
'        END IF
'       IF (i MOD 80) = 0 THEN
'               DEF SEG = &HB800
'               POKE (i * 2), ((i \ 160) MOD 10 + ASC("0"))
'                POKE i * 2 + 1, 2
'        END IF
'NEXT
'DEF SEG

END SUB

SUB HPan (N)
'ATC Index/Data Port
OUT &H3C0, (&H13 OR 32)
OUT &H3C0, (N OR 32)
END SUB

SUB Setstart (N)
IF XDIR = 0 THEN
        'vertical scrolling
        m% = FIX(N / 256): l% = N - (m% * 256)
        OUT &H3D4, 12: OUT &H3D5, m%: OUT &H3D4, 13: OUT &H3D5, l%
        WAIT &H3DA, 8 'Wait for vertical retrace
END IF
IF YDIR = 0 THEN
        'horizontal scrolling
        WaitInDisplay
        m% = N \ 256: l% = N MOD 256
        OUT &H3D4, 12: OUT &H3D5, m%: OUT &H3D4, 13: OUT &H3D5, l%
END IF
END SUB

SUB VPan (N)
'CRTC Register 8 (Initial Row Address) bits 4-0
OUT &H3D4, 8
OUT &H3D5, N
END SUB

SUB WaitInDisplay
WAIT &H3DA, 8
DO: a = INP(&H3DA): LOOP UNTIL a
END SUB

SUB WaitInRetrace
WAIT &H3DA, 8
WAIT &H3DA, 8, 8
END SUB



Sun, 12 Dec 1999 03:00:00 GMT  
 Pixel by Pixel Scrolling in QBasic

Quote:

> I'm making a Dragon Warrior clone and can't figure out how to get pixel by
> pixel scrolling.  I can get tile by tile, but not pixel by pixel.  I'm
> using 20X20 tiles.
> -Apester001

        You''re probably creating "Blocks" of data statement graphics or
something... what you want to do is somehow get the graphics on the
screen, GET the one's you want to move around into an array, and then
use PUT to place it somewhere... If you want to have transparent areas,
you'd have to use the AND/OR method.... experiment with PUT in a loop:

draw graphic...
GET (x1,y1)-(x2,y2),array%

FOR i = 1 to 25
PSET (i,y1),array%
wait &h3da,8        'This waits for the screen to draw itself out, for
smoothness.
next i

END
This code'll move a graphics 25 pixels over, SMOOTHLY.


...Hope this helps...



Mon, 13 Dec 1999 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. PIXELS, PIXELS, PIXELS

2. Rotate one pixel around another pixel...

3. BMP output mapping BMP-pixel to printer-pixel 1:1

4. Print PicBox pixel by pixel?

5. How to change True color pixel to 256 color pixel, @Thanks

6. full screen graphics, pixel by pixel control

7. Single Pixel Scrolling w/Tiles?

8. More on my pixel scrolling problem

9. Single-pixel scrolling demo

10. Single-Pixel Scrolling Demo - Revised

11. Pixel scroll Word document through DDE

12. Scrolling Pixels?

 

 
Powered by phpBB® Forum Software