Rev | Line | |
---|
[1] | 1 | #include "screen.h" |
---|
| 2 | #include <cpu-io.h> |
---|
| 3 | |
---|
| 4 | void scrollup(unsigned int n) |
---|
| 5 | { |
---|
| 6 | unsigned char *video, *tmp; |
---|
| 7 | |
---|
| 8 | for(video = (unsigned char *) RAMSCREEN; video < (unsigned char *) SCREENLIM; video += 2) |
---|
| 9 | { |
---|
| 10 | tmp = (unsigned char *) (video + n * 160); |
---|
| 11 | |
---|
| 12 | if(tmp < (unsigned char *) SCREENLIM) |
---|
| 13 | { |
---|
| 14 | *video = *tmp; |
---|
| 15 | *(video + 1) = *(tmp + 1); |
---|
| 16 | } else |
---|
| 17 | { |
---|
| 18 | *video = 0; |
---|
| 19 | *(video + 1) = 0x07; |
---|
| 20 | } |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | kY -= n; |
---|
| 24 | |
---|
| 25 | if(kY < 0) |
---|
| 26 | kY = 0; |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | void putcar(uint8_t c) |
---|
| 30 | { |
---|
| 31 | unsigned char *video; |
---|
| 32 | |
---|
| 33 | if(c == 10) /* CR-NL */ |
---|
| 34 | { |
---|
| 35 | kX = 0; |
---|
| 36 | kY++; |
---|
| 37 | } |
---|
| 38 | else if(c == 9) /* TAB */ |
---|
| 39 | { |
---|
| 40 | kX = kX + 8 - (kX % 8); |
---|
| 41 | } |
---|
| 42 | else if(c == 13) /* CR */ |
---|
| 43 | { |
---|
| 44 | kX = 0; |
---|
| 45 | } |
---|
| 46 | else |
---|
| 47 | { |
---|
| 48 | video = (unsigned char *) (RAMSCREEN + 2 * kX + 160 * kY); |
---|
| 49 | *video = c; |
---|
| 50 | *(video + 1) = kattr; |
---|
| 51 | |
---|
| 52 | kX++; |
---|
| 53 | if (kX > 79) |
---|
| 54 | { |
---|
| 55 | kX = 0; |
---|
| 56 | kY++; |
---|
| 57 | } |
---|
| 58 | } |
---|
| 59 | |
---|
| 60 | if (kY > 24) |
---|
| 61 | scrollup(kY - 24); |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | void move_cursor(uint8_t x, uint8_t y) |
---|
| 65 | { |
---|
| 66 | uint16_t c_pos; |
---|
| 67 | |
---|
| 68 | c_pos = y * 80 + x; |
---|
| 69 | |
---|
| 70 | cpu_io_out8(0x3d4, 0x0f); |
---|
| 71 | cpu_io_out8(0x3d5, (uint8_t) c_pos); |
---|
| 72 | cpu_io_out8(0x3d4, 0x0e); |
---|
| 73 | cpu_io_out8(0x3d5, (uint8_t) (c_pos >> 8)); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | void show_cursor(void) |
---|
| 77 | { |
---|
| 78 | move_cursor(kX, kY); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | void hide_cursor(void) |
---|
| 82 | { |
---|
| 83 | move_cursor(-1, -1); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | void dump (uint8_t* addr, int n) |
---|
| 87 | { |
---|
| 88 | char c1, c2; |
---|
| 89 | char *tab = "0123456789ABCDEF"; |
---|
| 90 | |
---|
| 91 | while(n--) { |
---|
| 92 | c1 = tab[(*addr & 0xF0)>>4]; |
---|
| 93 | c2 = tab[*addr & 0x0F]; |
---|
| 94 | addr++; |
---|
| 95 | putcar(c1); |
---|
| 96 | putcar(c2); |
---|
| 97 | } |
---|
| 98 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.