4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
33 #include <devices/newmouse.h>
35 #include <devices/rawkeycodes.h>
37 //#include <proto/powerpacker.h>
40 #include <hardware/custom.h>
41 struct Custom
*custom
= 0x00DFF000;
43 #include <clib/pchglib_protos.h>
57 #define DIMBUFSIZE sizeof(struct DimensionInfo)
60 struct AnimFrame
*next
;
61 struct AnimHeader
*animheader
;
68 struct AnimFrame initial_frame
;
69 struct AnimFrame
*first_frame
;
70 struct AnimFrame
*current_frame
;
71 struct AnimFrame
*last_frame
;
72 struct BitMap
*frame_bm
[2],
74 struct Image frameimage
;
83 static struct NewWindow iffwin
= {
86 IDCMP_MOUSEBUTTONS
|IDCMP_RAWKEY
|IDCMP_INTUITICKS
|IDCMP_INACTIVEWINDOW
,
87 WFLG_RMBTRAP
|WFLG_BORDERLESS
|WFLG_SIMPLE_REFRESH
|WFLG_NOCAREREFRESH
,
88 NULL
,NULL
,NULL
,NULL
,NULL
,
89 0,0,0,0,CUSTOMSCREEN
};
91 static char *picbuffer
,*picturename
;
92 static unsigned char *bodyptr
;
93 static ULONG buffersize
,bufferpos
;
95 static ULONG
*colourtable_8
;
96 static UWORD
*copperlist
,*colourtable_4
;
98 static struct ViewPort
*ivp
;
100 static int numcolours
,currange
,copperheight
,
101 screenwidth
,screenheight
,
102 bitmapwidth
,bitmapheight
,
104 static int palette32
,got_dpan
;
105 static char doublebuffer
;
106 static char specialformat
;
108 static struct BitMapHeader bmhd
;
110 static struct BitMap
*iffbm
[2];
111 static struct Window
*iffwindow
;
114 static struct PCHGHeader
*pchghead
;
119 static struct DBufInfo
*dbufinfo
;
120 static struct MsgPort
*dbufport
;
123 static char iffscreenname
[34];
125 static struct DOpusAnim anim
;
127 static inline void dotitle(struct BitMapHeader
*bmhd
)
129 char title
[100],modes
[140],cols
[30];
133 lsprintf(title
,"%ld x %ld x %ld (page %ld x %ld) %s cols (%s)",
134 (long int)bmhd
->bmh_Width
,
135 (long int)bmhd
->bmh_Height
,
136 (long int)bmhd
->bmh_Depth
,
137 (long int)bmhd
->bmh_PageWidth
,
138 (long int)bmhd
->bmh_PageHeight
,
146 struct DOpusRemember
*iffkey
;
157 imagewidth
, imageheight
,
158 minwidth
, minheight
, maxwidth
, maxheight
,
167 struct DimensionInfo
*dimension
;
168 DisplayInfoHandle
*handle
;
169 char dimbuf
[DIMBUFSIZE
],
172 struct AnimFrame
*cur_frame
= NULL
,
174 CRange cyclerange
[6];
181 anim
.framespersec
= 20;
186 iffscreenname
[0] = 0;
195 anim
.initialframe_bm
= NULL
;
199 anim
.first_frame
= NULL
;
200 anim
.last_frame
= NULL
;
201 anim
.initial_frame
.cmap
= NULL
;
210 for (a
= 0; a
< 2; a
++) iffbm
[a
] = anim
.frame_bm
[a
] = NULL
;
212 if (readfile(name
,&picbuffer
,(int *)&buffersize
)) return(0);
214 if (! chunkread(chunkbuf
,sizeof(ULONG
)*3) ||
215 chunkbuf
[0] != ID_FORM
||
216 ((chunkbuf
[2] != ID_ANIM
) && (chunkbuf
[2] != ID_ILBM
)))
221 if ((dto
= NewDTObject(name
,DTA_GroupID
,GID_PICTURE
,
222 // PDTA_Remap, FALSE,
223 PDTA_FreeSourceBitMap
, TRUE
,
226 struct BitMapHeader
*dto_bmhd
;
229 PDTA_ModeID
, &viewmode
,
230 PDTA_BitMapHeader
, &dto_bmhd
,
231 PDTA_ColorRegisters
, &colourptr
,
232 PDTA_NumColors
, &coloursize
,
235 D(bug("viewmode(0) = %08lx\n",viewmode
));
241 //D(KDump(colourptr,coloursize));
247 retcode
=IFFERR_NOTILBM
;
253 if (chunkbuf
[2] == ID_ANIM
) isanim
= 1;
255 while (bufferpos
<=buffersize
) {
256 if (!chunkread(&chunkid
,sizeof(int)) ||
257 !chunkread(&chunksize
,sizeof(int)) ||
258 ((bufferpos
+chunksize
)>buffersize
)) break;
265 if (!(chunkread(&dpan
,sizeof(DPAnimChunk
)))) {
266 retcode
=IFFERR_BADIFF
;
270 maxframes
=dpan
.nframes
;
271 if ((anim
.framespersec
=dpan
.framespersecond
)>0)
272 anim
.speed
=1000000/dpan
.framespersecond
;
276 if (isanim
&& anim
.framecount
<maxframes
&&
277 (frame
=LAllocRemember(&iffkey
,sizeof(struct AnimFrame
),MEMF_CLEAR
))) {
278 frame
->animheader
=(struct AnimHeader
*)(picbuffer
+bufferpos
);
279 if (frame
->animheader
->ah_Interleave
!=1) doublebuffer
=1;
280 if (!anim
.type
) anim
.type
=frame
->animheader
->ah_Operation
;
282 if (cur_frame
) cur_frame
->next
=frame
;
283 else anim
.first_frame
=frame
;
288 if (isanim
&& anim
.framecount
<maxframes
&& cur_frame
) {
289 cur_frame
->delta
=picbuffer
+bufferpos
;
294 if (!chunkread(&bmhd
,sizeof(struct BitMapHeader
))) {
295 retcode
=IFFERR_BADIFF
;
298 if ((! isanim
) && (bmhd
.bmh_Depth
> 8)) goto DTload
;
303 colourptr
=bufferpos
; coloursize
=chunksize
;
304 anim
.initial_frame
.cmap
=(unsigned char *)&picbuffer
[bufferpos
];
305 anim
.initial_frame
.cmapsize
=chunksize
;
307 else if (isanim
&& anim
.framecount
<maxframes
&& cur_frame
) {
308 cur_frame
->cmap
=(unsigned char *)&picbuffer
[bufferpos
];
309 cur_frame
->cmapsize
=chunksize
;
316 if (!chunkread(&viewmode
,sizeof(int))) {
317 retcode
=IFFERR_BADIFF
;
321 D(bug("viewmode(0) = %08lx\n",viewmode
));
324 if ((copperlist
=LAllocRemember(&iffkey
,chunksize
,MEMF_CLEAR
))) {
325 coppersize
=chunksize
;
326 copperheight
=chunksize
/32;
327 CopyMem((char *)&picbuffer
[bufferpos
],(char *)copperlist
,chunksize
);
328 CopyMem((char *)&picbuffer
[bufferpos
],(char *)colourlist
,8);
336 if (!(pchghead
=PCHG_SHAM2PCHG((UWORD
*)&picbuffer
[bufferpos
],chunksize
,(viewmode
&LACE
)?2:1))) {
337 retcode
=IFFERR_NOMEM
;
340 sham
=&picbuffer
[bufferpos
];
344 pchghead
=(struct PCHGHeader
*)&picbuffer
[bufferpos
];
350 CopyMem((char *)&picbuffer
[bufferpos
],(char *)&cyclerange
[currange
],sizeof(CRange
));
351 if (cyclerange
[currange
].rate
<=CRNG_NORATE
||
352 cyclerange
[currange
].low
==cyclerange
[currange
].high
)
353 cyclerange
[currange
].active
=0;
354 if (cyclerange
[currange
].rate
>CRNG_NORATE
)
355 cyclerange
[currange
].rate
=16384/cyclerange
[currange
].rate
;
356 else cyclerange
[currange
].rate
=0;
363 bodyptr
=picbuffer
+bufferpos
;
368 bufferpos
+=chunksize
;
369 if (chunksize
&1) ++bufferpos
;
374 retcode
=IFFERR_BADIFF
;
378 if (copperlist
) specialformat
=1;
381 depth
= bmhd
.bmh_Depth
;
384 numcolours
=coloursize
/3;
386 if (/*system_version2>=OSVER_39 &&*/ !specialformat
)
387 colourtable_8
=LAllocRemember(&iffkey
,(coloursize
+2)*sizeof(APTR
),MEMF_CLEAR
);
389 colourtable_4
=LAllocRemember(&iffkey
,numcolours
*sizeof(UWORD
),MEMF_CLEAR
);
392 if (!colourtable_8
&& !colourtable_4
) {
393 retcode
=IFFERR_BADIFF
;
397 if ((config
->viewbits
&VIEWBITS_8BITSPERGUN
|| bmhd
.bmh_Pad
&BMHF_CMAPOK
) &&
398 colourtable_8
) palette32
=1;
400 build_palettes(&picbuffer
[colourptr
],coloursize
,colourtable_4
,colourtable_8
);
402 imagewidth
= bmhd
.bmh_Width
;
403 screenwidth
= bmhd
.bmh_Width
;
404 imageheight
= bmhd
.bmh_Height
;
405 screenheight
= bmhd
.bmh_Height
;
411 maxheight
= (scrdata_is_pal
? 281 : 241);
413 if (viewmode
==-1 || brush
) {
414 viewflags
=viewmode
; viewmode
=0;
415 if (bmhd
.bmh_PageWidth
>maxwidth
) viewmode
|=HIRES
;
416 if (bmhd
.bmh_PageHeight
>maxheight
) viewmode
|=LACE
;
420 if (!(ModeNotAvailable(viewmode
))) extflag
= 1;
421 D(bug("extflag,viewmode(1) = %ld,%08lx\n",extflag
,viewmode
));
422 if (config
->viewbits
& VIEWBITS_BESTMODEID
)
426 if (!(ModeNotAvailable((newmode
=BestModeID(
427 // BIDTAG_NominalWidth,imagewidth,
428 // BIDTAG_NominalHeight,imageheight,
429 BIDTAG_DesiredWidth
,imagewidth
,
430 BIDTAG_DesiredHeight
,imageheight
,
432 BIDTAG_SourceID
,viewmode
,
433 BIDTAG_MonitorID
,GetVPModeID(&Window
->WScreen
->ViewPort
) & MONITOR_ID_MASK
,
434 TAG_END
))))) viewmode
=newmode
;
435 D(bug("extflag,viewmode(2) = %ld,%08lx\n",extflag
,viewmode
));
438 if ((handle
=FindDisplayInfo(viewmode
))) {
439 if (!(a
=GetDisplayInfoData(handle
,dimbuf
,DIMBUFSIZE
,DTAG_NAME
,0))) {
440 DisplayInfoHandle
*temphandle
;
443 tempviewmode
=viewmode
;
444 tempviewmode
&=~(HAM_KEY
|EXTRAHALFBRITE_KEY
);
446 if ((temphandle
=FindDisplayInfo(tempviewmode
)))
447 a
=GetDisplayInfoData(temphandle
,dimbuf
,DIMBUFSIZE
,DTAG_NAME
,0);
449 if (a
&& (((struct NameInfo
*)dimbuf
)->Name
)) {
450 strcpy(iffscreenname
,((struct NameInfo
*)dimbuf
)->Name
);
451 if ((ptr
=strchr(iffscreenname
,':'))) strcpy(iffscreenname
,ptr
+1);
453 GetDisplayInfoData(handle
,dimbuf
,DIMBUFSIZE
,DTAG_DIMS
,0);
454 dimension
=(struct DimensionInfo
*)dimbuf
;
455 maxwidth
=(dimension
->StdOScan
.MaxX
-dimension
->StdOScan
.MinX
)+1;
456 maxheight
=(dimension
->StdOScan
.MaxY
-dimension
->StdOScan
.MinY
)+1;
457 if (depth
>dimension
->MaxDepth
) {
458 retcode
=IFFERR_BADMODE
;
465 if ((viewmode
&SUPER_KEY
)==SUPER_KEY
) viewflags
|=SUPERHIRES
|HIRES
;
466 else if (viewmode
&HIRES_KEY
) viewflags
|=HIRES
;
467 if (viewmode
&LORESLACE_KEY
) viewflags
|=LACE
;
468 if (viewmode
&HAM_KEY
) viewflags
|=HAM
;
469 if (viewmode
&EXTRAHALFBRITE_KEY
) viewflags
|=EXTRA_HALFBRITE
;
473 D(bug("extflag,viewmode(3) = %ld,%08lx\n",extflag
,viewmode
));
474 viewmode
&=0x0000ffff;
475 viewmode
&=~(SPRITES
|GENLOCK_AUDIO
|GENLOCK_VIDEO
|VP_HIDE
|DUALPF
|PFBA
|EXTENDED_MODE
);
477 D(bug("extflag,viewmode(4) = %ld,%08lx\n",extflag
,viewmode
));
479 if (viewflags
&HIRES
) {
480 maxwidth
*= (viewflags
&SUPERHIRES
) ? 4 : 2;
485 if (screenwidth
< minwidth
) screenwidth
= minwidth
;
486 else if (screenwidth
> maxwidth
) screenwidth
= maxwidth
;
488 if (!extflag
&& viewflags
& LACE
) {
492 if (screenheight
< minheight
) screenheight
= minheight
;
493 else if (screenheight
> maxheight
) screenheight
= maxheight
;
495 bitmapwidth
= (imagewidth
< screenwidth
) ? screenwidth
: imagewidth
;
496 bitmapheight
= (imageheight
< screenheight
) ? screenheight
: imageheight
;
498 if ((bitmapwidth
> screenwidth
) || (bitmapheight
> screenheight
)) scroll
=3;
502 if (isanim
&& anim
.first_frame
) {
503 if (!(anim
.frame_bm
[0]=AllocBitMap(bitmapwidth
,bitmapheight
,bmhd
.bmh_Depth
,BMF_DISPLAYABLE
|BMF_CLEAR
,NULL
))) {
504 retcode
=IFFERR_NOMEM
;
508 if ((anim
.frame_bm
[1]=AllocBitMap(bitmapwidth
,bitmapheight
,bmhd
.bmh_Depth
,BMF_DISPLAYABLE
|BMF_CLEAR
,NULL
))) {
509 anim
.initialframe_bm
=AllocBitMap(bitmapwidth
,bitmapheight
,bmhd
.bmh_Depth
,BMF_DISPLAYABLE
|BMF_CLEAR
,NULL
);
511 if (/*system_version2>=OSVER_39 && */
512 (dbufinfo
=AllocDBufInfo(ivp
))) {
513 if (dbufport
=LCreatePort(NULL
,0)) {
514 dbufinfo
->dbi_SafeMessage
.mn_ReplyPort
=dbufport
;
515 dbufinfo
->dbi_SafeMessage
.mn_Length
=sizeof(struct Message
);
525 if (anim
.frame_bm
[a
]) {
526 if (!(iffbm
[a
]=LAllocRemember(&iffkey
,sizeof(struct BitMap
),MEMF_CLEAR
))) {
527 retcode
=IFFERR_NOMEMORY
;
530 CopyMem((char *)anim
.frame_bm
[a
],(char *)iffbm
[a
],sizeof(struct BitMap
));
538 iffbm
[0]=AllocBitMap(bitmapwidth
,bitmapheight
,depth
,BMF_DISPLAYABLE
|BMF_CLEAR
,NULL
);
540 if (iffbm
[0] == NULL
)
542 retcode
= IFFERR_NOMEMORY
;
548 D(bug("extflag,viewmode(5) = %ld,%lx\n",extflag
,viewmode
));
549 if (!(iffscreen
= OpenScreenTags(NULL
,
550 SA_Width
, bitmapwidth
,
551 SA_Height
, bitmapheight
,
553 dt_ok
?SA_Type
:SA_BitMap
, dt_ok
?CUSTOMSCREEN
:(IPTR
)iffbm
[0],
555 SA_DisplayID
, viewmode
,
557 SA_Overscan
, OSCAN_MAX
,
560 SA_Colors32
, colourtable_8
,
561 // SA_ErrorCode, (Tag)&err,
564 retcode
= IFFERR_NOSCREEN
;
568 ivp
= &(iffscreen
->ViewPort
);
569 if (!dt_ok
) LoadRGB4(ivp
,nullpalette
,1<<(depth
>8?8:depth
));
571 iffwin
.Screen
= iffscreen
;
572 iffwin
.Width
= iffscreen
->Width
;
573 iffwin
.Height
= iffscreen
->Height
;
575 if (!(iffwindow
=OpenWindow(&iffwin
))) {
576 retcode
=IFFERR_NOSCREEN
;
582 SetDTAttrs(dto
,NULL
,NULL
,PDTA_Screen
,iffscreen
,TAG_END
);
583 DoDTMethod(dto
, iffwindow
, NULL
, DTM_PROCLAYOUT
, NULL
, 1);
584 GetDTAttrs(dto
, PDTA_DestBitMap
, &iffbm
[0],TAG_END
);
585 D(bug("PDTA_DestBitMap: %08lx\n",iffbm
[0]));
588 GetDTAttrs(dto
, PDTA_BitMap
, &iffbm
[0],TAG_END
);
589 D(bug("PDTA_BitMap: %08lx\n",iffbm
[0]));
591 // if (!(iffbm[0])) GetDTAttrs(dto, PDTA_ClassBitMap, (Tag)&iffbm[0],TAG_END);
592 //D(bug("PDTA_ClassBitMap: %08lx\n",iffbm[0]));
595 retcode
=IFFERR_NOMEMORY
;
599 D(KDump(iffbm
[0],sizeof(struct BitMap
)));
601 BltBitMapRastPort(iffbm
[0],0,0,iffwindow
->RPort
,0,0,bitmapwidth
,bitmapheight
,0xC0);
604 setnullpointer(iffwindow
);
606 if (isanim
&& anim
.first_frame
) {
609 anim
.current_frame
=anim
.first_frame
;
611 rletobuffer(bodyptr
,bmhd
.bmh_Width
,bmhd
.bmh_Height
,anim
.frame_bm
[0],bmhd
.bmh_Masking
,bmhd
.bmh_Compression
);
614 if (anim
.frame_bm
[1]) {
615 BltBitMap(anim
.frame_bm
[0],0,0,anim
.frame_bm
[1],0,0,bmhd
.bmh_Width
,bmhd
.bmh_Height
,0xc0,0xff,NULL
);
616 if (anim
.initialframe_bm
)
617 BltBitMap(anim
.frame_bm
[0],0,0,anim
.initialframe_bm
,0,0,bmhd
.bmh_Width
,bmhd
.bmh_Height
,0xc0,0xff,NULL
);
622 anim
.frameimage
.LeftEdge
=(bitmapwidth
-bmhd
.bmh_Width
)/2;
623 anim
.frameimage
.TopEdge
=(bitmapheight
-bmhd
.bmh_Height
)/2;
627 else if (!dt_ok
) readpic(&bmhd
,bodyptr
,iffbm
[0]);
629 if (numcolours
>ivp
->ColorMap
->Count
) numcolours
=ivp
->ColorMap
->Count
;
637 if (palette32
) LoadRGB32(ivp
,colourtable_8
);
638 else LoadRGB4(ivp
,colourtable_4
,numcolours
);
643 if (sham
) PCHG_SetUserCopList(0,0,ivp
,pchghead
,&pchghead
[1],sham
);
644 else PCHG_ParsePCHG(pchghead
,ivp
);
647 ActivateWindow(iffwindow
);
648 ScreenToFront(iffscreen
);
651 struct View
*view
= ViewAddress();
653 if ((copperheight
>>1)>scrdata_norm_height
) view
->DyOffset
=14+(/*system_version2?*/8/*:0*/);
654 if (mp
) LoadRGB4(ivp
,colourlist
,4);
655 if (!InitDHIRES(mp
)) {
658 else if ((depth
<=8) && !specialformat
&& !(viewflags
&HAM
)) {
659 if (palette32
) FadeRGB32(iffscreen
,&colourtable_8
[1],numcolours
,1,config
->fadetime
);
660 else FadeRGB4(iffscreen
,colourtable_4
,numcolours
,1,config
->fadetime
);
663 if (currange
) initcycle(ivp
,colourtable_4
,numcolours
,cyclerange
,currange
);
665 retcode
= (WaitForMouseClick(scroll
,iffwindow
) ? -1 : 1);
667 if (checkcycling()) togglecycle();
671 ScreenToBack(iffscreen
);
672 FreeVPortCopLists(ivp
);
674 else if ((depth
<=8) && a
!=-3 && !(viewflags
&HAM
)) {
675 if (palette32
) FadeRGB32(iffscreen
,&colourtable_8
[1],numcolours
,-1,config
->fadetime
);
676 else FadeRGB4(iffscreen
,colourtable_4
,numcolours
,-1,config
->fadetime
);
681 FreeDBufInfo(dbufinfo
);
682 if (dbufport
) LDeletePort(dbufport
);
684 ScreenToFront(blankscreen
? blankscreen
: Window
->WScreen
);
687 CloseWindow(iffwindow
);
691 CloseScreen(iffscreen
);
696 DisposeDTObject(dto
);
701 for (a
= 0; a
< 2; a
++)
703 FreeBitMap(iffbm
[a
]);
704 FreeBitMap(anim
.frame_bm
[a
]);
706 FreeBitMap(anim
.initialframe_bm
);
709 ActivateWindow(Window
);
711 if (pchghead
&& sham
) {
712 FreeMem(pchghead
,sizeof(struct PCHGHeader
)+((pchghead
->LineCount
+31)/32)*4);
715 LFreeRemember(&iffkey
);
718 anim
.first_frame
= NULL
;
719 colourtable_8
= NULL
;
720 colourtable_4
= NULL
;
725 void rletobuffer(source
,sourcewidth
,sourceheight
,dest
,mask
,comp
)
726 unsigned char *source
;
727 int sourcewidth
,sourceheight
;
731 struct RLEinfo picinfo
;
733 picinfo
.sourceptr
=source
;
734 picinfo
.destplanes
=dest
->Planes
;
735 picinfo
.imagebpr
=((sourcewidth
+15)/16)*2;
736 picinfo
.imageheight
=sourceheight
;
737 picinfo
.imagedepth
=dest
->Depth
;
738 picinfo
.destbpr
=dest
->BytesPerRow
;
739 picinfo
.destheight
=dest
->Rows
;
740 picinfo
.destdepth
=dest
->Depth
;
741 picinfo
.masking
=mask
;
742 picinfo
.compression
=comp
;
748 void readpic(bmhd
,source
,bmap
)
749 struct BitMapHeader
*bmhd
;
750 unsigned char *source
;
753 int rowbytes
,bmrbytes
,rows
;
755 struct RLEinfo picinfo
;
757 rowbytes
=((bmhd
->bmh_Width
+15)/16)*2;
758 bmrbytes
=((GetBitMapAttr(bmap
,BMA_WIDTH
)+15)/16)*2;
760 if ((rows
=bmhd
->bmh_Height
)>bmap
->Rows
) rows
=bmap
->Rows
;
762 picinfo
.sourceptr
=source
;
763 picinfo
.destplanes
=bmap
->Planes
;
764 picinfo
.imagebpr
=rowbytes
;
765 picinfo
.imageheight
=rows
;
766 picinfo
.imagedepth
=bmhd
->bmh_Depth
;
767 picinfo
.destbpr
=bmrbytes
;
768 picinfo
.destheight
=bmap
->Rows
;
769 picinfo
.destdepth
=bmap
->Depth
;
770 picinfo
.masking
=bmhd
->bmh_Masking
;
771 picinfo
.compression
=bmhd
->bmh_Compression
;
772 picinfo
.offset
=byteoff
;
777 void decoderle(rleinfo
)
778 struct RLEinfo
*rleinfo
;
780 register char *source
,*dest
;
781 register int copy
,col
;
783 register int plane
,row
,bmoffset
,planes
;
785 planes
=rleinfo
->imagedepth
;
786 if (rleinfo
->masking
==mskHasMask
) ++planes
;
787 source
=rleinfo
->sourceptr
;
789 switch (rleinfo
->compression
) {
791 bmoffset
=rleinfo
->offset
;
792 for (row
=0;row
<rleinfo
->imageheight
;row
++) {
793 for (plane
=0;plane
<planes
;plane
++) {
794 if (plane
<rleinfo
->destdepth
&& rleinfo
->destplanes
[plane
])
795 dest
=(char *)(rleinfo
->destplanes
[plane
]+bmoffset
);
798 for (col
=0;col
<rleinfo
->imagebpr
;) {
799 if ((count
=*source
++)>=0) {
803 while (copy
--) *dest
++=*source
++;
807 else if (count
!=-128) {
811 while (copy
--) *dest
++=*source
;
817 bmoffset
+=rleinfo
->destbpr
;
821 bmoffset
=rleinfo
->offset
;
822 for (row
=0;row
<rleinfo
->imageheight
;row
++) {
823 for (plane
=0;plane
<planes
;plane
++) {
824 if (plane
<rleinfo
->destdepth
)
825 CopyMem(source
,(char *)rleinfo
->destplanes
[plane
]+bmoffset
,rleinfo
->imagebpr
);
826 source
+=rleinfo
->imagebpr
;
828 bmoffset
+=rleinfo
->destbpr
;
836 struct AnimFrame
*frame
;
838 if (anim
.last_frame
) {
839 frame
=anim
.last_frame
;
840 anim
.last_frame
=anim
.last_frame
->next
;
843 frame
=&anim
.initial_frame
;
844 anim
.last_frame
=anim
.first_frame
;
848 build_palettes(frame
->cmap
,frame
->cmapsize
,colourtable_4
,colourtable_8
);
849 if (palette32
) LoadRGB32(ivp
,colourtable_8
);
850 else LoadRGB4(ivp
,colourtable_4
,numcolours
);
853 if (doublebuffer
&& iffbm
[1]) {
856 ChangeVPBitMap(ivp
,iffbm
[anim
.framedisp
],dbufinfo
);
861 iffscreen
->RastPort
.BitMap
=iffbm
[anim
.framedisp
];
862 iffscreen
->ViewPort
.RasInfo
->BitMap
=iffbm
[anim
.framedisp
];
863 MakeScreen(iffscreen
);
867 iffscreen
->RastPort
.BitMap
=iffbm
[anim
.framedisp
];
868 iffscreen
->ViewPort
.RasInfo
->BitMap
=iffbm
[anim
.framedisp
];
869 MakeScreen(iffscreen
);
874 BltBitMap(anim
.frame_bm
[anim
.framedisp
],0,0,
875 iffwindow
->RPort
->BitMap
,anim
.frameimage
.LeftEdge
,anim
.frameimage
.TopEdge
,
876 bmhd
.bmh_Width
,bmhd
.bmh_Height
,0xc0,0xff,NULL
);
879 if (anim
.frame_bm
[1]) anim
.framedisp
=1-anim
.framedisp
;
881 if (!anim
.current_frame
) {
882 if (anim
.frame_bm
[1]) {
883 if (anim
.initialframe_bm
) {
884 BltBitMap(anim
.initialframe_bm
,0,0,
885 anim
.frame_bm
[anim
.framedisp
],0,0,
886 bmhd
.bmh_Width
,bmhd
.bmh_Height
,0xc0,0xff,NULL
);
889 else rletobuffer(bodyptr
,bmhd
.bmh_Width
,bmhd
.bmh_Height
,
890 anim
.frame_bm
[anim
.framedisp
],bmhd
.bmh_Masking
,bmhd
.bmh_Compression
);
892 if (got_dpan
|| anim
.framenum
==0) {
893 anim
.current_frame
=anim
.first_frame
;
894 anim
.last_frame
=anim
.first_frame
;
897 else anim
.framenum
=0;
900 if (anim
.framenum
>0) {
901 switch (anim
.current_frame
->animheader
->ah_Operation
) {
903 if (anim
.current_frame
->delta
)
904 rletobuffer(anim
.current_frame
->delta
,bmhd
.bmh_Width
,bmhd
.bmh_Height
,
905 anim
.frame_bm
[anim
.framedisp
],bmhd
.bmh_Masking
,bmhd
.bmh_Compression
);
908 doriff(anim
.current_frame
->delta
,anim
.frame_bm
[anim
.framedisp
],
909 (anim
.current_frame
->animheader
->ah_Flags
&2 || !anim
.frame_bm
[1]),bmhd
.bmh_Width
,0);
912 doriff7(anim
.current_frame
->delta
,anim
.frame_bm
[anim
.framedisp
],
913 bmhd
.bmh_Width
,(anim
.current_frame
->animheader
->ah_Flags
&1)?2:1);
916 doriff(anim
.current_frame
->delta
,anim
.frame_bm
[anim
.framedisp
],
917 1,bmhd
.bmh_Width
,(anim
.current_frame
->animheader
->ah_Flags
&1)?2:1);
921 anim
.current_frame
=anim
.current_frame
->next
;
925 void doriff(delta
,image
,xor,sourcewidth
,size
)
926 unsigned char *delta
;
927 struct BitMap
*image
;
928 int xor,sourcewidth
,size
;
933 sourcewidth
=((sourcewidth
+15)/16)*2;
935 if ((dptr
=(int *)delta
)) {
936 for (plane
=0;plane
<image
->Depth
;plane
++) {
938 data
=(unsigned char *)delta
+dptr
[plane
];
940 if (xor) decode_riff_xor(data
,image
->Planes
[plane
],image
->BytesPerRow
,sourcewidth
);
941 else decode_riff_set(data
,image
->Planes
[plane
],image
->BytesPerRow
,sourcewidth
);
944 decode_riff_short((UWORD
*)data
,image
->Planes
[plane
],image
->BytesPerRow
,sourcewidth
);
945 else decode_riff_long((ULONG
*)data
,image
->Planes
[plane
],image
->BytesPerRow
,sourcewidth
);
951 void doriff7(delta
,image
,sourcewidth
,size
)
952 unsigned char *delta
;
953 struct BitMap
*image
;
954 int sourcewidth
,size
;
958 unsigned char *opcode
;
960 sourcewidth
=((sourcewidth
+15)/16)*2;
962 if ((dptr
=(int *)delta
)) {
963 for (plane
=0;plane
<image
->Depth
;plane
++) {
964 if (dptr
[plane
] && dptr
[plane
+8]) {
965 opcode
=(unsigned char *)delta
+dptr
[plane
];
966 data
=(unsigned char *)delta
+dptr
[plane
+8];
968 decode_riff7_short((UWORD
*)data
,opcode
,image
->Planes
[plane
],image
->BytesPerRow
,sourcewidth
);
969 else decode_riff7_long((ULONG
*)data
,opcode
,image
->Planes
[plane
],image
->BytesPerRow
,sourcewidth
);
975 void decode_riff_xor(delta
,image
,rowbytes
,sourcebytes
)
976 unsigned char *delta
;
978 int rowbytes
,sourcebytes
;
981 unsigned char *data
,ch
;
983 for (column
=0;column
<sourcebytes
;column
++) {
989 if (!(ch
&128)) data
+=rowbytes
*ch
;
1010 void decode_riff_set(delta
,image
,rowbytes
,sourcebytes
)
1011 unsigned char *delta
;
1013 int rowbytes
,sourcebytes
;
1016 unsigned char *data
,ch
;
1018 for (column
=0;column
<sourcebytes
;column
++) {
1024 if (!(ch
&128)) data
+=rowbytes
*ch
;
1045 void decode_riff_short(delta
,image
,rowbytes
,sourcebytes
)
1047 unsigned char *image
;
1048 int rowbytes
,sourcebytes
;
1051 unsigned char *data
;
1056 for (column
=0;column
<sourcebytes
;column
++) {
1057 data
=(unsigned char *)(image
+(column
*2));
1062 if (!(ch
&0x8000)) data
+=rowbytes
*ch
;
1066 *(UWORD
*)data
=*delta
++;
1074 *(UWORD
*)data
=*delta
;
1083 void decode_riff_long(delta
,image
,rowbytes
,sourcebytes
)
1085 unsigned char *image
;
1086 int rowbytes
,sourcebytes
;
1089 unsigned char *data
;
1094 for (column
=0;column
<sourcebytes
;column
++) {
1095 data
=(unsigned char *)(image
+(column
*4));
1100 if (!(ch
&0x80000000)) data
+=rowbytes
*ch
;
1104 *(ULONG
*)data
=*delta
++;
1112 *(ULONG
*)data
=*delta
;
1121 void decode_riff7_short(delta
,opcode
,image
,rowbytes
,sourcebytes
)
1123 unsigned char *opcode
;
1124 unsigned char *image
;
1125 int rowbytes
,sourcebytes
;
1128 unsigned char *data
,ch
;
1132 for (column
=0;column
<sourcebytes
;column
++) {
1133 data
=(unsigned char *)(image
+(column
*2));
1138 if (!(ch
&0x80)) data
+=rowbytes
*ch
;
1142 *(UWORD
*)data
=*delta
++;
1150 *(UWORD
*)data
=*delta
;
1159 void decode_riff7_long(delta
,opcode
,image
,rowbytes
,sourcebytes
)
1161 unsigned char *opcode
;
1162 unsigned char *image
;
1163 int rowbytes
,sourcebytes
;
1166 unsigned char *data
,ch
;
1170 for (column
=0;column
<sourcebytes
;column
++) {
1171 data
=(unsigned char *)(image
+(column
*4));
1176 if (!(ch
&0x80)) data
+=rowbytes
*ch
;
1180 *(ULONG
*)data
=*delta
++;
1188 *(ULONG
*)data
=*delta
;
1197 int WaitForMouseClick(tits
,wind
)
1199 struct Window
*wind
;
1201 struct IntuiMessage
*msg
;
1204 int ticks
,waitfor
=0,pon
=0,waitbits
,retcode
=1,gottimer
=0,origspeed
,startanim
,delta
;
1205 struct timerequest treq
;
1207 while ((msg
=(struct IntuiMessage
*) GetMsg(wind
->UserPort
)))
1208 ReplyMsg((struct Message
*)msg
);
1209 if (!anim
.first_frame
&& config
->showdelay
>0) {
1210 waitfor
=config
->showdelay
*10; ticks
=0;
1213 origspeed
=anim
.speed
;
1215 waitbits
=1<<wind
->UserPort
->mp_SigBit
;
1216 if (anim
.first_frame
) {
1217 if (!(OpenDevice(TIMERNAME
,UNIT_VBLANK
,&treq
.tr_node
,0))) {
1218 treq
.tr_node
.io_Message
.mn_ReplyPort
=general_port
;
1219 treq
.tr_node
.io_Command
=TR_ADDREQUEST
;
1220 treq
.tr_node
.io_Flags
=0;
1221 treq
.tr_time
.tv_secs
=0;
1222 treq
.tr_time
.tv_micro
=10;
1223 SendIO(&treq
.tr_node
);
1224 waitbits
|=1<<general_port
->mp_SigBit
;
1227 if (!(startanim
=(!(config
->viewbits
&VIEWBITS_PAUSEANIMS
))) && doublebuffer
)
1232 if (anim
.first_frame
) {
1233 while (GetMsg(general_port
));
1234 if (CheckIO(&treq
.tr_node
)) {
1235 WaitIO(&treq
.tr_node
);
1236 treq
.tr_time
.tv_secs
=0;
1237 treq
.tr_time
.tv_micro
=anim
.speed
;
1238 SendIO(&treq
.tr_node
);
1239 if (startanim
) doanimframe();
1242 while ((msg
=(struct IntuiMessage
*) GetMsg(wind
->UserPort
))) {
1243 class=msg
->Class
; code
=msg
->Code
; qual
=msg
->Qualifier
;
1244 ReplyMsg((struct Message
*) msg
);
1246 case IDCMP_INTUITICKS
:
1247 if (waitfor
&& (++ticks
)>=waitfor
) retcode
=0;
1250 if (code
>=0x50 && code
<=0x59) { // F1-F10
1252 anim
.speed
=(code
*10000)+10;
1257 if ((anim
.speed
+=10000)>1000000) anim
.speed
=1000000;
1260 if ((anim
.speed
-=10000)<10) anim
.speed
=10;
1263 anim
.speed
=origspeed
;
1266 startanim
=1-startanim
;
1269 if (anim
.first_frame
) {
1275 case RAWKEY_NM_WHEEL_LEFT
:
1278 case RAWKEY_NM_WHEEL_RIGHT
:
1281 if (qual
&IEQUALIFIER_CONTROL
) delta
=bitmapwidth
;
1282 else if (qual
&IEQUALIFIER_ANYSHIFT
) delta
=screenwidth
-20;
1284 if (code
==CURSOR_LEFT
|| code
==0x2d || code
== RAWKEY_NM_WHEEL_LEFT
) delta
=-delta
;
1286 MoveScreen(wind
->WScreen
,-delta
,0);
1289 case RAWKEY_NM_WHEEL_UP
:
1292 case RAWKEY_NM_WHEEL_DOWN
:
1295 if (qual
&IEQUALIFIER_CONTROL
) delta
=bitmapheight
;
1296 else if (qual
&IEQUALIFIER_ANYSHIFT
) delta
=screenheight
-20;
1298 if (code
==CURSOR_UP
|| code
==RAWKEY_NM_WHEEL_UP
|| code
==0x3e) {
1300 if (wind
->WScreen
->TopEdge
> delta
) delta
= wind
->WScreen
->TopEdge
;
1302 MoveScreen(wind
->WScreen
,0,-delta
);
1305 retcode
= ((tits
== 2) ? -2 : 0);
1311 if (!(qual
&IEQUALIFIER_REPEAT
)) retcode
=0;
1314 if (tits
&1 && currange
) togglecycle();
1319 if (!(qual
&IEQUALIFIER_REPEAT
)) {
1320 ModifyIDCMP(wind
,(wind
->IDCMPFlags
&~IDCMP_INACTIVEWINDOW
)|IDCMP_ACTIVEWINDOW
);
1321 if (tits
&1) gfxprint(wind
,&iffscreen
->RastPort
,0,0,bitmapwidth
,bitmapheight
,1);
1322 else gfxprint(wind
,wind
->RPort
,0,0,wind
->Width
,wind
->Height
,0);
1326 if (pon
) setnullpointer(wind
);
1327 else ClearPointer(wind
);
1331 if (colourtable_4
&& !specialformat
)
1332 LoadRGB4(ivp
,colourtable_4
,numcolours
);
1335 if (colourtable_8
&& !specialformat
)
1336 LoadRGB32(ivp
,colourtable_8
);
1340 case IDCMP_ACTIVEWINDOW
:
1341 ModifyIDCMP(wind
,(wind
->IDCMPFlags
&~IDCMP_ACTIVEWINDOW
)|IDCMP_INACTIVEWINDOW
);
1343 case IDCMP_INACTIVEWINDOW
:
1344 if (IntuitionBase
->ActiveScreen
!=wind
->WScreen
) {
1349 case IDCMP_MOUSEBUTTONS
:
1350 if (code
==SELECTDOWN
) retcode
=0;
1351 else if (code
==MENUDOWN
) retcode
=-1;
1354 if (retcode
!=1) break;
1356 if (retcode
!=1) break;
1359 if (anim
.first_frame
&& gottimer
) {
1360 if (!(CheckIO(&treq
.tr_node
)))
1361 AbortIO(&treq
.tr_node
);
1362 WaitIO(&treq
.tr_node
);
1363 CloseDevice(&treq
.tr_node
);
1364 while (GetMsg(general_port
));
1369 int chunkread(buf
,nbytes
)
1373 if (bufferpos
+nbytes
>buffersize
) return(0);
1374 CopyMem((char *)&picbuffer
[bufferpos
],(char *)buf
,nbytes
);
1379 void getcolstring(str
)
1382 if (viewflags
&HAM
|| specialformat
) {
1383 if (bmhd
.bmh_Depth
==8) strcpy(str
,"256K");
1384 else strcpy(str
,"4096");
1386 else lsprintf(str
,"%ld",(long int)(1<<bmhd
.bmh_Depth
));
1389 void gfxprint(wind
,rast
,x
,y
,w
,h
,iff
)
1390 struct Window
*wind
;
1391 struct RastPort
*rast
;
1394 static struct NewScreen printscreen
={
1397 CUSTOMSCREEN
|SCREENQUIET
|SCREENBEHIND
|NS_EXTENDED
,
1398 &screen_attr
,NULL
,NULL
,NULL
};
1399 static struct NewWindow printwin
={
1401 IDCMP_GADGETUP
|IDCMP_VANILLAKEY
,
1402 WFLG_RMBTRAP
|WFLG_BORDERLESS
,
1403 NULL
,NULL
,NULL
,NULL
,NULL
,
1404 0,0,0,0,CUSTOMSCREEN
};
1406 printcheckimage
={7,2,13,7,1,NULL
,1,0,NULL
},
1407 printnullcheckimage
={7,2,13,7,1,NULL
,0,0,NULL
};
1408 static struct Gadget
1410 {&printgadgets
[1],142,104,123,14,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
1411 NULL
,NULL
,NULL
,GAD_CYCLE
,NULL
,PRINT_ASPECT
,NULL
},
1412 {&printgadgets
[2],142,120,123,14,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
1413 NULL
,NULL
,NULL
,GAD_CYCLE
,NULL
,PRINT_IMAGE
,NULL
},
1414 {&printgadgets
[3],142,136,123,14,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
1415 NULL
,NULL
,NULL
,GAD_CYCLE
,NULL
,PRINT_SHADE
,NULL
},
1416 {&printgadgets
[4],142,152,123,14,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
1417 NULL
,NULL
,NULL
,GAD_CYCLE
,NULL
,PRINT_PLACE
,NULL
},
1418 {&printgadgets
[5],18,168,26,11,GFLG_GADGIMAGE
|GFLG_GADGHIMAGE
|GFLG_SELECTED
,GACT_RELVERIFY
|GACT_TOGGLESELECT
,GTYP_BOOLGADGET
,
1419 (APTR
)&printnullcheckimage
,(APTR
)&printcheckimage
,NULL
,GAD_CHECK
,NULL
,PRINT_FORMFD
,NULL
},
1420 {&printgadgets
[6],142,168,26,11,GFLG_GADGIMAGE
|GFLG_GADGHIMAGE
,GACT_RELVERIFY
|GACT_TOGGLESELECT
,GTYP_BOOLGADGET
,
1421 (APTR
)&printnullcheckimage
,(APTR
)&printcheckimage
,NULL
,GAD_CHECK
,NULL
,PRINT_TITLE
,NULL
},
1422 {&printgadgets
[7],20,186,100,12,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
1423 NULL
,NULL
,NULL
,0,NULL
,PRINT_OKAY
,NULL
},
1424 {NULL
,196,186,100,12,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
1425 NULL
,NULL
,NULL
,0,NULL
,PRINT_CANCEL
,NULL
}},
1427 NULL
,60,0,200,80,GFLG_GADGHCOMP
,GACT_RELVERIFY
,GTYP_BOOLGADGET
,
1428 NULL
,NULL
,NULL
,0,NULL
,PRINT_ABORT
,NULL
};
1430 print_gads_sel
[4]={0,0,0,0},
1431 print_gads_max
[4]={1,1,2,1};
1432 static UWORD basepalette
[4]={0xaaa,0x000,0xfff,0x679};
1433 static char firsttime
;
1435 struct IntuiMessage
*msg
;
1436 struct Window
*pwin
;
1437 struct Screen
*pscr
;
1438 struct RastPort
*prp
;
1439 struct DOpusRemember
*pkey
=NULL
;
1440 struct PrinterData
*pd
;
1441 struct Preferences
*prefs
;
1442 union printerIO
*print_request
; /* IO request for Print operation */
1445 UWORD code
,gadgetid
,qual
;
1446 int a
,/*b,*/abort
=0,goff
,fnum
;
1447 char buf
[200],modes
[140],*ptr
,pactcode
[6],cols
[30],title
[120];
1450 *printabortgadtxt
[2]={NULL
,NULL
},
1451 *print_aspect_txt
[2],
1452 *print_image_txt
[2],
1453 *print_shade_txt
[3],
1454 *print_placement_txt
[2],
1455 **print_gads_txt
[4]={
1459 print_placement_txt
};
1461 if (scrdata_is_pal
) {
1462 printscreen
.Height
=printwin
.Height
=256;
1466 printscreen
.Height
=printwin
.Height
=200;
1471 if (a
==5) printgadtxt
[a
]=globstring
[STR_PRINTTITLE
];
1472 else if (a
==6) printgadtxt
[a
]=globstring
[STR_PRINT
];
1473 else printgadtxt
[a
]=globstring
[STR_ASPECT
+a
];
1475 pactcode
[a
] = getkeyshortcut(printgadtxt
[a
]);
1477 if (!printgadtxt[a][b]) break;
1478 if (printgadtxt[a][b]=='_') {
1479 pactcode[a]=ToLower(printgadtxt[a][b+1]);
1486 printgadtxt
[7]=str_cancelstring
;
1487 printgadtxt
[8]=NULL
;
1488 printabortgadtxt
[0]=globstring
[STR_ABORT_PRINT
];
1490 print_aspect_txt
[a
]=globstring
[STR_PORTRAIT
+a
];
1491 print_image_txt
[a
]=globstring
[STR_POSITIVE
+a
];
1492 print_placement_txt
[a
]=globstring
[STR_CENTER
+a
];
1494 for (a
=0;a
<3;a
++) print_shade_txt
[a
]=globstring
[STR_BLACK_WHITE
+a
];
1496 /*if (system_version2 >= OSVER_39)*/
1498 class = BestModeID(BIDTAG_NominalWidth
, printscreen
.Width
,
1499 BIDTAG_NominalHeight
, printscreen
.Height
,
1500 BIDTAG_Depth
, printscreen
.Depth
,
1501 BIDTAG_MonitorID
, GetVPModeID(&Window
->WScreen
->ViewPort
) & MONITOR_ID_MASK
,
1503 D(bug("Print screen ModeID: %lx\n",class));
1504 if (class == INVALID_ID
) class = LORES_KEY
;
1506 if (!(pscr
=OpenScreenTags(&printscreen
,
1507 SA_DisplayID
, class,
1508 SA_Pens
, (IPTR
)scr_drawinfo
,
1511 LoadRGB4(&(pscr
->ViewPort
),basepalette
,4);
1512 printwin
.Screen
=pscr
;
1513 if (!(pwin
=OpenWindow(&printwin
))) {
1518 SetFont(prp
,scr_font
[FONT_GENERAL
]);
1520 Do3DFrame(prp
,0,4+goff
,320,88,globstring
[STR_DESCRIPTION
],2,1);
1521 Do3DFrame(prp
,0,98+goff
,320,86,globstring
[STR_PRINT_CONTROL
],2,1);
1524 ptr
=BaseName(picturename
);
1526 lsprintf(buf
,"%12s : %s",
1527 globstring
[STR_FILE
],
1529 iffinfotxt(prp
,buf
,7,19+goff
);
1531 lsprintf(buf
,"%12s : %ld x %ld",
1532 globstring
[STR_IMAGE_SIZE
],
1533 (long int)bmhd
.bmh_Width
,
1534 (long int)bmhd
.bmh_Height
);
1535 iffinfotxt(prp
,buf
,7,35+goff
);
1537 if (anim
.first_frame
) {
1538 if (anim
.framenum
<2) fnum
=1;
1539 else fnum
=anim
.framenum
-1;
1540 lsprintf(buf
,"%12s : %ld %s %ld @ %ld/sec",
1541 globstring
[STR_NUM_FRAMES
],
1544 (long int)(anim
.framecount
+(1-got_dpan
)),
1545 (long int)anim
.framespersec
);
1546 iffinfotxt(prp
,buf
,7,43+goff
);
1548 lsprintf(buf
,"%12s : ANIM Op %ld",
1549 globstring
[STR_ANIM_TYPE
],
1550 (long int)anim
.type
);
1551 iffinfotxt(prp
,buf
,7,51+goff
);
1553 lsprintf(title
,"IFF ANIM : %s %s %ld %s %ld %ld x %ld x %s\n\n",
1555 globstring
[STR_FRAME
],
1558 (long int)(anim
.framecount
+1),
1559 (long int)bmhd
.bmh_Width
,
1560 (long int)bmhd
.bmh_Height
,
1564 lsprintf(buf
,"%12s : %ld x %ld",
1565 globstring
[STR_PAGE_SIZE
],
1566 (long int)bmhd
.bmh_PageWidth
,
1567 (long int)bmhd
.bmh_PageHeight
);
1568 iffinfotxt(prp
,buf
,7,43+goff
);
1570 lsprintf(buf
,"%12s : %ld x %ld",
1571 globstring
[STR_SCREEN_SIZE
],
1572 (long int)iffscreen
->Width
,
1573 (long int)iffscreen
->Height
);
1574 iffinfotxt(prp
,buf
,7,51+goff
);
1576 lsprintf(title
,"IFF ILBM : %s %ld x %ld x %s\n\n",
1578 (long int)bmhd
.bmh_Width
,
1579 (long int)bmhd
.bmh_Height
,
1582 lsprintf(buf
,"%12s : %ld",
1583 globstring
[STR_DEPTH
],
1584 (long int)bmhd
.bmh_Depth
);
1585 iffinfotxt(prp
,buf
,7,67+goff
);
1587 lsprintf(buf
,"%12s : %s",
1588 globstring
[STR_COLOURS
],
1590 iffinfotxt(prp
,buf
,7,75+goff
);
1592 getviewmodes(modes
);
1593 lsprintf(buf
,"%12s : %s",
1594 globstring
[STR_SCREEN_MODES
],
1596 iffinfotxt(prp
,buf
,7,83+goff
);
1598 else if (show_global_font
) {
1599 char fontname
[40],*ptr
;
1601 strcpy(fontname
,show_global_font
->tf_Message
.mn_Node
.ln_Name
);
1602 if ((ptr
=strstri(fontname
,".font"))) *ptr
=0;
1604 lsprintf(buf
,"%12s : %s",
1605 globstring
[STR_FONT
],
1607 iffinfotxt(prp
,buf
,7,19+goff
);
1609 lsprintf(buf
,"%12s : %ld",
1610 globstring
[STR_FONT_SIZE
],
1611 (long int)show_global_font
->tf_YSize
);
1612 iffinfotxt(prp
,buf
,7,35+goff
);
1614 lsprintf(buf
,"%12s : %ld (%ld - %ld)",
1615 globstring
[STR_NUM_CHARS
],
1616 (long int)((show_global_font
->tf_HiChar
-show_global_font
->tf_LoChar
)+1),
1617 (long int)show_global_font
->tf_LoChar
,
1618 (long int)show_global_font
->tf_HiChar
);
1619 iffinfotxt(prp
,buf
,7,51+goff
);
1621 lsprintf(buf
,"%12s :",
1622 globstring
[STR_FONT_STYLE
]);
1623 if ((show_global_font
->tf_Style
&15)==0) strcat(buf
," NORMAL");
1625 if (show_global_font
->tf_Style
&FSF_UNDERLINED
) strcat(buf
," ULINED");
1626 if (show_global_font
->tf_Style
&FSF_BOLD
) strcat(buf
," BOLD");
1627 if (show_global_font
->tf_Style
&FSF_ITALIC
) strcat(buf
," ITALIC");
1628 if (show_global_font
->tf_Style
&FSF_EXTENDED
) strcat(buf
," EXTEND");
1630 iffinfotxt(prp
,buf
,7,67+goff
);
1632 lsprintf(buf
,"%12s :",globstring
[STR_FONT_FLAGS
]);
1633 if (show_global_font
->tf_Flags
&FPF_TALLDOT
) strcat(buf
," TALL");
1634 if (show_global_font
->tf_Flags
&FPF_WIDEDOT
) strcat(buf
," WIDE");
1635 if (show_global_font
->tf_Flags
&FPF_PROPORTIONAL
)
1636 strcat(buf
," PROP");
1637 iffinfotxt(prp
,buf
,7,75+goff
);
1639 lsprintf(title
,"Font : %s/%ld %ld chars (%ld - %ld)\n\n",
1640 fontname
,(long int)show_global_font
->tf_YSize
,
1641 (long int)((show_global_font
->tf_HiChar
-show_global_font
->tf_LoChar
)+1),
1642 (long int)show_global_font
->tf_LoChar
,
1643 (long int)show_global_font
->tf_HiChar
);
1645 else if (show_global_icon
) {
1646 lsprintf(buf
,"%12s : %s",
1647 globstring
[STR_ICON
],
1648 show_global_icon_name
);
1649 iffinfotxt(prp
,buf
,7,27+goff
);
1651 lsprintf(buf
,"%12s : %s",
1652 globstring
[STR_ICON_TYPE
],
1653 icon_type_names
[show_global_icon
->do_Type
-1]);
1654 iffinfotxt(prp
,buf
,7,43+goff
);
1656 lsprintf(buf
,"%12s : %s",
1657 globstring
[STR_ICON_ALTERNATE
],
1658 (show_global_icon
->do_Gadget
.Flags
&GFLG_GADGHIMAGE
)?
1659 globstring
[STR_YES
]:globstring
[STR_NO
]);
1660 iffinfotxt(prp
,buf
,7,59+goff
);
1662 if (show_global_icon
->do_DefaultTool
) {
1663 lsprintf(buf
,"%12s : %s",
1664 globstring
[STR_ICON_DEFAULTTOOL
],
1665 show_global_icon
->do_DefaultTool
);
1666 iffinfotxt(prp
,buf
,7,75+goff
);
1668 lsprintf(title
,"Workbench %s : %s\n\n",
1669 globstring
[STR_ICON
],
1670 show_global_icon_name
);
1673 for (a
=0;a
<8;a
++) printgadgets
[a
].TopEdge
+=goff
;
1674 printcheckimage
.ImageData
=(UWORD
*)DOpusBase
->pdb_check
;
1675 AddGadgetBorders(&pkey
,printgadgets
,4,2,1);
1676 AddGadgetBorders(&pkey
,&printgadgets
[PRINT_OKAY
],2,2,1);
1677 AddGadgets(pwin
,printgadgets
,printgadtxt
,8,2,1,1);
1680 struct Preferences prefs
;
1682 GetPrefs(&prefs
,sizeof(struct Preferences
));
1683 print_gads_sel
[PRINT_ASPECT
]=prefs
.PrintAspect
;
1684 print_gads_sel
[PRINT_IMAGE
]=prefs
.PrintImage
;
1685 print_gads_sel
[PRINT_SHADE
]=prefs
.PrintShade
;
1691 DoCycleGadget(&printgadgets
[a
],
1697 ScreenToFront(pscr
);
1698 ActivateWindow(pwin
);
1699 save
=main_proc
->pr_WindowPtr
;
1700 main_proc
->pr_WindowPtr
=(APTR
)pwin
;
1702 Wait(1<<pwin
->UserPort
->mp_SigBit
);
1705 while ((msg
=(struct IntuiMessage
*) GetMsg(pwin
->UserPort
))) {
1706 class=msg
->Class
; code
=msg
->Code
; qual
=msg
->Qualifier
;
1707 if (class==IDCMP_GADGETUP
)
1708 gadgetid
=((struct Gadget
*)msg
->IAddress
)->GadgetID
;
1709 ReplyMsg((struct Message
*) msg
);
1711 case IDCMP_VANILLAKEY
:
1712 if (qual
&IEQUALIFIER_REPEAT
) break;
1713 code
= ToLower(code
);
1715 if (code
==pactcode
[a
] /*|| code==ToUpper(pactcode[a])*/) {
1716 // if (ToLower(code)==pactcode[a]) {
1718 // if (code==ToUpper(pactcode[a])) qual|=IEQUALIFIER_LSHIFT;
1719 SelectGadget(pwin
,&printgadgets
[a
]);
1724 printgadgets
[4].Flags
^=GFLG_SELECTED
;
1725 RefreshGList(&printgadgets
[4],pwin
,NULL
,1);
1728 printgadgets
[5].Flags
^=GFLG_SELECTED
;
1729 RefreshGList(&printgadgets
[5],pwin
,NULL
,1);
1733 if (code
=='\r' || code
==getkeyshortcut(globstring
[STR_PRINT
])) {
1734 SelectGadget(pwin
,&printgadgets
[6]);
1737 else if (code
=='\e' || code
==' ' || code
==getkeyshortcut(str_cancelstring
)) {
1738 SelectGadget(pwin
,&printgadgets
[7]);
1743 case IDCMP_GADGETUP
:
1744 if (gadgetid
<PRINT_FORMFD
) {
1746 if (qual
&IEQUALIFIER_ANYSHIFT
) {
1747 if ((--print_gads_sel
[gadgetid
])<0)
1748 print_gads_sel
[gadgetid
]=print_gads_max
[gadgetid
];
1751 if ((++print_gads_sel
[gadgetid
])>print_gads_max
[gadgetid
])
1752 print_gads_sel
[gadgetid
]=0;
1754 DoCycleGadget(&printgadgets
[gadgetid
],
1756 print_gads_txt
[gadgetid
],
1757 print_gads_sel
[gadgetid
]);
1759 else switch (gadgetid
) {
1770 RemoveGList(pwin
,printgadgets
,-1);
1772 RectFill(prp
,0,0,319,pwin
->Height
-1);
1774 abortprintgad
.TopEdge
=(pwin
->Height
-80)/2;
1775 AddGadgetBorders(&pkey
,&abortprintgad
,1,2,1);
1776 AddGadgets(pwin
,&abortprintgad
,printabortgadtxt
,1,2,1,1);
1777 SetBusyPointer(pwin
);
1778 if ((print_request
=(union printerIO
*) LCreateExtIO(general_port
,sizeof(union printerIO
)))) {
1779 if (!(OpenDevice("printer.device",0,(struct IORequest
*)print_request
,0))) {
1780 pd
=(struct PrinterData
*)print_request
->iodrp
.io_Device
;
1781 prefs
=&pd
->pd_Preferences
;
1782 prefs
->PrintAspect
=print_gads_sel
[PRINT_ASPECT
];
1783 prefs
->PrintImage
=print_gads_sel
[PRINT_IMAGE
];
1784 prefs
->PrintShade
=print_gads_sel
[PRINT_SHADE
];
1785 prefs
->PrintXOffset
=0;
1787 print_request
->ios
.io_Command
=CMD_WRITE
;
1788 print_request
->ios
.io_Data
="\033#1";
1789 print_request
->ios
.io_Length
=-1;
1790 while (DoIO((struct IORequest
*)print_request
)) {
1792 a
=simplerequest(globstring
[STR_ERROR_INITIALISING_PRINTER
],
1793 globstring
[STR_TRY_AGAIN
],str_cancelstring
,NULL
);
1795 if (!a
) goto closeprinter
;
1798 if (printgadgets
[5].Flags
&GFLG_SELECTED
) {
1799 print_request
->ios
.io_Command
=CMD_WRITE
;
1800 print_request
->ios
.io_Data
=title
;
1801 print_request
->ios
.io_Length
=-1;
1802 if (DoIO((struct IORequest
*)print_request
)) goto closeprinter
;
1805 print_request
->iodrp
.io_Command
=PRD_DUMPRPORT
;
1806 print_request
->iodrp
.io_RastPort
=rast
;
1807 print_request
->iodrp
.io_ColorMap
=wind
->WScreen
->ViewPort
.ColorMap
;
1808 //if (system_version2) {
1809 print_request
->iodrp
.io_Modes
=GetVPModeID(&(wind
->WScreen
->ViewPort
));
1812 print_request->iodrp.io_Modes=wind->WScreen->ViewPort.Modes;
1814 print_request
->iodrp
.io_SrcX
=x
;
1815 print_request
->iodrp
.io_SrcY
=y
;
1816 print_request
->iodrp
.io_SrcWidth
=w
;
1817 print_request
->iodrp
.io_SrcHeight
=h
;
1818 print_request
->iodrp
.io_Special
=SPECIAL_FULLCOLS
|SPECIAL_ASPECT
|SPECIAL_NOFORMFEED
;
1819 if (!print_gads_sel
[PRINT_PLACE
])
1820 print_request
->iodrp
.io_Special
|=SPECIAL_CENTER
;
1821 if (!(printgadgets
[4].Flags
&GFLG_SELECTED
))
1822 print_request
->iodrp
.io_Special
|=SPECIAL_NOFORMFEED
;
1824 SendIO((struct IORequest
*)print_request
);
1826 Wait(1<<pwin
->UserPort
->mp_SigBit
|1<<general_port
->mp_SigBit
);
1827 while (GetMsg(general_port
));
1828 while ((msg
=(struct IntuiMessage
*) GetMsg(pwin
->UserPort
))) {
1830 if (class==IDCMP_GADGETUP
)
1831 gadgetid
=((struct Gadget
*)msg
->IAddress
)->GadgetID
;
1832 ReplyMsg((struct Message
*) msg
);
1833 if (class==IDCMP_GADGETUP
&& gadgetid
==PRINT_ABORT
) {
1835 abort
=simplerequest(globstring
[STR_REALLY_ABORT_PRINT
],
1836 globstring
[STR_ABORT
],globstring
[STR_CONTINUE
],NULL
);
1838 if (abort
) AbortIO((struct IORequest
*)print_request
);
1842 if (abort
|| (CheckIO((struct IORequest
*)print_request
))) break;
1844 WaitIO((struct IORequest
*)print_request
);
1845 if (!abort
&& printgadgets
[4].Flags
&GFLG_SELECTED
) {
1846 print_request
->ios
.io_Command
=CMD_WRITE
;
1847 print_request
->ios
.io_Data
="\f";
1848 print_request
->ios
.io_Length
=-1;
1849 DoIO((struct IORequest
*)print_request
);
1852 CloseDevice((struct IORequest
*)print_request
);
1854 LDeleteExtIO((struct IORequest
*)print_request
);
1857 for (a
=0;a
<8;a
++) printgadgets
[a
].TopEdge
-=goff
;
1858 main_proc
->pr_WindowPtr
=save
;
1859 ActivateWindow(iffwindow
);
1863 LFreeRemember(&pkey
);
1870 #warning Not implemented because of copper usage
1871 //bug("InitDHIRES(): NOT IMPLEMENTED BECAUSE OF COPPER MACRO USAGE\n");
1875 int line
,creg
,top
,oscan
,lace
;
1876 struct UCopList
*ucop
;
1878 if (!(ucop
=(struct UCopList
*)AllocMem(sizeof(struct UCopList
),MEMF_CLEAR
)))
1881 lace
=(viewflags
&LACE
)?1:0;
1886 if (screenwidth
>640) oscan
=14;
1889 for (line
=0;line
<top
;line
++) {
1890 CWAIT(ucop
,(line
-1)<<lace
,112);
1891 for (creg
=4;creg
<oscan
;creg
++) {
1892 CMove(ucop
,(long *)(0xdff180+(creg
*2)),copperlist
[(line
<<(4+lace
))+creg
]);
1898 CINIT(ucop
,copperheight
*17);
1899 for (line
=0;line
<copperheight
;line
++) {
1900 CWAIT(ucop
,line
-1,122);
1901 for (creg
=4;creg
<16;creg
++) {
1902 CMove(ucop
,(long *)(0xdff180+(creg
*2)),copperlist
[(line
<<4)+creg
]);
1917 void getviewmodes(modes
)
1920 if (iffscreenname
[0]) strcpy(modes
,iffscreenname
);
1922 if (viewflags
&SUPERHIRES
) {
1923 strcpy(modes
,"SUPERHIRES");
1924 if (bmhd
.bmh_Width
>1280) strcat(modes
," OSCAN");
1926 else if (viewflags
&HIRES
) {
1927 strcpy(modes
,"HIRES");
1928 if (bmhd
.bmh_Width
>640) strcat(modes
," OSCAN");
1931 strcpy(modes
,"LORES");
1932 if (bmhd
.bmh_Width
>320) strcat(modes
," OSCAN");
1934 if (viewflags
&LACE
) strcat(modes
," LACE");
1936 if (copperlist
) strcat(modes
," DHIRES");
1938 else if (pchghead
) {
1939 if (sham
) strcat(modes
," SHAM");
1940 else strcat(modes
," PCHG");
1945 if (viewflags
&HAM
) strcat(modes
," HAM");
1946 else if (viewflags
&EXTRA_HALFBRITE
) strcat(modes
," EHB");
1950 void iffinfotxt(r
,buf
,x
,y
)
1957 a
=strlen(buf
); l
=(316-x
)/8;
1959 Text(r
,buf
,(a
>l
)?l
:a
);
1962 void build_palettes(colourdata
,coloursize
,ctable4
,ctable8
)
1963 unsigned char *colourdata
;
1969 struct ColorRegister rgb
;
1972 for (a
=0,b
=1;a
<coloursize
;a
++,b
++)
1974 ctable8[b]=(colourdata[a]<<24)|0x00ffffff;
1977 ((colourdata
[a
]<<24)&0xff000000)|
1978 ((colourdata
[a
]<<16)&0x00ff0000)|
1979 ((colourdata
[a
]<<8)&0x0000ff00)|
1980 ((colourdata
[a
]&0x000000ff));
1982 ctable8
[0]=numcolours
<<16;
1983 ctable8
[(numcolours
*3)+1]=0;
1987 for (a
=0;a
<numcolours
;a
++) {
1988 rgb
.red
= *(colourdata
++)>>4;
1989 rgb
.green
= *(colourdata
++)>>4;
1990 rgb
.blue
= *(colourdata
++)>>4;
1991 ctable4
[a
]=(rgb
.red
<<8)+(rgb
.green
<<4)+rgb
.blue
;