home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u191.dms / in.adf / SupportFiles / Programming / pix.a < prev    next >
Encoding:
Text File  |  1978-02-03  |  5.1 KB  |  216 lines

  1.       INCLUDE "EXEC/TYPES.I"
  2.  
  3.       INCLUDE "GRAPHICS/GFXBASE.I"
  4.       INCLUDE "GRAPHICS/GFX.I"
  5.       INCLUDE "GRAPHICS/VIEW.I"
  6.       INCLUDE "GRAPHICS/RASTPORT.I"
  7.  
  8.  XREF  _AbsExecBase             ;library references
  9.  XREF  _LVOCloseLibrary
  10.  XREF  _LVOOpenLibrary
  11.  XREF  _LVOInitView
  12.  XREF  _LVOLoadView
  13.  XREF  _LVOInitBitMap
  14.  XREF  _LVOFreeRaster
  15.  XREF  _LVOFreeColorMap
  16.  XREF  _LVOFreeVPortCopLists
  17.  XREF  _LVOAllocRaster
  18.  XREF  _LVOMakeVPort
  19.  XREF  _LVOMrgCop
  20.  XREF  _LVOInitVPort
  21.  XREF  _LVOGetColorMap
  22.  XREF  _LVOWaitTOF
  23.  XREF  _LVOLoadRGB4
  24.  XREF  _LVOExit
  25.  XREF  _LVOBltBitMap
  26.  
  27.  
  28.  XREF   readfile
  29.  
  30.  XDEF  dosbase
  31.  
  32.  CSECT  text,code
  33.  main:
  34.   jsr     openlibraries         ;for graphics library
  35.   move.l  graphicsbase,a6
  36.   move.l  gb_ActiView(a6),d0
  37.   movem.l d0,oldview            ;save old view address
  38.   jsr     init                  ;initialise view
  39.   lea     viewport,a0           ;load colours to clear the screen
  40.   lea     colourlist,a1
  41.   move.l  #16,d0              
  42.   move.l  graphicsbase,a6     
  43.   jsr     _LVOLoadRGB4(a6)
  44.   jsr     remake                ;load the display
  45.   move.l  #filename,d0          ;in this case piccy
  46.   move.l  #BMscene,d1           ;initialised bitmap
  47.   move.l  #colourlist2,d2        ;list for colours
  48.   jsr     readfile             ;read the iff file using C module iffread2
  49.   lea     viewport,a0           ;load colours from colourlist
  50.   lea     colourlist2,a1
  51.   move.l  #16,d0   
  52.   move.l  graphicsbase,a6     
  53.   jsr     _LVOLoadRGB4(a6)
  54.   jsr      remake
  55. loop:
  56.  move.b   $bfe001,d1       ;CIA-A parallel port  A
  57.  btst     #6,d1            ;test bit 6 for game port 0 fire button
  58.  beq      finish
  59.  move.b   $bfe001,d1       ;CIA-A parallel port A
  60.  btst     #7,d1            ;test bit 7 for game port 1 fire button 
  61.  bne      loop
  62. finish:
  63.   move.l  oldview,a1           ;replace old view
  64.   move.l  graphicsbase,a6 
  65.   jsr     _LVOLoadView(a6) 
  66.   jsr     cleanup              ;release memory 
  67.   jsr     closelibraries
  68.   rts
  69.  
  70. remake:                        ;remakes the display
  71.   move.l  graphicsbase,a6      ;the display could be made any which way
  72.   lea     view,a0              ;you want
  73.   lea     viewport,a1
  74.   jsr     _LVOMakeVPort(a6)
  75.   lea     view,a1
  76.   jsr     _LVOMrgCop(a6)
  77.   jsr     _LVOWaitTOF(a6)
  78.   lea     view,a1
  79.   jsr     _LVOLoadView(a6)
  80.   rts
  81.   
  82. init:                          ;if you are not using graphics primitives
  83.   move.l  graphicsbase,a6      ;all you need do here is set up a bitmap 
  84.   lea     view,a1              ;structure, poking the values in directly
  85.   jsr     _LVOInitView(a6)
  86.   lea     viewport,a0
  87.   jsr     _LVOInitVPort(a6)     ;initialises viewport(NTSC) viewport
  88.   lea     view,a5
  89.   move.l  #viewport,d0
  90.   move.l  d0,v_ViewPort(a5)
  91.   lea     BMscene,a0           ;bitmap 
  92.   move.b  #4,d0                ;playfield 1 320x256 fixed
  93.   move.w  #320,d1
  94.   move.w  #200,d2
  95.   jsr     _LVOInitBitMap(a6)
  96.   move.l  #BMscene,d0
  97.   lea     riscene,a5           ;rasinfo
  98.   move.l  d0,ri_BitMap(a5)
  99.   move.w  #0,ri_RxOffset(a5)
  100.   move.w  #0,ri_RyOffset(a5)
  101.   move.l  #0,ri_Next(a5)
  102.   lea     viewport,a5          ;viewport parameters
  103.   move.w  #320,vp_DWidth(a5)
  104.   move.w  #200,vp_DHeight(a5)
  105.   move.w  #0,vp_DyOffset(a5)   ;centred
  106.   move.w  #-2,vp_DxOffset(a5)
  107.   move.l  #riscene,d0
  108.   move.l  d0,vp_RasInfo(a5)
  109.   move.w  #0,vp_Modes(a5)
  110.   move.l  #16,d0               ;put in colour map
  111.   jsr     _LVOGetColorMap(a6)
  112.   lea     viewport,a5
  113.   move.l  d0,vp_ColorMap(a5)
  114.   movem.l d0,colourmap
  115.   lea     BMscene,a5           ;allocate rasters for bitmap
  116.   move.l  #3,d5
  117.   lea     bm_Planes(a5),a3
  118. nextplane:
  119.   move.l  #320,d0
  120.   move.l  #200,d1
  121.   jsr     _LVOAllocRaster(a6)
  122.   tst.l   d0
  123.   beq     notworthstarting
  124.   move.l  d0,(a3)+
  125.   dbra    d5,nextplane
  126.   rts
  127.  
  128. notworthstarting:              ;graceful exit if necessary
  129.   move.l  #1,d0
  130.   move.l  #dosbase,a6
  131.   jsr     _LVOExit(a6)
  132.   rts
  133.  
  134. openlibraries:               
  135.   move.l  _AbsExecBase,a6
  136.   move.l  #dosname,a1
  137.   clr.l   d0
  138.   jsr     _LVOOpenLibrary(a6)
  139.   movem.l d0,dosbase
  140.   tst.l   d0
  141.   beq     notworthstarting
  142.   move.l  #graphicsname,a1
  143.   clr.l   d0
  144.   jsr     _LVOOpenLibrary(a6)
  145.   movem.l d0,graphicsbase
  146.   tst.l   d0
  147.   beq     notworthstarting
  148.   rts
  149.  
  150. cleanup:
  151.   move.l  graphicsbase,a6
  152.   lea     viewport,a0
  153.   jsr     _LVOFreeVPortCopLists(a6)
  154.   move.l  colourmap,a0
  155.   jsr     _LVOFreeColorMap(a6)
  156.   lea     BMscene,a5
  157.   move.l  #3,d5
  158.   lea     bm_Planes(a5),a3
  159. cleanrast:
  160.   move.l  (a3)+,a0
  161.   move.l  #320,d0
  162.   move.l  #200,d1
  163.   jsr     _LVOFreeRaster(a6)
  164.   add.l   #4,a0
  165.   dbra    d5,cleanrast
  166.   rts
  167.  
  168. closelibraries:              
  169.   move.l  _AbsExecBase,a6
  170.   move.l  graphicsbase,a1
  171.   jsr     _LVOCloseLibrary(a6)
  172.   move.l  dosbase,a1
  173.   jsr     _LVOCloseLibrary(a6)
  174.   rts
  175.  
  176.  
  177.  CSECT  data
  178. filename:
  179.  dc.b  'piccy',0
  180.  ds.w    0
  181. dosname:
  182.  dc.b  'dos.library',0
  183.  ds.w   0
  184. graphicsname:
  185.  dc.b  'graphics.library',0
  186.  ds.w   0
  187. riscene:                        
  188.  dc.l 0
  189.  dc.l BMscene
  190.  ds.w 2
  191. viewport:      
  192.  ds.b vp_SIZEOF
  193.  ds.w 0
  194. graphicsbase:                      
  195.  ds.l    1
  196. oldview:
  197.  ds.l    1
  198. colourmap:
  199.  ds.l    1
  200. colourlist:
  201.  ds.l 32
  202. colourlist2:
  203.  dc.l 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  204.  dc.l 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  205. BMscene:
  206.  ds.b  bm_SIZEOF
  207.  ds.w  0
  208. view:
  209.  ds.b  v_SIZEOF
  210.  ds.w  0
  211. dosbase:
  212.  ds.l 1
  213.  END 
  214.  
  215.        
  216.