about summary refs log tree commit diff stats
path: root/translate_subx_emulated
Commit message (Expand)AuthorAgeFilesLines
* shell: literal imagesKartik K. Agaram2021-07-281-1/+1
* shell: render image from pbm data streamKartik K. Agaram2021-07-271-1/+1
* update memory map doc and anticipate a gotchaKartik K. Agaram2021-07-221-0/+6
* grow code region yet againKartik K. Agaram2021-07-051-1/+1
* fix emulated buildKartik K. Agaram2021-06-181-2/+2
* ok, function modal now has full coverageKartik K. Agaram2021-06-081-1/+1
* shell: skeleton for scrollingKartik K. Agaram2021-05-291-1/+1
* grow a few buffers until shell/ loadsKartik K. Agaram2021-05-151-2/+2
* load debug info from disk on abortKartik K. Agaram2021-05-141-1/+7
* fixup! load debug info into code diskKartik K. Agaram2021-05-141-1/+9
* insert a compile phase to emit some debug infoKartik K. Agaram2021-05-141-8/+18
* shell: ctrl-r runs on real screen without a traceKartik K. Agaram2021-04-171-1/+1
* .Kartik K. Agaram2021-04-161-3/+3
* rename boot.hex to boot.subxKartik K. Agaram2021-03-141-1/+1
* treat boot.hex as a SubX fileKartik K. Agaram2021-03-141-6/+4
* 7842 - new directory organizationKartik K. Agaram2021-03-031-15/+31
* 7440Kartik Agaram2020-12-281-9/+9
* 7439 - start translating Mu programs to baremetalKartik Agaram2020-12-281-1/+1
* 7401 - clean up support for non-Linux platformsKartik Agaram2020-12-251-18/+7
* 6401 - have scripts follow the Unix wayKartik Agaram2020-05-241-17/+0
* 5865Kartik Agaram2020-01-021-9/+9
* 5851Kartik Agaram2020-01-011-0/+50
17:40:25 -0700 committer Kartik K. Agaram <vc@akkartik.com> 2015-04-20 17:40:25 -0700 1115 - another pass at names: console and display' href='/akkartik/mu/commit/cpp/070display?h=hlt&id=ec961781d0dd952384d08639b74f4b5a14942259'>ec961781 ^
5f128523 ^
54d48b25 ^



12d73ee8 ^




5f128523 ^

12d73ee8 ^








5f128523 ^





12d73ee8 ^








dcfca05e ^
5f128523 ^

















12d73ee8 ^








12d73ee8 ^
5f128523 ^
dcfca05e ^
12d73ee8 ^
5f128523 ^
dcfca05e ^
12d73ee8 ^








dcfca05e ^

5f128523 ^



12d73ee8 ^





f08a13e1 ^
54d48b25 ^
f08a13e1 ^
54d48b25 ^
f08a13e1 ^
5f128523 ^

54d48b25 ^

5f128523 ^


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
                                                      
 

                       


                                           
                                             
                  
                                        
                                                       
                                                
                         

                                   



                                             
                  
                                        
                                                       
                                                
                         
                



                                             




                                                

                                   








                                                               





                                                              








                                                                         
                                                                      

















                                                                            








                                                                         
                  
                             
                                                       
                     
                                   
                                                          








                                                                 

                                                                         



                                             





                                             
                           
                                        
                                                                         
                                                
                                  

                        

        


                           
//: Take charge of the text-mode display and keyboard.

//:: Display management

:(before "End Globals")
size_t Display_row = 0, Display_column = 0;

:(before "End Primitive Recipe Declarations")
SWITCH_TO_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["switch-to-display"] = SWITCH_TO_DISPLAY;
:(before "End Primitive Recipe Implementations")
case SWITCH_TO_DISPLAY: {
  tb_init();
  Display_row = Display_column = 0;
  break;
}

:(before "End Primitive Recipe Declarations")
RETURN_TO_CONSOLE,
:(before "End Primitive Recipe Numbers")
Recipe_number["return-to-console"] = RETURN_TO_CONSOLE;
:(before "End Primitive Recipe Implementations")
case RETURN_TO_CONSOLE: {
  tb_shutdown();
  break;
}

:(before "End Primitive Recipe Declarations")
CLEAR_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["clear-display"] = CLEAR_DISPLAY;
:(before "End Primitive Recipe Implementations")
case CLEAR_DISPLAY: {
  tb_clear();
  Display_row = Display_column = 0;
  break;
}

:(before "End Primitive Recipe Declarations")
CLEAR_LINE_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["clear-line-on-display"] = CLEAR_LINE_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case CLEAR_LINE_ON_DISPLAY: {
  size_t width = tb_width();
  for (size_t x = Display_column; x < width; ++x) {
    tb_change_cell(x, Display_row, ' ', TB_WHITE, TB_DEFAULT);
  }
  tb_set_cursor(Display_column, Display_row);
  tb_present();
  break;
}

:(before "End Primitive Recipe Declarations")
PRINT_CHARACTER_TO_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["print-character-to-display"] = PRINT_CHARACTER_TO_DISPLAY;
:(before "End Primitive Recipe Implementations")
case PRINT_CHARACTER_TO_DISPLAY: {
  vector<int> arg = read_memory(current_instruction().ingredients[0]);
  int h=tb_height(), w=tb_width();
  size_t height = (h >= 0) ? h : 0;
  size_t width = (w >= 0) ? w : 0;
  if (arg[0] == '\n') {
    if (Display_row < height) {
      Display_column = 0;
      ++Display_row;
      tb_set_cursor(Display_column, Display_row);
      tb_present();
    }
    break;
  }
  tb_change_cell(Display_column, Display_row, arg[0], TB_WHITE, TB_DEFAULT);
  if (Display_column < width) {
    Display_column++;
    tb_set_cursor(Display_column, Display_row);
  }
  tb_present();
  break;
}

:(before "End Primitive Recipe Declarations")
CURSOR_POSITION_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["cursor-position-on-display"] = CURSOR_POSITION_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case CURSOR_POSITION_ON_DISPLAY: {
  vector<int> row;
  row.push_back(Display_row);
  write_memory(current_instruction().products[0], row);
  vector<int> column;
  column.push_back(Display_column);
  write_memory(current_instruction().products[1], column);
  break;
}

:(before "End Primitive Recipe Declarations")
MOVE_CURSOR_ON_DISPLAY,
:(before "End Primitive Recipe Numbers")
Recipe_number["move-cursor-on-display"] = MOVE_CURSOR_ON_DISPLAY;
:(before "End Primitive Recipe Implementations")
case MOVE_CURSOR_ON_DISPLAY: {
  vector<int> row = read_memory(current_instruction().ingredients[0]);
  vector<int> column = read_memory(current_instruction().ingredients[1]);
  Display_row = row[0];
  Display_column = column[0];
  tb_set_cursor(Display_column, Display_row);
  tb_present();
  break;
}

//:: Keyboard management

:(before "End Primitive Recipe Declarations")
WAIT_FOR_KEY_FROM_KEYBOARD,
:(before "End Primitive Recipe Numbers")
Recipe_number["wait-for-key-from-keyboard"] = WAIT_FOR_KEY_FROM_KEYBOARD;
:(before "End Primitive Recipe Implementations")
case WAIT_FOR_KEY_FROM_KEYBOARD: {
  struct tb_event event;
  tb_poll_event(&event);
  break;
}

:(before "End Includes")
#include"termbox/termbox.h"