diff --git a/lib/CPUs/MIPS/bsp/examples/libsys.c b/lib/CPUs/MIPS/bsp/examples/libsys.c index baaebd9..a2fb8d1 100644 --- a/lib/CPUs/MIPS/bsp/examples/libsys.c +++ b/lib/CPUs/MIPS/bsp/examples/libsys.c @@ -242,18 +242,37 @@ void _ser_putchar(char c) void cg_writechar(char c) { - volatile UINT32 *pCG_data = (UINT32*)sys_vga_data; + volatile UINT32 *pCG_ctrl = (UINT32*)sys_vga_ctrl; + volatile UINT32 *pCG_ascii = (UINT32*)sys_vga_ascii; - while (!(*pCG_data & 1)); - *pCG_data = (UINT32)c; + while (!(*pCG_ctrl & sys_vga_bit_cgrdy)); + *pCG_ascii = (UINT32)c; } void cg_clr_line(void) { - volatile UINT32 *pCG_clrline = (UINT32*)sys_vga_clrline; + volatile UINT32 *pCG_ctrl = (UINT32*)sys_vga_ctrl; + + while (!(*pCG_ctrl & sys_vga_bit_cgrdy)); + *pCG_ctrl |= sys_vga_bit_clrline; +} + +void cg_clr_screen(void) +{ + volatile UINT32 *pCG_ctrl = (UINT32*)sys_vga_ctrl; + volatile UINT32 *pCG_x = (UINT32*)sys_vga_posx; + volatile UINT32 *pCG_y = (UINT32*)sys_vga_posy; + + while (!(*pCG_ctrl & sys_vga_bit_cgrdy)); + *pCG_ctrl |= sys_vga_bit_clrscr; + + // Cursor home + while (!(*pCG_ctrl & sys_vga_bit_cgrdy)); + *pCG_x = 0; + + while (!(*pCG_ctrl & sys_vga_bit_cgrdy)); + *pCG_y = 0; - while (!(*pCG_clrline & 1)); - *pCG_clrline = 1; } void _cg_putchar(char c) diff --git a/lib/CPUs/MIPS/bsp/examples/libsys.h b/lib/CPUs/MIPS/bsp/examples/libsys.h index 8079df6..e3a5f02 100644 --- a/lib/CPUs/MIPS/bsp/examples/libsys.h +++ b/lib/CPUs/MIPS/bsp/examples/libsys.h @@ -58,14 +58,19 @@ #define sys_usb_mbx 0xA0020004 #define sys_usb_addr 0xA0020008 #define sys_usb_status 0xA002000C -#define sys_vga_data 0xA0030004 -#define sys_vga_posx 0xA0030008 -#define sys_vga_posy 0xA0030010 -#define sys_vga_clrscr 0xA0030020 -#define sys_vga_clrline 0xA0030040 -#define sys_vga_cgcol 0xA0030080 -#define sys_vga_mctrl 0xA0030100 -#define sys_vga_moffs 0xA0030200 +#define sys_vga_ctrl 0xA0030000 // R/W +#define sys_vga_bit_cgrdy 0x00000001 // RO +#define sys_vga_bit_msten 0x00000002 // R/W +#define sys_vga_bit_clrscr 0x00000010 // WO +#define sys_vga_bit_clrline 0x00000020 // WO +#define sys_vga_ascii 0xA0030004 // R/W +#define sys_vga_posx 0xA0030008 // R/W +#define sys_vga_posy 0xA003000C // R/W +#define sys_vga_cgcol 0xA0030010 // R/W +#define sys_vga_moffs 0xA0030014 // R/W +#define sys_vga_resx 0xA0030018 // RO +#define sys_vga_resy 0xA003001C // RO +#define sys_vga_fps 0xA0030020 // RO #define sys_ac97_stat 0xA0040000 #define sys_ac97_ctrl 0xA0040000 #define sys_ac97_acstat 0xA0040400 @@ -130,5 +135,13 @@ void sleep(unsigned ms); void PrintBuffer8(UINT8 *pBuf, int nbpr, int len); void memdump(UINT8 *pBuf, int print_offset_only, int num_bytes_per_row, int len); +// ------------------------------------ +// Character Generator functions +// ------------------------------------ +void cg_writechar(char c); +void cg_clr_line(void); +void cg_clr_screen(void); +void _cg_putchar(char c); + #endif // LIBSYS_H