1 #ifndef GRAPH_H_INCLUDED 2 #define GRAPH_H_INCLUDED 3 4 5 /*********************************************************************** 6 * ����ե��å����� (�����ƥ��¸) 7 ************************************************************************/ 8 9 #include "screen.h" /* PC88_PALETTE_T */ 10 11 12 /*********************************************************************** 13 * ���̤˴ؤ��롢���ܾ����ޤȤ��¤�� 14 ************************************************************************/ 15 typedef struct { 16 17 int window_max_width; /* ������ɥ�ɽ����ǽ�ʡ������ */ 18 int window_max_height; /* ���������Ƚĥ����� (�ԥ������) */ 19 /* ������ɥ�ɽ��������������� */ 20 /* ̵�����ϡ�Ŭ�����礭���ͤ� */ 21 /* ���åȤ��Ƥ�����(640�ʾ�) */ 22 23 int fullscreen_max_width; /* �ե륹�����ɽ����ǽ�ʡ������ */ 24 int fullscreen_max_height; /* ���������Ƚĥ����� (�ԥ������) */ 25 /* �ե륹�����ɽ���Ǥ��ʤ��� */ 26 /* ��� 0 �åȤ��Ƥ��� */ 27 28 int forbid_status; /* ���ơ�����ɽ����ػߤ���ʤ顢�� */ 29 30 int forbid_half; /* Ⱦʬ������ɽ����ػߤ���ʤ顢�� */ 31 32 } T_GRAPH_SPEC; 33 34 35 /*********************************************************************** 36 * ���� QUASI88 �����������оݤȤʤ���̤Ρ������ޤȤ��¤�� 37 * 38 * 39 * <--- byte_per_line ---> (*) width �ϡ��ºݤ�ɽ�� 40 * <-- width (*) --> ����륨�ꥢ�Υԥ��������� 41 * buffer =>@---------------+-----+ - �Х��ȿ��Ǥϡ� 42 * | |/////| ^ width * byte_per_pixel �Х��� 43 * | |/////| | �Ȥʤ롣 44 * | |/////| | height 45 * | |/////| | 46 * | |/////| v 47 * +---------------+/////| - 48 * |/////////////////////| 49 * +---------------------+ 50 * 51 * (��) byte_per_pixel == 2 �λ������̥Хåե���Υԥ����� (X,Y) �ˤϡ� 52 * ((unsigned short *) buffer) + (Y * byte_per_line / byte_per_pixel) + X 53 * �Ȥ��ơ�����������ǽ�� 54 * 55 * ����Ū�ˤϡ� graph_add_color() �ˤƼ������� pixel ���ͤ��� 56 * �饤�Ȥ��뤳�Ȥˤʤ롣 57 * 58 ************************************************************************/ 59 typedef struct { 60 61 int fullscreen; /* �����̥⡼�ɤʤ鿿��������ɥ��ʤ鵶 */ 62 63 int width; /* ���ݤ������̤Ρ������ǽ���ꥢ�� */ 64 int height; /* ���ݤ������̤Ρ������ǽ���ꥢ�⤵ */ 65 66 int byte_per_pixel; /* ���ݤ������̤Υԥ����뤢����Х��ȿ� */ 67 /* 1, 2, 4 �Τ����줫 */ 68 69 int byte_per_line; /* ���ݤ������̤�1�饤����Х��ȿ� */ 70 /* (width * byte_per_line) �ʾ� */ 71 72 void *buffer; /* ���ݤ������̤ΥХåե� */ 73 /* byte_per_pixel ���� */ 74 /* 1 �ʤ顢 unsigned char */ 75 /* 2 �ʤ顢 unsigned short */ 76 /* 4 �ʤ顢 unsigned int */ 77 /* �ǡ����������Ǥ���ݥ��� */ 78 79 int nr_color; /* ���ݤ������̤ˤơ����Ѳ�ǽ�ʿ��ο� */ 80 /* Ʊ�������ѤǤ��뿧�ο������� */ 81 /* �����硢���ο��ο����֤��� */ 82 /* ���������ʲ��Τ����줫�Ȥ��롣 */ 83 /* 16, 24, 144, 255 */ 84 /* ���ο������ʤ����ϡ� */ 85 /* 255 �ʾ� */ 86 87 int write_only; /* ���̤ΥХåե����ɽ��ԲĤξ�硢�� */ 88 /* ľ�ܥե졼��Хåե�����ݤ��� */ 89 /* ���ʤɤϡ����ˤ��Ƥ����� */ 90 91 int broken_mouse; /* �ޥ�����������ɽ�����ꤢ��ʤ顢�� */ 92 /* �ޥ�����������ɽ�������꤬���� */ 93 /* �����ƥब����褦���� */ 94 /* X11-DGA:�ޥ�����������ϴ��� */ 95 /* Ū�ˡ�ɽ������ʤ��� */ 96 /* SDL-DGA:�ޥ������������ɽ�� */ 97 /* ������ȡ����̤˥��� */ 98 /* ���Ĥ��礬���롣 */ 99 /* �����Υ����ƥ�Ǥϡ���˥塼 */ 100 /* ���̤��ȼ��Υ������������Ԥ� */ 101 /* �Τǡ� TRUE �åȤ��Ƥ����� */ 102 /* ���̤Υ����ƥ�Ǥϡ�����Ϥʤ� */ 103 /* �Ȼפ��Τǡ� FALSE �åȤ��� */ 104 /* �������ȡ� */ 105 106 void (*draw_start)(void); 107 void (*draw_finish)(void); 108 /* ���̤ΥХåե��˥�����������ݤˡ� */ 109 /* ��������˸ƤӽФ����ؿ� */ 110 /* buffer �Υ饤�Ȥ˺ݤ��ơ�ɬ�פ� */ 111 /* ���������������硢����� */ 112 /* �����ؿ��������ꤷ�Ƥ����� */ 113 /* �ä�ɬ�פ��ʤ���С� NULL �� */ 114 /* ���ꤷ�Ƥ����� */ 115 116 int dont_frameskip; /* �ե졼�ॹ���åפ�ػߤ���ʤ顢�� */ 117 /* ���ʤ�С��ե졼�����ɬ�� */ 118 /* graph_update ���ƤӽФ���롣 */ 119 /* ������åפ����������ϡ� */ 120 /* graph_update �����ˤ��ȼ��� */ 121 /* �����å������Ȥ߹��ळ�ȡ� */ 122 123 } T_GRAPH_INFO; 124 125 126 127 /**************************************************************************** 128 * ����ե��å������ν��������λ 129 * 130 * const T_GRAPH_SPEC *graph_init(void) 131 * 132 * �����ƥ��¸�Υ���ե��å������ν������Ԥ��� 133 * ����������������顢���̤˴ؤ�����ܾ���� T_GRAPH_SPEC ���ѿ��ؤ� 134 * �ݥ��ˤ��֤��������˼��Ԥ������ϡ� NULL ���֤��� 135 * 136 * o QUASI88 �ϡ���ư���� 1��������δؿ���ƤӽФ��� 137 * �����̥⡼�ɤ���ǽ�������̥������ڤ��ؤ��ϲ�ǽ�����ʤɤ�Ƚ�Ǥ��롣 138 * 139 * void graph_exit(void) 140 * 141 * �����ƥ��¸�Υ���ե��å������θ������Ԥ��� 142 * ���δؿ��ϡ���λ���� 1������ƤӽФ���롣 143 * 144 *****************************************************************************/ 145 const T_GRAPH_SPEC *graph_init(void); 146 void graph_exit(void); 147 148 149 150 /**************************************************************************** 151 * ����ե��å����������� 152 * 153 * const T_GRAPH_INFO *graph_setup(int width, int height, 154 * int fullscreen, double aspect) 155 * 156 * ������ɥ���������ꥵ�������롣�ޤ��������̥⡼�ɤ��ڤ��ؤ��롣 157 * width, height �ϡ�������ɥ��ʤ��������̥⡼�ɤΥ������� 158 * ɬ���� width �� 8���ܿ��� height �� 2���ܿ������åȤ���롣 159 * fullscreen �����ʤ顢�����̥⡼�ɤˤ��롣 160 * aspect �ϡ���˥����Υ����ڥ����� (�IJ���)�� 161 * 4:3���ʤ� 1.3333�� 16:9���ʤ� 1.7778������ʤ��ʤ� 0.0 �Ȥʤ롣 162 * fullscreen �����ǡ� aspect > 0.0 �ʤ饢���ڥ�������θ���������̥⡼�� 163 * �ˤ���Ȥ��줷�����⡣(���ΰ�����̵�뤷�Ƥ⡢�³��Ϥʤ�����) 164 * 165 * ɬ�����⡢�����̤�ˤʤ�ʤ��Ƥ�褤�� 166 * �����̥⡼�ɤ��ڤ��ؤ��˼��Ԥ����顢������ɥ���ɽ�����Ƥ�褤���� 167 * ���ꥵ�����������̥⡼�ɤ�̵���ʤ顢���������礭�ʡ������̥⡼�ɤ� 168 * ���Ƥ�褤��(������⾮���ʥ������ˤ��ƤϤ����ʤ�) 169 * 170 * �ǽ�Ū�ˤɤΤ褦�ʽ�����̤ˤʤä����� T_GRAPH_INFO ���ѿ��ؤΥݥ��� 171 * �ˤ��֤��������˼��Ԥ���³����ǽ�Ȥʤä����ϡ� NULL ���֤��� 172 * 173 * o QUASI88 �ϡ� graph_init() ��ˡ����δؿ���ƤӽФ��� 174 * ���̥������䡢�����̥⡼�����ؤκݤˤ⡢���δؿ���ƤӽФ��� 175 * QUASI88 �ϥ�����ɥ���1�Ĥ����Ȥ�ʤ��Τǡ�2���ܰʹߤθƤӽФ����ϡ� 176 * �����Υ�����ɥ��俧�ʤɤΡ����٤Ƥξ�����˴����롣 177 * 178 * <QUASI88 �β��̥������ڤ��ؤ����ν���> 179 * 180 * �� 181 * graph_setup(); 182 * graph_add_color(���Ƥο�); 183 * graph_update(�������ΰ�); 184 * �� 185 * 186 ****************************************************************************/ 187 const T_GRAPH_INFO *graph_setup(int width, int height, 188 int fullscreen, double aspect); 189 190 191 /**************************************************************************** 192 * ���γ��ݤ��˴� 193 * 194 * void graph_add_color(const PC88_PALETTE_T color[], 195 * int nr_color, unsigned long pixel[]) 196 * 197 * color �Ϻ�������Ѥ��������ǡ� nr_color �Ĥ����� 198 * ���� color ���б�����ԥ������ͤ� nr_color �Ĥ����� pixel ���֤��� 199 * 200 * �㤨�С�(T_GRAPH_INFO *)->byte_per_pixel �� 2 �Ǥ����硢QUASI88 �� 201 * pixel �ˤ��֤��줿�ԥ������ͤ� unsigned short ���˥��㥹�Ȥ��ơ� 202 * (T_GRAPH_INFO *)->buffer ��ľ�ܥ饤�Ȥ��뤳�Ȥˤʤ롣 203 * 204 * o TrueColor �δĶ��Ǥϡ� color �� RGB�ͤΤޤޥԥ�����ե����ޥåȤ� 205 * �Ѵ����ơ�pixel[] �˥��åȤ���Ф褤�Ϥ��� 206 * 207 * 208 * void graph_remove_color(int nr_pixel, unsigned long pixel[]) 209 * 210 * pixel �ϡ����Ѥ��ʤ��ʤä����ǡ� nr_pixel �Ĥ����� 211 * graph_add_color() �ˤƼ������� pixel ���ͤ����åȤ���Ƥ��롣 212 * 213 * o TrueColor �δĶ��Ǥϡ��ä˲����������ɬ�פϤʤ��ϥ��� 214 * 215 * o ���ѤǤ��뿧�����������ƥ�ˤ�ä����¤���Ƥ����硢���δ�����ɬ�� 216 * �ˤʤ뤳�Ȥ����롣 (X11 �� PseudoColor �Ƕ�ͭ���顼��Ȥ����ʤ�) 217 * 218 * QUASI88 �� graph_remove_color ��ƤӽФ���硢���ΰ����� pixel �ϡ� 219 * ľ���� graph_add_color() �ˤƳ��ݤ��� nr_color �Ĥ� pixel �� 220 * Ʊ���Ȥʤ�褦�ˤ��Ƥ��롣 (�ĤޤꡢLIFO����) 221 * 222 * �� 223 * graph_add_color(8��); ���ơ������Ѥ�8�����ݤ��� 224 * �� 225 * graph_add_color(16��); �ᥤ���Ѥ�16�����ݤ��� 226 * �� 227 * graph_remove_color(16��); ľ����16�����˴����� 228 * �� 229 * graph_remove_color(8��); ����ˤ�������8�����˴����� 230 * �� 231 * 232 * ���Τ��Ȥ�����Ȥ��ơ� graph_add_color(), graph_remove_color() �� 233 * ��������ɬ�פ����롣 234 * 235 *****************************************************************************/ 236 void graph_add_color(const PC88_PALETTE_T color[], 237 int nr_color, unsigned long pixel[]); 238 void graph_remove_color(int nr_pixel, unsigned long pixel[]); 239 240 241 242 /*********************************************************************** 243 * ���̤ι��� 244 * 245 * void graph_update(int nr_rect, T_SCREEN_RECT rect[]) 246 * �����ǡ�����ºݤ����褹�롣 247 * ���褷�������ꥢ����T_SCREEN_RECT �������� rect[] �� nr_rect ��ʬ�� 248 * ���åȤ���Ƥ���Τǡ����Υ��ꥢ�����褹�롣 249 * 250 * o QUASI88 �ϡ�ɽ���κݤ˰ʲ��ν�˽������롣 251 * 252 * if (�ե졼�ॹ���åפ��ʤ�?) { ��1 253 * if (�ѥ�å��Ѳ�����?) { 254 * graph_remove_color(����Υѥ�åȤǻȤä���); 255 * graph_add_color(����Υѥ�åȤǻȤ���); 256 * �����Ѳ�����Ȥ��� 257 * } 258 * if (�����Ѳ�����?) { 259 * if (draw_start != NULL) { ��2 260 * (*draw_start)(); 261 * } 262 * buffer �������� 263 * if (draw_finish != NULL) { ��2 264 * (*draw_finish)(); 265 * } 266 * graph_update(���̾�Ρ��������줿����ΰ�); 267 * } 268 * 269 * ��1 graph_setup() �ˤơ� dont_frameskip �����Ǥ��ä���硢 270 * ������ե졼�ॹ���åפ��ʤ� 271 * ��2 graph_setup() �ˤơ� draw_start / draw_finish �� 272 * �ؿ��ݥ������ꤵ�줿���Τߡ��ƤӽФ��� 273 * 274 ************************************************************************/ 275 typedef struct { 276 int x, y; 277 int width, height; 278 } T_GRAPH_RECT; 279 280 void graph_update(int nr_rect, T_GRAPH_RECT rect[]); 281 282 283 284 /*********************************************************************** 285 * °�������� 286 * �����ϼ������ʤ��Ƥ⡢�����餯���ߥ��ư��ˤϱƶ��Ϥʤ��� 287 * �����ƥब���ݡ��Ȥ��Ƥ�����ܤ�����С��������������Ф褤�� 288 * 289 * void graph_set_window_title(const char *title) 290 * ������ɥ��Υ����ȥ�����ꤹ�롣 291 * title ������ʸ����ǡ� 255ʸ������� ASCII�� 292 * 293 * void graph_set_attribute(int mouse_show, int grab, int keyrepeat_on) 294 * ���ޤ��ޤ�°�������ꤹ�롣 295 * mouse_show �����ʤ顢�ޥ������������ɽ�����롣���ʤ�õ�롣 296 * grab �� ���ʤ顢�ޥ������������Ϥ�֤��롣���ʤ餷�ʤ��� 297 * keyrepeat_on �����ʤ顢������ԡ��Ȥ�ˤ��롣���ʤ饪�դˤ��롣 298 * 299 ************************************************************************/ 300 void graph_set_window_title(const char *title); 301 void graph_set_attribute(int mouse_show, int grab, int keyrepeat_on); 302 303 304 305 #endif /* GRAPH_H_INCLUDED */ 306