int kmain(BootInfo_p BOOTINF) { #ifdef DEBUG DEBUG_printf("BOS v. 0.0.4\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif _PMM_init(BOOTINF); _VMM_init(BOOTINF); _i686_init(); _TM_init(BOOTINF); // Do everything the Kernel Needs to do before sti // Note Kernel Thread is Idle Thread once ints are on. _TSS_setESP(); #ifdef DEBUG DEBUG_printf("BOS v. 0.0.4\t%s\tCompiled at %s on %s Line %i\tFunction \"%s\"\n", __FILE__, __TIME__, __DATE__, (__LINE__ - 3), __func__); #endif sti(); while(TRUE) { #ifdef DEBUG_FULL DEBUG_print("Idle Thread\n"); #endif hlt(); DEBUG_print("DONE\n"); } return -1; }
static void check_heap_space(void){ sprintf(txtbuffer,"%ldKB MEM1 available", SYS_GetArena1Size()/1024); DEBUG_print(txtbuffer,DBG_MEMFREEINFO); sprintf(txtbuffer,"Dynarec (KB) %04ld/%04ld",dyna_used,dyna_total/1024); DEBUG_print(txtbuffer,DBG_CORE1); }
static char* toggleSDDebug_func(void){ printToSD ^= 1; if(printToSD) DEBUG_print("open",DBG_SDGECKOOPEN); else DEBUG_print("close",DBG_SDGECKOCLOSE); devFeatures_submenu[5].caption = &toggleSDDebug_strings[printToSD][0]; return NULL; }
static void check_heap_space(void){ sprintf(txtbuffer,"%dKB MEM1 available", SYS_GetArena1Size()/1024); DEBUG_print(txtbuffer,DBG_MEMFREEINFO); sprintf(txtbuffer,"Dynarec (KB) %04d/%04d",dyna_used,dyna_total/1024); DEBUG_print(txtbuffer,DBG_CORE1); sprintf(txtbuffer,"DSP is at %f%%",AESND_GetDSPProcessUsage()); DEBUG_print(txtbuffer,DBG_CORE2); }
void DEBUG_printf(const char* Str, ...) { va_list ap; va_start(ap, Str); while(*Str) { if(*Str == '%') { *Str++; switch(*Str) { /*** characters ***/ case 'c': { const char c = (const char) va_arg (ap, const char); DEBUG_putch(c); *Str++; break; } /*** integers ***/ case 'd': case 'i': { uint32_t c = va_arg (ap, uint32_t); uint8_t s[32]={0}; itoa_s (c, 10, s); DEBUG_print((const char*) s); *Str++; // go to next character break; } /*** display in hex ***/ case 'X': case 'x': { uint32_t c = va_arg (ap, uint32_t); uint8_t s[32]={0}; itoa_s (c,16,s); DEBUG_print((const char*) s); *Str++; // go to next character break; } /*** strings ***/ case 's': { const char *s = va_arg (ap, const char*); DEBUG_print((const char*) s); *Str++; // go to next character break; } case '%': { DEBUG_putch('%'); *Str++; break; } } } else {
void DEBUG_stats(int stats_id, char *info, unsigned int stats_type, unsigned int adjustment_value) { #ifdef SHOW_DEBUG switch(stats_type) { case STAT_TYPE_ACCUM: //accumulate stats_buffer[stats_id] += adjustment_value; break; case STAT_TYPE_AVGE: //average avge_counter[stats_id] += 1; stats_buffer[stats_id] += adjustment_value; break; case STAT_TYPE_CLEAR: if(stats_type & STAT_TYPE_AVGE) avge_counter[stats_id] = 0; stats_buffer[stats_id] = 0; break; } unsigned int value = stats_buffer[stats_id]; if(stats_type == STAT_TYPE_AVGE) value /= avge_counter[stats_id]; sprintf(txtbuffer,"%s [ %i ]", info, value); DEBUG_print(txtbuffer,DBG_STATSBASE+stats_id); #endif }
void DoClearFrontBuffer(void) // CLEAR DX BUFFER { if (menuActive) return; // clear the screen, and flush it DEBUG_print("DoClearFrontBuffer",DBG_GPU1); // printf("DoClearFrontBuffer\n"); //Write menu/debug text on screen GXColor fontColor = {150,255,150,255}; IplFont_drawInit(fontColor); if((ulKeybits&KEY_SHOWFPS)&&showFPSonScreen) IplFont_drawString(10,35,szDispBuf, 1.0, false); int i = 0; DEBUG_update(); for (i=0;i<DEBUG_TEXT_HEIGHT;i++) IplFont_drawString(10,(10*i+60),text[i], 0.5, false); //reset swap table from GUI/DEBUG GX_SetTevSwapModeTable(GX_TEV_SWAP0, GX_CH_RED, GX_CH_GREEN, GX_CH_BLUE, GX_CH_ALPHA); GX_SetTevSwapMode(GX_TEVSTAGE0, GX_TEV_SWAP0, GX_TEV_SWAP0); GX_DrawDone(); whichfb ^= 1; GX_CopyDisp(xfb[0], GX_TRUE); GX_DrawDone(); VIDEO_SetNextFramebuffer(xfb[0]); VIDEO_Flush(); // VIDEO_WaitVSync(); }
void refresh_stat() { long long this_tick = gettime(); if(diff_sec(last_refresh, this_tick) >= 1) { time_in_section[0] = this_tick - last_start[0]; sprintf(txtbuffer, "gfx=%f%%", 100.0f * (float)time_in_section[GFX_SECTION] / (float)time_in_section[0]); DEBUG_print(txtbuffer, DBG_PROFILE_GFX); sprintf(txtbuffer, "audio=%f%%", 100.0f * (float)time_in_section[AUDIO_SECTION] / (float)time_in_section[0]); DEBUG_print(txtbuffer, DBG_PROFILE_AUDIO); sprintf(txtbuffer, "tlb=%f%%", 100.0f * (float)time_in_section[TLB_SECTION] / (float)time_in_section[0]); DEBUG_print(txtbuffer, DBG_PROFILE_TLB); sprintf(txtbuffer, "fp=%f%%", 100.0f * (float)time_in_section[FP_SECTION] / (float)time_in_section[0]); DEBUG_print(txtbuffer, DBG_PROFILE_FP); sprintf(txtbuffer, "comp=%f%%", 100.0f * (float)time_in_section[COMPILER_SECTION] / (float)time_in_section[0]); DEBUG_print(txtbuffer, DBG_PROFILE_COMP); sprintf(txtbuffer, "interp=%f%%", 100.0f * (float)time_in_section[INTERP_SECTION] / (float)time_in_section[0]); DEBUG_print(txtbuffer, DBG_PROFILE_INTERP); sprintf(txtbuffer, "tramp=%f%%", 100.0f * (float)time_in_section[TRAMP_SECTION] / (float)time_in_section[0]); DEBUG_print(txtbuffer, DBG_PROFILE_TRAMP); int i; for(i=1; i<=NUM_SECTIONS; ++i) time_in_section[i] = 0; last_start[0] = this_tick; last_refresh = this_tick; } }
void DoClearScreenBuffer(void) // CLEAR DX BUFFER { // clear the screen, and DON'T flush it DEBUG_print("DoClearScreenBuffer",DBG_GPU1); // printf("DoClearScreenBuffer\n"); // whichfb ^= 1; // GX_CopyDisp(xfb[1], GX_TRUE); // GX_Flush(); // VIDEO_SetNextFramebuffer(xfb[0]); // VIDEO_Flush(); // VIDEO_WaitVSync(); }
void BlitScreenNS_GX(unsigned char * surf,long x,long y, short dx, short dy) { unsigned long lu; unsigned short row,column; // unsigned short dx=PreviousPSXDisplay.Range.x1; // unsigned short dy=PreviousPSXDisplay.DisplayMode.y; unsigned short LineOffset,SurfOffset; long lPitch=iResX_Max<<1; // long lPitch=iResX<<1; #ifdef USE_DGA2 int DGA2fix; int dga2Fix; if (!iWindowMode) { DGA2fix = (char*)surf == Xpixels; dga2Fix = dgaDev->mode.imageWidth - dgaDev->mode.viewportWidth; } else DGA2fix = dga2Fix = 0; #endif if(PreviousPSXDisplay.Range.y0) // centering needed? { surf+=PreviousPSXDisplay.Range.y0*lPitch; dy-=PreviousPSXDisplay.Range.y0; } if(PSXDisplay.RGB24) { unsigned char * pD;unsigned int startxy; DEBUG_print("BlitScreenNSGX: RGB24",DBG_GPU1+1); surf+=PreviousPSXDisplay.Range.x0<<1; #ifdef USE_DGA2 if (DGA2fix) lPitch+= dga2Fix*2; #endif for(column=0;column<dy;column++) { startxy=((1024)*(column+y))+x; pD=(unsigned char *)&psxVuw[startxy]; for(row=0;row<dx;row++) { lu=*((unsigned long *)pD); *((unsigned short *)((surf)+(column*lPitch)+(row<<1)))= ((RED(lu)<<8)&0xf800)|((GREEN(lu)<<3)&0x7e0)|(BLUE(lu)>>3); pD+=3; } } }
void SysPrintf(const char *fmt, ...) { #ifdef PRINTGECKO va_list list; char msg[512]; va_start(list, fmt); vsprintf(msg, fmt, list); va_end(list); //if (Config.PsxOut) printf ("%s", msg); DEBUG_print(msg, DBG_USBGECKO); #if defined (CPU_LOG) || defined(DMA_LOG) || defined(CDR_LOG) || defined(HW_LOG) || \ defined(BIOS_LOG) || defined(GTE_LOG) || defined(PAD_LOG) fprintf(emuLog, "%s", msg); #endif #endif }
EXPORT void CALL AiDacrateChanged( int SystemType ) { // Taken from mupen_audio freq = 32000; //default to 32khz incase we get a bad systemtype switch (SystemType){ case SYSTEM_NTSC: freq = 48681812 / (*AudioInfo.AI_DACRATE_REG + 1); break; case SYSTEM_PAL: freq = 49656530 / (*AudioInfo.AI_DACRATE_REG + 1); break; case SYSTEM_MPAL: freq = 48628316 / (*AudioInfo.AI_DACRATE_REG + 1); break; } // Calculate the absolute differences from 32 and 48khz int diff32 = freq - 32000; int diff48 = freq - 48000; diff32 = diff32 > 0 ? diff32 : -diff32; diff48 = diff48 > 0 ? diff48 : -diff48; // Choose the closest real frequency real_freq = (diff32 < diff48) ? 32000 : 48000; freq_ratio = (float)freq / real_freq; if( real_freq == 32000 ){ AUDIO_SetDSPSampleRate(AI_SAMPLERATE_32KHZ); buffer_size = (SystemType != SYSTEM_PAL) ? BUFFER_SIZE_32_60 : BUFFER_SIZE_32_50; } else if( real_freq == 48000 ){ AUDIO_SetDSPSampleRate(AI_SAMPLERATE_48KHZ); buffer_size = (SystemType != SYSTEM_PAL) ? BUFFER_SIZE_48_60 : BUFFER_SIZE_48_50; } #ifdef SHOW_DEBUG sprintf(txtbuffer, "Initializing frequency: %d (resampling ratio %f)", real_freq, freq_ratio); DEBUG_print(txtbuffer,DBG_AUDIOINFO); #endif }
MicrocodeInfo *GBI_DetectMicrocode( u32 uc_start, u32 uc_dstart, u16 uc_dsize ) { MicrocodeInfo *current; for (unsigned int i = 0; i < GBI.numMicrocodes; i++) { current = GBI.top; while (current) { if ((current->address == uc_start) && (current->dataAddress == uc_dstart) && (current->dataSize == uc_dsize)) return current; current = current->lower; } } current = GBI_AddMicrocode(); current->address = uc_start; current->dataAddress = uc_dstart; current->dataSize = uc_dsize; current->NoN = FALSE; current->type = NONE; // See if we can identify it by CRC uc_crc = CRC_Calculate( 0xFFFFFFFF, &RDRAM[uc_start & 0x1FFFFFFF], 4096 ); #if 0 //def __GX__ sprintf(txtbuffer,"GBI:uc_crc: %x", uc_crc); DEBUG_print(txtbuffer,3); #endif // __GX__ for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++) { if (uc_crc == specialMicrocodes[i].crc) { current->type = specialMicrocodes[i].type; return current; } } // See if we can identify it by text char uc_data[2048]; #ifndef _BIG_ENDIAN UnswapCopy( &RDRAM[uc_dstart & 0x1FFFFFFF], uc_data, 2048 ); #else // !_BIG_ENDIAN memcpy( uc_data, &RDRAM[uc_dstart & 0x1FFFFFFF], 2048 ); #endif strcpy( uc_str, "Not Found" ); for (u32 i = 0; i < 2048; i++) { if ((uc_data[i] == 'R') && (uc_data[i+1] == 'S') && (uc_data[i+2] == 'P')) { u32 j = 0; while (uc_data[i+j] > 0x0A) { uc_str[j] = uc_data[i+j]; j++; } uc_str[j] = 0x00; #if 0 //def __GX__ sprintf(txtbuffer,"GBI:uc_str(i=%i): %s", i, uc_str); DEBUG_print(txtbuffer,4); #endif // __GX__ int type = NONE; if (strncmp( &uc_str[4], "SW", 2 ) == 0) { type = F3D; } else if (strncmp( &uc_str[4], "Gfx", 3 ) == 0) { current->NoN = (strncmp( &uc_str[20], ".NoN", 4 ) == 0); if (strncmp( &uc_str[14], "F3D", 3 ) == 0) { if (uc_str[28] == '1') type = F3DEX; else if (uc_str[31] == '2') type = F3DEX2; } else if (strncmp( &uc_str[14], "L3D", 3 ) == 0) { if (uc_str[28] == '1') type = L3DEX; else if (uc_str[31] == '2') type = L3DEX2; } else if (strncmp( &uc_str[14], "S2D", 3 ) == 0) { if (uc_str[28] == '1') type = S2DEX; else if (uc_str[31] == '2') type = S2DEX2; } } if (type != NONE) { current->type = type; return current; } break; } } for (u32 i = 0; i < sizeof( specialMicrocodes ) / sizeof( SpecialMicrocodeInfo ); i++) { if (strcmp( uc_str, specialMicrocodes[i].text ) == 0) { current->type = specialMicrocodes[i].type; return current; } } // Let the user choose the microcode #ifndef __LINUX__ current->type = DialogBox( hInstance, MAKEINTRESOURCE( IDD_MICROCODEDLG ), hWnd, MicrocodeDlgProc ); #else // !__LINUX__ printf( "glN64: Warning - unknown ucode!!!\n" ); # ifndef __GX__ //TODO: Make sure having ucode = NONE is ok current->type = MicrocodeDialog(); # endif // !__GX__ #endif // __LINUX__ return current; }
void DecodedMux::Decode(uint32 dwMux0, uint32 dwMux1) { m_dwMux0 = dwMux0; m_dwMux1 = dwMux1; aRGB0 = uint8((dwMux0>>20)&0x0F); // c1 c1 // a0 bRGB0 = uint8((dwMux1>>28)&0x0F); // c1 c2 // b0 cRGB0 = uint8((dwMux0>>15)&0x1F); // c1 c3 // c0 dRGB0 = uint8((dwMux1>>15)&0x07); // c1 c4 // d0 aA0 = uint8((dwMux0>>12)&0x07); // c1 a1 // Aa0 bA0 = uint8((dwMux1>>12)&0x07); // c1 a2 // Ab0 cA0 = uint8((dwMux0>>9 )&0x07); // c1 a3 // Ac0 dA0 = uint8((dwMux1>>9 )&0x07); // c1 a4 // Ad0 aRGB1 = uint8((dwMux0>>5 )&0x0F); // c2 c1 // a1 bRGB1 = uint8((dwMux1>>24)&0x0F); // c2 c2 // b1 cRGB1 = uint8((dwMux0 )&0x1F); // c2 c3 // c1 dRGB1 = uint8((dwMux1>>6 )&0x07); // c2 c4 // d1 aA1 = uint8((dwMux1>>21)&0x07); // c2 a1 // Aa1 bA1 = uint8((dwMux1>>3 )&0x07); // c2 a2 // Ab1 cA1 = uint8((dwMux1>>18)&0x07); // c2 a3 // Ac1 dA1 = uint8((dwMux1 )&0x07); // c2 a4 // Ad1 //This fuction will translate the decode mux info further, so we can use //the decode data better. //Will translate A,B,C,D to unified presentation aRGB0 = sc_Mux16[aRGB0]; bRGB0 = sc_Mux16[bRGB0]; cRGB0 = sc_Mux32[cRGB0]; dRGB0 = sc_Mux8[dRGB0]; aA0 = sc_Mux8[aA0]; bA0 = sc_Mux8[bA0]; cA0 = sc_Mux8[cA0]; dA0 = sc_Mux8[dA0]; aRGB1 = sc_Mux16[aRGB1]; bRGB1 = sc_Mux16[bRGB1]; cRGB1 = sc_Mux32[cRGB1]; dRGB1 = sc_Mux8[dRGB1]; aA1 = sc_Mux8[aA1]; bA1 = sc_Mux8[bA1]; cA1 = sc_Mux8[cA1]; dA1 = sc_Mux8[dA1]; m_bShadeIsUsed[1] = isUsedInAlphaChannel(MUX_SHADE); m_bShadeIsUsed[0] = isUsedInColorChannel(MUX_SHADE); m_bTexel0IsUsed = isUsed(MUX_TEXEL0); m_bTexel1IsUsed = isUsed(MUX_TEXEL1); m_dwShadeColorChannelFlag = 0; m_dwShadeAlphaChannelFlag = 0; m_ColorTextureFlag[0] = 0; m_ColorTextureFlag[1] = 0; #if 0//def SHOW_DEBUG //sprintf(txtbuffer,"DispTEVMuxStr: index %d, Mux0 %8x, Mux1 %8x\r\n", index, m_dwLastMux0, m_dwLastMux1); sprintf(txtbuffer,"\r\nDecodeMux: Mux0 0x%8x, Mux1 0x%8x\r\n", m_dwMux0, m_dwMux1); DEBUG_print(txtbuffer,DBG_USBGECKO); for( int rgbalpha = 0; rgbalpha<2; rgbalpha++ ) { for ( int cycle = 0; cycle<2; cycle++ ) { CombinerFormatType type = splitType[cycle*2+rgbalpha]; N64CombinerType &m = m_n64Combiners[cycle*2+rgbalpha]; sprintf(txtbuffer,"RGBA %d Cycle %d Type %s:\r\n", rgbalpha, cycle, muxTypeStrs[type]); DEBUG_print(txtbuffer,DBG_USBGECKO); sprintf(txtbuffer," abcd = %s%s(0x%2x), %s%s(0x%2x), %s%s(0x%2x), %s%s(0x%2x)\r\n", translatedCombTypes[m.a&MUX_MASK], (m.a&(~MUX_MASK))?"*":" ", m.a, translatedCombTypes[m.b&MUX_MASK], (m.b&(~MUX_MASK))?"*":" ", m.b, translatedCombTypes[m.c&MUX_MASK], (m.c&(~MUX_MASK))?"*":" ", m.c, translatedCombTypes[m.d&MUX_MASK], (m.d&(~MUX_MASK))?"*":" ", m.d); DEBUG_print(txtbuffer,DBG_USBGECKO); } } #endif //SHOW_DEBUG }
static void check_heap_space(void){ sprintf(txtbuffer,"At least %dKB MEM1 available", SYS_GetArena1Size()/1024); DEBUG_print(txtbuffer,DBG_MEMFREEINFO); }