/***************************************************************************** * Copyright (C) 2010 by ANNEHEIM Geoffrey * Contact: geoffrey.anneheim@gmail.com * * Original code by BoneSoft: * http://www.codeproject.com/KB/GDI-plus/FunWithGravity.aspx * * This program 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. * * RCSID $Id$ *****************************************************************************/ #include #include "utils.h" inline bool rect_intersect(const t_rect* r1, const t_rect* r2) { if ((r1->y + r1->h) < r2->y) return false; if (r1->y > (r2->y + r2->h)) return false; if ((r1->x + r1->w) < r2->x) return false; if (r1->x > (r2->x + r2->w)) return false; return true; } inline void clearScreen() { memset(SCREEN_BASE_ADDRESS, 0xFF, SCREEN_BYTES_SIZE); } inline void setPixel(int x, int y, int color) { unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS + ((x >> 1) + (y << 7) + (y << 5))); *p = (x & 1) ? ((*p & 0xF0) | color) : ((*p & 0x0F) | (color << 4)); } inline int getPixel(int x, int y) { unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS + ((x >> 1) + (y << 7) + (y << 5))); return ((x & 1) ? (*p & 0x0F) : (*p >> 4)); } int rand() { static int m_w = 56789; static int m_z = 38765; m_z = 36969 * (m_z & 65535) + (m_z >> 16); m_w = 18000 * (m_w & 65535) + (m_w >> 16); return (m_z << 16) + m_w; } void showSimpleDialogBox(const char* title, const char* msg) { char* buffTitle; char* buffMsg; char *language = "E\x00n\x00g\x00l\x00i\x00s\x00h\x00\x00"; buffTitle = (char*)malloc(0x200); buffMsg = (char*)malloc(0x800); ascii2utf16(buffTitle, title, 0x80); ascii2utf16(buffMsg, msg, 0x200); show_dialog_box2( buffTitle, buffMsg, (const char*)&language[0]); free(buffTitle); free(buffMsg); } int show3BtnDialogBox(const char* title, const char* msg) { char *buffTitle; char *buffMsg; char *buttons = "Y\x00e\x00s\x00\x00N\x00o\x00\x00"; // cancel is the third int ans; buffTitle = (char*)malloc(0x200); buffMsg = (char*)malloc(0x800); ascii2utf16(buffTitle, title, 0x80); ascii2utf16(buffMsg, msg, 0x200); ans = dialog_3btn( buffTitle, buffMsg, (const char*)&buttons[0], 0x13f1); free(buffTitle); free(buffMsg); return ans; }