home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / utilities / cdrom / jukeboxprog.lha / Prog-Gui.s < prev    next >
Encoding:
Text File  |  1994-12-17  |  9.6 KB  |  555 lines

  1. * sorry, comments only german.
  2. * see docs for details
  3. * © Patrick Kursawe 1994
  4.  
  5. * assemblieren mit a68k und blink
  6. * Das GUI zum JukeBox-Programmieren ! (JukeBox © by Franz-Josef Reichert)
  7. * Eingabe durch t:toc (Format: Titel,0,Titel,...,0)
  8. * Ausgabe in t:jb.tracks (Format: Track,10,Track,10...)
  9.  
  10.  
  11.     include exec/memory.i
  12.     include dos/dos.i
  13.     include exec/lists.i
  14.     include exec/nodes.i
  15.     include intuition/intuition.i
  16.     include libraries/gadtools.i
  17.     include libraries_lib.i        * Einsprünge, geändert. Für Standard-Includes _LVO Davor!
  18. st
  19.     move.l 4,a6
  20.     lea iname,a1
  21.     move.l #37,d0
  22.     jsr OpenLibrary(a6)
  23.     move.l d0,ibase
  24.     beq closelibs
  25.     lea dname,a1
  26.     move.l #37,d0
  27.     jsr OpenLibrary(a6)
  28.     move.l d0,dbase
  29.     beq closelibs
  30.     lea gadtoolsname,a1
  31.     move.l #37,d0
  32.     jsr OpenLibrary(a6)
  33.     move.l d0,gadtoolsbase
  34.     beq closelibs
  35.     jsr PrepareLists
  36.     cmp.l #1,d0
  37.     bne closelibs
  38.     move.l ibase,a6
  39.     lea newwin,a0
  40.     jsr OpenWindow(a6)
  41.     move.l d0,window
  42.     beq closelibs
  43.     move.l d0,a0
  44.     move.l wd_WScreen(a0),a0
  45.     move.l gadtoolsbase,a6
  46.     sub.l a1,a1
  47.     jsr GetVisualInfoA(a6)
  48.     move.l d0,vi
  49.     beq closewin
  50.     lea list1,a0
  51.     move.l d0,gng_VisualInfo(a0)
  52.     lea list2,a0
  53.     move.l d0,gng_VisualInfo(a0)
  54. * Koordinaten korregieren
  55.     move.l window,a0
  56.     lea list1,a1
  57.     clr.l d0
  58.     move.b wd_BorderTop(a0),d0
  59.     add.w #20,d0
  60.     move.w d0,gng_TopEdge(a1)
  61.     move.l #100,d0
  62.     sub.w gng_TopEdge(a1),d0
  63.     move.w d0,gng_Height(a1)
  64. * soll reichen, jetzt Gadgets erstellen und einbinden        
  65.     lea glistptr,a0
  66.     jsr CreateContext(a6)
  67.     move.l d0,context
  68.     beq closewin
  69.     move.l #LISTVIEW_KIND,d0
  70.     move.l context,a0
  71.     lea list1,a1
  72.     lea ggtags1,a2
  73.     jsr CreateGadgetA(a6)
  74.     tst.l d0
  75.     beq closewin
  76.     move.l d0,a0
  77.     move.l d0,gg1ptr
  78.     move.l #LISTVIEW_KIND,d0
  79.     lea list2,a1
  80.     lea ggtags2,a2
  81.     jsr CreateGadgetA(a6)
  82.     tst.l d0
  83.     beq closewin
  84.     move.l d0,gg2ptr
  85.     move.l ibase,a6
  86.     move.l window,a0
  87.     move.l glistptr,a1
  88.     move.l #0,a2
  89.     move.l #0,d0
  90.     move.l #-1,d1
  91.     jsr AddGList(a6)
  92.     move.l gadtoolsbase,a6
  93.     move.l window,a0
  94.     move.l #0,a1
  95.     jsr GT_RefreshWindow(a6)
  96.     move.l ibase,a6
  97.     move.l glistptr,a0
  98.     move.l window,a1
  99.     move.l #0,a2
  100.     jsr RefreshGadgets(a6)
  101.     move.l window,a0
  102.     move.l wd_UserPort(a0),d7
  103. waitport
  104.     move.l 4,a6
  105.     move.l d7,a0
  106.     jsr WaitPort(a6)
  107.     move.l d7,a0
  108.     move.l gadtoolsbase,a6
  109.     jsr GT_GetIMsg(a6)
  110.     tst.l d0
  111.     beq waitport
  112.     move.l d0,a1
  113.     move.l im_Class(a1),class
  114.     move.w im_Code(a1),code
  115.     move.l im_IAddress(a1),address
  116.     move.l class,d0
  117.     and.l #IDCMP_GADGETUP,d0
  118.     tst.l d0
  119.     beq zurück
  120.     clr.l d0
  121.     move.w code,d0
  122.     move.l d0,num
  123. zurück
  124.     jsr GT_ReplyIMsg(a6)
  125.     cmp.l #IDCMP_CLOSEWINDOW,class
  126.     beq ende_der_eingabe
  127.     move.l class,d0
  128.     and.l #IDCMP_GADGETUP,d0
  129.     tst.l d0
  130.     beq weiterparsen
  131.     move.l address,a0
  132.     clr.l d0
  133.     move.w gg_GadgetID(a0),d0
  134.     move.l num,d1
  135.     jsr Program
  136. weiterparsen
  137.     bra waitport
  138. ende_der_eingabe
  139.     jsr Rettet_Die_Eingaben
  140.     jsr freememlist1
  141. closewin
  142.     move.l ibase,a6
  143.     move.l window,a0
  144.     jsr CloseWindow(a6)
  145.     move.l gadtoolsbase,a6
  146.     move.l glistptr,a0
  147.     jsr FreeGadgets(a6)
  148.     move.l vi,a0
  149.     jsr FreeVisualInfo(a6)
  150. closelibs
  151.     move.l 4,a6
  152.     move.l ibase,a1
  153.     jsr CloseLibrary(a6)
  154.     move.l dbase,a1
  155.     jsr CloseLibrary(a6)
  156.     move.l gadtoolsbase,a1
  157.     jsr CloseLibrary(a6)
  158.     move.l rec,d0
  159.     rts
  160.  
  161. *** die listnodes aus Textdatei erstellen und eintragen ***
  162. PrepareLists
  163.     move.l #0,preperr
  164.     move.l dbase,a6
  165.     move.l #DOS_FIB,d1
  166.     clr.l d2
  167.     jsr AllocDosObject(a6)
  168.     move.l d0,fib
  169.     beq ex_no_fib
  170.     move.l #inputname,d1
  171.     move.l #MODE_OLDFILE,d2
  172.     jsr Open(a6)
  173.     move.l d0,inputhandle
  174.     bne InputOpen
  175.     move.l #2,preperr
  176.     bra freefib
  177. InputOpen
  178.     move.l d0,d1
  179.     move.l fib,d2
  180.     jsr ExamineFH(a6)
  181.     move.l fib,a0
  182.     move.l fib_Size(a0),d0
  183.     move.l d0,inputlen
  184.     move.l #MEMF_CLEAR,d1
  185.     move.l 4,a6
  186.     jsr AllocVec(a6)
  187.     move.l d0,filebuffer
  188.     bne HabInBuffer
  189.     move.l #2,preperr
  190.     bra CloseInput
  191. HabInBuffer
  192.     move.l dbase,a6
  193.     move.l inputhandle,d1
  194.     move.l filebuffer,d2
  195.     move.l inputlen,d3
  196.     jsr Read(a6)
  197.  
  198. CloseInput
  199.     move.l dbase,a6
  200.     move.l inputhandle,d1
  201.     jsr Close(a6)
  202. freefib
  203.     move.l dbase,a6
  204.     move.l fib,d2
  205.     move.l #DOS_FIB,d1
  206.     jsr FreeDosObject(a6)    
  207.     cmp.l #2,preperr
  208.     beq freememlist1
  209.     lea list1header,a5
  210.     move.l filebuffer,a4
  211.     move.l 4,a6    
  212.     move.l #LN_SIZE,d0
  213.     move.l #MEMF_CLEAR,d1
  214.     jsr AllocVec(a6)
  215.     move.l d0,LH_HEAD(a5)
  216.     beq freememlist1
  217.     move.l filebuffer,d7
  218.     add.l inputlen,d7
  219. * d7: Position für Dateiende
  220. * a4: Aktuelle Position in Datei
  221. * a5: aktuelle ListNode
  222.  
  223.     move.l d0,a5
  224.     move.l a4,LN_NAME(a5)
  225. makenodes
  226.     cmp.l a4,d7
  227.     bls Liste1Fertig
  228.     cmp.b #0,(a4)+
  229.     beq nexttext
  230.     bra makenodes
  231. nexttext
  232.     move.l #LN_SIZE,d0
  233.     move.l #MEMF_CLEAR,d1
  234.     jsr AllocVec(a6)
  235.     move.l d0,LN_SUCC(a5)
  236.     beq freememlist1
  237.     move.l a5,d1 
  238. * Jetzt alte Node in d1
  239.     move.l d0,a5
  240. * neue in a5
  241.     move.l d1,LN_PRED(a5)
  242.     move.l a4,LN_NAME(a5)
  243.     bra makenodes
  244. Liste1Fertig
  245.     move.l a5,lastentry
  246.     lea list1header,a0
  247.     move.l a5,LH_TAILPRED(a0)
  248.     move.l #1,d0
  249.     rts
  250.  
  251. freememlist1
  252. * FileBuffer und komplette Liste freigeben
  253.     move.l 4,a6
  254.     move.l filebuffer,a1
  255.     jsr FreeVec(a6)
  256.     lea list1header,a0
  257. letzter
  258.     move.l lastentry,a5
  259. letzterloop
  260.     cmp.l #0,a5
  261.     beq liste2checken
  262.     move.l a5,a1
  263.     move.l LN_PRED(a5),a5
  264.     jsr FreeVec(a6)
  265.     bra letzterloop
  266. liste2checken
  267.     move.l last2entry,a5
  268. clear2loop
  269.     cmp.l #0,a5
  270.     beq ex_no_fib
  271.     move.l a5,a1
  272.     move.l LN_PRED(a5),a5
  273.     jsr FreeVec(a6)
  274.     bra clear2loop
  275. ex_no_fib
  276.     move.l preperr,d0
  277.     rts
  278. Rettet_Die_Eingaben
  279.     move.l dbase,a6
  280.     move.l #outputname,d1
  281.     move.l #MODE_NEWFILE,d2
  282.     jsr Open(a6)
  283.     tst.l d0
  284.     beq nixzuretten
  285.     move.l d0,d7
  286.     lea list2header,a5
  287.     move.l LH_HEAD(a5),a5
  288. rausloop
  289.     cmp.l #0,a5
  290.     beq ausgabezu
  291.     clr.l d0
  292.     move.b LN_PRI(a5),d0
  293.     tst.l d0
  294.     beq ausgabezu
  295.     move.l d7,d1
  296.     move.w d0,char
  297.     move.l #char,d3
  298.     move.l #format,d2
  299.     jsr VFPrintf(a6)
  300.     cmp.l #-1,d0
  301.     beq ausgabezu
  302.     move.l LN_SUCC(a5),a5
  303.     bra rausloop 
  304. ausgabezu
  305.     move.l d7,d1
  306.     jsr Close(a6)
  307. nixzuretten
  308.     rts
  309. Program
  310.     clr.l d6
  311.     cmp.l #1,d0
  312.     beq Zufügen
  313.     cmp.l #2,d0
  314.     beq entfernen
  315.     rts
  316. Zufügen
  317.     move.l #1,d6
  318.     move.l d1,d0
  319.     lea list1header,a0
  320.     jsr FindNodeNum
  321.     cmp.l #0,a0
  322.     beq progfertig
  323.     move.l a0,a5
  324.     move.l 4,a6
  325.     move.l #LN_SIZE,d0
  326.     move.l #MEMF_CLEAR,d1
  327.     jsr AllocVec(a6)
  328.     tst.l d0
  329.     beq progfertig
  330.     move.l num,d1
  331.     addq.l #1,d1
  332. ** Titelnummer
  333.     cmp.l #0,last2entry
  334.     beq istdererstezumzufügen
  335.     move.l last2entry,a0
  336.     move.l d0,LN_SUCC(a0)
  337.     move.l d0,a1
  338.     move.b d1,LN_PRI(a1)
  339.     move.l a0,LN_PRED(a1)
  340.     move.l LN_NAME(a5),d0
  341.     move.l d0,LN_NAME(a1)
  342.     move.l a1,last2entry
  343.     lea dummyentry,a0
  344.     move.l a0,LN_SUCC(a1)
  345.     move.l a1,LN_PRED(a0)
  346.     bra progfertig
  347. istdererstezumzufügen
  348.     move.l d0,last2entry
  349.     lea list2header,a0
  350.     move.l d0,LH_HEAD(a0)
  351.     move.l d0,a1
  352.     move.b d1,LN_PRI(a1)
  353.     move.l LN_NAME(a5),d0
  354.     move.l d0,LN_NAME(a1)
  355.     lea dummyentry,a0
  356.     move.l a0,LN_SUCC(a1)
  357.     move.l a1,LN_PRED(a0)
  358. progfertig
  359.     move.l gadtoolsbase,a6
  360.     move.l gg2ptr,a0
  361.     move.l window,a1
  362.     sub.l a2,a2
  363.     lea ggtags2,a3
  364.     jsr GT_SetGadgetAttrsA(a6)
  365.     tst.l d6
  366.     beq novis
  367.     move.l gg2ptr,a0
  368.     move.l window,a1
  369.     sub.l a2,a2
  370.     lea vistag,a3
  371.     jsr  GT_SetGadgetAttrsA(a6)
  372. novis
  373.     move.l ibase,a6
  374.     move.l gg2ptr,a0
  375.     move.l window,a1
  376.     sub.l a2,a2
  377.     jsr RefreshGadgets(a6)
  378.     rts
  379. entfernen
  380. * entfernen des angeklickten Punktes aus der Liste
  381.     move.l 4,a6
  382.     move.l d1,d0
  383.     lea list2header,a0
  384.     jsr FindNodeNum
  385.     cmp.l #0,a0
  386.     beq progfertig
  387.     move.l last2entry,d0
  388.     cmp.l a0,d0
  389.     beq warderletzte
  390.     move.l a0,a1
  391.     move.l LN_PRED(a1),a0
  392.     move.l LN_SUCC(a1),a2
  393.     cmp.l #0,a0
  394.     beq keinpred
  395.     move.l a2,LN_SUCC(a0)
  396. succändern
  397.     move.l a0,LN_PRED(a2)
  398.     jsr FreeVec(a6)
  399.     bra progfertig
  400. warderletzte
  401.     cmp.l #0,LN_PRED(a0)
  402.     beq ganzallein
  403.     move.l LN_PRED(a0),a1
  404.     move.l a1,last2entry
  405.     lea dummyentry,a2
  406.     move.l a1,LN_PRED(a2)
  407.     move.l a2,LN_SUCC(a1)
  408.     move.l a0,a1
  409.     jsr FreeVec(a6)
  410.     bra progfertig
  411. ganzallein
  412.     lea dummyentry,a1
  413.     move.l #0,LN_PRED(a1)
  414.     lea list2header,a1
  415.     move.l #0,LH_HEAD(a1)
  416.     move.l #0,last2entry
  417.     move.l a0,a1
  418.     jsr FreeVec(a6)
  419.     bra progfertig
  420. keinpred
  421.     lea list2header,a0
  422.     move.l #0,LN_PRED(a2)
  423.     move.l a2,LH_HEAD(a0)
  424.     jsr FreeVec(a6)
  425.     bra progfertig
  426. FindNodeNum
  427. ** Diese Routine sucht die Node Nr x (ab 0)
  428. * header in a0
  429. * num in d0
  430. * adresse in a0 zurück oder 0
  431.     cmp.l #0,LH_HEAD(a0)
  432.     beq nix
  433.     move.l LH_HEAD(a0),a0
  434. suchnodeloop
  435.     cmp.l #0,d0
  436.     beq gefunden
  437.     move.l LN_SUCC(a0),a0
  438.     cmp.l #0,a0
  439.     beq gefunden
  440.     subq.l #1,d0
  441.     bra suchnodeloop
  442. gefunden
  443.     rts
  444. nix
  445.     clr.l d0
  446.     rts
  447. ** Ende von FindNodeNum
  448. ggtags1
  449.     dc.l GTLV_Labels,list1header,TAG_DONE
  450. ggtags2
  451.     dc.l GTLV_Labels,list2header,TAG_DONE
  452. vistag
  453.     dc.l GTLV_MakeVisible
  454. visnum
  455.     dc.l %111111111111111,TAG_DONE   * Ganz große Numer, damit man nicht immer die höchste angeben muß!
  456. list1header
  457.     dc.l 0,0,0
  458.     dc.b 0,0
  459. list2header
  460.     dc.l 0,0,0
  461.     dc.b 0,0
  462. last2entry
  463.     dc.l 0
  464.  
  465. dummyentry
  466.     dc.l 0,0
  467.     dc.b 0,0
  468.     dc.l 0
  469. lastentry
  470.     dc.l 0
  471. rec
  472.     dc.l 0
  473. list1
  474.     dc.w 10,30,340,75
  475.     dc.l list1label,0
  476.     dc.w 1
  477.     dc.l PLACETEXT_ABOVE,0,0
  478. list2
  479.     dc.w 10,115,340,65
  480.     dc.l list2label,0
  481.     dc.w 2
  482.     dc.l PLACETEXT_ABOVE,0,0    
  483. newwin
  484.     dc.w 0,10,360,190
  485.     dc.b -1,-1
  486.     dc.l LISTVIEWIDCMP|IDCMP_CLOSEWINDOW,WFLG_ACTIVATE|WFLG_DRAGBAR|WFLG_CLOSEGADGET|WFLG_DEPTHGADGET
  487.     dc.l 0,0,wintitle,0,0,-1,-1
  488.     dc.w PUBLICSCREEN
  489. inputname
  490.     dc.b "T:jb.toc",0
  491. outputname
  492.     dc.b "T:jb.tracks",0
  493. wintitle
  494.     dc.b "JukeBox®-Programmer ©P.Kursawe 1994",0 ; DO NOT CHANGE!
  495.     dc.b "$VER: JukeBoxProg by Patrick Kursawe 1.0 1994",0
  496. dname
  497.     dc.b "dos.library",0
  498. iname
  499.     dc.b "intuition.library",0
  500. gadtoolsname
  501.     dc.b "gadtools.library",0    
  502. list1label
  503.     dc.b "Track auswählen",0  ;Select Track
  504. list2label
  505.     dc.b "Bisher gewählt",0   ;Already chosen
  506. format
  507.     dc.b "%d",10,0
  508.     bss
  509.  
  510. * diese ganzen Nullen sind sicher nicht sehr elegant, aber ich wollte das Programm eigentlich
  511. * nur schnell fertig haben. Speicher belegen und relativ adressieren kann das Ganze
  512. * kürzer und schneller machen. bss verhindert aber das schlimmste
  513. char
  514.     dc.w 0
  515. gg1ptr
  516.     dc.l 0
  517. gg2ptr
  518.     dc.l 0
  519. filebuffer
  520.     dc.l 0
  521. inputlen
  522.     dc.l 0
  523. preperr
  524.     dc.l 0
  525. inputhandle
  526.     dc.l 0
  527. outputhandle
  528.     dc.l 0
  529. fib
  530.     dc.l 0
  531. glistptr
  532.     dc.l 0
  533. context
  534.     dc.l 0
  535. vi
  536.     dc.l 0
  537. num
  538.     dc.l 0
  539. class
  540.     dc.l 0
  541. code
  542.     dc.w 0
  543. address
  544.     dc.l 0
  545. window
  546.     dc.l 0
  547. gadtoolsbase
  548.     dc.l 0
  549. dbase
  550.     dc.l 0
  551. ibase
  552.     dc.l 0
  553.  
  554.     end
  555.