home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 277.lha / GetSend / Get.asm < prev    next >
Encoding:
Assembly Source File  |  1989-08-08  |  2.5 KB  |  153 lines

  1. ; $$TABS=12
  2.     exeobj
  3.  
  4.     INCLUDE    "i:HARDWARE.asm"
  5.     include    "i:lvo.asm"
  6.     include    "i:strucdef.asm"
  7.  
  8.     code
  9.  
  10. serper_value equ    30    ; 115.2 Kbaud
  11. blocksize    equ    32768
  12. ack_byte    equ    $55
  13.  
  14. start    move.l    $4,a6
  15.     lea    gfxname(pc),a1
  16.     moveq    #0,d0
  17.     jsr    _LVOOpenLibrary(a6)
  18.     move.l    d0,gfxbase
  19.     lea    dosname(pc),a1
  20.     moveq    #0,d0
  21.     jsr    _LVOOpenLibrary(a6)
  22.     move.l    d0,dosbase
  23.     
  24.     move.l    4,a6
  25.     move.l    #blocksize,d0
  26.     moveq    #0,d1
  27.     jsr    _LVOAllocMem(a6)
  28.     move.l    d0,bufptr
  29.     beq    done_prog
  30.  
  31.     bsr    disable
  32.     move.w    #serper_value,$dff032    ; set baud rate
  33.     bsr    sget_byte
  34.     cmp.b    #$55,d0
  35.     bne    done_prog
  36.     bsr    sget_byte
  37.     cmp.b    #$aa,d0
  38.     bne    done_prog
  39.     moveq    #3,d2
  40.     lea    file_len(pc),a0
  41. len_loop:    bsr    sget_byte
  42.     move.b    d0,(a0)+
  43.     dbra    d2,len_loop
  44.     lea    file_name(pc),a0
  45. fname_loop:    bsr    sget_byte
  46.     tst.b    d7
  47.     bne    done_prog
  48.     move.b    d0,(a0)+
  49.     bne.s    fname_loop
  50.     move.b    chksum(pc),d2
  51.     bsr    sget_byte
  52.     cmp.b    d0,d2
  53.     bne    done_prog
  54.     bsr    enable
  55. got_name    move.l    dosbase(pc),a6
  56.     move.l    #file_name,d1
  57.     move.l    #mode_newfile,d2
  58.     jsr    _LVOOpen(a6)
  59.     move.l    d0,file_handle
  60.     beq    done_prog
  61. next_block    bsr    disable
  62.     move.b    #ack_byte,d0
  63.     bsr    send_byte
  64.     clr.b    chksum
  65.     move.l    bufptr(pc),a0
  66.     move.l    #blocksize,d2
  67.     cmp.l    file_len,d2
  68.     ble.s    full_block
  69.     move.l    file_len(pc),d2
  70. full_block:    sub.l    d2,file_len
  71.     move.l    d2,d3
  72.     subq    #1,d2
  73. get_loop:    bsr    sget_byte
  74.     tst.b    d7
  75.     bne    done_prog
  76.     move.b    d0,(a0)+
  77.     dbra    d2,get_loop
  78.     move.b    chksum(pc),d2
  79.     bsr    sget_byte
  80.     cmp.b    d2,d0
  81.     bne    done_prog
  82.     bsr    enable
  83. got_block    move.l    dosbase(pc),a6
  84.     move.l    file_handle(pc),d1
  85.     move.l    bufptr(pc),d2
  86.     jsr    _LVOWrite(a6)
  87.     tst.l    file_len
  88.     bne    next_block
  89. done_prog:    move.l    4,a6
  90.     tst.b    disable_flag
  91.     beq    not_dis
  92.     jsr    _LVODisable(a6)
  93. not_dis:    move.l    bufptr(pc),a1
  94.     cmp    #0,a1
  95.     beq.s    no_free1
  96.     move.l    #blocksize,d0
  97.     jsr    _LVOFreeMem(a6)
  98. no_free1    move.l    dosbase(pc),a6
  99.     move.l    file_handle(pc),d1
  100.     beq.s    no_close
  101.     jsr    _LVOClose(a6)
  102. no_close    moveq    #0,d1
  103.     jmp    _LVOExit(a6)
  104.  
  105. sget_byte    move.l    #1500000,d1
  106. timeout1:    move.w    serdatr,d0
  107.     btst    #14,d0
  108.     bne.s    sgot_byte
  109.     subq.l    #1,d1
  110.     bne    sget_byte
  111.     moveq    #0,d0
  112.     st    d7
  113.     rts
  114. sgot_byte:    move    d0,color00
  115.     add.b    d0,chksum
  116.     move.w    #$800,intreq
  117.     clr    d7
  118.     rts
  119.  
  120. SEND_BYTE:
  121.     move.w    #$1,intena
  122.     MOVEM.L    D0/D1,-(A7)
  123. POLL_LOOP:
  124.     MOVE.W    SERDATR,D1
  125.     BTST    #13,D1
  126.     BEQ    POLL_LOOP
  127.     AND.W    #$FF,D0
  128.     BSET    #8,D0
  129.     MOVE.W    D0,SERDAT
  130.     MOVEM.L    (A7)+,D0/D1
  131.     RTS
  132.  
  133. enable    clr.b    disable_flag
  134.     move.l    4,a6
  135.     jmp    _LVOEnable(a6)
  136.  
  137. disable    st    disable_flag
  138.     move.l    4,a6
  139.     jmp    _LVODisable(a6)
  140.  
  141. file_handle    dc.l    0
  142. gfxbase    dc.l    0
  143. dosbase    dc.l    0
  144. bufptr    dc.l    0
  145. file_len    dc.l    0
  146. chksum    dc.b    0
  147. DOSNAME:    DC.B    'dos.library',0
  148. gfxname    dc.b    'graphics.library',0
  149. file_name    ds.b    100
  150. disable_flag    dc.b    0
  151.     end
  152.  
  153.