home *** CD-ROM | disk | FTP | other *** search
/ YPA: Your Privacy Assured / YPA.ISO / other_goodies / music / ep154b_1.dms / ep154b_1.adf / EagleplayerDeveloper / Examples / NoisePackerIII.s < prev    next >
Text File  |  1995-01-17  |  21KB  |  930 lines

  1.     **************************************************************
  2.     ** EaglePlayer/DelitrackerV1.3+ Noisepackerplayroutine 3.x  **
  3.     ** angepa▀t 1993 von Buggs of DEFECT                        **
  4.     **************************************************************
  5. test = 0
  6.         incdir    include:
  7.         include    misc/Eagleplayer.i
  8.  
  9.     ifne    test
  10.     lea    mod,a0
  11.     bsr    np_check
  12.  
  13.     lea    mod,a0
  14.     move.l    a0,np_data
  15.     bsr    np_init
  16.  
  17. wa    move.b    $dff006,d0
  18.     cmp.b    #$50,d0
  19.     bne    wa
  20.     bsr    np_music
  21.     btst    #6,$bfe001
  22.     bne    wa
  23.     move.w    #15,$dff096
  24.     illegal
  25.     endc
  26.  
  27.     PLAYERHEADER Tags
  28.     dc.b    '$VER: NoisePacker3 Eagleplayer V1.50 (jan/26/93)',0,0
  29.  
  30. Tags        dc.l    DTP_PlayerVersion,5
  31.         dc.l    DTP_PlayerName,playername
  32.         dc.l    DTP_Creator,creator
  33.         dc.l    DTP_Check2,NP_check
  34.         dc.l    DTP_Interrupt,interrupt
  35.         dc.l    DTP_InitPlayer,initplayer
  36.         dc.l    DTP_EndPlayer,endplayer
  37.         dc.l    DTP_InitSound,np_init
  38.         dc.l    DTP_EndSound,np_endsnd
  39.         dc.l    DTP_NextPatt,NP_NextPattern
  40.         dc.l    DTP_PrevPatt,NP_PrevPattern
  41.         dc.l    DTP_Volume,SetVol
  42.         dc.l    DTP_Balance,SetVol
  43.         dc.l    EP_Flags,EPB_Save!EPB_Restart!EPB_Songend!EPB_Volume!EPB_Balance!EPB_Voices!EPB_Analyzer!EPB_Moduleinfo!EPB_Nextpatt!EPB_Prevpatt
  44.         dc.l    EP_Voices,SetVoices
  45.         dc.l    EP_Get_ModuleInfo,NP_GetInfos
  46.         dc.l    EP_GetPositionNr,NP_GetPosNr
  47.         dc.l    EP_StructInit,StrukInit
  48.         dc.l    0
  49.  
  50. Playername:    dc.b    "NoisePacker 3.x",0
  51. creator        dc.b    "Twins of Phenomena,",10
  52.         dc.b    "adapted by DEFECT",0
  53. NP_Prefix    dc.b    "NP3.",0
  54.         even
  55.  
  56. *-----------------------------------------------------------------------------*
  57. NP_SongendAdr:    dc.l    0
  58. NP_Structadr:    ds.b    ups_sizeof
  59. NP_Data:    dc.l    0
  60. NP_RightVol    dc.w    0
  61. NP_LeftVol    dc.w    0
  62. NP_SndVol    dc.w    0
  63.  
  64. NP_Voice1    dc.w    1
  65. NP_Voice2    dc.w    1
  66. NP_Voice3    dc.w    1
  67. NP_Voice4    dc.w    1
  68. NP_OldVoice1    dc.w    0
  69. NP_OldVoice2    dc.w    0
  70. NP_OldVoice3    dc.w    0
  71. NP_OldVoice4    dc.w    0
  72. num_samples:    dc.w    0
  73.  
  74. ;================ Struktur ⁿbergeben =====================================
  75. Strukinit:    lea    NP_StructAdr(pc),a0
  76.         rts
  77.  
  78.  
  79. *-----------------------------------------------------------------------------*
  80. NP_NextPattern:    lea    np_block+$15(pc),a6
  81.         lea    np_voidat1+128(pc),a2
  82.         moveq    #0,d0
  83.         move.b    d0,(a6)
  84.         move.l    d0,-32(a2)
  85.         move.l    d0,-64(a2)
  86.         move.l    d0,-96(a2)
  87.         move.l    d0,-128(a2)
  88.  
  89.         lea    np_block+2(pc),a6
  90.         move.l    (a6)+,a0
  91.         addq.w    #2,(a6)
  92.         move.w    (a6),d0
  93.         cmp.w    -4(a0),d0
  94.         bne.b    .np_next
  95.         move.w    -2(a0),d0
  96.  
  97.         move.l    NP_SongEndAdr(pc),a0
  98.         jsr    (a0)
  99.     
  100.         cmp.w    #254,d0
  101.         blo.s    .ok
  102.         moveq    #0,d0
  103. .ok        move.w    d0,(a6)
  104. .np_next:    bra    np_PATTE
  105.  
  106. *------------------------------------------------------------------------*
  107. NP_PrevPattern:    lea    np_block+$15(pc),a6
  108.         lea    np_voidat1+128(pc),a2
  109.         moveq    #0,d0
  110.         move.b    d0,(a6)
  111.         move.l    d0,-32(a2)
  112.         move.l    d0,-64(a2)
  113.         move.l    d0,-96(a2)
  114.         move.l    d0,-128(a2)
  115.  
  116.         lea    np_block+6(pc),a6
  117.         subq.w    #2,(a6)
  118.         tst.w    (a6)
  119.         bge.s    NP_Patte
  120.         clr.w    (a6)
  121.  
  122. *------------------------------------------------------------------------*
  123. NP_Patte:    lea    $dff0a8,a0
  124.         move.w    #0,(a0)
  125.         move.w    #0,$10(a0)
  126.         move.w    #0,$20(a0)
  127.         move.w    #0,$30(a0)
  128.         rts
  129.  
  130. *------------------------------------------------------------------------*
  131. NP_GetPosNr:    moveq    #0,d0
  132.         move.w    np_block+6(pc),d0
  133.         lsr.w    #1,d0
  134.         rts
  135.  
  136. *--------------- Daten in die Userprogramm-Struktur ⁿbergeben -----------*
  137. NP_GetVoice:    movem.l    d0-d1/a1,-(sp)
  138.         lea    NP_Structadr(pc),a1    ;1.Kanal
  139.         cmp.l    #$dff0a0,a4
  140.         beq.s    .yes
  141.         lea    NP_Structadr+ups_modulo(pc),a1    ;2.Kanal
  142.         cmp.l    #$dff0b0,a4
  143.         beq.s    .yes
  144.         lea    NP_Structadr+ups_modulo*2(pc),a1    ;3.Kanal
  145.         cmp.l    #$dff0c0,a4
  146.         beq.s    .yes
  147.         lea    NP_Structadr+ups_modulo*3(pc),a1    ;4.Kanal
  148. .yes:        move.w    -6(a2),UPS_Voice1Per(a1)    ;Sampleperiode
  149.         move.l    (a3),UPS_Voice1Adr(a1)        ;Sampleadresse
  150.         moveq    #0,d1
  151.         cmp.w    #1,10(a3)    ;Repeat on ?
  152.         bhi.s    .ok
  153.         moveq    #1,d1        ;nein,Repeat "off" setzen
  154. .ok        move.w    d1,UPS_Voice1Repeat(a1)
  155.         move.w    4(a3),UPS_Voice1len(a1)    ;LΣnge/2
  156.         movem.l    (sp)+,d0-d1/a1
  157.         rts
  158.  
  159. *------------------- Tag-Item Struktur fⁿr Module-Info -----------------*
  160. NP_InfoBuffer:    dc.l    MI_Length
  161. NP_Infolen:    dc.l    0
  162.         dc.l    MI_SongSize
  163. NP_InfoSong    dc.l    0
  164.         dc.l    MI_SamplesSize
  165. NP_InfoSamples    dc.l    0
  166.         dc.l    MI_Samples
  167. NP_NumSamples    dc.l    0
  168.         dc.l    MI_CalcSize
  169. NP_Numall    dc.l    0
  170.         dc.l    MI_Pattern
  171. NP_Numpatts    dc.l    0
  172.         dc.l    MI_Unpackedsystem,MIUS_Noisetracker
  173.         dc.l    MI_Unpacked
  174. NP_Unp        dc.l    0
  175.         dc.l    MI_Prefix,NP_Prefix
  176.         dc.l    0
  177.  
  178. *------------------------------------------------------------------------*
  179. NP_GetInfos:    lea    NP_InfoBuffer(pc),a0
  180.         move.l    np_numpatts(pc),d0
  181.         lsr.w    #3,d0
  182.         move.l    d0,np_numpatts-NP_InfoBuffer(a0)
  183.         mulu    #1024,d0
  184.         add.l    #$43c,d0
  185.         add.l    NP_InfoSamples(pc),d0
  186.         move.l    d0,np_unp-NP_InfoBuffer(a0)
  187. NP_Return:    rts
  188.  
  189. *-----------------------------------------------------------------------*
  190. *        d0 Bit 0-3 = Set Voices Bit=1 Voice on            *
  191. SetVoices:    lea    NP_Voice1(pc),a0
  192.         lea    NP_StructAdr(pc),a1
  193.         moveq    #1,d1
  194.         move.w    d1,(a0)+            Voice1=0 setzen
  195.         btst    #0,d0
  196.         bne.s    .NoVoice1
  197.         clr.w    -2(a0)
  198.         clr.w    $dff0a8
  199.         clr.w    UPS_Voice1Vol(a1)
  200. .NoVoice1:    move.w    d1,(a0)+            Voice2=0 setzen
  201.         btst    #1,d0
  202.         bne.s    .NoVoice2
  203.         clr.w    -2(a0)
  204.         clr.w    $dff0b8
  205.         clr.w    UPS_Voice2Vol(a1)
  206. .NoVoice2:    move.w    d1,(a0)+            Voice3=0 setzen
  207.         btst    #2,d0
  208.         bne.s    .NoVoice3
  209.         clr.w    -2(a0)
  210.         clr.w    $dff0c8
  211.         clr.w    UPS_Voice3Vol(a1)
  212. .NoVoice3:    move.w    d1,(a0)+            Voice4=0 setzen
  213.         btst    #3,d0
  214.         bne.s    .NoVoice4
  215.         clr.w    -2(a0)
  216.         clr.w    $dff0d8
  217.         clr.w    UPS_Voice4Vol(a1)
  218. .NoVoice4:    move.w    d0,UPS_DMACON(a1)
  219.         moveq    #0,d0
  220.         rts
  221.  
  222. *-----------------------------------------------------------------------*
  223. SetVol:        move.w    DTG_SndLBal(a5),d0
  224.         mulu    DTG_SndVol(a5),d0
  225.         lsr.w    #6,d0                ; durch 64
  226.         move.w    d0,NP_LeftVol            ; Left Volume
  227.  
  228.         move.w    DTG_SndRBal(a5),d0
  229.         mulu    DTG_SndVol(a5),d0
  230.         lsr.w    #6,d0                ; durch 64
  231.         move.w    d0,NP_RightVol            ; Right Volume
  232.  
  233.  
  234.         lea    NP_OldVoice1(pc),a0
  235.         lea    $dff0a0,a4
  236.         moveq    #3,d1
  237. .SetNew        move.w    (a0)+,d0
  238.         bsr.s    NP_SetVoices
  239.         addq.l    #8,a4
  240.         addq.l    #8,a4
  241.         dbf    d1,.SetNew
  242.         rts
  243. *-----------------------------------------------------------------------*
  244. NP_SetVoices:    and.w    #$7f,d0
  245.         cmp.l    #$dff0a0,a4            ;Left Volume
  246.         bne.s    .NoVoice1
  247.         move.w    d0,NP_OldVoice1
  248.         tst.w    NP_Voice1
  249.         bne.s    .Voice1On
  250.         moveq    #0,d0
  251. .Voice1On:    move.w    d0,NP_StructAdr+UPS_Voice1Vol
  252.         mulu.w    NP_LeftVol(pc),d0
  253.         bra.b    .SetIt
  254. .NoVoice1:    cmp.l    #$dff0b0,a4            ;Right Volume
  255.         bne.s    .NoVoice2
  256.         move.w    d0,NP_OldVoice2
  257.         tst.w    NP_Voice2
  258.         bne.s    .Voice2On
  259.         moveq    #0,d0
  260. .Voice2On:    move.w    d0,NP_StructAdr+UPS_Voice2Vol
  261.         mulu.w    NP_RightVol(pc),d0
  262.         bra.b    .SetIt
  263. .NoVoice2:    cmp.l    #$dff0c0,a4            ;Right Volume
  264.         bne.s    .NoVoice3
  265.         move.w    d0,NP_OldVoice3
  266.         tst.w    NP_Voice3
  267.         bne.w    .Voice3On
  268.         moveq    #0,d0
  269. .Voice3On:    move.w    d0,NP_StructAdr+UPS_Voice3Vol
  270.         mulu.w    NP_RightVol(pc),d0
  271.         bra.b    .SetIt
  272. .NoVoice3:    cmp.l    #$dff0d0,a4
  273.         bne.s    .Return
  274.         move.w    d0,NP_OldVoice4
  275.         tst.w    NP_Voice4
  276.         bne.w    .Voice4On
  277.         moveq    #0,d0
  278. .Voice4On:    move.w    d0,NP_StructAdr+UPS_Voice4Vol
  279.         mulu.w    NP_LeftVol(pc),d0
  280. .SetIt:        lsr.w    #6,d0
  281.         move.w    d0,8(a4)
  282. .Return:    rts
  283.  
  284.  
  285. *--------------------------- Modultyp ⁿberprⁿfen -----------------------------*
  286. NP_Check:    ifeq    test
  287.         move.l    dtg_ChkData(a5),a0
  288.         endc
  289.  
  290.     move.l    a0,a1
  291.     move.l    a0,a2
  292.  
  293.     move.w    (a0),d0        ;Anzahl der Samples
  294.     move.w    d0,d1        ;merken
  295.     and.w    #$f,d0        ;jedes NP Modul beginnt mit
  296.                 ;(Anzahl der Samples*16) OR 12
  297.     cmp.w    #$c,d0        ;ist die 12 vorhanden ?
  298.     bne    .NP_Fail    ;n÷
  299.     lsr.w    #4,d1        ;$c rausrotieren
  300.     cmp.w    #$1f,d1        ;Anzahl der Samples > 32 (0..31)
  301.     bhi    .NP_Fail    ;ja,Fehler
  302.  
  303.     moveq    #0,d2
  304.     move.w    4(a0),d2    ;Offset Patterns
  305.     btst    #0,d2        ;Ungerade ?
  306.     bne    .np_fail    ;->Fehler
  307.     move.l    d2,NP_Numpatts    ;Anzahl Patterns
  308.     add.w    (a0),a1        ;auf Pointer addieren
  309.     move.w    -4(a1),d0    ;H÷chste Patternnummer ist 2 mal eingetragen
  310.     btst    #0,d0        ;Ungerade ?
  311.     bne    .np_fail    ;->Fehler
  312.     cmp.w    2(a0),d0    ;Vergleich
  313.     bne    .NP_fail    ;Unstimmigkeit,Ende der Vorstellung
  314.  
  315.     move.l    a0,a1        ;Pointer auf Modul saven
  316.     add.w    (a1),a0        ;Liste der Patterns fⁿr jeweilige Songposition
  317.     moveq    #0,d1        ;D1 l÷schen
  318.     move.w    -4(a0),d1    ;LΣnge des Songs
  319.     asr.w    #1,d1        ;durch 2 dividieren
  320.     move.l    d1,NP_Infolen    ;SonglΣnge in Patterns (fⁿr Eagleplayer)
  321.     subq.w    #1,d1
  322.                 ;in A0 Zeiger auf Tabelle fⁿr die
  323.                 ;Zeiger auf die Patternnummer fⁿr die
  324.                 ;jeweilige Songposition
  325.  
  326.     moveq    #0,d0
  327.     move.w    d1,d4        ;brauchen wir noch
  328. .check2
  329.     move.w    (a0)+,d3    ;Patternnummer
  330.     cmp.w    d0,d3        ;mit derzeit h÷chster vergleichen
  331.     bls.s    .check1        ;kleiner -> weiter
  332.     move.w    d3,d0        ;h÷chste Patternnr. merken
  333. .check1    dbf    d1,.check2    ;alle Patterns
  334.     addq.l    #8,d0        ;+8
  335.     cmp.w    d0,d2        ;Gegenvergleich
  336.     bne    .np_fail    ;passt nicht -> Fehler
  337.     and.w    #7,d0        ;ausmaskieren (Patternnummer mu▀ durch 8 
  338.                 ;teilbar sein)
  339.     bne    .np_fail    ;nein->Fehler
  340.  
  341.             ;A0 mu▀ hier auf dem Anfang der Offsettabelle der
  342.             ;Patterns stehen
  343.  
  344.     moveq    #0,d0        ;D0 killen
  345.     move.w    (a1),d0        ;Pointer auf Patternliste
  346.     add.w    2(a1),a1    ;LΣnge dieser Patternliste
  347.     add.l    d0,a1        ;zusammenaddieren = Pointer auf Patternoffsets
  348.  
  349.     cmp.l    a0,a1        ;stimmt das ?
  350.     bne    .np_fail    ;wieso auch ?
  351.  
  352. ;an dieser Stelle kann als gesichert gelten,da▀ es sich um ein
  353. ;Noisepackermodul handelt,es bleibt nur die Unterscheidung zum
  354. ;Noisepacker 2
  355.  
  356. ;Trick: beim Noisepacker3 sind die Sampleinfos folgenderma▀en
  357. ;angeordnet :
  358. ;
  359. ;LautstΣrke.w,Adresse.l,LΣnge.w,Repeatadresse.l,RepeatlΣnge.w,Repeatbeginn.w
  360. ;
  361. ;bei Noisepacker 2.02 so:
  362. ;
  363. ;Adresse.l,LΣnge.w,LautstΣrke.w,Repeatadresse.l,RepeatlΣnge.w,Repeatbeginn.w
  364.  
  365.     moveq    #0,d0
  366.     move.w    (a2),d0        ;Anzahl der Sampeles
  367.     lsr.w    #4,d0        ;$c rausrotieren
  368.     move.w    d0,d2        ;fⁿr spΣter aufheben
  369.     move.l    d0,NP_NumSamples;nur fⁿr Eagleplayer wichtig,hat mit Checkrou-
  370.                 ;tine nichts zu tun
  371.     subq.w    #1,d0        ;minus 1 fⁿr DBF-Schleife
  372.  
  373.     lea    8(a2),a0    ;Zeiger auf SampleVolume (NP3)
  374.  
  375.     moveq    #0,d1        ;LΣnge NP3
  376.     moveq    #0,d7        ;...
  377. .np_Getstuff
  378.     moveq    #0,d6        ;...
  379.  
  380.     move.w    6(a0),d6    ;LΣnge NP3
  381.     add.l    d6,d1
  382.  
  383.     cmp.b    #$40,1(a0)    ;LautstΣrke NP3 ⁿberprⁿfen
  384.     bhi    .np_fail    ;gr÷▀er 64 -> Fehler
  385.         ;^- Anmerkung:sollte es sich um ein NP2-Modul handeln,kommt
  386.         ;   es hierzu sowieso erst,wenn das Modul beim Rippen au▀erhalb
  387.         ;   der 4-Megabyte Chipmem Grenze lag (also allein
  388.         ;   AA-Chipset-Rechner - und dann noch nicht mal 1200 und 4000)
  389.     cmp.b    #$F,(a0)    ;Finetune,falls irgendeiner auf die Idee kommt
  390.                 ;und Protrackermodule hiermit packen will
  391.     bhi    .np_fail    ;Finetune bei allen mir bekannten Protrackern
  392.                 ;geht nur bis $F (-8...7)
  393.  
  394.     tst.l    2(a0)        ;Sampleadresse schon mal initialisiert (Modul
  395.                 ;gerippt oder NP2 - Modul) ?
  396.     beq.s    .np3_testwei    ;wenn also eine Null.l steht,hei▀t das:
  397.                 ;Noisepacker 3,weil bei NP2 in unteren Wort
  398.                 ;die LΣnge steht,die immer gr÷▀er 0 ist
  399.  
  400.     tst.l    8(a0)        ;Test,ob Repeatbeginn eingetragen ist,wenn
  401.                 ;nicht,dann ist es kein NP3-Modul,weil bei Init
  402.                 ;der Adresse auch Repeatbeginn gesetzt wird
  403.     beq    .np_fail    ;Fehler
  404.  
  405.     move.w    14(a0),d6    ;RepeatBeginn in Worten
  406.     add.l    d6,d6        ;mal 2 -> Repeatbeginn in Bytes
  407.     move.l    2(a0),d7    ;Samplestart
  408.     add.l    d6,d7        ;Samplestart+Repeatstart
  409.     cmp.l    8(a0),d7    ;Samplestart+Repeatstart = Repeatbeginn im
  410.                 ;Modul
  411.     bne    .np_fail    ;Fehler
  412. .np3_testwei
  413.     addq.l    #8,a0        ;nΣchstes Sample ist 16 Bytes weiter
  414.     addq.l    #8,a0        
  415.  
  416.     dbf    d0,.np_getstuff    ;alle Samples durchgehen
  417.  
  418.     add.l    d1,d1        ;in D1 steht nun die LΣnge des gesamten
  419.                 ;Sampleblockes !
  420.  
  421.     suba.l    a1,a1        ;Moduladresse
  422.     add.w    (a2)+,a1    ;die ersten 4 W÷rter reprΣsentieren
  423.     add.w    (a2)+,a1    ;die gesamte LΣnge des
  424.     add.w    (a2)+,a1    ;Einfⁿhrungsblockes und der Patterns
  425.  
  426.     add.w    (a2)+,a1
  427.     move.l    a1,NP_infosong    ;nur fⁿr Eagleplayer von Nutzen
  428.  
  429.     add.l    d1,a1        ;GesamtlΣnge berechnen
  430.  
  431.     move.l    a1,NP_numall        ;nur fⁿr Eagleplayer von Nutzen
  432.     move.l    d1,NP_infosamples    ;nur fⁿr Eagleplayer von Nutzen
  433.  
  434. ;folgende Routine kann bei Bedarf eingefⁿgt werden,sie testet
  435. ;die LΣnge des berechneten Modules und vergleicht mit den Realwerten
  436. ;    move.l    a1,a2        ;saven
  437. ;    sub.l    #2000,a2    ;~2k nach unten Spielraum,falls falsch gerippt
  438. ;    add.l    #2000,a1    ;~2k nach oben Spielraum,falls falsch gerippt
  439. ;    move.l    dtg_ChkSize(a5),d1    ;LΣnge des getesteten Moduls
  440. ;    cmp.l    a2,d1        ;Vergleich: Realwert und min. Wert
  441. ;    blt.s    .np_fail    ;Fehler
  442. ;    cmp.l    a1,d1        ;Vergleich: Realwert und max. Wert
  443. ;    bgt.s    .np_fail    ;Fehler
  444.  
  445. .NP_ok        moveq    #0,d0
  446.         rts
  447.  
  448. .NP_fail    moveq    #-1,d0            ;fail!
  449.         rts                    ;gone!
  450.  
  451. *--------------------------------------------------------------------------*
  452. Interrupt    movem.l    d0-d7/a0-a6,-(sp)
  453.         lea    NP_StructAdr(pc),a0
  454.         move.w    #UPSB_Adr!UPSB_LEN!UPSB_Per!UPSB_Vol!UPSB_DMACON,UPS_Flags(a0)
  455.         clr.w    UPS_Voice1per(a0)
  456.         clr.w    UPS_Voice2per(a0)
  457.         clr.w    UPS_Voice3per(a0)
  458.         clr.w    UPS_Voice4per(a0)
  459.         move.w    #1,UPS_Enabled(A0)
  460.  
  461.         bsr.w    NP_Music
  462.         lea    NP_StructAdr(pc),a0
  463.         clr.w    UPS_Enabled(A0)
  464.         movem.l    (sp)+,d0-d7/a0-a6
  465.         rts
  466.  
  467. *--------------------------------------------------------------------------*
  468. Initplayer:    moveq    #0,d0
  469.         move.l    dtg_GetListData(a5),a0
  470.         jsr    (a0)
  471.         lea    NP_Data(pc),a1
  472.         move.l    a0,(a1)
  473.         move.l    DTG_SongEnd(a5),NP_SongEndAdr-NP_Data(a1)
  474.         move.l    dtg_AudioAlloc(a5),a0
  475.         jmp    (a0)
  476.  
  477. Endplayer:    move.l    dtg_AudioFree(a5),a0
  478.         jmp    (a0)
  479.  
  480. ;======== Noisepacker III Playroutine (C) Phenomena =========================
  481. np_init        lea    np_datastart(pc),a6
  482.         moveq    #NP_Datalen>>1-1,d0
  483. .clr:        clr.w    (a6)+
  484.         dbf    d0,.clr
  485.  
  486.         moveq    #1,d0
  487.         moveq    #0,d1
  488.  
  489.         move.l    np_data(pc),a4
  490.         lea    $dff000,a5
  491.  
  492.         lea    np_datastart(pc),a6
  493.         move.l    #0,(a6)+
  494.         move.w    d0,(a6)+
  495.  
  496.         move.l    a4,a3
  497.         add.w    (a4)+,a3
  498.         move.l    a3,(a6)+
  499.         move.w    d1,(a6)+
  500.  
  501. np_ini1:        adda.w    (a4)+,a3
  502.         move.l    a3,(a6)+
  503.         dbf    d0,np_ini1
  504.  
  505.         move.w    (a4)+,d0
  506.         adda.l    d0,a3
  507.         move.l    #$82000006,(a6)+
  508.         move.w    #$0100,(a6)+
  509.         move.l    #np_portup,(a6)+
  510.         move.l    #np_portdown,(a6)+
  511.         move.l    #np_port,(a6)+
  512.         move.l    #np_vib,(a6)+
  513.         move.l    #np_port2,(a6)+
  514.         move.l    #np_vib2,(a6)+
  515.         move.l    #np_volslide,(a6)+
  516.         move.l    #np_arp,(a6)+
  517.         move.l    #np_songjmp,(a6)+
  518.         move.l    #np_setvol,(a6)+
  519.         move.l    #np_pattbreak,(a6)+
  520.         move.l    #np_filter,(a6)+
  521.         move.l    #np_setspeed,(a6)+
  522.         moveq    #0,d0
  523.  
  524.         movea.l    a4,a6
  525.  
  526.         adda.w    -8(a4),a6
  527.         suba.w    #12,a6
  528. np_ini2:    move.l    a3,2(a4)
  529.         movea.l    a3,a2
  530.         move.w    14(a4),d0
  531.         add.w    d0,d0
  532.         adda.l    d0,a2
  533.         move.l    a2,8(a4)
  534.         move.w    6(a4),d0
  535.         add.w    d0,d0
  536.         adda.l    d0,a3
  537.         adda.w    #16,a4
  538.         cmpa.l    a4,a6
  539.         bne.b    np_ini2
  540.  
  541.         clr.w    $a8(a5)
  542.         clr.w    $b8(a5)
  543.         clr.w    $c8(a5)
  544.         clr.w    $d8(a5)
  545.         move.w    #$f,$96(a5)
  546.         rts
  547.  
  548.  
  549.  
  550. ;=========================================================================
  551. np_endsnd    lea    np_block+$15(pc),a6
  552.         lea    np_voidat1+128(pc),a2
  553.         moveq    #0,d0
  554.         move.b    d0,(a6)
  555.         move.l    d0,-32(a2)
  556.         move.l    d0,-64(a2)
  557.         move.l    d0,-96(a2)
  558.         move.l    d0,-128(a2)
  559.  
  560.         moveq    #31,d0
  561.         lea    np_voidat1(pc),a0
  562. .npclr        clr.l    (a0)+
  563.         dbf    d0,.npclr
  564.         moveq    #0,d0
  565.         lea    $dff000,a0
  566.         move.l    d0,$a6(a0)
  567.         move.l    d0,$b6(a0)
  568.         move.l    d0,$c6(a0)
  569.         move.l    d0,$d6(a0)
  570.         move.w    #$f,$96(a0)
  571.         rts
  572.  
  573. *----------------------------------------------------------------------------*
  574. np_music    moveq    #0,d6
  575.         lea    $dff0d0,a4
  576.         lea    np_block(pc),a6
  577.         subq.w    #1,(a6)+
  578.         bhi    np_nonew
  579.         movea.l    (a6)+,a1
  580.         adda.w    (a6)+,a1
  581.         movea.l    (a6)+,a0
  582.         adda.w    (a1),a0
  583.         move.l    (a6)+,d2
  584.         movea.l    np_data(pc),a1
  585.         subq.w    #8,a1
  586.         lea    np_voidat1(pc),a2
  587.         moveq    #8,d0
  588.         moveq    #0,d1
  589.         moveq    #0,d4
  590.         moveq    #0,d5
  591.  
  592. np_loop1:    move.w    (a0)+,d1
  593.         tst.w    (a2)+
  594.         bpl.b    np_lop3
  595.         addq.w    #1,-(a2)
  596.         adda.w    #32,a2
  597.         addq.w    #8,a4
  598.         bra    np_lop7
  599.  
  600. np_lop3        movea.l    d2,a3
  601.         adda.l    d1,a3
  602.         adda.w    (a2),a3
  603.         move.b    (a3)+,d1
  604.         bpl.b    np_lop4
  605.         ext.w    d1
  606.         addq.w    #1,d1
  607.         addq.w    #1,(a2)
  608.         move.w    d1,-(a2)
  609.         move.w    d6,8(a2)
  610.         adda.w    #32,a2
  611.         addq.w    #8,a4
  612.         bra    np_lop7
  613.  
  614. np_lop4        move.b    (a3)+,d3
  615.         move.b    (a3)+,d4
  616.         addq.w    #3,(a2)+
  617.         movea.l    a1,a3
  618.         move.b    d1,d7
  619.         lsl.w    #8,d7
  620.         or.b    d3,d7
  621.         andi.w    #$1f0,d7
  622.         bne.b    np_loop3
  623.         adda.w    (a2)+,a3
  624.         addq.w    #2,a2
  625.         addq.w    #2,a3
  626.         bra.b    np_loop4
  627.  
  628. np_loop3:    move.w    d7,(a2)+
  629.         adda.w    d7,a3
  630.         move.w    (a3)+,(a2)+
  631. np_loop4:    andi.w    #$f,d3
  632.         move.w    d3,(a2)+
  633.         move.w    d4,(a2)+
  634.         andi.w    #$fe,d1
  635.         beq.b    np_loop5
  636.         move.w    np_periods-2(pc,d1.w),d7
  637.         subq.w    #3,d3
  638.         beq    np_setport
  639.         subq.w    #2,d3
  640.         beq    np_setport
  641.         or.w    d0,d5
  642.         move.w    d7,(a2)+    ;-6
  643.         move.w    d1,(a2)+    ;-4
  644.         move.w    d6,(a2)+    ;-2
  645.  
  646.         bsr    np_getvoice
  647.                     ;(a2)->Periode
  648.         move.l    (a3)+,(a4)+    ;Adresse          (a3)
  649.         move.w    (a3)+,(a4)+    ;LΣnge/2         4(a3)
  650.         move.l    (a3)+,(a2)+    ;Repeatadresse         6(a3)
  651.         move.w    (a3)+,(a2)+    ;RepeatlΣnge        10(a3)
  652.  
  653.         subq.w    #6,d3
  654.         bmi.b    np_loop6
  655.         add.w    d3,d3
  656.         add.w    d3,d3
  657.         movea.l    38(a6,d3.w),a3
  658.         jmp    (a3)
  659.  
  660. np_loop5    adda.w    #12,a2
  661.         addq.w    #6,a4
  662.         subi.w    #11,d3
  663.         bmi.b    np_loop6
  664.         add.w    d3,d3
  665.         add.w    d3,d3
  666.         movea.l    38(a6,d3.w),a3
  667.         jmp    (a3)
  668.  
  669. np_periods    dc.w    $0358,$0328,$02fa,$02d0,$02a6,$0280,$025c,$023a,$021a
  670.         dc.w    $01fc,$01e0,$01c5,$01ac,$0194,$017d,$0168,$0153,$0140
  671.         dc.w    $012e,$011d,$010d,$00fe,$00f0,$00e2,$00d6,$00ca,$00be
  672.         dc.w    $00b4,$00aa,$00a0,$0097,$008f,$0087,$007f,$0078,$0071
  673.  
  674. NP_setvolume:    move.l    a4,-(sp)
  675.         subq.l    #8,a4
  676.         bsr    NP_SetVoices
  677.         move.l    (sp)+,a4
  678.         rts
  679.  
  680. np_loop6    move.w    -12(a2),(a4)+
  681. np_loop7    ;move.w    -18(a2),(a4)    ;Volume
  682.         move.l    d0,-(sp)
  683.         move.w    -18(a2),d0
  684.         bsr    NP_setvolume
  685.         move.l    (sp)+,d0
  686.         addq.w    #8,a2
  687.         bra.s    np_com
  688.  
  689. np_lop7        ;move.w    -26(a2),(a4)    ;Volume
  690.  
  691.         move.l    d0,-(sp)
  692.         move.w    -26(a2),d0
  693.         bsr    NP_setvolume
  694.         move.l    (sp)+,d0
  695.  
  696. np_com:        suba.w    #$18,a4
  697.         lsr.w    #1,d0
  698.         bne    np_loop1
  699.         move.w    d5,6(a4)
  700.         or.w    d5,(a6)+
  701.         move.w    (a6)+,-20(a6)
  702.         bsr    waitdma
  703.         move.w    np_block+16(pc),$dff096
  704.         bsr    waitdma
  705.         bset    #0,(a6)+
  706.         beq.b    np_break
  707.         addq.b    #1,(a6)
  708.         cmpi.b    #64,(a6)
  709.         bne.b    np_next
  710.  
  711. np_break:    move.b    d6,(a6)
  712.         move.l    d6,-32(a2)
  713.         move.l    d6,-64(a2)
  714.         move.l    d6,-96(a2)
  715.         move.l    d6,-128(a2)
  716.  
  717.         lea    np_block+2(pc),a6
  718.         movea.l    (a6)+,a0
  719.         addq.w    #2,(a6)
  720.         move.w    (a6),d0
  721.         cmp.w    -4(a0),d0
  722.         bne.b    np_next
  723.         move.w    -2(a0),(a6)
  724.  
  725.     ifeq    test
  726.         move.l    NP_SongEndAdr(pc),a0
  727.         jsr    (a0)
  728.     endc
  729.  
  730. np_next        move.l    np_voidat1+18(pc),$dff0d0
  731.         move.w    np_voidat1+22(pc),$dff0d4
  732.         move.l    np_voidat1+50(pc),$dff0c0
  733.         move.w    np_voidat1+54(pc),$dff0c4
  734.         move.l    np_voidat1+82(pc),$dff0b0
  735.         move.w    np_voidat1+86(pc),$dff0b4
  736.         move.l    np_voidat1+114(pc),$dff0a0
  737.         move.w    np_voidat1+118(pc),$dff0a4
  738.         rts
  739.  
  740. np_checkend    bpl    np_notdone
  741. np_notdone    rts
  742.  
  743. np_setvol    move.w    d4,-18(a2)
  744.         bra.w    np_loop6
  745.  
  746. np_pattbreak    move.b    d6,4(a6)
  747.         bra.w    np_loop6
  748.  
  749. np_songjmp    move.b    #63,5(a6)
  750.         move.b    d4,-9(a6)
  751.         bra.w    np_loop6
  752.  
  753. np_setspeed    move.w    d4,2(a6)
  754.         bra    np_loop6
  755.  
  756. np_filter    ;andi.b    #$fd,$bfe001
  757.     ;    or.b    d4,$bfe001
  758.         bra    np_loop6
  759.  
  760. np_setport    adda.w    #12,a2
  761.         addq.w    #8,a4
  762.         cmp.w    -12(a2),d7
  763.         slt    (a2)
  764.         beq.b    np_clear
  765.         move.w    d7,2(a2)
  766.         bra    np_loop7
  767.  
  768. np_clear    move.w    d6,2(a2)
  769.         bra    np_loop7
  770.  
  771. np_nonew    lea    np_voidat1(pc),a0
  772.         moveq    #3,d0
  773. np_lop1        move.w    8(a0),d1
  774.         beq.w    np_lop2
  775.         subq.w    #8,d1
  776.         bhi.w    np_lop2
  777.         addq.w    #7,d1
  778.         add.w    d1,d1
  779.         add.w    d1,d1
  780.         movea.l    20(a6,d1.w),a3
  781.         jmp    (a3)
  782.  
  783. np_lop2:    adda.w    #32,a0
  784.         suba.w    #$10,a4
  785.         dbf    d0,np_lop1
  786.         rts
  787.  
  788. np_portup:    move.w    10(a0),d2
  789.         sub.w    d2,12(a0)
  790.         cmpi.w    #$71,12(a0)
  791.         bpl.b    np_portup2
  792.         move.w    #$71,12(a0)
  793.  
  794. np_portup2:    move.w    12(a0),6(a4)
  795.         bra.b    np_lop2
  796.  
  797. np_portdown:    move.w    10(a0),d2
  798.         add.w    d2,12(a0)
  799.         cmpi.w    #$358,12(a0)
  800.         bmi.b    np_portdown2
  801.         move.w    #$358,12(a0)
  802.  
  803. np_portdown2:    move.w    12(a0),6(a4)
  804.         bra.b    np_lop2
  805.  
  806. np_arp:        move.w    -2(a6),d2
  807.         sub.w    16(a6),d2
  808.         neg.w    d2
  809.         move.b    np_arplist(pc,d2.w),d2
  810.         beq.b    np_arp0
  811.         subq.w    #2,d2
  812.         beq.b    np_arp2
  813.  
  814. np_arp1        move.w    10(a0),d2
  815.         lsr.w    #3,d2
  816.         andi.w    #$e,d2
  817.         bra.b    np_arp3
  818.  
  819. np_arp2        move.w    10(a0),d2
  820.         andi.w    #$f,d2
  821.         add.w    d2,d2
  822. np_arp3        add.w    14(a0),d2
  823.         cmpi.w    #$48,d2
  824.         bls.b    np_arp4
  825.         moveq    #$48,d2
  826. np_arp4        lea    np_periods-2(pc),a3
  827.         move.w    (a3,d2.w),6(a4)
  828.         bra    np_lop2
  829.  
  830. np_arp0        move.w    12(a0),6(a4)
  831.         bra    np_lop2
  832.  
  833. np_arplist    dc.b 0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1,2,0,1
  834. np_sin        dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1,$b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
  835.         dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5,$b4,$a1,$8d,$78,$61,$4a,$31,$18
  836.  
  837. np_vib        move.w    10(a0),d3
  838.         beq.b    np_vib2
  839.         move.w    d3,30(a0)
  840. np_vib2        move.w    16(a0),d3
  841.         lsr.w    #2,d3
  842.         andi.w    #$1f,d3
  843.         moveq    #0,d2
  844.         move.b    np_sin(pc,d3.w),d2
  845.         move.w    30(a0),d3
  846.         andi.w    #$f,d3
  847.         mulu.w    d3,d2
  848.         lsr.w    #7,d2
  849.         move.w    12(a0),d3
  850.         tst.b    17(a0)
  851.         bmi.b    np_vibsub
  852.         add.w    d2,d3
  853.         bra.b    np_vib3
  854.  
  855. np_vibsub:    sub.w    d2,d3
  856. np_vib3        move.w    d3,6(a4)
  857.         move.w    30(a0),d3
  858.         lsr.w    #2,d3
  859.         andi.w    #$3c,d3
  860.         add.b    d3,17(a0)
  861.         cmpi.b    #20,d1
  862.         bne    np_lop2
  863.  
  864. np_volslide:    move.w    10(a0),d2
  865.         add.b    d2,7(a0)
  866.         bmi.b    np_vol3
  867.         cmpi.w    #$40,6(a0)
  868.         bmi.b    np_vol2
  869.         move.w    #$40,6(a0)
  870. np_vol2    ;    move.w    6(a0),8(A4)
  871.         move.l    d0,-(sp)
  872.         move.w    6(a0),d0
  873.         bsr    NP_setvoices
  874.         move.l    (sp)+,d0
  875.         bra    np_lop2
  876.  
  877. np_vol3        move.w    d6,6(a0)
  878.         bra.s    NP_vol2
  879.  
  880. np_port        move.w    10(a0),d2
  881.         beq.b    np_port2
  882.         move.w    d2,28(a0)
  883.  
  884. np_port2:    move.w    26(a0),d2
  885.         beq.b    np_rts
  886.         move.w    28(a0),d3
  887.         tst.w    24(a0)
  888.         bne.b    np_sub
  889.         add.w    d3,12(a0)
  890.         cmp.w    12(a0),d2
  891.         bgt.b    np_portok
  892.         move.w    d2,12(a0)
  893.         move.w    d6,26(a0)
  894.  
  895. np_portok:    move.w    12(a0),6(a4)
  896. np_rts        cmpi.b    #16,d1
  897.         beq.b    np_volslide
  898.         bra    np_lop2
  899.  
  900. np_sub        sub.w    d3,12(a0)
  901.         cmp.w    12(a0),d2
  902.         blt.b    np_portok
  903.         move.w    d2,12(a0)
  904.         move.w    d6,26(a0)
  905.         move.w    12(a0),6(a4)
  906.         cmpi.b    #16,d1
  907.         beq    np_volslide
  908.         bra    np_lop2
  909.  
  910. waitdma        movem.l    d0-d1,-(sp)
  911.         moveq    #7,d0
  912. .wait1        move.b    $dff006,d1
  913. .wait2        cmp.b    $dff006,d1
  914.         beq    .wait2
  915.         dbra    d0,.wait1
  916.         movem.l    (sp)+,d0-d1
  917.         rts
  918.  
  919. np_datastart    dc.l    0
  920. np_block    ds.l    19
  921. np_voidat1    ds.l    32
  922.         dc.l    0
  923. NP_Datalen=*-np_datastart
  924.     ifne    test
  925. Mod
  926.     incdir    vr0:
  927. ;    incbin    Np3.agnostica
  928.     incbin    Np3.quartz
  929.     endc
  930.