home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / CBMDevKit1.dms / CBMDevKit1.adf / tutorials.lha / tutorials / V39_AA_Compatibility < prev    next >
Encoding:
Text File  |  1993-11-04  |  51.9 KB  |  1,201 lines

  1.  
  2.  
  3.                             V39 and AA Compatibility
  4.  
  5.             Commodore Engineering and CATS
  6.  
  7.     (c) Copyright 1991-93 Commodore-Amiga, Inc.  All Rights Reserved
  8.  
  9.  
  10. Introduction
  11.  
  12. The capabilities of the built-in Amiga graphics hardware did not change
  13. significantly between the introduction of the Amiga 1000 in 1985 and the
  14. release of the Amiga 3000 in 1990.  The ECS chip set and the display enhancer
  15. added several new graphics modes and increased the functionality of existing
  16. modes -- yet the market demanded more.
  17.  
  18. This document explains some of the features of the latest generation Amiga
  19. graphics hardware known as the the AA (double-A) chip set, and ways to ensure
  20. application compatibility with these and other V39 features and changes.
  21. Additionally, coding methods are outlined which will allow current software
  22. to automatically exploit some of the new features.
  23.  
  24.  
  25. New Hardware Features
  26.  
  27. The most important capabilities of the new Amiga graphics
  28. hardware are summarized below.
  29.  
  30. o  Enhanced Bandwidth.  A 32-bit wide data bus allows doubling of
  31. Chip memory bandwidth (up to 2x the normal bandwidth) and supports the
  32. input of 32-bit wide bitplane and sprite data.  Bandwidth may be
  33. doubled again (to 4x) by using Fast Page Mode RAM.
  34.  
  35. o  More Bitplanes.  The maximum number of bitplanes has increased
  36. to 8 in all resolution modes.  This translates to a 256-entry
  37. color table for each available mode.
  38.  
  39. o  Larger Palette.  Each entry in the color table may now be 25
  40. bits wide (8 bits each for Red, Blue, and Green data plus 1 bit
  41. for genlock information).  This translates to a palette of
  42. 16,777,216 colors.
  43.  
  44. o  HAM and HALFBRITE are available in all display resolutions and depths,
  45. allowing for greatly enhanced dipslay modes such as 8-bitplane HIRES HAM.
  46.  
  47. o  Enhanced Dual Playfield Support.  Each playfield may now have
  48. up to 4 bitplanes.  The bank of 16 colors in the 256-color table
  49. is independently selectable for each playfield.
  50.  
  51. o  Enhanced Sprite Support.  Sprite resolution can be set to
  52. Lores, Hires, or SuperHires, independent of screen resolution. 
  53. Attached sprites are now available in all modes.  However, some new higher
  54. bandwidth modes may only allow one sprite (making an attached sprite impossible).
  55. Odd and even sprites may use their own independent 16-color bank from the
  56. 256-color table.  Old format sprites are still 16 bits wide, but new format
  57. sprites may be 32 or 64 bits wide.  Sprites may now optionally appear in the
  58. border region.  The horizontal positioning resolution of sprites has increased
  59. to 35ns (equivalent to SuperHires pixel widths.)
  60.  
  61. o  Enhanced hardware scrolling support.  The resolution of bitplane
  62. scrolling has increased to 35ns.
  63.  
  64. o  Hardware scan-doubling support.  15 kHz bitplanes and sprites
  65. may now be scan-doubled for flicker-free display on 31 kHz
  66. monitors, and for enhanced display sharing with 31 kHz bitplanes.
  67.  
  68. o  ECS compatibility.  New chips will power-up in an ECS
  69. compatibility mode, which will allow many older self-booting
  70. programs to be run on new machines.
  71.  
  72.  
  73.  
  74. Ensuring Compatibility
  75.  
  76. This section covers programming techniques that will help ensure
  77. that your application will work as expected when running under V39
  78. and on systems that use AA and future generation graphics hardware.
  79.  
  80. Support of Release 2 is integral to supporting new graphics chips.
  81. One of the main reasons is the display database.  Starting with
  82. the ECS chip set, not all machines have all display modes available.
  83. This will be even more true in the future.  The only way to know if
  84. a particular mode is available is to check the display database.
  85.  
  86. For a detailed explanation of how to properly open a screen using
  87. the display database information to check for available modes,
  88. refer to the Amiga ROM Kernel Reference Manual: Libraries, 3rd Edition.
  89. Also  see the Amiga Mail articles entitled "An Introduction to V36 Screens
  90. and Windows" (page IV-3) and "Opening Screens and Windows on Any Amiga"
  91. (Page IV-17).  Some other pertinent details can also be found in the Paris
  92. DevCon notes article entitled "Monitors, Modes, and the Display Database."
  93.  
  94. Once a screen or other display has been opened, all manipulations should
  95. also be handled using system calls.  In particular, these manipulations
  96. must be handled by the system software:
  97.  
  98. o  Allocation of graphics resources - use the graphics or intuition library
  99.  
  100. o  Palette manipulation - use the graphics library
  101.  
  102. o  Manipulating mouse pointer sprite - use intuition.library to
  103.    select or change imagery; input.device to move it
  104.  
  105. o  Manipulating sprites other than the mouse pointer - use the graphics library
  106.  
  107. o  Manipulating icons - use the icon library
  108.  
  109. o  Allocating and changing colormaps and colortables - use the
  110. graphics library
  111.  
  112. o  Bitplane allocations - use AllocBitMap() under V39 and higher,
  113. and AllocRaster() under earlier releases, but please refer to
  114. the next section for important information about limitations of
  115. AllocRaster().
  116.  
  117. Furthermore, these manipulations should be handled by the system
  118. software whenever possible:
  119.  
  120. o  Drawing operations - use the graphics library and Intuition
  121. library
  122.  
  123. o  Blitter operations - if possible, use only use higher level blitter
  124. functions from graphics.library such as BltBitMap(), BltRastPort(), etc.
  125. If you must wait for a blit to complete, always use the system's WaitBlit()
  126. function, never your own.  The system knows about and handles problems with
  127. the BLITTER_DONE signal that different revisions of the Agnus chip have.
  128. If you feel that must use the blitter hardware directly (sacrificing all
  129. hope for any RTG compatibility), be sure to properly OwnBlitter, then
  130. WaitBlit, then use blitter, then DisownBlitter.
  131.  
  132. Remember that system structures are subject to change or extension.
  133. For new graphics hardware, structures likely to be extended are those
  134. associated with ColorMaps, ViewPortExtras, Sprites, and many others.
  135. To deal with changing system structures, developers should use system
  136. calls to allocate, create, and manipulate these structures.  
  137. Many new "Get" and "Set" calls have been added to graphics.library
  138. to provide an upwards-compatible mechanism for reading and setting
  139. structure members which were previously accessed by program code either
  140. directly or through macros which accessed them directly.
  141. For future compatibility, do not directly access or change any
  142. structure or value for which a "Get" and "Set" call is available.
  143. And do not declare or AllocMem any structure for which a special
  144. allocation call is provided.
  145.  
  146. Most of the new new "Get" and "Set" graphics calls for V39 are listed below.
  147. Note that some of these functions are workalike replacements for old
  148. gfxmacros which poked or peeked a structure, and others provide tag-based
  149. capability for getting and/or setting more than one attribute (Attr) of
  150. a structure:
  151.  
  152. GetAPen(rp)(a0)
  153. GetBPen(rp)(a0)
  154. GetDrMd(rp)(a0)
  155. SetABPenDrMd(rp,apen,bpen,drawmode)(a1,d0/d1/d2)
  156. GetOutlinePen(rp)(a0)
  157. SetOutlinePen(rp,pen)(a0,d0)
  158. GetBitMapAttr(bm,attrnum)(a0,d1)
  159. SetWriteMask(rp,msk)(a0,d0)
  160. SetMaxPen(rp,maxpen)(a0,d0)
  161. SetRPAttrsA(rp,tags)(a0/a1)
  162. GetRPAttrsA(rp,tags)(a0/a1)
  163.  
  164.  
  165. Use the newest functions available.  For compatibility reasons, it
  166. is sometimes not possible to change the behavior of an existing system
  167. function to provide enhanced capabilities.  In such cases, new functions
  168. may be provided.  For upwards compatibility, conditionally use the newest
  169. functions that are available.  For example, when running under an OS
  170. earlier than V39, applications that wish to allocate a BitMap should use
  171. AllocRaster() and InitBitMap().  New or updated applications should use
  172. the new AllocBitMap() call instead when running under V39 or higher.
  173. See the V39 graphics library Autodocs for specifications of new functions
  174. such as AllocBitMap().
  175.  
  176.  
  177. Hardware Compatibility
  178.  
  179. The new chips power-up in an ECS compatible state that allows a
  180. large portion of older, self-booting (i.e., game) software to run
  181. even though these older titles often access hardware registers
  182. directly.  However, directly accessing hardware should be avoided
  183. by any software that expects to run after the operating system has
  184. been started.  Keep in mind also that it is difficult to maintain
  185. hardware register-level compatibility even on powerup as new and
  186. more enhanced chip sets are developed.  Avoid directly programming the
  187. hardware whenever possible.
  188.  
  189. In cases where applications _must_ access the hardware:
  190.  
  191. o  Applications must not write spurious data to,
  192.    or interpret data from, currently unused bits or addresses.
  193.  
  194. o  Applications must set undefined bits to zero for writes and
  195.    ignore them for reads.
  196.  
  197. o  Mask out all the bits except the ones the application is
  198.    actually interested in.
  199.  
  200. o  Do not assume the initial state of any registers.
  201.  
  202. o  Do not read write-only registers or write to read-only registers.
  203.  
  204. o  Do not read or write BYTEs to the custom chip registers
  205. (they are WORD registers).
  206.  
  207.  
  208. Graphics and Intuition Issues
  209.  
  210. The following notes detail some known coding practices that can
  211. cause software to function incorrectly on V39 and AA machines.
  212.  
  213.  
  214. o  BitMap plane allocations unsuitable for new modes.
  215. This problem surfaces because the new chips have an increased fetch bandwidth. 
  216. The data for each bitplane scan line must be properly aligned in Chip memory
  217. for new display modes to work.
  218.  
  219. For instance, these allocation methods should all be avoided under V39
  220. and higher:
  221.  
  222. /* WRONG for AA */
  223. for(planenum=0; planenum<DEPTH; planenum++)                 
  224.    bitmap.Planes[planenum]=(PLANEPTR)AllocMem(RASSIZE(width,height),MEMF_CHIP);
  225.  
  226. /* Also WRONG */
  227. allplanes=AllocMem(DEPTH*RASSIZE(width,height),MEMF_CHIP);  
  228.  
  229. /* Also WRONG */
  230. for(planenum=0; planenum<DEPTH; planenum++)
  231.     bitmap.Planes[planenum]=(PLANEPTR)AllocRaster(width,height);
  232.  
  233. The correct V39 method for allocating rasters is to use AllocBitMap()
  234. for graphics-level bitmaps or for CUSTOMBITMAP screens, or let Intuition
  235. OpenScreen() or OpenScreenTagList() allocate your bitmap.  This method will
  236. allow you to get the greater bandwidth and more efficient displays available
  237. under V39 in a manner that will be upward-compatible with future enhancements.
  238. The new V39 graphics function AllocBitMap() properly handles all allocation
  239. and alignment issues.  The Intuition OpenScreenTags() call uses AllocBitMap()
  240. under V39.
  241.  
  242. If for some reason your existing code design prevents you from conditionally
  243. calling AllocBitMap() or OpenScreen() when running under V39 and higher,
  244. you may be able to at least get compatibility with the currently available
  245. higher-bandwidth modes by using AllocRaster() or AllocMem() after rounding
  246. your width up to a multiple of 64 pixels (absolutely no guarantees here;
  247. future chips may require greater alignment; we suggest you conditionally
  248. code to use AllocBitMap() for future compatibility).
  249.     
  250. o  Incorrect assumptions about BitMap->BytesPerRow.
  251. Applications that use system functions to initialize and allocate BitMaps
  252. and their elements should be aware that the value of BitMap->BytesPerRow
  253. may be different from the expected value, depending on the bandwidth mode
  254. chosen, the custom chip type, method of allocation, and the asked-for
  255. width of the allocated planes.
  256.  
  257. Here's the explanation.  First, due to fetch-alignment restrictions
  258. in AA, some modes require a higher granularity (BytesPerRow must
  259. be a multiple of 4 or 8, instead of just 2 under ECS).  Second,
  260. BytesPerRow actually means two different things, which have always
  261. been identical, but aren't any more when using interleaved bitmaps.
  262. BytesPerRow officially means "the number of bytes you have to add
  263. to a pointer to a byte of the BitMap to get to the same place one
  264. row down".  It no longer can be depended on to mean "the number
  265. of bytes in this row".
  266.  
  267. To detect software compatibility problems related to BytesPerRow
  268. changes,it is extremely important to test on a machine with the AA chipset
  269. and Mode Promotion turned on in the IControl Preferences editor,
  270. and if the software supports various display sizes, to test with sizes
  271. which are not divisible by 64.
  272. Two typical symptoms of BytesPerRow problems are 1. skewing of
  273. the display, where the pixel data for every line is progressively
  274. further right or left, giving a diagonal appearance to the display,
  275. and 2. images saved with excess blank space at the right.
  276.  
  277. NOTE - CATS intends to provide a developer tool, probably called "BumpBPR",
  278. which will force all Screen and AllocBitMap() BitMap widths to a multiple
  279. of 64 pixels to emulate the higher scanline alignment of higher bandwidth
  280. AA modes.  This should allow developers to test for many BitMap->BytesPerRow
  281. problems on non-AA and no-promotion machines running V39.
  282.  
  283. o Non-matching BitMap->BytesPerRow
  284. Some applications assume that two BitMaps of the same width, but allocated
  285. by different methods, will be swappable or block-copyable in various manners.
  286. This is often no longer the case.  For example, a BitMap allocated by
  287. OpenScreen (which calls AllocBitMap) may have raster line storage widths
  288. rounded up to provide higher alignment for higher-bandwidth displays.
  289. But the raster lines of BitMap planes allocated with AllocMem() are generally
  290. rounded up only to a multiple of 16 with a hardcoded macro (RASSIZE),
  291. and for compatibility reasons, AllocRaster() currently still performs
  292. only the same rounding to a multiple of 16.
  293.  
  294.  
  295. o Interleaved BitMaps
  296. For interleaved bitmaps, BytesPerRow is quite a bit larger than the
  297. number of bytes in this row.  Screen grabbers and screen printers seem
  298. to be the primary victims of this change.
  299. For compatibility, the Workbench screen is non-interleaved if it opens
  300. before IPrefs has run.  If opened or reset after IPrefs has run, the
  301. Workbench screen will be interleaved, so under V39, the Workbench
  302. screen in a normally booted environment is likely to be interleaved.
  303. GetBitMapAttr( bm, BMA_WIDTH ) can return the true width of a BitMap
  304. in pixels.  However, this is not the width to be used when saving a BitMap
  305. as an ILBM since this width may be rounded up for alignment reasons.
  306.  
  307.  
  308. o  Incorrect assumptions about the internal structure of BitMap plane data.
  309. New types of BitMaps may have a significantly different layout.
  310. For example, new V39 interleaved BitMaps are allocated as one contiguous
  311. block of Chip memory and and are internally different from non-interleaved
  312. plane data.
  313.  
  314. Interleaved BitMaps consist of line 0 of plane 0, followed by
  315. line 0 of plane 1, line 0 of plane 2, on through to line 0 of
  316. plane n.  Then the pattern repeats with the data for the next
  317. line.  This BitMap layout reduces the color flashing effect which
  318. normally accompanies the blitting of individual planes.  Interleaved
  319. BitMaps can be requested by applications under AA.  Note however,
  320. that callers are not guaranteed to receive an interleaved BitMap
  321. whenever they ask for one.  The BMF_INTERLEAVED flag to AllocBitMap()
  322. is considered  a request, not a requirement.  If no sufficiently large
  323. continuous block of chip memory is available, it may not be possible to
  324. allocate the BitMap interleaved.  In that case, AllocBitMap() will attempt
  325. to allocate an ordinary BitMap instead.  Applications should be written
  326. so as not to be sensitive to whether or not a BitMap is interleaved.
  327. In those rare cases when it might matter, GetBitMapAttr( BMA_FLAGS )
  328. can be used.
  329.  
  330. o  Incorrect assumptions about the Display Database.
  331. Data about a display mode could change between one version of Kickstart
  332. and another, between different models of the Amiga and even between
  333. similar models.  Treat the data in the display database as dynamic!
  334. Information that was available under V37 may not necessarily
  335. be available under V39.  For instance, VGA and A2024 mode
  336. information is no longer in ROM and unless they are added by the
  337. user, there will be no information about these modes available.
  338.  
  339. Never cache information about the DEFAULT_MONITOR_ID modes
  340. because the default monitor can be changed by the user with the
  341. promotion feature.  
  342.  
  343. Use the 2.1 asl.library screen mode requester to present your
  344. user with choices which are actually available (Note - 2.1 asl.library
  345. works under 2.0 Kickstart, and a free amendment to distribute 2.1
  346. asl.library is available for 2.0 Workbench licensees).
  347.  
  348. o  Direct handling of ViewPorts.
  349. Applications that use low-level graphics calls to create the View
  350. directly may have problems in V39.  MakeVPort() and MrgCop() can now
  351. return an error.  In addition, the gap required between ViewPorts may
  352. now need to be significantly larger than on pre-AA chips, where it was
  353. never more than 3 non-interlaced lines (6 interlaced lines).
  354. The V39 graphics function CalcIVG() (Calc Inter Viewport Gap) may be used
  355. to determine how many blank lines will be needed above a ViewPort.  Note
  356. that Intuition currently uses at least 3 lines, or MAX(3,CalcIVG(v,vp))
  357. (substitute 6 for 3 if interlaced).  Also note that for old display modes
  358. with old depths and 4-bit-per-gun colors, the gap is unchanged from
  359. that under the ECS and original chip sets.
  360.  
  361. o  Incorrect use of PAL or NTSC flags.
  362. The common method of determining whether a machine is running in
  363. PAL or NTSC mode has always been to check for the PAL bit in
  364. GfxBase->DisplayFlags:
  365.  
  366.     BOOL IsPAL;
  367.  
  368.     IsPAL=(GfxBase->DisplayFlags & PAL) ? TRUE : FALSE;
  369.  
  370. One classic reason for desiring such a PAL/NTSC determination is to decide
  371. what size or type display to open.  The other common reason is to determine
  372. what clock constant to use in serial or audio period calculations (Amigas
  373. built as PAL machines have a slightly different system clock crystal frequency
  374. than Amigas built as NTSC machines, and serial/audio period calculations are
  375. dependent on this frequency).
  376.  
  377. Because V37 and V39 are more adaptable, this bit may longer be counted
  378. on to mean the user's preferred display mode, nor to even signify the
  379. probable clock crystal in the user's system.
  380.  
  381. For accurate serial and audio period calculations, you need to determine
  382. whether the system has a system clock crystal designed for PAL or NTSC.
  383. There is no totally foolproof way of doing this.  Under 1.x through 2.x,
  384. your best indicator of whether a system has a PAL system clock crystal
  385. is the GfxBase->DisplayFlags PAL bit.  This bit should tell you the
  386. hardware default of the machine, and should only mislead you if the user
  387. has moved the PAL/NTSC jumper or has run a PD program to change the bootup
  388. mode between PAL and NTSC.
  389.  
  390. Under V39 (and probably above), new BootMenu options now allow the user
  391. to software-select PAL or NTSC as the default graphics environment.
  392. This can modify the GfxBase->DisplayFlags PAL bit, but obviously does not
  393. change the system clock crystal.  Therefore, under V39 and higher, a new
  394. DisplayFlags bit called REALLY_PAL has been added to signify the whether
  395. the motherboard hardware jumper setting appears to be PAL.  Therefore,
  396. under V39 and higher, the best bit available for determining NTSC or PAL
  397. hardware is the new REALLY_PAL bit.
  398.  
  399. If your software needs to determine the characteristics of default
  400. displays, prior to V37 look at DisplayFlags PAL bit.  Under V37 or higher,
  401. instead use GetDisplayInfoData() to get information about the modeid
  402. LORES_KEY or HIRES_KEY, and then check the DisplayInfo.PropertyFlags
  403. for properties such as DIPF_IS_PAL (which will be true for both
  404. PAL and DblPAL).
  405.  
  406. If your software instead needs to determine the characteristics of the
  407. user's preferred display mode to work in (as evidenced by the mode of
  408. their Workbench or other default public screen), you can GetDisplayInfoData()
  409. on the modeID of the default public screen.  Be aware however that this
  410. modeID might not be any of the PAL or NTSC modes, but rather VGA or some
  411. other mode.
  412.  
  413. #include <graphics/displayinfo.h>
  414.  
  415.     Bool IsPAL;
  416.     struct Screen *screen;
  417.     ULONG modeID = LORES_KEY;
  418.     struct DisplayInfo displayinfo;
  419.  
  420.     /* Open graphics.library, etc. */
  421.  
  422.     /* Above, modeID is initialized to LORES_KEY.  You should inquire
  423.      * about LORES_KEY or HIRES_KEY if you are interested in the
  424.      * display characteristics of default displays (for example, what
  425.      * OpenScreen() will provide if you don't use tags to ask for a
  426.      * display mode with an explicit monitor like PAL or NTSC or VGA).
  427.      *
  428.      * Do the following LockPubScreen part if you are instead interested
  429.      * in the display characteristics of the modeID of the user's default
  430.      * public screen (usually Workbench).
  431.      */
  432.     if (screen = LockPubScreen(NULL))
  433.     {
  434.         modeID = GetVPModeID(&(screen->ViewPort));
  435.         UnlockPubScreen(NULL,screen);
  436.     }
  437.  
  438.  
  439.     /* Now get information about the modeID */
  440.     if (GetDisplayInfoData(NULL, (UBYTE *) &displayinfo,
  441.         sizeof(struct DisplayInfo), DTAG_DISP, modeID))
  442.     {
  443.         /* True if PAL or DblPAL */
  444.         if (displayinfo.PropertyFlags & DIPF_IS_PAL)
  445.             IsPAL = TRUE;
  446.         else
  447.             IsPAL = FALSE;
  448.     }
  449.  
  450.  
  451. o  Incorrect assumptions about ColorMaps and ColorTables.
  452. The color system has undergone significant changes so new V39 graphic
  453. functions should be used to manage color whenever possible. 
  454. ColorMaps should always be allocated using GetColorMap(); freed using
  455. FreeColorMap(); colors changed using LoadRGB4/32(), SetRGB4/32(),
  456. or SetRGB4/32CM(); and colors queried using GetRGB4/32().
  457. Specifically, the value ColorMap->ColorTable and the structure it points
  458. to should never be poked or read directly. 
  459.  
  460. The color functions with names containing ``32'' are new V39 functions for
  461. getting, setting, and loading color registers.  These new functions treat
  462. color guns (R, G, B) each as 32-bit values for handling not only the
  463. 8-bit color available in AA but also any conceivable future needs.
  464. Use of these new 32-bit color functions is required to display the
  465. 16 million different color shades available under AA and V39.
  466. The old 4-bit color manipulation functions can only provide 4096
  467. different colors.  Use these new 32-bit color functions to ensure the
  468. future compatibility of your V39 applications.
  469.  
  470. When using 4 or 8-bit R/G/B values, scale your values to 32 bits.
  471. Scale 8 bit R/G/B values to 32 bits by duplicating the 8-bit value in
  472. all 4 bytes of the 32-bit value.  Scale 4-bit values to 32 bits by duplicating
  473. the 4 bit value in each nibble of the 32-bit value.
  474.  
  475.         4-bit red value $3  becomes $33333333
  476.         8-bit red value $1F becomes $1F1F1F1F
  477.         8-bit red value $03 becomes $03030303
  478.  
  479. The graphics.library VideoControl() function should be used to
  480. get, set, or clear the special features associated with ColorMaps.
  481.  
  482. o  Poking Copper lists or copinit.
  483. The structure and order of Copper lists will change for all modes,
  484. so any program that relies on poking the Copper lists will likely break.
  485. Certain programs (especially games) make assumptions about copinit and
  486. poke it directly.  These programs will break with the AA chips and V39
  487. unless the AA machine is running in a non-AA old-chip emulation mode.
  488. Note again that copinit has changed, and will continue to change.  Do Not Touch.
  489.  
  490. o  Dangerous bits in the display hardware.
  491. Many bits in the custom chip registers that were previously undefined
  492. now have a function.  Beware of poking the following bits.
  493.  
  494.     o  In BPLCON0: bits 0, 4, 5, 6, and 7
  495.  
  496.     o  In BPLCON2: bits 7, 8, 9
  497.  
  498.     o  In BPLCON3: bits 0,1,6,7, and bits 9 through 15
  499.  
  500. o  Illegal use of the processor to write to bitplane and sprite data registers.
  501. Bitplane and sprite data registers should NOT be written to by the processor.
  502. The correct way for data to be fed to the chips is by setting up DMA that
  503. points to the data in Chip memory.
  504.  
  505. o  Illegal re-use of sprites on the same line.
  506. Attempting to re-use sprites on the same horizontal line by redefining the
  507. sprite data is illegal and unsupported.  Sprites may only be re-used
  508. vertically, and then only with at least a one line gap between re-uses.
  509. See the Amiga Hardware Reference Manual for an example of sprite re-use.
  510.  
  511. o  Incorrect allocation of sprite image data.
  512. Because of the increased fetch bandwidth of the new chips, sprite image
  513. data must be properly aligned in Chip memory.  Under 2.0, the best way to
  514. allocate this memory is to call the Exec library AllocMem() function.
  515. Use the new AllocSpriteData() call for allocation of new mode sprites
  516. under V39 and higher.
  517.  
  518. o  Forgotten FreeSprite() call.
  519. Sprites may now have a number of different modes.  However, under Intuition,
  520. these modes are global to all sprites.  If a program gets a sprite in a
  521. particular mode, but then does not free it, Intuition (and all Intuition-based
  522. programs including Workbench) are forced to use sprites in the mode of the
  523. forgotten sprite.  In general, it is good practice to not use sprites other
  524. than the pointer when coding software that is meant to be Intuition-compatible.
  525.  
  526. o  Illegal use of Intuition pointer data.
  527. Intuition's pointer handling has become much more sophisticated.
  528. People playing tricky games with the pointer data may get into trouble
  529. if they make assumptions about the data format of the Intuition pointer
  530. which can change depending on the display mode.  
  531.  
  532. o The old SetPointer() and ClearPointer() functions still work,
  533. giving compatible Intuition pointers.  Likewise, the pointer imagery in
  534. devs:system-configuration will be used until a pointer.prefs file is
  535. received.  However, due to growing complexity in the pointer subsystem,
  536. calling SetPointer() or ClearPointer() from within an input handler or
  537. inside Begin/EndRefresh() runs a risk of deadlocking.  There are currently
  538. some patches in place to help prevent a deadlock, however we warn
  539. people to stick to simple rendering functions only when inside LockLayer(),
  540. LockLayerInfo(), BeginRefresh(), BeginUpdate(), etc. and not to call
  541. Intuition or other high-level system functions inside of LockIBase().
  542. As well, great care should be taken inside an input handler (it's generally
  543. best for the handler to signal a high-priority task which actually does the
  544. work).  Don't be the application that dies under the next release when an
  545. inappropriate function that happened to work now deadlocks because its
  546. handling has become more sophisticated.  See the Autodocs for these
  547. functions for more information on what other system calls are OK to use
  548. with these functions.
  549.             
  550. o Intuition and Graphics are involved in a scheme to maximize
  551. compatibility with older sprite-using applications.  The AA chipset
  552. supports variable sprite resolution and width, but the setting affects
  553. all sprites.  If an application requests a specific sprite width
  554. (through the old graphics.library/GetSprite() call or the new
  555. graphics.library calls (GetExtSpriteA() and ChangeExtSpriteA()), and
  556. Intuition's sprite is not compatible with that request, then
  557. graphics.library will blank Intuition's sprite and notify Intuition.
  558. Intuition will rebound by generating the most suitable pointer sprite
  559. which is compatible.
  560.  
  561. o Using an attached sprite for the Intuition pointer was quasi-supported
  562. under 2.0.  It no longer works.
  563.  
  564. o The pointer information returned by GetPrefs() is no longer kept
  565. up-to-date, since the pointer data can exceed the storage space
  566. available in struct Preferences.  (The ROM default pointer will be
  567. returned in all cases).  (Like V37, V39 ignores the pointer data in
  568. calls to SetPointer() after the first one, for reasons such as this).
  569.  
  570. o Pens for Screens
  571. The handling of defaults for the pen array is a bit involved because
  572. of compatibility issues.  The only change for old applications should
  573. be those who pass an SA_Pens array of {~0}.  They will get the new
  574. values for BARDETAILPEN, BARBLOCKPEN, and BARTRIMPEN.  This will only
  575. affect the color of their screen title bar, and the color of the menus of
  576. any window on that screen which requests new-look menus (WFLG_NEWLOOKMENUS).
  577. Applications that specify no SA_Pens array or ones who specify an SA_Pens
  578. array with at least one explicit pen provided get V37-compatible defaults.
  579. Our options were limited because the request for default palette and
  580. default pens were too loosely coupled (until SA_LikeWorkbench).
  581.  
  582. o Screen.BitMap is becoming obsolete.
  583. The original Screen structure has an embedded instance of a BitMap
  584. structure, which can not grow to support current needs.  When
  585. Intuition allocates a non-CUSTOMBITMAP screen's BitMap,
  586. it now uses AllocBitMap(), and just copies the old struct BitMap portion
  587. into the embedded &screen->BitMap.  Intuition internally now references the
  588. true BitMap (obtainable as screen->RastPort.BitMap) instead of &screen->BitMap.
  589. We recommend that applications do the same.  This is the direction we're
  590. headed anyways for RTG, and is needed for double-buffering.
  591. There are currently some patches in Intuition to handle people who are
  592. poking the Screen.BitMap depth or planes.  Such poking is strongly
  593. discouraged.  See the new V39 Intuition function ChangeScreenBuffer().
  594.  
  595. o  OpenScreen failure if too deep
  596. Since all modes and all depths are no longer available on every systems,
  597. OpenScreen will fail if you request a mode/depth combination that is not
  598. displayable.  This can be an issue both for applications which may
  599. have been counting on allocating extra planes this way, or counting
  600. on having extra planes which would not be displayed.
  601. There is a new SA_ErrorCode value, OSERR_TOODEEP.
  602.  
  603. o  Console compatibility
  604. Applications which draw graphics in the console portion of the window, but
  605. use console scroll commands may not work if they are drawing their text in
  606. other than pen 1 or pen 0 when only the bitplane for those colors is scrolled.
  607.  
  608. Applications that use pen sharing on their own screens should allocate and
  609. set pens 3-7 if they plan on using those colors in console.  The console
  610. device still uses pens 0-7 just as it always has.
  611.  
  612.  
  613. Promotion-Related Issues
  614.  
  615. Under V39 and AA, when Mode Promotion is turned on, display modes which
  616. use the default monitor (e.g. display modes which are not explicitly PAL
  617. or NTSC) are promoted to scan-doubled or de-interlaced modes such as
  618. DblPAL or DblNTSC to provide a flicker-free display.
  619. Mode Promotion, on or off, is controlled system-wide by the IControl
  620. Preferences editor and the availability of the DblNTSC or DblPAL
  621. monitor.
  622.  
  623. Mode promotion can change the behavior of the system in a manner which
  624. may be incompatible with certain applications.
  625.  
  626. o The overscan limits of DblNTSC (DblPAL) are a little less than the
  627. overscan limits of NTSC (PAL).  (For 3.01, the DblNTSC (DblPAL) limits
  628. have been extended and are now comparable to, but still less than, NTSC (PAL)).
  629.  
  630. o It may be harder to center a DblNTSC or DblPAL screen on certain
  631. multiscan monitors than it was to center a hardware de-interlaced NTSC or PAL
  632. screen.  (3.01 provides additional centering flexibility which
  633. helps solve this problem).
  634.  
  635. o An interlaced screen is promoted to a non-interlaced screen, which
  636. has obvious implications on custom copper-lists and copper-list pokers.
  637.  
  638. o The higher resolutions/depths of the AA chipset require higher
  639. alignment restrictions on bitplanes.  Fortunately, most applications
  640. either let Intuition allocate their screen's BitMap or else they
  641. have a custom BitMap whose width is a multiple of 64 pixels (the
  642. highest alignment currently required by AA).  However, if the
  643. custom BitMap is an unusual width, it may not be sufficiently
  644. aligned for the hardware.  Such a screen can come up skewed when
  645. promoted.
  646.  
  647. o Coercion of displays in back to match a promoted or explicit DblNTSC
  648. or DblPAL front display may result in a lower resolution mode for
  649. unsuitably aligned back displays.
  650.  
  651. "1x" modes require 16-pixel (word boundary) alignment of each
  652. scan-line.  "2x" modes require 32-pixel (longword boundary) alignment,
  653. while "4x" modes require 64-pixel (double-longword boundary)
  654. alignment.  Here is a short reference:
  655.  
  656.     o 140 ns pixels (lores in 15 kHz modes, extra-lores in 31 kHz modes)
  657.       1-8 planes require 1X
  658.  
  659.     o 70 ns pixels (hires in 15 kHz modes, lores in 31 kHz modes)
  660.       1-4 planes require 1X
  661.       5-8 planes require 2X
  662.  
  663.     o 35 ns pixels (super-hires in 15 kHz modes, hires in 31 kHz modes)
  664.       1-2 planes require 1X
  665.       2-4 planes require 2X
  666.       5-8 planes require 4X
  667.  
  668. As the graphics.library AllocBitMap() function takes care of
  669. allocating suitably-aligned BitMaps for you, you do not need to worry
  670. about alignment when using modern system calls.
  671.  
  672. o The AA hardware does not allow dual-playfield non-interlaced screens
  673. to be scan-doubled, so they will appear half as tall as their
  674. non-promoted counterparts.
  675.  
  676. o Like earlier chipsets, the AA chipset still supports eight sprites.
  677. In much the same way as ECS and original chipsets lose sprites when
  678. overscan is increased, many of the new modes have insufficient spare
  679. cycles to fetch data for these sprites.  A promoted screen may have
  680. fewer sprites left than the corresponding 15 kHz mode, meaning that
  681. some sprites other than the pointer sprite may vanish.
  682.  
  683. NOTE - If the system is aware that additional sprites are needed,
  684. it will attempt to drop a display's bandwidth (if possible) to allow
  685. additional sprites.  To cause this to happen, either GetSprite() your
  686. sprites before opening your display, or RemakeDisplay() after doing
  687. your GetSprite() calls.
  688.  
  689. o  There is currently no 31 kHz mode having 1280 pixels per line.
  690. That would require 17.5 ns pixel speeds, which is twice what the
  691. AA chipset is capable of.  Therefore, SuperHires screens are promoted
  692. to 640 pixel-per-line screens, which generally can scroll.
  693. This is required for systems which have a VGA-only monitor, but otherwise
  694. might not be the desired way to display this mode.  To prevent promotion of
  695. SuperHires to Hires, an application could ask explicitly for PAL
  696. or NTSC SuperHires.  However, keep in mind that future chipsets
  697. may be capable of de-interlacing 1280-wide displays, and this would
  698. be defeated if NTSC or PAL is explicitly requested.  Also remember
  699. that a user with a VGA-only monitor can not display these modes.  The V39
  700. BestModeIDA() function may be used to determine the best available mode.
  701.  
  702. o  Applications that specifically request the NTSC or PAL monitor when
  703. opening a display will receive non-promoted PAL or NTSC, suitable for
  704. genlocking, etc.  For interlace modes, this will not be a flicker-free display.
  705. Therefore, productivity and design applications that wish to offer
  706. an explicit PAL/NTSC choice should use the display database or 2.1
  707. ASL screen mode requester to allow the user to choose a flicker-free
  708. display mode that is available on their system.
  709.  
  710.  
  711. Other Compatibility Issues
  712.  
  713. o  Library Vector Offsets and SetFunction().
  714. In general, some new LVOs supersede old ones.  While the old ones still work,
  715. software that calls SetFunction() based on the old LVOs may no longer catch
  716. what they were hoping to.  An example from V37 was people who called
  717. SetFunction() on AutoRequest().  Most system requests go through EasyRequest()
  718. now.  A V39 example would be SetWindowPointer() replacing SetPointer().
  719.  
  720. o  Test for Memory by Poking Breaks
  721. Apparently, some games test for RAM at $200000 by writing a pattern
  722. there and immediately reading it back.  On the A1200 bus, such games
  723. will be fooled.  Never test for RAM by poking/peeking.  Always use
  724. Exec's memory allocation functions, or the Exec TypeOfMem() function
  725. which can tell the caller whether (and what type of) memory exists at
  726. any particular address.
  727.  
  728. o  Preferences file format changes
  729. The format of some Preferences files have changed of necessity to
  730. support new system capabilities, and these files may continue to change.
  731. The documentation which has been provided only shows some chunks which
  732. may be encountered in a system Preferences file.  There is no guarantee
  733. that new chunks will not be added, or that the current chunks will
  734. continue to be used.   Do not read or write system Preferences files.
  735. Instead use other provided system mechanisms for reading and setting
  736. such items (for example, use device-specific commands or structures for
  737. controlling device preferences, functions such as QueryOverscan() and
  738. LockPubScreen() for determining display characteristics, etc.)
  739.  
  740. o  Changes to support for width-scaling of fonts
  741. Under V37, different widths of one YSize of a scalable font could
  742. be opened with a tagged OpenDiskFont() by first running a patch called
  743. setpatchwtam.  Under V38, this patch program does nothing, and an
  744. incorrect already-opened width may be returned.  Under V39, the correct
  745. requested width should again be returned, and these loaded width-scaled
  746. fonts are both hidden from AvailFonts() and should not be accidentally
  747. provided if application just does OpenFont() for the same YSize.
  748.  
  749. o  Self-modifying, copied, and directly loaded code
  750. Self-modifying code without proper cache control has been breaking
  751. since the 68020 was introduced.  The larger caches of the 68030 and 68040
  752. processors make it even more necessary to use the exec cache control
  753. functions such as CacheClearU() which have been available since V37.
  754. The cache control functions make it possible to flush the processor
  755. caches after modifying code in place, copying code to a different memory
  756. address, or placing code into memory via any mechanism that bypasses LoadSeg.
  757. Cache-control functions are also provided for DMA controllers which
  758. DMA data into memory.
  759.  
  760. o  IFF code
  761. Older IFF sample/example code contains many hardcoded limits and
  762. accesses some structures which may no longer be accessed directly.
  763. The older code (and even the code listed in the Amiga ROM Kernel Reference
  764. Manual: Devices, 3rd Edition) also would not load more than 32 color registers.
  765. The new IFF code, NewIFF39.lzh, attempts to use the latest system functions
  766. wherever possible in a conditional backward-compatible manner.
  767. The new code provides support for the full AA color palette, arbitrary
  768. display modes, the clipboard, overscan and autoscroll screens, and
  769. loading/saving of 24-bit ILBMs.  Please see the ILBM Compatibility
  770. notes for additional information on ILBM compatibility and support
  771. of AA features.
  772.  
  773.  
  774. o Tablet driver writers should test that their tablets now work with
  775. console drag selection (known not to work in the 2.04 OS).
  776.  
  777.  
  778. o Pre/Post DMA Cache functions and 68040
  779. For those of you with DMA devices that need to use the CachePreDMA()
  780. and CachePostDMA() calls:  Be careful as incorrect use of these
  781. calls may look like they work fine in 68000/68020/68030 systems but
  782. may cause strange system behavior and even major system slowdown
  783. on 68040 systems.
  784.  
  785. The correct way to use these calls is:
  786.  
  787.     original_length=length;
  788.     CachePreDMA(address,&length,0);
  789.  
  790.     /* Optional, multiple ones here for breaking up
  791.      * DMA operations within the single larger DMA block
  792.      * defined in the first call to CachePreDMA()
  793.      */
  794.     CachePreDMA(....,....,DMA_Continue);
  795.  
  796.     /*
  797.      * Very important to call CachePostDMA() with the
  798.      * exact same values as CachePreDMA()
  799.      */
  800.     CachePostDMA(address,&original_length,0)
  801.  
  802. Also, you must make sure they match up.  If they do not, the system will not
  803. be able to figure out that the DMA that was starting has finished.
  804. Internally, the OS needs to track these things for the 68040 and higher
  805. processors and may need to track them even more in the future.
  806.  
  807.  
  808. o An upcoming release of 3.0 (3.01?) will support the dos.library SetVBuf()
  809. function.  From V36 to V39 this call did nothing.  It will now properly change
  810. buffering modes, sizes, etc.  For programs using Dos buffered IO calls
  811. (FGetC, FPutC, FRead, etc) this can make a major improvement in IO
  812. performance if the buffer size is increased (and if the buffering mode
  813. is changed when writing to BUF_FULL).
  814.  
  815.  
  816. For additional information on OS changes, take particular note of all
  817. BUGS and NOTES entries in the sytem autodocs.
  818.  
  819.  
  820.  
  821.  
  822. Taking Advantage of New Features
  823.  
  824. By simply using system features and functions which were introduced
  825. in Release 2, you can write adaptable software that can automatically grow
  826. and support many new system software and hardware capabilities.
  827.  
  828.  
  829. Add a bit of conditional code to treat color guns (R, G, and B) as
  830. at least 8-bits each, and to conditionally use the new 32-bit V39 color
  831. setting and getting functions, and your application can provide full
  832. AA palette support.
  833.  
  834.  
  835.  
  836. Here are some strategies for adapting to new system capabilities.
  837.  
  838. o  Use the asl.library requesters if available.
  839. They are localized, they cut down on the amount of code you have to
  840. maintain, and they grow with the system.  2.0 Workbench licensees may
  841. get a free amendment to distribute the 2.1 asl.library which contains
  842. the screen mode requester.
  843.  
  844. o  Adapt to previously impossible deeper modes.
  845. Properly written software can use the calling syntax of the current graphics
  846. and Intuition library functions to open the screen modes with larger numbers
  847. of bitplanes.  These modes are simply deeper bitplane versions of existing modes:
  848. Lores 6,7, and 8 bits; Hires 5,6,7, and 8 bits; SuperHires 3,4,5,6,7,
  849. and 8 bits; and VGA 3,4,5,6,7, and 8 bits.  
  850.  
  851. Note that the display database must be checked to see if the user's
  852. machine supports the desired mode and number of bitplanes.
  853.  
  854. Intuition's screen functions can be used to open these previously
  855. impossible screens, but programs cannot rely on Intuition to throw out
  856. all "bad" possibilities.  For example, V36 Intuition will open an
  857. 8-bitplane Lores screen, but this is a waste of memory if the new chip
  858. set is not present since the 3 extra bitplanes will simply go unused.
  859. Programs will therefore need to explicitly check the display database
  860. to find out what the chips support.  In V39, Intuition will check the
  861. chips for you and fail to open a screen which is "too deep".  There is
  862. a new SA_ErrorCode value, OSERR_TOODEEP.
  863.  
  864.  
  865. Note on Mode IDs.  The currently defined display database mode IDs have
  866. all been moved from <graphics/displayinfo.h> to the new include file
  867. <graphics/modeid.h>.  Do not attempt to create your own display mode
  868. IDs by OR'ing together monitors and modes unless the include file
  869. explicitly allows it.  Do not try to draw conclusions about display
  870. characteristics by interpreting bits in the display mode ID.  Instead,
  871. pass the mode ID to the display database functions to discover the
  872. display characteristics (see the example below and other examples in
  873. Amiga Mail, Devcon Notes, Amiga RKRM: Libraries manual, and the new
  874. screen mode requester example).
  875.  
  876. The complete example listed below will check the display database
  877. entry for a LORES screen and open a screen with the maximum allowable
  878. number of bitplanes (assuming there is enough Chip memory).  On an Amiga
  879. with any chip set up to and including ECS, this code will open a
  880. 5-bitplane screen.  On a machine with the AA chip set, the screen will
  881. be 8 bits deep.  The code will then draw one vertical line for each
  882. available color using Intuition's preferred palette (which can be 
  883. set by the user with Preferences).  The example requires V36 or a
  884. later version of the OS.
  885.  
  886. /*  maxdepthlores.c  */
  887.  
  888. #include <exec/types.h>
  889. #include <intuition/intuition.h>
  890. #include <graphics/displayinfo.h>
  891. #include <dos/dos.h>
  892.  
  893. #include <clib/exec_protos.h>
  894. #include <clib/intuition_protos.h>
  895. #include <clib/graphics_protos.h>
  896. #include <clib/dos_protos.h>
  897.  
  898. #include <stdio.h>
  899. #include <stdlib.h>
  900.  
  901. struct Library *IntuitionBase;
  902. struct Library *GfxBase;
  903.  
  904. void Quit(char *whytext,LONG failcode)
  905. {
  906.     if(*whytext) printf("%s\n",whytext);
  907.  
  908.     if (IntuitionBase)    CloseLibrary(IntuitionBase);
  909.     if (GfxBase)    CloseLibrary(GfxBase);
  910.  
  911.     exit(failcode);
  912. }
  913.  
  914. void main(void)
  915. {
  916.     ULONG modeID = LORES_KEY;
  917.     DisplayInfoHandle displayhandle;
  918.     struct DimensionInfo dimensioninfo;
  919.  
  920.     UWORD maxdepth, maxcolors;
  921.     ULONG soerror = NULL,colornum;
  922.     struct Screen *screen;
  923.  
  924.     if ((GfxBase = OpenLibrary("graphics.library",36))==NULL)
  925.         Quit("graphics.library is too old <V36",RETURN_FAIL);
  926.  
  927.     if ((IntuitionBase = OpenLibrary("intuition.library",36))==NULL)
  928.         Quit("intuition.library is too old <V36",RETURN_FAIL);
  929.  
  930.     if ((displayhandle=FindDisplayInfo(modeID))==NULL)
  931.         Quit("modeID not found in display database",RETURN_FAIL);
  932.  
  933.     if (GetDisplayInfoData(displayhandle,(UBYTE *) &dimensioninfo,
  934.     sizeof(struct DimensionInfo),DTAG_DIMS,NULL)==0)
  935.         Quit("mode dimension info not available",RETURN_FAIL);
  936.         
  937.     maxdepth=dimensioninfo.MaxDepth;
  938.     printf("dimensioninfo.MaxDepth=%d\n",(int) maxdepth);
  939.  
  940.     if (screen=OpenScreenTags(NULL, SA_DisplayID    ,modeID,
  941.                                     SA_Depth        ,(UBYTE) maxdepth,
  942.                                     SA_Title        ,"MaxDepth LORES",
  943.                                     SA_ErrorCode    ,&soerror,
  944.                                     SA_FullPalette  ,TRUE,
  945.                                     TAG_END))
  946.         {
  947.             /* Zowee! we actually got the screen open!
  948.              * now let's try drawing into it.
  949.              */
  950.             maxcolors=1<<maxdepth;
  951.             
  952.             printf("maxcolors=%d\n",(int) maxcolors);
  953.             
  954.             for(colornum=0;colornum<maxcolors;++colornum)
  955.             {
  956.                 SetAPen(&(screen->RastPort),colornum);
  957.                 Move(&(screen->RastPort),colornum,screen->BarHeight + 2);
  958.                 Draw(&(screen->RastPort),colornum,screen->Height - 1);
  959.             }
  960.             Delay(TICKS_PER_SECOND * 6);
  961.  
  962.             CloseScreen(screen);
  963.         }            
  964.     else
  965.         {   /* Hmmm.  Couldn't open the screen.  maybe not
  966.              * enough CHIP RAM? Maybe not enough chips! ;-)
  967.              */
  968.             switch(soerror)
  969.             {
  970.                 case OSERR_NOCHIPS:
  971.                     Quit("Bummer! You need new chips dude!",RETURN_FAIL);
  972.                     break;
  973.                 
  974.                 case OSERR_UNKNOWNMODE:
  975.                     Quit("Bummer! Unknown screen mode.",RETURN_FAIL);
  976.                     break;
  977.                 
  978.                 case OSERR_NOCHIPMEM:
  979.                     Quit("Not enough CHIP memory.",RETURN_FAIL);
  980.                     break;
  981.                 
  982.                 case OSERR_NOMEM:
  983.                     Quit("Not enough FAST memory.",RETURN_FAIL);
  984.                     break;
  985.                 
  986.                 default:
  987.                     printf("soerror=%d\n",soerror);
  988.                     Quit("Screen opening error.",RETURN_FAIL);
  989.                     break;
  990.             }
  991.             Quit("Couldn't open screen.",RETURN_FAIL);
  992.         }
  993.  
  994. Quit("",RETURN_OK);    /* clean up and exit */
  995. }
  996.  
  997.  
  998.  
  999. o  Open on Workbench.
  1000. One of the easiest ways to help a given program peacefully coexist with
  1001. new hardware is to allow it to open on the Workbench screen (or on any
  1002. public screen).  Software written this way should be robust enough that
  1003. it can find out from the system any information it might need about the
  1004. display environment, and, if it understands the kind of screen that it's
  1005. on, use the appropriate graphics.library calls to manipulate its windows.
  1006.  
  1007. Here's some example code that determines the depth of the default public
  1008. screen and opens a window on it.  If it were part of a real application,
  1009. this code would tell how many colors the screen has.
  1010.  
  1011. Add some conditional V39 palette sharing code and you can even have
  1012. your own color registers to use, if available, or closest matching
  1013. register to share.
  1014.  
  1015.  
  1016. /* depthawarevisitor.c */
  1017.  
  1018. #include <exec/types.h>
  1019. #include <intuition/intuition.h>
  1020. #include <graphics/displayinfo.h>
  1021. #include <dos/dos.h>
  1022.  
  1023. #include <clib/exec_protos.h>
  1024. #include <clib/intuition_protos.h>
  1025. #include <clib/graphics_protos.h>
  1026. #include <clib/dos_protos.h>
  1027.  
  1028. #include <stdio.h>
  1029. #include <stdlib.h>
  1030.  
  1031.  
  1032. struct Library *IntuitionBase;
  1033. struct Library *GfxBase;
  1034. struct Screen  *screen = NULL;
  1035.  
  1036.  
  1037. void Quit(char *whytext, LONG failcode)
  1038. {
  1039.     if(*whytext) printf("%s\n",whytext);
  1040.  
  1041.     if (screen)        UnlockPubScreen(NULL, screen);
  1042.     if (IntuitionBase)    CloseLibrary(IntuitionBase);
  1043.     if (GfxBase)    CloseLibrary(GfxBase);
  1044.  
  1045.     exit(failcode);
  1046. }
  1047.  
  1048.  
  1049. void main(void)
  1050. {
  1051.     struct Screen *screen;
  1052.     struct DrawInfo *drawinfo;
  1053.     struct Window *window;
  1054.     UWORD depth;
  1055.  
  1056.     if ((GfxBase = OpenLibrary("graphics.library",36))==NULL)
  1057.         Quit("graphics.library is too old <V36",RETURN_FAIL);
  1058.  
  1059.     if ((IntuitionBase = OpenLibrary("intuition.library",36))==NULL)
  1060.         Quit("intuition.library is too old <V36",RETURN_FAIL);
  1061.  
  1062.     if (!(screen = LockPubScreen(NULL)))
  1063.         Quit("Can't lock default public screen",RETURN_FAIL);
  1064.  
  1065.     /* Here's where we'll ask Intuition about the screen. */
  1066.     if((drawinfo=GetScreenDrawInfo(screen)) == NULL)
  1067.     Quit("Can't get DrawInfo",RETURN_FAIL);
  1068.  
  1069.     depth=drawinfo->dri_Depth;
  1070.  
  1071.     /* Because Intuition allocates the DrawInfo structure,
  1072.      * we have to tell it when we're done, to get the memory back.
  1073.      */
  1074.     FreeScreenDrawInfo(screen, drawinfo);
  1075.  
  1076.     /* This next line takes advantage of the stack-based amiga.lib
  1077.      * version of OpenWindowTags.
  1078.      */
  1079.     if (window = OpenWindowTags(NULL, WA_PubScreen ,screen,
  1080.                                       WA_Left      ,0,
  1081.                                       WA_Width     ,screen->Width,
  1082.                                       WA_Top       ,screen->BarHeight,
  1083.                                       WA_Height    ,screen->Height - screen->BarHeight,
  1084.                                       WA_Flags     ,WINDOWDRAG|WINDOWDEPTH|WINDOWCLOSE|
  1085.                                                     ACTIVATE|SIMPLE_REFRESH|NOCAREREFRESH,
  1086.                                       WA_Title     ,"Big Visitor",
  1087.                                       TAG_END))
  1088.     {
  1089.  
  1090.         printf("depth=%d\n",depth);
  1091.         
  1092.         /* All our window event handling might go here */
  1093.  
  1094.         Delay(TICKS_PER_SECOND * 10);
  1095.  
  1096.         /* Of course, some other program might come along
  1097.          * and change the attributes of the screen that we read from
  1098.          * DrawInfo, but that's a mean thing to do to a public screen,
  1099.          * so let's hope it doesn't happen.
  1100.          */
  1101.  
  1102.         CloseWindow(window);
  1103.     }
  1104.  
  1105. Quit("",RETURN_OK);    /* clean up (close/unlock) and exit */
  1106. }
  1107.  
  1108.  
  1109. o  If necessary, use tag-extended older structures with 1.3 functions.
  1110. If you are not yet able to drop support for 1.3 systems, use tag-extended
  1111. structures such as ExtNewScreen and ExtNewWindow to provide V37 and V39/AA
  1112. enhanced capabilities with 1.3-compatible code.  See the RKM Libraries volume
  1113. Intuition chapters for examples which use these tag-extended structures.
  1114. An example of such coding is the NewIFF39 code.
  1115.  
  1116.  
  1117.  
  1118. Table:  New AA Modes (In Addition to Modes Supported by ECS)
  1119.  
  1120.  
  1121. Mode            Planes    Colors            Bandwidth (See note 1)
  1122. ----            ------    ------            ----------------------
  1123. LORES (320x200)        6    64                1
  1124.             7    128                1
  1125.             8    256                1
  1126.             8    HAM 256,000+ (see note 2)    1
  1127.  
  1128. HIRES (640x200)        5    32                2
  1129.             6    EHB 64 (see note 3)        2
  1130.             6    HAM 4096 (see note 4)        2
  1131.             6    64                2
  1132.             7    128                2
  1133.             8    256                2
  1134.             8    HAM 256,000+ (see note 2)    2
  1135.  
  1136. SUPERHIRES (1280x200)
  1137.             1    2 (see note 5)            1
  1138.             2    4 (see note 5)            1
  1139.             3    8                2
  1140.             4    16                2
  1141.             5    32                4
  1142.             6    EHB 64 (see note 3)        4
  1143.             6    HAM 4096 (see note 4)        4
  1144.             6    64                4
  1145.             7    128                4
  1146.             8    256                4
  1147.             8     HAM    256,000+ (see note 2)    4
  1148.  
  1149. VGA  (160,320,640x480 non-int.)
  1150.             1    2 (see note 5)            1
  1151.             2    4 (see note 5)            1
  1152.             3    8                2
  1153.             4    16                2
  1154.             5    32                4
  1155.             6     EHB 64 (see note 3)        4
  1156.             6     HAM 4096 (see note 4)        4
  1157.             6    64                4
  1158.             7    128                4
  1159.             8    256                4
  1160.             8     HAM 256,000+ (see note 2)    4
  1161.  
  1162. Notes:
  1163. 1 - The "Bandwidth" number describes the amount of fetch bandwidth required
  1164. by a particular screen mode.  For example, a 5 bit deep VGA screen requires
  1165. the 4x bandwidth fetch mode while a 1 bit VGA screen requires only the 1x
  1166. mode..  This translates to the hardware having to move data 4 times faster.
  1167. To be able to move data at these higher rates, the higher bandwidth modes
  1168. require data to be properly aligned in CHIP memory that is fast enough to
  1169. support the bandwidth.  Specifically, bandwidth fetch mode factors of 1
  1170. require data to be on 16 bit boundaries, factors of 2 require 32 bit
  1171. boundaries, and factors of 4 require 64 bit boundaries.  Restrictions like
  1172. these are the best reason to use the system allocation functions whenever
  1173. data is being prepared for the custom hardware.  It is not guaranteed that
  1174. all machines that have the new chipset will also have memory fast enough
  1175. for the 4x modes.  Therefore, the ONLY way to know whether or not the
  1176. machine will support the mode you want is to check the Display Database.
  1177.  
  1178. 2 - New 8 bit HAM mode uses the upper 6 bits for 64 24-bit base register
  1179. colors or as a 6 bit modify value, plus the lower 2 bits for 18 bit hold or
  1180. modify mode control.  This mode could conceivably allow simultaneous
  1181. display of more than 256,000 colors (up to 16.8 million, presuming a
  1182. monitor / screenmode with enough pixels.)  Please note that while the
  1183. register planes and control planes are internally reversed in 8 bit HAM
  1184. (the control bits are the two LSBs instead of the two MSBs),  programs
  1185. using graphics.library and intuition.library (i.e. Screens, BitMaps)
  1186. will not have to deal with this reversal, as it will be handled
  1187. automatically for them.
  1188.  
  1189. 3 - This is like the original EHB mode, but in new resolutions.  It uses 5
  1190. bits to yield 32 register colors, plus a sixth bit for 32 colors that are
  1191. 1/2 as bright.
  1192.  
  1193. 4 - This is like the original 6 bit Ham mode, but in new resolutions.  It
  1194. uses the lower 4 bits for 16 register colors, plus the upper 2 bits for
  1195. modify mode control.  This mode allows  simultaneous display of 4096
  1196. colors.
  1197.  
  1198. 5 - These modes are unlike the old VGA and SUPERHIRES modes in that they
  1199. are not restricted to a nonstandard 64 color palette.
  1200.  
  1201.