home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 1
/
GoldFishApril1994_CD2.img
/
d4xx
/
d484
/
viewer
/
viewer.s
< prev
next >
Wrap
Text File
|
1991-05-09
|
6KB
|
531 lines
* Picture Viewer
* ( In EZAsm )
* Click left mouse button to exit
LONG _GfxBase _DosBase _IntuitionBase
LONG CLIName CLILen
LONG Fhandle
LONG ViewMode
WORD bm_xpos bm_ypos bm_tcolor
WORD bm_pwidth bm_pheight
BYTE bm_mask bm_compress bm_pad bm_xasp bm_yasp
LONG bm_planes bm_width bm_height
LONG DispMem PSize
LONG Offset BCount TSize
LONG Colors
BYTE Bmhd CMap
LONG Flock FIB FSize FBuf BMap
LONG SaveAddr CTab
LONG OldView
WORD OrgX OrgY ModesSave
LONG Xadj Yadj TabLen
LONG View ViewPort RasInfo
LONG ColorMap
BYTE sw
CLIName = a0
CLILen = d0
_GfxBase = OpenLibrary( "graphics.library" 0 )
beq Quit
_DosBase = OpenLibrary( "dos.library" 0 )
beq Quit
_IntuitionBase = OpenLibrary( "intuition.library" 0 )
beq Quit
a0 = CLIName
CLILen --
a0 += CLILen
(a0) = 0 b ;$0A -> $00
a1 = _GfxBase
OldView = 34(a1) ;save GfxBase.ActiView
View = AllocMem( 18 $10001 )
beq Quit
ViewPort = AllocMem( 40 $10001 )
beq Quit
RasInfo = AllocMem( 12 $10001 )
beq Quit
BMap = AllocMem( 40 $10001 )
beq Quit
* Get file size..
FIB = AllocMem( 260 $10001 )
beq Quit
Flock = Lock( CLIName -2 )
beq Quit
Examine( Flock FIB )
tst.l d0
beq Quit
a0 = FIB
FSize = 124(a0) ;fib_Size
FBuf = AllocMem( FSize $10001 )
beq Quit
* Read whole file..
Fhandle = Open( CLIName 1005 )
beq Quit
Read( Fhandle FBuf FSize )
tst.l d0
bmi Quit
a0 = FBuf
(a0) != 'FORM' Quit
a0 += 8
(a0) != 'ILBM' Quit
* loop till you find a 'type' process it, continue till 'BODY'
* ( for now, ignore 'GRAB' & 'DEST' )
a0 += 4
Nxt
(a0) = 'BMHD' {
Bmhd = 1 ;set 'BMHD'
a0 += 8 ;(skip length) inc to 'struct'
bm_width = (a0)+ w
bm_height = (a0)+ w
bm_xpos = (a0)+
bm_ypos = (a0)+
bm_planes = (a0)+ b
bm_mask = (a0)+
bm_compress = (a0)+
bm_pad = (a0)+
bm_tcolor = (a0)+
bm_xasp = (a0)+
bm_yasp = (a0)+
bm_pwidth = (a0)+
bm_pheight = (a0)+
jmp Nxt
}
(a0) = 'CMAP' {
CMap = 1 ;set 'CMAP'
a0 += 4 ;inc to length
d0 = (a0)+ ;number of 'triplets'
d0 /= 3
Colors = d0
d3 = d0 ;D3 loop cnt
d3 --
d0 *= 2
TabLen = d0 w
-(SP) = a0 ;save
CTab = AllocMem( TabLen $10001 )
beq Quit
a0 = (SP)+ ;restore
* Load ColorTable
a2 = CTab
LdColor d1 = (a0)+ b ;??X?
d1 << 4 w ;?X?0
d1 = (a0)+ b ;?XX?
d1 << 4 w ;XX?0
d1 = (a0)+ b ;XXX?
d1 >> 4 w ;0XXX
(a2)+ = d1 w
dbf d3,LdColor
jmp Nxt
}
(a0) = 'CAMG' {
a0 += 8 ;( skip length )
ViewMode = (a0)+
jmp Nxt
}
(a0) = 'BODY' {
Bmhd = 0 Quit ;BODY before BMHD.... error
SaveAddr = a0
jmp Body
}
a0 ++
jmp Nxt
Body
Bmhd = 0 Quit ;didn't get BMHD..
* Set ViewMode
bm_width > 384 {
ViewMode |= $8000 ;NScr.ViewModes |= HIRES
}
bm_height > 240 {
ViewMode |= $0004 ;NScr.ViewModes |= LACE
}
ViewMode |= $4000 ;turn on SPRITES
* Get bitmap ready..
InitBitMap( BMap bm_planes bm_width bm_height )
d0 = bm_width
d0 /= 8
BCount = d0 ;save
d0 *= bm_height w
PSize = d0
d0 *= bm_planes w
TSize = d0
DispMem = AllocMem( TSize $10002 )
beq Quit
* Load plane addr's into BMap
a1 = BMap
a1 += 8
d0 = DispMem
d1 = bm_planes
d1 --
Ld1 (a1)+ = d0
d0 += PSize
dbf d1,Ld1
InitView( View )
InitVPort( ViewPort )
a0 = View
(a0) = ViewPort ;View.ViewPort
16(a0) = ViewMode w ;View.Modes
a0 = RasInfo
4(a0) = BMap ;RasInfo.BitMap = BMap
8(a0) = 0 w ;RasInfo.RxOffset
10(a0) = 0 w ;RasInfo.RyOffset
a0 = ViewPort
24(a0) = bm_width w ;ViewPort.DWidth
26(a0) = bm_height w ;ViewPort.DHeight
36(a0) = RasInfo ;ViewPort.RasInfo
32(a0) = ViewMode w ;ViewPort.Modes
* Pre-calc adjustments for centering
d0 = ViewMode
d1 = bm_height
d2 = bm_width
d3 = 0
a0 = _GfxBase
d3 = 216(a0) w ;GfxBase.NormalDisplayRows
d0:2 = 1 { ;LACE?
d3 *= 2
d1 > d3 { ; > ( NormalDisplayRows * 2 )?
d1 -= d3
d1 /= 4
Yadj = d1 w
}
} else {
d1 > d3 { ; > ( NormalDisplayRows )?
d1 -= d3
d1 /= 4
Yadj = d1 w
}
}
d0:15 = 1 { ;HIRES?
d2 > 640 {
d2 -= 640
d2 /= 4
Xadj = d2 w
}
} else {
d2 > 320 {
d2 -= 320
d2 /= 4
Xadj = d2 w
}
}
* Load Picture
a0 = SaveAddr
a0 += 8 ;skip to good stuff..
d1 = bm_planes
d1 --
d2 = bm_height
d2 --
NewLine
a3 = DispMem
a3 += Offset
Next1 d0 = BCount
d0 --
a2 = a3
bm_compress != 0 { ;( compressed )
d4 = BCount ;D4 keeps track of bytes remaining in line
Again d3 = 0
d3 = (a0)+ b
bmi Neg
d4 -= d3
d4 --
posloop (a2)+ = (a0)+ b
dbf d3,posloop
jmp EndCk
Neg d3 = $80 EndCk b
neg.b d3
d4 -= d3
d4 --
d5 = (a0)+ b
negloop (a2)+ = d5 b
dbf d3,negloop
EndCk d4 != 0 Again
} else { ;( non-compressed )
Next2 (a2)+ = (a0)+ b
dbf d0,Next2
}
a3 += PSize
dbf d1,Next1
d1 = bm_planes
d1 --
d6 = BCount
Offset += d6
dbf d2,NewLine
* Save Current View's info
Forbid( )
a0 = ViewAddress( )
OrgX = 14(a0) ;View.DxOffset
OrgY = 12(a0) ;View.DyOffset
ModesSave = 16(a0) ;View.Modes
Permit( )
* Try to center..
a0 = View
d0 = OrgX
Xadj != 0 {
d0 -= Xadj
}
14(a0) = d0 w ;View.DxOffset
d0 = OrgY
Yadj != 0 {
d0 -= Yadj
}
12(a0) = d0 w ;View.DyOffset
ColorMap = GetColorMap( Colors )
beq Quit
a0 = ViewPort
4(a0) = ColorMap
CMap = 1 {
LoadRGB4( ViewPort CTab Colors )
}
MakeVPort( View ViewPort )
MrgCop( View )
LoadView( View )
sw = 1
Wait ($bfe001):6 = 1 Wait
Quit
sw = 1 {
Forbid( )
a0 = ViewAddress( )
14(a0) = OrgX
12(a0) = OrgY
16(a0) = ModesSave
Permit( )
LoadView( OldView )
WaitTOF( )
}
ColorMap != 0 {
FreeColorMap( ColorMap )
}
FreeVPortCopLists( ViewPort )
a1 = View
a0 = 4(a1) ;View.LOFCprList
FreeCprList( * )
a1 = View
a0 = 8(a1) ;View.SHFCprList
FreeCprList( * )
DispMem != 0 {
FreeMem( DispMem TSize )
}
View != 0 {
FreeMem( View 18 )
}
ViewPort != 0 {
FreeMem( ViewPort 40 )
}
RasInfo != 0 {
FreeMem( RasInfo 12 )
}
Fhandle != 0 {
Close( Fhandle )
}
FBuf != 0 {
FreeMem( FBuf FSize )
}
Flock != 0 {
UnLock( Flock )
}
FIB != 0 {
FreeMem( FIB 260 )
}
CTab != 0 {
FreeMem( CTab TabLen )
}
BMap != 0 {
FreeMem( BMap 40 )
}
_GfxBase != 0 {
CloseLibrary( _GfxBase )
}
_DosBase != 0 {
CloseLibrary( _DosBase )
}
_IntuitionBase != 0 {
CloseLibrary( _IntuitionBase )
}
END