#include "ruby.h" #include "ns_winmgr.h" #include "ns_d3dmgr.h" #include "rgss.h" #pragma comment (lib, "msvcr90-ruby191-static.lib") #pragma comment (lib, "WS2_32.lib") #pragma comment (lib, "Dbghelp.lib") void manage_ruby_error(int retval_from_ruby) { //~~@ move this fn to rgss.cpp if(retval_from_ruby == 0) {return;} VALUE global_bang = rb_gv_get("$!"); ID msg_id = rb_intern("message"); VALUE e_msg = rb_funcall(global_bang, msg_id, 0); char* c_e_msg = StringValueCStr(e_msg); if(strcmp(c_e_msg, "exit") == 0) {return;} ID backtrace_id = rb_intern("backtrace"); ID join_id = rb_intern("join"); VALUE trace = rb_funcall(global_bang, backtrace_id, 0); VALUE str_newline = rb_str_new_cstr("\n"); VALUE trace_str = rb_funcall(trace, join_id, 1, str_newline); char* c_trace_str = StringValueCStr(trace_str); extern char msgbox_buffer[]; sprintf(msgbox_buffer, "Error: \"%s\"\n\n%s", c_e_msg, c_trace_str); MessageBoxA(NULL, msgbox_buffer, "RGSS Error", MB_ICONEXCLAMATION); } DWORD WINAPI rgssThread(LPVOID data) { char* options[] = {"test", "test.rb"}; int one = 1; //<- ghetto fabulous ruby_sysinit(&one, (char***)&options); ruby_init(); init_rgss(); //this fn is where all my classes/methods/modules are added in void* node = ruby_options(2, options); manage_ruby_error(ruby_exec_node(node)); SendMessage((WinMgr::get_hWnd()), WM_CLOSE, 0, 0); return 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { HWND hWnd = WinMgr::initialize(hInstance, nCmdShow); D3DMgr::initialize(); HANDLE hThread = CreateThread(NULL, 0, rgssThread, NULL, 0, NULL); BOOL running = true; while(running) { //~~~yield here? measure framerate once gfx is impl running = (WinMgr::update() == 0); } return 0; }