[mips]
- libsys multitarget - apps multitarget git-svn-id: http://moon:8086/svn/mips@67 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
Executable
+164
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* 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 <assert.h>
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <board.h>
|
||||
#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));
|
||||
}
|
||||
Reference in New Issue
Block a user