summaryrefslogtreecommitdiff
path: root/Source/GetViewModes.S
diff options
context:
space:
mode:
authorChristian A. Weber <chris@gna.ch>1992-05-12 22:26:12 +0000
committerChristian A. Weber <chris@gna.ch>1992-05-12 22:26:12 +0000
commit36c824864c02f0a3f62c8a1d365d1670835c8c96 (patch)
treef3f433e4af522925d4c91f56865d38efaf83a456 /Source/GetViewModes.S
downloadiff-library-36c824864c02f0a3f62c8a1d365d1670835c8c96.tar.gz
iff-library-36c824864c02f0a3f62c8a1d365d1670835c8c96.tar.bz2
iff-library-36c824864c02f0a3f62c8a1d365d1670835c8c96.zip
Initial revision
Diffstat (limited to 'Source/GetViewModes.S')
-rw-r--r--Source/GetViewModes.S124
1 files changed, 124 insertions, 0 deletions
diff --git a/Source/GetViewModes.S b/Source/GetViewModes.S
new file mode 100644
index 0000000..e6a10c6
--- /dev/null
+++ b/Source/GetViewModes.S
@@ -0,0 +1,124 @@
+**
+** $Id: $
+** $Revision: $
+**
+** $Filename: GetViewModes.S $
+** $Author: Christian A. Weber $
+** $Release: 19.1 $
+** $Date: 92/05/11 21:11:27 $
+**
+** iff.library/IFFLib_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 IFFLib_GetViewModes
+ SECTION text,CODE
+
+ INCLUDE "IffLib.i"
+
+ XREF FindChunkFunc,GetBMHDFunc
+ XDEF CalcViewModes ; für SaveClip.S
+ XDEF GetViewModesFunc
+
+
+******* iff.library/IFFLib_GetViewModes **************************************
+*
+* NAME
+* IFFLib_GetViewModes() -- Get Amiga-specific ViewModes
+*
+* SYNOPSIS
+* viewmodes = IFFLib_GetViewModes( ifffile )
+* D0 A1
+*
+* ULONG IFFLib_GetViewModes( IFFFILE )
+*
+* 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 GetViewModes()
+* call into the ns_ViewModes field of a NewScreen structure. All
+* forbidden bits are masked out, as suggested by CBM.
+*
+* INPUTS
+* ifffile - IFF file pointer, returned from OpenIFF()
+*
+* RESULT
+* viewmodes - LONG containing the view modes (HAM, LACE, HIRES ...)
+* 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
+*
+*****************************************************************************
+
+ *** Flags, die nur in graphics/view.h aber nicht .i sind (!)
+
+HAM: EQU $0800
+SPRITES: EQU $4000
+VP_HIDE: EQU $2000
+GENLOCK_AUDIO: EQU $0100
+GENLOCK_VIDEO: EQU $0002
+EXTRA_HALFBRITE: EQU $0080
+
+MODESMASK: EQU ~(SPRITES|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.s CalcEm ; not found ---> Berechnen
+ movea.l d0,a0 ; Zeiger auf CAMG....
+ move.l 8(a0),d0 ; ViewModes
+ andi.l #MODESMASK,d0 ; Verbotene Bits ausmaskieren
+ bra.s Ende ; --->
+
+ *** ViewModes aus BMHD berechnen, 0 falls kein CAMG
+
+CalcEm: movea.l a2,a1 ; IFFFile
+ bsr GetBMHDFunc ; BitMapHeader suchen
+ ;; tst.l d0 ; nicht gefunden?
+ beq.s Ende ; dann 0 zurückgeben
+ movea.l d0,a0 ; A0 : BMHD-Struktur
+ bsr.s CalcViewModes ; ViewModes nach D0
+
+ cmpi.b #6,bmh_nPlanes(a0) ; 6 Bitplanes ?
+ blt.s Ende ; nein --->
+ bset #11,d0 ; ViewModes |= HAM
+Ende:
+ movea.l (SP)+,a2
+ rts
+
+ *** ViewModes berechnen, A0 = struct BitMapHeader
+ *** Diese Routine wird auch von SaveClip() benutzt
+
+CalcViewModes: moveq.l #0,d0 ; D0 : ViewModes
+
+ cmpi.b #4,bmh_nPlanes(a0) ; mehr als 4 Planes ?
+ bgt.s NotHiRes ; ja ---> nicht HiRes
+
+ cmpi.w #400,bmh_Width(a0) ; Bildbreite > 400 ?
+ ble.s NotHiRes ; nein --->
+ bset #15,d0 ; ViewModes |= HiRes
+NotHiRes:
+ cmpi.w #320,bmh_Height(a0) ; Bildhöhe > 320 ?
+ blt.s NotInterlace ; nein --->
+ bset #2,d0 ; ViewModes |= Interlace
+NotInterlace:
+ rts
+
+ END