Rev 1487 | Rev 1525 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1487 | Rev 1497 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | field = get_field_at(scr, scr->position_x, scr->position_y); |
41 | field = get_field_at(scr, scr->position_x, scr->position_y); |
42 | 42 | ||
43 | field->character = c; |
43 | field->character = c; |
44 | field->style = scr->style; |
44 | field->style = scr->style; |
45 | 45 | ||
46 | scr->position_x++; |
- | |
47 | if (scr->position_x == scr->size_x) { |
- | |
48 | scr->position_x = 0; |
- | |
49 | scr->position_y++; |
- | |
50 | if (scr->position_y == scr->size_y) { |
- | |
51 | /* scroll */ |
- | |
52 | scr->position_y--; |
- | |
53 | screenbuffer_clear_line(scr, scr->top_line++); |
- | |
54 | } |
- | |
55 | } |
- | |
56 | - | ||
57 | return 1; |
46 | return 1; |
58 | } |
47 | } |
59 | 48 | ||
60 | screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y) |
49 | screenbuffer_t *screenbuffer_init(screenbuffer_t *scr, int size_x, int size_y) |
61 | { |
50 | { |
Line 63... | Line 52... | ||
63 | return NULL; |
52 | return NULL; |
64 | } |
53 | } |
65 | 54 | ||
66 | scr->size_x = size_x; |
55 | scr->size_x = size_x; |
67 | scr->size_y = size_y; |
56 | scr->size_y = size_y; |
68 | scr->position_y = 0; |
- | |
69 | scr->position_x = 0; |
- | |
70 | scr->style.fg_color = DEFAULT_FOREGROUND_COLOR; |
57 | scr->style.fg_color = DEFAULT_FOREGROUND_COLOR; |
71 | scr->style.bg_color = DEFAULT_BACKGROUND_COLOR; |
58 | scr->style.bg_color = DEFAULT_BACKGROUND_COLOR; |
- | 59 | ||
72 | scr->top_line = 0; |
60 | screenbuffer_clear(scr); |
- | 61 | ||
73 | return scr; |
62 | return scr; |
74 | } |
63 | } |
75 | 64 | ||
76 | void screenbuffer_clear(screenbuffer_t *scr) |
65 | void screenbuffer_clear(screenbuffer_t *scr) |
77 | { |
66 | { |
78 | unsigned int i; |
67 | unsigned int i; |
79 | 68 | ||
80 | for (i = 0; i < scr->size_x * scr->size_y; i++) { |
69 | for (i = 0; i < (scr->size_x * scr->size_y); i++) { |
81 | scr->buffer[i].character = ' '; |
70 | scr->buffer[i].character = ' '; |
82 | scr->buffer[i].style = scr->style; |
71 | scr->buffer[i].style = scr->style; |
83 | } |
72 | } |
84 | 73 | ||
85 | scr->top_line = 0; |
74 | scr->top_line = 0; |
Line 111... | Line 100... | ||
111 | } |
100 | } |
112 | 101 | ||
113 | void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y) |
102 | void screenbuffer_goto(screenbuffer_t *scr, unsigned int x, unsigned int y) |
114 | { |
103 | { |
115 | scr->position_x = x % scr->size_x; |
104 | scr->position_x = x % scr->size_x; |
116 | scr->position_y = (y + scr->top_line) % scr->size_y; |
105 | scr->position_y = y % scr->size_y; |
117 | } |
106 | } |
118 | 107 |