00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "Core/precomp.h"
00016
00017 #ifdef USE_PTC
00018
00019 #include <ptc/ptc.h>
00020
00021 #include <Display/Display/PTC/displaycard_ptc.h>
00022 #include <Display/Display/X11/display_xwindow.h>
00023 #include <Display/Display/Generic/mousecursor_generic.h>
00024
00025 #include <API/Display/Display/palette.h>
00026 #include <API/Display/Display/target.h>
00027 #include <API/Display/Display/vidmode.h>
00028 #include <API/Core/System/clanapp.h>
00029 #include <API/Core/Math/rect.h>
00030
00031 #ifndef WIN32
00032 #include "Core/System/Generic/string_asm.h"
00033 #else
00034 #define asm_memmove memcpy
00035 #define asm_memset memset
00036 #endif
00037
00038 CL_DisplayCard_PTC::CL_DisplayCard_PTC(int card_no)
00039 #ifndef WIN32
00040 : CL_XWindow_CompatibleCard(card_no)
00041 #else
00042 : CL_DisplayCard_Generic(card_no)
00043 #endif
00044 {
00045 m_initialized = false;
00046 m_target = new CL_Target_PTC(&m_console, &m_palette);
00047 }
00048
00049 CL_DisplayCard_PTC::~CL_DisplayCard_PTC()
00050 {
00051 CL_MouseCursor::hide();
00052 if (m_initialized) m_console.close();
00053 delete m_target;
00054 }
00055
00056 void CL_DisplayCard_PTC::flip_display(bool )
00057 {
00058 signal_preflip();
00059 m_console.update();
00060 signal_postflip();
00061 }
00062
00063 void CL_DisplayCard_PTC::put_display(const class CL_Rect &rect)
00064 {
00065 signal_preflip();
00066 Area a(rect.x1, rect.y2, rect.x2, rect.y2);
00067 m_console.update(a);
00068 signal_postflip();
00069 }
00070
00071 CL_Target *CL_DisplayCard_PTC::get_target()
00072 {
00073 return m_target;
00074 }
00075
00076 CL_Target *CL_DisplayCard_PTC::get_frontbuffer()
00077 {
00078 return m_target;
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095 void CL_DisplayCard_PTC::set_palette(CL_Palette *cl_pal)
00096 {
00097 int32 pal_ptr[3*256];
00098
00099 for (int i=0; i<256; i++)
00100 pal_ptr[i] = ((cl_pal->palette[i*3]&0xff)<<16)|
00101 ((cl_pal->palette[i*3+1]&0xff)<<8)|
00102 (cl_pal->palette[i*3+2]&0xff);
00103
00104 Palette pal(pal_ptr);
00105 m_console.palette(pal);
00106
00107 asm_memmove((char *) m_palette.palette, (char *) cl_pal->palette, 3*256);
00108 }
00109
00110 CL_Palette *CL_DisplayCard_PTC::get_palette()
00111 {
00112 return &m_palette;
00113 }
00114
00115 void CL_DisplayCard_PTC::set_videomode(
00116 int width,
00117 int height,
00118 int bpp,
00119 bool fullscreen,
00120 bool allow_resize,
00121 bool video_memory)
00122 {
00123 set_gfxmode(width, height, bpp, fullscreen, allow_resize);
00124
00125
00126 Format format;
00127 m_console.open(CL_ClanApplication::app->get_title(), width, height, format);
00128
00129 #ifdef WIN32
00130 m_console.option("disable key buffering");
00131 #endif
00132
00133 m_initialized = true;
00134 }
00135
00136 bool CL_DisplayCard_PTC::is_initialized()
00137 {
00138 return m_initialized;
00139 }
00140
00141 const std::list<CL_VidMode*> &CL_DisplayCard_PTC::get_videomodes()
00142 {
00143
00144
00145 static std::list<CL_VidMode*> list;
00146 return list;
00147 }
00148
00149 #ifdef WIN32
00150
00151 CL_Display_PTC::CL_Display_PTC(int options)
00152 {
00153 int card_no=0;
00154 CL_Display::cards.push_back(new CL_DisplayCard_PTC(card_no++));
00155
00156 CL_Display_PTC::cur_card = (CL_DisplayCard_PTC *) (*CL_Display::cards.begin());
00157 }
00158
00159 CL_Display_PTC::~CL_Display_PTC()
00160 {
00161
00162
00163
00164
00165
00166
00167 }
00168
00169 CL_DisplayCard_PTC *CL_Display_PTC::cur_card = NULL;;
00170
00171
00172 void CL_Display::select_card(CL_DisplayCard *card)
00173 {
00174 CL_Display_PTC::cur_card = (CL_DisplayCard_PTC*) card;
00175 }
00176
00177 CL_DisplayCard *CL_Display::get_current_card()
00178 {
00179 return CL_Display_PTC::cur_card;
00180 }
00181 #endif
00182
00183 #endif