home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / hacking / phreak_utils_pc / dial.asm < prev    next >
Encoding:
Assembly Source File  |  1993-07-03  |  23.3 KB  |  1,150 lines

  1. ; AT&T dialer, by The Brain, 7-2-93, +31-74-425982
  2. ;
  3. ;     >>> DON'T SPREAD IT TO THE LAMERS! <<<
  4. ;
  5. ; Okay, now for the coders looking at this piece of shit...
  6. ; I did this one in just one day (a coded one before but it used keyboard
  7. ; stuffing and very long dial command which some programm did not like
  8. ; at all and some modems didn't catch the long dial string).
  9. ; It's a real messy due to this. 
  10. ; I used BIOS int 10h everywhere for screen control (YUUUUCK!) to get it
  11. ; working with DESQVIEW or any other programm having troubles with direct
  12. ; screen writes or register access.
  13. ; Hope ya like it, wait for more nice Brain stuff comin' up!
  14. ; Whah.... i spend a day on debugging!!! Aargh
  15. ;
  16.         code    segment
  17.         org    100h
  18.         assume    cs:code, ds:code, es:code, ss:code
  19. Start:        jmp    GoInit
  20.  
  21. IdString    db    'AT&T'            ; ID-string of TSR
  22. DataFile    db    80 dup(?)        ; Full path/file of 'DIAL.DAT'
  23. StringOK    db    2,'OK'            ; 'OK' for waiting (^M)
  24. AbortString    db    0            ; Send when pressed Enter 2*
  25. OldPos        dw    ?            ; Cursor position before TSR
  26. OldShape    dw    ?            ; Cursor shape before TSR
  27. OldScreen    dw    80*25 dup(?)        ; Screen contents
  28. ReceivePos    dw    ?            ; Cursor pos. in receive window
  29. ReceiveBuf    db    20 dup(0)        ; Last 20 received characters
  30. SendPtr        dw    0            ; Pointer dial-string (0=stop)
  31. SendSub        dw    0            ; Pointer sub-string (0=stop)
  32. SendLineAdr    dw    ?            ; Address of entry to dial
  33. SendCardAdr    dw    ?            ; Address of card to use
  34. ComSaveLine    db    ?            ; Comport status before TSR
  35.  
  36. ; Following data is stored in DIAL.DAT file
  37. ;
  38. DataStart:
  39. ComPort        dw    0            ; 0=COM1, 1=COM2...
  40. CardCur        db    1            ; Current card
  41. DialCur        db    1            ; Position in dial list
  42. DialOfs        db    0
  43. ModemString    db    'ATDT06-022911,,,,,,,,'    ; Dial string :
  44.         db    ';^MATDT^1#,^2#,,^M',0    ; '^M' = send CR, wait for OK
  45.                         ; '^1' = send choosen number
  46.                         ; '^2' = send card number
  47.         org    offset ModemString+60    ; Buffer = 60 characters
  48. CardList    db    10*20 dup(0)        ; 10 card numbers
  49. DialList    db    256*70 dup(0)        ; board names/nubers/comments
  50. DialLast    equ    $-70
  51. DataSize    equ    $-offset DataStart    ; Size of the data file
  52.  
  53. ; Yoho, just try +31-74-425982
  54.  
  55. SaveOk        db    28,12,23,1,2Eh
  56.         db    ' DATA FILE IS SAVED... '
  57.  
  58. SaveErr        db    24,12,32,1,4Eh
  59.         db    '>> ERROR WRITING DATA FILE!!! <<'
  60.  
  61. ModemScreen    db    9,8,62,7,1Bh
  62.         db    '┌────────────────────[',7,'Enter modem string',11,']────────────────────┐'
  63.         db    '│                                                            │'
  64.         db    '├────────────────────────────────────────────────────────────┤'
  65.         db    '│ A ^M is replaced by a CR and the dialer will wait for a    │'
  66.         db    '│ OK-string. ^1 is replaced by the selected telephone number.│'
  67.         db    '│ ^2 is replaced by the current card number and pin.         │'
  68.         db    '└────────────────────────────────────────────────────────────┘'
  69.         
  70. CardScreen    db    28,6,25,13,1Bh
  71.         db    '┌──┬───[',7,'Card List',11,']──────┐'
  72.         db    '│',14,'Nr',11,'│',14,'  Card/Pin number   ',11,'│'
  73.         db    '│01│                    │'
  74.         db    '│02│                    │'
  75.         db    '│03│                    │'
  76.         db    '│04│                    │'
  77.         db    '│05│                    │'
  78.         db    '│06│                    │'
  79.         db    '│07│                    │'
  80.         db    '│08│                    │'
  81.         db    '│09│                    │'
  82.         db    '│10│                    │'
  83.         db    '└──┴────────────────────┘'
  84.  
  85. DialScreen    db    1,3
  86.         db    78,19,1Bh
  87.         db    '┌───┬──────────────────────[',7,'Dial List by The Brain',11,']─────┬────────────────────┐'
  88.         db    '│',14,'Nr.',0Bh,'│',14,'           Board Name         ',11,'│',14,'       Number       ',11,'│',14,'      Comment       ',11,'│'
  89.         db    '│   │                              │                    │                    │'
  90.         db    '│   │                              │                    │                    │'
  91.         db    '│   │                              │                    │                    │'
  92.         db    '│   │                              │                    │                    │'
  93.         db    '│   │                              │                    │                    │'
  94.         db    '│   │                              │                    │                    │'
  95.         db    '│   │                              │                    │                    │'
  96.         db    '│   │                              │                    │                    │'
  97.         db    '│   │                              │                    │                    │'
  98.         db    '│   │                              │                    │                    │'
  99.         db    '│   │                              │                    │                    │'
  100.         db    '│   │                              │                    │                    │'
  101. Line0        db    '├───┴──────────────────────────[',7,'Modem Input, COM'
  102. ComText        db    '1:',11,']─────┴────────────────────┤'
  103. Line1        db    '│                                                                            │'
  104. LineSize    equ    $-offset Line1
  105. Line2        db    '│                                                                            │'
  106. Line3        db    '│                                                                            │'
  107.         db    '└─────────── '
  108.         db    '[',14,'C',11,']',15,'ards',         11,' / '
  109.         db    '[',14,'E',11,']',15,'dit',          11,' / '
  110.         db    '[',14,'M',11,']',15,'odem command', 11,' / '
  111.         db    '[',14,'P',11,']',15,'ort',          11,' / '
  112.         db    '[',14,'S',11,']',15,'ave',          11,' '
  113.         db    '───────────┘'
  114.         
  115.         ; [C]ards / [E]dit / [M]odem command / [P]ort / [S]ave
  116.  
  117.  
  118. MyInt8:        pushf
  119.         db    09Ah
  120. OldInt8        dw    ?,?
  121.         cmp    cs:Bussy,1
  122.         je    MyInt8A
  123.         push    ax ds
  124.         xor    ax,ax
  125.         mov    ds,ax
  126.         mov    al,ds:[417h]
  127.         and    al,0Eh
  128.         cmp    al,0Eh
  129.         pop    ds ax
  130.         je    DoeUtil
  131. MyInt8A:    iret
  132. Bussy        db    0
  133.  
  134.  
  135. DoeUtil:    mov    cs:Bussy,1
  136.         push    ax bx cx dx
  137.         push    si di ds es
  138.         push    bp
  139.         sti
  140.         mov    al,20h
  141.         out    20h,al
  142.         call    GoTSR
  143.         pop    bp
  144.         pop    es ds di si
  145.         pop    dx cx bx ax
  146.         mov    cs:Bussy,0
  147.         iret
  148.  
  149.  
  150. ; TSR initialisation
  151. ;
  152. GoTSR:        push    cs cs            ; DS,ES = CS
  153.         pop    ds es
  154.         mov    ah,0Fh            ; Only in screem mode 2/3
  155.         int    10h
  156.         cmp    al,3
  157.         je    GoTSR1
  158.         cmp    al,2
  159.         je    GoTSR1
  160.         ret
  161. GoTSR1:        mov    ah,3            ; Store cursor location and
  162.         xor    bh,bh            ; cursor shape
  163.         int    10h
  164.         mov    OldShape,cx
  165.         mov    OldPos,dx
  166.         mov    ch,20h            ; Cursor off
  167.         mov    ah,1
  168.         int    10h
  169.         mov    di,offset OldScreen    ; Store screen data
  170.         xor    bh,bh
  171.         xor    dx,dx
  172.         mov    cx,25
  173. GoTSR2:        push    cx dx
  174.         mov    cx,80
  175. GoTSR3:        mov    ah,2
  176.         int    10h
  177.         mov    ah,8
  178.         int    10h
  179.         stosw
  180.         inc    dl
  181.         loop    GoTSR3
  182.         pop    dx cx
  183.         inc    dh
  184.         loop    GoTSR2
  185.         call    ComCapture
  186.         call    Main            ; Go for it
  187.         call    ComRelease
  188.         mov    si,offset OldScreen    ; Restore screen data
  189.         xor    bh,bh
  190.         xor    dx,dx
  191.         mov    cx,25
  192. GoTSR4:        push    cx dx
  193.         mov    cx,80
  194. GoTSR5:        push    cx
  195.         mov    ah,2
  196.         int    10h
  197.         lodsw
  198.         mov    bl,ah
  199.         mov    ah,9
  200.         mov    cx,1
  201.         int    10h
  202.         inc    dl
  203.         pop    cx
  204.         loop    GoTSR5
  205.         pop    dx cx
  206.         inc    dh
  207.         loop    GoTSR4
  208.         mov    cx,OldShape        ; Restore cursor shape
  209.         mov    ah,1
  210.         int    10h
  211.         mov    dx,OldPos        ; Restore cursor position
  212.         xor    bh,bh
  213.         mov    ah,2
  214.         int    10h
  215.         ret
  216.  
  217.  
  218. ; Disable interrupt from COM-port ---------------------------------------------
  219. ;
  220. ComCapture    proc    near
  221.         push    ax dx
  222.         call    ComPortIO
  223.         jc    ComCapture1        ; Quit => not connected!
  224.         inc    dx            ; Disable interrupt from port
  225.         xor    al,al
  226.         out    dx,al
  227. ComCapture1:    pop    dx ax
  228.         ret
  229. ComCapture    endp
  230.  
  231.  
  232. ; Enable interrupt from COM-port ----------------------------------------------
  233. ;
  234. ComRelease    proc    near
  235.         push    ax dx
  236.         call    ComPortIO
  237.         jc    ComRelease1        ; Quit => not connected!
  238.         inc    dx            ; Enable interrupt from port
  239.         mov    al,0Fh
  240.         out    dx,al
  241. ComRelease1:    pop    dx ax
  242.         ret
  243. ComRelease    endp
  244.  
  245.  
  246. ; Get COM port I/O adress -----------------------------------------------------
  247. ; output:    CF=1 => not available
  248. ;
  249. ComPortIO    proc    near
  250.         push    bx ds
  251.         mov    bx,40h
  252.         mov    ds,bx
  253.         mov    bx,cs:ComPort
  254.         shl    bx,1
  255.         mov    dx,[bx]
  256.         cmp    dx,1
  257.         pop    ds bx
  258.         ret
  259. ComPortIO    endp
  260.  
  261.  
  262. ComSend        proc    near
  263.         push    cx dx
  264.         call    ComPortIO
  265.         jc    ComSend2
  266.         push    ax
  267.         add    dx,5            ; Send request to send
  268.         xor    cx,cx
  269. ComSend1:    jmp    $+2
  270.         jmp    $+2
  271.         in    al,dx
  272.         test    al,20h
  273.         loopz    ComSend1
  274.         pop    ax
  275.         sub    dx,5
  276.         out    dx,al
  277. ComSend2:    pop    dx cx
  278.         ret
  279. ComSend        endp
  280.     
  281.     
  282. ComReceive    proc    near
  283.         push    cx dx
  284.         call    ComPortIO
  285.         jc    ComReceive2
  286.         add    dx,5            ; DTR
  287.         in    al,dx
  288.         test    al,1
  289.         stc
  290.         jz    ComReceive2
  291.         sub    dx,5
  292.         in    al,dx
  293. ComReceive2:    pop    dx cx
  294.         ret
  295. ComReceive    endp
  296.     
  297.  
  298. ; Update lower part of dial window --------------------------------------------
  299. ;
  300. UpdateLower    proc    near
  301.         push    ax bx cx dx si
  302.         mov    ah,3
  303.         xor    bh,bh
  304.         int    10h
  305.         push    dx
  306.         mov    dx,word ptr DialScreen
  307.         add    dh,14
  308.         mov    cx,044Eh
  309.         mov    ah,DialScreen[4]
  310.         mov    si,offset Line0        
  311. UpdateLower1:    push    cx dx
  312.         xor    ch,ch
  313. UpdateLower2:    lodsb
  314.         cmp    al,32
  315.         jae    UpdateLower3
  316.         and    ah,0F0h
  317.         or    ah,al
  318.         lodsb
  319. UpdateLower3:    call    ShowChar
  320.         loop    UpdateLower2
  321.         pop    dx cx
  322.         inc    dh
  323.         dec    ch
  324.         jnz    UpdateLower1
  325.         pop    dx
  326.         mov    ah,2
  327.         xor    bh,bh
  328.         int    10h
  329.         pop    si dx cx bx ax
  330.         ret
  331. UpdateLower    endp
  332.  
  333.  
  334. ; Scroll receive window up ----------------------------------------------------
  335. ; input:    none
  336. ; output:    none
  337. ; modified:    AX, CX, SI, DI, flags
  338. ;
  339. ScrollUp    proc    near
  340.         push    ax cx si di
  341.         mov    di,offset Line1
  342.         mov    si,offset Line2
  343.         mov    cx,2
  344. ScrollUp1:    inc    si
  345.         inc    di
  346.         push    cx
  347.         mov    cx,LineSize-2
  348.         rep    movsb
  349.         pop    cx
  350.         inc    si
  351.         inc    di
  352.         loop    ScrollUp1
  353.         inc    di
  354.         mov    al,' '
  355.         mov    cx,LineSize-2
  356.         rep    stosb
  357.         mov    dx,0200h
  358.         pop    di si cx ax
  359.         ret
  360. ScrollUp    endp
  361.  
  362.  
  363. ; Send character to receive window --------------------------------------------
  364. ; input:    AL = character
  365. ; output:    none
  366. ; modifed:    ...
  367. ;
  368. MonitorChar    proc    near
  369.         push    ax bx cx dx si di
  370.         mov    si,offset ReceiveBuf+1    ; Flush in buffer
  371.         mov    di,offset ReceiveBuf
  372.         mov    cx,19
  373.         rep    movsb
  374.         stosb
  375.         push    ax
  376.         mov    dx,ReceivePos        ; [SI] = cursor position
  377.         mov    al,LineSize        ; DX = cursor location
  378.         mul    dh
  379.         add    al,dl
  380.         adc    ah,0
  381.         mov    si,ax
  382.         add    si,offset Line1+1
  383.         pop    ax
  384.         cmp    al,13
  385.         jne    MonitorChar1
  386.         xor    dl,dl
  387.         jmp    MonitorChar9
  388. MonitorChar1:    cmp    al,10
  389.         jne    MonitorChar3
  390. MonitorChar2:    inc    dh
  391.         cmp    dh,3
  392.         jb    MonitorChar9
  393.         call    ScrollUp
  394.         jmp    MonitorChar9
  395. MonitorChar3:    mov    [si],al
  396.         inc    dl
  397.         cmp    dl,LineSize-2
  398.         jb    MonitorChar9
  399.         xor    dl,dl
  400.         jmp    MonitorChar2
  401. MonitorChar9:    mov    ReceivePos,dx
  402.         call    UpdateLower
  403.         pop    di si dx cx bx ax
  404.         ret
  405. MonitorChar    endp
  406.  
  407.  
  408. ; Check presence of string in receive buffer ----------------------------------
  409. ; input:    DS:SI = string
  410. ; output:    zf=1 => found in receive buffer
  411. ;
  412. TestString    proc    near
  413.         push    cx si di
  414.         mov    cl,[si]
  415.         xor    ch,ch
  416.         inc    si
  417.         mov    di,offset ReceiveBuf+20
  418.         sub    di,cx
  419.         repe    cmpsb
  420.         pop    di si cx
  421.         ret
  422. TestString    endp
  423.  
  424.  
  425. ; Handle receiving data -------------------------------------------------------
  426. ;
  427. DoReceive    proc    near        
  428.         call    ComReceive
  429.         jc    DoReceive1
  430.         call    MonitorChar
  431. DoReceive1:    ret
  432. DoReceive    endp
  433.  
  434.  
  435. ; Handle command sending ------------------------------------------------------
  436. ;
  437. DoSending    proc    near
  438.         mov    si,SendPtr        ; Command available
  439.         or    si,si
  440.         jz    DoSending5
  441.         cmp    [si],'1^'        ; ^1 => send number to call
  442.         jne    DoSending3
  443.         mov    si,SendSub
  444.         or    si,si
  445.         jne    DoSending1
  446.         mov    si,SendLineAdr
  447.         add    si,30
  448. DoSending1:    lodsb
  449.         or    al,al
  450.         jnz    DoSending2
  451.         mov    SendSub,0
  452.         add    SendPtr,2
  453.         ret
  454. DoSending2:    mov    SendSub,si
  455.         call    ComSend
  456.         ret
  457. DoSending3:    cmp    [si],'2^'        ; ^2 => send card/pin
  458.         jne    DoSending4
  459.         mov    si,SendSub
  460.         or    si,si
  461.         jne    DoSending1
  462.         mov    si,SendCardAdr
  463.         jmp    DoSending1
  464. DoSending4:    cmp    [si],'M^'        ; ^M => send CR and wait 'OK'
  465.         jne    DoSending7
  466.         cmp    SendSub,0
  467.         jne    DoSending6
  468.         mov    SendSub,1
  469.         mov    al,13
  470.         call    ComSend
  471. DoSending5:    ret
  472. DoSending6:    mov    si,offset StringOK
  473.         call    TestString
  474.         jne    DoSending5
  475.         mov    SendSub,0
  476.         add    SendPtr,2
  477.         ret
  478. DoSending7:    cmp    byte ptr [si],0        ; 0 => stop sending
  479.         jne    DoSending8
  480.         mov    SendPtr,0
  481.         mov    al,13
  482.         call    ComSend
  483.         ret
  484. DoSending8:    lodsb                ; Send next character
  485.         mov    SendPtr,si
  486.         call    ComSend
  487.         ret
  488. DoSending    endp        
  489.         
  490.  
  491. ; Read key with COM-port watching ect -----------------------------------------
  492. ;
  493. ReadKey        proc    near
  494.         push    bx cx dx si di
  495.         call    DoReceive        ; Receive characters
  496.         call    DoSending        ; Send command
  497.         pop    di si dx cx bx
  498.         mov    ah,1            ; Key pressed?
  499.         int    16h
  500.         jz    ReadKey            ; No => wait
  501. ReadKey1:    mov    ah,0            ; Get key (wait for it)
  502.         int    16h
  503.         ret
  504. ReadKey        endp
  505.         
  506.  
  507. ; Show character and increment DL ---------------------------------------------
  508. ; input:    DL,DH = location
  509. ;        AL    = character
  510. ;        AH    = attribute
  511. ; output:    DL+1
  512. ; modified:    nothing
  513. ;
  514. ShowChar    proc    near
  515.         push    ax bx cx
  516.         push    ax
  517.         mov    ah,2
  518.         xor    bh,bh
  519.         int    10h
  520.         pop    ax
  521.         mov    bl,ah
  522.         mov    ah,9
  523.         mov    cx,1
  524.         int    10h
  525.         pop    cx bx ax
  526.         inc    dl
  527.         ret
  528. ShowChar    endp
  529.  
  530.  
  531. ; Show ASCIIZ string with fixed display length --------------------------------
  532. ; Input:    DS:SI = ASCIIZ string
  533. ;        CX    = length
  534. ;        DL,DH = position
  535. ;        AH    = attribute
  536. ; Output:    SI+CX, DL+CX
  537. ; Modified:    AL, flags
  538. ;
  539. ShowASCIIZ    proc    near
  540.         push    cx si
  541. ShowASCIIZ1:    lodsb
  542.         cmp    al,1
  543.         sbb    si,0
  544.         call    ShowChar
  545.         loop    ShowASCIIZ1
  546.         pop    si cx
  547.         add    si,cx
  548.         ret
  549. ShowASCIIZ    endp
  550.  
  551.  
  552. ;        DX = string-positie
  553. ;        SI = string-adres
  554. ;        BP = maximum length
  555. ;        BX = huidige adres
  556. ;        AX = toets
  557.  
  558.  
  559. EditKeys:    cmp    ax,4B00h    ; [Left]
  560.         je    EditLeft
  561.         cmp    ax,4D00h    ; [Right]
  562.         je    EditRight
  563.         cmp    ax,5300h    ; [Del]
  564.         je    EditDel
  565.         cmp    ax,5200h    ; [Ins]
  566.         je    EditIns
  567.         cmp    ax,4700h    ; [Home]
  568.         je    EditHome
  569.         cmp    ax,4F00h    ; [End]
  570.         je    EditEnd
  571.         cmp    al,8        ; [BackSpace]
  572.         jne    EditKeys1
  573.         call    EditLeft
  574.         jmp    EditDel
  575. EditKeys1:    cmp    al,32        ; Insert character
  576.         jb    EditKeys2
  577.         push    ax
  578.         call    EditIns
  579.         pop    ax
  580.         mov    [bx],al
  581.         jmp    EditRight
  582. EditKeys2:    ret
  583.  
  584.         ; [Left]
  585. EditLeft:    cmp    si,bx
  586.         sbb    bx,0
  587.         ret
  588.  
  589.         ; [Right]
  590. EditRight:    mov    ax,si
  591.         add    ax,bp
  592.         dec    ax
  593.         cmp    bx,ax
  594.         jae    EditRight1
  595.         cmp    byte ptr [bx],0
  596.         je    EditRight1
  597.         inc    bx
  598. EditRight1:    ret
  599.  
  600.         ; [Ins]
  601. EditIns:    push    si
  602.         mov    cx,si
  603.         add    cx,bp
  604.         sub    cx,bx
  605.         add    si,bp
  606.         mov    di,si
  607.         dec    di
  608.         sub    si,2
  609.         std
  610.         rep    movsb
  611.         cld
  612.         mov    byte ptr [bx],' '
  613.         pop    si
  614.         ret
  615.  
  616.         ; [Del]
  617. EditDel:    push    si
  618.         mov    cx,si
  619.         add    cx,bp
  620.         sub    cx,bx
  621.         mov    si,bx
  622.         mov    di,si
  623.         inc    si
  624.         rep    movsb
  625.         dec    di
  626.         xor    al,al
  627.         stosb
  628.         pop    si
  629.         ret
  630.         
  631. EditHome:    mov    bx,si
  632.         ret
  633.         
  634. EditEnd:    mov    bx,si
  635.         dec    bx
  636.         mov    cx,bp
  637. EditEnd1:    inc    bx
  638.         cmp    byte ptr [bx],0
  639.         loopnz    EditEnd1
  640.         ret
  641.  
  642. ; input:    DS:SI = string
  643. ;        BP    = maximum length
  644. ;        DL,DH = display position
  645. ;
  646. EditASCIIZ    proc    near
  647.         push    dx
  648.         mov    ah,3
  649.         int    10h
  650.         pop    dx
  651.         push    cx
  652.         mov    ah,1
  653.         mov    cx,0607h
  654.         int    10h
  655.         call    EditEnd
  656. EditASCIIZ2:    push    bx dx si        ; Show string and cursor
  657.         sub    bx,si
  658.         mov    cx,bp
  659.         mov    ah,0Fh
  660.         call    ShowASCIIZ
  661.         add    dx,bx
  662.         sub    dx,bp
  663.         mov    ah,2
  664.         xor    bh,bh
  665.         int    10h
  666.         pop    si dx bx
  667.         call    ReadKey            ; Read key
  668.         push    ax
  669.         call    EditKeys
  670.         pop    ax
  671.         cmp    al,13
  672.         je    EditASCIIZ3
  673.         cmp    al,27
  674.         jne    EditASCIIZ2
  675. EditASCIIZ3:    pop    cx
  676.         push    ax
  677.         mov    ah,1
  678.         int    10h
  679.         push    si
  680.         mov    cx,bp
  681.         mov    ah,30h
  682.         call    ShowASCIIZ
  683.         sub    dx,bp
  684.         pop    si
  685.         pop    ax
  686.         cmp    al,27
  687.         ret
  688. EditASCIIZ    endp
  689.  
  690.  
  691. ; Show window to screen -------------------------------------------------------
  692. ; input:    DS:SI = window data
  693. ; output:    nothing
  694. ; modified:    AX, BX, CX, DX
  695. ;
  696. ShowScreen    proc    near
  697.         mov    dx,[si]
  698.         mov    cx,[si+2]
  699.         mov    ah,[si+4]
  700.         xor    bh,bh
  701.         add    si,5
  702. ShowScreen1:    push    cx dx
  703.         xor    ch,ch
  704. ShowScreen2:    lodsb
  705.         cmp    al,32
  706.         jae    ShowScreen3
  707.         and    ah,0F0h
  708.         or    ah,al
  709.         lodsb
  710. ShowScreen3:    call    ShowChar
  711.         loop    ShowScreen2
  712.         pop    dx cx
  713.         inc    dh
  714.         dec    ch
  715.         jnz    ShowScreen1
  716.         ret
  717. ShowScreen    endp        
  718.  
  719.  
  720. ; Show current dial list ------------------------------------------------------
  721. ;
  722. ShowList    proc    near
  723.         mov    al,70
  724.         mul    DialOfs
  725.         add    ax,offset DialList
  726.         mov    si,ax
  727.         mov    bl,DialOfs
  728.         mov    cx,12
  729.         mov    dx,word ptr DialScreen    ; DX = cursor loc of first nr.
  730.         add    dx,201h                
  731. ShowList1:    mov    al,13
  732.         sub    al,cl
  733.         cmp    al,DialCur
  734.         mov    bh,1Bh
  735.         jne    ShowList2
  736.         mov    bh,30h
  737. ShowList2:    push    cx dx
  738.         mov    al,bl            ; Show number
  739.         xor    ah,ah
  740.         mov    cx,640Ah
  741.         div    ch
  742.         push    ax
  743.         add    al,'0'
  744.         mov    ah,bh
  745.         call    ShowChar
  746.         pop    ax
  747.         mov    al,ah
  748.         xor    ah,ah
  749.         div    cl
  750.         add    ax,'00'
  751.         push    ax
  752.         mov    ah,bh
  753.         call    ShowChar
  754.         pop    ax
  755.         mov    al,ah
  756.         mov    ah,bh
  757.         call    ShowChar
  758.         mov    al,'│'
  759.         call    ShowChar
  760.         mov    cx,30            ; Show name
  761.         mov    ah,bh
  762.         call    ShowASCIIZ
  763.         mov    al,'│'
  764.         call    ShowChar
  765.         mov    cx,20            ; Show number
  766.         call    ShowASCIIZ
  767.         mov    al,'│'
  768.         call    ShowChar
  769.         mov    cx,20            ; how comment
  770.         call    ShowASCIIZ
  771.         pop    dx cx
  772.         inc    bl
  773.         inc    dh
  774.         loop    ShowList1
  775.         ret
  776. ShowList    endp
  777.  
  778.  
  779. ; Show card menu --------------------------------------------------------------
  780. ;
  781. ShowCards    proc    near
  782.         push    ax bx cx dx si
  783.         mov    si,offset CardScreen
  784.         call    ShowScreen
  785.         mov    si,offset CardList
  786.         mov    dx,word ptr CardScreen
  787.         add    dx,201h
  788.         mov    cx,10
  789.         mov    bx,'01'
  790. ShowCards1:    push    cx
  791.         mov    ax,1B0Bh
  792.         sub    al,cl
  793.         cmp    al,CardCur
  794.         jne    ShowCards2
  795.         mov    ah,30h
  796. ShowCards2:    mov    al,bh
  797.         call    ShowChar
  798.         mov    al,bl
  799.         call    ShowChar
  800.         mov    al,'│'
  801.         call    ShowChar
  802.         mov    cx,20
  803.         call    ShowASCIIZ
  804.         sub    dl,23
  805.         pop    cx
  806.         inc    bl
  807.         cmp    bl,'9'
  808.         jbe    ShowCards3
  809.         inc    bh
  810.         mov    bl,'0'
  811. ShowCards3:    inc    dh
  812.         loop    ShowCards1
  813.         pop    si dx cx bx ax
  814.         ret
  815. ShowCards    endp    
  816.         
  817. CardEdit    proc    near
  818.         call    ShowCards
  819.         call    ReadKey
  820.         cmp    ax,4800h        ; [Up]
  821.         jne    CardEdit1
  822.         cmp    CardCur,2
  823.         adc    CardCur,-1
  824.         jmp    CardEdit
  825. CardEdit1:    cmp    ax,5000h        ; [Down]
  826.         jne    CardEdit2
  827.         cmp    CardCur,10
  828.         adc    CardCur,0
  829.         jmp    CardEdit
  830. CardEdit2:    and    al,0DFh
  831.         cmp    al,13            ; [Enter] = [E]dit
  832.         je    CardEdit3
  833.         cmp    al,'E'
  834.         jne    CardEdit4
  835. CardEdit3:    mov    al,20
  836.         mul    CardCur
  837.         add    ax,offset CardList-20
  838.         mov    si,ax
  839.         mov    bp,20
  840.         mov    dx,word ptr CardScreen
  841.         add    dh,CardCur
  842.         add    dx,104h
  843.         call    EditASCIIZ
  844.         jmp    CardEdit
  845. CardEdit4:    cmp    al,27
  846.         jne    CardEdit
  847.         ret
  848. CardEdit    endp
  849.  
  850.  
  851.  
  852.  
  853. ; Edit dial entry -------------------------------------------------------------
  854. ;
  855. DialEdit:    mov    dx,word ptr DialScreen
  856.         add    dx,105h
  857.         add    dh,DialCur
  858.         mov    al,DialOfs
  859.         add    al,DialCur
  860.         dec    al
  861.         mov    ah,70
  862.         mul    ah
  863.         add    ax,offset DialList
  864.         mov    si,ax
  865. DialEdit1:    mov    bp,30
  866.         call    EditASCIIZ
  867.         je    DialEdit2
  868.         add    si,30
  869.         mov    bp,20
  870.         add    dl,31
  871.         call    EditASCIIZ
  872.         je    DialEdit2
  873.         add    si,20
  874.         mov    bp,20
  875.         add    dl,21
  876.         call    EditASCIIZ
  877.         je    DialEdit2
  878.         sub    si,50
  879.         sub    dl,52
  880.         jmp    DialEdit1
  881. DialEdit2:    ret
  882.         ; DX = pos, SI = adres
  883.         
  884.                 
  885. ; Save data file --------------------------------------------------------------
  886. ;
  887. SaveData    proc    near
  888.         mov    dx,offset DataFile
  889.         mov    ah,3Ch
  890.         mov    cx,20h
  891.         int    21h
  892.         jnc    SaveData1
  893.         mov    si,offset SaveErr
  894.         call    ShowScreen
  895.         jmp    ReadKey
  896. SaveData1:    mov    bx,ax
  897.         mov    dx,offset DataStart
  898.         mov    cx,DataSize
  899.         mov    ah,40h
  900.         int    21h
  901.         mov    ah,3Eh
  902.         int    21h
  903.         mov    si,offset SaveOk
  904.         call    ShowScreen
  905.         jmp    ReadKey
  906. SaveData    endp
  907.  
  908.  
  909. ; Handle extended keys for dial list ------------------------------------------
  910. ;
  911. DialExtend:    cmp    ah,72            ; Up
  912.         jne    DialExtend1
  913.         dec    DialCur
  914.         jnz    DialExtend8
  915.         inc    DialCur
  916.         cmp    DialOfs,1
  917.         adc    DialOfs,-1
  918.         jmp    DialExtend8
  919. DialExtend1:    cmp    ah,80            ; Down
  920.         jne    DialExtend2
  921.         inc    DialCur
  922.         cmp    DialCur,12
  923.         jbe    DialExtend8
  924.         dec    DialCur
  925.         cmp    DialOfs,256-12
  926.         adc    DialOfs,0
  927.         jmp    DialExtend8
  928. DialExtend2:    cmp    ah,73            ; PgUp
  929.         jne    DialExtend3
  930.         cmp    DialCur,1
  931.         mov    DialCur,1
  932.         jne    DialExtend8
  933.         sub    DialOfs,11
  934.         jnc    DialExtend8
  935.         mov    DialOfs,0
  936. DialExtend8:    ret
  937. DialExtend3:    cmp    ah,81            ; PgDn
  938.         jne    DialExtend4
  939.         cmp    DialCur,12
  940.         mov    DialCur,12
  941.         jne    DialExtend9
  942.         add    DialOfs,11
  943.         cmp    DialOfs,256-12
  944.         jb    DialExtend9
  945.         mov    DialOfs,256-12
  946.         jmp    DialExtend9
  947. DialExtend4:    cmp    ah,53h            ; [Del]
  948.         jne    DialExtend6
  949.         mov    al,DialOfs
  950.         add    al,DialCur
  951.         dec    al
  952.         mov    ah,70
  953.         mul    ah
  954.         mov    cx,255*70
  955.         sub    cx,ax
  956.         add    ax,offset DialList
  957.         mov    di,ax
  958.         mov    si,di
  959.         add    si,70
  960.         jcxz    DialExtend5
  961.         rep    movsb
  962. DialExtend5:    mov    cx,70
  963.         xor    al,al
  964.         rep    stosb
  965.         jmp    DialExtend9
  966. DialExtend6:    cmp    ah,52h            ; [Ins]            
  967.         jne    DialExtend9
  968.         mov    al,DialCur
  969.         add    al,DialOfs
  970.         dec    al
  971.         mov    ah,70
  972.         mul    ah
  973.         mov    cx,255*70
  974.         sub    cx,ax
  975.         add    ax,offset DialList
  976.         std
  977.         mov    di,offset DialList+256*70-1
  978.         mov    si,offset DialList+255*70-1
  979.         jcxz    DialExtend7
  980.         rep    movsb
  981. DialExtend7:    xor    al,al
  982.         mov    cx,70
  983.         rep    stosb
  984.         cld
  985. DialExtend9:    ret        
  986.                 
  987.         
  988. ; Main TSR routine (dial list) ------------------------------------------------
  989. ;
  990. Main        proc    near
  991.         mov    SendPtr,0        ; Cut of sending string
  992. Main7:        mov    al,byte ptr ComPort
  993.         add    al,'1'
  994.         mov    ComText,al
  995.         mov    si,offset DialScreen
  996.         call    ShowScreen
  997. Main1:        call    ShowList
  998. Main2:        call    ReadKey
  999.         cmp    al,0
  1000.         jne    Main3
  1001.         call    DialExtend
  1002.         jmp    Main1        
  1003. Main3:        cmp    al,'a'            ; UpCase
  1004.         jb    Main4
  1005.         cmp    al,'z'
  1006.         ja    Main4
  1007.         sub    al,20h
  1008. Main4:        cmp    al,'P'            ; [P]ort
  1009.         jne    Main5
  1010.         call    ComRelease        ; Release current port
  1011.         inc    ComPort            ; Next port (1,2,3,4)
  1012.         and    ComPort,3
  1013.         call    ComCapture        ; Capture port again
  1014.         jmp    Main
  1015. Main5:        cmp    al,'E'            ; [E]dit
  1016.         jne    Main6
  1017.         call    DialEdit
  1018.         jmp    Main1
  1019. Main6:        cmp    al,'C'            ; [C]ards
  1020.         jne    Main9
  1021.         xor    al,al
  1022.         xchg    DialCur,al
  1023.         push    ax
  1024.         call    ShowList
  1025.         pop    ax
  1026.         mov    DialCur,al
  1027.         call    CardEdit
  1028.         jmp    Main7
  1029. Main9:        cmp    al,'M'            ; [M]odem string
  1030.         jne    Main10
  1031.         xor    al,al
  1032.         xchg    DialCur,al
  1033.         push    ax
  1034.         call    ShowList
  1035.         pop    ax
  1036.         mov    DialCur,al
  1037.         mov    si,offset ModemScreen
  1038.         call    ShowScreen
  1039.         mov    si,offset ModemString
  1040.         mov    dx,word ptr ModemScreen
  1041.         add    dx,101h
  1042.         mov    bp,60
  1043.         call    EditASCIIZ
  1044.         jmp    Main7
  1045. Main10:        cmp    al,'S'            ; [S]ave
  1046.         jne    Main11
  1047.         call    SaveData
  1048.         jmp    Main7
  1049. Main11:        cmp    al,13            ; [Enter]
  1050.         jne    Main8
  1051.         cmp    SendPtr,0
  1052.         je    Main12
  1053.         mov    SendPtr,offset AbortString
  1054.         jmp    Main2
  1055. Main12:        mov    al,20
  1056.         mul    CardCur
  1057.         add    ax,offset CardList-20
  1058.         mov    SendCardAdr,ax
  1059.         mov    al,DialCur
  1060.         add    al,DialOfs
  1061.         dec    al
  1062.         mov    ah,70
  1063.         mul    ah
  1064.         add    ax,offset DialList
  1065.         mov    SendLineAdr,ax
  1066.         mov    SendPtr,offset ModemString
  1067.         mov    SendSub,0
  1068.         jmp    Main2
  1069. Main8:        cmp    al,27            ; [Esc]
  1070.         je    Main999
  1071.         jmp    Main2
  1072. Main999:    ret
  1073.  
  1074. Main        endp
  1075.         
  1076.  
  1077. ; Initialization --------------------------------------------------------------
  1078. ;
  1079. GoInit:        mov    ax,3508h        ; Get old INT 8 vector
  1080.         int    21h
  1081.         mov    OldInt8[0],bx
  1082.         mov    OldInt8[2],es
  1083.         cmp    es:IdString[0],'A'    ; Install in not 'AT&T' loaded
  1084.         jne    GoInitLoad
  1085.         cmp    es:IdString[1],'T'
  1086.         jne    GoInitLoad
  1087.         cmp    es:IdString[2],'&'
  1088.         jne    GoInitLoad
  1089.         cmp    es:IdString[3],'T'
  1090.         jne    GoInitLoad
  1091.         lds    dx,dword ptr es:OldInt8    ; Remove TSR from memory
  1092.         mov    ax,2508h
  1093.         int    21h
  1094.         mov    ah,49h
  1095.         int    21h
  1096.         push    cs            ; 'Unloaded'
  1097.         pop    ds
  1098.         mov    dx,offset Unload
  1099.         mov    ah,9
  1100.         int    21h
  1101.         mov    ah,4Ch
  1102.         int    21h
  1103. GoInitLoad:    mov    es,cs:[2Ch]        ; Find load-file (DIAL.COM)
  1104.         mov    di,1
  1105.         xor    ax,ax
  1106. GoInitLoad1:    dec    di
  1107.         scasw
  1108.         jne    GoInitLoad1
  1109.         add    di,2
  1110.         mov    si,di
  1111.         repne    scasb
  1112.         push    cs es
  1113.         pop    ds es
  1114.         mov    byte ptr [di-4],'D'    ; Replace '.COM' by '.DAT'
  1115.         mov    byte ptr [di-3],'A'
  1116.         mov    byte ptr [di-2],'T'
  1117.         mov    di,offset DataFile
  1118. GoInitLoad3:    movsb                ; Copy to file-buffer
  1119.         cmp    byte ptr [si-1],0
  1120.         jne    GoInitLoad3
  1121.         push    cs            ; DS = CS
  1122.         pop    ds
  1123.         mov    dx,offset DataFile    ; Try to open file
  1124.         mov    ax,3D00h
  1125.         int    21h
  1126.         jc    GoInitLoad4
  1127.         mov    bx,ax            ; Read if succesfull
  1128.         mov    dx,offset DataStart
  1129.         mov    cx,DataSize
  1130.         mov    ah,3Fh
  1131.         int    21h
  1132.         mov    ah,3Eh
  1133.         int    21h
  1134. GoInitLoad4:    mov    dx,offset LoadOk    ; 'OK'
  1135.         mov    ah,9
  1136.         int    21h
  1137.         mov    dx,offset MyInt8    ; Revector interrupt
  1138.         mov    ax,2508h
  1139.         int    21h
  1140.         mov    dx,offset GoInit
  1141.         int    27h
  1142.  
  1143. Unload        db    'AT&T dialer disabled!',13,10,'$'
  1144. LoadOk        db    'AT&T dialer loaded!',13,10,'$'
  1145.  
  1146.         code    ends
  1147.         end    Start
  1148.         
  1149.         
  1150.