- moved console source code to new files for only windows port;

This commit is contained in:
mtabachenko 2008-05-03 05:32:52 +00:00
parent 69709ba274
commit e42186683d
5 changed files with 124 additions and 81 deletions

View File

@ -23,13 +23,6 @@
#include <stdlib.h>
#include <string.h>
/////// Console vars
#define BUFFER_SIZE 100
#ifdef WIN32
HANDLE hConsole;
#endif
///////
//////////////////////////////////////////////////////////////////////////////
Debug * DebugInit(const char * n, DebugOutType t, char * s) {
@ -164,56 +157,3 @@ void LogStop(void) {
}
//////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////// Console
#ifdef WIN32
#ifdef BETA_VERSION
void OpenConsole()
{
COORD csize;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
SMALL_RECT srect;
char buf[256];
if (hConsole) return;
AllocConsole();
memset(buf,0,256);
sprintf(buf,"DeSmuME v%s OUTPUT", VERSION);
SetConsoleTitle(TEXT(buf));
csize.X = 60;
csize.Y = 800;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize);
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
srect = csbiInfo.srWindow;
srect.Right = srect.Left + 99;
srect.Bottom = srect.Top + 64;
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect);
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
}
void CloseConsole() {
if (hConsole == NULL) return;
FreeConsole();
hConsole = NULL;
}
void printlog(char *fmt, ...) {
va_list list;
char msg[512],msg2[522];
wchar_t msg3[522];
char *ptr;
DWORD tmp;
int len, s;
int i, j;
LPWSTR ret;
va_start(list,fmt);
_vsnprintf(msg,511,fmt,list);
msg[511] = '\0';
va_end(list);
ptr=msg; len=strlen(msg);
WriteConsole(hConsole,ptr, (DWORD)len, &tmp, 0);
}
#endif
#endif

View File

@ -20,9 +20,6 @@
#ifndef DEBUG_H
#define DEBUG_H
#ifdef WIN32
#include <windows.h>
#endif
#include "types.h"
#include <stdio.h>
@ -53,18 +50,6 @@ extern Debug * MainLog;
void LogStart(void);
void LogStop(void);
#ifdef WIN32
#ifdef BETA_VERSION
void OpenConsole();
void CloseConsole();
void printlog(LPCTSTR *fmt, ...);
#else
#define OpenConsole()
#define CloseConsole()
#define printlog(...)
#endif
#endif
#ifdef DEBUG
#define LOG(...) DebugPrintf(MainLog, __FILE__, __LINE__, __VA_ARGS__)
#else

View File

@ -0,0 +1,83 @@
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
Copyright 2008 CrazyMax (mtabachenko)
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <windows.h>
#include <stdio.h>
///////////////////////////////////////////////////////////////// Console
#ifdef BETA_VERSION
#define BUFFER_SIZE 100
HANDLE hConsole;
void printlog(char *fmt, ...);
void OpenConsole()
{
COORD csize;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
SMALL_RECT srect;
char buf[256];
if (hConsole) return;
AllocConsole();
memset(buf,0,256);
sprintf(buf,"DeSmuME v%s OUTPUT", VERSION);
SetConsoleTitle(TEXT(buf));
csize.X = 60;
csize.Y = 800;
SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), csize);
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbiInfo);
srect = csbiInfo.srWindow;
srect.Right = srect.Left + 99;
srect.Bottom = srect.Top + 64;
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &srect);
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
printlog("DeSmuME v%s BETA\n",VERSION);
printlog("- compiled: %s %s\n\n",__DATE__,__TIME__);
}
void CloseConsole() {
if (hConsole == NULL) return;
printlog("Closing...");
FreeConsole();
hConsole = NULL;
}
void printlog(char *fmt, ...) {
va_list list;
char msg[512],msg2[522];
wchar_t msg3[522];
char *ptr;
DWORD tmp;
int len, s;
int i, j;
LPWSTR ret;
va_start(list,fmt);
_vsnprintf(msg,511,fmt,list);
msg[511] = '\0';
va_end(list);
ptr=msg; len=strlen(msg);
WriteConsole(hConsole,ptr, (DWORD)len, &tmp, 0);
}
#endif

View File

@ -0,0 +1,37 @@
/* Copyright (C) 2006 yopyop
yopyop156@ifrance.com
yopyop156.ifrance.com
Copyright 2008 CrazyMax (mtabachenko)
This file is part of DeSmuME
DeSmuME is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DeSmuME is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DeSmuME; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _CONSOLE_H_
#define _CONSOLE_H_
#include <windows.h>
#include <stdio.h>
#ifdef BETA_VERSION
void OpenConsole();
void CloseConsole();
void printlog(LPCTSTR *fmt, ...);
#else
#define OpenConsole()
#define CloseConsole()
#define printlog(...)
#endif
#endif

View File

@ -53,6 +53,7 @@
#include "../render3D.h"
#include "../gdbstub.h"
#include "colorctrl.h"
#include "console.h"
#include "snddx.h"
@ -671,7 +672,6 @@ int WINAPI WinMain (HINSTANCE hThisInstance,
InitCustomControls();
OpenConsole(); // Init debug console
printlog("DeSmuME v%s starting...\n\n",VERSION);
/* default the firmware settings, they may get changed later */
NDS_FillDefaultFirmwareConfigData( &win_fw_config);
@ -1693,20 +1693,18 @@ LRESULT CALLBACK SoundSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
static timerid=0;
switch (uMsg)
{
case WM_INITDIALOG:
{
int i;
char tempstr[MAX_PATH];
// Setup Sound Core Combo box
SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (long)"None");
SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)"None");
for (i = 1; SNDCoreList[i] != NULL; i++)
SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (long)SNDCoreList[i]->Name);
for (i = 1; SNDCoreList[i] != NULL; i++)
SendDlgItemMessage(hDlg, IDC_SOUNDCORECB, CB_ADDSTRING, 0, (LPARAM)SNDCoreList[i]->Name);
// Set Selected Sound Core
for (i = 0; SNDCoreList[i] != NULL; i++)