home *** CD-ROM | disk | FTP | other *** search
/ Computer Club Elmshorn Atari PD / CCE_PD.iso / pc / 0600 / CCE_0613.ZIP / CCE_0613.PD / XHARDCOP.Y / XHARDCPY.GFA (.txt) < prev    next >
GFA-BASIC Atari  |  1991-05-01  |  7KB  |  227 lines

  1. ' eXtended-Hardcopy-Accessory
  2. ' ---------------------------
  3. '
  4. ' © HayoSoft 1990 (und Uwe Seimet 1988)
  5. ' Hayo Schmidt
  6. ' Grotiusweg 1
  7. ' 2000 Hamburg 55
  8. '
  9. ' Anregungen von:
  10. ' Uwe Seimet, vgl. ST-Computer 4/90, S.94ff
  11. '
  12. $m300
  13. ' $I- Option kostet 1200 Bytes
  14. $U- ! Option bringt nichts
  15. $%3 ! "
  16. $E- ! "
  17. $P< ! "
  18. $*& ! bringt scheinbar 92 Bytes
  19. '
  20. '
  21. REM Als Accessory initialisieren
  22. ' ap_id&=APPL_INIT() ![direkt übergeben spart 4 Bytes]
  23. IF {BASEPAGE+&H24}=0   ! wenn p_parent gleich null, ist es ein Accessory
  24. ' ## INLINE:
  25. ' $0000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  26. ' 16  Bytes.
  27.   INLINE adr_buffer%,16
  28.   IF MENU_REGISTER(APPL_INIT(),"  XHardcopy 1.2")=-1 ! registrieren
  29.     ' PRINT "pXHardcopy nicht installiert - Menu_register() fehlgeschlagenq"
  30.     END
  31.   ENDIF
  32.   DO
  33.     ~EVNT_MESAG(adr_buffer%) ! warten bis Aufruf 40 AC_OPEN
  34.     '
  35.     IF WORD{adr_buffer%}=40
  36.       ~WIND_UPDATE(3)
  37.       xhard
  38.       ~WIND_UPDATE(2)
  39.     ENDIF
  40.   LOOP
  41. ELSE
  42.   xhard
  43. ENDIF
  44. END
  45. ' +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  46. '
  47. '
  48. PROCEDURE xhard
  49.   '
  50.   ' LOCAL mx&,my&,lw&,lh&,m_state&
  51.   '
  52.   REM Bildschirmparameter
  53.   '   (müssen immer wieder neu geholt werden wegen AutoSwitchOverScan)
  54.   xres&=WORD{L~A-12}                  ! Bildschirmauflösung
  55.   yres&=WORD{L~A-4}
  56.   v_lin_wr&=WORD{L~A+2}               ! Bytes pro Videozeile
  57.   v_planes&=WORD{L~A}                 ! Anzahl Bildebenen
  58.   pixperline&=v_lin_wr& DIV v_planes& ! Pixel pro Zeile
  59.   '
  60.   al&=FORM_ALERT(2,"[2][       *** XHardcopy ***| |      Bildschirm-Hardcopy|      Ausschnitt-Hardcopy|         ©HayoSoft 1990][Bildschirm|Ausschnitt|Abbruch]")
  61.   '
  62.   IF al&=1
  63.     blkhardcopy(0,0,xres&,yres&)         ! gesamter Bildschirm
  64.   ELSE IF al&=2
  65.     DEFMOUSE 3                           ! Ausschnitt
  66.     ~EVNT_BUTTON(1,1,1,mx&,my&,d&,d&)       ! x,y-Koordinaten bestimmen
  67.     ~GRAF_RUBBERBOX(mx&,my&,0,0,lw&,lh&)    ! Breite, Höhe bestimmen
  68.     '
  69.     ' statt GRAPHMODE 3
  70.     REM vswr_mode()
  71.     '   Set Writing Mode
  72.     CONTRL(6)=V~H
  73.     INTIN(0)=3
  74.     VDISYS 32,1,0
  75.     '
  76.     REM vsf_interior(vsfi_hd&,style&)
  77.     '   Set Fill Interior Style
  78.     ' CONTRL(6)=V~H
  79.     INTIN(0)=0
  80.     VDISYS 23,1,0
  81.     '
  82.     FOR i&=3 DOWNTO 0
  83.       ' statt BOX mx&,my&,mx&+lw&,my&+lh&   ! Ausschnitt nochmal anzeigen
  84.       REM v_bar()
  85.       ' CONTRL(6)=V~H
  86.       PTSIN(0)=mx&
  87.       PTSIN(1)=my&
  88.       PTSIN(2)=mx&+lw&
  89.       PTSIN(3)=my&+lh&
  90.       VDISYS 11,0,2,1
  91.       '
  92.       PAUSE 5
  93.     NEXT i&
  94.     DEFMOUSE 0
  95.     blkhardcopy(mx&,my&,lw&,lh&)
  96.   ENDIF
  97. RETURN
  98. ' --------------------------------
  99. '
  100. PROCEDURE blkhardcopy(x&,y&,w&,h&)
  101.   ' Block-Hardcopy:
  102.   ' Führt automatisch Hardcopy eines bestimmten Bildausschnittes durch.
  103.   ' Läuft auch unter Hyperscreen/OverScan.
  104.   ' ©HayoSoft 1990
  105.   '
  106.   ' LOCAL setprt%,pmask%,prttype&
  107.   '
  108.   setprt%=XBIOS(33,-1)       ! SETPRT
  109.   ' RESTORE prttypes
  110.   '   FOR i&=0 TO setprt% AND 7
  111.   '   READ prttype&
  112.   ' NEXT i&
  113.   '
  114.   '                        ! Wesentlich kürzer folgende Form der Tabelle
  115. ' ## INLINE:
  116. ' $0000: 00 02 01 ff 03 ff ff ff 
  117. ' 8  Bytes.
  118.   INLINE prttypes%,8
  119.   {prttypes%}=&H201FF      ! Tabelle in FLOAT-Variable (15 B kürzer als String)
  120.   {prttypes%+4}=&H3FFFFFF
  121.   prttype&=BYTE{prttypes%+(setprt% AND 7)}
  122.   '
  123.   ' RESTORE pmask
  124.   ' pmask$=""
  125.   ' FOR i&=0 TO 17
  126.   '   READ pm|
  127.   '   pmask$=pmask$+CHR$(pm|)
  128.   ' NEXT i&
  129.   '
  130.   ' wesentlich kürzer ist
  131. ' ## INLINE:
  132. ' $0000: 0f 0f 0d 06 09 06 08 06 08 02 08 00 08 00 08 00 
  133. ' $0010: 00 00 
  134. ' 18  Bytes.
  135.   INLINE pmask%,18
  136.   {pmask%}=&HF0F0D06
  137.   {pmask%+4}=&H9060806
  138.   {pmask%+8}=&H8020800
  139.   {pmask%+12}=&H8000800       ! durch die 2 Änderungen habe ich über 1800
  140.   ' WORD{pmask%+16}=0           ! Bytes eingespart.
  141.   '
  142.   xdiv8&=x& DIV 8
  143.   a%=XBIOS(3)+xdiv8&*v_planes&              ! Die Zerlegung der Parameter
  144.   ADD a%,MUL(y&,v_lin_wr&)
  145.   SUB x&,MUL(xdiv8&,8)                      ! auf Variablen
  146.   c&=MUL(pixperline&,8)-w&                  ! bringt nochmal 740 Bytes
  147.   d&=-BTST(setprt%,2)
  148.   e&=-BTST(setprt%,4)
  149.   prtblk(a%,x&,w&,h&,c&,0,XBIOS(4),d&,&HFF8240,prttype&,e&,pmask%)
  150.   '
  151.   ' prtblk(XBIOS(3)+x& DIV 8+y&*v_lin_wr&/v_planes&,x& MOD 8,w&,h&,v_lin_wr&*8-w&,0,XBIOS(4),-1*(BTST(setprt%,2)),&HFF8240,prttype&,-1*(BTST(setprt%,4)),pmask%)
  152.   '     logbase   x,y in Bytes umrechnen   x-Rest  Breite
  153.   '                                                 Höhe
  154.   ' prttypes:               ! Druckertypen entsprechend OS-Tabelle
  155.   ' DATA 0,2,1,-1,3,-1,-1,-1
  156.   '
  157.   ' pmask:                  ! Graustufenmaske
  158.   ' DATA $0F,$0F,$0D,$06,$09,$06,$08,$06
  159.   ' DATA $08,$02,$08,$00,$08,$00,$08,$00
  160.   ' DATA $00,$00
  161.   '
  162.   ' Parameterbeschreibung:
  163.   ' ----------------------
  164.   ' blkprt%        logbase
  165.   '                + x-Koordinate in Bytes
  166.   '                + y-Koordinate mal Bytes pro Videozeile.
  167.   ' offset&        ist der nicht durch 8 teilbare Rest der x-Koordinate.
  168.   ' width&,height& ist wohl klar.
  169.   ' left&          v_lin_wr, die Anzahl Bytes pro Videozeile wird ermittelt
  170.   '                durch v_planes (bit je Pixel) geteilt und
  171.   '                mit 8 multipliziert (dieses umständliche Verfahren
  172.   '                ist notwendig um Overscan-kompatibel zu sein). left& ist
  173.   '                die Videozeilenbreite in Pixeln abzüglich width&.
  174.   ' right&         wird auf 0 gesetzt (dieser 2. Parameter ist scheinbar
  175.   '                ziemlich überflüssig?).
  176.   '                left&+width&+right& muß = Videozeilenbreite in Pixel sein.
  177.   ' scrres&        GETREZ-Rückgabewert (0,1 oder 2), entspricht sshiftmd.
  178.   ' dstres&        wird über Bit 2 von SETPRT ermittelt.
  179.   ' colpal%        über das Farbpalettenregister 0 ($FF8240).
  180.   ' type&          das Verfahren der XBIOS-Hardcopy-Routine wird nachempfunden.
  181.   ' port&          Bit 4 aus SETPRT.
  182.   ' masks%         0 würde grundsätzlich auch reichen, jedoch enthält das XBIOS
  183.   '                einen Fehler und gibt den rechten Rand nicht immer voll-
  184.   '                ständig aus. Deshalb verwendet man eine eigene Kopie der
  185.   '                masks-Tabelle (vgl. ST-Computer 4/90, S. 94ff).
  186.   '
  187. RETURN
  188. ' -----------------
  189. '
  190. PROCEDURE prtblk(blkprt%,offset&,width&,height&,left&,right&,scrres&,dstres&,colpal%,type&,port&,masks%)
  191.   ' Aufruf der entsprechenden XBIOS-Routine prtblk()
  192.   ' vgl. ST-Computer 4/90, S.95
  193.   REM Normale Hardcopy wäre z.B.:
  194.   REM prtblk(LPEEK(&H44E),0,640,400,0,0,PEEK(&H44C),1,&HFF8240,3,0,0)
  195.   '
  196.   ' LOCAL par% ! entfällt zum Speicherplatz sparen
  197. ' ## INLINE:
  198. ' $0000: 00 0f 95 95 00 06 00 1a 00 1c 02 66 00 00 00 02 
  199. ' $0010: 00 01 00 ff 82 40 00 03 00 00 00 0a 34 2e 
  200. ' 30  Bytes.
  201.   INLINE par%,30
  202.   LONG{par%}=blkprt%        ! Startadresse = _v_bas_ad + x,y-Offset
  203.   WORD{par%+4}=offset&      ! 0 bis 7 Pixel links ausblenden
  204.   WORD{par%+6}=width&       ! Breite
  205.   WORD{par%+8}=height&      ! Höhe
  206.   WORD{par%+10}=left&       ! ???? linker Rand in Pixeln (geht nicht)
  207.   WORD{par%+12}=right&      ! ???? rechter Rand in Pixeln (dito)
  208.   '                         ! [width+left+right = Bildschirmbreite in Pixeln]
  209.   WORD{par%+14}=scrres&     ! _sshiftmod
  210.   WORD{par%+16}=dstres&     ! Druckerauflösung in Punkten
  211.   LONG{par%+18}=colpal%     ! Farbpalette (aus Videoregister)
  212.   WORD{par%+22}=type&       ! Druckertyp (z.B. Epson SW Matrix=3)
  213.   WORD{par%+24}=port&       ! 0=parallel  1=seriell
  214.   LONG{par%+26}=masks%      ! Graustufenmaske
  215.   '
  216.   SDPOKE &H4EE,1            ! _dmpflg setzen
  217.   ~XBIOS(36,L:par%)         ! PRTBLK
  218.   ' Der Rückgabewert ist meistens -65536, also $FFFF0000,
  219.   ' Läßt das auf einen unkorrekten Abbruch der Funktion schließen?
  220.   ' Ein Rückgabewert von -1 bedeutet fehlerhafte Parameter.
  221.   ' Ein Rückgabewert von 0 wird erzeugt, wenn der Ausschnitt als Breite
  222.   ' UND Höhe 0 hat. Nur Höhe=0 gibt -65536, nur Breite=0 gibt -1.
  223.   SDPOKE &H4EE,-1           ! scrdmp-flag rücksetzen
  224.   '
  225. RETURN
  226. '
  227.