about summary refs log blame commit diff stats
path: root/apps/tui.mu
blob: d65e35181992f4227d431cc7a755347fdea6311e (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11




                                     





                                 
                               

                               
                                       
                            
                               
                                           
                                 
                                  
                                 
                                  
 
                                                        



                                
                                       

                                 
                             

                       
# Test some primitives for text-mode.
#
# To run:
#   $ ./translate_mu apps/tui.mu
#   $ ./a.elf

fn main -> exit-status/ebx: int {
  var nrows/eax: int <- copy 0
  var ncols/ecx: int <- copy 0
  nrows, ncols <- screen-size
  enable-screen-grid-mode
  move-cursor-on-screen 5, 0x22
  start-color-on-screen 1, 0x7a
  start-blinking-on-screen
  print-string-to-screen "Hello world!"
  reset-formatting-on-screen
  move-cursor-on-screen 6, 0x22
  print-string-to-screen "tty dimensions: "
  print-int32-hex-to-screen nrows
  print-string-to-screen " rows, "
  print-int32-hex-to-screen ncols
  print-string-to-screen " rows\n"

  print-string-to-screen "press a key to see its code: "
  enable-keyboard-immediate-mode
  var x/eax: byte <- read-key
  enable-keyboard-type-mode
  enable-screen-type-mode
  print-string-to-screen "You pressed "
  var x-int/eax: int <- copy x
  print-int32-hex-to-screen x-int
  print-string-to-screen "\n"
  exit-status <- copy 0
}