home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / bbs / libdisks / d700t799 / disk718.lha / BootPic / BootPic_source.lz / boopic.asm < prev    next >
Encoding:
Assembly Source File  |  1992-08-13  |  72.3 KB  |  2,540 lines

  1. ********************************************************************************
  2. *                                                                              *
  3. *                                BootPic V2.1                                  *
  4. *                                (source-code)                                 *
  5. *                                                                              *
  6. *  Author:     Andreas Ackermann                                               *
  7. *  Assembler:  Devpac V2.14D                                                   *
  8. *  Date:       from 8.7. to 19.7. 1991 to 29.12.1991 to 18.1.1992 15.7.'92     *
  9. *  Develloped under Kickstart V1.2                                             *
  10. *                                                                              *
  11. *  [see doc-file for further information].                                     *
  12. *                                                                              *
  13. * The whole programm is split in two parts:                                    *
  14. * 1st we look what the user wants, then we remove or install BootPic in the    *
  15. * way it is requested.                                                         *
  16. * The 2nd part, which is installed resident, is responsible for showing the    *
  17. * picture.                                                                     *
  18. *                                                                              *
  19. * Added intuition-interface, main part unchanged, int-routines documented      *
  20. * in intuition_support.asm                                                     *
  21. *                                                                              *
  22. * NEW !!!: 18|12|91 BUG behoben: Resetfeste Teile ins CHIP-Mem !!!             *
  23. *   29|12|91 :[finished]                                                       *
  24. * CRNG-Support                                                                 *
  25. * Kick2.0 support   ( bug removed [view] )                                     *
  26. * DPaint IV support ( no crash when more than 32 colors !!)                    *
  27. * Starting 14.1.: MED_Support                                                  *
  28. *          23.1.: pp-packed modules + playmodule nur dann resetfest, wenn modul*
  29. *                 geladen ist                                                  *
  30. *          ??.5.  -d Option                                                    *
  31. *          15.6.: 1MB Chip-RAM sollte mit Kick 1.3 keine Probleme machen !!!   *
  32. *          19.6.: test, ob Version=ROM-Version                                 *
  33. *          13.7.: anfang bootselektor + Bootsel fertig                         *
  34. *          14.7.: Nocklick                                                     *
  35. *          31.7.  Noclick wieder entfernt ( ging nicht )                       *
  36. *          10.8   coldcap wurde immer gelöscht; jetzt nur wenn er gesetzt war  *
  37. ********************************************************************************
  38.  
  39. ; This was my first programm I ever wrote in assembler ( at least a large
  40. ; part of it) . So some parts may confuse you , as they could be expressed
  41. ; much better. Please don't laugh ! But as everything seems to do its job
  42. ; I left everything as is. I'm sorry for not having the time to document
  43. ; the source. If you have any questions, propositions, if you ( god knows
  44. ; how) find a bug please write me. Please include postage for my answer.
  45. ; Maybe you wonder how the bootselector works:
  46. ; To reassemble the file you'll have to change the include paths for
  47. ; gfx, dos, arp and intuition in standard.macs to your needs
  48. ;
  49. ; _lvosetfunction manipulates ANY libraryfunction, so your code is called
  50. ; instead of the old function. Then it's your turn to call the original
  51. ; function.
  52. ; I change opendevice. Everytime opendevice is called, I check if it's
  53. ; trackdiskdevice. If yes, I change the unitnumber for my own needs
  54. ; ( if System wants df0: I simply pass df1: oder df2: !!!)
  55. ; look at label 'activatebootsel'
  56.  
  57.                 rsreset
  58. border          rs.l    0
  59. bd_leftedge     rs.w    1
  60. bd_topedge      rs.w    1
  61. bd_frontpen     rs.b    1
  62. bd_backpen      rs.b    1
  63. bd_drawmode     rs.b    1
  64. bd_count        rs.b    1
  65. bd_XY           rs.l    1   ; ^ auf Daten
  66. bd_nextborder   rs.l    1
  67. size_of_border  rs.l    0
  68.                 rsreset
  69.  
  70. gadget          rs.l    0
  71. gd_nextgadget   rs.l    1
  72. gd_leftedge     rs.w    1
  73. gd_topedge      rs.w    1
  74. gd_width        rs.w    1
  75. gd_height       rs.w    1
  76. gd_flags        rs.w    1
  77. gd_activation   rs.w    1
  78. gd_gadgettype   rs.w    1
  79. gd_gadgetrender rs.l    1
  80. gd_selectrender rs.l    1
  81. gd_gadgettext   rs.l    1
  82. gd_dummy        rs.l    1
  83. gd_specialinfo  rs.l    1
  84. gd_gadgetid     rs.w    1
  85. gd_userdata     rs.l    1
  86. size_of_gadget  rs.l    0
  87.                 rsreset
  88.  
  89. itext           rs.l    0
  90. it_frontpen     rs.b    1
  91. it_backpen      rs.b    1
  92. it_drawmode     rs.b    2   ; Dummy eingeschlossen !!!)
  93. it_leftedge     rs.w    1
  94. it_topedge      rs.w    1
  95. it_textattr     rs.l    1
  96. it_itext        rs.l    1
  97. it_nexttext     rs.l    1
  98. size_of_itext   rs.l    0
  99.                 rsreset
  100.  
  101. gadget1         equ     0
  102. render1         equ     46
  103. koords          equ     render1+20
  104. itext1          equ     koords+24
  105. itext2          equ     itext1+24
  106.  
  107. bufferstart     equ     770
  108.  
  109. gadgetmemsize   equ     570+50+50+100+34+200     ; ???
  110.  
  111.  
  112.         include "standard.macs"
  113.         include "exec/exec_lib.i"
  114.         include "bpic_special.i"
  115.         include "dev_support.i"
  116.  
  117.         windowsup
  118.  
  119.         movem.l d0/a0,-(sp)            ;save commandline parameters
  120.         move.l  playerstart-8,playerlength
  121.         move.l  4.w,a6
  122.         opendos
  123.         opengfx
  124.         openint                        ;arp erst später öffnen, da sonst Absturz
  125.         sub.l   a1,a1                  ;wenn Start von WB und arp noch nicht geladen
  126.         jsr     _lvoFindTask(a6)       ;find structure of our task
  127.         move.l  d0,a4
  128.         move.l  a4,taskptr
  129.  
  130.  
  131.         movem.l (sp)+,d0/a0            ;return commandline parms
  132.         tst.l   pr_CLI(a4)             ;WB?
  133.         beq.s   workbench      !!!
  134.         movem.l d0/a0,-(sp)
  135.         getdos
  136.         jsr     _lvooutput(a6)      ;get handle of CLI
  137.         move.l  d0,whandle
  138.  
  139.         lea     welcome(pc),a2      ;introduce ourselves
  140.         bsr     stringout
  141.         movem.l (sp)+,d0/a0
  142.         bsr     parser
  143.         tst.b   mparm
  144.         beq.s   cli_int
  145.  
  146.         bsr   _bootpic               ;call our programm
  147. fromparse
  148.         bra     _exit
  149. workbench
  150.  
  151.         move.l  taskptr(pc),a4
  152.         lea     pr_MsgPort(a4),a0      ;if WB we must wait for startup-msg
  153.         jsr     _lvowaitport(a6)
  154.         lea     pr_MsgPort(a4),a0
  155.         jsr     _lvogetmsg(a6)
  156.         move.l  d0,wbenchmsg          ;save message !!
  157.         move.l  d0,a0
  158.         cmp.l   #1,$1c(a0)
  159.         beq.s   cli_int
  160.         move.l  $24(a0),a0
  161.         move.l  8(a0),d1              ;ob andere icons mit selektiert wurden
  162.         move.l  12(a0),thename
  163.         getdos
  164.         jsr     _lvocurrentdir(a6)
  165.         move.l  d0,thelock
  166. cli_int
  167.         move.l  4.w,a6
  168.         openarp
  169.  
  170.     bsr     initwindow
  171.     tst.l   thename
  172.     beq.s   1$
  173.     move.l  thename(pc),a0
  174.  
  175.     move.l  gadgetmem(pc),a1
  176.     move.l  a1,a2
  177.     add.l   #bufferstart+100,a1
  178.     add.l   #bufferstart+50,a2
  179. 10$ move.b  (a0),(a1)+
  180.     move.b  (a0)+,(a2)+
  181.     bne.s   10$
  182.  
  183. 1$  move.l  userport(pc),a2
  184.     bsr     waitmsg
  185.     cmp.l   #$200,20(a1)
  186.     beq     6$
  187.     move.l  28(a1),a0
  188.     move.w  gd_gadgetid(a0),theid
  189.     jsr     _lvoreplymsg(a6)
  190.     cmp.w   #8,theid
  191.     bne.s   2$
  192.     bsr     infowindow
  193. 2$  cmp.w   #6,theid
  194.     bne    3$
  195.     lea.l   reqtext(pc),a0
  196.     bsr     getfilename
  197.     tst.b   d0
  198.     beq.s   1$
  199.     move.l  gadgetmem(pc),a0
  200.     add.l   #bufferstart+100,a0
  201.         lea     gdef(pc),a1
  202. 207$
  203.         move.b  (a0),(a1)+
  204.         tst.b   (a0)+
  205.         bne.s   207$
  206.     move.l  gadgetmem(pc),a0
  207.     add.l   #bufferstart+100,a0
  208.     clr.b   (a0)
  209.     move.l  #gdef,fname
  210.     getint
  211.     move.l  windowptr(pc),a0
  212.     jsr     _lvoviewportaddress(a6)
  213.     getgfx
  214.     move.l  d0,a0
  215.     move.l  4(a0),a0
  216.     moveq   #0,d0
  217.     jsr     _lvogetrgb4(a6)
  218.     lea     konst(pc),a0
  219.  
  220.     move.b  d0,2(a0)
  221.     and.b   #%1111,2(a0)
  222.     lsr.w   #4,d0
  223.     move.b  d0,1(a0)
  224.     and.b   #%1111,1(a0)
  225.     lsr.b   #4,d0
  226.     move.b  d0,(a0)
  227.     bsr     yesnowindow
  228.     tst.w   d0
  229.     beq.s   277$
  230.     move.l  gadgetmem(pc),a0
  231.     add.l   #bufferstart+50,a0
  232.     clr.b   (a0)
  233.     lea.l  qtext(pc),a0
  234.     bsr     getfilename
  235.         tst.b   d0
  236.         beq.s   277$
  237.     move.l  gadgetmem(pc),a0
  238.     add.l   #bufferstart+100,a0
  239.     move.l  a0,modulename
  240.  
  241.  
  242. 277$
  243.     bsr     _bootpic
  244. 3$  cmp.w   #7,theid
  245.     bne.s   50$
  246.     move.b  #1,remptr
  247.     bsr     _bootpic
  248.     bra 1$
  249. 50$ cmp.w   #10,theid
  250.     bne.s   51$
  251.     tst.w   kickflag
  252.     beq.s    501$
  253.     clr.w   kickflag
  254.     bra 1$
  255. 501$
  256.     move.w #1,kickflag
  257. 51$ cmp.w   #9,theid
  258.     bne.s   4$
  259.     tst.w   cycflag
  260.     beq.s    511$
  261.     clr.w   cycflag
  262.     bra 1$
  263. 511$
  264.     move.w #1,cycflag
  265.  
  266.  
  267. 4$  bra     1$
  268. 6$  jsr     _lvoreplymsg(a6)
  269.     bsr     windowcleanup
  270.     getdos
  271.     move.l  thelock(pc),d1
  272.     beq.s   nolock
  273.     jsr     _lvocurrentdir(a6)
  274. nolock
  275.         tst.l   wbenchmsg              ;run from WB ?
  276.         beq.s   _exit                  ;no => CLI
  277.  
  278.         move.l  4.w,a6
  279.         jsr     _lvoforbid(a6)
  280.         move.l  wbenchmsg(pc),a1        ;return message
  281.         jsr     _lvoreplymsg(a6)
  282.  
  283. _exit
  284.         move.l  4.w,a6
  285.         closedos
  286.         closegfx
  287.         closeint
  288.         move.l   arpbase(pc),d0
  289.         beq.s   noarp
  290.         closearp
  291. noarp   clr.l   d0                      ;no returncode
  292.         rts                             ;the end
  293.  
  294.         arpstuff
  295.  
  296. taskptr     dc.l    0
  297. thename     dc.l    0
  298. thelock     dc.l    0
  299. theid       dc.w    0
  300.  
  301.  
  302. * a2= portaddresse     erg:message=a1
  303. waitmsg
  304.     move.l  4.w,a6
  305.     move.l  a2,a0
  306.     jsr     _lvowaitport(a6)
  307.     move.l  a2,a0
  308.     jsr     _lvogetmsg(a6)
  309.     move.l  d0,a1
  310.     rts
  311.  
  312.  
  313.  
  314. parser                      ;here we get from CLI : figure out
  315.                             ;what the user wants
  316.         subq.w  #1,d0       ;any parms ? no->int-window
  317.         beq     wrt2 ;noparms
  318.         clr.w   kickflag        ;bei cli ist das keine Voreinstellung !!!(BootSel)
  319.         clr.b   0(a0,d0.w)  ;zero-terminate it
  320. plop    bsr     getspcout
  321.         cmp.b   #'-',(a0)+
  322.         bne     noparms     ;no '-' in front of parameter
  323.         bclr.b  #5,(a0)     ;force uppercase
  324.         cmp.b   #'R',(a0)   ;get out -r
  325.         bne.s   noreset
  326.         move.b  #1,resetvar
  327.         addq.l   #1,a0
  328.         bra.s   plop        ; -k
  329. noreset cmp.b   #'K',(a0)
  330.         bne.s   nokick
  331.         addq.l  #1,a0
  332.         move.w  #1,kickflag
  333.         bra.s   plop
  334. nokick  cmp.b   #'Y',(a0)      ; colorcycling
  335.         bne.s   nocyc
  336.         move.w  #1,cycflag
  337.         addq.l  #1,a0
  338.         bra.s   plop
  339. nocyc   cmp.b   #'E',(a0)   ;get out -e
  340.         bne.s   noremove
  341.         move.b  #1,mparm
  342.         move.b  #1,remptr
  343.         addq.l   #1,a0
  344.         bra.s   plop
  345. noremove
  346.         cmp.b   #'S',(a0)  ;get out -s
  347.         bne.s   nostartup
  348.         move.b  #1,startup
  349.         addq.l   #1,a0
  350.         bra.s   plop
  351. nostartup
  352.         cmp.b   #'D',(a0)  ;get out -s
  353.         bne.s   nodelay
  354.         addq.l   #1,a0
  355.         bsr     getspcout
  356.         moveq   #0,d0
  357.         move.b  (a0)+,d0
  358.         sub.w   #$30,d0
  359.         mulu    #50,d0
  360.         move.w  d0,delaytime
  361.         bra   plop
  362.  
  363. nodelay
  364.         cmp.b   #'L',(a0)  ;get out -l
  365.         bne.s   noload
  366.         move.b  #1,mparm
  367.         addq.l   #1,a0
  368.         bsr     getspcout
  369.         move.l  a0,fname
  370. findspc addq.l   #1,a0
  371.         cmp.b   #' ',(a0)
  372.         beq.s   terminate1
  373.         tst.b   (a0)
  374.         bne.s   findspc
  375.         beq     plop
  376. terminate1
  377.         clr.b  (a0)+
  378.         bra     plop
  379. noload
  380.         cmp.b   #'M',(a0)  ;get out -m
  381.         bne.s   nomed
  382.         addq.l   #1,a0
  383.         bsr     getspcout
  384.         move.l  a0,modulename
  385. findspc5 addq.l   #1,a0
  386.         cmp.b   #' ',(a0)
  387.         beq.s   terminate15
  388.         tst.b   (a0)
  389.         bne.s   findspc5
  390.         beq     plop
  391. terminate15
  392.         clr.b  (a0)+
  393.         bra     plop
  394.  
  395.  
  396. nomed  cmp.b   #'C',(a0)+ ;get out -c
  397.         bne.s   noparms    ;someone typed nosense after '-'
  398.         bsr     getspcout
  399.         moveq.w #2,d0
  400.         lea     konst(pc),a1    ;there we put the color
  401. cl      tst.b   (a0)
  402.         beq.s   wrt3     ;ende
  403.         cmp.b   #' ',(a0)
  404.         beq.s   wrt3 ;           ende
  405.         sub.b   #48,(a0)
  406.         cmp.b   #10,(a0)
  407.         blt.s   no15
  408.         bclr.b  #5,(a0)
  409.         sub.b   #7,(a0)
  410. no15    and.b   #%1111,(a0)
  411.         move.b  (a0)+,(a1)+
  412.         dbf     d0,cl
  413.         bra     plop
  414.  
  415. getspcout
  416.         tst.b   (a0)       ;increase a0 till we find a space or zero
  417.         beq.s   wrt
  418.         cmp.b   #' ',(a0)+
  419.         beq.s    getspcout
  420.         subq.l   #1,a0
  421.         rts
  422. wrt     addq.l   #4,sp
  423. wrt3    rts
  424. wrt2    clr.b   mparm
  425.         rts
  426. noparms add.l   #4,a7
  427.         lea     use(pc),a2
  428.         bsr     stringout
  429.         bra     fromparse
  430.  
  431.  
  432. _bootpic
  433.         movem.l d0-1/d3-7/a0-1/a3-6,-(sp)
  434.         lea     crngs(pc),a0
  435.         move.w  #(7*2)-1,d0
  436. 100$    clr.l   (a0)+
  437.         dbf     d0,100$
  438. ;        clr.w   kickflag
  439.         move.l  4.w,a6      ;the parms were correct, so let's kill a possibly
  440.         move.l  546(a6),a3  ;installed BootPic at any rate
  441.         tst.l   546(a6)
  442.         beq     notinstalled
  443. chknxt  move.l  LN_NAME(a3),a0
  444.         cmp.l   #'BPic',(a0)        ;go through memlist till we find BootPic
  445.         beq.s   bpicfound           ;or till the end
  446.         tst.l   (a3)                ;[tst.l  LN_SUCC(a3)]
  447.         beq     notinstalled
  448.         move.l  (a3),a3             ;[move.l LN_SUCC(a3),a3] next node
  449.         bra.s   chknxt
  450. bpicfound               ;we found BootPic !!!
  451.         tst.b   startup ;check for -s flag: if not set let's remove BootPic
  452.         beq.s   remove
  453.         lea     stext(pc),a2    ;tell the user that BPic is installed
  454.         bra     noopen          ;return
  455. remove  jsr     _lvoforbid(a6)  ;in a3 we still hold the memlist-node of BPic
  456.         tst.l   LN_PRED(a3)     ;is there anyone before ?
  457.         beq.s   nopred          ;if not, we're first
  458.         move.l  LN_PRED(a3),a0  ;move our successor(or zero) to the successor
  459.         move.l  (a3),(a0)       ;of our predecessor
  460. tstsuc  tst.l   (a3)            ;is there any successor ?
  461.         beq.s   predok          ;no, everything ok
  462.         move.l  (a3),a1         ;if so we must move its address to the
  463.         move.l  a0,LN_PRED(a1)  ;successor's address of our predecessor
  464.         bra.s   predok
  465. nopred  move.l  (a3),546(a6)    ;if we're first, we must write the start of
  466.         sub.l   a0,a0           ;memlist into sysbase->kickmemptr
  467.         bra.s   tstsuc
  468. predok                          ;we switched off multitasking, so we can free
  469.  
  470.         move.w  LN_NAME+4(a3),d3;the allocated memory already now (numentries)
  471.         subq.w  #1,d3           ;LN_NAME+4 = ML_NUMENTRIES
  472.         add.l   #LN_NAME+6,a3   ;start of memorypointer table
  473.         tst.l   playerstart-8
  474.         bne.s   fagain          ; wegen remove wenn noch kein reset war
  475.         clr.l   24-8(a3)
  476.         clr.l   28-8(a3)
  477.         move.l  playerlength(pc),playerstart-8
  478.  
  479. fagain  move.l  (a3)+,a1        ;startaddress
  480.         move.l  (a3)+,d0        ;length
  481.         jsr     _lvofreemem(a6) ;free it
  482.         dbf     d3,fagain       ;usually twice (dbf loop for reasons of compa-
  483.                                 ;tibilty to higher versions that might follow)
  484.         move.l  550(a6),a3      ;kicktagptr to a3
  485. nentry  move.l  (a3),a0
  486.         move.l  rt_name(a0),a0
  487.         cmp.l   #'BPic',(a0)    ;check first resident structure for BPic
  488.         beq.s   bpicf2
  489.         move.l  a3,a4           ;save actual restabptr
  490.         add.l   #4,a3           ;next entry
  491.         move.l  (a3),d0 ;no more entrys ?! but we found BPic's memory and now
  492.         beq.s   finito  ;we found not its resident structure => fatal error !
  493.         btst.l  #$1f,d0 ;next entry or pointer to next restab
  494.         beq.s   nentry
  495.         bclr.l  #$1f,d0 ;clear highbit
  496.         move.l  d0,a3   ;lets' check next residenttable structure
  497.         bra.s   nentry
  498.  
  499. finito  lea.l   fail(pc),a2     ;if we run here there was a fatal error
  500.         jsr     _lvopermit(a6)
  501.         bra     noopen
  502.  
  503. bpicf2  cmp.l   550(a6),a3      ;is our actual restab the same as in kicktagptr?
  504.         bne.s   linkout         ;if not we have a predecessor (held in a4)
  505.         move.l  4(a3),d0        ;move our sucessor (or zero) to kicktagptr
  506.         bclr.l  #$1f,d0         ;clear highbit
  507.         move.l  d0,550(a6)
  508.         bra.s   ready
  509. linkout move.l  4(a3),4(a4)     ;put our successor (or zero) to our predecessor
  510. ready
  511.         jsr     -612(a6)        ;calc checksum (kicksumdata)
  512.         move.l  d0,554(a6)
  513.  
  514.         move.l  $2a(a6),d0
  515.         beq.s   56$
  516.         move.l  d0,a0
  517.         cmp.l   #'Acki',-4(a0)
  518.         bne.s   56$
  519.         clr.l   $2a(a6)
  520. 56$     moveq.l #0,d0
  521.         lea     34(a6),a0
  522.         move.w  #22,d1
  523. chkloop2
  524.         add.w   (a0)+,d0
  525.         dbf     d1,chkloop2
  526.         not.w   d0
  527.         move.w  d0,82(a6)
  528.  
  529.  
  530.  
  531.         jsr     _lvopermit(a6)
  532.         lea     remt(pc),a2     ;print out that we removed it
  533.         bsr     stringout
  534.         sub.l   a2,a2
  535.         tst.b   remptr          ;check for -e: was that all we should do?
  536.         bne     noopen          ;yes->return, no-> let's try to load the picture
  537. notinstalled
  538.         lea     nrem(pc),a2
  539.         tst.b   remptr          ;test if user typed -e;but BPic was not there
  540.         bne     noopen          ;return and let's tell him if so
  541.  
  542.  
  543.         move.l  dosbase(pc),a6
  544.         move.l  fname(pc),d1
  545.         move.l  #1005,d2
  546.         jsr     _lvoopen(a6)    ;try to open file
  547.         lea     fnf(pc),a2
  548.         move.l  d0,handle
  549.         beq     noopen          ;if error let's tell the user
  550.  
  551.         move.l  4.w,a6
  552.         move.l  #4000,d0
  553.         move.l  #$10003,d1      ;chip+clear
  554.         jsr     _lvoallocmem(a6);get memory for readbuffer of file
  555.         lea     nomem(pc),a2
  556.         move.l  d0,buffer
  557.         beq     nobufmem
  558.         move.l  #allmeml,d0
  559.         move.l  #$10003,d1      ;memf_public+clear+ CHIP !!!! 18|12|91
  560.         jsr     _lvoallocmem(a6);get memory for our special structure
  561.         move.l  d0,a5           ;from now on this pointer is to be found in a5
  562.         beq     nostruktmem
  563.  
  564.         move.l  dosbase(pc),a6
  565.         move.l  handle(pc),d1
  566.         move.l  buffer(pc),d2
  567.         moveq.l #12,d3
  568.         jsr     _lvoread(a6)    ;read header of file
  569.         move.l  buffer(pc),a4   ;buffer to address-register so that we can use
  570.         lea     nilbm(pc),a2    ;offsets
  571.         cmp.l   #'FORM',(a4)
  572.         bne     noiff           ;no IFF->error
  573.         cmp.l   #'ILBM',8(a4)
  574.         bne     noiff           ;not ILBM->error
  575. getchunk
  576.         move.l  handle(pc),d1
  577.         moveq.l #8,d3
  578.         jsr     _lvoread(a6)    ;read header of chunk
  579.         lea     bnf(pc),a2      ;4 Bytes code word + 4 Bytes length
  580.         tst.l   d0              ;end of file ? but we didn't find BODY
  581.         beq     noiff           ;->error
  582.         cmp.l   #'BODY',(a4)
  583.         beq     bodyfound
  584.         cmp.l   #'CMAP',(a4)
  585.         beq     cmapfound
  586.         cmp.l   #'CAMG',(a4)
  587.         beq     camgfound
  588.         cmp.l   #'CRNG',(a4)
  589.         beq     crngfound
  590.         cmp.l   #'BMHD',(a4)
  591.         beq     bmhdfound
  592.         bsr     rcdata         ;if we get here it wasn't any chunk we need
  593.         bra.s   getchunk
  594. bodyfound
  595.  
  596.         move.l  4.w,a6
  597.         move.l  4(a4),d0
  598.         addq.l  #7,d0
  599.         addq.l  #3,d0
  600.         move.l  d0,ml_len2(a5)
  601.         addq.l  #7,d0           ;allocmem rounds down by 8 bytes ;vorher 8
  602.         move.l  #$10003,d1
  603.         jsr     _lvoallocmem(a6);memory for BODY-chunk
  604.         lea     nmfb(pc),a2
  605.         move.l  d0,memptr
  606.         beq     noiff
  607.         move.l  d0,d2
  608.         move.l  dosbase(pc),a6
  609.         bsr     rcdata          ;read BODY in
  610.         move.l  4.w,a6
  611. nofast  move.l  memptr(pc),a3
  612. memfreed
  613.         move.l  a3,ml_addr2(a5)
  614.         tst.b   camgf           ;did we find CAMG ?
  615.         bne.s   noham
  616.         lea     ncamg(pc),a2    ;let's tell the user that we improvise
  617.         bsr     stringout
  618.         sub.l   a2,a2
  619.         cmp.w   #353,vp_dwidth(a5)      ;wider than 352 bytes?
  620.         blt.s   nohires                 ;it must be hires
  621.         add.w   #$8000,vp_modes(a5)
  622. nohires
  623.         cmp.w   #283,vp_dheight(a5)     ;...
  624.         blt.s   nolace
  625.         add.w   #$4,vp_modes(a5)
  626. nolace
  627.         cmp.w   #6,depth(a5)        ;HAM and Halfbright work with 6 planes
  628.         bne.s   noham
  629.         add.w   #$800,vp_modes(a5)  ;I say it's HAM !!!
  630. noham
  631.         move.l  a5,strktptr         ;put the pointer to our structure into the
  632.         lea     suc(pc),a2          ;resident code (will be copied later on! )
  633.         move.l  gfxbase(pc),a6
  634.         lea     view(a5),a1         ;init all we need to show the picture
  635.         jsr     _lvoinitview(a6)
  636. ; wichtig: um später verändern zu können : für neue modi !!!
  637.         nop
  638.         and.w   #$ffff,vp_modes(a5)
  639.         nop
  640.  
  641.         move.w  vp_modes(a5),v_modes(a5)
  642.         elea    viewport(a5),v_viewport(a5)
  643.         lea     bitmap(a5),a0
  644.         move.w  depth(a5),d0
  645.         move.w  bmw(a5),d1
  646.         move.w  bmh(a5),d2
  647.         jsr     _lvoinitbitmap(a6)
  648.         lea.l   rasinfo(a5),a0
  649.         elea    bitmap(a5),ri_bitmap(a5)
  650.         elea     rasinfo(a5),vp_rasinfo(a5)
  651.         move.w  vp_modes(a5),d0    ;if overscan move the picture to top left
  652.         move.w  #320,d1            ;corner
  653.         btst.l  #$f,d0
  654.         beq.s   nohires2
  655.         lsl.w   #1,d1
  656. nohires2
  657.         neg.w   d1
  658.         add.w   vp_dwidth(a5),d1
  659.         bpl.s   doit1
  660.         clr.w   d1
  661. doit1   lsr.w   #1,d1
  662.         sub.w   d1,v_dxoffset(a5)
  663.         move.w  #256,d1
  664.         btst.l  #$2,d0
  665.         beq.s   nolace2
  666.         lsl.w   #1,d1
  667. nolace2 neg.w   d1
  668.         add.w   vp_dheight(a5),d1
  669.         bpl.s   doit
  670.         clr.w   d1
  671. doit    lsr.w   #1,d1
  672.         sub.w   d1,v_dyoffset(a5)
  673.  
  674.  
  675.         move.l  modulename(pc),a0
  676.         move.l  a0,d0
  677.         beq.s   1$
  678.         bsr     _loadmodule
  679.         tst.l   d0
  680.         beq.s   11$
  681.         move.l  d7,modlength
  682.         move.l  d0,modulestart
  683.  
  684.  
  685.         move.l  playerlength(pc),ml_len3(a5)
  686.         sub.l   #10,ml_len3(a5)
  687.         clr.l   playerstart-8
  688.         move.l  #playerstart,ml_addr3(a5)
  689.  
  690.  
  691.  
  692.         move.l  modulestart(pc),ml_addr4(a5)
  693.         move.l  modlength(pc),ml_len4(a5)
  694.         bra.s   2$
  695. 11$     lea     nomod(pc),a2
  696.         bsr     stringout
  697.         sub.l   a2,a2
  698. 1$      clr.l   modlength
  699. 2$      lea     idendity(a5),a0         ;copy code into allocated memory
  700.         lea     begincopy(pc),a1
  701.         move.w  #endcopy-begincopy-1,d0
  702. idlop   move.b  (a1)+,(a0)+
  703.         dbf     d0,idlop
  704.         clr.l   modulename
  705.         clr.l   modlength
  706.         clr.l   modulestart
  707.         clr.w   packflag
  708.         move.l  a5,ml_addr1(a5)        ;intialize resident structure
  709.         move.l  #allmeml-20,ml_len1(a5)   ; vorher 20
  710. fillout move.w  #rtc_matchword,rt_matchword(a5)
  711.         elea    rt_matchword(a5),rt_matchtag(a5)
  712.         elea    rt_SIZE(a5),rt_endskip(a5)
  713.         move.b  #1,rt_flags(a5)
  714.         move.b  #-1,rt_pri(a5)
  715.         elea    id_name(a5),rt_name(a5)
  716.         elea    id_string(a5),rt_idstring(a5)
  717.         elea    code(a5),rt_init(a5)
  718.  
  719.         move.w  #2,ml_numentries(a5)  ;init memlist structure
  720.         tst.l   ml_addr4(a5)
  721.         beq.s   1$
  722.         add.w   #2,ml_numentries(a5)
  723. 1$      elea    id_name(a5),myln_name(a5)
  724.         move.b  #nt_memory,myln_type(a5)
  725.  
  726. login
  727.         getexe
  728.       cmp.w   #34,$14(a6)   ;    Test auf Kick 1.3
  729.       bne.s   wert5
  730.       move.l  $3e(a6),d0
  731.       cmp.l   #$80000,d0
  732.       bhi.s   2$
  733.  
  734.       bra.s   wert5
  735. 2$
  736.         lea     coldcapoff(a5),a0
  737.         move.l  a0,$2a(a6)         ; coldcapvector
  738.  
  739.         moveq.l #0,d0
  740.         lea     34(a6),a0
  741.         move.w  #22,d1
  742. chkloop1
  743.         add.w   (a0)+,d0
  744.         dbf     d1,chkloop1
  745.         not.w   d0
  746.         move.w  d0,82(a6)
  747.  
  748. wert5
  749.         jsr     _lvoforbid(a6)      ;let's write ourselves into sysbase
  750.         move.l  546(a6),a1          ;kickmemptr
  751.         tst.l   546(a6)
  752.         beq.s   nixda               ;we always use first place and put
  753.         move.l  a1,myln_succ(a5)      ;any things that were before us behind us
  754.         elea    myln_succ(a5),4(a1)   ;[predecessor]
  755.  
  756. nixda   elea    myln_succ(a5),546(a6) ;and now for kicktagptr
  757.         move.l  a5,restab(a5)
  758.         move.l  550(a6),d0
  759.         beq.s   nomtag
  760.         bset    #$1f,d0
  761.         move.l  d0,restab+4(a5)
  762.  
  763. nomtag  elea    restab(a5),550(a6)
  764.         jsr     -612(a6)            ;kicksumdata
  765.         move.l  d0,554(a6)          ;fill in kickchecksum
  766.         jsr     _lvopermit(a6)
  767.  
  768.         tst.b   resetvar            ;does the user want to reset the machine?
  769.         beq.s   nostruktmem
  770.         lea     cod(pc),a5
  771.         lea     2,a4
  772.         jsr     _lvosupervisor(a6) ;that's all ...
  773.         cnop    0,4
  774. cod     reset
  775.         jmp     (a4)
  776. noiff                               ;here we run if there's an error while
  777.         move.l  4.w,a6              ;loading
  778.         move.l  a5,a1
  779.         move.l  #allmeml,d0
  780.         jsr     _lvofreemem(a6)
  781. nostruktmem                         ;not enough memory for our structure
  782.         move.l  4.w,a6
  783.         move.l  buffer(pc),a1
  784.         move.l  #4000,d0
  785.         jsr     _lvofreemem(a6)
  786. nobufmem                            ;not enough mem for diskbuffer
  787.         move.l  dosbase(pc),a6
  788.         move.l  handle(pc),d1
  789.         jsr     _lvoclose(a6)
  790. noopen  ;move.l  dosbase(pc),a6
  791.         move.l  a2,d2
  792.         beq.s   noerr
  793.         bsr     stringout
  794. noerr   clr.l   remptr
  795.         clr.b   camgf
  796.         move.b  #1,mparm
  797.         movem.l (sp)+,d0-1/d3-7/a0-1/a3-6
  798.         rts
  799. ;!!!2.0!!!
  800. modulename  dc.l    0
  801.  
  802. ;       Function: d0 = _LoadModule(a0)
  803. ;       a0 = module name
  804. ;       d0 = pointer to loaded module, zero if load failed
  805.  
  806. ;        xdef    _LoadModule
  807. ;        xdef    _UnLoadModule
  808. ;        code
  809. ;  d7= länge !!!!!!!
  810.  
  811. _LoadModule:
  812.         movem.l a2-a4/a6/d2-d6,-(sp)
  813.         moveq   #0,d6                   ;d6 = return value (zero = error)
  814.         move.l  a0,a4                   ;a4 = module name
  815.         movea.l 4,a6
  816.         lea     dosname(pc),a1
  817.         jsr     -$198(a6)       ;OldOpenLibrary()
  818.         tst.l   d0
  819.         beq     xlm1
  820.         move.l  d0,a3                   ;a3 = DOSBase
  821.         move.l  d0,a6
  822.         move.l  a4,d1                   ;name = d1
  823.         move.l  #1005,d2                ;accessmode = MODE_OLDFILE
  824.         jsr     -$1e(a6)                ;Open()
  825.         move.l  d0,d4                   ;d4 = file handle
  826.         beq     xlm2
  827.         move.l  d4,d1
  828.         moveq   #0,d2
  829.         moveq   #1,d3                   ;OFFSET_END
  830.         jsr     -$42(a6)                ;Seek(fh,0,OFFSET_END)
  831.         move.l  d4,d1
  832.         moveq   #0,d3
  833.         not.l   d3                      ;OFFSET_BEGINNING
  834.         jsr     -$42(a6)                ;Seek(fh,0,OFFSET_BEGINNING)
  835.         move.l  d0,d5                   ;d5 = file size
  836.         move.l  d0,d7
  837.         movea.l 4,a6
  838.         moveq   #2,d1                   ;get chip mem
  839.         jsr     -$c6(a6)                ;AllocMem()
  840.         tst.l   d0
  841.         beq.s   xlm3
  842.         move.l  d0,a2                   ;a2 = pointer to module
  843.         move.l  d4,d1   ;file
  844.         move.l  d0,d2   ;buffer
  845.         move.l  d5,d3   ;length
  846.         move.l  a3,a6
  847.         jsr     -$2a(a6)                ;Read()
  848.         cmp.l   d5,d0
  849.         bne.s   xlm4                    ;something wrong...
  850.  
  851.         cmp.l   #'PP11',(a2)
  852.         beq.s   lm_packed
  853.         cmp.l   #'PP20',(a2)
  854.         beq.s   lm_packed
  855.         cmp.l   #'MMD0',(a2)
  856.         bne.s   xlm4                    ;this is not a module!!!
  857.  
  858.         movea.l a2,a0
  859.         ;opt    o-
  860.         jsr     _RelocModule
  861.         ;opt    o+
  862.         move.l  a2,d6           ;no error...
  863.         bra.s   xlm3
  864. xlm4:   move.l  a2,a1           ;error: free the memory
  865.         move.l  d5,d0
  866.         movea.l 4,a6
  867.         jsr     -$d2(a6)        ;FreeMem()
  868. xlm3:   move.l  a3,a6           ;close the file
  869.         move.l  d4,d1
  870.         jsr     -$24(a6)                ;Close(fhandle)
  871. xlm2:   move.l  a3,a1           ;close dos.library
  872.         movea.l 4,a6
  873.         jsr     -$19e(a6)
  874. xlm1:   move.l  d6,d0                   ;push return value
  875.         movem.l (sp)+,a2-a4/a6/d2-d6    ;restore registers
  876.         rts                             ;and exit...
  877.  
  878. lm_packed
  879.         move.w  #1,packflag
  880.         move.l  a2,d6
  881.         bra.s   xlm3
  882.  
  883.  
  884. **//** SUBs + chunk-reading routines
  885.  
  886. * print out a zero-termintated string of which the start is found in a2
  887. stringout
  888.         move.l  a6,-(a7)
  889.         tst.l   rastport
  890.         beq.s   1$
  891.             getgfx
  892.     moveq.w #1,d0
  893.     move.l  rastport(pc),a1
  894.     jsr     _lvosetapen(a6)
  895.     move.l  rastport(pc),a1
  896.     moveq.w #67,d0
  897.     move.w  #144,d1
  898.     move.w  #445,d2
  899.     move.w  #160,d3
  900.     jsr     _lvorectfill(a6)
  901.  
  902.  
  903.         move.w  #72,d2
  904.         move.w  #154,d3
  905.         move.l  a2,a0
  906. 6$      tst.b   (a0)+
  907.         bne.s   6$
  908.         cmp.b   #10,-2(a0)
  909.         bne.s   5$
  910.         clr.b  -2(a0)
  911. 5$      bsr     schatten
  912.         bra     sende
  913. 1$
  914.  
  915.         move.l  a2,d2
  916.         move.l  #-1,d3
  917. p1      addq.l  #1,d3
  918.         tst.b   (a2)+
  919.         bne.s   p1
  920.         move.l  whandle(pc),d1
  921.         move.l  dosbase(pc),a6
  922.         jsr     _lvowrite(a6)
  923. sende
  924.         move.l  (sp)+,a6
  925.         rts
  926.  
  927. * read in one chunk
  928. rcdata
  929.         move.l  4(a4),d3
  930.         move.l  handle,d1
  931.         jsr     _lvoread(a6)
  932.         rts
  933.  
  934. * get colormap [format see at getcols ! ]
  935. cmapfound
  936.         move.l  4(a4),d4
  937.         cmp.l   #100,d4
  938.         blt.s   1$
  939.         move.l  #3*32,d4
  940. 1$      move.l  buffer(pc),d2
  941. ;        elea    coltab(a5),d2
  942.         bsr     rcdata
  943. ;        move.l  buffer(pc),d2
  944.         move.l  d2,a1
  945.         lea     coltab(a5),a0
  946. gcol    move.b  (a1)+,d0
  947.         lsr.b   #4,d0
  948.         and.b   #%1111,d0
  949.         move.b  d0,(a0)+
  950.         dbf     d4,gcol
  951.         bra getchunk
  952.  
  953. crngfound
  954.         bsr     rcdata
  955.         btst    #0,5(a4)
  956.         beq.s   2$
  957.         tst.w   2(a4)
  958.         beq.s   2$
  959.         lea     crngs(pc),a0
  960.         subq.l  #8,a0
  961.         moveq.l #0,d0
  962. 1$      addq.l  #8,a0
  963.         addq.l  #1,d0
  964.         cmp.b   #7,d0
  965.         beq.s   2$
  966.         tst.b   crng_flag(a0)
  967.         bne.s   1$
  968.         move.w  4(a4),crng_flag(a0)
  969.         move.b  #$ff,crng_flag(a0)
  970.         move.w  6(a4),crng_start(a0)
  971.  
  972.         moveq.l #0,d0
  973.         move.w  #$ffff,d0
  974.         divu.w  2(a4),d0
  975.         and.l   #$ffff,d0
  976.         divu.w  #5,d0
  977.         addq.w  #1,d0
  978.         move.w  d0,crng_ticks(a0)
  979.         swap    d0
  980.         cmp.w   #2,d0
  981.         bls.s   2$
  982.         add.w   #1,crng_ticks(a0)
  983. 2$      bra     getchunk
  984. * here are the viewmodes
  985. camgfound
  986.  
  987.         bsr     rcdata
  988.         move.w  modes+2(a4),vp_modes(a5)    ;get the viewmodes
  989.         move.b  #1,camgf
  990.         bra     getchunk
  991. * get the dimensions of the picture
  992. bmhdfound
  993.         bsr     rcdata
  994.         move.l  w(a4),bmw(a5)   ;w+h are .w so .l is enough for both
  995.         move.b  nplanes(a4),depth+1(a5)
  996.         move.b  masking(a4),mask(a5)
  997.         lea ncomp(pc),a2
  998.         tst.b   compression(a4);we won't load compressed pictures
  999.         beq noiff
  1000.         move.w  bmw(a5),vp_dwidth(a5)
  1001.         move.w  bmh(a5),vp_dheight(a5)
  1002.         bra     getchunk
  1003. **//**
  1004.  
  1005. wbenchmsg   dc.l    0       ;contains msg if run from WB
  1006. ;conbuf      dc.l    0       ;readbuffer for CON:-window
  1007. remptr      dc.b    0       ;set if -e was specified
  1008. resetvar    dc.b    0       ;set if -r was specified
  1009. mparm       dc.b    0       ;set if either -e or -l was specified
  1010. startup     dc.b    0       ;set if -s was specified
  1011. camgf       dc.b    0       ;set if CAMG was found
  1012.             dc.b    0       ;make even
  1013. memptr      dc.l    0       ;ptr to BODY-chunk
  1014. buffer      dc.l    0       ;ptr to readbuffer
  1015. handle      dc.l    0       ;handle of IFF-file
  1016. dosbase     dc.l    0       ;...
  1017. whandle     dc.l    0       ;handle we write to (CLI or CON:)
  1018. fname       dc.l    0       ;pointer to filename
  1019. playerlength    dc.l    0
  1020. dosname     dc.b    'dos.library',0
  1021.             even
  1022.                 intstuff
  1023. welcome     dc.b    10,27,'[1;32m',' BootPic V2.1b ',27,'[0;31m','©1992 by '
  1024.             dc.b    27,'[3;33m','Andreas Ackermann',27,'[0;31m',10
  1025.             dc.b    ' This programm is SHAREWARE. If you use it, please send '
  1026.             dc.b    27,'[1;32m','5$ or 5DM',27,'[0;31m to:',10
  1027.             dc.b    '    Andreas Ackermann',10
  1028.             dc.b    '    Lorenz-Summa-Str. 10',10
  1029.             dc.b    '    W-8679 Oberkotzau',10
  1030.             dc.b    '    GERMANY',10
  1031.             dc.b    ' See Doc-File for detailed information !',10,10,0
  1032.             even
  1033. nomod       dc.b    "Couldn't open Module / Not a MED-Module.",0
  1034.             even
  1035. nmfb        dc.b    'Not enough Memory for BODY-Chunk.',10,0
  1036.             even
  1037. bnf         dc.b    'BODY-Chunk not found.',10,0
  1038.             even
  1039. ncamg       dc.b    'Warning:CAMG-Chunk not found.',10,0
  1040.             even
  1041. nilbm       dc.b    "It's not an ILBM-File Didn't load music either.",10,0
  1042.             even
  1043. nomem       dc.b    "Couldn't get enough Memory.",10,0
  1044.             even
  1045. fnf         dc.b    "Couldn't open Picturefile.",10,0
  1046.             even
  1047. use         dc.b    "Usage: BootPic -e | -l{ILBM-filename} [-c rgb][-r][-s][-y][-k]",10
  1048.             dc.b    "               [-m {MED-Module}][-d time]",10
  1049.             dc.b    "Without parms: An Intuition-style window will open.",10,0
  1050.             even
  1051. remt        dc.b    "Removed old BootPicture (& MED-Mod.) from list.",10,0
  1052.             even
  1053. ncomp       dc.b    'Picture is not compressed. Save it with DPaint and try again.',10,0
  1054.             even
  1055. suc         dc.b    'BootPic successfully installed. Have fun !',10,0
  1056.             even
  1057. fail        dc.b    'Memlist Corrupt. Something went totally wrong !',10,0
  1058.             even
  1059. stext       dc.b    'BootPic already installed. Changed nothing.',10,0
  1060.             even
  1061. nrem        dc.b    "BootPic was not installed. Couldn't remove it.",10,0
  1062.             even
  1063.  
  1064. * Part of Programm that shows picture after reset
  1065.  
  1066. begincopy
  1067.  
  1068. idname      dc.b    'BPic',0,0
  1069. idstring    dc.b    'BootPic,©1991 by Acki',0
  1070.             dc.b    0,0,0,0,0,0,0,0
  1071.  
  1072.         movem.l d0-7/a0-6,-(sp)
  1073.         lea     delaycurrent(pc),a0
  1074.         clr.w   (a0)
  1075.         move.l  4.w,a6
  1076.  
  1077.         move.l  strktptr(pc),a5             ;get ptr of our special structure
  1078.         move.l  ml_addr2(a5),a3             ;get ptr of BODY-data
  1079.         lea     gfxname(pc),a1
  1080.         jsr     _lvooldopenlibrary(a6)
  1081.         emove   d0,gfxbase(pc)
  1082.  
  1083. tdd_len equ 200
  1084.  
  1085.         moveq.l #0,d7
  1086.         lea     iorequests(pc),a2
  1087. open_device
  1088.         move.l  #tdd_len,d0
  1089.         move.l  d7,d2
  1090.  
  1091.         moveq.l #0,d1
  1092.         lea     trddevice(pc),a0
  1093.         bsr     open_a_device
  1094.         tst.l   d0
  1095.         beq.s   device_error
  1096.         addq.l  #1,d7
  1097.         move.l  d0,(a2)+
  1098.         lea     kickflag(pc),a0
  1099.         tst.w   (a0)
  1100.         beq.s   device_error
  1101.         cmp.l   #4,d7
  1102.         bne.s   open_device
  1103.  
  1104.  
  1105. device_error
  1106.         tst.l   d7
  1107.         beq     device_fail
  1108.  
  1109.         m_alloc #chip+clear+public,#1040
  1110.         emove   d0,readbuf(pc)
  1111.         moveq.l #0,d5                  ; wichtig !!! darf nicht veändert werden
  1112.         moveq.b #0,d2
  1113.         bsr     readboot                    ;check for bootable disk in df0:
  1114.         tst.b   d3                          ;[see at readboot what d2 means !]
  1115.         beq     cleanup
  1116.  
  1117.         move.l  modulestart(pc),d0
  1118.         beq.s   showpic
  1119.         ;opt    o-
  1120.         jsr     _initplayer
  1121.         ;opt    o+
  1122.         lea     packflag(pc),a0
  1123.         tst.w   (a0)
  1124.         bne.s   showpic
  1125.         move.l  modulestart(pc),a0
  1126.         jsr     _playmodule
  1127. showpic move.l  gfxbase(pc),a6      ;clear all pointers to copperlists
  1128.         clr.l   view+4(a5)          ;so that mrgcop knows that it has to take
  1129.         clr.l   view+8(a5)          ;new copperlists !
  1130.         moveq.w #4,d0
  1131.         lea     vp_colormap(a5),a0
  1132. cll     clr.l   (a0)+
  1133.         dbf     d0,cll
  1134.  
  1135.         move.w  depth(a5),d2        ;allocate planes; if masking then alloc one
  1136.         lea     bm_planes(a5),a2    ;more plane that isn't to be found in
  1137.         cmp.b   #1,mask(a5)         ;bm_depth
  1138.         bne.s   nomsk                   ; vorher beq.s
  1139.         subq.w  #1,d2
  1140. nomsk   move.w  bmw(a5),d0
  1141.         move.w  bmh(a5),d1
  1142.         jsr     _lvoallocraster(a6)
  1143.         move.l  d0,(a2)+
  1144.         beq     rasterfail
  1145.         dbf     d2,nomsk
  1146.         clr.l   (a2)                ;zero-terminate bm_planes cause we'll free
  1147.         bsr     unpackbody          ;memory till we find zero
  1148.  
  1149.         move.l  #32,d0              ;32 is always enough
  1150.         jsr     _lvogetcolormap(a6)
  1151.         move.l  d0,vp_colormap(a5)
  1152.         move.l  d0,a0
  1153.  
  1154.         lea     view(a5),a0
  1155.         lea     viewport(a5),a1
  1156.         jsr     _lvomakevport(a6)
  1157.         lea     view(a5),a1
  1158.         jsr     _lvomrgcop(a6)      ;generate display
  1159.         move.l  34(a6),d7
  1160.  
  1161.         lea     view(a5),a1
  1162.         jsr     _lvoloadview(a6)    ;let's show it
  1163.  
  1164.         lea     coltab(a5),a2
  1165.         lea     viewport(a5),a3
  1166.         lea     white(pc),a4
  1167.         moveq.w #0,d0
  1168.         bsr     fadein              ;fade picture in
  1169.  
  1170.         lea     packflag(pc),a0
  1171.         tst.w   (a0)
  1172.         beq.s   14$
  1173.         move.l  modulestart(pc),a0
  1174.         move.l  modlength(pc),d0
  1175.         jsr     _med_startup
  1176. 14$
  1177.  
  1178.  
  1179.  
  1180.         lea     vv_viewport(pc),a0
  1181.         lea     viewport(a5),a1
  1182.         move.l  a1,(a0)
  1183.         bsr     getpalette
  1184.  
  1185.         move.l  4.w,a6
  1186.         move.b  #1,d2
  1187.         bsr     readboot            ;wait for bootable disk
  1188.  
  1189. ; a1 enthält noch die aktuelle iorequest
  1190.  
  1191.         bsr     freepalette
  1192.         move.l  gfxbase(pc),a6
  1193.         lea     konst(pc),a4
  1194.         moveq.w #0,d0
  1195.         bsr     fadeout             ;fade to color specified under -c
  1196.  
  1197.  
  1198.         move.l  modulestart(pc),d0
  1199.         beq.s   110$
  1200.         jsr _stopplayer
  1201.         jsr _remplayer
  1202.         jsr _med_cleanup
  1203. 110$
  1204.         bclr    #1,$bfe001
  1205.         move.l  vp_colormap(a5),a0  ;free copperlists
  1206.         jsr     _lvofreecolormap(a6)
  1207.         lea.l   viewport(a5),a0
  1208.         jsr     _lvofreevportcoplists(a6)
  1209.         move.l   view+4(a5),a0
  1210.         jsr     _lvofreecprlist(a6)
  1211.         move.l  view+8(a5),a0
  1212.         jsr     _lvofreecprlist(a6)
  1213.  
  1214.         clr.l   34(a6)
  1215. rasterfail
  1216.         lea     bm_planes(a5),a2
  1217. nomsk2  move.l  (a2)+,a0
  1218.         tst.l   -4(a2)
  1219.         beq.s   meme
  1220.         move.w  bmw(a5),d0
  1221.         move.w  bmh(a5),d1
  1222.         jsr     _lvofreeraster(a6)
  1223.         bra.s   nomsk2              ;free planes till we find zero
  1224. meme
  1225.  
  1226. cleanup move.l  4.w,a6              ;clean up everything we needed to wait for
  1227.         lea     iorequests(pc),a2
  1228. close_devs
  1229.         move.l  (a2),d0
  1230.         beq.s   no_more_devs
  1231.         move.l  d0,a1
  1232.         clr.l   (a2)+
  1233.         move.l  #tdd_len,d0
  1234.         bsr     close_a_device
  1235.         bra.s   close_devs
  1236.  
  1237. no_more_devs
  1238.         m_free  readbuf(pc),#1040
  1239.  
  1240. device_fail
  1241.         getexe
  1242.         move.l  gfxbase(pc),a1
  1243.         jsr     _lvocloselibrary(a6)
  1244.  
  1245.         movem.l (sp)+,d0-7/a0-6
  1246.         rts
  1247.  
  1248. activatebootsel
  1249.         lea     kickflag(pc),a0  ; check only df0: ?
  1250.         tst.w   (a0)
  1251.         beq.s   570$
  1252.  
  1253.         cmp.w   #35,20(a6)     ; welche Kickstart, bitteschön ?
  1254.         bhi.s   570$           ; scho 2.0 ?! Dann braung' ma kan 'Buutselekta' !!
  1255.         moveq.l #$ff,d2        ; für nicht-franken: brauchen wir keinen Bootselektor
  1256.         lea     iorequests(pc),a0
  1257. 560$    addq.l  #1,d2
  1258.         cmp.l   (a0)+,a1
  1259.         bne.s   560$           ; how many drives are there ?
  1260.         tst.w   d2
  1261.         beq.s   570$           ; only 1: nobootselector
  1262.  
  1263.         lea     drvnum(pc),a0
  1264.         move.w  d2,(a0)
  1265.         move.l  4.w,a6
  1266.         move.l  #bs_end-bs_start+10,d0
  1267.         move.l  #PUBLIC+CLEAR,d1
  1268.         jsr     _lvoallocmem(a6)
  1269.         move.l  d0,a1
  1270.         move.l  d0,a2
  1271.         lea     func(pc),a0
  1272.         move.w  #bs_end-bs_start,d1
  1273. 40$     move.b  (a0)+,(a1)+
  1274.         dbf d1,40$
  1275.         move.l  4.w,a1
  1276.         move.l  #_lvoopendevice,a0
  1277.         call    setfunction
  1278.         move.l  d0,vec-func+2(a2)
  1279. 570$    rts
  1280.  
  1281. bs_start
  1282. func    movem.l  a0/a1,-(sp)
  1283.         lea     trddevice(pc),a1
  1284. 10$     tst.b   (a1)
  1285.         beq.s   doit5
  1286.         cmpm.b  (a0)+,(a1)+
  1287.         beq.s   10$
  1288. endit
  1289.         movem.l (sp)+,a0/a1
  1290. vec     jmp     $0
  1291.  
  1292. doit5
  1293.         lea     drvnum(pc),a0
  1294.         tst.w   d0
  1295.         beq.s   30$
  1296.         cmp.w   (a0),d0
  1297.         bne.s   31$
  1298.         moveq.l #0,d0
  1299.         bra.s   31$
  1300. 30$     move.w  (a0),d0
  1301. 31$     bra.s   endit
  1302.  
  1303.  
  1304. drvnum  dc.w    0
  1305. trddevice       dc.b    'trackdisk.device',0
  1306.                 even
  1307. ; Wichtig: muß hier stehen, da dieser Bereich kopiert wird !!!
  1308. bs_end
  1309. * This routines checks for a bootable disk in df0: .
  1310. * Result in d3.b : zero if a disk is there, 1 if no bootable disk in drive.
  1311. * Flags: if d2.b=1 it will wait until a bootable disk is inserted
  1312.  
  1313. * d0=länge des Speicherblocks                                   *
  1314. * d1=devicflags                                                 *
  1315. * d2=deviceunit                                                 *
  1316. * a0=devicenmae                                                 *
  1317. * d0=0 => error   else d0=pointer to iorequest                  *
  1318.  
  1319. * a1=iorequest                                                  *
  1320. * d0=länge des Speicherblocks                                   *
  1321. rmbcnt  dc.w    0
  1322. readboot
  1323.         getexe
  1324. next_lw_loop
  1325.  
  1326.         lea     iorequests(pc),a2
  1327.         moveq.l #$ff,d6
  1328. next_lw
  1329.         lea     rmbcnt(pc),a0
  1330.         btst.b  #10,$dff016
  1331.         bne.s   20$
  1332.         tst.w   (a0)
  1333.         bne.s   21$
  1334.         move.w  #1,(a0)
  1335.         bchg    #1,$bfe001
  1336.         bra.s   21$
  1337. 20$     clr.w   (a0)
  1338. 21$
  1339.  
  1340.         addq.l  #1,d6
  1341.         move.l  (a2)+,d0
  1342.         beq     leave_no_lw
  1343.         move.l  d0,a1
  1344.         move.w  #$e,io_command(a1)
  1345.         jsr     _lvodoio(a6)    ;check for disk in df0:
  1346.         tst.l   32(a1)          ; 0 wenn disk da
  1347.         beq.s   1$
  1348.         bclr    d6,d5           ; keine disk-> also auch kiene unbootfähige
  1349.         bra.s   next_lw
  1350. 1$      btst    d6,d5           ; unbootfähig ? next_lw
  1351.         bne.s   next_lw
  1352.         bsr     test_boot
  1353.         tst.l   d0
  1354.         beq.s   leave_ok
  1355.         bset    d6,d5
  1356.         bra.s   next_lw
  1357.  
  1358. leave_no_lw
  1359.         tst.b   d2
  1360.         beq.s   leave_error
  1361.         btst    #6,$bfe001
  1362.         beq.s   leave_ok_nodisk
  1363.         movem.l a0-1/d0-1,-(sp)
  1364.         getgfx
  1365.         call    waittof
  1366.         lea     delaycurrent(pc),a0
  1367.         add.w   #1,(a0)
  1368.         move.w   delaytime(pc),d0
  1369.         getexe
  1370.         cmp.w   (a0),d0
  1371.         beq.s   leave_okdelay
  1372.  
  1373.         movem.l  (sp)+,a0-1/d0-1
  1374.         bra   next_lw_loop
  1375.  
  1376. leave_error
  1377.         moveq.b #1,d3
  1378.         rts
  1379. leave_okdelay
  1380.         movem.l  (sp)+,a0-1/d0-1
  1381.         bra.s   leave_ok_nodisk
  1382. leave_ok
  1383.         bsr     activatebootsel
  1384. leave_ok_nodisk
  1385.         moveq.b #0,d3
  1386.         rts
  1387.  
  1388. * result : d0= 0 if disk is bootable
  1389. test_boot
  1390.         move.w  #$5,io_command(a1)      ;declare the buffer to be invalid
  1391.         jsr     _lvodoio(a6)
  1392.         move.l  #2*512,io_length(a1)
  1393.         move.w  #$2,io_command(a1)       ;read bootblock
  1394.         move.l  readbuf(pc),io_data(a1)
  1395.         jsr     _lvodoio(a6)
  1396.         tst.l   d0                      ;any errors ?
  1397.         bne.s   tb_error                     ;if then goto waitfordisk
  1398. tb_calcsum
  1399.         cmp.w   #35,20(a6)     ; welche Kickstart, bitteschön ?
  1400.         bhi.s   1$
  1401.  
  1402.         move.l  readbuf(pc),a0
  1403.         cmp.l   #$444f5300,(a0)         ;check if DOS,0 [could be FFS,0 as well]
  1404.         bne.s   tb_error                     ; bei 2.0 ist FFS auch gültig !!!!
  1405. 1$      moveq.l #0,d0
  1406.         move.w  #$00ff,d1               ;calculate checksum of bootblock
  1407.         move.l  readbuf(pc),a0
  1408. tb_schleife
  1409.         add.l   (a0)+,d0
  1410.         bcc.s   tb_nof
  1411.         addq.l  #1,d0
  1412. tb_nof  dbf     d1,tb_schleife
  1413.         not.l   d0
  1414.         beq.s   tb_fine                  ;if zero, disk is bootable
  1415. tb_error
  1416.         clr.l   io_length(a1)           ;switch off motor
  1417.         move.w  #$9,io_command(a1)
  1418.         jsr     _lvodoio(a6)            ;[if io_length=0 motor off, if 1 then on]
  1419.         moveq.l #1,d0
  1420.         rts
  1421. tb_fine
  1422.         clr.l   io_length(a1)           ;switch off motor
  1423.         move.w  #$9,io_command(a1)
  1424.         jsr     _lvodoio(a6)            ;[if io_length=0 motor off, if 1 then on]
  1425.         moveq.l #0,d0
  1426.         rts
  1427.  
  1428.  
  1429. strktptr    dc.l    0   ;pointer to our special structure
  1430. gfxbase     dc.l    0   ;...
  1431. gfxname     dc.b    'graphics.library',0
  1432.             even
  1433. konst       dc.b    $0,$5,$a,0      ;here we put the color specified by -c
  1434. white       dc.b    $f,$f,$f,0      ;data for white color.
  1435. iorequests  ds.l    6
  1436. packflag    dc.w    0
  1437. ;            intstuff
  1438.  
  1439.  
  1440.         dc.b    'BPic'
  1441. coldcaproutine
  1442.     getexe
  1443.         move.l  $fc0010,d0
  1444.         cmp.l   $14(A6),d0
  1445.         beq.s   3$
  1446.         jmp     $fc01ce
  1447. 3$
  1448.     move.l  a0,$2a(a6)
  1449.     move.l  $3e(a6),a3
  1450.     move.w  #-1,d0
  1451. 2$  move.w  #$f00,$dff180
  1452.     dbf     d0,2$
  1453.     bchg    #1,$bfe001
  1454.     jmp     $fc01aa
  1455.  
  1456. coldcapoff  equ idendity+(coldcaproutine-begincopy)
  1457.  
  1458. * This routine unpacks the BODY-chunk
  1459. * a3 holds a pointer to the packed BODY-data
  1460. * a2 must contain pointer to bm_planes
  1461. * bm_depth must be put in d4
  1462. * bm_bytesperrow could be put in d2 and bm_height could be put in d3
  1463. * [to include this in your own programms, it has to be slightly modified.]
  1464.  
  1465. unpackbody
  1466.         movem.l d0-7/a0-6,-(sp)
  1467.         moveq.w #0,d5
  1468.         move.w  depth(a5),d4
  1469.         lea.l   bm_planes(a5),a2
  1470.         cmp.b   #1,mask(a5)
  1471.         bne.s   unpackline
  1472.         addq.w  #1,d4
  1473. UnpackLine
  1474.         clr.l d6
  1475. UnpackPlane
  1476.         move.w  bm_bytesperrow(a5),d0
  1477.         mulu    d5,d0
  1478.         move.l  d0,a4
  1479.         asl     #2,d6
  1480.         add.l   0(a2,d6.w),a4
  1481.         asr     #2,d6
  1482.         move.l  a4,a6
  1483.         add.w   bm_bytesperrow(a5),a6
  1484.         clr.l d0
  1485. CheckPacked
  1486.         move.b  (a3)+,d0
  1487.         cmp.b   #128,d0
  1488.         bhi.s   GoOn
  1489.         beq.s   CheckFinished
  1490. FinishLine
  1491.         move.b  (a3)+,(a4)+
  1492.         subq.b  #1,d0
  1493.         bpl.s   FinishLine
  1494.         bra.s   CheckFinished
  1495. GoOn    move.b  (a3)+,d1
  1496. StoreByte
  1497.         move.b  d1,(a4)+
  1498.         addq.b  #1,d0
  1499.         cmp.b   #1,d0
  1500.         bne.s   StoreByte
  1501. CheckFinished
  1502.         cmp.l   a4,a6
  1503.         bhi.s   CheckPacked
  1504.         addq.w  #1,d6
  1505.         cmp.w   d4,d6
  1506.         bne.s   UnpackPlane
  1507. GoOnLoop
  1508.         addq.w    #1,d5
  1509.         cmp.w     bmh(a5),d5
  1510.         bne.s     UnpackLine
  1511.         movem.l (sp)+,d0-7/a0-6
  1512.         rts
  1513.  
  1514. * reads out the colors of a colormap and stores it in a piece of memory [200
  1515. * Bytes required ] in the following form:
  1516. * 1st byte r, 2nd byte g and in 3rd byte b. Then the next color appears.
  1517. * parms: a2=pointer to memory  a3=pointer to Colormap  a6=gfxbase
  1518.  
  1519. getcols
  1520.  
  1521.         movem.l d0-2/a0-2,-(sp)
  1522.         moveq.w #0,d2
  1523. 1$      move.l  a3,a0
  1524.         move.l  d2,d0
  1525.         jsr _lvogetrgb4(a6)
  1526.         move.b  d0,2(a2)            ;b
  1527.         and.b   #%1111,2(a2)
  1528.         lsr.w   #4,d0
  1529.         move.b  d0,1(a2)            ;g
  1530.         and.b   #%1111,1(a2)
  1531.         lsr.w   #4,d0
  1532.         move.b  d0,(a2)             ;r
  1533.         addq.w  #1,d2
  1534.         add.l   #3,a2
  1535.         cmp.w   2(a3),d2
  1536.         bne.s   1$
  1537.         movem.l (sp)+,d0-2/a0-2
  1538.         rts
  1539.  
  1540. * fades out a viewport to a specified color [this color must be given in a
  1541. * special format:  1st byte r, 2nd g and 3rd b.(4th=0)]
  1542. * before fading out it is advisable to save the colors with getcols
  1543. * parms: a3=viewport  a4=pointer to color  d0=delaytime (see below)
  1544. *        [a5=dosbase] a6=gfxbase
  1545.  
  1546. fadeout
  1547.         movem.l d0-7/a0-6,-(sp)
  1548.         move.l  4.w,a6
  1549.         move.l  #100,d0
  1550.         move.l  #$10001,d1
  1551.         jsr _lvoallocmem(a6)
  1552.         move.l  d0,a2
  1553.         move.l  4(a3),a3
  1554.         move.l  56(sp),a6
  1555.         bsr getcols
  1556.         move.w  2(a3),a3
  1557.         move.l  a2,a5
  1558. 1$      moveq.b #0,d7
  1559.         moveq   #2,d5
  1560.         moveq   #0,d6
  1561. 2$      moveq   #0,d4
  1562.         move.l  a5,a2
  1563. 3$      move.b  (a2),d1
  1564.         move.b  1(a2),d2
  1565.         move.b  2(a2),d3
  1566.         move.b  0(a4,d6.w),d0
  1567.         cmp.b   0(a2,d6.w),d0
  1568.         blt.s   5$
  1569.         beq.s   4$
  1570.         addq.b  #1,0(a2,d6.w)
  1571.         bra.s   6$
  1572. 5$      subq.b  #1,0(a2,d6.w)
  1573. 6$      moveq.b #1,d7
  1574. 4$      move.w  d4,d0
  1575.         move.l  44(sp),a0   ;viewport
  1576.         move.l  56(sp),a6
  1577.         jsr _lvosetrgb4(a6)
  1578.         add.l   #3,a2
  1579.         addq.w  #1,d4
  1580.         cmp.w   a3,d4
  1581.         bne.s   3$
  1582. ;       move.l  (sp),d1     ;we're before boot up so we can't use dos.lib.
  1583. ;       move.l  52(sp),a6   ;so we help ourselves with dbf.
  1584. ;       jsr _lvodelay(a6)   ;delay just needed if less then 32 colors.
  1585.         move.l  (sp),d0
  1586. 10$     dbf d0,10$
  1587.         addq.w  #1,d6
  1588.         dbf d5,2$
  1589.         tst.b   d7
  1590.         bne.s   1$
  1591.         move.l  4.w,a6
  1592.         move.l  a5,a1
  1593.         move.l  #100,d0
  1594.         jsr _lvofreemem(a6)
  1595.         movem.l (sp)+,d0-7/a0-6
  1596.         rts
  1597.  
  1598. * fades in a viewport from a specified color [this color must be given in a
  1599. * special format:  1st byte r, 2nd g and 3rd b.(4th=0)]
  1600. * parms: a2=pointer to coltab as given by getcols  a3=viewport
  1601. * a4=pointer to color  d0=delaytime (see above) [a5=dosbase] a6=gfxbase
  1602.  
  1603. fadein
  1604.         movem.l d0-7/a0-6,-(sp)
  1605.         move.l  4(a3),a0
  1606.         move.w  2(a0),d0
  1607.         move.l  a2,a0
  1608.         add.l   #100,a0
  1609.         subq.w  #1,d0
  1610. 7$      move.b  (a4),(a0)+
  1611.         move.b  1(a4),(a0)+
  1612.         move.b  2(a4),(a0)+
  1613.         dbf d0,7$
  1614.         move.l  a2,a5
  1615. 1$      move.w  #0,a4
  1616.         moveq   #2,d5
  1617.         moveq   #0,d6
  1618. 2$      moveq   #0,d4
  1619.         move.l  a5,a2
  1620. 3$      move.b  100(a2),d1
  1621.         move.b  101(a2),d2
  1622.         move.b  102(a2),d3
  1623.         move.b  0(a2,d6.w),d0
  1624.         cmp.b   100(a2,d6.w),d0
  1625.         beq.s   4$
  1626.         blt.s   5$
  1627.         addq.b  #1,100(a2,d6.w)
  1628.         bra.s   6$
  1629. 5$      subq.b  #1,100(a2,d6.w)
  1630. 6$      move.w  #1,a4
  1631. 4$      move.w  d4,d0
  1632.         move.l  a3,a0
  1633.         move.l  56(sp),a6   ;gfxbase from Stack
  1634.         jsr _lvosetrgb4(a6)
  1635.         add.l   #3,a2       ;step to the data of the next colour
  1636.         addq    #1,d4       ;count the number of colours that we modified
  1637.         move.l  4(a3),a0    ;vport->colormap to a0
  1638.         cmp.w   2(a0),d4    ;compare the number of colours with our colour
  1639.                         ;counter
  1640.         bne.s   3$      ;have we already modified all colours ?If not
  1641.                         ;then let's modify the next one
  1642. ;       move.l  (sp),d1 ;see above
  1643. ;       move.l  52(sp),a6
  1644. ;       jsr _lvodelay(a6)
  1645.         move.l  (sp),d0
  1646. 10$     dbf d0,10$
  1647.         addq.w  #1,d6   ;now it's the next component's turn to be changed
  1648.         dbf d5,2$   ;we must do this loop three times:once for red,
  1649.                     ;once for green and once for blue,
  1650.                     ;so we load d5 with 2!!(3-1) in the beginning
  1651.         cmp.w   #0,a4   ;(tst.w  a4 doesn't work) find out if any changes were
  1652.         bne.s   1$  ;done in this loop,if not then we are ready
  1653.         movem.l (sp)+,d0-7/a0-6 ;clean up stackpointer
  1654.         rts
  1655.  
  1656.         device_support
  1657.  
  1658. modulestart     dc.l    0
  1659. modlength       dc.l    0
  1660. i_server        dc.l    0,0
  1661.         dc.b    2,0
  1662.         dc.l    0             ;10      name
  1663.         dc.l    0,0          ;18       irupt
  1664.  
  1665. i_name  dc.b    'BPic1.2_Color_Cycling',0
  1666.         even
  1667. delaytime       dc.w    0
  1668. delaycurrent    dc.w    0
  1669.  
  1670. cm_length   equ 80
  1671.  
  1672. getpalette
  1673.     movem.l a0-6/d0-7,-(sp)
  1674.     move.w  cycflag(pc),d0
  1675.     beq.s   11$
  1676.     m_alloc #clear+public,#cm_length
  1677.     emove   d0,palette(pc)
  1678.     getgfx
  1679.     move.l  palette(pc),a2
  1680.     moveq.w #0,d2
  1681. 1$  lea.l  viewport(a5),a0
  1682.     move.l  4(a0),a0
  1683.     move.w  d2,d0
  1684.     call    getrgb4
  1685.     move.w  d0,(a2)+
  1686.     addq.w  #1,d2
  1687.     cmp.w   #33,d2
  1688.     bne.s   1$
  1689.     getexe
  1690. ; interrupt einbinden
  1691.     lea     i_server(pc),a1
  1692.     emove   i_name(pc),10(a1)
  1693.     elea    cg_interrupt(pc),18(a1)
  1694.     moveq.l #5,d0
  1695.     getexe
  1696.     call    addintserver
  1697. 11$ movem.l (sp)+,a0-6/d0-7
  1698.     rts
  1699.  
  1700. palette dc.l    0
  1701. cmap    dc.l    0
  1702.  
  1703.  
  1704. freepalette
  1705.     move.w  cycflag(pc),d0
  1706.     beq.s   4$
  1707.     m_free  palette(pc),#cm_length
  1708. ; interrupt entfernen
  1709.     lea     i_server(pc),a1
  1710.     moveq.l #5,d0
  1711.     getexe
  1712.     call    remintserver
  1713.  
  1714. 4$  rts
  1715.  
  1716.         rsreset
  1717.  
  1718. crng_flag    rs.w    1
  1719. crng_ticks  rs.w    1
  1720. crng_start  rs.b    1
  1721. crng_end    rs.b    1
  1722. crng_ticked rs.w    1
  1723.  
  1724.         rsreset
  1725.  
  1726.  
  1727. crngs   ds.w    7*4
  1728.         dc.l    0
  1729.  
  1730. cg_interrupt
  1731.     movem.l a0-6/d0-7,-(sp)
  1732.     lea     crngs(pc),a2
  1733.         moveq.l #0,d7
  1734. cg_begin
  1735.  
  1736.         addq.l  #1,d7
  1737.         cmp.w   #7,d7
  1738.         beq     cg_finito
  1739.     add.w   #1,crng_ticked(a2)
  1740.     move.w  crng_ticks(a2),d0
  1741.     cmp.w   crng_ticked(a2),d0
  1742.     bhi.s   cg_end
  1743.     clr.w   crng_ticked(a2)
  1744.     move.l  palette(pc),a0
  1745.     moveq.w #0,d1
  1746.     move.b  crng_start(a2),d1
  1747.     lsl.w   #1,d1
  1748.     moveq.l #0,d2
  1749.     move.b  crng_end(a2),d2
  1750.     lsl.w   #1,d2
  1751.     cmp.w   d1,d2
  1752.     beq     cg_end
  1753.     btst    #1,crng_flag+1(a2)
  1754.     bne.s   cg_backward
  1755.     move.w  0(a0,d2.w),d6
  1756. 11$ subq.w  #2,d2
  1757.     move.w  0(a0,d2.w),2(a0,d2.w)
  1758.     cmp.w   d1,d2
  1759.     bne.s   11$
  1760.     move.w  d6,0(a0,d2.w)
  1761.     bra.s   cg_end
  1762. cg_backward
  1763.     move.w  0(a0,d1.w),d6
  1764. 11$ addq.w  #2,d1
  1765.     move.w  0(a0,d1.w),-2(a0,d1.w)
  1766.     cmp.w   d1,d2
  1767.     bne.s   11$
  1768.     move.w  d6,0(a0,d1.w)
  1769.  
  1770. cg_end
  1771.     addq.l  #8,a2
  1772.     bra.s   cg_begin
  1773. cg_finito
  1774.     move.l  vv_viewport(pc),a0
  1775.     moveq.l #32,d0
  1776.     move.l  palette(pc),a1
  1777.     getgfx
  1778.     call    loadrgb4
  1779.     movem.l (sp)+,a0-6/d0-7
  1780.     moveq.l #0,d0
  1781.     rts
  1782.  
  1783. vv_viewport     dc.l    0
  1784. readbuf dc.l    0
  1785. kickflag    dc.w    1   ; depends on checkdrive
  1786. cycflag     dc.w    0
  1787. endcopy
  1788. ;        opt     p-
  1789.  
  1790. allmeml equ endcopy-begincopy+code+100
  1791.  
  1792.  
  1793. filegdef
  1794.             dc.w    85,16,304,8,4,3,-78
  1795.             dc.l    filetxt
  1796.             dc.w    300,32,70,11,1,0,11
  1797.             dc.l    canctxt
  1798. canctxt     dc.b    'Cancel',0
  1799.             even
  1800. filetxt     dc.b    'IFF-File:',0
  1801.             even
  1802.  
  1803. reqtext dc.b    'Please enter IFF-Filename :',0
  1804.         even
  1805.  
  1806. arpcode
  1807.         clr.l   30(a0)
  1808.         move.w  #1,46(a0)
  1809.         move.w  #50,2(a0)
  1810.         rts
  1811.  
  1812. _lvotackon      equ     -624
  1813. _lvofilerequest equ     -294
  1814.  
  1815. * gadgetmem =zeiger auf speicherbereich 50 Byte direct. 50 Byte filename
  1816. *      100 Bytes: path
  1817. getfilename
  1818.     movem.l d2-5/a2-5,-(sp)
  1819.  
  1820.     tst.l   arpbase
  1821.     beq     8$
  1822.     move.l  a0,-(sp)
  1823.     move.l  gadgetmem(pc),a0
  1824.     add.l   #bufferstart+200,a0
  1825.     move.l  a0,4(a0)
  1826.     move.l  a0,8(a0)
  1827.     sub.l   #150,4(a0)
  1828.     sub.l   #200,8(a0)
  1829.     move.l  (sp)+,a1
  1830.     move.l  a1,(a0)
  1831.     move.b  #8,16(a0)
  1832.     lea     arpcode(pc),a1
  1833.     move.l  a1,18(a0)
  1834.     getarp
  1835.     jsr     _lvofilerequest(a6)
  1836.     tst.l   d0
  1837.     beq     1$
  1838.     move.l  gadgetmem(pc),a2
  1839.     add.l   #bufferstart+100,a2
  1840.     lea     -100(a2),a1
  1841.     move.l  a2,a0
  1842. 3$  move.b  (a1)+,(a2)+
  1843.     bne.s   3$
  1844.     move.l  d0,a1
  1845.     jsr     _lvotackon(a6)
  1846.  
  1847.     moveq.w #1,d0
  1848.     bra     1$
  1849. 8$  move.l  4.w,a6
  1850.     move.l  #420,d0
  1851.     move.l  #$10000+1,d1
  1852.     jsr     _lvoallocmem(a6)
  1853.     move.l  d0,a3
  1854.     beq     1$
  1855.     lea.l   filegdef(pc),a1
  1856.     move.l  a3,a2
  1857.     bsr     makegadget
  1858.     move.w  #1,itext1+it_topedge(a2)
  1859.     clr.w   itext2+it_topedge(a2)
  1860.     elea    280(a3),gd_specialinfo(a2)
  1861.     elea    320(a3),280+4(a3)   ;undobuffer
  1862.     move.w  #98,280+10(a3)          ;zeichenzahl
  1863.     move.l  gadgetmem(pc),a0
  1864.     elea    bufferstart+100(a0),280(a3)
  1865.  
  1866.     add.l   #18,a1
  1867.     add.l   #140,a2
  1868.     move.l  a2,-140(a2)
  1869.     bsr     makegadget
  1870.  
  1871.  
  1872.  
  1873.     move.l  a3,newwindow+18
  1874.     move.w  #180,newwindow
  1875.     move.w  #80,newwindow+2
  1876.     move.w  #400,newwindow+4
  1877.     move.w  #50,newwindow+6
  1878.     move.w  #$0102,newwindow+8
  1879.     move.l  #$40,newwindow+10
  1880.     move.l  #$1000+6,newwindow+14
  1881.     bsr     openwin
  1882.     move.l  a0,a4
  1883.  
  1884.     getint
  1885.     move.l  a3,a0
  1886.     move.l  a4,a1
  1887.     sub.l   a2,a2
  1888.     jsr     _lvoactivategadget(a6)
  1889.     move.l  wd_userport(a4),a2
  1890.     bsr     waitmsg
  1891.     move.l  28(a1),a5
  1892.     jsr     _lvoreplymsg(a6)
  1893.     move.l  a4,a0
  1894.     getint
  1895.     jsr     _lvoclosewindow(a6)
  1896.     move.l  4.w,a6
  1897.     move.l  a3,a1
  1898.     move.l  #420,d0
  1899.     jsr     _lvofreemem(a6)
  1900.     move.w  gd_gadgetid(a5),d0
  1901. 1$  movem.l (sp)+,d2-5/a2-5
  1902.     rts
  1903.  
  1904.  
  1905.  
  1906. infowindow
  1907.     movem.l d2-5/a2-5,-(sp)
  1908.     move.l  4.w,a6
  1909.     move.l  #140,d0
  1910.     move.l  #$10000+1,d1
  1911.     jsr     _lvoallocmem(a6)
  1912.     move.l  d0,a3
  1913.     beq     1$
  1914.     lea.l   infogdef(pc),a1
  1915.     move.l  a3,a2
  1916.     bsr     makegadget
  1917.     move.l  a3,newwindow+18
  1918.     move.w  #180,newwindow
  1919.     move.w  #45,newwindow+2
  1920.     move.w  #280,newwindow+4
  1921.     move.w  #150,newwindow+6
  1922.     move.w  #$0102,newwindow+8
  1923.     move.l  #$40,newwindow+10
  1924.     move.l  #$1000+6,newwindow+14
  1925.     bsr     openwin
  1926.     move.l  a0,a4
  1927.         move.l  rastport(pc),-(sp)
  1928.     move.l  wd_rastport(a4),rastport
  1929.  
  1930.     move.w  #15,d2
  1931.     move.w  #13,d3
  1932.     lea     infotext2(pc),a5
  1933.     moveq.w #9,d5
  1934. 2$  add.w   #10,d3
  1935.     move.l  a5,a2
  1936.     bsr     schatten
  1937.     add.l   d0,a5
  1938.     addq.l  #1,a5
  1939.     dbf     d5,2$
  1940.  
  1941.     move.l  wd_userport(a4),a2
  1942.     bsr     waitmsg
  1943.     jsr     _lvoreplymsg(a6)
  1944.     getint
  1945.     move.l  a4,a0
  1946.     jsr     _lvoclosewindow(a6)
  1947.     move.l  4.w,a6
  1948.     move.l  a3,a1
  1949.     move.l  #140,d0
  1950.     jsr     _lvofreemem(a6)
  1951.     move.l  (sp)+,rastport
  1952. 1$  movem.l (sp)+,d2-5/a2-5
  1953.     rts
  1954.  
  1955.  
  1956. infogdef
  1957.             dc.w    120,125,40,11,1,0,11
  1958.             dc.l    infotext
  1959. infotext    dc.b    'Ok',0,0
  1960. infotext2   dc.b    '  This Programm is SHAREWARE',0
  1961.             dc.b    ' It replaces the standard Boot-',0
  1962.             dc.b    'hand by any given IFF-file and',0
  1963.             dc.b    'additionally plays a MED-Module.',0
  1964.             dc.b    '  If you like it please send',0
  1965.             dc.b    '   5$ or 5DM to the author:',0
  1966.             dc.b    '     Andreas Ackermann',0
  1967.             dc.b    '     Lorenz-Summa-Str. 10',0
  1968.             dc.b    '     W-8679 Oberkotzau',0
  1969.             dc.b    '     GERMANY',0
  1970.             even
  1971. initwindow
  1972.     movem.l d2-4/a2-4,-(sp)
  1973.     move.l  4.w,a6
  1974.     move.l  #gadgetmemsize,d0
  1975.     move.l  #$10000+1,d1
  1976.     jsr     _lvoallocmem(a6)
  1977.     move.l  d0,gadgetmem
  1978.     beq     nogadgetmem
  1979.     lea.l   gdef(pc),a1
  1980.     move.l  gadgetmem(pc),a2
  1981.     moveq.w #4,d0                 ; vorher 3
  1982. 1$  bsr     makegadget
  1983.     move.l  a2,(a2)
  1984.     add.l   #140,(a2)
  1985.     add.l   #140,a2
  1986.     add.l   #18,a1
  1987.     dbf     d0,1$
  1988.     clr.l   -140(a2)
  1989.     add.w   #$100,-140+gd_activation(a2)
  1990.     add.w   #$100,-280+gd_activation(a2)
  1991.     move.l  gadgetmem(pc),newwindow+18
  1992.     bsr     openwin
  1993.     move.l  wd_userport(a0),userport
  1994.     move.l  wd_rastport(a0),rastport
  1995.     move.l  a0,windowptr
  1996.     beq     nowindow
  1997.  
  1998.     move.w  #10,d2
  1999.     move.w  #154,d3       ; vorher 134
  2000.     lea     stat(pc),a2
  2001.     bsr     schatten
  2002.     getint
  2003.     lea.l   imagestruct(pc),a1
  2004.     move.l  rastport(pc),a0
  2005.     clr.l   d0
  2006.     clr.l   d1
  2007.     jsr     _lvodrawimage(a6)
  2008.  
  2009.     moveq.w #1,d0
  2010.     movem.l (sp)+,d2-4/a2-4
  2011.     rts
  2012.  
  2013.  
  2014. windowcleanup
  2015.     movem.l d2-4/a2-4,-(sp)
  2016.     move.l  windowptr(pc),a0
  2017.     getint
  2018.     jsr     _lvoclosewindow(a6)
  2019. nowindow
  2020.     move.l  4.w,a6
  2021.     move.l  gadgetmem(pc),a1
  2022.     move.l  #gadgetmemsize,d0
  2023.     jsr     _lvofreemem(a6)
  2024. nogadgetmem
  2025.     clr.l   d0
  2026.     movem.l (sp)+,d2-4/a2-4
  2027.     rts
  2028.  
  2029. userport    dc.l    0
  2030. rastport    dc.l    0
  2031. windowptr   dc.l    0
  2032. gadgetmem   dc.l    0
  2033.  
  2034. newwindow
  2035.     dc.w    100,30,450,165
  2036.     dc.b    2,3
  2037.     dc.l    $200+$40,$1000+14 ;closew|gadup,wdrag|wdepth|wclose|activate
  2038.     dc.l    0,0
  2039.     dc.l    windowname
  2040.     dc.l    0,0
  2041.     dc.w    10,10,640,256
  2042.     dc.w    1
  2043.  
  2044. windowname  dc.b    'BootPic V2.1b ©1992 by Acki',0
  2045.             even
  2046.  
  2047. openwin     ;windowptr=>a0
  2048.     move.l  intbase(pc),a6
  2049.     lea     newwindow(pc),a0
  2050.     jsr     _lvoopenwindow(a6)
  2051.     move.l  d0,-(sp)
  2052.     beq.s   1$
  2053.     move.l  d0,a0
  2054.     move.l  wd_rastport(a0),a2
  2055.     getgfx
  2056.     moveq.w #1,d0
  2057.     move.l  a2,a1
  2058.     jsr     _lvosetapen(a6)
  2059.     move.l  a2,a1
  2060.     moveq.w #4,d0
  2061.     move.w  #11,d1
  2062.     lea     newwindow(pc),a0
  2063.     move.w  4(a0),d2
  2064.     subq.w  #5,d2
  2065.     move.w  6(a0),d3
  2066.     subq.w  #3,d3
  2067.     jsr     _lvorectfill(a6)
  2068.     clr.w   d0
  2069.     move.l  a2,a1
  2070.     jsr     _lvosetdrmd(a6)
  2071.     move.l  newwindow+18,a0
  2072.     sub.l   a2,a2
  2073.     move.l  (sp),a1
  2074.     moveq.l #7,d0                 ;max gadgetanzahl
  2075.     getint
  2076.     jsr     _lvorefreshglist(a6)
  2077. 1$  move.l  (sp)+,a0
  2078.     rts
  2079.  
  2080.  
  2081. ;d2=x-pos, d3=y-pos a2=^auf Text  erg:d0=länge
  2082.  
  2083. schatten
  2084.     moveq.w #2,d0
  2085.     addq.w  #1,d2
  2086.     addq.w  #1,d3
  2087.     bsr     pencrsr
  2088.     move.l  a2,a0
  2089.     bsr     printtext
  2090.     moveq.w #3,d0
  2091.     subq.w  #1,d2
  2092.     subq.w  #1,d3
  2093.     bsr     pencrsr
  2094.     move.l  a2,a0
  2095.     bsr     printtext
  2096.     rts
  2097.  
  2098. pencrsr           ;   d0=>pen ,d2=>x d3=>y
  2099.     getgfx
  2100.     move.l  rastport(pc),a1
  2101.     jsr     _lvosetapen(a6)
  2102.     move.w  d2,d0
  2103.     move.w  d3,d1
  2104.     move.l  rastport(pc),a1
  2105.     jsr     _lvomove(a6)
  2106.     rts
  2107.  
  2108. printtext
  2109.     getgfx
  2110.     move.w  #-1,d0
  2111.     move.l  a0,a1
  2112. 1$  addq.w  #1,d0
  2113.     tst.b   (a1)+
  2114.     bne.s   1$
  2115.     move.w  d0,-(sp)
  2116.     move.l  rastport(pc),a1
  2117.     jsr     _lvotext(a6)
  2118.     moveq   #0,d0
  2119.     move.w  (sp)+,d0
  2120.     rts
  2121.  
  2122. * a1=>auf gadgetdef   a2=>auf memory (möglichst genug !!!)
  2123.  
  2124. makegadget
  2125.     add.w   #1,width(a1)
  2126.     move.w  width(a1),koords+4(a2)
  2127.     move.w  width(a1),koords+8(a2)
  2128.     sub.w   #1,width(a1)
  2129.     add.w   #1,height(a1)
  2130.     move.w  height(a1),koords+10(a2)
  2131.     move.w  height(a1),koords+14(a2)
  2132.     sub.w   #1,height(a1)
  2133.     move.l  #-1,render1+bd_leftedge(a2)
  2134.     elea    koords(a2),render1+bd_xy(a2)
  2135.     move.b  #5,render1+bd_count(a2)
  2136.     move.b  #2,render1+bd_frontpen(a2)
  2137.     elea    render1(a2),gd_gadgetrender(a2)
  2138.     move.b  #2,itext1+it_frontpen(a2)
  2139.     move.w  #2,itext1+it_topedge(a2)
  2140.     move.w  textx(a1),itext1+it_leftedge(a2)
  2141.     add.w   #1,itext1+it_leftedge(a2)
  2142.     move.l  textptr(a1),itext1+it_itext(a2)
  2143.     elea    itext2(a2),itext1+it_nexttext(a2)
  2144.     move.b  #3,itext2+it_frontpen(a2)
  2145.     move.w  #1,itext2+it_topedge(a2)
  2146.     move.w  textx(a1),itext2+it_leftedge(a2)
  2147.     move.l  textptr(a1),itext2+it_itext(a2)
  2148.     elea    itext1(a2),gd_gadgettext(a2)
  2149.     move.l  leftedge(a1),gd_leftedge(a2)
  2150.     move.w  height(a1),gd_height(a2)
  2151.     move.w  width(a1),gd_width(a2)
  2152.     move.w  #$1,gd_activation(a2)
  2153.     move.w  type(a1),gd_gadgettype(a2)
  2154.     move.w  id(a1),gd_gadgetid(a2)
  2155.     rts
  2156.  
  2157. yesnowindow
  2158.     movem.l d2-5/a2-5,-(sp)
  2159.     move.l  4.w,a6
  2160.     move.l  #300,d0
  2161.     move.l  #$10000+1,d1
  2162.     jsr     _lvoallocmem(a6)
  2163.     move.l  d0,a3
  2164.     beq     1$
  2165.     lea.l   qgdef(pc),a1
  2166.     move.l  a3,a2
  2167.     bsr     makegadget
  2168.     move.l  a3,a2
  2169.     add.l   #textptr+4,a1
  2170.     add.l   #140,a2
  2171.     move.l  a2,gd_nextgadget(a3)
  2172.     bsr     makegadget
  2173.  
  2174.     move.l  a3,newwindow+18
  2175.     move.w  #140,newwindow
  2176.     move.w  #100,newwindow+2
  2177.     move.w  #335,newwindow+4
  2178.     move.w  #50,newwindow+6
  2179.     move.w  #$0102,newwindow+8
  2180.     move.l  #$40,newwindow+10
  2181.     move.l  #$1000+6,newwindow+14
  2182.     bsr     openwin
  2183.     move.l  a0,a4
  2184.     move.l  rastport(pc),-(sp)
  2185.     move.l  wd_rastport(a4),rastport
  2186.  
  2187.     move.w  #30,d2
  2188.     move.w  #22,d3
  2189.     lea     qt(pc),a2
  2190.     bsr     schatten
  2191.  
  2192.     move.l  wd_userport(a4),a2
  2193.     bsr     waitmsg
  2194.     move.l  28(a1),a0
  2195.     moveq.l #0,d5
  2196.     tst.w   gd_gadgetid(a0)
  2197.     beq.s   27$
  2198.     addq.w  #1,d5
  2199. 27$
  2200.     jsr     _lvoreplymsg(a6)
  2201.     getint
  2202.     move.l  a4,a0
  2203.     jsr     _lvoclosewindow(a6)
  2204.     move.l  4.w,a6
  2205.     move.l  a3,a1
  2206.     move.l  #300,d0
  2207.     jsr     _lvofreemem(a6)
  2208.     move.l  (sp)+,rastport
  2209.     move.l  d5,d0
  2210. 1$  movem.l  (sp)+,d2-5/a2-5
  2211.     rts
  2212.     ; erg: d0= 0   when no
  2213.  
  2214.             rsreset
  2215. gadgetdef   rs.l    0
  2216. leftedge    rs.w    1
  2217. topedge     rs.w    1
  2218. width       rs.w    1
  2219. height      rs.w    1
  2220. type        rs.w    1
  2221. id          rs.w    1
  2222. textx       rs.w    1
  2223. textptr     rs.l    1
  2224.  
  2225. qgdef       dc.w    38,31,60,11,1,1,16
  2226.             dc.l    yes
  2227.             dc.w    225,31,60,11,1,0,20
  2228.             dc.l    no
  2229.  
  2230.  
  2231.  
  2232. qt          dc.b    'Do you wish to load a MED-Module ?',0
  2233.             even
  2234. yes         dc.b    'Yes',0
  2235. no          dc.b    'No',0
  2236.             even
  2237. qtext       dc.b    'Please select a MED-Module :',0
  2238.             even
  2239.  
  2240.  
  2241. gdef        dc.w    38,90,175,11,1,6,10
  2242.             dc.l    loadt
  2243.             dc.w    238,90,175,11,1,7,32
  2244.             dc.l    remtt
  2245.             dc.w    138,130,175,11,1,8,67
  2246.             dc.l    infot
  2247.             dc.w    238,110,175,11,1,9,35
  2248.             dc.l    cyct
  2249.             dc.w    38,110,175,11,1,10,29
  2250.             dc.l    kickt
  2251.  
  2252. imagestruct
  2253.     dc.w    77,28
  2254.     dc.w    284,39
  2255.     dc.w    1
  2256.     dc.l    imagedata
  2257.     dc.b    2,1
  2258.     dc.l    0
  2259.  
  2260. loadt       dc.b    'Load Picture & Music',0
  2261.             even
  2262. remtt       dc.b    'Remove BootPic',0
  2263.             even
  2264. infot       dc.b    'Info',0
  2265.             even
  2266. cyct        dc.b    'Color-Cycling',0
  2267.             even
  2268. kickt       dc.b    'Check only df0:',0
  2269.             even
  2270. stat        dc.b    'Status:',0
  2271.             even
  2272.  
  2273.  
  2274.  
  2275.     section player,code_c
  2276. playerstart
  2277.         include "modplayer.i"
  2278. ;    a0=ptr auf data
  2279. ;    d0=ptr auf länge
  2280. _med_startup
  2281.  
  2282.         movem.l d0-7/a0-6,-(sp)
  2283.         move.l  a0,a2
  2284.         move.l  d0,d2
  2285.         getexe
  2286.         move.l  #$10003,d1
  2287.         move.l  a2,a0
  2288.         add.l   d2,a0
  2289.         move.l  -4(a0),d0
  2290.         lsr.l   #8,d0
  2291.         addq.l  #7,d0
  2292.         addq.l  #7,d0
  2293.         move.l  d0,pp_memlength
  2294.         call    allocmem
  2295.         move.l  d0,a1
  2296.         move.l  d0,pp_memptr
  2297.         move.l  a2,a0
  2298.         move.l  4(a0),d0
  2299.         add.l   d2,a0
  2300.         bsr     _pp_decrunchbuffer
  2301.         move.l  pp_memptr(pc),a0
  2302.         cmp.l   #'MMD0',(a0)
  2303.         bne.s   1$
  2304.         bsr     _relocmodule
  2305.         move.l  pp_memptr(pc),a0
  2306.         bsr     _playmodule
  2307. 1$      movem.l (sp)+,d0-7/a0-6
  2308.         rts
  2309.  
  2310.  
  2311. pp_memlength    dc.l    0
  2312. pp_memptr       dc.l    0
  2313.  
  2314. _med_cleanup
  2315.         movem.l d0-7/a0-6,-(sp)
  2316.         getexe
  2317.         move.l  pp_memlength(pc),d0
  2318.         beq.s   1$
  2319.         move.l  pp_memptr(pc),a1
  2320.         call    freemem
  2321.         clr.l   pp_memlength
  2322. 1$      movem.l (sp)+,d0-7/a0-6
  2323.         rts
  2324.  
  2325.  
  2326.  
  2327.  
  2328. ;       Function: _RelocModule(a0)
  2329. ;       a0 = pointer to module
  2330. relocentr:
  2331.         tst.l   (a0)
  2332.         beq.s   norel
  2333.         add.l   d1,(a0)
  2334. norel:  addq.l  #4,a0
  2335.         rts
  2336. _RelocModule:
  2337.         movem.l a2-a3/d2-d3,-(sp)
  2338.         movea.l a0,a2
  2339.         move.l  a2,d1           ;d1 = ptr to start of module
  2340.         lea     8(a2),a0
  2341.         bsr.s   relocentr       ;reloc song ptr
  2342.         addq.l  #4,a0
  2343.         bsr.s   relocentr       ;reloc blockarr ptr
  2344.         addq.l  #4,a0
  2345.         bsr.s   relocentr       ;reloc smplarr ptr
  2346.         addq.l  #4,a0
  2347.         bsr.s   relocentr       ;reloc expdata ptr
  2348.         movea.l 24(a2),a0
  2349.         movea.l 8(a2),a1
  2350.         moveq   #0,d0
  2351.         move.b  787(a1),d0      ;number of samples
  2352.         subq.b  #1,d0
  2353. relocs: bsr.s   relocentr
  2354.         move.l  -4(a0),d3       ;sample ptr
  2355.         beq.s   nosyn
  2356.         move.l  d3,a3
  2357.         tst.w   4(a3)
  2358.         bpl.s   nosyn           ;type >= 0
  2359.         move.w  20(a3),d2       ;number of waveforms
  2360.         lea     278(a3),a3      ;ptr to wf ptrs
  2361.         subq.w  #1,d2
  2362. relsyn: add.l   d3,(a3)+
  2363.         dbf     d2,relsyn
  2364. nosyn:  dbf     d0,relocs
  2365.         movea.l 16(a2),a0
  2366.         move.w  504(a1),d0
  2367.         subq.b  #1,d0
  2368. relocb: bsr.s   relocentr
  2369.         dbf     d0,relocb
  2370.         move.l  32(a2),d0       ;extension struct
  2371.         beq.s   rel_ex
  2372.         move.l  d0,a0
  2373.         addq.l  #4,a0           ;pass "reserved"
  2374.         bsr.s   relocentr       ;InstrExt...
  2375.         addq.l  #4,a0           ;pass sizes of InstrExt
  2376.         bsr.s   relocentr       ;annotxt
  2377. rel_ex  movem.l (sp)+,d2-d3/a2-a3
  2378.         rts
  2379.  
  2380.  
  2381.  
  2382.  
  2383. ; call as:
  2384. ;    DecrunchBuffer (endcrun, buffer, efficiency);
  2385.  
  2386.  
  2387. _pp_DecrunchBuffer:
  2388.         movem.l d1-d7/a2-a6,-(a7)
  2389.         bsr.s Decrunch
  2390.         movem.l (a7)+,d1-d7/a2-a6
  2391.         rts
  2392. Decrunch:
  2393.         lea myBitsTable(PC),a5
  2394.         move.l d0,(a5)
  2395.         move.l a1,a2
  2396.         move.l -(a0),d5
  2397.         moveq #0,d1
  2398.         move.b d5,d1
  2399.         lsr.l #8,d5
  2400.         add.l d5,a1
  2401.         move.l -(a0),d5
  2402.         lsr.l d1,d5
  2403.         move.b #32,d7
  2404.         sub.b d1,d7
  2405. LoopCheckCrunch:
  2406.         bsr.s ReadBit
  2407.         tst.b d1
  2408.         bne.s CrunchedBytes
  2409. NormalBytes:
  2410.         moveq #0,d2
  2411. Read2BitsRow:
  2412.         moveq #2,d0
  2413.         bsr.s ReadD1
  2414.         add.w d1,d2
  2415.         cmp.w #3,d1
  2416.         beq.s Read2BitsRow
  2417. ReadNormalByte:
  2418.         move.w #8,d0
  2419.         bsr.s ReadD1
  2420.         move.b d1,-(a1)
  2421.         dbf d2,ReadNormalByte
  2422.         cmp.l a1,a2
  2423.         bcs.s CrunchedBytes
  2424.         rts
  2425. CrunchedBytes:
  2426.         moveq #2,d0
  2427.         bsr.s ReadD1
  2428.         moveq #0,d0
  2429.         move.b (a5,d1.w),d0
  2430.         move.l d0,d4
  2431.         move.w d1,d2
  2432.         addq.w #1,d2
  2433.         cmp.w #4,d2
  2434.         bne.s ReadOffset
  2435.         bsr.s ReadBit
  2436.         move.l d4,d0
  2437.         tst.b d1
  2438.         bne.s LongBlockOffset
  2439.         moveq #7,d0
  2440. LongBlockOffset:
  2441.         bsr.s ReadD1
  2442.         move.w d1,d3
  2443. Read3BitsRow:
  2444.         moveq #3,d0
  2445.         bsr.s ReadD1
  2446.         add.w d1,d2
  2447.         cmp.w #7,d1
  2448.         beq.s Read3BitsRow
  2449.         bra.s DecrunchBlock
  2450. ReadOffset:
  2451.         bsr.s ReadD1
  2452.         move.w d1,d3
  2453. DecrunchBlock:
  2454.         move.b (a1,d3.w),d0
  2455.         move.b d0,-(a1)
  2456.         dbf d2,DecrunchBlock
  2457. EndOfLoop:
  2458. _pp_DecrunchColor:
  2459. ;        bchg    #1,$bfe001
  2460. ;        move.w a1,$dff180
  2461.         btst.b  #6,$bfe001
  2462.         beq.s   1$
  2463.         cmp.l a1,a2
  2464.         bcs.s LoopCheckCrunch
  2465. 1$      rts
  2466. ReadBit:
  2467.         moveq #1,d0
  2468. ReadD1:
  2469.         moveq #0,d1
  2470.         subq.w #1,d0
  2471. ReadBits:
  2472.         lsr.l #1,d5
  2473.         roxl.l #1,d1
  2474.         subq.b #1,d7
  2475.         bne.s No32Read
  2476.         move.b #32,d7
  2477.         move.l -(a0),d5
  2478. No32Read:
  2479.         dbf d0,ReadBits
  2480.         rts
  2481. myBitsTable:
  2482.         dc.b $09,$0a,$0b,$0b
  2483.  
  2484.  
  2485.         rs.b    20
  2486.     section bootpicdata,data_c
  2487. imagedata
  2488.  dc.w  $0000,$007f,$f800,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$1fe0,$0000,$0000,$6000,$0000,$0000
  2489.  dc.w  $0000,$3fff,$ff80,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$003f,$fffe,$0000,$0000,$fc00,$0000,$0000
  2490.  dc.w  $0007,$ffff,$ffe0,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$01ff,$ffff,$8000,$0000,$fe00,$0000,$0000
  2491.  dc.w  $000f,$ffff,$fff0,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$03ff,$ffff,$e000,$0001,$fe00,$0000,$0000
  2492.  dc.w  $000f,$ffff,$fff8,$0000,$0000,$0000,$0000,$0000,$0000,$0180,$0000,$03ff,$ffff,$f000,$0001,$fc00,$0000,$0000
  2493.  dc.w  $000f,$ffff,$fffc,$0000,$0000,$0000,$0000,$0000,$0000,$03e0,$0000,$003f,$ffff,$f800,$0001,$fc00,$0000,$0000
  2494.  dc.w  $0000,$1ff8,$07fc,$0000,$0000,$0000,$0000,$0000,$0000,$07e0,$0000,$007f,$f83f,$f800,$0000,$f800,$0000,$0000
  2495.  dc.w  $0000,$3fe0,$03fc,$0000,$0000,$0000,$0000,$0000,$0000,$0fe0,$0000,$00ff,$c00f,$fc00,$0000,$7000,$0000,$0000
  2496.  dc.w  $0000,$3fc0,$03fc,$0000,$0000,$0000,$0000,$0000,$0000,$1fe0,$0000,$01ff,$8007,$fc00,$0000,$0000,$0000,$0000
  2497.  dc.w  $0000,$7fc0,$07fc,$0000,$00e0,$0000,$0000,$e000,$0000,$3fc0,$0000,$01ff,$0007,$fc00,$0000,$0000,$0000,$0000
  2498.  dc.w  $0000,$ff80,$0ffc,$0000,$03f0,$0000,$0003,$f000,$0000,$7f80,$0000,$03ff,$000f,$fc00,$0000,$0000,$0000,$0000
  2499.  dc.w  $0000,$ff80,$1ff8,$0000,$0ff8,$0000,$000f,$f800,$0000,$ff80,$0000,$07fe,$001f,$f800,$0000,$0000,$0000,$fe00
  2500.  dc.w  $0001,$ff00,$3ff8,$0000,$3ff8,$0000,$003f,$f800,$000f,$fffe,$0000,$0ffc,$003f,$f800,$0000,$0000,$0003,$ff80
  2501.  dc.w  $0003,$ff00,$fff0,$0000,$fff8,$0000,$00ff,$f800,$001f,$ffff,$0000,$0ffc,$00ff,$f000,$001c,$0000,$001f,$ffe0
  2502.  dc.w  $0003,$fe03,$ffe0,$0003,$ffff,$8000,$03ff,$ff80,$001f,$ffff,$0000,$1ff8,$01ff,$e000,$003f,$0000,$007f,$fff0
  2503.  dc.w  $0007,$fe0f,$ff80,$0007,$ffff,$e000,$07ff,$ffe0,$001f,$ffff,$0000,$3ff8,$07ff,$c000,$003f,$8000,$01ff,$fff0
  2504.  dc.w  $0007,$ffff,$ff00,$001f,$ff07,$f800,$1fff,$07f8,$0003,$fe00,$0000,$7ff0,$1fff,$8000,$007f,$8000,$03ff,$8ff0
  2505.  dc.w  $000f,$ffff,$fc00,$003f,$fc07,$f800,$3ffc,$07f8,$0007,$f800,$0000,$7fe0,$7fff,$0000,$00ff,$0000,$07fe,$0ff0
  2506.  dc.w  $001f,$ffff,$f800,$007f,$f007,$fc00,$7ff0,$07fc,$000f,$f000,$0000,$ffe1,$fffe,$0000,$01fe,$0000,$0ff8,$07f0
  2507.  dc.w  $001f,$ffff,$c000,$00ff,$e007,$fc00,$ffe0,$07fc,$001f,$e000,$0001,$ffff,$fff8,$0000,$01fe,$0000,$1ff0,$07c0
  2508.  dc.w  $003f,$ffff,$f000,$01ff,$c007,$fc01,$ffc0,$07fc,$001f,$e000,$0001,$ffff,$ffe0,$0000,$03fc,$0000,$3fe0,$0000
  2509.  dc.w  $007f,$ffff,$f800,$01ff,$8007,$fc01,$ff80,$07fc,$003f,$c000,$0003,$ffff,$ff80,$0000,$07f8,$0000,$7fc0,$0000
  2510.  dc.w  $007f,$f80f,$fc00,$03ff,$000f,$fc03,$ff00,$0ffc,$003f,$c000,$0003,$ffff,$fe00,$0000,$07f8,$0000,$ff80,$0000
  2511.  dc.w  $00ff,$f007,$fc00,$03fe,$000f,$f803,$fe00,$0ff8,$007f,$8000,$0007,$fe7f,$f800,$0000,$0ff0,$0001,$ff80,$0000
  2512.  dc.w  $01ff,$e007,$fc00,$07fe,$001f,$f807,$fe00,$1ff8,$007f,$8000,$000f,$fe3f,$c000,$0000,$1fe0,$0001,$ff00,$0000
  2513.  dc.w  $01ff,$c007,$fc00,$07fc,$001f,$f007,$fc00,$1ff0,$00ff,$0000,$000f,$fc00,$0000,$0000,$3fc0,$0003,$fe00,$0000
  2514.  dc.w  $03ff,$800f,$fc00,$07fc,$003f,$f007,$fc00,$3ff0,$00ff,$0000,$001f,$fc00,$0000,$0000,$3fc0,$0003,$fe00,$0000
  2515.  dc.w  $07ff,$001f,$f800,$0ff8,$007f,$e00f,$f800,$7fe0,$01fe,$0000,$003f,$f800,$0000,$0000,$7f80,$0007,$fc00,$0000
  2516.  dc.w  $0ffe,$003f,$f800,$0ff8,$00ff,$c00f,$f800,$ffc0,$01fc,$0000,$003f,$f000,$0000,$0000,$ff80,$0007,$fc00,$0000
  2517.  dc.w  $0ffc,$007f,$f000,$0ff8,$01ff,$800f,$f801,$ff80,$03fc,$0000,$007f,$f000,$0000,$0000,$ff00,$0007,$fc00,$0000
  2518.  dc.w  $1ff8,$00ff,$e000,$0ff8,$03ff,$000f,$f803,$ff00,$03f8,$0000,$007f,$e000,$0000,$0001,$ff00,$0007,$fc00,$0000
  2519.  dc.w  $3ff8,$03ff,$c000,$07f8,$07fe,$0007,$f807,$fe00,$07f8,$0000,$00ff,$e000,$0000,$0001,$fe00,$0007,$fc00,$0000
  2520.  dc.w  $7ff8,$0fff,$0000,$07f8,$0ffc,$0007,$f80f,$fc00,$07f0,$0000,$01ff,$c000,$0000,$0003,$fc00,$0007,$fc00,$7000
  2521.  dc.w  $7fff,$fffe,$0000,$03fc,$3ff8,$0003,$fc3f,$f800,$0ff0,$0000,$01ff,$8000,$0000,$0007,$fc00,$0007,$ff07,$f800
  2522.  dc.w  $ffff,$fffc,$0000,$03ff,$ffe0,$0003,$ffff,$e000,$0ff0,$0000,$03ff,$8000,$0000,$0007,$f800,$0007,$ffff,$f000
  2523.  dc.w  $ffff,$fff0,$0000,$01ff,$ffc0,$0001,$ffff,$c000,$0ff0,$0000,$03ff,$0000,$0000,$000f,$f800,$0003,$ffff,$f000
  2524.  dc.w  $ffff,$ffc0,$0000,$00ff,$ff00,$0000,$ffff,$0000,$07f0,$0000,$03ff,$0000,$0000,$000f,$f000,$0001,$ffff,$c000
  2525.  dc.w  $7e0f,$ff00,$0000,$003f,$f800,$0000,$3ff8,$0000,$01f0,$0000,$01fe,$0000,$0000,$000f,$f000,$0000,$7fff,$0000
  2526.  dc.w  $1c03,$f800,$0000,$000f,$c000,$0000,$0fc0,$0000,$0070,$0000,$0078,$0000,$0000,$0007,$e000,$0000,$1ff0,$0000
  2527.  
  2528.     end
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.