142 lines
2.5 KiB
C
142 lines
2.5 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include "irq.h"
|
|
#include "libsys.h"
|
|
|
|
int enable_response;
|
|
|
|
#define ATTR_RESET 0
|
|
#define ATTR_CSR_BRIGHT 1
|
|
#define ATTR_CSR_DIM 2
|
|
#define ATTR_CSR_UNDERSCORE 4
|
|
#define ATTR_CSR_BLINK 5
|
|
#define ATTR_CSR_REVERSE 7
|
|
#define ATTR_CSR_HIDDEN 8
|
|
#define ATTR_FORE_BLACK 30
|
|
#define ATTR_FORE_RED 31
|
|
#define ATTR_FORE_GREEN 32
|
|
#define ATTR_FORE_YELLOW 33
|
|
#define ATTR_FORE_BLUE 34
|
|
#define ATTR_FORE_MAGENTA 35
|
|
#define ATTR_FORE_CYAN 36
|
|
#define ATTR_FORE_WHITE 37
|
|
#define ATTR_BACK_BLACK 40
|
|
#define ATTR_BACK_RED 41
|
|
#define ATTR_BACK_GREEN 42
|
|
#define ATTR_BACK_YELLOW 43
|
|
#define ATTR_BACK_BLUE 44
|
|
#define ATTR_BACK_MAGENTA 45
|
|
#define ATTR_BACK_CYAN 46
|
|
#define ATTR_BACK_WHITE 47
|
|
|
|
|
|
void ISR_serial_rx(void)
|
|
{
|
|
volatile UINT32 *pUART_stat = (UINT32*)sys_uart_stat;
|
|
volatile UINT32 *pUART_data = (UINT32*)sys_uart_data;
|
|
|
|
while((0x10 & *pUART_stat))
|
|
{
|
|
if (enable_response)
|
|
print_byte((char)*pUART_data);
|
|
}
|
|
|
|
}
|
|
|
|
void VT100_CSR_SETPOS(int x, int y)
|
|
{
|
|
char str[64];
|
|
|
|
sprintf(str, "[%d;%dH", y, x);
|
|
writechar(0x1B);
|
|
sputs(str);
|
|
}
|
|
|
|
void VT100_CSR_MOVE_UP(int count)
|
|
{
|
|
char str[64];
|
|
|
|
sprintf(str, "[%dA", count);
|
|
writechar(0x1B);
|
|
sputs(str);
|
|
}
|
|
|
|
void VT100_CSR_MOVE_DOWN(int count)
|
|
{
|
|
char str[64];
|
|
|
|
sprintf(str, "[%dB", count);
|
|
writechar(0x1B);
|
|
sputs(str);
|
|
}
|
|
|
|
void VT100_CSR_MOVE_LEFT(int count)
|
|
{
|
|
char str[64];
|
|
|
|
sprintf(str, "[%dD", count);
|
|
writechar(0x1B);
|
|
sputs(str);
|
|
}
|
|
|
|
void VT100_CSR_MOVE_RIGHT(int count)
|
|
{
|
|
char str[64];
|
|
|
|
sprintf(str, "[%dC", count);
|
|
writechar(0x1B);
|
|
sputs(str);
|
|
}
|
|
|
|
void VT100_ERASE_SCREEN(void)
|
|
{
|
|
writechar(0x1B);
|
|
sputs("[2J");
|
|
}
|
|
|
|
void VT100_SCROLL_ENABLE(void)
|
|
{
|
|
writechar(0x1B);
|
|
sputs("[r");
|
|
}
|
|
|
|
void VT100_ATTR_SET(int attribute)
|
|
{
|
|
char str[64];
|
|
|
|
sprintf(str, "[%dm", attribute);
|
|
writechar(0x1B);
|
|
sputs(str);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
int i, x, y;
|
|
// interrupt_register(3, ISR_serial_rx);
|
|
// interrupt_enable(3);
|
|
|
|
VT100_ERASE_SCREEN();
|
|
VT100_SCROLL_ENABLE();
|
|
printf("VT100 test:\n");
|
|
|
|
for (i=0; i < 8000; i++)
|
|
{
|
|
printf("\n");
|
|
VT100_ATTR_SET(ATTR_FORE_RED);
|
|
x = (int)(40*(1.1+sin((2*M_PI*i)/80)));
|
|
VT100_CSR_MOVE_RIGHT(x);
|
|
writechar('o');
|
|
writechar(0x0D);
|
|
VT100_ATTR_SET(ATTR_FORE_BLUE);
|
|
x = (int)(40*(1.1+cos((2*M_PI*i)/80)));
|
|
VT100_CSR_MOVE_RIGHT(x);
|
|
writechar('+');
|
|
}
|
|
|
|
printf("\n");
|
|
VT100_ATTR_SET(ATTR_RESET);
|
|
return 0;
|
|
}
|