1 /*
2     TiMidity++ -- MIDI to WAVE converter and player
3     Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4     Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
5 
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10 
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15 
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 
20 	Macintosh interface for TiMidity
21 	by T.Nogami	<t-nogami@happy.email.ne.jp>
22 
23     mac_wrdwindow.h
24     Macintosh graphics driver for WRD
25 */
26 
27 #ifndef MAC_GRF_H
28 #define MAC_GRF_H
29 
30 #include "png.h"
31 #include "wrd.h"
32 
33 #if ENTITY
34  #define EXTERN /*entitiy*/
35 #else
36  #define EXTERN  extern
37 #endif
38 
39 static const RGBColor	black={0,0,0},white={0xFFFF,0xFFFF,0xFFFF};
40 
41 #define BASE_X	8
42 #define	BASE_Y	16
43 #define LINES 25
44 #define COLS 80
45 #define SIZEX 640
46 #define SIZEY 400
47 
48 // for graphics
49 EXTERN GWorldPtr	graphicWorld[8], dispWorld, charbufWorld;
50 #define	GACTIVE_PIX	(graphicWorld[activeGraphics]->portPixMap)
51 #define	GDISP_PIX	(graphicWorld[dispGraphics]->portPixMap)
52 #define	DISP_PIX	(dispWorld->portPixMap)
53 EXTERN int			gmode_mask, gmode_mask_gline, dev_gon_flag, dev_redrawflag;
54 #define				DEV_SET_GMODE(mask)  (gmode_mask=gmode_mask_gline=(mask))
55 EXTERN RGBColor		dev_palette[20][17];
56 EXTERN int			startpal, endpal; //for @FADE
57 
58 //for text
59 EXTERN char			char_vram[25+1][80+2];
60 EXTERN int			wrd_ton;
61 #define				CHAR_VRAM(x,y)  (char_vram[y][x])
62 EXTERN char			char_color_vram[25+1][80+1];
63 #define				CHAR_COLOR_VRAM(x,y)  (char_color_vram[y][x])
64 EXTERN char			multi_byte_flag[25+1][80+1];
65 #define				MULTI_BYTE_FLAG(x,y)  (multi_byte_flag[y][x])   //...Umm
66 EXTERN int			activeGraphics, dispGraphics, gvram_bank_num;
67 #define WRD_LOCX(x)		(((x)-1)*BASE_X)
68 #define WRD_LOCY(y)		((y)*BASE_Y-3)
69 #define WRD_MOVE_COURSOR_TMP(x,y)	MoveTo( WRD_LOCX(x), WRD_LOCY(y) )
70 #define IS_MULTI_BYTE(c)	( ((c)&0x80) && ((0x1 <= ((c)&0x7F) && ((c)&0x7F) <= 0x1f) ||\
71 				 (0x60 <= ((c)&0x7F) && ((c)&0x7F) <= 0x7c)))
72 #define SYNC_DISP(rect)	(CopyBits((BitMap*)&DISP_PIX, &win.ref->portBits, \
73 			&(rect), &(rect), srcCopy,0)) //make visible Graphics
74 #define LOCK_ALL_PIXMAP() (LockPixels(GDISP_PIX),LockPixels(GACTIVE_PIX),LockPixels(DISP_PIX))
75 #define UNLOCK_ALL_PIXMAP() (UnlockPixels(GDISP_PIX),UnlockPixels(GACTIVE_PIX),UnlockPixels(DISP_PIX))
76 
77 #define SET_G_COLOR(code,world)	((world)->fgColor=(code))
78 EXTERN int pallette_exist, fading;
79 
80 
81 EXTERN int		wrd_coursor_x,wrd_coursor_y;
82 EXTERN int		wrd_text_color_attr;
83 #define CATTR_LPART (1)
84 #define CATTR_16FONT (1<<1)
85 #define CATTR_COLORED (1<<2)
86 #define CATTR_BGCOLORED (1<<3)
87 #define CATTR_TXTCOL_MASK_SHIFT 4
88 #define CATTR_TXTCOL_MASK (7<<CATTR_TXTCOL_MASK_SHIFT)
89 #define CATTR_INVAL (1<<31)
90 #define TCOLOR_INDEX_SHIFT	32
91 #define TCODE2INDEX(attr)	((((attr)&CATTR_TXTCOL_MASK)>>CATTR_TXTCOL_MASK_SHIFT)+TCOLOR_INDEX_SHIFT)
92 #define SET_T_COLOR(attr)	(wrd_text_color_attr=(attr))
93 #define SET_T_RGBFORECOLOR_TMP(attr)	(dispWorld->fgColor=TCODE2INDEX(attr))
94 
95 void dev_init(int version);
96 void dev_set_height(int height);
97 void dev_redisp(Rect rect);
98 void dev_remake_disp(Rect rect);
99 void dev_draw_text_gmode(PixMapHandle pixmap, int x, int y, const char* s, int len,
100 		int pmask, int mode, int fgcolor, int bgcolor, int ton_mode);
101 
102 void dev_change_palette(RGBColor pal[16]);
103 void dev_change_1_palette(int code, RGBColor color);
104 void dev_init_text_color();
105 void MyCopyBits(PixMapHandle srcPixmap, PixMapHandle dstPixmap,
106 		Rect srcRect, Rect dstRect, short mode, int trans, int pmask,
107 		int maskx, int masky, const uint8 maskdata[]);
108 void dev_gmove(int x1, int y1, int x2, int y2, int xd, int yd,
109 			GWorldPtr srcworld, GWorldPtr destworld, int sw, int trans, int mask,
110 			int maskx, int masky, const uint8 maskdata[]);
111 void dev_box(PixMapHandle pixmap, Rect rect, int color, int pmask);
112 void dev_line(int x1, int y1, int x2, int y2, int color, int style,
113 	int pmask, PixMapHandle pixmap );
114 void dev_gline(int x1, int y1, int x2, int y2, int p1, int sw, int p2, GWorldPtr world);
115 void mac_setfont(GWorldPtr world, Str255 fontname);
116 //#define WRD_FONTNAME "\p��������"
117 #define WRD_FONTNAME "\pOsaka�|����"
118 
119 void sry_start();
120 void sry_end();
121 void sry_start();
122 void sry_update();
123 
124 int mac_loadpng_pre( png_structp *png_ptrp, png_infop *info_ptrp, struct timidity_file * tf);
125 int mac_loadpng(png_structp png_ptr, png_infop info_ptr, GWorldPtr world, RGBColor pal[256] );
126 void mac_loadpng_post(png_structp png_ptr, png_infop info_ptr);
127 
128 EXTERN Rect portRect
129 #if ENTITY
130  ={0,0,480,640}
131 #endif
132 ;
133 
134 EXTERN RGBColor textcolor[8]
135 #if ENTITY
136 	={{0x0000,0x0000,0x0000},	//0: black
137 	{0xFFFF,0x0000,0x0000},	//1:red
138 	{0x0000,0xFFFF,0x0000},	//2:green
139 	{0xFFFF,0xFFFF,0x0000},	//3:yellow
140 	{0x0000,0x0000,0xFFFF},	//4:blue
141 	{0xFFFF,0x0000,0xFFFF},	//5:purpl
142 	{0x0000,0xFFFF,0xFFFF},	//6:mizuiro
143 	{0xFFFF,0xFFFF,0xFFFF} } //7:white
144 #endif
145 ;
146 
147 #endif //MAC_GRF_H
148 
149 
150