
; LinePic Routine Example V0.1
; By TheOwl 1997
:
; Some experimental GFX Routine to bring a pic to the screen using
; some nice effects...
; As you can see from the code, i really know _nothing_ of Blitz
; Programming, so i'm interested in any help you can offer.
;
; contact me at jani.karkkainen@mbnet.fi

;---------< Variable Definitions >---------

turn=1

;---------< Startup Code >---------

WBStartup                  ;Enable Start From WB
NoCli                      ;Don't use cli when running from TEd

Gosub palettedef           ;Goes to label palettedef
Gosub screendef            ;Goes to label screendef
Gosub sounddef
Gosub SetError

;---------< Main Part >---------

Repeat
  If y<256 Then Gosub NextRow
  If doshow=True Then Gosub ShowRes
  If Joyb(0)=1 Then Goto BtnQuit
Until y=256

ResetTimer
Repeat
  t.l=Ticks
  If t/50=1 : ti+1 : ResetTimer
  Sound 0,1,64 : EndIf
Until Joyb(0)=1 OR ti=10                 ;Waits for mouseclick
End                        ;Ends

;---------< Row Blitting >---------

.NextRow
    Use BitMap 2           ;Uses Bitmap 2; Our picture to show is there
    GetaShape shp,x,y,320,1:Handle shp,0,0 ;Gets one line from the pic
    Use BitMap turn     ;Use bitmap to blit  ;and sets its handle to topleft
    Boxf 0,y+1,320,256,0;now and draw a black;corner
    For i=y+1 To 255    ;Box. ;Loop to draw the shape to lines below y-1
      Blit shp,x,i      ;Draw the shape
    Next i
    doshow=True       ;Mark DoShow flag to true; now we know to refresh the
  Return              ;screen. ;go back where called this Sub

;---------< Show New Bitmap >---------

.ShowRes
    ShowBitMap turn   ;Show the newly drawn Bitmap
    VWait             ;Wait for VBlank
    turn=1-turn       ;Change the Bitmap to draw to
    CopyBitMap 1-turn,turn ; Copy old bitmap to new
    Use BitMap turn   ;Use the new bitmap to draw to it
    y+1:doshow=False  ;Unmark the doshow flag; we won't come here too early
  Return              ;Get back

;---------< Define A Black Palette >---------

.palettedef
    For i=0 To 15        ;Make every palette offset
      PalRGB 0,i,0,0,0   ;Black
    Next i
  Return                 ;Get back

;---------< Define A New Screen >---------

.screendef
    Screen 0,0,0,320,256,4,0,"",1,2 ;Open a lowres screen
    ScreensBitMap 0,0         ;make it a bitmap
    ShowPalette 0             ;Show paletteobject 0 - Our black palette
    Cls                       ;Clear the screen
    BitMap 1,320,256,4        ;Define two identical Bitmaps
    BitMap 2,320,256,4
    LoadBitMap 2,"Pic",1     ;Load our palette and picture to bitmap 2
    Use Screen 0:Use BitMap 0
    ShowPalette 1             ;Shows the palette we loaded
  Return

;---------< Init Sound >---------

.sounddef
    LoadSound 0,"Sound"
  Return

;---------< Set The Error Handling >---------

.SetError
    SetErr
      VWait 100
      End
    End SetErr
  Return

;---------< User Quits >---------

.BtnQuit
    VWait 150
    End

