home *** CD-ROM | disk | FTP | other *** search
- '$INCLUDE: 'modex.bi'
- DECLARE SUB Waitvbi ()
- DECLARE SUB Playfli (Name$)
- COMMON SHARED a$
- 'Check out the REMs in the PLAYFLI sub
- 'This is a .FLI player written in Quick Basic, it's relatively fast
- 'I used an awesome routine I found on a BBS to do VGA paging.
- 'I think it was Matt Pritchard.... thanks man!
- 'If that dude finds this code, he can go ahead and steal this
- 'Player. Thanks....
- DEFINT A-Z
- CLS
- TYPE Fheader 'This is the format of the Header on a .FLI
- Size AS LONG
- Typ AS STRING * 2
- Numf AS INTEGER
- Wid AS INTEGER
- Hei AS INTEGER
- Bits AS INTEGER
- Flag AS INTEGER
- Speed AS INTEGER
- Nex AS LONG
- Fri AS LONG
- Blank AS STRING * 102
- END TYPE
- TYPE Frameh 'This is the header attached to each frame on a .FLI
- Size AS LONG
- Typf AS INTEGER
- Nchu AS INTEGER
- Blank AS STRING * 8
- END TYPE
- TYPE Chunkh 'This is the header for each Chunk in a frame
- Size AS LONG
- Typec AS INTEGER
- END TYPE
- IF COMMAND$ = "" THEN 'Access input
- PRINT "File not specified!"
- END
- END IF
- Nme$ = COMMAND$
- IF INSTR(Nme$, ".") = 0 THEN Nme$ = Nme$ + ".FLI"
- PRINT "Dean's FLI player! (320x200x256)"
- PRINT "This was written in QUICK BASIC!!!"
- PRINT "Now playing: "; Nme$
- PRINT "Press any key to continue..."
- DO WHILE INKEY$ = "": LOOP
- SCREEN 13
- a = Set.Modex(Mode320x200) 'Go into the mode with paging
- OPEN Nme$ FOR BINARY AS #1
- DO UNTIL a$ <> ""
- a$ = INKEY$
- Playfli Nme$ 'Play the .FLI
- LOOP
- CLOSE #1
- SCREEN 0
- WIDTH 80
- END
-
- SUB Playfli (Name$)
- DIM Byte AS STRING * 1 'Varibles for compatibility
- DIM Word AS INTEGER
- DIM Dword AS LONG
- DIM Qword AS DOUBLE
- DIM Fhead AS Fheader
- DIM Chunk AS Chunkh
-
- DIM Lns AS LONG 'This is for QB enviroment (SLOW)
- 'Un rem the next line when compling! (FAST!)
- 'DIM Lns AS INTEGER
- SEEK #1, 1
- GET #1, , Fhead 'Get the header data
- DIM Frame AS Frameh 'Set the Frame varible
- Lr = LOC(1)
- GET #1, , Frame
- Seekn& = Frame.Size + Lr + 1
- Fm$ = SPACE$(Frame.Size)
- GET #1, , Fm$ 'Get the whole FIRST frame into memory
- DEF SEG = VARSEG(Fm$)
- Vl = SADD(Fm$)
-
- Lns = 1
- Apage = 1
- Vpage = 0
-
- FOR Frms = 1 TO Fhead.Numf
- IF INKEY$ <> "" THEN
- a$ = " "
- EXIT SUB
- END IF
- SET.ACTIVE.PAGE Apage 'Do some page swapping
- SET.DISPLAY.PAGE Vpage
- IF Frms > 1 THEN
- COPY.PAGE Vpage, Apage 'Make sure the page your using is up to date
- SEEK #1, Seekn&
- GET #1, , Frame 'Get the frame data
- Seekn& = Seekn& + Frame.Size 'Store where next frame in file is
- Fm$ = SPACE$(Frame.Size)
- GET #1, , Fm$ 'Get the whole frame
- DEF SEG = VARSEG(Fm$)
- Vl = SADD(Fm$)
- Lns = 1
- END IF
-
- FOR t = 1 TO Frame.Nchu
- Chunk.Size = CVL(MID$(Fm$, Lns, 4)) 'Get chunk data
- Lns = Lns + 4
- Chunk.Typec = CVI(MID$(Fm$, Lns, 2))
- Lns = Lns + 2
- C = Chunk.Typec
- IF C = 11 THEN 'This is if its a PALETTE block
- Word = CVI(MID$(Fm$, Lns, 2))
- Lns = Lns + 2
- Cl = 0
- FOR i = 1 TO Word
- a = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- Cl = Cl + a
- f = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- IF f = 0 THEN f = 256
- FOR e = Cl TO f - 1
- OUT &H3C8, e 'I know Matt's routines
- 'had a palette setting command,
- 'but this is still faster
- g = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- OUT &H3C9, g
- g = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- OUT &H3C9, g
- g = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- OUT &H3C9, g
- NEXT e
- NEXT i
- END IF
- IF C = 15 THEN 'This is if it's a FIRST frame RLE
- x = 0
- y = 0
- DO
- Nump = PEEK(Vl + Lns - 1) 'Forget the stupid MID$ command
- 'PEEK is faster!
- Lns = Lns + 1
- FOR r = 1 TO Nump
- u = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- IF u < 128 THEN
- Cr = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- DRAW.LINE x, y, x + u - 1, y, Cr
- x = x + u
-
- END IF
- IF u > 127 THEN
- u = ABS(u - 255) + 1
- FOR w = 1 TO u
- f = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- SET.POINT x, y, f
- x = x + 1
- NEXT w
- END IF
- NEXT r
- x = 0
- y = y + 1
- LOOP UNTIL y >= 199
- END IF
- IF C = 12 THEN 'This is if it's another frame, it skips lines but
- 'it's also an RLE
- y = CVI(MID$(Fm$, Lns, 2))
- Lns = Lns + 2
-
- x = 0
- Clins = CVI(MID$(Fm$, Lns, 2))
- Lns = Lns + 2
- FOR Ncl = 1 TO Clins
- a = PEEK(Vl + Lns - 1) 'Get num of lines to skip
- Lns = Lns + 1
- IF a = 0 THEN GOTO Skip
- FOR Npa = 1 TO a
- Repeat:
- Pskip = PEEK(Vl + Lns - 1) 'Get num of pixels to skip
- Lns = Lns + 1
- x = x + Pskip
- IF Pkskip = 255 THEN GOTO Repeat
- Snd = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
-
- IF Snd < 128 THEN
- FOR Rd = 1 TO Snd
- Clr = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- SET.POINT x, y, Clr
- x = x + 1
- NEXT Rd
- ELSE
- Snd = ABS(Snd - 256)
- Clr = PEEK(Vl + Lns - 1)
- Lns = Lns + 1
- DRAW.LINE x, y, x + Snd - 1, y, Clr
- x = x + Snd
- END IF
- NEXT Npa
- Skip:
- x = 0
- y = y + 1
- NEXT Ncl
- END IF
- NEXT t
- SWAP Apage, Vpage 'exchange pages
- ' FOR Wt = 1 TO Fhead.Speed
- ' Waitvbi 'Do delay for num set of video cycles
- ' NEXT Wt 'If not needed, it goes faster on fast frame rate FLIs if REMED
- NEXT Frms
- END SUB
-
- SUB Waitvbi
- Agin:
- i = INP(&H3DA)
- a = i AND &H8
- IF a = 1 THEN GOTO Agin
- Agin2:
- i = INP(&H3DA)
- a = i AND &H8
- IF a = 0 THEN GOTO Agin2
- END SUB
-
-