home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Games / WHDLoad / Extra / wwarp.lha / wwarp / src / mfm.asm < prev    next >
Assembly Source File  |  2000-08-06  |  4KB  |  206 lines

  1. ;*---------------------------------------------------------------------------
  2. ;  :Program.    mfm.asm
  3. ;  :Contents.    decodes mfm data
  4. ;  :Author.    Bert Jahn
  5. ;  :EMail.    wepl@whdload.org
  6. ;  :Address.    Franz-Liszt-Straße 16, Rudolstadt, 07404, Germany
  7. ;  :Version    $Id: mfm.asm 1.3 2000/06/02 04:56:44 jah Exp jah $
  8. ;  :History.    27.02.00 initial
  9. ;  :Requires.    OS V37+
  10. ;  :Copyright.    © 2000 Bert Jahn, All Rights Reserved
  11. ;  :Language.    68000 Assembler
  12. ;  :Translator.    Barfly V2.9
  13. ;  :To Do.
  14. ;---------------------------------------------------------------------------*
  15. ;##########################################################################
  16.  
  17.     INCDIR    Includes:
  18.     INCLUDE    lvo/exec.i
  19.     INCLUDE    exec/execbase.i
  20.     INCLUDE    lvo/dos.i
  21.     INCLUDE    dos/dos.i
  22.     
  23.     INCLUDE    macros/ntypes.i
  24.  
  25. ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  26.  
  27.     STRUCTURE    Globals,0
  28.         APTR    gl_execbase
  29.         APTR    gl_dosbase
  30.         APTR    gl_rdargs
  31.         LABEL    gl_rdarray
  32.         ULONG    gl_rd_odd
  33.         ULONG    gl_rd_even
  34.         ULONG    gl_rc            ;programs return code
  35.         ALIGNLONG
  36.         STRUCT    gl_tmp,10
  37.         LABEL    gl_SIZEOF
  38.  
  39. ;##########################################################################
  40.  
  41. GL    EQUR    A4        ;a4 ptr to Globals
  42. LOC    EQUR    A5        ;a5 for local vars
  43. CPU    =    68000
  44.  
  45.     OUTPUT    C:mfm
  46.     BOPT    O+            ;enable optimizing
  47.     BOPT    OG+            ;enable optimizing
  48.     BOPT    ODd-            ;disable mul optimizing
  49.     BOPT    ODe-            ;disable mul optimizing
  50.  
  51.     IFND    .passchk
  52.     DOSCMD    "WDate  >T:date"
  53. .passchk
  54.     ENDC
  55.  
  56. Version        = 0
  57. Revision    = 1
  58.  
  59.     SECTION a,CODE
  60.  
  61.         bra    _Start
  62.  
  63.         dc.b    "$VER: "
  64. _txt_creator    sprintx    "mfm %ld.%ld ",Version,Revision
  65.         INCBIN    "T:date"
  66.         dc.b    0
  67.         dc.b    "$Id: mfm.asm 1.3 2000/06/02 04:56:44 jah Exp jah $",0
  68.     EVEN
  69.  
  70. ;##########################################################################
  71.  
  72.     INCDIR    Sources:
  73.     INCLUDE    dosio.i
  74.         PrintArgs
  75.     INCLUDE    strings.i
  76.         atoi
  77.     INCLUDE    error.i
  78.         PrintErrorDOS
  79.  
  80. ;##########################################################################
  81.  
  82. _StartErr    moveq    #33,d0            ;kick 1.2
  83.         lea    (_dosname),a1
  84.         jsr    (_LVOOpenLibrary,a6)
  85.         tst.l    d0
  86.         beq    .q
  87.         move.l    d0,a6
  88.         jsr    (_LVOOutput,a6)
  89.         move.l    d0,d1            ;file handle
  90.         move.l    (a7)+,d2
  91.         move.l    d2,a0
  92.         moveq    #-1,d3
  93. .c        addq.l    #1,d3
  94.         tst.b    (a0)+
  95.         bne    .c
  96.         jsr    (_LVOWrite,a6)
  97.         move.l    a6,a1
  98.         move.l    (gl_execbase,GL),a6
  99.         jsr    (_LVOCloseLibrary,a6)
  100. .q        move.l    (gl_rc,GL),d0
  101.         rts
  102.  
  103.     ;program start
  104. _Start        lea    (_Globals),GL
  105.         move.l    #RETURN_FAIL,(gl_rc,GL)
  106.         move.l    (4).w,a6
  107.         move.l    a6,(gl_execbase,GL)
  108.  
  109.     ;open dos.library
  110.         move.l    #37,d0
  111.         lea    (_dosname),a1
  112.         move.l    (gl_execbase,GL),a6
  113.         jsr    _LVOOpenLibrary(a6)
  114.         move.l    d0,(gl_dosbase,GL)
  115.         bne    .dosok
  116.         pea    (_badkick)
  117.         bra    _StartErr
  118. .dosok
  119.     ;read arguments
  120.         lea    (_template),a0
  121.         move.l    a0,d1
  122.         lea    (gl_rdarray,GL),a0
  123.         move.l    a0,d2
  124.         moveq    #0,d3
  125.         move.l    (gl_dosbase,GL),a6
  126.         jsr    (_LVOReadArgs,a6)
  127.         move.l    d0,(gl_rdargs,GL)
  128.         bne    .argsok
  129.         lea    (_readargs),a0
  130.         bsr    _PrintErrorDOS
  131.         bra    .noargs
  132. .argsok
  133.     ;parse args
  134.         move.l    (gl_rd_odd,GL),a0
  135.         bsr    _parse
  136.         move.l    d0,d5            ;d5 = odd
  137.         move.l    (gl_rd_even,GL),a0
  138.         bsr    _parse
  139.         move.l    d0,d6            ;d6 = even
  140.  
  141.         move.l    #$55555555,d0
  142.         move.l    d5,d1
  143.         and.l    d0,d1
  144.         add.l    d1,d1
  145.         move.l    d6,d2
  146.         and.l    d0,d2
  147.         or.l    d1,d2
  148.         lea    (_out),a0
  149.         move.l    d2,-(a7)
  150.         move.l    d6,-(a7)
  151.         move.l    d5,-(a7)
  152.         move.l    a7,a1
  153.         bsr    _PrintArgs
  154.         add.w    #12,a7
  155.  
  156.         move.l    (gl_rdargs,GL),d1
  157.         move.l    (gl_dosbase,GL),a6
  158.         jsr    (_LVOFreeArgs,a6)
  159. .noargs
  160.         move.l    (gl_dosbase,GL),a1
  161.         move.l    (gl_execbase,GL),a6
  162.         jsr    (_LVOCloseLibrary,a6)
  163. .nodoslib
  164.         move.l    (gl_rc,GL),d7
  165. _rts        rts
  166.  
  167. _parse        lea    (gl_tmp,GL),a1
  168.         move.b    #"$",d0
  169.         cmp.b    (a0),d0
  170.         bne    .1
  171.         addq.l    #1,a0
  172. .1        move.b    d0,(a1)+
  173.         moveq    #7,d0
  174. .2        move.b    (a0)+,(a1)+
  175.         dbf    d0,.2
  176.         clr.b    (a1)
  177.         lea    (gl_tmp,GL),a0
  178.         bra    _atoi
  179.  
  180. ;##########################################################################
  181.  
  182.     CNOP 0,4
  183. _out        dc.b    "  odd      even   decoded",10
  184.         dc.b    "%08lx %08lx %08lx",10,0
  185.         
  186. _badkick    dc.b    "requires Kickstart 2.0 or better.",10,0
  187. _readargs    dc.b    "read arguments",0
  188.  
  189. ;subsystems
  190. _dosname    DOSNAME
  191.  
  192. _template    dc.b    "Odd/A"            ;odd bits
  193.         dc.b    ",Even/A"        ;even bits
  194.         dc.b    0
  195.  
  196. ;##########################################################################
  197.  
  198.     SECTION g,BSS
  199.  
  200. _Globals    dsb    gl_SIZEOF
  201.  
  202. ;##########################################################################
  203.  
  204.     END
  205.  
  206.