home *** CD-ROM | disk | FTP | other *** search
/ FreeWare Collection 2 / FreeSoftwareCollection2pd199x-jp.img / ms_dos / xscrfm51 / xinit.asm < prev    next >
Assembly Source File  |  1990-06-14  |  9KB  |  432 lines

  1.     title    xscript version 1.4 for FMR series
  2.     page    66, 132
  3. ;
  4. ;    Transcript service for PC-9801 MS-DOS ( Ver 1.4 )
  5. ;    Initialize routine.
  6. ;    Written by  Oka  /  Feb. 7, 1988.
  7. ;    Modified for FMR by SHU on Jan. 1989
  8. ;    Ver. 2.1 by SHU  /  Mar. 11, 1989
  9. ;    Ver. 2.2 by SHU  /  Mar. 21, 1989
  10. ;    Ver. 2.3 by SHU  /  Mar. 25, 1989
  11. ;    Ver. 3.0 by SHU  /  Apr.  1, 1989
  12. ;    Ver. 3.1 by SHU  /  Apr.  7, 1989
  13. ;    Ver. 3.2 by SHU  /  Apr. 11, 1989
  14. ;    Ver. 3.3 by SHU  /  Apr. 19, 1989
  15. ;    Ver. 3.4 by SHU  /  May. 11, 1989
  16. ;    Ver. 4.0 by SHU  /  May. 27, 1989
  17. ;    Ver. 4.2 by SHU  /  Jan. 13, 1990
  18. ;    Ver. 4.3 by SHU  /  Feb. 15, 1990
  19. ;
  20.  
  21. include xscript.h
  22.  
  23. code    segment  byte  public
  24.     assume    cs:code
  25.  
  26.  
  27. ;---------------------------------------;
  28. ;    initialize            ;
  29. ;---------------------------------------;
  30. public    init
  31. IFNDEF    FMR
  32.   extrn    kbtrap_init    : near
  33.   extrn    restore_int09h    : near
  34. ENDIF
  35. extrn    trap18h_entry    : near
  36. extrn    int18h_entry    : word
  37. extrn    trap29h_entry    : near
  38. extrn    int29h_entry    : word
  39. extrn    xservice_entry    : near
  40. extrn    org_xint_entry    : word
  41. extrn    my_name        : byte
  42. extrn    my_name_len    : word
  43. extrn    tvram_seg    : word
  44. extrn    txtbuf_seg    : word
  45. extrn    tvbuf_seg    : word
  46. extrn    xbank_on    : byte
  47. extrn    header_char    : byte
  48. extrn    always_paste    : byte
  49. IFDEF    FMR
  50.  extrn    use_gvram_flag    : byte
  51.  extrn    use_mm_flag    : byte
  52. ENDIF
  53.  
  54. IFDEF    FMR
  55.   last_addr_fm    label    word
  56. ENDIF
  57. remove_flag    db    OFF
  58. usage_flag    db    OFF
  59. now_option    db    OFF
  60.  
  61.  
  62. init:
  63.     call    get_option
  64.     cmp    remove_flag, ON        ; specified remove option (-R) ?
  65.     jne    init1
  66.     jmp    remove_exit        ; Yes
  67. init1:
  68.     cmp    usage_flag, ON
  69.     jne    init2
  70.     jmp    disp_usage
  71. init2:
  72.     call    check_exist        ; existency check.
  73.     jne    init9
  74.     jmp    exist_exit        ; already exist
  75. ;
  76. init9:
  77. IFDEF    FMR
  78.   IFDEF    FMR70
  79.     cmp    use_gvram_flag, ON
  80.     jne    init9_1
  81.     mov    cs:tvbuf_seg, TVBUF_SEG_R70G
  82.   ELSE
  83.     mov    cs:tvram_seg, TVRAM_SEG_R50
  84.     mov    cs:tvbuf_seg, TVBUF_SEG_R50
  85.     cmp    use_gvram_flag, ON
  86.     jne    init9_1
  87.     mov    cs:tvbuf_seg, TVBUF_SEG_R50G
  88.   ENDIF
  89. init9_1:
  90. ENDIF
  91. IFDEF    FMR
  92.     mov    ax, offset last_addr_fm
  93. ELSE
  94.     call    kbtrap_init        ; keyboard interrupt trap.
  95. ENDIF
  96.     mov    cl, 4
  97.     shr    ax, cl
  98.     inc    ax
  99.     mov    dx, ax
  100.     cmp    use_mm_flag, ON
  101.     jne    init9_2
  102.                     ; 主記憶上にバッファを確保
  103.     mov    ax, cs
  104.     add    ax, dx
  105.     mov    cs:tvbuf_seg, ax    ; set screen buffer segment
  106.     add    ax, 512            ; 8KB = 16B * 512
  107.     mov    cs:txtbuf_seg, ax    ; set transcript buffer segment
  108.     add    dx, 512 + 4096        ; 64KB = 16B * 4096
  109. init9_2:
  110.     mov    cs:last_addr, dx
  111.  
  112. IFDEF    FMR
  113.     mov    ax, 3590h        ; FM BIOS keyboard
  114. ELSE
  115.     mov    ax, 3518h
  116. ENDIF
  117.     int    21h
  118.     mov    int18h_entry, bx    ; int 18h のエントリ・ポイントを保存
  119.     mov    int18h_entry+2, es
  120.  
  121.     mov    ax, 3529h
  122.     int    21h
  123.     mov    int29h_entry, bx    ; int 29h のエントリ・ポイントを保存
  124.     mov    int29h_entry+2, es
  125.  
  126.     mov    ah, 35h
  127.     mov    al, XSERV_INT
  128.     int    21h
  129.     mov    org_xint_entry, bx    ; xscript int のエントリ・ポイントを保存
  130.     mov    org_xint_entry+2, es
  131.  
  132.     mov    dx, offset trap18h_entry
  133. IFDEF    FMR
  134.     mov    ax, 2590h
  135. ELSE
  136.     mov    ax, 2518h
  137. ENDIF
  138.     int    21h            ; set the keyboard bios entry address.
  139.  
  140.     mov    dx, offset trap29h_entry
  141.     mov    ax, 2529h        ; トラップ・ルーチンのエントリ・ポイントを
  142.     int    21h            ; int 29h に設定する
  143.  
  144.     mov    dx, offset xservice_entry
  145.     mov    ah, 25h
  146.     mov    al, XSERV_INT        ; transcript サービス・ルーチンの
  147.     int    21h            ; エントリ・ポイントを設定する
  148.  
  149.     mov    dx, offset op_msg    ; opening message.
  150.     mov    ah, 9
  151.     int    21h
  152.  
  153. ;    mov    ax, cs:last_addr    ; プログラムの残りを解放して、
  154. ;    mov    cl, 4
  155. ;    shr    ax, cl
  156. ;    inc    ax
  157. ;    mov    dx, ax
  158.  
  159.     mov    dx, cs:last_addr
  160.     mov    ax, 3100h
  161.     int    21h            ; 常駐終了
  162.  
  163.  
  164. ;---------------------------------------;
  165. ;    already exist            ;
  166. ;---------------------------------------;
  167. exist_exit:
  168.     mov    dx, offset exist_msg
  169.     jmp    short all_exit
  170.  
  171.  
  172. ;---------------------------------------;
  173. ;    usage を表示            ;
  174. ;---------------------------------------;
  175. disp_usage:
  176.     mov    dx, offset help_msg
  177.     jmp    short all_exit
  178.  
  179.  
  180. ;---------------------------------------;
  181. ;    xscript を解放して終了        ;
  182. ;---------------------------------------;
  183. remove_exit:
  184.     call    check_exist
  185.     je    remove1
  186.     mov    dx, offset not_exist_msg
  187.     jmp    short all_exit
  188.  
  189. remove1:
  190.     push    ds
  191.     lds    dx, dword ptr es:int18h_entry
  192. IFDEF    FMR
  193.     mov    ax, 2590h        ; int 90h のエントリ・ポイントを回復
  194. ELSE
  195.     mov    ax, 2518h        ; int 18h のエントリ・ポイントを回復
  196. ENDIF
  197.     int    21h
  198.  
  199.     lds    dx, dword ptr es:int29h_entry
  200.     mov    ax, 2529h        ; int 29h のエントリ・ポイントを回復
  201.     int    21h
  202.  
  203.     lds    dx, dword ptr es:org_xint_entry
  204.     mov    ah, 25h
  205.     mov    al, XSERV_INT        ; xscript int のエントリ・ポイントを回復
  206.     int    21h
  207.  
  208. IFNDEF    FMR
  209.     call    restore_int09h
  210. ENDIF
  211.     pop    ds
  212.  
  213. IFDEF    FMR
  214.     cmp    es:use_gvram_flag, OFF
  215.     je    remove1_1
  216.     push    es
  217.     mov    es, es:tvbuf_seg
  218.     xor    di, di
  219.     xor    ax, ax
  220.     mov    cx, 2000h
  221.     cld
  222.     rep    stosb            ; clear tvbuf memory
  223.   IFDEF    FMR70
  224.     pop    es
  225.     push    es
  226.     mov    es, es:txtbuf_seg
  227.     xor    di, di
  228.     mov    cx, 8000h
  229.     rep    stosw            ; clear txtbuf memory
  230.   ENDIF
  231.     mov    ah, 01h            ; set display mode
  232.     mov    al, 00h            ; show char & graphic plane
  233.     int    91h            ; call BIOS display
  234.     pop    es
  235. remove1_1:
  236. ENDIF
  237.     call    free_env
  238.     mov    ah, 49h            ; メモリー ノ カイホウ
  239.     int    21h
  240.  
  241.     mov    dx, offset remove_msg
  242. ;
  243. all_exit:
  244.     mov    ah, 9            ; メッセージ ヲ ヒョウジ シテ
  245.     int    21h
  246.     mov    ax, 4C00h        ; シュウリョウ
  247.     int    21h
  248.  
  249. free_env:
  250.     push    es
  251.     mov    ax, es:[2Ch]        ; カンキョウ ヘンスウ リョウイキ
  252.     cmp    ax, 0
  253.     je    no_env
  254.     mov    es, ax
  255.     mov    ah, 49h            ; メモリー ノ カイホウ
  256.     int    21h
  257. no_env:
  258.     pop    es
  259.     mov    word ptr es:[2Ch], 0
  260.     ret
  261.  
  262.  
  263. ;---------------------------------------;
  264. ;    existency check            ;
  265. ;  out  ZERO  on .. exist        ;
  266. ;         off .. not exist        ;
  267. ;---------------------------------------;
  268. check_exist:
  269.     call    get_xscr_seg
  270.     mov    di, offset my_name
  271.     mov    si, offset my_name
  272. ;    mov    cx, 20
  273.     mov    cx, my_name_len
  274.     cld
  275.     repe    cmpsb
  276.     ret
  277.  
  278.  
  279. ;-----------------------------------------------;
  280. ;   xscript routine のセグメントの取り出し    ;
  281. ;-----------------------------------------------;
  282. get_xscr_seg:
  283.     sub    ax, ax
  284.     mov    es, ax
  285.     mov    es, es:[XSERV_INT*4+2]
  286.     ret
  287.  
  288.  
  289. ;---------------------------------------;
  290. ;    オプションパラメータの取り出し    ;
  291. ;---------------------------------------;
  292. get_option:
  293.     cld
  294.     mov    si, 81h            ; beginning of option line.
  295. get_opt1:
  296.     call    get_1opt        ; get 1 option specifier.
  297.     cmp    al, ' '
  298.     jb    get_opt2        ; end of line.
  299.     call    opt_toupper        ; convert into uppercase.
  300.     call    set_opt_var        ; set option variable.
  301.     jmp    get_opt1        ; continue.
  302. get_opt2:
  303.     ret
  304.  
  305.  
  306. ;---------------------------------------;
  307. ;    オプションラインを大文字化する    ;
  308. ;---------------------------------------;
  309. opt_toupper:
  310.     cmp    al, 'a'
  311.     jb    opt_up2
  312.     cmp    al, 'z'
  313.     ja    opt_up2
  314.     sub    al, 20h
  315. opt_up2:
  316.     ret
  317.  
  318.  
  319. ;---------------------------------------;
  320. ;    1オプション指定文字を得る    ;
  321. ;---------------------------------------;
  322. get_1opt:
  323.     lodsb
  324.     cmp    al, ' '
  325.     jb    get_1opt2
  326.     jne    get_1opt0
  327.     mov    now_option, OFF
  328. get_1opt0:
  329.     cmp    now_option, ON
  330.     je    get_1opt2
  331.     cmp    al, '-'
  332.     je    get_1opt1
  333.     cmp    al, '/'
  334.     jne    get_1opt
  335. get_1opt1:
  336.     lodsb
  337.     mov    now_option, ON
  338. get_1opt2:
  339.     ret
  340.  
  341.  
  342. ;---------------------------------------;
  343. ;    オプション変数に値をセット    ;
  344. ;---------------------------------------;
  345. set_opt_var:
  346.     cmp    al, 'R'            ; Remove option ?
  347.     jne    set_opt1
  348.     mov    remove_flag, ON
  349.     ret
  350. set_opt1:
  351.     cmp    al, 'M'            ; Use main memory
  352.     jne    set_opt2
  353.     mov    use_mm_flag, ON
  354.     ret
  355. set_opt2:
  356.     cmp    al, '?'
  357.     jne    set_opt4
  358. set_opt3:
  359.     mov    usage_flag, ON
  360.     ret
  361. set_opt4:
  362.     cmp    al, 'H'
  363.     je    set_opt3
  364.     
  365.     cmp    al, 'I'
  366.     jne    set_opt5
  367.     lodsb
  368.     mov    cs:header_char, al
  369.     ret
  370. set_opt5:
  371.     cmp    al, 'A'
  372.     jne    set_opt6
  373.     lodsb
  374.     sub    al, '0'
  375.     mov    cs:always_paste, al
  376.     ret
  377. set_opt6:
  378.     cmp    al, 'E'
  379.     jne    set_opt7
  380.     call    free_env
  381.     ret
  382. set_opt7:
  383. IFDEF    FMR
  384.     cmp    al, 'G'            ; Use graphic VRAM
  385.     jne    set_opt9
  386.     mov    use_gvram_flag, ON
  387.     mov    cs:xbank_on, BANK_R_P0
  388.     mov    ah, 01h            ; set display mode
  389.     mov    al, 0Ah            ; disable graphic plane
  390.     int    91h            ; call BIOS display
  391.     ret
  392. set_opt9:
  393. ENDIF
  394.     dec    si
  395.     mov    now_option, OFF
  396.     ret
  397.  
  398. last_addr  dw    ?
  399.  
  400. help_msg    db    'XSCRIPT(', VERSION, '): '
  401.         db    'xscript [-r|-?|-h|-[eiagm]..]',CR,LF
  402.         db    '     r : remove xscript',CR,LF
  403.         db    '     ? : show help',CR,LF
  404.         db    '     h : show help',CR,LF
  405.         db    '     e : free environment area',CR,LF
  406.         db    '     iC: set C to include char',CR,LF
  407.         db    '     a0: include with SHIFT key(default)',CR,LF
  408.         db    '     a1: include with non-SHIFT key',CR,LF
  409.         db    '     a2: include always',CR,LF
  410.         db    '     g : use graphic VRAM',CR,LF
  411.         db    '     m : use main memory',CR,LF
  412.         db    '$'
  413. not_exist_msg    db    'The transcript service not installed',CR,LF,'$'
  414. exist_msg    db    'The transcript service already installed',CR,LF,'$'
  415. remove_msg      db      'Remove the transcript service',CR,LF,'$'
  416. op_msg        db    'Install the transcript service (Ver 1.4)  by  Oka, Appne, ish and Locus',CR,LF
  417. IFDEF    FMR
  418.   IFDEF    FMR50
  419.         db    09,VERSIONL,' (FMR-10LT/30/50/60:16dot/FM16β)  by  SHU',CR,LF,'$'
  420.   ELSE
  421.     IFDEF  FMTOWNS
  422.         db    09,VERSIONL,' (FMTOWNS:MS-DOS)  by  SHU',CR,LF,'$'
  423.     ELSE
  424.         db    09,VERSIONL,' (FMR-60/70)  by  SHU',CR,LF,'$'
  425.     ENDIF
  426.   ENDIF
  427. ENDIF
  428.  
  429. code    ends
  430.  
  431.     end
  432.