- initial import

git-svn-id: http://moon:8086/svn/mips@1 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2014-07-20 15:01:37 +00:00
commit 26291bca3d
1549 changed files with 3997969 additions and 0 deletions
+178
View File
@@ -0,0 +1,178 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <sys/times.h>
#include <sys/time.h>
#include "libsys.h"
#include "gpio.h"
#include "mips_gfx.h"
#define PIC_NX 800
#define PIC_NY 600
gpio_if_t gpio_if;
box_t box;
gfx_t gfx;
UINT32 color_cycle[12] = {0x000000FF, 0x00808080, 0x0000FFFF, 0x00808080, 0x0000FF00, 0x00808080, 0x00FFFF00, 0x00808080, 0x00FF0000, 0x00808080, 0x00FF00FF, 0x00808080};
void BlitConstColor(UINT32 fb_addr, UINT32 dim_x, UINT32 pos_x, UINT32 pos_y, UINT32 size_x, UINT32 size_y, UINT32 color);
void Blit(UINT32 fb_addr, UINT32 dim_x, UINT32 pos_x_src, UINT32 pos_y_src, UINT32 pos_x_dst, UINT32 pos_y_dst, UINT32 size_x, UINT32 size_y);
int main (void)
{
int result, i, j, cnt, size;
UINT32 volatile *pUART_baud = (UINT32*)SYS_UART_BAUD;
UINT32 volatile *pUART_stat = (UINT32*)SYS_UART_STAT;
UINT32 volatile *pGPIO = (UINT32*)SYS_GPIO_0_DATA;
UINT32 volatile *pReg_usec = (UINT32*)SYS_TIMER_USEC;
UINT32 volatile *pReg_sec = (UINT32*)SYS_TIMER_SEC;
UINT32 volatile *pSSRAM = (UINT32*)SYS_SSRAM_IO;
UINT32 volatile *pTim_ctrl = (UINT32*)SYS_ITIM_CTRL;
UINT32 volatile *pTim_stat = (UINT32*)SYS_ITIM_STAT;
UINT32 volatile *pTim0_cnt = (UINT32*)SYS_ITIM0_CNT;
UINT32 volatile *pTim0_cmp = (UINT32*)SYS_ITIM0_CMP;
UINT32 volatile *pTim1_cnt = (UINT32*)SYS_ITIM1_CNT;
UINT32 volatile *pTim1_cmp = (UINT32*)SYS_ITIM1_CMP;
UINT32 volatile *pVGA_cgcol = (UINT32*)SYS_VGA_CGCOL;
UINT32 volatile *pFlashPicture = (UINT32*)(SYS_FLASH_MEM + 0x00600000);
UINT32 volatile *pVGA_src0 = (UINT32*)SYS_VGA_BLIT_SRC0;
UINT32 volatile *pVGA_dst = (UINT32*)SYS_VGA_BLIT_DST;
UINT32 volatile *pVGA_dimx_src0 = (UINT32*)SYS_VGA_BLIT_SRC0_DIMX;
UINT32 volatile *pVGA_dimx_dst = (UINT32*)SYS_VGA_BLIT_DST_DIMX;
UINT32 volatile *pVGA_nx = (UINT32*)SYS_VGA_BLIT_NX;
UINT32 volatile *pVGA_ny = (UINT32*)SYS_VGA_BLIT_NY;
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
UINT32 volatile *pVGA_moffs_0 = (UINT32*)SYS_VGA_FB_FRONT;
UINT32 volatile *pVGA_moffs_1 = (UINT32*)SYS_VGA_FB_BACK;
UINT32 volatile *pVGA_const_color = (UINT32*)SYS_VGA_BLIT_DST_LAST;
UINT32 screen_res_x, screen_res_y, screen_fps;
UINT32 pos, posx, posy, xoff, yoff, color;
UINT64 *pBuf64_0, *pBuf64_1;
time_t curr_date;
struct tm *pDate, date;
UINT32 start, end;
char sel[80];
struct timeval time_sec;
Screen_clr();
gpio_init(&gpio_if, SYS_GPIO_0_BASE);
*pVGA_ctrl &= ~SYS_VGA_BIT_BLIT_FIN_INTEN;
*pVGA_cgcol = 0x00FFFFFF;
pBuf64_0 = (UINT64*)malloc(800*600*4);
*pVGA_moffs_0 = (UINT32)pBuf64_0;
*pVGA_moffs_1 = (UINT32)pBuf64_0;
*pVGA_ctrl |= SYS_VGA_BIT_MSTEN;
// GFX_init(&gfx);
while(1)
{
box_create(&box, 128, 128);
*pVGA_dimx_src0 = (UINT32)4*800;
*pVGA_dimx_dst = (UINT32)4*800;
*pVGA_nx = (UINT32)box.w;
*pVGA_ny = (UINT32)box.h;
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_OP_CONSTCOL;
*pVGA_dst = (UINT32)*pVGA_moffs_0 + 4*(5 + 800*5);// + 4*((UINT32)rand()%800 + 800*((UINT32)rand()%600));
*pGPIO = 1;
color = 0;
for (i=0; i < 100; i++)
{
// Blitter test
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_BSY);
color = ~color;
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
*pVGA_const_color = color;
}
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_ACTIVE);
// fprintf(stdout, "Hardware draw 1\n");
// sleep(1000);
*pGPIO = 0;
color = 0;
for (i=0; i < 100; i++)
{
// Blitter test
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_BSY);
*pVGA_const_color = color;
color = ~color;
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
}
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_ACTIVE);
// fprintf(stdout, "Hardware draw 2\n");
// sleep(1000);
}
}
void BlitConstColor(UINT32 fb_addr, UINT32 dim_x, UINT32 pos_x, UINT32 pos_y, UINT32 size_x, UINT32 size_y, UINT32 color)
{
UINT32 volatile *pVGA_src0 = (UINT32*)SYS_VGA_BLIT_SRC0;
UINT32 volatile *pVGA_dst = (UINT32*)SYS_VGA_BLIT_DST;
UINT32 volatile *pVGA_dimx_src0 = (UINT32*)SYS_VGA_BLIT_SRC0_DIMX;
UINT32 volatile *pVGA_dimx_dst = (UINT32*)SYS_VGA_BLIT_DST_DIMX;
UINT32 volatile *pVGA_nx = (UINT32*)SYS_VGA_BLIT_NX;
UINT32 volatile *pVGA_ny = (UINT32*)SYS_VGA_BLIT_NY;
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
UINT32 volatile *pVGA_moffs_0 = (UINT32*)SYS_VGA_FB_FRONT;
UINT32 volatile *pVGA_const_color = (UINT32*)SYS_VGA_BLIT_DST_LAST;
// fprintf(stdout, "BlitConstColor to (%d,%d), size (%d,%d) ...", pos_x, pos_y, size_x, size_y);
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_OP_CONSTCOL;
*pVGA_const_color = color;
*pVGA_dst = fb_addr + 4*(pos_x + pos_y*dim_x);
*pVGA_dimx_dst = 4*dim_x;
*pVGA_nx = size_x - 0;
*pVGA_ny = size_y - 0;
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_BSY);
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
// fprintf(stdout, "done\n");
}
void Blit(UINT32 fb_addr, UINT32 dim_x, UINT32 pos_x_src, UINT32 pos_y_src, UINT32 pos_x_dst, UINT32 pos_y_dst, UINT32 size_x, UINT32 size_y)
{
UINT32 volatile *pVGA_src0 = (UINT32*)SYS_VGA_BLIT_SRC0;
UINT32 volatile *pVGA_dst = (UINT32*)SYS_VGA_BLIT_DST;
UINT32 volatile *pVGA_dimx_src0 = (UINT32*)SYS_VGA_BLIT_SRC0_DIMX;
UINT32 volatile *pVGA_dimx_dst = (UINT32*)SYS_VGA_BLIT_DST_DIMX;
UINT32 volatile *pVGA_nx = (UINT32*)SYS_VGA_BLIT_NX;
UINT32 volatile *pVGA_ny = (UINT32*)SYS_VGA_BLIT_NY;
UINT32 volatile *pVGA_ctrl = (UINT32*)SYS_VGA_CTRL;
UINT32 volatile *pVGA_moffs_0 = (UINT32*)SYS_VGA_FB_FRONT;
UINT32 volatile *pVGA_const_color = (UINT32*)SYS_VGA_BLIT_DST_LAST;
// fprintf(stdout, "Blit from (%d,%d) to (%d,%d), size (%d,%d) ...", pos_x_src, pos_y_src, pos_x_dst, pos_y_dst, size_x, size_y);
*pVGA_ctrl &= ~SYS_VGA_BIT_BLIT_OP_CONSTCOL;
*pVGA_src0 = fb_addr + 4*(pos_x_src + pos_y_src*dim_x);
*pVGA_dimx_src0 = 4*dim_x;
*pVGA_dst = fb_addr + 4*(pos_x_dst + pos_y_dst*dim_x);
*pVGA_dimx_dst = 4*dim_x;
*pVGA_nx = size_x - 0;
*pVGA_ny = size_y - 0;
while (*pVGA_ctrl & SYS_VGA_BIT_BLIT_BSY);
*pVGA_ctrl |= SYS_VGA_BIT_BLIT_REQ;
// fprintf(stdout, "done\n");
}