?login_element?

Subversion Repositories NedoOS

Rev

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