home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
058.lha
/
COLLAGE
< prev
next >
Wrap
Text File
|
1986-11-20
|
8KB
|
437 lines
'COLLAGE (VERSION 1.0)
'BY HERMES (PEOPLE LINK)
'All Rights Reserved
'Public Domain but not for Sale
'LoadACBM by Carolyn Scheppner
'Various improvements by the author are forthcoming
main0:
CLEAR ,25000
CLEAR ,60000&
DIM bPlane&(5), cTabWork%(32), cTabSave%(32), array%(17000)
CLS
PALETTE 2,.64,.64,.64
FOR n = 1 TO 69
FOR m = 1 TO 50
NEXT m
LINE (180+n,60+n) - (460-n,120-n),2,b
NEXT n
LINE (184,63) - (456,117),3,b
COLOR 1,2
LOCATE 10,26
PRINT " HERMES' COLLAGE (V. 1.0)
LOCATE 12,31
PRINT "All Rights Reserved"
LOCATE 14,27
PRINT " (October 1986)"
COLOR 1,0
FOR n = 1 TO 8000
NEXT n
CLS
PALETTE 2,0,0,0
II=0
REM - Functions from dos.library
DECLARE FUNCTION xOpen& LIBRARY
DECLARE FUNCTION xRead& LIBRARY
DECLARE FUNCTION xWrite& LIBRARY
DECLARE FUNCTION IoErr& LIBRARY
DECLARE FUNCTION AllocMem&() LIBRARY
PRINT:PRINT "Looking for bmaps ... ";
LIBRARY "dos.library"
LIBRARY "exec.library"
LIBRARY "graphics.library"
PRINT "found them."
Prime:
PRINT
GetNames:
INPUT " ACBM FILENAME ";ACBMname$
IF (ACBMname$ = "") THEN GOTO Prime
First:
REM - Load the ACBM pic
loadError$ = ""
GOSUB LoadACBM
IF loadError$ <> "" THEN GOSUB Mcleanup2
Collage:
mx = 0:my = 0
MENU 1,0,1,"PROJECT "
MENU 1,1,1,"FRAME ON "
MENU 1,2,0,"FRAME OFF "
MENU 1,3,0,"PASTE "
MENU 1,4,1,"QUIT "
MENU 2,0,0,""
MENU 3,0,0,""
MENU 4,0,0,""
MENU ON
Here:
ON MENU GOSUB MenuChief
GOTO Here
FrameOn:
ex = mx:ey = my
IF MOUSE(0) = 1 OR MOUSE(0) = 0 GOTO Hello
WHILE MOUSE(0) <> 0
Undo
LINE (mx,my) - (ex,ey),,b
cx = MOUSE(1):cy = MOUSE(2)
LINE (mx,my) - (cx,cy),,b
ex = cx:ey=cy
WEND
LINE (mx,my) - (ex,ey),,b
Do
Hurt = 6 + (ey - my + 1)*2*INT((ex - mx + 16)/16)*iDepth%
IF Hurt > 17000 THEN
WINDOW 3," SYSTEM REQUEST",(50,50) - (194,75),0,2
PRINT
PRINT " SIZE TOO BIG"
CALL Food
FOR n = 1 TO 6000
NEXT n
WINDOW CLOSE 3
RETURN
END IF
IF ex > 311 THEN ex = 311
IF ey >= 185 THEN ey = 184
IF ex < mx OR ey < my THEN
CALL Food
RETURN
END IF
IF ex - mx < 5 AND ey - my < 5 THEN
CALL Food
RETURN
END IF
zx = ex - mx:zy = ey - my
ON ERROR GOTO Message
GET (mx,my) - (ex,ey),array%
WINDOW 3,"HERMES",(mx,my) - (ex,ey),18,2
PUT (0,0),array%,PSET
mx = 0:my = 0
MENU 1,1,0
MENU 1,2,1
MENU 1,3,1
RETURN
Message:
WINDOW 3," SYSTEM REQUEST",(50,50) - (194,85),0,2
PRINT
PRINT " NO HEAP SPACE! "
PRINT
FOR n = 1 TO 6000
NEXT n
WINDOW CLOSE 3
CALL Food
GOSUB FrameOn
SUB Food STATIC
MENU 1,1,1
MENU 1,2,0
MENU 1,3,0
END SUB
SUB Undo STATIC
CALL SetDrMd&(WINDOW(8),3)
END SUB
SUB Do STATIC
CALL SetDrMd&(WINDOW(8),1)
END SUB
Hello:
WHILE MOUSE(0) = 0
IF MENU(1) = 4 THEN GOSUB Wrapup
WEND
mx = MOUSE(1):my = MOUSE(2)
GOTO FrameOn
RETURN
Paster:
IF Wp > 0 GOTO There
IF MOUSE(0) = 1 GOTO HiThere
IF MOUSE(0) <> 0 THEN
WINDOW CLOSE 3
Wp = Wp + 1
mx = 0:my = 0
END IF
There:
WINDOW OUTPUT 2
IF mx > 0 OR my > 0 THEN
PUT (mx,my),array%,PSET
Wp = 0
IF my - 9 < 0 THEN my - 9 = 0
IF my + zy - 9 >= 185 THEN my + zy - 9 = 184
IF mx + zx > 311 THEN mx + zx = 311
WINDOW 3,"HERMES",(mx,my-9) - (mx+zx,my+zy-9),18,2
PUT (0,0),array%,PSET
mx = 0:my = 0
RETURN
END IF
HiThere:
WHILE MOUSE(0) = 0:WEND
mx = MOUSE(1):my = MOUSE(2)
GOTO Paster
RETURN
Shut:
WINDOW CLOSE 2
WINDOW CLOSE 3
SCREEN CLOSE 2
MenuChief:
menuID = MENU(0)
itemID = MENU(1)
ON menuID GOSUB Projects
RETURN
Projects:
ON itemID GOSUB FrameOn,FrameOff,Paster,Wrapup
RETURN
FrameOff:
CALL Food
WINDOW CLOSE 3
RETURN
Wrapup:
WINDOW CLOSE 3
WINDOW CLOSE 2
SCREEN CLOSE 2
MENU RESET
CLEAR ,25000
END
RETURN
LoadACBM:
REM - Requires the following variables
REM - to have been initialized:
REM - ACBMname$ (ACBM filespec)
REM - init variables
f$ = ACBMname$
fHandle& = 0
mybuf& = 0
foundBMHD = 0
foundCMAP = 0
foundCAMG = 0
foundCCRT = 0
foundABIT = 0
filename$ = f$ + CHR$(0)
fHandle& = xOpen&(SADD(filename$),1005)
IF fHandle& = 0 THEN
PRINT
loadError$ = " CAN'T OPEN/FIND PICTURE FILE"
GOTO Lcleanup
END IF
REM - Alloc ram for work buffers
ClearPublic& = 65537&
mybufsize& = 360
mybuf& = AllocMem&(mybufsize&,ClearPublic&)
IF mybuf& = 0 THEN
PRINT
loadError$ = " CAN'T ALLOC BUFFER"
GOTO Lcleanup
END IF
inbuf& = mybuf&
cbuf& = mybuf& + 120
ctab& = mybuf& + 240
REM - Should read FORMnnnnACBM
rLen& = xRead&(fHandle&,inbuf&,12)
tt$ = ""
FOR kk = 8 TO 11
tt% = PEEK(inbuf&+kk)
tt$ = tt$ + CHR$(tt%)
NEXT
IF tt$ <> "ACBM" THEN
PRINT
loadError$ = " NOT AN ACBM PICTURE FILE"
GOTO Lcleanup
END IF
REM - Read ACBM chunks
ChunkLoop:
REM - Get Chunk name/length
rLen& = xRead&(fHandle&,inbuf&,8)
icLen& = PEEKL(inbuf& + 4)
tt$ = ""
FOR kk = 0 TO 3
tt% = PEEK(inbuf& + kk)
tt$ = tt$ + CHR$(tt%)
NEXT
IF tt$ = "BMHD" THEN 'BitMap header
foundBMHD = 1
rLen& = xRead&(fHandle&,inbuf&,icLen&)
iWidth% = PEEKW(inbuf&)
iHeight% = PEEKW(inbuf& + 2)
iDepth% = PEEK(inbuf& + 8)
iCompr% = PEEK(inbuf& + 10)
scrWidth% = PEEKW(inbuf& + 16)
scrHeight% = PEEKW(inbuf& + 18)
iRowBytes% = iWidth% /8
scrRowBytes% = scrWidth% / 8
nColors% = 2^(iDepth%)
REM - Enough free ram to display ?
AvailRam& = FRE(-1)
'PRINT AvailRam&
NeededRam& = ((scrWidth%/8)*scrHeight%*(iDepth%+1))+5000
'PRINT NeededRam&
IF AvailRam& < NeededRam& THEN
loadError$ = " Not enough free ram. "
GOTO Lcleanup
END IF
kk = 1
IF scrWidth% > 320 THEN kk = kk + 1
IF scrHeight% > 200 THEN kk = kk + 2
IF iDepth% = 4 AND scrWidth% = 400 THEN
Q$ = "H"
GOTO Winds
END IF
IF iDepth% = 4 THEN
Q$ = "M"
GOTO Winds
END IF
IF iDepth% = 5 THEN
Q$ = "L"
END IF
Winds:
SCREEN 2,scrWidth%,scrHeight%,iDepth%,kk
IF scrWidth% = 320 AND scrHeight% = 200 THEN
wwid% = 311
GOTO Winds1
END IF
IF scrWidth% = 320 THEN wwid% = 311
IF scrWidth% = 640 THEN wwid% = 631
Winds1:
WINDOW 2,"",(0,0) - (wwid%,scrHeight%-15),16,2
REM - Get addresses of structures
GOSUB GetScrAddrs
blackout:
REM - Black out screen
CALL LoadRGB4&(sViewPort&,ctab&,nColors%)
ELSEIF tt$ = "CMAP" THEN 'ColorMap
foundCMAP = 1
rLen& = xRead&(fHandle&,cbuf&,icLen&)
REM - Build Color Table
ColorLoop:
FOR kk = 0 TO nColors% - 1
red% = PEEK(cbuf&+(kk*3))
gre% = PEEK(cbuf&+(kk*3)+1)
blu% = PEEK(cbuf&+(kk*3)+2)
Major:
regTemp% = (red%*16)+gre%+(blu%/16)
POKEW(ctab&+(2*kk)),regTemp%
NEXT
ELSEIF tt$ = "CAMG" THEN 'Amiga ViewPort Modes
foundCAMG = 1
rLen& = xRead&(fHandle&,inbuf&,icLen&)
camgModes& = PEEKL(inbuf&)
ELSEIF tt$ = "ABIT" THEN 'Contiguous BitMap
foundABIT = 1
REM - This only handles full size BitMaps, not brushes
REM - Very fast - reads in entire BitPlanes
plSize& = (scrWidth%/8) * scrHeight%
FOR pp = 0 TO iDepth% -1
rLen& = xRead&(fHandle&,bPlane&(pp),plSize&)
NEXT
ELSE
REM - Reading unknown chunk
FOR kk = 1 TO icLen&
rLen& = xRead&(fHandle&,inbuf&,1)
NEXT
REM - If odd length, read 1 more byte
IF (icLen& OR 1) = icLen& THEN
rLen& = xRead&(fHandle&,inbuf&,1)
END IF
END IF
REM - Done if got all chunks
IF foundBMHD AND foundCMAP AND foundABIT THEN
GOTO GoodLoad
END IF
REM - Good read, get next chunk
IF rLen& > 0 THEN GOTO ChunkLoop
IF rLen& < 0 THEN 'Read error
loadError$ = " Read error"
GOTO Lcleanup
END IF
REM - rLen& = 0 means EOF
IF (foundBMHD=0) OR (foundABIT=0) OR (foundCMAP=0) THEN
loadError$ = " Needed ILBM chunks not found "
GOTO Lcleanup
END IF
GoodLoad:
loadError$ =""
REM Load proper Colors
IF foundCMAP THEN
CALL LoadRGB4&(sViewPort&,ctab&,nColors%)
END IF
Lcleanup:
IF fHandle& <> 0 THEN CALL xClose&(fHandle&)
IF mybuf& <> 0 THEN CALL FreeMem&(mybuf&,mybufsize&)
RETURN
Mcleanup2:
IF loadError$ <> "" THEN PRINT loadError$
GOTO Prime
GetScrAddrs:
REM - Get addresses of screen structures
sWindow& = WINDOW(7)
sScreen& = PEEKL(sWindow& + 46)
sViewPort& = sScreen& + 44
sRastPort& = sScreen& + 84
sColorMap& = PEEKL(sViewPort& + 4)
colorTab& = PEEKL(sColorMap& + 4)
sBitMap& = PEEKL(sRastPort& + 4)
REM - Get screen parameters
scrWidth% = PEEKW(sScreen& + 12)
scrHeight% = PEEKW(sScreen& + 14)
scrDepth% = PEEK(sBitMap& + 5)
nColors% = 2^scrDepth%
REM - Get addresses of Bit Planes
FOR kk = 0 TO scrDepth% - 1
bPlane&(kk) = PEEKL(sBitMap&+8+(kk*4))
NEXT
RETURN