1 /*---------------------------------------------------------------------------*
2 Project: Dolphin GD demo
3 File: gd-win32-ui.c
4
5 Copyright 2001 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Log: gd-win32-ui.c,v $
14 Revision 1.3 2007/11/22 13:15:06 iwai_yuma
15 (none)
16
17 Revision 1.2 2007/11/22 13:03:21 iwai_yuma
18 Replaced unsecure functions to secure functions.
19
20 Revision 1.1 2006/02/08 11:19:43 mitu
21 1st version.
22
23
24 1 10/09/01 11:20a Hirose
25 Initial check in.
26
27 $NoKeywords: $
28 *---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*
30 This code provides common procedure for host applications
31 *---------------------------------------------------------------------------*/
32
33 #include <windows.h>
34 #include <stdio.h>
35 #include <stdarg.h>
36 #include <stdlib.h>
37 #include <string.h>
38
39 /*---------------------------------------------------------------------------*
40 Forward references
41 *---------------------------------------------------------------------------*/
42 extern void main( void );
43
44 static ATOM MyRegisterClass(HINSTANCE hInstance);
45
46 /*---------------------------------------------------------------------------*
47 Global variables
48 *---------------------------------------------------------------------------*/
49 extern char* AppName; // defined in each application
50
51 static HINSTANCE MyInstance;
52 static HWND MyWindow;
53
54 /*------------------------------------------------------------------*
55 Main
56 *------------------------------------------------------------------*/
WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int iCmdShow)57 int APIENTRY WinMain(HINSTANCE hInstance,
58 HINSTANCE hPrevInstance,
59 LPSTR lpCmdLine,
60 int iCmdShow)
61 {
62 MyInstance = hInstance;
63
64 MyRegisterClass(hInstance);
65
66 // This window won't be actually displayed.
67 MyWindow = CreateWindow(AppName, AppName, WS_OVERLAPPEDWINDOW,
68 CW_USEDEFAULT, CW_USEDEFAULT,
69 CW_USEDEFAULT, CW_USEDEFAULT,
70 NULL, NULL, hInstance, NULL);
71
72 main();
73
74 return 0;
75 }
76
77 /*------------------------------------------------------------------*
78 Window callback
79 *------------------------------------------------------------------*/
WndProc(HWND hWnd,UINT iMsg,WPARAM wParam,LPARAM lParam)80 LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
81 {
82 return DefWindowProc(hWnd, iMsg, wParam, lParam);
83 }
84
85 /*------------------------------------------------------------------*
86 Window class registration
87 *------------------------------------------------------------------*/
MyRegisterClass(HINSTANCE hInstance)88 ATOM MyRegisterClass(HINSTANCE hInstance)
89 {
90 WNDCLASSEX wcex;
91
92 wcex.cbSize = sizeof(WNDCLASSEX);
93
94 wcex.style = CS_HREDRAW | CS_VREDRAW;
95 wcex.lpfnWndProc = (WNDPROC)WndProc;
96 wcex.cbClsExtra = 0;
97 wcex.cbWndExtra = 0;
98 wcex.hInstance = hInstance;
99 wcex.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
100 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
101 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
102 wcex.lpszMenuName = NULL;
103 wcex.lpszClassName = AppName;
104 wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
105
106 return RegisterClassEx(&wcex);
107 }
108
109 /*------------------------------------------------------------------*
110 Message output
111 *------------------------------------------------------------------*/
GDReport(char * msg,...)112 void GDReport(char* msg, ...)
113 {
114 va_list marker;
115 char strbuffer[256];
116
117 va_start(marker, msg);
118 vsprintf_s( strbuffer, 256, msg, marker );
119 // vsprintf(strbuffer, msg, marker);
120
121 MessageBox(MyWindow, strbuffer, AppName, MB_OK);
122 }
123
124 // Stuff needed by ASSERTMSG (found in GD libs)
125 #ifdef _DEBUG
OSPanic(char * file,int line,char * msg,...)126 void OSPanic(char* file, int line, char* msg, ...)
127 {
128 va_list marker;
129 char strbuffer0[256];
130 char strbuffer1[128];
131
132 va_start(marker, msg);
133 vsprintf_s( strbuffer0, 256, msg, marker );
134 // vsprintf(strbuffer0, msg, marker);
135
136 sprintf_s(strbuffer1, 128, " in \"%s\" on line %d.", file, line );
137 strcat_s( strbuffer0, 256, strbuffer1 );
138 // sprintf(strbuffer1, " in \"%s\" on line %d.", file, line);
139 // strcat( strbuffer0, strbuffer1);
140
141 MessageBox(MyWindow, strbuffer0, AppName, MB_ICONEXCLAMATION | MB_OK);
142
143 abort();
144 }
145 #endif
146
147 /*======================================================================*/
148