home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / utilities / guide / minixpkguide.lha / MiniXpkGuide.S < prev    next >
Encoding:
Text File  |  1995-03-09  |  5.4 KB  |  218 lines

  1. *****************************************
  2. *        MiniXpkGuide        *
  3. * Small AmigaGuide-viewer with XPK sup.    *
  4. *    V1.0 by Martin Gierich        *
  5. *    Last change:07.03.95        *
  6. *****************************************
  7.  
  8. ;Can be started from WB and CLI
  9. ;Tabsize=8
  10.  
  11. ;exec
  12. _LVOOpenLibrary        = -552
  13. _LVOOldOpenLibrary    = -408
  14. _LVOCloseLibrary    = -414
  15. _LVOFindTask        = -294
  16. _LVOWaitPort        = -384
  17. _LVOGetMsg        = -372
  18. _LVOReplyMsg        = -378
  19. _LVOForbid        = -132
  20.  
  21. ;xpkmaster
  22. _LVOXpkExamine        = -36
  23. _LVOXpkUnpack        = -48
  24.  
  25. ;amigaguide
  26. _LVOOpenAmigaGuideA    = -54
  27. _LVOCloseAmigaGuide    = -66
  28.  
  29. ;dos
  30. _LVODeleteFile        = -72
  31. _LVOReadArgs        = -798
  32. _LVOFreeArgs        = -858
  33.  
  34.  
  35. XPK_InName    = $80005851    filename
  36. XPK_OutName    = $80005860    filename
  37. XPK_GetError    = $80005875    buffer
  38. XPK_TaskPri    = $8000587f    ubyte
  39.  
  40.         RSRESET
  41. ;NewAmigaGuide-structure
  42. nag_Lock    RS.L    1    Lock on the document directory
  43. nag_Name    RS.L    1    Name of document file
  44. nag_Screen    RS.L    1    Screen to place windows within
  45. nag_PubScreen    RS.L    1    Public screen name to open on
  46. nag_HostPort    RS.L    1    Application's ARexx port name
  47. nag_ClientPort    RS.L    1    Name to assign to the clients ARexx port
  48. nag_BaseName    RS.L    1    Base name of the application
  49. nag_Flags    RS.L    1    Flags
  50. nag_Context    RS.L    1    NULL terminated context table
  51. nag_Node    RS.L    1    Node to align on first (defaults to Main)
  52. nag_Line    RS.L    1    Line to align on
  53. nag_Extens    RS.L    1    Tag array extens
  54. nag_Client    RS.L    1    Private! MUST be NULL
  55. NewAmigaGuide_SIZEOF    RS.W    0
  56.  
  57. TagSize        = 3*2+1        longwords for tags
  58. NameSize    = 12        for new filename
  59. ArraySize    = 32        must be multiple of 16
  60. AllSize        = NewAmigaGuide_SIZEOF+TagSize*4+NameSize+ArraySize
  61.  
  62. pr_CLI        = 172
  63. pr_MsgPort    = 92
  64. pr_CurrentDir    = 152
  65. sm_NumArgs    = 28
  66. sm_ArgList    = 36
  67.  
  68.  
  69.  
  70. ;d0-d3:scratch
  71. ;d4=RdArgs-struct
  72. ;d5=Return-code
  73. ;d6=WB-message
  74. ;d7=filename of guide
  75.  
  76. ;a0-a2:scratch
  77. ;a3=temporary filename
  78. ;a4=this task
  79. ;a5=dos-base
  80.  
  81.  
  82. ;init place for needed structures on stack
  83. start    moveq    #20,d5        ;set return-code to FAIL
  84.     moveq    #AllSize/4-1,d0
  85. .Wdh    clr.l    -(sp)        ;get some space for nag
  86.     dbra    d0,.Wdh
  87.     move.l    4.w,a6        ;exec-base to a6
  88.     lea    DosName(pc),a1
  89.     moveq    #36,d0        ;check for OS2.0+
  90.     jsr    _LVOOpenLibrary(a6)    ;open dos.library (in ROM)
  91.     move.l    d0,a5        ;a5=dos-base
  92.  
  93. ;create unique temporary filename in T:
  94.     sub.l    a1,a1
  95.     jsr    _LVOFindTask(a6)    ;find this task
  96.     move.l    d0,a4        ;a4=this task
  97.     lea    NewAmigaGuide_SIZEOF+TagSize*4(sp),a1
  98.     move.l    a1,a3
  99.     move.w    #"T:",(a1)+    ;unpack to T: dir
  100.     moveq    #7,d1        ;create unique name using the task adr.
  101. .Nib    move.b    d0,(a1)
  102.     and.b    #$0f,(a1)
  103.     add.b    #"J",(a1)+    ;use "J" to "Y" for each nibble
  104.     ror.l    #4,d0
  105.     dbra    d1,.Nib        ;do it for all 8 nibbles
  106.  
  107. ;check for WB or CLI start
  108.     moveq    #0,d4        ;reset Rdargs-struct
  109.     moveq    #0,d6        ;reset WB-msg
  110.     tst.l    pr_CLI(a4)    ;a4=this task
  111.     bne.s    .CLI
  112. .WB    lea    pr_MsgPort(a4),a0    ;it was WB-start
  113.     jsr    _LVOWaitPort(a6)
  114.     lea    pr_MsgPort(a4),a0
  115.     jsr    _LVOGetMsg(a6)
  116.     move.l    d0,d6        ;d6=message from WB
  117.     move.l    d0,a0
  118.     moveq    #2,d0
  119.     cmp.l    sm_NumArgs(a0),d0
  120.     bne    .Ende
  121.     move.l    sm_ArgList(a0),a1
  122.     addq.l    #8,a1
  123.     move.l    (a1)+,pr_CurrentDir(a4)    ;Lock on Current Dir
  124.     move.l    (a1),d7        ;filename to d7
  125.     bra.s    .UnPack
  126.  
  127. .CLI    move.l    a5,a6            ;started from CLI
  128.     lea    Template(pc),a0
  129.     move.l    a0,d1
  130.     lea    NewAmigaGuide_SIZEOF+TagSize*4+NameSize(sp),a2
  131.     move.l    a2,d2            ;a2=arg-array
  132.     moveq    #0,d3
  133.     jsr    _LVOReadArgs(a6)    ;process argumentline
  134.     move.l    d0,d4            ;d4=RdArgs-struct
  135.     beq    .Ende
  136.     move.l    (a2),d7            ;filename to d7
  137.     move.l    4(a2),nag_Node(sp)
  138.     move.l    8(a2),d0        ;pointer to linenumber ?
  139.     beq.s    .NoLine
  140.     move.l    d0,a0
  141.     move.l    (a0),nag_Line(sp)
  142. .NoLine    move.l    12(a2),nag_PubScreen(sp)
  143.     move.l    16(a2),nag_ClientPort(sp)
  144.  
  145. ;try to unpack file to temporary file, will fail if not packed
  146. .UnPack    move.l    4.w,a6        ;exec-base to a6
  147.     lea    XpkName(pc),a1
  148.     jsr    _LVOOldOpenLibrary(a6)
  149.     tst.l    d0
  150.     beq.s    .Show        ;opened xpkmaster.library ?
  151.     move.l    d0,a6
  152.     lea    NewAmigaGuide_SIZEOF(sp),a0    ;create tags-field
  153.     move.l    #XPK_InName,(a0)
  154.     move.l    d7,4(a0)    ;filename from argumentline
  155.     move.l    #XPK_OutName,8(a0)
  156.     move.l    a3,12(a0)    ;unique self-done filename
  157.     move.l    #XPK_TaskPri,16(a0)
  158.     moveq    #-1,d0
  159.     move.l    d0,20(a0)    ;unpack in background
  160.     jsr    _LVOXpkUnpack(a6)
  161.     tst.l    d0
  162.     bne.s    .NoPack
  163.     move.l    a3,d7        ;only replace filename if it succeded
  164. .NoPack    move.l    a6,a1
  165.     move.l    4.w,a6
  166.     jsr    _LVOCloseLibrary(a6)
  167.  
  168. ;show file using amigaguide.library
  169. .Show    lea    GuideName(pc),a1
  170.     jsr    _LVOOldOpenLibrary(a6)
  171.     tst.l    d0
  172.     beq.s    .Ende        ;opened amigaguide.library ?
  173.     move.l    d0,a6
  174.     move.l    d7,nag_Name(sp)    ;filename into nag
  175.     move.l    sp,a0        ;nag to a0
  176.     sub.l    a1,a1        ;must be zero
  177.     jsr    _LVOOpenAmigaGuideA(a6)    ;open guide
  178.     tst.l    d0
  179.     beq.s    .NoGuid        ;failed to open guide ?
  180.     move.l    d0,a0
  181.     jsr    _LVOCloseAmigaGuide(a6)    ;wait till user closes guide
  182.     moveq    #0,d5        ;set return-code to OK
  183. .NoGuid    move.l    a6,a1        ;Free all stuff
  184.     move.l    4.w,a6
  185.     jsr    _LVOCloseLibrary(a6)
  186.  
  187. ;clean up all things used
  188. .Ende    move.l    a5,a6        ;dos-base to a6
  189.     cmp.l    d7,a3        ;unpacked file ?
  190.     bne.s    .NoDel
  191.     move.l    a3,d1
  192.     jsr    _LVODeleteFile(a6)    ;yes, delete it
  193. .NoDel    move.l    d4,d1
  194.     beq.s    .NoFree
  195.     jsr    _LVOFreeArgs(a6)    ;free RdArgs-struct, if needed
  196. .NoFree    move.l    a6,a1        ;close dos.library
  197.     move.l    4.w,a6
  198.     jsr    _LVOCloseLibrary(a6)
  199.     lea    AllSize(sp),sp    ;restore stack
  200.  
  201. ;end program
  202.     move.l    d5,d0        ;set return-code
  203.     tst.l    d6        ;wb-msg ? -> started from WB
  204.     bne.s    .Jump
  205.     rts            ;THE END ! from CLI
  206. .Jump    jsr    _LVOForbid(a6)    ;must be in forbid-state
  207.     move.l    d6,a1
  208.     jmp    _LVOReplyMsg(a6)    ;THE END ! from WB
  209.  
  210. XpkName        dc.b    "xpkmaster.library",0
  211. GuideName    dc.b    "amigaguide.library",0
  212. DosName        dc.b    "dos.library",0
  213. Template    dc.b    "DATABASE,DOCUMENT/K,LINE/N,PUBSCREEN/K,"
  214.         dc.b    "PORTNAME/K",0
  215.  
  216.         end
  217.  
  218.