?login_element?

Subversion Repositories NedoOS

Rev

Rev 1386 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.         MODULE OS_STDIO
  2.         PUBLIC initstdio, receivekey, sendchar, sendchars
  3.         PUBLIC yieldgetkeyloop
  4.         #include "sysdefs.asm"
  5.         RSEG CODE
  6.         #include "stdio.asm"
  7.         ENDMOD
  8.        
  9.         MODULE OS_INITSTDIO
  10.         PUBLIC os_initstdio
  11.         EXTERN initstdio
  12.         RSEG CODE
  13. os_initstdio
  14.         push bc
  15.         push de
  16.         push ix
  17.         push iy
  18.         call initstdio
  19.         pop iy
  20.         pop ix
  21.         pop de
  22.         pop bc
  23.         ret
  24.         ENDMOD
  25.        
  26.         MODULE TTYGETKEY
  27.         PUBLIC ttygetkey
  28.         EXTERN receivekey,exit
  29.         #include "sysdefs.asm"
  30.         RSEG CODE
  31. ttygetkey
  32.         push bc
  33.         push de
  34.         push ix
  35.         push iy
  36.         ld c,CMD_YIELD
  37.         call BDOS
  38.         call receivekey
  39.         cp key_esc
  40.         ld de,0
  41.         jp z,exit
  42.         ld l,a
  43.         ld h,0
  44.         pop iy
  45.         pop ix
  46.         pop de
  47.         pop bc
  48.         ret
  49.         ENDMOD
  50.  
  51.         MODULE TTYGETKEY_NE
  52.         PUBLIC ttygetkey_ne
  53.         EXTERN receivekey,exit
  54.         #include "sysdefs.asm"
  55.         RSEG CODE
  56. ttygetkey_ne
  57.         push bc
  58.         push de
  59.         push ix
  60.         push iy
  61.         ld c,CMD_YIELD
  62.         call BDOS
  63.         call receivekey
  64. ;       cp key_esc
  65. ;       ld de,0
  66. ;       jp z,exit
  67.         ld l,a
  68.         ld h,0
  69.         pop iy
  70.         pop ix
  71.         pop de
  72.         pop bc
  73.         ret
  74.         ENDMOD
  75.        
  76.         MODULE TTYPUTCHAR
  77.         PUBLIC ttyputchar
  78.         EXTERN sendchar
  79.         RSEG CODE
  80. ttyputchar
  81.         push bc
  82.         push de
  83.         push ix
  84.         push iy
  85.         ld a,e
  86.         call sendchar
  87.         pop iy
  88.         pop ix
  89.         pop de
  90.         pop bc
  91.         ret
  92.         ENDMOD
  93.        
  94.         MODULE TTYGETS
  95.         PUBLIC ttygets,bs_loop
  96.         EXTERN yieldgetkeyloop,exit,sendchars
  97.         EXTERN sendchar
  98.         #include "sysdefs.asm"
  99.         RSEG CODE
  100. ttygets
  101.         xor a
  102.         ld (de),a
  103.         ld (str_begin),de
  104.         push bc
  105.         push ix
  106.         push iy
  107. main_loop
  108.         push de
  109. main_loop1
  110.         call yieldgetkeyloop
  111.         or a
  112.         jr z,main_loop1
  113.         pop de
  114.         cp key_esc
  115.         jp z,exit
  116.         cp key_enter
  117.         jr nz,no_enter
  118.         ld de,str_rn
  119.         ld hl,2
  120.         call sendchars
  121. str_begin=$+1
  122.         ld hl,0
  123.         pop iy
  124.         pop ix
  125.         pop bc
  126.         ret
  127. str_rn
  128.         DEFB '\r\n'
  129. no_enter
  130.         cp key_left
  131.         jr nz,no_left
  132.         ld hl,(str_begin)
  133.         sbc hl,de
  134.         jr z,main_loop
  135.         dec de
  136. left_1
  137.         push de
  138.         ld hl,3
  139.         ld de,csi_left
  140.         call sendchars
  141.         jr main_loop1
  142. csi_left
  143.         DEFB '\x1b[D'
  144. no_left
  145.         cp key_right
  146.         jr nz,no_right
  147.         ld a,(de)
  148.         or a
  149.         jr z,main_loop
  150. right_1
  151.         inc de
  152.         push de
  153.         ld hl,3
  154.         ld de,csi_right
  155.         call sendchars
  156.         jr main_loop1
  157. csi_right
  158.         DEFB '\x1b[C'
  159. no_right
  160.         cp extH
  161.         jr nz,no_backspace
  162.         ld hl,(str_begin)
  163.         sbc hl,de
  164.         jr z,main_loop
  165.         push de
  166.         ld hl,3
  167.         ld de,csi_left
  168.         call sendchars
  169.         pop de
  170.         ld b,d
  171.         ld c,e
  172.         dec de
  173.         ld h,d
  174.         ld l,e
  175. bs_loop
  176.         ld a,(bc)
  177.         ld (hl),a
  178.         inc bc
  179.         inc hl
  180.         or a
  181.         jr nz,bs_loop
  182.         sbc hl,de
  183.         call puts_w_restore
  184.         jp main_loop
  185. no_backspace
  186.         cp 0xfc
  187.         jr nz,no_del
  188.         ld b,d
  189.         ld c,e
  190.         ld h,d
  191.         ld l,e
  192.         inc bc
  193. del_loop
  194.         ld a,(bc)
  195.         ld (hl),a
  196.         inc bc
  197.         inc hl
  198.         or a
  199.         jr nz,del_loop
  200.         sbc hl,de
  201.         call puts_w_restore
  202.         jp main_loop
  203. no_del
  204.         ld (store_ch),a
  205.         ld h,d
  206.         ld l,e
  207.         ld a,(hl)
  208. sh_right
  209.         inc hl
  210.         ld b,(hl)
  211.         ld (hl),a
  212.         or a
  213.         ld a,b
  214.         jr nz,sh_right
  215. store_ch=$+1
  216.         ld a,0
  217.         ld (de),a
  218.         sbc hl,de
  219.         call puts_w_restore
  220.         jr right_1
  221.        
  222. puts_w_restore
  223.         push de
  224.         ld (pw_size),hl
  225.         ld hl,3
  226.         ld de,csi_save_cursor
  227.         call sendchars
  228.         pop de
  229.         push de
  230. pw_size=$+1
  231.         ld hl,0
  232.         call sendchars
  233.         ld hl,4
  234.         ld de,csi_rest_cursor
  235.         call sendchars
  236.         pop de
  237.         ret
  238. csi_save_cursor
  239.         DEFB '\x1b[s'
  240. csi_rest_cursor
  241.         DEFB ' \x1b[u'
  242.         ENDMOD
  243.        
  244.         MODULE TTYPUTS
  245.         PUBLIC ttyputs
  246.         EXTERN sendchars,sendchar
  247.         RSEG CODE
  248. ttyputs
  249.         push bc
  250.         push ix
  251.         push iy
  252.         ld h,d
  253.         ld l,e
  254.         xor a
  255.         ld b,a
  256.         ld c,a
  257.         cpir
  258.         xor a
  259.         sbc hl,de
  260.         dec hl
  261.         call sendchars
  262.         ld a,'\r'
  263.         call sendchar
  264.         ld a,'\n'
  265.         call sendchar
  266.         pop iy
  267.         pop ix
  268.         pop bc
  269.         ld hl,0x0000
  270.         ret
  271.         ENDMOD
  272.        
  273.         MODULE TTY_PUTF
  274.         PUBLIC putf
  275.         EXTERN sendchars,sendchar
  276.         RSEG CODE
  277. putf
  278.         push bc
  279.         push ix
  280.         push iy
  281.         ld h,d
  282.         ld l,e
  283.         xor a
  284.         ld b,a
  285.         ld c,a
  286.         cpir
  287.         xor a
  288.         sbc hl,de
  289.         dec hl
  290.         push hl
  291.         call sendchars
  292.         pop hl
  293.         pop iy
  294.         pop ix
  295.         pop bc
  296.         ret
  297.         ENDMOD
  298.        
  299.         MODULE TTY_PUTCSI
  300.         PUBLIC putcsi
  301.         EXTERN sendchars,sendchar
  302.         RSEG CODE
  303. putcsi2
  304.         ld hl,4
  305.         jr $+3
  306. putcsi
  307.         ld hl,3
  308.         push bc
  309.         push ix
  310.         push iy
  311.         ld (csi+2),de
  312.         ld de,csi
  313.         call sendchars
  314.         pop iy
  315.         pop ix
  316.         pop bc
  317.         ld hl,0x0000
  318.         ret
  319. csi DEFB 0x1b,'[',0,0,0,0
  320.         ENDMOD
  321.  
  322.         MODULE PUTN
  323.         PUBLIC printn
  324.         EXTERN sendchars
  325.         RSEG CODE
  326. printn
  327.         push ix
  328.         push iy
  329.         ld h,b
  330.         ld l,c
  331.         call sendchars
  332.         pop iy
  333.         pop ix
  334.         ret
  335.         END