home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / b-block1.lha / Print_Bitmap.s < prev    next >
Encoding:
Text File  |  1980-01-01  |  5.0 KB  |  266 lines

  1.     section    lard,code
  2.  
  3.     opt    d+
  4.  
  5. code:    IncDir    "DH0:Include/"
  6.     Include    Intuition/Intuition.I
  7.     Include    Intuition/Intuition_Lib.I
  8.     Include    Libraries/dos_LIb.i
  9.     Include    Libraries/Dos.i
  10.     Include    Exec/Exec_Lib.I
  11.     Include    Exec/Exec.I
  12.     Include    Graphics/Graphics_Lib.i
  13.     Include    Graphics/Gfx.i    
  14.     include    Graphics/Display.i    
  15.     include    Devices/Printer.i
  16.  
  17.     ***************************************************
  18.  
  19.     Lea    DosName,A1
  20.     Moveq    #0,D0
  21.     CALLEXEC    OpenLibrary
  22.     Move.l     D0,_DOSBase
  23.     Beq    error
  24.  
  25.     Lea    GFXName,A1
  26.     Moveq    #0,D0
  27.     CALLEXEC    OpenLibrary
  28.     Move.l     D0,_GFXBase
  29.     Beq    error
  30.  
  31.     Lea    IntName,A1
  32.     Moveq    #0,D0
  33.     CALLEXEC    OpenLibrary
  34.     Move.l    D0,_IntuitionBase
  35.     Beq    error
  36.  
  37.     *-----------------------------------------------------------*
  38.  
  39.     ; when ituition opens a screen it puts the screen name, gadgets
  40.     ; etc. on the top
  41.  
  42.     lea    picmem+256*40*0,a0
  43.     lea    backup+20*40*0,a1
  44.     bsr    copylines
  45.  
  46.     lea    picmem+256*40*1,a0
  47.     lea    backup+20*40*1,a1
  48.     bsr    copylines
  49.  
  50.     lea    picmem+256*40*2,a0
  51.     lea    backup+20*40*2,a1
  52.     bsr    copylines
  53.  
  54.     lea    picmem+256*40*3,a0
  55.     lea    backup+20*40*3,a1
  56.     bsr    copylines
  57.  
  58.     lea    picmem+256*40*4,a0
  59.     lea    backup+20*40*4,a1
  60.     bsr    copylines
  61.  
  62.     *-----------------------------------------------------------*
  63.     
  64.     Lea    MyScreen,a0
  65.     CALLINT    OpenScreen
  66.     Move.l    D0,_MyScrBase
  67.     
  68.     move.l    d0,a0
  69.     lea    sc_ViewPort(a0),a0
  70.     lea    picmem,a1
  71.  
  72.     move.w    #0,d0        ; convert colourmap 
  73. .cols    move.w    (a1),d1        ; to GFX RGB values
  74.     and.w    #$f00,d1
  75.     lsr.w    #8,d1
  76.     move.w    (a1),d2
  77.     and.w    #$0f0,d2
  78.     lsr.w    #4,d2
  79.     move.w    (a1)+,d3
  80.     and.w    #$00f,d3
  81.     
  82.     movem.l    d0-d7/a0-a6,-(a7)
  83.     CALLGRAF    SetRGB4
  84.     movem.l    (a7)+,d0-d7/a0-a6
  85.     add.w    #1,d0
  86.     cmp.w    #32,d0
  87.     bne    .cols
  88.  
  89.     *-----------------------------------------------------------*
  90.  
  91.     lea    picmem+256*40*0,a1
  92.     lea    backup+20*40*0,a0
  93.     bsr    copylines
  94.  
  95.     lea    picmem+256*40*1,a1
  96.     lea    backup+20*40*1,a0
  97.     bsr    copylines
  98.  
  99.     lea    picmem+256*40*2,a1
  100.     lea    backup+20*40*2,a0
  101.     bsr    copylines
  102.  
  103.     lea    picmem+256*40*3,a1
  104.     lea    backup+20*40*3,a0
  105.     bsr    copylines
  106.  
  107.     lea    picmem+256*40*4,a1
  108.     lea    backup+20*40*4,a0
  109.     bsr    copylines
  110.  
  111.     *-----------------------------------------------------------*
  112.  
  113.     bsr    print_rp
  114.  
  115. .wait    btst    #6,$bfe001
  116.     bne    .wait
  117.     
  118. CloseInt    Move.l    _MyScrBase,A0
  119.     CALLINT    CloseScreen
  120.  
  121.     Move.l    _IntuitionBase,A1
  122.     CALLEXEC    CloseLibrary
  123.  
  124.     Move.l    _GFXBase,A1
  125.     CALLEXEC    CloseLibrary
  126.  
  127.     Move.l    _DOSBase,A1
  128.     CALLEXEC    CloseLibrary
  129.  
  130.     *-------------------------------*
  131.  
  132. error    moveq    #0,D0
  133.     rts
  134.  
  135.     *-------------------------------*
  136.     
  137. print_rp:    move.l    #0,a1
  138.     CALLEXEC    FindTask
  139.  
  140.     lea    reply_port,a1
  141.     move.l    d0,MP_SIGTASK(a1)
  142.     CALLEXEC    AddPort
  143.         
  144.     lea    IO_port,a1
  145.     move.l    #0,d0
  146.     move.l    #0,d1
  147.     lea    prt_dev,a0
  148.     CALLEXEC    OpenDevice
  149.     cmp.l    #0,d0
  150.     bne    Error
  151.  
  152.     lea    IO_port,a1
  153.     move.l    #reply_port,MN_REPLYPORT(a1)
  154.     move.w    #PRD_DUMPRPORT,IO_COMMAND(a1)
  155.  
  156.     move.l    _IntuitionBase,a6
  157.     move.l    _MyScrBase,a2
  158.     
  159.     lea    sc_RastPort(a2),a3
  160.     move.l    a3,io_RastPort(a1)    
  161.     
  162.     lea    sc_ViewPort(a2),a3
  163.     move.l    vp_ColorMap(a3),io_ColorMap(a1)
  164.     
  165.     lea    myscreen,a6
  166.     move.w    ns_Width(a6),d0
  167.     moveq    #0,d1
  168.     move.w    ns_ViewModes(a6),d1
  169.     
  170.     move.l    d1,io_Modes(a1)
  171.     move.w    #0,io_SrcX(a1)
  172.     move.w    #0,io_SrcY(a1)
  173.     
  174.     move.w    d0,io_SrcWidth(a1)        ; screen width
  175.     move.w    #256,io_SrcHeight(a1)        ; screen height
  176.     move.l    #320*2,io_DestCols(a1)        ; printer width
  177.     move.l    #256,io_DestRows(a1)        ; printer height
  178.  
  179.     move.l    #SPECIAL_FULLCOLS+SPECIAL_FULLROWS,io_Special(a1)
  180.     CALLEXEC    DoIO
  181.  
  182.     lea    IO_port,a1
  183.     move.b    #0,IO_ERROR(a1)
  184.  
  185.     ; 0=no error
  186.     ; 1=Printing canceled
  187.     ; 2=Printer driver does not support graphics
  188.     ; 3=Printer driver obsolete
  189.     ; 4=Print dimensions are illegal
  190.     ; 5=No memory available for internal variables
  191.     ; 6=No memory available for print buffer
  192.     ; 7=Printer driver has taken control
  193.  
  194. .ok    lea    reply_port,a1
  195.     CALLEXEC    RemPort
  196.     
  197.     lea    IO_port,a1
  198.     CALLEXEC    CloseDevice
  199.  
  200.     rts
  201.  
  202.     *------------------------------------------------*
  203.  
  204. copylines:    move.w    #(10*20)-1,d0
  205. .loop    move.l    (a0)+,(a1)+
  206.     dbf    d0,.loop
  207.     rts
  208.     
  209.     *------------------------------------------------*
  210.  
  211. _MyScrBase        Dc.l    0
  212. _MyWinBase        Dc.l    0
  213. _MyWinRPort        Dc.l    0
  214. _MyWinUserPort    Dc.l    0
  215. _MyWinVPort        Dc.l    0
  216.  
  217. _IntuitionBase    Dc.l    0
  218. _DOSBase        Dc.l    0
  219. _GFXBase        Dc.l    0
  220.  
  221. IO_port:        dcb.l    20,0
  222. reply_port:        dcb.l    8,0
  223.  
  224. IntName        INTNAME
  225. DosName        DOSNAME
  226. GfxName        GRAFNAME
  227. prt_dev:        dc.b    "printer.device",0
  228.         even
  229.         
  230. **************************************************
  231.  
  232. MyScreen:    dc.w    0,0        ;screen XY origin relative to View
  233.     dc.w    320,256        ;screen width and height
  234.     dc.w    0        ;screen depth (number of bitplanes)
  235.     dc.b    0,0        ;detail and block pens
  236.     dc.w    0        ;display modes for this screen
  237.     dc.w    CUSTOMSCREEN+CUSTOMBITMAP+SCREENQUIET
  238.                 ;screen type
  239.     dc.l    0        ;pointer to default screen font
  240.     dc.l    0        ;screen title
  241.     dc.l    0        ;first in list of custom screen gadgets
  242.     dc.l    MyBitMap        ;pointer to custom BitMap structure
  243.  
  244. MyBitMap:    dc.w    40        ;bm_BytesPerRow (.w)
  245.     dc.w    256        ;bm_Rows (.w)
  246.     dc.b    0        ;bm_Flags (.b)
  247.     dc.b    5        ;bm_Depth (.b)
  248.     dc.w    0        ;bm_Pad (.w)
  249.     dc.l    picmem+64+(0*40*256)    ;bm_Planes (.l) 1
  250.     dc.l    picmem+64+(1*40*256)    ;bm_Planes (.l) 2
  251.     dc.l    picmem+64+(2*40*256)    ;bm_Planes (.l) 3
  252.     dc.l    picmem+64+(3*40*256)    ;bm_Planes (.l) 4
  253.     dc.l    picmem+64+(4*40*256)    ;bm_Planes (.l) 5
  254.     dc.l    0        ;bm_Planes (.l) 6
  255.     dc.l    0        ;bm_Planes (.l) 7
  256.     dc.l    0        ;bm_Planes (.l) 8
  257.  
  258.     section    ddp,code_c
  259.  
  260. picmem:    incbin    "dh0:data/pic.bin"
  261. backup:    ds.l    10*20*6
  262.  
  263.     end
  264.  
  265.  
  266.