/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ #include #include #include #include #include #include "screen.h" vga_if_t vga_if = { (uint32_t*)SYS_VGA_CTRL, (uint32_t*)SYS_VGA_ASCII, (uint32_t*)SYS_VGA_POSX, (uint32_t*)SYS_VGA_POSY }; void cg_open(void const *pInst) { assert (pInst); vga_if_t *pIF = (vga_if_t*)pInst; cg_clr_screen(&vga_if); } void cg_close(void const *pInst) { } void cg_writechar(void const *pInst, char c) { assert (pInst); vga_if_t *pIF = (vga_if_t*)pInst; uint32_t code; // Output translation switch(c) { case 'Ä': code = 196; break; case 'ä': code = 228; break; case 'Ö': code = 214; break; case 'ö': code = 246; break; case 'Ü': code = 220; break; case 'ü': code = 252; break; case '&': code = 230; break; case '§': code = 167; break; case 'ß': code = 223; break; case '°': code = 176; break; case 'µ': code = 181; break; default: code = (uint32_t)c; break; } while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pDATA = code; if (c == 0x0A) { cg_clr_line(pIF); while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pDATA = 0x0D; } } void cg_set_csr_x(vga_if_t *pIF, uint32_t coord) { assert (pIF); // Set cursor while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pCSRX = coord; } void cg_set_csr_y(vga_if_t *pIF, uint32_t coord) { assert (pIF); // Set cursor while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pCSRY = coord; } void cg_clr_line(vga_if_t *pIF) { assert (pIF); while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pCTRL |= SYS_VGA_BIT_CLRLINE; } void cg_clr_screen(vga_if_t *pIF) { assert (pIF); while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pCTRL |= SYS_VGA_BIT_CLRSCR; // Cursor home while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pCSRX = 0; while (!(*pIF->pCTRL & SYS_VGA_BIT_CGRDY)); *pIF->pCSRY = 0; } uint32_t Screen_get_resx(void) { uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES; return (0xFFF & (*pVGA_res >> 0)); } uint32_t Screen_get_resy(void) { uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES; return (0xFFF & (*pVGA_res >> 12)); } uint32_t Screen_get_fps(void) { uint32_t volatile *pVGA_res = (uint32_t*)SYS_VGA_RES; return (0xFF & (*pVGA_res >> 24)); }