home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / disks / disk439.lzh / DeluxeChanger / Sources / DeluxeChanger.asm < prev    next >
Assembly Source File  |  1991-01-18  |  9KB  |  500 lines

  1.  
  2.     XREF    SysRequest,Request,TypeAsk,TitelBitmap
  3.     XDEF    _DCScrBase,TopazName
  4.  
  5.     ;*********************************************************
  6.     ;**    _                      _    **
  7.     ;**   /| \        DELUXE CHANGER V1.0      / |\    **
  8.     ;**  /_|_/     (C) 1990/91 BY ANDREAS RÖPKE      \_|_\  **
  9.     ;** /  | \    THIS IS PUBLIC DOMAIN SOFTWARE     / |  \ **
  10.     ;**                            **
  11.     ;**    MADE WITH THE A68K ASSEMBLER & AMIGA 500 1.3    **
  12.     ;**         WORK WITH KICKSTART 2.0 UNCERTAIN        **
  13.     ;**                            **
  14.     ;*********************************************************
  15.  
  16.     INCLUDE exec/exec_lib.i
  17.     INCLUDE intuition/intuition_lib.i
  18.     INCLUDE libraries/dos_lib.i
  19.     INCLUDE graphics/graphics_lib.i
  20.     INCLUDE help.i
  21.  
  22.     SECTION "Startup",CODE
  23.  
  24. Start    move.l    4,a6                ;DOS-Basis finden
  25.     lea    $17a(a6),a0                     ;und merken
  26.     lea    DOSName,a1
  27.     CALLSYS FindName
  28.     move.l    d0,_DOSBase
  29.     move.l    $114(a6),a4                     ;Aufruf von diesem Task ?
  30.     tst.l    $ac(a4)
  31.     bne.s    FromCLI
  32.     lea    92(a4),a0
  33.     CALLSYS WaitPort
  34.     lea    92(a4),a0
  35.     CALLSYS GetMsg
  36.     move.l    d0,-(sp)
  37.     jsr    DeluxeStart
  38.     CALLEXEC Forbid
  39.     move.l    (sp)+,a1
  40.     CALLSYS ReplyMsg
  41.     bra    EndAll
  42. FromCLI CALLSYS Forbid
  43.     PEEKL    Start-4,SegmentPtr
  44.     clr.l    Start-4
  45.     move.l    #ProcessName,d1
  46.     moveq.l #9,d2
  47.     move.l    #DeluxeStart-4,d3
  48.     asr.l    #2,d3
  49.     move.l    #3000,d4
  50.     CALLDOS CreateProc
  51. EndAll    moveq.l #0,d0
  52.     rts
  53.  
  54.     SECTION "Main",CODE
  55.  
  56. DeluxeStart
  57.     bsr    GetLibs
  58.     SADD    DCScreen,a0
  59.     CALLPC    _IntuitionBase,OpenScreen
  60.     beq    NoScr
  61.     POKEL    d0,_DCScrBase
  62.     PEEKL    _DCScrBase,a0
  63.     lea    $2c(a0),a0
  64.     SADD    Colors,a1
  65.     moveq.l #4,d0
  66.     CALLPC    _GfxBase,LoadRGB4
  67.     SADD    DCWindow,a0
  68.     CALLPC    _IntuitionBase,OpenWindow
  69.     beq    NoWind
  70.     POKEL    d0,_DCWindBase
  71.     move.l    d0,a1
  72.     POKEL    $32(a1),_DCWindRast
  73.     POKEL    $56(a1),_DCWindUser
  74.     bsr    MakeTop
  75. DCWait    PEEKL    _DCWindUser,a0
  76.     CALLEXEC WaitPort
  77.     PEEKL    _DCWindUser,a0
  78.     CALLSYS GetMsg
  79.     move.l    d0,a1
  80.     move.l    $14(a1),d4
  81.     move.l    $1c(a1),a4
  82.     CALLSYS ReplyMsg
  83.     cmpi.b    #$40,d4
  84.     beq.s    GadUp
  85.     bra    DCWait
  86. GadUp    cmpi.w    #"QU",$26(a4)
  87.     beq.s    DCQuit
  88.     cmpi.w    #"LD",$26(a4)
  89.     bne.s    NoLD
  90.     bsr    Load
  91.     bra    DCWait
  92. NoLD    cmpi.w    #"CV",$26(a4)
  93.     bne.s    NoCV
  94.     bsr    Convert
  95.     bra    DCWait
  96. NoCV    cmpi.w    #"SV",$26(a4)
  97.     bne.s    DCWait
  98.     bsr    Save
  99.     bra    DCWait
  100. DCQuit    PEEKL    _DCWindBase,a0
  101.     CALLPC    _IntuitionBase,CloseWindow
  102. NoWind    PEEKL    _DCScrBase,a0
  103.     CALLPC    _IntuitionBase,CloseScreen
  104. NoScr    bsr    ASCBufTest
  105.     bsr    FileBufTest
  106.     tst.l    SegmentPtr
  107.     beq.s    WasWork
  108.     CALLEXEC Forbid
  109.     PEEKL    SegmentPtr,d1
  110.     CALLPC    _DOSBase,UnLoadSeg
  111. WasWork moveq.l #0,d0
  112.     rts
  113.  
  114. SegmentPtr    ds.l    1
  115.  
  116. *** File laden
  117.  
  118. Load    bsr    FileBufTest
  119.     SADD    LoadTitel,a0
  120.     jsr    Request
  121.     beq    NoLoad
  122.     move.l    d0,d1
  123.     move.l    #1005,d2
  124.     CALLPC    _DOSBase,Open
  125.     bne    ScrOK
  126.     SADD    ErrNoFile,a0
  127.     jsr    SysRequest
  128.     bra    NoLoad
  129. ScrOK    move.l    d0,d6
  130.     move.l    d6,d1
  131.     moveq.l #0,d2
  132.     moveq.l #1,d3
  133.     CALLSYS Seek
  134.     move.l    d6,d1
  135.     moveq.l #0,d2
  136.     moveq.l #-1,d3
  137.     CALLSYS Seek
  138.     POKEL    d0,FileLenght
  139.     moveq.l #1,d1
  140.     CALLEXEC AllocMem
  141.     bne    ScrBufferOK
  142.     SADD    ErrNoMem,a0
  143.     jsr    SysRequest
  144.     bra    NoScrBuffer
  145. ScrBufferOK
  146.     POKEL    d0,FileBuffer
  147.     move.l    d6,d1
  148.     PEEKL    FileBuffer,d2
  149.     PEEKL    FileLenght,d3
  150.     CALLPC    _DOSBase,Read
  151.     SADD    DoneIt,a0
  152.     jsr    SysRequest
  153. NoScrBuffer
  154.     move.l    d6,d1
  155.     CALLPC    _DOSBase,Close
  156. NoLoad    rts
  157.  
  158. *** File nach ASC konvertieren
  159.  
  160. Convert bsr    ASCBufTest
  161.     tst.l    FileBuffer
  162.     bne.s    OKConv
  163.     SADD    ErrEmpty,a0
  164.     jsr    SysRequest
  165.     bra    NoConv
  166. OKConv    jsr    TypeAsk
  167.     cmpi.w    #"CL",d7
  168.     beq    NoConv
  169.     POKEL    d0,ASCLenght
  170.     move.l    #1!$10000,d1
  171.     CALLEXEC AllocMem
  172.     bne.s    MemGot
  173.     SADD    ErrNoMem,a0
  174.     jsr    SysRequest
  175.     bra    NoConv
  176. MemGot    POKEL    d0,ASCBuffer
  177.     PEEKL    FileLenght,d5
  178.     PEEKL    FileBuffer,a2
  179.     PEEKL    ASCBuffer,a3
  180.     divu    #16,d5
  181.     tst.w    d5
  182.     beq    NoMore16
  183.     subq.w    #1,d5
  184. LineLoop
  185.     PEEKL    ASCBuffer,d0
  186.     add.l    ASCLenght(pc),d0
  187.     sub.l    #100,d0
  188.     cmpa.l    d0,a3
  189.     bls    Enough
  190.     SADD    ErrNoBuffer,a0
  191.     jsr    SysRequest
  192.     bra    NoConv
  193. Enough    bsr    ConstructFront
  194.     move.w    #7,d4
  195. ConLoop bsr    ConstructPrefix
  196.     move.w    (a2)+,d2
  197.     bsr    D2ToHex
  198.     cmpi.w    #0,d4
  199.     beq    NoKomma
  200.     move.b    #44,(a3)+
  201. NoKomma dbra    d4,ConLoop
  202.     dbra    d5,LineLoop
  203. NoMore16
  204.     swap    d5
  205.     tst.w    d5
  206.     beq    NoEnd
  207.     addq.l    #1,d5
  208.     lsr.w    #1,d5
  209.     subq.l    #1,d5
  210.     bsr    ConstructFront
  211. EndLoop bsr    ConstructPrefix
  212.     move.w    (a2)+,d2
  213.     bsr    D2ToHex
  214.     cmpi.w    #0,d5
  215.     beq    LastByte
  216.     move.b    #44,(a3)+
  217. LastByte
  218.     dbra    d5,EndLoop
  219. NoEnd    suba.l    ASCBuffer(pc),a3
  220.     move.l    a3,ASCLast
  221.     SADD    DoneIt,a0
  222.     jsr    SysRequest
  223. NoConv    rts
  224.  
  225. ConstructPrefix
  226.     cmpi.w    #"AS",d7
  227.     bne    NoAss2
  228.     move.b    #"$",(a3)+
  229.     bra    Ques2
  230. NoAss2    cmpi.w    #"CS",d7
  231.     bne    Ques2
  232.     move.b    #"0",(a3)+
  233.     move.b    #"x",(a3)+
  234. Ques2    rts
  235.  
  236. ConstructFront
  237.     cmpi.w    #"BS",d7
  238.     bne    NoBas1
  239.     SADD    BasicFront,a0
  240. CopyBas move.b    (a0)+,(a3)+
  241.     cmpi.b    #0,(a0)
  242.     bne.s    CopyBas
  243.     bra    Ques1
  244. NoBas1    cmpi.w    #"AS",d7
  245.     bne    NoAss1
  246.     SADD    AssFront,a0
  247. AssCopy move.b    (a0)+,(a3)+
  248.     cmpi.b    #0,(a0)
  249.     bne.s    AssCopy
  250.     bra    Ques1
  251. NoAss1    move.b    #10,(a3)+
  252.     move.b    #9,(a3)+
  253. Ques1    rts
  254.  
  255. ***    wandelt d2 nach Hex-ASC
  256.  
  257. D2ToHex moveq.w #3,d1
  258. D2Next    rol.w    #4,d2
  259.     move.w    d2,d3
  260.     and.b    #$f,d3
  261.     add.b    #48,d3
  262.     cmp.b    #58,d3
  263.     bcs    D2Out
  264.     addq.b    #7,d3
  265. D2Out    move.b    d3,(a3)+
  266.     dbra    d1,D2Next
  267.     rts
  268.  
  269. ***    Save
  270.  
  271. Save    tst.l    ASCBuffer
  272.     bne.s    OKSave
  273.     SADD    ErrEmpty,a0
  274.     jsr    SysRequest
  275.     bra    NoSave
  276. OKSave    SADD    SaveTitel,a0
  277.     jsr    Request
  278.     beq    NoSave
  279.     move.l    d0,d1
  280.     move.l    #1006,d2
  281.     CALLPC    _DOSBase,Open
  282.     bne    SaveFileOK
  283.     SADD    ErrNoFile,a0
  284.     jsr    SysRequest
  285.     bra    NoSave
  286. SaveFileOK
  287.     move.l    d0,-(sp)
  288.     move.l    (sp),d1
  289.     PEEKL    ASCBuffer,d2
  290.     PEEKL    ASCLast,d3
  291.     CALLSYS Write
  292.     move.l    (sp)+,d1
  293.     CALLSYS Close
  294.     SADD    DoneIt,a0
  295.     jsr    SysRequest
  296. NoSave    rts
  297.  
  298. ***    Buffer-Test & Speicher freigeben
  299.  
  300. FileBufTest
  301.     tst.l    FileBuffer
  302.     beq    FileBufEmpty
  303.     PEEKL    FileBuffer,a1
  304.     PEEKL    FileLenght,d0
  305.     CALLEXEC FreeMem
  306.     POKEL    #0,FileBuffer
  307. FileBufEmpty
  308.     rts
  309.  
  310. ASCBufTest
  311.     tst.l    ASCBuffer
  312.     beq    ASCBufEmpty
  313.     PEEKL    ASCBuffer,a1
  314.     PEEKL    ASCLenght,d0
  315.     CALLEXEC FreeMem
  316.     POKEL    #0,ASCBuffer
  317. ASCBufEmpty
  318.     rts
  319.  
  320. ***    Titel Image/Border/Text ausgeben
  321.  
  322. MakeTop PEEKL    _DCWindRast,a0
  323.     SADD    TitelImage,a1
  324.     moveq.l #0,d0
  325.     moveq.l #0,d1
  326.     CALLPC    _IntuitionBase,DrawImage
  327.     PEEKL    _DCWindRast,a0
  328.     SADD    Border0,a1
  329.     moveq.l #0,d0
  330.     moveq.l #0,d1
  331.     CALLSYS DrawBorder
  332.     PEEKL    _DCWindRast,a0
  333.     SADD    TitelText,a1
  334.     moveq.l #0,d0
  335.     moveq.l #0,d1
  336.     CALLSYS PrintIText
  337.     rts
  338.  
  339. ***    Library-Zeiger suchen und merken
  340.  
  341. GetLibs move.l    4,a6
  342.     lea    $17a(a6),a0
  343.     SADD    IntName,a1
  344.     CALLSYS FindName
  345.     POKEL    d0,_IntuitionBase
  346.     lea    $17a(a6),a0
  347.     SADD    GrafName,a1
  348.     CALLSYS FindName
  349.     POKEL    d0,_GfxBase
  350.     rts
  351.  
  352. IntName     INTNAME
  353. DOSName     DOSNAME
  354. GrafName    GRAFNAME
  355. _IntuitionBase    ds.l    1
  356. _DOSBase    ds.l    1
  357. _GfxBase    ds.l    1
  358.  
  359. ***    Data-Teil
  360.  
  361. DCScreen    dc.w    0,0,640,200,2
  362.         dc.b    0,1
  363.         dc.w    $8000,1
  364.         dc.l    Topaz8,0,0,0
  365. Colors        dc.w    $888,0,$fff,$555
  366. DCWindow    dc.w    0,0,640,200
  367.         dc.b    -1,-1
  368.         dc.l    8!$40,$800!$1000!$10000,DCGad0,0,0
  369. _DCScrBase    dc.l    0,0
  370.         dc.w    0,0,0,0,15
  371. _DCWindBase    ds.l    1
  372. _DCWindRast    ds.l    1
  373. _DCWindUser    ds.l    1
  374. DCGad0        dc.l    DCGad1
  375.         dc.w    20,68,600,23,2,1,1
  376.         dc.l    Border2,Border4,DCText0,0,0
  377.         dc.w    "LD"
  378.         dc.l    0
  379. DCText0     dc.b    1,0,0,0
  380.         dc.w    300-16*4,8
  381.         dc.l    0,DCBytes0,0
  382.         TEXT    DCBytes0,<"LOAD BINARY FILE">
  383. DCGad1        dc.l    DCGad2
  384.         dc.w    20,101,600,23,2,1,1
  385.         dc.l    Border2,Border4,DCText1,0,0
  386.         dc.w    "CV"
  387.         dc.l    0
  388. DCText1     dc.b    1,0,0,0
  389.         dc.w    300-19*4,8
  390.         dc.l    0,DCBytes1,0
  391.         TEXT    DCBytes1,<"CONVERT BINARY FILE">
  392. DCGad2        dc.l    DCGad3
  393.         dc.w    20,134,600,23,2,1,1
  394.         dc.l    Border2,Border4,DCText2,0,0
  395.         dc.w    "SV"
  396.         dc.l    0
  397. DCText2     dc.b    1,0,0,0
  398.         dc.w    300-15*4,8
  399.         dc.l    0,DCBytes2,0
  400.         TEXT    DCBytes2,<"SAVE ASCII FILE">
  401. DCGad3        dc.l    0
  402.         dc.w    20,167,600,23,2,1,1
  403.         dc.l    Border2,Border4,DCText3,0,0
  404.         dc.w    "QU"
  405.         dc.l    0
  406. DCText3     dc.b    1,0,0,0
  407.         dc.w    300-4*4,8
  408.         dc.l    0,DCBytes3,0
  409.         TEXT    DCBytes3,<"QUIT">
  410.  
  411. ***    Titel-Strukturen
  412.  
  413. TitelImage    dc.w    320-17*8,13,17*16,25,1
  414.         dc.l    TitelBitmap
  415.         dc.b    1,0
  416.         dc.l    0
  417. TitelText    dc.b    1,0,0,0
  418.         dc.w    320-60*4,43
  419.         dc.l    0,TitelBytes,0
  420.         TEXT    TitelBytes,<"(C) WRITTEN 1990/91 BY ANDREAS RÖPKE  PUBLIC DOMAIN SOFTWARE">
  421. LoadTitel    dc.b    1,0,0,0
  422.         dc.w    160-14*4,0
  423.         dc.l    0,LoadBytes,0
  424.         TEXT    LoadBytes,<"FILE TO LOAD ?">
  425. SaveTitel    dc.b    1,0,0,0
  426.         dc.w    160-14*4,0
  427.         dc.l    0,SaveBytes,0
  428.         TEXT    SaveBytes,<"FILE TO SAVE ?">
  429. DoneIt        dc.b    1,0,0,0
  430.         dc.w    140-20*4,0
  431.         dc.l    0,DoneItBytes,0
  432.         TEXT    DoneItBytes,<"I`VE DONE IT, MASTER">
  433.  
  434. ***    Fehler
  435.  
  436. ErrEmpty    dc.b    1,0,0,0
  437.         dc.w    140-15*4,0
  438.         dc.l    0,ErrNoLoadBytes,0
  439.         TEXT    ErrNoLoadBytes,<"BUFFER IS EMPTY">
  440. ErrNoFile    dc.b    1,0,0,0
  441.         dc.w    140-15*4,0
  442.         dc.l    0,ErrNoFileBytes,0
  443.         TEXT    ErrNoFileBytes,<"CAN`T OPEN FILE">
  444. ErrNoMem    dc.b    1,0,0,0
  445.         dc.w    140-21*4,0
  446.         dc.l    0,ErrNoMemBytes,0
  447.         TEXT    ErrNoMemBytes,<"CAN`T ALLOCATE MEMORY">
  448. ErrNoBuffer    dc.b    1,0,0,0
  449.         dc.w    140-21*4,0
  450.         dc.l    0,ErrNoBBytes,0
  451.         TEXT    ErrNoBBytes,<"SORRY, BUFFER IS FULL">
  452.  
  453. ***    Fonts
  454.  
  455. Topaz8        dc.l    TopazName
  456.         dc.w    8
  457.         dc.b    0,1
  458.         TEXT    TopazName,"topaz.font"
  459.  
  460. ***    Borders
  461.  
  462. Border0     dc.w    20,10
  463.         dc.b    2,0,0,3
  464.         dc.l    Pairs0,Border1
  465. Pairs0        dc.w    599,0,0,0,0,43
  466. Border1     dc.w    20,10
  467.         dc.b    1,0,0,3
  468.         dc.l    Pairs1,0
  469. Pairs1        dc.w    0,44,599,44,599,1
  470. Border2     dc.w    0,0
  471.         dc.b    2,0,0,3
  472.         dc.l    Pairs24,Border3
  473. Border3     dc.w    0,0
  474.         dc.b    1,0,0,3
  475.         dc.l    Pairs35,0
  476. Border4     dc.w    0,0
  477.         dc.b    1,0,0,3
  478.         dc.l    Pairs24,Border5
  479. Border5     dc.w    0,0
  480.         dc.b    2,0,0,3
  481.         dc.l    Pairs35,0
  482. Pairs24     dc.w    599,0,0,0,0,21
  483. Pairs35     dc.w    0,22,599,22,599,1
  484.  
  485. BasicFront    dc.b    10,"DATA ",0
  486. AssFront    dc.b    10,9,9,"dc.w",9,0
  487.         even
  488.  
  489. ASCBuffer    ds.l    1
  490. ASCLenght    ds.l    1
  491. ASCLast     ds.l    1
  492. FileBuffer    ds.l    1
  493. FileLenght    ds.l    1
  494.  
  495.         TEXT    ProcessName,<"DeluxeChanger V1.0">
  496.  
  497.     END
  498.  
  499.  
  500.