home *** CD-ROM | disk | FTP | other *** search
/ Global Amiga Experience / globalamigaexperience.iso / compressed / development / heliosdemodisk3.dms / heliosdemodisk3.adf / Source / DualPFScroll.src < prev    next >
Text File  |  1995-01-20  |  24KB  |  766 lines

  1.   \ ***********************************************************
  2.   \
  3.   \      PARALLAX SCROLLING DUAL PLAYFIELD WITH TEXT DEMO
  4.   \
  5.   \ ***********************************************************
  6.   \
  7.   \ This code demonstrates how to create a display with multiple
  8.   \ dual playfield slices and variable speed parallax scrolling.
  9.   \
  10.   \ This code builds upon the following Demos:
  11.   \
  12.   \ Demo1_SinglePF.src
  13.   \ Demo2_SinglePFCopper.src
  14.   \
  15.   \ ***********************************************************
  16.  
  17.  
  18.  
  19.   \ ***********************************************************
  20.   \ Re-initialise HeliOS dictionary to standard CORE vocabulary
  21.   \ ***********************************************************
  22.  
  23.   \ This should always be used at the start of any program which
  24.   \ is to be repeatedly recompiled.
  25.  
  26.   FORGET **CORE**
  27.  
  28.   \ *************************
  29.   \ Load include symbol files
  30.   \ *************************
  31.   \
  32.   \ These "include files" are pre-compiled (for speed) versions of the
  33.   \ Amiga includes and the Helios system includes.
  34.   \
  35.   \ Uncomment the lines below for standalone compilation, but otherwise
  36.   \ it is better to set these include files from the Helios Forth menus
  37.  
  38.   AMIGAINCLUDE Helios:Amiga_Include
  39.   USERINCLUDE  Helios:Helios_Include
  40.  
  41.   \ ****************************************
  42.   \ Create display imagery file name strings
  43.   \ ****************************************
  44.  
  45.   \ These files are ordinary IFF's (and may be "PowerPacked" if required)
  46.   \
  47.   \ The pictures here will be loaded into each of the display BitMaps.
  48.   \
  49.  
  50.   $CONSTANTL Slice1APic $Helios:Source/Data/Pic1A$
  51.   $CONSTANTL Slice1BPic $Helios:Source/Data/Pic1B$
  52.   $CONSTANTL Slice2APic $Helios:Source/Data/Pic2A$
  53.   $CONSTANTL Slice2BPic $Helios:Source/Data/Pic2B$
  54.   $CONSTANTL Slice3Pic  $Helios:Source/Data/Pic3$
  55.  
  56.   \ **************************************
  57.   \ Create display configuration constants
  58.   \ **************************************
  59.   \
  60.   \ Collect all "display-specific" parameters here and generate "named"
  61.   \ constants which make references easier than using numeric values.
  62.   \
  63.   \ Collecting these together here makes it easier to adjust things at any
  64.   \ time without having to search source code to replace values individually.
  65.   \
  66.  
  67.  
  68.   256                      CONSTANT DisplayHeight      \ Full PAL display
  69.   44                       CONSTANT DisplayTopLine     \ Display start
  70.  
  71.  \ The top slice is a scrolling display area with two 8-colour playfields
  72.  \
  73.  \ A-slice = foreground playfield and B-slice = background playfield
  74.  \
  75.  \ The B-slice has extra-wide horizontal raster size (640 pixels) to allow
  76.  \ for horizontal scrolling, with an additional 320 pixels width to allow
  77.  \ for horizontal smooth wrapping.
  78.  \
  79.  \ The A-slice does not scroll.
  80.  \
  81.  
  82.   320                      CONSTANT Slice1Width        \ Lores width
  83.   30                       CONSTANT Slice1Height       \ Top slice height
  84.   30                       CONSTANT Slice1RasterHeight \ Raster=sliceheight
  85.   WORDINCLUDE
  86.   V_DUALPF                 CONSTANT Slice1Mode         \ Top slice screenmode
  87.   LONGINCLUDE
  88.  
  89.   320                      CONSTANT Slice1ARasterWidth \ Raster=screenwidth
  90.   3                        CONSTANT Slice1APlanes      \ A-slice bitplanes
  91.   2 Slice1APlanes 1- LSL   CONSTANT Slice1AColours     \ A-slice colours
  92.  
  93.   640 320 +                CONSTANT Slice1BRasterWidth \ Scroll plane width
  94.   3                        CONSTANT Slice1BPlanes      \ B-slice bitplanes
  95.  
  96.   \ The calculation below takes the number of bitplanes and calculates
  97.   \ how many colours this represents.
  98.   \
  99.   \ One bitplane gives two colours.
  100.   \
  101.   \ Each additional bitplane multiplies the number of colours by two.
  102.   \
  103.   \ Performing a single LSL operation on any number multipies by 2, so we
  104.   \ have a quick method of multiplying by two for our colour calculation.
  105.   \
  106.   \ In this case, we need "2 to the power 3", which is 2*2*2=8.
  107.   \
  108.   \ e.g.                              2*2*2
  109.   \                                   ^ ^ ^
  110.   \                                   Total number of planes = 3
  111.   \
  112.   \
  113.   \ So, we take the first value two
  114.   \
  115.   \ e.g.                              2*2*2
  116.   \                                   ^
  117.   \                                  Initial start value of 2
  118.   \
  119.   \ and we now need to multiply it by two "the_number_of_planes minus_one"
  120.   \ more times.
  121.   \
  122.   \ e.g.                              2*2*2
  123.   \                                     ^ ^
  124.   \                                     Total planes minus one
  125.   \
  126.   \
  127.   \ So, Number of colours = 2 operated on by LSL NumberOfPlanes-1 times.
  128.   \
  129.  
  130.   2 Slice1BPlanes 1- LSL   CONSTANT Slice1BColours     \ B-slice colours
  131.  
  132.  
  133.  \ The middle slice is a scrolling play area and has two 8 colour playfields
  134.  \
  135.  \ A-slice = foreground playfield and B-slice = background playfield
  136.  \
  137.  \ Both these slices have extra-wide horizontal raster size to allow for
  138.  \ horizontal scrolling (1280 pixels), and an additional 320 pixels for
  139.  \ horizontal smooth wrapping.
  140.  \
  141.  \ These slices both also have 16 pixel extra border areas to allow
  142.  \ rendering of partially off-screen BOBs, since this would normally be
  143.  \ a main game play area.
  144.  \
  145.  
  146.   320                      CONSTANT Slice2Width        \ Lores width
  147.   170                      CONSTANT Slice2Height       \ Middle slice height
  148.   170 32 +                 CONSTANT Slice2RasterHeight \ Middle bitplane height
  149.   WORDINCLUDE
  150.   V_DUALPF                 CONSTANT Slice2Mode         \ Middle screenmode
  151.   LONGINCLUDE
  152.  
  153.   1280 320 + 32 +          CONSTANT Slice2ARasterWidth \ A-slice scroll-raster
  154.   3                        CONSTANT Slice2APlanes      \ A-slice planes
  155.   2 Slice2APlanes 1- LSL   CONSTANT Slice2AColours     \ A-slice colours
  156.  
  157.   640 320 + 32 +           CONSTANT Slice2BRasterWidth \ B-slice scroll-raster
  158.   3                        CONSTANT Slice2BPlanes      \ B-slice planes
  159.   2 Slice2BPlanes 1- LSL   CONSTANT Slice2BColours     \ B-slice colours
  160.  
  161.  \ The bottom slice is an ordinary single playfield with 32 colours
  162.  
  163.   640                      CONSTANT Slice3Width        \ Hires width
  164.   640                      CONSTANT Slice3RasterWidth  \ Raster=screenwidth
  165.  
  166.   DisplayHeight
  167.   Slice1Height -
  168.   Slice2Height -           CONSTANT Slice3Height       \ Bottom slice height
  169.  
  170.   4                        CONSTANT Slice3Planes       \ Bottom slice planes
  171.   2 Slice3Planes 1- LSL    CONSTANT Slice3Colours      \ Bottom slice colours
  172.   WORDINCLUDE
  173.   V_HIRES                  CONSTANT Slice3Mode         \ Bottom slice screenmode
  174.   LONGINCLUDE
  175.  
  176.   \ ***********************
  177.   \ Error handling routines
  178.   \ ***********************
  179.  
  180.   \ This error handler allows all errors to be routed via a comprehensive
  181.   \ sequential closedown routine, which is associated with the HeliOS
  182.   \ system error handler word ERROR".
  183.   \
  184.   \ When ERROR" senses an error, it prints an associated error message
  185.   \ delimited by '"' characters, and then closes everything down using the
  186.   \ routine CLOSEDOWN below which you have supplied.
  187.   \
  188.   \ This simplifies errors checks to the use of a single word, ERROR", which
  189.   \ displays a text message and closes eveything down.
  190.   \
  191.  
  192.   0 VARIABLE (CLOSEDOWN)
  193.  
  194.   : ?CLOSEDOWNERROR
  195.  
  196.   IF
  197.     CR
  198.     CR
  199.     TYPE
  200.     CR
  201.     CR
  202.     ." Press <Space> to quit!"
  203.     CR
  204.     CR
  205.     WAITSPACE
  206.     (CLOSEDOWN) @EXECUTE
  207.     QUIT
  208.   ELSE
  209.     DDROP
  210.   THEN
  211.   ;
  212.  
  213.   LATESTCFA VARIABLE ERROR1
  214.  
  215.   \ ********************************
  216.   \ Create pointer storage variables
  217.   \ ********************************
  218.  
  219.   \ Here we create a set of "pointers", initially set to a "null" value.
  220.   \
  221.   \ These "pointers" are set up as "long addresses" when various components
  222.   \ of the display system are allocated and initialised.
  223.   \
  224.   \ Note that initially these are all set to zero, and we clear them back
  225.   \ to zero when we de-allocate the associated resource.
  226.   \
  227.   \ These DPOINTERs are all initially set to "null" by using 'D0'.
  228.   \
  229.   \ When we allocate memory or Amiga system resources in the program at
  230.   \ run-time, these pointers are updated to contain the 32-bit address
  231.   \ of the newly allocated resource.
  232.   \
  233.   \ Subsequently the symbolic DPOINTER name can be used in your code to
  234.   \ represent the associated address.
  235.  
  236.   D0 DPOINTER Display1             \ Main Display structure pointer
  237.   D0 DPOINTER Slice1               \ Slice 1 Slice structure pointer
  238.   D0 DPOINTER Slice2               \ Slice 2 Slice structure pointer
  239.   D0 DPOINTER Slice3               \ Slice 3 Slice structure pointer
  240.  
  241.   D0 DPOINTER Slice1_ColorMap      \ Slice 1 ColourMap structure pointer
  242.   D0 DPOINTER Slice2_ColorMap      \ Slice 2 ColourMap structure pointer
  243.   D0 DPOINTER Slice3_ColorMap      \ Slice 3 ColourMap structure pointer
  244.  
  245.   D0 DPOINTER Slice1A_RasInfo      \ Slice 1A RasInfo structure pointer
  246.   D0 DPOINTER Slice1B_RasInfo      \ Slice 1B RasInfo structure pointer
  247.   D0 DPOINTER Slice2A_RasInfo      \ Slice 2A RasInfo structure pointer
  248.   D0 DPOINTER Slice2B_RasInfo      \ Slice 2B RasInfo structure pointer
  249.   D0 DPOINTER Slice3_RasInfo       \ Slice 3  RasInfo structure pointer
  250.  
  251.   D0 DPOINTER Slice1A_BMap         \ Slice 1A BitMap structure pointer
  252.   D0 DPOINTER Slice1B_BMap         \ Slice 1B BitMap structure pointer
  253.   D0 DPOINTER Slice2A_BMap         \ Slice 2A BitMap structure pointer
  254.   D0 DPOINTER Slice2B_BMap         \ Slice 2B BitMap structure pointer
  255.   D0 DPOINTER Slice3_BMap          \ Slice 3  BitMap structure pointer
  256.  
  257.   D0 DPOINTER Slice1A_SliceControl \ Slice 1A SliceControl structure pointer
  258.   D0 DPOINTER Slice1B_SliceControl \ Slice 1B SliceControl structure pointer
  259.   D0 DPOINTER Slice2A_SliceControl \ Slice 2A SliceControl structure pointer
  260.   D0 DPOINTER Slice2B_SliceControl \ Slice 2B SliceControl structure pointer
  261.  
  262.   \ *************
  263.   \ Colour tables
  264.   \ *************
  265.  
  266.   \ Each colour entry requies 2 bytes of storage space
  267.  
  268.   CREATEL Slice1_ColorTable        \ Create longword pointer
  269.   Slice1AColours 2* ALLOT          \ Allocate Slice1A colours * 2 bytes
  270.   Slice1BColours 2* ALLOT          \ Allocate Slice1B colours * 2 bytes
  271.  
  272.   CREATEL Slice2_ColorTable        \ Create longword pointer
  273.   Slice2AColours 2* ALLOT          \ Allocate Slice2A colours * 2 bytes
  274.   Slice2BColours 2* ALLOT          \ Allocate Slice2B colours * 2 bytes
  275.  
  276.   CREATEL Slice3_ColorTable  Slice3Colours  2* ALLOT
  277.  
  278.  
  279.   \ ***************************
  280.   \ Synchronised display scroll
  281.   \ ***************************
  282.  
  283.   \ This word is plugged into the interrupt driven SliceControl handler,
  284.   \ so will always execute automatically every frame with perfect timing.
  285.  
  286.   : MoveDisplay
  287.  
  288.   DDROP                                           \ Drop SliceControl pointer
  289.  
  290.   1 0  Slice1A_SliceControl  SETFIELD2SCROLL      \ Set 1 pixel H-scroll
  291.  
  292.   RAWKEY @ 79 =
  293.   IF
  294.     QUALIFIER @ 8 AND                             \ Is <Ctrl> pressed?
  295.     IF
  296.       12
  297.     ELSE
  298.       4
  299.     THEN
  300.     DUP
  301.        0  Slice2A_SliceControl  SETFIELD1SCROLL   \ Set foreground H-scroll
  302.     2/ 0  Slice2A_SliceControl  SETFIELD2SCROLL   \ Set background H-scroll
  303.   ELSE
  304.     RAWKEY @ 78 =
  305.     IF
  306.     QUALIFIER @ 8 AND                             \ Is <Ctrl> pressed?
  307.     IF
  308.       -12
  309.     ELSE
  310.       -4
  311.     THEN
  312.     DUP
  313.        0  Slice2A_SliceControl  SETFIELD1SCROLL \ Set foreground H-scroll
  314.     2/ 0  Slice2A_SliceControl  SETFIELD2SCROLL \ Set background H-scroll
  315.     THEN
  316.   THEN
  317.   ;
  318.  
  319.   LATESTCFA VARIABLE (MoveDisplay)                \ Store cfa address
  320.  
  321.   \ *************************************
  322.   \ Copper strip for graduated background
  323.   \ *************************************
  324.  
  325.   D0 DVARIABLE Copper
  326.   D0 DVARIABLE CopperLength
  327.  
  328.   : AddCopper
  329.  
  330.   Display1
  331.   Copper D@
  332.   ADDCOPPERSTRIP
  333.   SORTSTRIPTABLE
  334.   LINKSTRIPS
  335.   DDROP
  336.   ;
  337.  
  338.   : RemCopper                      \ Remove custom copper list from display
  339.  
  340.   Display1                         \ We are removing CopperList from Display1
  341.   Copper D@
  342.   REMCOPPERSTRIP
  343.   LINKSTRIPS
  344.   DDROP
  345.   ;
  346.  
  347.   : Create_Copper
  348.  
  349.   COPPERSTART
  350.   Copper D!
  351.   0 [ DECIMAL ] 190 [ HEX ] FFFE COPPERWAIT  DROP   0100 192 COPPERMOVE  DROP
  352.   0 [ DECIMAL ] 194 [ HEX ] FFFE COPPERWAIT  DROP   0200 192 COPPERMOVE  DROP
  353.   0 [ DECIMAL ] 198 [ HEX ] FFFE COPPERWAIT  DROP   0300 192 COPPERMOVE  DROP
  354.   0 [ DECIMAL ] 202 [ HEX ] FFFE COPPERWAIT  DROP   0400 192 COPPERMOVE  DROP
  355.   0 [ DECIMAL ] 204 [ HEX ] FFFE COPPERWAIT  DROP   0500 192 COPPERMOVE  DROP
  356.   0 [ DECIMAL ] 208 [ HEX ] FFFE COPPERWAIT  DROP   0600 192 COPPERMOVE  DROP
  357.   0 [ DECIMAL ] 212 [ HEX ] FFFE COPPERWAIT  DROP   0700 192 COPPERMOVE  DROP
  358.   0 [ DECIMAL ] 216 [ HEX ] FFFE COPPERWAIT  DROP   0800 192 COPPERMOVE  DROP
  359.   0 [ DECIMAL ] 220 [ HEX ] FFFE COPPERWAIT  DROP   0900 192 COPPERMOVE  DROP
  360.   0 [ DECIMAL ] 224 [ HEX ] FFFE COPPERWAIT  DROP   0A00 192 COPPERMOVE  DROP
  361.   0 [ DECIMAL ] 228 [ HEX ] FFFE COPPERWAIT  DROP   0B00 192 COPPERMOVE  DROP
  362.   0 [ DECIMAL ] 232 [ HEX ] FFFE COPPERWAIT  DROP   0C00 192 COPPERMOVE  DROP
  363.   0 [ DECIMAL ] 236 [ HEX ] FFFE COPPERWAIT  DROP   0D00 192 COPPERMOVE  DROP
  364.   0 [ DECIMAL ] 240 [ HEX ] FFFE COPPERWAIT  DROP   0E00 192 COPPERMOVE  DROP
  365.   0 [ DECIMAL ] 244 [ HEX ] FFFE COPPERWAIT  DROP   0F00 192 COPPERMOVE  DROP
  366.   [ DECIMAL ]
  367.   COPPEREND
  368.   CopperLength D!   Copper D!
  369.   ADDCOPPER
  370.   ;
  371.  
  372.   : Free_Copper
  373.  
  374.   RemCopper
  375.   Copper D@ FREEMEMORY
  376.   ;
  377.  
  378.   \ ***********************************
  379.   \ Create Display and Slice structures
  380.   \ ***********************************
  381.  
  382.   \ This routine simple makes blank structures, which then need to be
  383.   \ initialised in the CREATE_DISPLAY routine below.
  384.  
  385.   : CREATE_DSLICES
  386.  
  387.   DS_SIZEOF MAKESTRUCTURE Display1 MAKEPOINTER  \ Main "Display" structure
  388.  
  389.   SL_SIZEOF MAKESTRUCTURE Slice1   MAKEPOINTER  \ Top    "Slice" structure
  390.   SL_SIZEOF MAKESTRUCTURE Slice2   MAKEPOINTER  \ Middle "Slice" structure
  391.   SL_SIZEOF MAKESTRUCTURE Slice3   MAKEPOINTER  \ Bottom "Slice" structure
  392.   ;
  393.  
  394.   : FREE_DSLICES
  395.  
  396.   Slice3    DDUP FREEMEMORY   CLEARPOINTER
  397.   Slice2    DDUP FREEMEMORY   CLEARPOINTER
  398.   Slice1    DDUP FREEMEMORY   CLEARPOINTER
  399.   Display1  DDUP FREEMEMORY   CLEARPOINTER
  400.   ;
  401.  
  402.   \ ******************************
  403.   \ Create RasInfo structures etc.
  404.   \ ******************************
  405.  
  406.   : CREATE_RASINFO
  407.  
  408.   \ First allocate and initialise complete RasInfo structures.
  409.   \
  410.   \ This routine automatically allocates all BitMaps etc.
  411.   \
  412.  
  413.   Slice1ARasterWidth Slice1RasterHeight  Slice1APlanes   OPENRASINFO
  414.   DFLAG0= ERROR" Fail: RasInfo1A"
  415.   Slice1A_RasInfo MAKEPOINTER
  416.  
  417.   Slice1BRasterWidth Slice1RasterHeight  Slice1BPlanes   OPENRASINFO
  418.   DFLAG0= ERROR" Fail: RasInfo1B"
  419.   Slice1B_RasInfo MAKEPOINTER
  420.  
  421.   Slice2ARasterWidth Slice2RasterHeight Slice2APlanes    OPENRASINFO
  422.   DFLAG0= ERROR" Fail: RasInfo2A"
  423.   Slice2A_RasInfo MAKEPOINTER
  424.  
  425.   Slice2BRasterWidth Slice2RasterHeight Slice2BPlanes    OPENRASINFO
  426.   DFLAG0= ERROR" Fail: RasInfo2B"
  427.   Slice2B_RasInfo MAKEPOINTER
  428.  
  429.   Slice3RasterWidth  Slice3Height  Slice3Planes          OPENRASINFO
  430.   DFLAG0= ERROR" Fail: RasInfo3"
  431.   Slice3_RasInfo MAKEPOINTER
  432.  
  433.   \ Set invisible area "sprite margins" for middle slice RasInfo
  434.  
  435.   16              Slice2A_RasInfo         ri_RxOffset    INDEX!L
  436.   16              Slice2A_RasInfo         ri_RyOffset    INDEX!L
  437.  
  438.   16              Slice2B_RasInfo         ri_RxOffset    INDEX!L
  439.   16              Slice2B_RasInfo         ri_RyOffset    INDEX!L
  440.  
  441.   \ Link Dual Playfield RasInfo structures
  442.  
  443.   Slice1B_RasInfo Slice1A_RasInfo         ri_Next        INDEXD!L
  444.   Slice2B_RasInfo Slice2A_RasInfo         ri_Next        INDEXD!L
  445.  
  446.   \ Store BitMap pointers - often useful for later reference
  447.  
  448.   Slice1A_RasInfo  ri_BitMap INDEXD@L Slice1A_BMap MAKEPOINTER
  449.  
  450.   Slice1B_RasInfo  ri_BitMap INDEXD@L Slice1B_BMap MAKEPOINTER
  451.  
  452.   Slice2A_RasInfo  ri_BitMap INDEXD@L Slice2A_BMap MAKEPOINTER
  453.  
  454.   Slice2B_RasInfo  ri_BitMap INDEXD@L Slice2B_BMap MAKEPOINTER
  455.  
  456.   Slice3_RasInfo   ri_BitMap INDEXD@L Slice3_BMap  MAKEPOINTER
  457.   ;
  458.  
  459.   : FREE_RASINFO
  460.  
  461.   Slice3_RasInfo    DDUP CLOSERASINFO   CLEARPOINTER
  462.   Slice2B_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  463.   Slice2A_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  464.   Slice1B_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  465.   Slice1A_RasInfo   DDUP CLOSERASINFO   CLEARPOINTER
  466.   ;
  467.  
  468.   \ ************************
  469.   \ Create Slice Copperlists
  470.   \ ************************
  471.  
  472.   \ This function builds the main display copperlist by:
  473.   \
  474.   \ 1. Initialising the individual Slice data structures
  475.   \ 2. Calling MAKECOPSTRIP for each slice, to build Slice copperlists
  476.   \ 3. Calling MAKEDISPLAY to build the master Display copperlist
  477.   \
  478.  
  479.   : CREATE_DISPLAY
  480.  
  481.   \ First initialise main display structures
  482.  
  483.   Slice1                           Display1  DS_Slice     INDEXD!L
  484.  
  485.   Slice2                           Slice1    SL_Next      INDEXD!L
  486.   Slice1Width                      Slice1    SL_DWidth    INDEX!L
  487.   Slice1Height                     Slice1    SL_DHeight   INDEX!L
  488.   DisplayTopLine                   Slice1    SL_DyOffset  INDEX!L
  489.   Slice1A_RasInfo                  Slice1    SL_RasInfo   INDEXD!L
  490.   Slice1_ColorMap                  Slice1    SL_ColorMap  INDEXD!L
  491.   Slice1Mode                       Slice1    SL_Modes     INDEX!L
  492.  
  493.   Slice3                           Slice2    SL_Next      INDEXD!L
  494.   Slice2Width                      Slice2    SL_DWidth    INDEX!L
  495.   Slice2Height                     Slice2    SL_DHeight   INDEX!L
  496.   Slice1Height DisplayTopLine + 1+ Slice2    SL_DyOffset  INDEX!L
  497.   Slice2A_RasInfo                  Slice2    SL_RasInfo   INDEXD!L
  498.   Slice2_ColorMap                  Slice2    SL_ColorMap  INDEXD!L
  499.   Slice2Mode                       Slice2    SL_Modes     INDEX!L
  500.  
  501.   Slice3Width                      Slice3    SL_DWidth    INDEX!L
  502.   Slice3Height                     Slice3    SL_DHeight   INDEX!L
  503.  
  504.   Slice1Height Slice2Height +
  505.   DisplayTopLine + 2+              Slice3    SL_DyOffset  INDEX!L
  506.  
  507.   Slice3_RasInfo                   Slice3    SL_RasInfo   INDEXD!L
  508.   Slice3_ColorMap                  Slice3    SL_ColorMap  INDEXD!L
  509.   Slice3Mode                       Slice3    SL_Modes     INDEX!L
  510.  
  511.   \ Generate copper list information for each of the display slices
  512.  
  513.   Slice1 MAKECOPSTRIP
  514.   D0= ERROR" Fail: Slice1CopStrip"
  515.   Slice2 MAKECOPSTRIP
  516.   D0= ERROR" Fail: Slice2CopStrip"
  517.   Slice3 MAKECOPSTRIP
  518.   D0= ERROR" Fail: Slice3CopStrip"
  519.  
  520.   \ Make display
  521.  
  522.   Display1 MAKEDISPLAY
  523.   D0= ERROR" Fail: Display1"
  524.   ;
  525.  
  526.   : FREE_DISPLAY
  527.  
  528.   Display1                 FREEDISPLAY
  529.   Slice3                   FREECOPSTRIP
  530.   Slice2                   FREECOPSTRIP
  531.   Slice1                   FREECOPSTRIP
  532.   ;
  533.  
  534.   \ ***************************************************
  535.   \ Create SliceControl structures for scrolling slices
  536.   \ ***************************************************
  537.  
  538.   \ SliceControl structures are used to control any slices which perform
  539.   \ mapping or scrolling functions, or which require double or triple
  540.   \ playfield buffering.
  541.   \
  542.   \ In this case we have two slices which scroll horizontally, each with
  543.   \ automatic wrap.
  544.   \
  545.   \ The front middle slice playfield in this case is double buffered to
  546.   \ allow smooth BOB rendering as a game main playfield.
  547.   \
  548.   \ The HeliOS SLICECONTROL functions are extremely powerful, since they
  549.   \ handle all the double buffering and scrolling with automatic wrap.
  550.   \
  551.  
  552.   : CREATE_SLICECONTROLS
  553.  
  554.   \ Make two top Dual-Playfield SliceControls, each playfield with standard
  555.   \ single buffered bitmap displays, as indicated by "-1" parameters
  556.  
  557.   Slice1  -1 -1 -1 -1 MAKEDPSLICECONTROL
  558.   DFLAG0= ERROR" Fail: SliceControl1"
  559.   Slice1A_SliceControl MAKEPOINTER
  560.  
  561.   \ Get second dual playfield SliceControl pointer
  562.  
  563.   Slice1A_SliceControl SliceControl_DPSControl2 INDEXD@L
  564.   Slice1B_SliceControl MAKEPOINTER
  565.  
  566.   \ Set BPLCON2 control value
  567.  
  568.   [ BIN ] 100100 [ DECIMAL ]
  569.   Slice1A_SliceControl    SliceControl_BPLCON2     INDEX!L
  570.  
  571.   \ Set up rear playfield for automatic horizontal smooth wrapping
  572.  
  573.   1 Slice1B_SliceControl  SliceControl_HWrapFlag   INDEX!L
  574.  
  575.   \ Make middle two Dual-Playfield SliceControls, the rear playfield with
  576.   \ a standard single buffered bitmap display, configured by "-1" parameters,
  577.   \ and the front one with a double buffered display, configured by the 0
  578.   \ parameters.
  579.  
  580.   Slice2  0  0 -1 -1 MAKEDPSLICECONTROL
  581.   DFLAG0= ERROR" Fail: SliceControl2"
  582.   Slice2A_SliceControl MAKEPOINTER
  583.  
  584.   \ Get second dual playfield slice control
  585.  
  586.   Slice2A_SliceControl    SliceControl_DPSControl2 INDEXD@L
  587.   Slice2B_SliceControl MAKEPOINTER
  588.  
  589.   \ Set BPLCON2 control value
  590.  
  591.   [ BIN ] 100100 [ DECIMAL ]
  592.   Slice2A_SliceControl    SliceControl_BPLCON2     INDEX!L
  593.  
  594.   \ Set up both playfields for automatic horizontal smooth wrapping
  595.  
  596.   1 Slice2A_SliceControl  SliceControl_HWrapFlag   INDEX!L
  597.   1 Slice2B_SliceControl  SliceControl_HWrapFlag   INDEX!L
  598.  
  599.   \ Install display movement control word
  600.  
  601.   (MoveDisplay) @ Slice2A_SliceControl SliceControl_BeforeForth INDEX!L
  602.  
  603.   \ Install slice controls into HeliOS display control system
  604.  
  605.   Slice1A_SliceControl  INSTALLSLICECONTROL
  606.   Slice1B_SliceControl  INSTALLSLICECONTROL
  607.   Slice2A_SliceControl  INSTALLSLICECONTROL
  608.   Slice2B_SliceControl  INSTALLSLICECONTROL
  609.   ;
  610.  
  611.   : FREE_SLICECONTROLS
  612.  
  613.   CLEARSLICECONTROLS
  614.   Slice2B_SliceControl  CLOSESLICECONTROL
  615.   Slice2A_SliceControl  CLOSESLICECONTROL
  616.   Slice1B_SliceControl  CLOSESLICECONTROL
  617.   Slice1A_SliceControl  CLOSESLICECONTROL
  618.   ;
  619.  
  620.   \ These routines load IFF pictures into supplied BitMaps, and correctly
  621.   \ initialise the supplied ColorTables.
  622.   \
  623.   \ The ColorTables are then used to create initialised ColorMap structures.
  624.   \
  625.  
  626.   : CREATE_IMAGERY
  627.  
  628.   Slice1A_BMap
  629.   Slice1_ColorTable
  630.   Slice1APic
  631.   10
  632.   2 DOSLIB
  633.   10 <> ERROR" Fail: Slice1APic"
  634.  
  635.   Slice1B_BMap
  636.   Slice1_ColorTable Slice1AColours 2 M* D+
  637.   Slice1BPic
  638.   10
  639.   2 DOSLIB
  640.   10 <> ERROR" Fail: Slice1BPic"
  641.  
  642.   Slice2A_BMap
  643.   Slice2_ColorTable
  644.   Slice2APic
  645.   10
  646.   2 DOSLIB
  647.   10 <> ERROR" Fail: Slice2APic"
  648.  
  649.   Slice2B_BMap
  650.   Slice2_ColorTable Slice2AColours 2 M* D+
  651.   Slice2BPic
  652.   10
  653.   2 DOSLIB
  654.   10 <> ERROR" Fail: Slice2BPic"
  655.  
  656.   Slice3_BMap
  657.   Slice3_ColorTable
  658.   Slice3Pic
  659.   10
  660.   2 DOSLIB
  661.   10 <> ERROR" Fail: Slice3Pic"
  662.  
  663.   Slice1_ColorTable  Slice1AColours Slice1BColours + MAKECOLORMAP
  664.   DFLAG0= ERROR" Fail: Slice1ColorMap"
  665.   Slice1_ColorMap MAKEPOINTER
  666.  
  667.   Slice2_ColorTable  Slice2AColours Slice2BColours + MAKECOLORMAP
  668.   DFLAG0= ERROR" Fail: Slice2ColorMap"
  669.   Slice2_ColorMap MAKEPOINTER
  670.  
  671.   Slice3_ColorTable   Slice3Colours                  MAKECOLORMAP
  672.   DFLAG0= ERROR" Fail: Slice3ColorMap"
  673.   Slice3_ColorMap MAKEPOINTER
  674.   ;
  675.  
  676.   : FREE_IMAGERY
  677.  
  678.   Slice3_ColorMap  DDUP FREECOLORMAP  CLEARPOINTER
  679.   Slice2_ColorMap  DDUP FREECOLORMAP  CLEARPOINTER
  680.   Slice1_ColorMap  DDUP FREECOLORMAP  CLEARPOINTER
  681.   ;
  682.  
  683.   \ *********************
  684.   \ Close down everything
  685.   \ *********************
  686.  
  687.   : CLOSEDOWN
  688.  
  689.   FREE_COPPER
  690.   FREE_SLICECONTROLS
  691.   FREE_DISPLAY
  692.   FREE_IMAGERY
  693.   FREE_RASINFO
  694.   FREE_DSLICES
  695.   RESETERROR"
  696.   ;
  697.  
  698.   LATESTCFA (CLOSEDOWN) !
  699.  
  700.   : TestDisplay
  701.  
  702.   SCRCLR
  703.   CR
  704.  
  705.   ."        **********************************************************"
  706.   CR 6 FPENSET
  707.   ."             PARALLAX SCROLLING DUAL PLAYFIELD WITH TEXT DEMO"
  708.   CR 1 FPENSET
  709.   ."        **********************************************************"
  710.   CR
  711.   CR
  712.   ."        This code demonstrates how to create a display with multiple"
  713.   CR
  714.   ."        dual playfield slices and variable speed parallax scrolling."
  715.   CR
  716.   CR
  717.   ."        This code builds upon the following Demos:"
  718.   CR
  719.   CR
  720.   ."        Demo1_SinglePF.src"
  721.   CR
  722.   ."        Demo2_SinglePFCopper.src"
  723.   CR
  724.   CR
  725.   ."        **********************************************************"
  726.   CR 6 FPENSET
  727.   ."                  Press <Space> or <L-Mouse> to see Demo"
  728.   CR 3 FPENSET
  729.   ."            Use keyboard to change scroll speed and direction."
  730.   CR
  731.   ."        **********************************************************"
  732.   CR
  733.  
  734.   WAITSPACE
  735.  
  736.   SCRCLR
  737.  
  738.  
  739.   ERROR1 SETERROR"
  740.  
  741.   CREATE_DSLICES
  742.   CREATE_RASINFO
  743.   CREATE_IMAGERY
  744.   CREATE_DISPLAY
  745.   CREATE_SLICECONTROLS
  746.   CREATE_COPPER
  747.  
  748.   HeliOS_On
  749.  
  750.   1 FrameRate !L
  751.  
  752.   Display1 SHOWDISPLAY
  753.  
  754.   1 0  Slice1A_SliceControl  SETFIELD2SCROLL   \ Set 1 pixel H-scroll
  755.   4 0  Slice2A_SliceControl  SETFIELD1SCROLL   \ Set foreground H-scroll
  756.   2 0  Slice2A_SliceControl  SETFIELD2SCROLL   \ Set background H-scroll
  757.  
  758.   WAITSPACE
  759.  
  760.   HeliOS_Off
  761.  
  762.   CLOSEDOWN
  763.   ;
  764.  
  765.   TestDisplay
  766.