home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / TPOWER53.ZIP / TPASM.ARC / TPMACED.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-07-10  |  3.3 KB  |  124 lines

  1. ;******************************************************
  2. ;            TPMACED.ASM    5.07
  3. ;              Macro editor
  4. ;     Copyright (c) TurboPower Software 1987.
  5. ; Portions copyright (c) Sunny Hill Software 1985, 1986
  6. ;     and used under license to    TurboPower Software
  7. ;         All rights reserved.
  8. ;******************************************************
  9.  
  10.     INCLUDE    TPCOMMON.ASM
  11.  
  12. ;******************************************************    Data
  13.  
  14. DATA    SEGMENT    WORD PUBLIC
  15.  
  16.     ;Pascal    variables
  17.  
  18.     EXTRN    TempMacro : BYTE        ;temp macro used by editor
  19.     EXTRN    LoCol :    WORD            ;dimensions for    the editing
  20.     EXTRN    HiCol :    WORD            ; window
  21.     EXTRN    LoRow :    WORD
  22.     EXTRN    HiRow :    WORD
  23.     EXTRN    KnownKeyPtr : WORD        ;last Key whose    location was
  24.                         ; calculated
  25.     EXTRN    KnownRow : WORD            ;row for KnownKeyPtr
  26.     EXTRN    KnownCol : WORD            ;column    for KnownKeyPtr
  27.     EXTRN    RegKeyLength : BYTE        ;length    table for regular keys
  28.     EXTRN    AuxKeyLength : BYTE        ;length    table for aux. keys
  29.  
  30.  
  31. DATA    ENDS
  32.  
  33. ;******************************************************    Code
  34.  
  35. CODE    SEGMENT    BYTE PUBLIC
  36.  
  37.     ASSUME    CS:CODE,DS:DATA
  38.  
  39.     PUBLIC    ComputeScreenPos
  40.  
  41. ;******************************************************    ComputeScreenPos
  42.  
  43. ;procedure ComputeScreenPos(KeyPtr : Word; var Row, Col    : Word);
  44.  
  45. ;Compute the Row and Col positions for KeyPtr
  46.  
  47. KeyPtr        EQU    WORD PTR [BP+12]
  48. Row        EQU    DWORD PTR [BP+8]
  49. Col        EQU    DWORD PTR [BP+4]
  50.  
  51. ComputeScreenPos    PROC NEAR
  52.  
  53.     StackFrameBP
  54.     MOV    SI,KeyPtr            ;SI = KeyPtr
  55.     MOV    DI,KnownKeyPtr            ;DI has    KnownKeyPtr
  56.     CMP    SI,DI                ;KeyPtr    < KnownKeyPtr?
  57.     JB    FirstKey            ;If so,    start with 1st key
  58.     MOV    DX,KnownRow            ;DX has    KnownRow
  59.     MOV    CX,KnownCol            ;CX has    KnownCol
  60.     JMP    NextKey                ;Start searching
  61.  
  62. FirstKey:
  63.     MOV    DI,1                ;KnownKeyPtr = 1
  64.     MOV    DX,LoRow            ;KnownRow = LoRow
  65.     MOV    CX,LoCol            ;KnownCol = LoCol
  66.  
  67. NextKey:
  68.     CMP    DI,SI                ;KnownKeyPtr = KeyPtr?
  69.     JE    Done                ;If so,    done
  70.  
  71.     ;get the length    of the next key    in the macro
  72.  
  73.     SHL    DI,1                ;Key array is array of words
  74.     MOV    BX,WP TempMacro[DI]        ;Key :=    TempMacro.KeyArray[KnownKeyPtr]
  75.                         ;Note: we're treating NumKeys
  76.                         ;as the    0th element of the array
  77.     SHR    DI,1                ;undo the shift    left
  78.     CMP    BL,0E0h                ;Is it an enhanced keyboard key?
  79.     JE    NotRegular            ;If so,    not regular
  80.     OR    BL,BL                ;Lo(Key) = 0?
  81.     JNZ    RegularKey            ;if not, regular key
  82. NotRegular:
  83.     MOV    BL,BH                ;BL = scan code
  84.     SetZero    BH                ;BX = scan code
  85.     MOV    BL,AuxKeyLength[BX]        ;BL = length of    string
  86.     JMP    SHORT ComputeRowCol        ;compute next row and column
  87.  
  88. RegularKey:
  89.     SetZero    BH                ;BH = 0
  90.     MOV    BL,RegKeyLength[BX]        ;BL = length of    string
  91.  
  92. ComputeRowCol:
  93.     INC    DI                ;increment KnownKeyPtr
  94.     SetZero    BH                ;BH = 0
  95.     MOV    AX,CX                ;AX = KnownCol
  96.     ADD    AX,BX                ;AX = KnownCol + Len
  97.     CMP    AX,HiCol            ;AX > HiCol?
  98.     JA    NewRow                ;If so,    new row
  99.  
  100.     ADD    CX,BX                ;KnownCol = KnownCol + length
  101.     JMP    SHORT NextKey            ;next key
  102.  
  103. NewRow:
  104.     INC    DX                ;Increment KnownRow
  105.     MOV    CX,LoCol            ;KnownCol = LoCol
  106.     ADD    CX,BX                ;KnownCol = LoCol + length
  107.     JMP    SHORT NextKey            ;next key
  108.  
  109. Done:
  110.     MOV    KnownKeyPtr,DI            ;Save KnownKeyPtr
  111.     MOV    KnownCol,CX            ;Save KnownCol
  112.     MOV    KnownRow,DX            ;Save KnownRow
  113.     LES    DI,Col                ;ES:DI => Col
  114.     MOV    ES:[DI],CX            ;Col = KnownCol
  115.     LES    DI,Row                ;ES:DI => Row
  116.     MOV    ES:[DI],DX            ;Row = KnownRow
  117.     ExitCode 10
  118.  
  119. ComputeScreenPos    ENDP
  120.  
  121. CODE    ENDS
  122.  
  123.     END
  124.