void do_frame() { int x, y, z; int size; int i; float col; glKosBeginFrame(); vid_border_color(0,255,0); glBegin(GL_TRIANGLES); for (i=0; i<polycnt; i++) { x = rand() % 640; y = rand() % 480; z = rand() % 100 + 1; size = rand() % 50; col = (rand () % 255) * 0.00391f; glColor3f(col, col, col); glVertex3f(x-size, y+size, z); glVertex3f(x-size, y-size, z); glVertex3f(x+size, y+size, z); } glEnd(); vid_border_color(255,0,0); glKosFinishFrame(); vid_border_color(0,0,0); }
static void spu_cb(void * p) { if (p) { dma_chain_t * chain = (dma_chain_t *) p; if (chain->src == NULL) { free_chain(chain); } else { sem_signal(chain->sema); if (chain->waiting_thd) thd_schedule_next(chain->waiting_thd); chain->dest = 0; /* mark dma completed */ } if (spu_chain_head == NULL) ;//draw_unlock(); vid_border_color(0, 0, 0); spu_transfering = 0; } else ;//bba_lock(); //asic_evt_disable(ASIC_EVT_EXP_PCI, ASIC_IRQB); if (spu_chain_head) { dma_chain_t * chain = spu_chain_head; spu_transfering = 1; vid_border_color(0, 255, 0); switch(chain->type) { /* case DMA_TYPE_VRAM: */ /* pvr_txr_load_dma(chain->src, chain->dest, */ /* chain->count, 0, spu_cb, chain); */ /* break; */ case DMA_TYPE_SPU: dma_cache_flush(chain->src, chain->count); spu_dma_transfer(chain->src, chain->dest, chain->count, 0, spu_cb, chain); break; case DMA_TYPE_BBA_RX: g2_dma_transfer(chain->dest, chain->src, chain->count, 0, spu_cb, chain, 1, bba_dma_mode, 1, 3); break; default: panic("got bad dma chain type in spu_cb\n"); } spu_chain_head = chain->next; } else { //asic_evt_enable(ASIC_EVT_EXP_PCI, ASIC_IRQB); ;//bba_unlock(); } }
void Init(){ /* Standard initialization */ vid_set_mode(DM_640x480,PM_RGB565); vid_border_color(0,255,0); //pvr_init_defaults(); pvr_init_params_t pvr_params; pvr_params.vertex_buf_size= 1024*512; pvr_params.dma_enabled= 0; pvr_params.fsaa_enabled= 0; pvr_params.autosort_disabled = 0; pvr_params.opb_sizes[PVR_LIST_OP_POLY]= PVR_BINSIZE_32; pvr_params.opb_sizes[PVR_LIST_OP_MOD]= PVR_BINSIZE_0; pvr_params.opb_sizes[PVR_LIST_TR_POLY]= PVR_BINSIZE_16; pvr_params.opb_sizes[PVR_LIST_TR_MOD]= PVR_BINSIZE_0; pvr_params.opb_sizes[PVR_LIST_PT_POLY]= PVR_BINSIZE_0; pvr_init(&pvr_params); //Set palette to ARGB8888 format pvr_set_pal_format(PVR_PAL_ARGB8888); mat_identity(); //Initialize ogg streamer //snd_stream_init(); //sndoggvorbis_init(); }
inline void BCOLOR(int r, int g, int b) { #ifdef DCPLAYA if (SPC_debugcolor) vid_border_color(r, g, b); #endif }
void do_frame() { pvr_vertex_t vert; int x, y, z; int size; int i, col; vid_border_color(0, 0, 0); pvr_wait_ready(); vid_border_color(255, 0, 0); pvr_scene_begin(); pvr_list_begin(PVR_LIST_OP_POLY); pvr_prim(&hdr, sizeof(hdr)); x = rand() % 640; y = rand() % 480; z = rand() % 100 + 1; col = rand () % 256; vert.flags = PVR_CMD_VERTEX; vert.x = x; vert.y = y; vert.z = z; vert.u = vert.v = 0.0f; vert.argb = col | (col << 8) | (col << 16) | 0xff000000; vert.oargb = 0; pvr_prim(&vert, sizeof(vert)); for (i=0; i<polycnt; i++) { x = (x + ((rand() % 50) - 25)) % 640; y = (y + ((rand() % 50) - 25)) % 480; col = rand () % 256; vert.x = x; vert.y = y; vert.argb = col | (col << 8) | (col << 16) | 0xff000000; if (i == (polycnt-1)) vert.flags = PVR_CMD_VERTEX_EOL; pvr_prim(&vert, sizeof(vert)); } pvr_list_finish(); pvr_scene_finish(); vid_border_color(0, 255, 0); }
/* Initialize PVR to defaults and sndoggvorbis */ void Init(){ vid_set_mode(DM_640x480,PM_RGB565); vid_border_color(0,255,0); pvr_init_defaults(); snd_stream_init(); sndoggvorbis_init(); }
static void renderdone_cb() { printf("\n!!!!! renderdone_cb !\n"); vid_border_color(255, 0, 0); if (!ta_block_render) { dma_cb(0); } ta_render_done_cb = NULL; }
int main(int argc, char *argv[]) { if(argc < 2) { ds_printf("Usage: %s option args...\n\n" "Options: \n" " -m, --mode - Set video mode\n" " -l, --list - Show list of video modes\n" " -c, --clear - Clear the display with color\n" " -e, --empty - Clear VRAM\n" " -o, --border - Set video border color\n\n" "Arguments: \n" " -d, --display - Display mode from list\n" " -p, --pixel - Pixel mode from list\n" " -r, --red - Red color for clear screen\n" " -g, --green - green color for clear screen\n" " -b, --blue - Blue color for clear screen\n\n" "Example: %s -m -d 1 -p 1\n", argv[0], argv[0]); return CMD_NO_ARG; } int mode = 0, list = 0, clear = 0, empty = 0, border = 0, display = 0, pixel = PM_RGB565; int r = 0, g = 0, b = 0; struct cfg_option options[] = { {"mode", 'm', NULL, CFG_BOOL, (void *) &mode, 0}, {"clear", 'c', NULL, CFG_BOOL, (void *) &clear, 0}, {"empty", 'e', NULL, CFG_BOOL, (void *) &empty, 0}, {"border", 'o', NULL, CFG_BOOL, (void *) &border, 0}, {"list", 'l', NULL, CFG_BOOL, (void *) &list, 0}, {"pixel", 'p', NULL, CFG_INT, (void *) &pixel, 0}, {"display",'d', NULL, CFG_INT, (void *) &display,0}, {"red", 'r', NULL, CFG_INT, (void *) &r, 0}, {"green", 'g', NULL, CFG_INT, (void *) &g, 0}, {"blue", 'b', NULL, CFG_INT, (void *) &b, 0}, CFG_END_OF_LIST }; CMD_DEFAULT_ARGS_PARSER(options); if(mode) { if(pixel == PM_RGB565) { SetVideoMode(display); } else { vid_set_mode(display, pixel); } return CMD_OK; } if(clear) { vid_clear(r, g, b); return CMD_OK; } if(empty) { vid_empty(); return CMD_OK; } if(border) { vid_border_color(r, g, b); return CMD_OK; } if(list) { ds_printf( " Pixel modes: \n" " 0 - RGB555 pixel mode (15-bit)\n" " 1 - RGB565 pixel mode (16-bit), default\n" " 3 - RGB888 pixel mode (24-bit)\n\n"); ds_printf( " Display modes: \n" " 1 - 320x240 VGA 60Hz \n" " 2 - 320x240 NTSC 60Hz \n" " 3 - 640x480 VGA 60Hz \n" " 4 - 640x480 NTSC Interlaced 60Hz \n" " 5 - 800x608 VGA 60Hz \n" " 6 - 640x480 PAL Interlaced 50Hz \n" " 7 - 256x256 PAL Interlaced 50Hz \n" " 8 - 768x480 NTSC Interlaced 60Hz \n" " 9 - 768x576 PAL Interlaced 50Hz \n" " 10 - 768x480 PAL Interlaced 50Hz \n"); ds_printf( " 11 - 320x240 PAL 50Hz \n" " 12 - 320x240 VGA 60Hz, 4FBs \n" " 13 - 320x240 NTSC 60Hz, 4FBs \n" " 14 - 640x480 VGA 60Hz, 4FBs \n" " 15 - 640x480 NTSC IL 60Hz, 4FBs \n" " 16 - 800x608 VGA 60Hz, 4FBs \n" " 17 - 640x480 PAL IL 50Hz, 4FBs \n" " 18 - 256x256 PAL IL 50Hz, 4FBs \n" " 19 - 768x480 NTSC IL 60Hz, 4FBs \n" " 20 - 768x576 PAL IL 50Hz, 4FBs \n" " 21 - 768x480 PAL IL 50Hz, 4FBs \n" " 22 - 320x240 PAL 50Hz, 4FBs \n\n"); return CMD_OK; } ds_printf("DS_ERROR: There is no option.\n"); return CMD_NO_ARG; }
int main (int argc, char *argv[]) { int cable_type; int quit = 0; float rot1 = 0.0, rot2 = 0.0, rot3 = 0.0; kos_img_t cubetxr; GLuint texture[2]; pvr_ptr_t texaddr; pvr_ptr_t bumpmap; /* Consider this as the vector from the object to the light, for now. */ GLfloat light_position[3] = { 0.7, 0.7, 2.0 }; vec_normalize (&light_position[0], &light_position[0]); cable_type = vid_check_cable (); printf ("KOS says M_PI is: %f\n", M_PI); if (cable_type == CT_VGA) vid_init (DM_640x480_VGA, PM_RGB565); else vid_init (DM_640x480_PAL_IL, PM_RGB565); init_pvr (); auto_orient (); png_to_img ("/rd/cube.png", PNG_NO_ALPHA, &cubetxr); texaddr = pvr_mem_malloc (cubetxr.w * cubetxr.h * 2); pvr_txr_load_kimg (&cubetxr, texaddr, PVR_TXRLOAD_INVERT_Y); kos_img_free (&cubetxr, 0); bumpmap = load_bumpmap ("/rd/bump.raw"); vid_border_color (0, 0, 0); pvr_set_bg_color (0.0, 0.0, 0.0); glKosInit (); glEnable (GL_DEPTH_TEST); glEnable (GL_CULL_FACE); glEnable (GL_TEXTURE_2D); glShadeModel (GL_SMOOTH); glClearDepth (1.0f); glDepthFunc (GL_LEQUAL); glMatrixMode (GL_PROJECTION); glLoadIdentity (); gluPerspective (45.0, /* Field of view in degrees. */ 640.0 / 480.0, /* Aspect ratio. */ 1.0, /* Z near. */ 50.0); /* Z far. */ glMatrixMode (GL_MODELVIEW); glLoadIdentity (); gluLookAt (0.0, 0.0, -4.5, /* Eye position. */ 0.0, 0.0, 0.0, /* Centre. */ 0.0, 1.0, 0.0); /* Up. */ glGenTextures (2, &texture[0]); /* Ordinary texture. */ glBindTexture (GL_TEXTURE_2D, texture[0]); glKosTex2D (GL_RGB565_TWID, cubetxr.w, cubetxr.h, texaddr); /* Bump texture. */ glBindTexture (GL_TEXTURE_2D, texture[1]); /*pvr_poly_cxt_txr (cxt, PVR_LIST_OP_POLY, PVR_TXRFMT_BUMP | PVR_TXRFMT_TWIDDLED, 128, 128, bumpmap, PVR_FILTER_BILINEAR);*/ glKosTex2D (GL_BUMP_TWID, 128, 128, bumpmap); glTexEnvi (GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE); /* Break the nice abstraction. Tweak for bump mapping. */ /*cxt = (pvr_poly_cxt_t *) texture[1]; cxt->gen.specular = PVR_SPECULAR_ENABLE;*/ /*pvr_poly_compile (&bumphdr, cxt);*/ printf ("objmatrix at %p\n", objmatrix); while (!quit) { int faces; GLfloat transformed_normals [sizeof (face_normals) / (3 * sizeof (GLfloat))][3]; GLfloat transformed_orient [sizeof (face_orient) / (3 * sizeof (GLfloat))][3]; MAPLE_FOREACH_BEGIN (MAPLE_FUNC_CONTROLLER, cont_state_t, st) if (st->buttons & CONT_START) quit = 1; MAPLE_FOREACH_END () glKosBeginFrame (); glPushMatrix (); glRotatef (rot1, 1.0, 0.0, 0.0); glRotatef (rot2, 0.0, 1.0, 0.0); glRotatef (rot3, 0.0, 0.0, 1.0); rot1 += 0.1; rot2 += 0.2; rot3 += 0.3; /* Get the object's transformation matrix. */ glGetFloatv (GL_MODELVIEW_MATRIX, &objmatrix[0][0]); /* We care only about rotation for now. */ objmatrix[0][3] = objmatrix[1][3] = objmatrix[2][3] = 0.0; objmatrix[3][0] = objmatrix[3][1] = objmatrix[3][2] = 0.0; objmatrix[3][3] = 1.0; /*printf ("Got matrix:\n"); printf ("[ %f %f %f %f ]\n", objmatrix[0][0], objmatrix[0][1], objmatrix[0][2], objmatrix[0][3]); printf ("[ %f %f %f %f ]\n", objmatrix[1][0], objmatrix[1][1], objmatrix[1][2], objmatrix[1][3]); printf ("[ %f %f %f %f ]\n", objmatrix[2][0], objmatrix[2][1], objmatrix[2][2], objmatrix[2][3]); printf ("[ %f %f %f %f ]\n", objmatrix[3][0], objmatrix[3][1], objmatrix[3][2], objmatrix[3][3]);*/ /* Do these all in one go. */ mat_load ((matrix_t *) &objmatrix[0][0]); /* Note: mat_transform is only for 3D->2D (perspective) transformations! This won't be quite as quick, most likely. */ for (faces = 0; faces < 6; faces++) { GLfloat x = face_normals[faces][0]; GLfloat y = face_normals[faces][1]; GLfloat z = face_normals[faces][2]; GLfloat w = 1.0; mat_trans_nodiv (x, y, z, w); transformed_normals[faces][0] = x; transformed_normals[faces][1] = y; transformed_normals[faces][2] = z; x = face_orient[faces][0]; y = face_orient[faces][1]; z = face_orient[faces][2]; w = 1.0; mat_trans_nodiv (x, y, z, w); transformed_orient[faces][0] = x; transformed_orient[faces][1] = y; transformed_orient[faces][2] = z; } glKosMatrixDirty (); glDisable (GL_KOS_OFFSET_COLOR); glBindTexture (GL_TEXTURE_2D, texture[0]); glDisable (GL_TEXTURE_2D); //glBlendFunc (GL_DST_COLOR, GL_ZERO); glBlendFunc (GL_ONE, GL_ZERO); for (faces = 0; faces < 6; faces++) { int strip; glBegin (GL_TRIANGLE_STRIP); glColor4ub (colour[faces][0], colour[faces][1], colour[faces][2], colour[faces][3]); for (strip = 0; strip < 4; strip++) { glTexCoord2fv (texcoords[strip]); glVertex3fv (points[tristrips[faces][strip]]); } glEnd (); } /* Finish opaque list, start transparent list. */ glKosFinishList (); glBindTexture (GL_TEXTURE_2D, texture[1]); glEnable (GL_TEXTURE_2D); glEnable (GL_KOS_OFFSET_COLOR); glBlendFunc (GL_ZERO, GL_SRC_ALPHA); for (faces = 0; faces < 6; faces++) { int strip, over_pi, over_2pi; GLfloat s_dot_n, f[3], d[3], t, q; GLfloat d_cross_r[3], dxr_len, d_len; s_dot_n = vec_dot (&transformed_normals[faces][0], &light_position[0]); /* Elevation (T) angle: s.n = |s| |n| cos T T = acos (s.n / (|s| * |n|)) |s| and |n| are both 1. */ t = M_PI / 2 - acosf (s_dot_n); if (t < 0) t = 0; /* Rotation (Q) angle: d x r = (|d| |r| sin Q) n |d x r| / (|d| |r|) = sin Q. */ vec_scale (&f[0], &transformed_normals[faces][0], s_dot_n); vec_sub (&d[0], &light_position[0], &f[0]); vec_cross (&d_cross_r[0], &d[0], &transformed_orient[faces][0]); dxr_len = vec_length (&d_cross_r[0]); d_len = vec_length (&d[0]); q = asinf (dxr_len / d_len); over_pi = vec_dot (&d[0], &transformed_orient[faces][0]) < 0; if (over_pi) q = M_PI - q; over_2pi = vec_dot (&d_cross_r[0], &transformed_normals[faces][0]) < 0; if (over_2pi) q = 2 * M_PI - q; /*printf ("length of n: %f\n", length (&transformed_normals[faces][0])); printf ("%d: [ %f %f %f ]\n", faces, transformed_normals[faces][0], transformed_normals[faces][1], transformed_normals[faces][2]); printf ("length of r: %f\n", length (&transformed_orient[faces][0])); printf ("%d: [ %f %f %f ]\n", faces, transformed_orient[faces][0], transformed_orient[faces][1], transformed_orient[faces][2]);*/ glBegin (GL_TRIANGLE_STRIP); set_bump_direction (t, 2 * M_PI - q, 1.0); glColor4ub (255, 255, 255, 255); for (strip = 0; strip < 4; strip++) { glTexCoord2fv (texcoords[strip]); glVertex3fv (points[tristrips[faces][strip]]); } glEnd (); } /* Finish opaque polygon list, start translucent polygon list. */ /* glKosFinishList ();*/ glPopMatrix (); glKosFinishFrame (); } glKosShutdown (); pvr_shutdown (); vid_shutdown (); return 0; }
int main(int argc,char **argv){ Init(); //sndoggvorbis_start("/pc/billy.ogg",-1); Lights[0].z = 10.0; Lights[0].x = 0.0; Lights[0].y = 0.0; Lights[0].w = 1.0; Lights[0].r = 5.0; Lights[0].g = 0.0; Lights[0].b = 0.0; Lights[0].a = 1.0; Lights[0].aa = 0.0; Lights[0].ab = 0.0; Lights[0].ac = 1.0; Lights[0].dummy = 1.0; Lights[1].z = 10.0; Lights[1].x = 100.0; Lights[1].y = 100.0; Lights[1].w = 1.0; Lights[1].r = 0.0; Lights[1].g = 5.0; Lights[1].b = 0.0; Lights[1].a = 1.0; Lights[1].aa = 0.0; Lights[1].ab = 0.0; Lights[1].ac = 1.0; Lights[1].dummy = 1.0; Lights[2].z = 10.0; Lights[2].x = 400.0; Lights[2].y = 400.0; Lights[2].w = 1.0; Lights[2].r = 0.0; Lights[2].g = 0.0; Lights[2].b = 5.0; Lights[2].a = 1.0; Lights[2].aa = 0.0; Lights[2].ab = 0.0; Lights[2].ac = 1.0; Lights[2].dummy = 1.0; vid_border_color(255,0,0); Load_Texture("/rd/bumpmap.raw",&GlobalNormal); Load_Texture("/rd/text.raw",&GlobalTex); vid_border_color(0,0,255); Init_Layer(); int q = 0; int x = 0; int pushed = 0; int bumpenabled = 1; int display_fps = 0; bfont_set_encoding(BFONT_CODE_ISO8859_1); while(q == 0){ mat_identity(); vid_border_color(255,0,0); pvr_wait_ready(); vid_border_color(0,255,0); pvr_scene_begin(); pvr_list_begin(PVR_LIST_OP_POLY); Draw_Layer(); pvr_list_finish(); pvr_list_begin(PVR_LIST_TR_POLY); if(bumpenabled) Draw_Layer_Bump(); pvr_list_finish(); pvr_scene_finish(); vid_border_color(0,0,255); MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st); if(st->buttons & CONT_START) q = 1; if(st->joyx > 32){ Lights[x].x += 4.0f; } if(st->joyx < -32){ Lights[x].x -= 4.0f; } if(st->joyy < -32){ Lights[x].y -= 4.0f; } if(st->joyy > 32){ Lights[x].y += 4.0f; } if(st->buttons & CONT_DPAD_LEFT){ Lights[x].x -= 4.0f; } if(st->buttons & CONT_DPAD_RIGHT){ Lights[x].x += 4.0f; } if(st->buttons & CONT_DPAD_UP){ Lights[x].y -= 4; } if(st->buttons & CONT_DPAD_DOWN){ Lights[x].y += 4; } if(st->buttons & CONT_A && pushed == 0){ pushed = 1; x++; if(x == LIGHTS){ x = 0; } } if(st->buttons & CONT_Y && pushed == 0){ LIGHTS--; pushed = 1; if(LIGHTS < 0){ LIGHTS = MAX_LIGHTS; } } if(st->buttons & CONT_B && pushed == 0){ display_fps ^= 0x01; pushed = 1; } if(st->buttons & CONT_X && pushed == 0){ bumpenabled ^= 0x01; pushed = 1; } if(!(st->buttons & CONT_A) && !(st->buttons & CONT_B) && !(st->buttons & CONT_X) && !(st->buttons & CONT_Y)){ pushed = 0; } MAPLE_FOREACH_END(); running_stats(); sprintf(buf,"FPS:%f",avgfps); if(display_fps){ //printf("%s\n",buf); bfont_draw_str(vram_s + (640*24),640,1,buf); } } DeleteTexture(&GlobalNormal); DeleteTexture(&GlobalTex); //sndoggvorbis_stop(); //sndoggvorbis_shutdown(); pvr_shutdown(); return 0; }
int main(int argc,char** argv){ pvr_vertex_t v; Texture spr; pvr_poly_cxt_t p_cxt; pvr_poly_hdr_t p_hdr; Init(); Load_VQTexture("/rd/billy.kmg",&spr); sndoggvorbis_start("/rd/billy.ogg",-1); int q = 0; while(q == 0){ vid_border_color(255,0,0); pvr_wait_ready(); vid_border_color(0,255,0); pvr_scene_begin(); pvr_list_begin(PVR_LIST_OP_POLY); pvr_list_finish(); pvr_list_begin(PVR_LIST_TR_POLY); pvr_poly_cxt_txr(&p_cxt,PVR_LIST_TR_POLY,spr.fmt,spr.w,spr.h,spr.txt,PVR_FILTER_BILINEAR); pvr_poly_compile(&p_hdr,&p_cxt); pvr_prim(&p_hdr,sizeof(p_hdr)); // submit header v.x = 0.0; v.y = 0.0; v.z = 1.0; v.u = 0.0; v.v = 0.0; v.argb = 0xffffffff; v.oargb = 0; v.flags = PVR_CMD_VERTEX; pvr_prim(&v,sizeof(v)); v.x = 640.0; v.y = 0.0; v.u = 1.0; v.v = 0.0; pvr_prim(&v,sizeof(v)); v.x = 0.0; v.y = 480.0; v.u = 0.0; v.v = 1.0; pvr_prim(&v,sizeof(v)); v.x = 640.0; v.y = 480.0; v.u = 1.0; v.v = 1.0; v.flags = PVR_CMD_VERTEX_EOL; pvr_prim(&v,sizeof(v)); pvr_list_finish(); pvr_scene_finish(); vid_border_color(0,0,255); MAPLE_FOREACH_BEGIN(MAPLE_FUNC_CONTROLLER, cont_state_t, st); if(st->buttons & CONT_START) q = 1; MAPLE_FOREACH_END(); } DeleteTexture(&spr); sndoggvorbis_stop(); pvr_shutdown(); sndoggvorbis_shutdown(); return 0; }
dma_chain_t * dma_initiate(void * dest, void * src, uint32 length, int type) { int irq = 0; dma_chain_t * chain = alloc_chain(); if (chain == NULL) return NULL; chain->dest = (uint32) dest; chain->src = (uint8 *) src; chain->count = length; chain->type = type; chain->waiting_thd = 0; if (type == DMA_TYPE_SPU || type == DMA_TYPE_BBA_RX) { if (type == DMA_TYPE_SPU && (0||nospudma)) { vid_border_color(0, 0, 255); spu_memload(chain->dest, chain->src, chain->count); vid_border_color(0, 0, 0); sem_signal(chain->sema); return chain; } else { //draw_lock(); vid_border_color(0, 0, 255); if (!irq_inside_int()) irq = irq_disable(); if (type == DMA_TYPE_BBA_RX) { /* if (spu_chain_head && spu_chain_head->type == DMA_TYPE_SPU) { */ /* if (!irq_inside_int()) */ /* irq_restore(irq); */ /* free_chain(chain); */ /* return NULL; */ /* } */ chain->waiting_thd = thd_current; } chain->next = spu_chain_head; spu_chain_head = chain; if (!spu_transfering) spu_cb(0); if (!irq_inside_int()) irq_restore(irq); return chain; } } else nospudma = 0; if (!irq_inside_int()) irq = irq_disable(); chain->next = chain_head; chain_head = chain; ta_render_done_cb = renderdone_cb; //vid_border_color(0, 0, 255); if (!irq_inside_int()) irq_restore(irq); return chain; }
static void dma_cb(void * p) { if (p) { dma_chain_t * chain = (dma_chain_t *) p; if (chain->count > 0) { /* vid_border_color(0, 0, 0); */ /* ta_block_render = 0; */ /* ta_render_done_cb = renderdone_cb; */ /* return; */ } else { vid_border_color(0, 255, 0); printf("\n!!!!!! dma done !\n"); if (chain->sema == NULL) { free_chain(chain); } else { sem_signal(chain->sema); chain->dest = 0; /* mark dma completed */ } dma_transfering = 0; } } if (chain_head) { dma_chain_t * chain = chain_head; ta_block_render = 1; static int toto; toto += 64; vid_border_color(255, toto&255, toto&255); dma_transfering = 1; printf("\n!!!!!! dma transfer ! \n"); switch(chain->type) { case DMA_TYPE_VRAM: pvr_txr_load_dma(chain->src, chain->dest, chain->count, 0, dma_cb, chain); break; /* case DMA_TYPE_SPU: */ /* if (chain->count > SPU_MAX_SZ) { */ /* //panic("chain->count > SPU_MAX_SZ\n"); */ /* dma_cache_flush(chain->src, chain->count); */ /* spu_dma_transfer(chain->src, chain->dest, SPU_MAX_SZ, 0, */ /* (spu_dma_callback_t) dma_cb, */ /* (ptr_t) chain); */ /* chain->count -= SPU_MAX_SZ; */ /* chain->dest += SPU_MAX_SZ; */ /* chain->src += SPU_MAX_SZ; */ /* return; */ /* } else { */ /* spu_dma_transfer(chain->src, chain->dest, chain->count, */ /* 0, */ /* (spu_dma_callback_t) dma_cb, */ /* (ptr_t) chain); */ /* } */ /* break; */ default: assert(0 && "got bad dma chain type in dma_cb"); } chain->count = 0; chain_head = chain->next; } else { printf("\n!!!!!! all dma done !\n"); ta_block_render = 0; vid_border_color(0, 0, 0); } }
void do_frame() { pvr_vertex_t * vert; int x, y, z; int i, col; int seed = oldseed; pvr_dr_state_t dr_state; #define nextnum() seed = seed * 1164525 + 1013904223; #define getnum(mn) (seed & ((mn) - 1)) vid_border_color(0, 0, 0); pvr_wait_ready(); vid_border_color(255, 0, 0); pvr_scene_begin(); pvr_list_begin(PVR_LIST_OP_POLY); pvr_prim(&hdr, sizeof(hdr)); pvr_dr_init(dr_state); x = getnum(1024); nextnum(); y = getnum(512); nextnum(); z = getnum(128) + 1; nextnum(); col = getnum(256); nextnum(); vert = pvr_dr_target(dr_state); vert->flags = PVR_CMD_VERTEX; vert->x = x; vert->y = y; vert->z = z; vert->u = vert->v = 0.0f; vert->argb = col | (col << 8) | (col << 16) | 0xff000000; vert->oargb = 0; pvr_dr_commit(vert); for(i = 0; i < polycnt; i++) { x = (x + ((getnum(64)) - 32)) & 1023; nextnum(); y = (y + ((getnum(64)) - 32)) % 511; nextnum(); col = getnum(256); nextnum(); vert = pvr_dr_target(dr_state); vert->flags = PVR_CMD_VERTEX; vert->x = x; vert->y = y; vert->z = z; vert->u = vert->v = 0.0f; vert->argb = col | (col << 8) | (col << 16) | 0xff000000; vert->oargb = 0; if(i == (polycnt - 1)) vert->flags = PVR_CMD_VERTEX_EOL; pvr_dr_commit(vert); } pvr_list_finish(); pvr_scene_finish(); vid_border_color(0, 255, 0); oldseed = seed; }