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.1 02/08/2006 11:19:43 mitu
15 1st version.
16
17
18 1 10/09/01 11:20a Hirose
19 Initial check in.
20
21 $NoKeywords: $
22 *---------------------------------------------------------------------------*/
23 /*---------------------------------------------------------------------------*
24 This code provides common procedure for host applications
25 *---------------------------------------------------------------------------*/
26
27 #include <windows.h>
28 #include <stdio.h>
29 #include <stdarg.h>
30 #include <stdlib.h>
31 #include <string.h>
32
33 /*---------------------------------------------------------------------------*
34 Forward references
35 *---------------------------------------------------------------------------*/
36 extern void main( void );
37
38 static ATOM MyRegisterClass(HINSTANCE hInstance);
39
40 /*---------------------------------------------------------------------------*
41 Global variables
42 *---------------------------------------------------------------------------*/
43 extern char* AppName; // defined in each application
44
45 static HINSTANCE MyInstance;
46 static HWND MyWindow;
47
48 /*------------------------------------------------------------------*
49 Main
50 *------------------------------------------------------------------*/
WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int iCmdShow)51 int APIENTRY WinMain(HINSTANCE hInstance,
52 HINSTANCE hPrevInstance,
53 LPSTR lpCmdLine,
54 int iCmdShow)
55 {
56 MyInstance = hInstance;
57
58 MyRegisterClass(hInstance);
59
60 // This window won't be actually displayed.
61 MyWindow = CreateWindow(AppName, AppName, WS_OVERLAPPEDWINDOW,
62 CW_USEDEFAULT, CW_USEDEFAULT,
63 CW_USEDEFAULT, CW_USEDEFAULT,
64 NULL, NULL, hInstance, NULL);
65
66 main();
67
68 return 0;
69 }
70
71 /*------------------------------------------------------------------*
72 Window callback
73 *------------------------------------------------------------------*/
WndProc(HWND hWnd,UINT iMsg,WPARAM wParam,LPARAM lParam)74 LRESULT CALLBACK WndProc(HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
75 {
76 return DefWindowProc(hWnd, iMsg, wParam, lParam);
77 }
78
79 /*------------------------------------------------------------------*
80 Window class registration
81 *------------------------------------------------------------------*/
MyRegisterClass(HINSTANCE hInstance)82 ATOM MyRegisterClass(HINSTANCE hInstance)
83 {
84 WNDCLASSEX wcex;
85
86 wcex.cbSize = sizeof(WNDCLASSEX);
87
88 wcex.style = CS_HREDRAW | CS_VREDRAW;
89 wcex.lpfnWndProc = (WNDPROC)WndProc;
90 wcex.cbClsExtra = 0;
91 wcex.cbWndExtra = 0;
92 wcex.hInstance = hInstance;
93 wcex.hIcon = LoadIcon(hInstance, IDI_APPLICATION);
94 wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
95 wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
96 wcex.lpszMenuName = NULL;
97 wcex.lpszClassName = AppName;
98 wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
99
100 return RegisterClassEx(&wcex);
101 }
102
103 /*------------------------------------------------------------------*
104 Message output
105 *------------------------------------------------------------------*/
GDReport(char * msg,...)106 void GDReport(char* msg, ...)
107 {
108 va_list marker;
109 char strbuffer[256];
110
111 va_start(marker, msg);
112 vsprintf(strbuffer, msg, marker);
113
114 MessageBox(MyWindow, strbuffer, AppName, MB_OK);
115 }
116
117 // Stuff needed by ASSERTMSG (found in GD libs)
118 #ifdef _DEBUG
OSPanic(char * file,int line,char * msg,...)119 void OSPanic(char* file, int line, char* msg, ...)
120 {
121 va_list marker;
122 char strbuffer0[256];
123 char strbuffer1[128];
124
125 va_start(marker, msg);
126 vsprintf(strbuffer0, msg, marker);
127
128 sprintf(strbuffer1, " in \"%s\" on line %d.", file, line);
129 strcat(strbuffer0, strbuffer1);
130
131 MessageBox(MyWindow, strbuffer0, AppName, MB_ICONEXCLAMATION | MB_OK);
132
133 abort();
134 }
135 #endif
136
137 /*======================================================================*/
138