** ** $Id: GetViewModes.S,v 21.2 92/05/18 02:18:15 chris Exp $ ** $Revision: 21.2 $ ** ** $Filename: GetViewModes.S $ ** $Author: chris $ ** $Date: 92/05/18 02:18:15 $ ** ** iff.library/IFFL_GetViewModes ** ** COPYRIGHT (C) 1987-1992 BY CHRISTIAN A. WEBER, BRUGGERWEG 2, ** CH-8037 ZUERICH, SWITZERLAND. ALL RIGHTS RESERVED. NO PART ** OF THIS SOFTWARE MAY BE COPIED, REPRODUCED, OR TRANSMITTED ** IN ANY FORM OR BY ANY MEANS, WITHOUT THE PRIOR WRITTEN PER- ** MISSION OF THE AUTHOR. USE AT YOUR OWN RISK. ** IDNT IFFL_GetViewModes SECTION text,CODE INCLUDE "graphics/view.i" INCLUDE "IffLib.i" XREF FindChunkFunc,GetBMHDFunc XDEF CalcViewModes ; für SaveClip.S XDEF GetViewModesFunc ******* iff.library/IFFL_GetViewModes *************************************** * * NAME * IFFL_GetViewModes() -- Get Amiga-specific ViewModes * * SYNOPSIS * viewmodes = IFFL_GetViewModes( iff ) * D0 A1 * * ULONG IFFL_GetViewModes( IFFL_HANDLE ) * * FUNCTION * Searches the IFF file for a 'CAMG' chunk which holds the view modes * information. If there is no CAMG chunk, the view modes are calcu- * lated using the information in the BitMapHeader structure. * You can directly put the low WORD of the result of a call to * IFFL_ GetViewModes() into the ns_ViewModes field of a NewScreen * structure, or you can use the whole ULONG for the SA_DisplayID tag * under OS 2.x. * * INPUTS * iff - IFF file handle, from OpenIFF() * * RESULT * viewmodes - ULONG containing the view modes (HAM, LACE, HIRES ...) * All forbidden bits are masked out, as suggested by CBM. * Under Kickstart V1.3, only the lower WORD is used. * * BUGS * If the IFF file has no CAMG chunk and 6 bitplanes, the HAM bit * will be set. This is not always correct since the picture could * be in the Extra Halfbrite mode. You can load such Halfbrite * pictures into DPaint III and save them again, DPaint will generate * the correct CAMG chunk. * * SEE ALSO * * ***************************************************************************** MODESMASK EQU ~(V_SPRITES|V_VP_HIDE|GENLOCK_AUDIO|GENLOCK_VIDEO) GetViewModesFunc: move.l a2,-(SP) movea.l a1,a2 ; A2 : IFFFile move.l #'CAMG',d0 bsr FindChunkFunc ; setzt Z-Flag wenn not found beq.b CalcEm ; not found ---> Berechnen movea.l d0,a0 ; Zeiger auf CAMG.... move.l 8(a0),d0 ; ViewModes tst.w 8(a0) ; Oberes WORD == 0 ? bne.b 1$ ; Nein ---> Nix ausmaskieren andi.l #MODESMASK,d0 ; Verbotene Bits ausmaskieren 1$: bra.b Ende ; ---> *** ViewModes aus BMHD berechnen, 0 falls kein BMHD CalcEm: movea.l a2,a1 ; IFFFile bsr GetBMHDFunc ; BitMapHeader suchen ;; tst.l d0 ; nicht gefunden? beq.b Ende ; dann 0 zurückgeben movea.l d0,a0 ; A0 : BMHD-Struktur bsr.b CalcViewModes ; ViewModes nach D0 IFD OLDBADHAMPICTURES cmpi.b #6,bmh_nPlanes(a0) ; 6 Bitplanes ? blt.b Ende ; nein ---> bset #11,d0 ; ViewModes |= HAM ENDC Ende: movea.l (SP)+,a2 rts *****i* iff.library/CalcViewModes ******************************************* * * NAME * CalcViewModes() -- Calculate Amiga-specific ViewModes from a BMHD * * SYNOPSIS * viewmodes = CalcViewModes( bmhd ) * D0 A0 * * ULONG CalcViewModes( struct IFFL_BMHD ) * * FUNCTION * Tries to calculate the viewmodes for a CAMG chunk by looking at * the bmh_Width, bmh_Height and bmh_Depth entries of a bmhd. * This is not always satisfactory, but we're stuck with it. * * INPUTS * bmhd - BitMapHeader describing the picture's dimensions * * RESULT * viewmodes - ULONG containing the view modes (LACE, HIRES) * * BUGS * Knows nothing about Monitor IDs or new View modes like SUPERHIRES * or HAM8. You should not use this function in new code. * * SEE ALSO * IFFL_GetViewModes(), IFFL_SaveClip() * ***************************************************************************** CalcViewModes: moveq.l #0,d0 ; D0 : ViewModes cmpi.b #4,bmh_nPlanes(a0) ; mehr als 4 Planes ? bgt.b NotHiRes ; ja ---> nicht HiRes cmpi.w #400,bmh_Width(a0) ; Bildbreite > 400 ? ble.b NotHiRes ; nein ---> bset #15,d0 ; ViewModes |= HiRes NotHiRes: cmpi.w #320,bmh_Height(a0) ; Bildhöhe > 320 ? blt.b NotInterlace ; nein ---> bset #2,d0 ; ViewModes |= Interlace NotInterlace: rts END