int dc_main(void) { unsigned long bin_size = 0xfeedbeef; char tmp_str[8]; vid_init(vid_check_cable(), DM_640x480, PM_RGB565); vid_clear(0,100,0); /* Relocate the 1st_read.bin */ bin_size = *((unsigned long *) REAL_LOAD_POINT); uint_to_string(bin_size, tmp_str); bfont_draw_str(vram_s+10*640+20, 640, "bin_size = "); bfont_draw_str(vram_s+50*640+20, 640, tmp_str); memmove((unsigned char *) REAL_LOAD_POINT, (unsigned char *) LOADED_POINT, bin_size); dbr_set(ubc_works); vbr_set(vbr_buffer); *UBC_R_BARA = (unsigned int) BREAKPOINT; *UBC_R_BAMRA = (1<<2); *UBC_R_BBRA = (1<<5) | (1<<4) | (1<<3) | (1<<2); *UBC_R_BRCR = (1<<10) | (1<<15) | 1; ubc_wait(); ubc_wait(); ubc_wait(); ubc_wait(); vid_clear(50,0,50); disable_cache(); (*(void (*)()) REAL_LOAD_POINT) (); vid_init(vid_check_cable(), DM_640x480, PM_RGB565); vid_clear(100,0,0); bfont_draw_str(vram_s+100*640+20, 640, "[UBC] DANGER! We're returned from the game!"); while(1); }
int main(int argc,char *argv[]) { //char huge *sptemp; short huge *ip; char huge *cp; int a,b,c,d,e,f,g; #ifdef DEBUG //fr=fopen("tmp","wt"); fr=stdout; #endif if(argc>1) { strcpy(scene,argv[1]); //strupr(scene); } else indemo=1; sprintf(tmpname,"%s.00M",scene); if(!indemo) printf("Loading materials %s...\n",tmpname); scene0=scenem=readfile(tmpname); if(scene0[15]=='C') city=1; if(scene0[15]=='R') city=2; ip=(short *)(scene0+LONGAT(scene0+4)); conum=d=*ip++; for(f=-1,c=1;c<d;c++) { e=*ip++; if(e>f) { f=e; sprintf(tmpname,"%s.%03i",scene,e); if(!indemo) printf("Loading %s... ",tmpname); co[c].o=vis_loadobject(tmpname); memset(co[c].o->r,0,sizeof(rmatrix)); memset(co[c].o->r0,0,sizeof(rmatrix)); co[c].index=e; co[c].on=0; if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name); } else { if(!indemo) printf("Copying %s.%03i... ",scene,e); for(g=0;g<c;g++) if(co[g].index==e) break; memcpy(co+c,co+g,sizeof(struct s_co)); co[c].o=getmem(sizeof(object)); memcpy(co[c].o,co[g].o,sizeof(object)); co[c].o->r=getmem(sizeof(rmatrix)); co[c].o->r0=getmem(sizeof(rmatrix)); memset(co[c].o->r,0,sizeof(rmatrix)); memset(co[c].o->r0,0,sizeof(rmatrix)); co[c].on=0; if(!indemo) printf("(co[%i]:%s)\n",c,co[c].o->name); } } co[0].o=&camobject; camobject.r=&cam; camobject.r0=&cam; sprintf(tmpname,"%s.0AA",scene); if(!indemo) printf("Loading animations... %s\n",tmpname); ip=(short *)readfile(tmpname); while(*ip) { a=*ip; if(a==-1) break; sprintf(tmpname,"%s.0%c%c",scene,a/10+'A',a%10+'A'); if(!indemo) printf("Scene: %s ",tmpname); scenelist[scl].data=readfile(tmpname); printf("(%i:@%p)\n",scl,scenelist[scl].data); scl++; ip+=2; } if(!indemo) { printf("Press any key to continue...\n"); //getch(); } resetscene(); if (init_graphics("Cplay", argc, argv) < 0) { fprintf(stderr, "Can't init graphics\n"); return -1; }; init_opengl(); set_fps(36); vid_init(1); ////// oversample x 4 cp=(char *)(scenem+16); vid_setpal(cp); #if 0 outp(0x3c8,0); outp(0x3c9,0); outp(0x3c9,0); outp(0x3c9,0); #endif while(1 /*!kbhit()*/) { int fov; int onum; long pflag; long dis; long l; object *o; rmatrix *r; //vid_switch(); //vid_waitb(); vid_clear(); // parse animation stream onum=0; for(;;) { /* sptemp=sp; _asm { mov ax,word ptr sptemp[0] cmp ax,1000h jb l1 sub word ptr sptemp[0],1000h add word ptr sptemp[2],100h l1: } sp=sptemp; */ a=*sp++; if(a==0xff) { a=*sp++; if(a<=0x7f) { fov=a<<8; break; } else if(a==0xff) { resetscene(); continue; } } if((a&0xc0)==0xc0) { onum=((a&0x3f)<<4); a=*sp++; } onum=(onum&0xff0)|(a&0xf); b=0; switch(a&0xc0) { case 0x80 : b=1; co[onum].on=1; break; case 0x40 : b=1; co[onum].on=0; break; } #ifdef DEBUG if(b) fprintf(fr,"[%i (%s) ",onum,co[onum].on?"on":"off"); else fprintf(fr,"[%i (--) ",onum); #endif if(onum>=conum) return(3); r=co[onum].o->r0; pflag=0; switch(a&0x30) { case 0x00 : break; case 0x10 : pflag|=*sp++; break; case 0x20 : pflag|=sp[0]; pflag|=(long)sp[1]<<8; sp+=2; break; case 0x30 : pflag|=sp[0]; pflag|=(long)sp[1]<<8; pflag|=(long)sp[2]<<16; sp+=3; break; } #ifdef DEBUG fprintf(fr,"pfl:%06lX",pflag); #endif l=lsget(pflag); r->x+=l; l=lsget(pflag>>2); r->y+=l; l=lsget(pflag>>4); r->z+=l; #ifdef DEBUG fprintf(fr," XYZ:(%f,%f,%f)",r->x,r->y,r->z); #endif if(pflag&0x40) { // word matrix for(b=0;b<9;b++) if(pflag&(0x80<<b)) { r->m[b]+=lsget(2); } } else { // byte matrix for(b=0;b<9;b++) if(pflag&(0x80<<b)) { r->m[b]+=lsget(1); } } #ifdef DEBUG fprintf(fr,"]\n"); #endif } // Field of vision vid_cameraangle(fov); // Calc matrices and add to order list (only enabled objects) ordernum=0; /* start at 1 to skip camera */ for(a=1;a<conum;a++) if(co[a].on) { order[ordernum++]=a; o=co[a].o; memcpy(o->r,o->r0,sizeof(rmatrix)); calc_applyrmatrix(o->r,&cam); b=o->pl[0][1]; // center vertex if(co[a].o->name[1]=='_') co[a].dist=1000000000L; else co[a].dist=calc_singlez(b,o->v0,o->r); } // Zsort if(city==1) { co[2].dist=1000000000L; // for CITY scene, test co[7].dist=1000000000L; // for CITY scene, test co[13].dist=1000000000L; // for CITY scene, test } if(city==2) { co[14].dist=1000000000L; // for CITY scene, test } for(a=0;a<ordernum;a++) { dis=co[c=order[a]].dist; for(b=a-1;b>=0 && dis>co[order[b]].dist;b--) order[b+1]=order[b]; order[b+1]=c; } // Draw for(a=0;a<ordernum;a++) { //int x,y; o=co[order[a]].o; #ifdef DEBUG fprintf(fr,"%s (i:%i Z:%li)\n",o->name,order[a],co[order[a]].dist); #endif vis_drawobject(o); } #ifdef DEBUG fprintf(fr,"\n"); #endif swap_buffers(); } vid_deinit(); #ifdef DEBUG fclose(fr); #endif return(0); }
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; }
static void guard_irq_handler(irq_t source, irq_context_t *context) { dbglog(DBG_INFO, "\n=============== CATCHING EXCEPTION ===============\n"); irq_context_t *irq_ctx = irq_get_context(); if (source == EXC_FPU) { /* Display user friendly informations */ export_sym_t * symb; symb = export_lookup_by_addr(irq_ctx->pc); if (symb) { dbglog(DBG_INFO, "FPU EXCEPTION PC = %s + 0x%08x (0x%08x)\n", symb->name, ((int)irq_ctx->pc) - ((int)symb->ptr), (int)irq_ctx->pc); } /* skip the offending FPU instruction */ int *ptr = (int *)&irq_ctx->r[0x40/4]; *ptr += 4; return; } /* Display user friendly informations */ export_sym_t * symb; int i; uint32 *stk = (uint32 *)irq_ctx->r[15]; for (i = 15; i >= 0; i--) { if((stk[i] < 0x8c000000) || (stk[i] > 0x8d000000) || !(symb = export_lookup_by_addr(stk[i])) || ((int)stk[i] - ((int)symb->ptr) > 0x800)) { dbglog(DBG_INFO, "STACK#%2d = 0x%08x\n", i, (int)stk[i]); } else { dbglog(DBG_INFO, "STACK#%2d = 0x%08x (%s + 0x%08x)\n", i, (int)stk[i], symb->name, (int)stk[i] - ((int)symb->ptr)); } } symb = export_lookup_by_addr(irq_ctx->pc); if (symb && (int)stk[i] - ((int)symb->ptr) < 0x800) { dbglog(DBG_INFO, " PC = %s + 0x%08x (0x%08x)\n", symb->name, ((int)irq_ctx->pc) - ((int)symb->ptr), (int)irq_ctx->pc); } else { dbglog(DBG_INFO, " PC = 0x%08x\n", (int)irq_ctx->pc); } symb = export_lookup_by_addr(irq_ctx->pr); if (symb && (int)stk[i] - ((int)symb->ptr) < 0x800) { dbglog(DBG_INFO, " PR = %s + 0x%08x (0x%08x)\n", symb->name, ((int)irq_ctx->pr) - ((int)symb->ptr), (int)irq_ctx->pr); } else { dbglog(DBG_INFO, " PR = 0x%08x\n", (int)irq_ctx->pr); } uint32 *regs = irq_ctx->r; dbglog(DBG_INFO, " R0-R3 = %08lx %08lx %08lx %08lx\n", regs[0], regs[1], regs[2], regs[3]); dbglog(DBG_INFO, " R4-R7 = %08lx %08lx %08lx %08lx\n", regs[4], regs[5], regs[6], regs[7]); dbglog(DBG_INFO, " R8-R11 = %08lx %08lx %08lx %08lx\n", regs[8], regs[9], regs[10], regs[11]); dbglog(DBG_INFO, " R12-R15 = %08lx %08lx %08lx %08lx\n", regs[12], regs[13], regs[14], regs[15]); //arch_stk_trace_at(regs[14], 0); for (i = 0; exceptions_code[i].code; i++) { if (exceptions_code[i].code == source) { dbglog(DBG_INFO, " EVENT = %s (0x%08x)\n", exceptions_code[i].name, (int)source); break; } } expt_quard_stack_t *s = NULL; s = (expt_quard_stack_t *) kthread_getspecific(expt_key); if (s && s->pos >= 0) { // Simulate a call to longjmp by directly changing stored // context of the exception irq_ctx->pc = (uint32)longjmp; irq_ctx->r[4] = (uint32)s->jump[s->pos]; irq_ctx->r[5] = (uint32)(void *) -1; } else { //malloc_stats(); //texture_memstats(); /* not handled --> panic !! */ //irq_dump_regs(0, source); dbgio_set_dev_fb(); vid_clear(0, 0, 0); ConsoleInformation *con = GetConsole(); for(i = 16; i > 0; i--) { dbglog(DBG_INFO, "%s\n", con->ConsoleLines[i]); } dbglog(DBG_ERROR, "Unhandled Exception. Reboot after 10 seconds."); //panic("Unhandled IRQ/Exception"); timer_spin_sleep(10000); arch_reboot(); // asic_sys_reset(); } }