変愚蛮怒のメインリポジトリです
Revision | 6fb57c9350afc907d593bbe759d7be8cabdc1956 (tree) |
---|---|
Time | 2002-04-17 21:45:37 |
Author | mogami <mogami@0568...> |
Commiter | mogami |
いろいろ修正。
- USE_TRANSPARENCY対応。
- タイル高、タイル幅、メニューをちゃんとサポートしていなかったのを修正。
- Bigtileの右半分の再描画ができていなかったのを修正。
- ウィンドウのサイズをマウスで変えたとき変なサイズになってしまうバグ修正。
!!!! To do: 全角ASCIIのモンスターが動いた跡の地形タイルの右半分が再描画されないバグが残っている。
@@ -860,16 +860,8 @@ static void term_data_check_size(term_data *td) | ||
860 | 860 | /* Allow small windows for the rest */ |
861 | 861 | else |
862 | 862 | { |
863 | -#ifdef MAC_MPW | |
864 | - if ((td->cols < 60) || (td->rows < 18)) | |
865 | - { | |
866 | - td->cols = 60; | |
867 | - td->rows = 18; | |
868 | - } | |
869 | -#else | |
870 | 863 | if (td->cols < 1) td->cols = 1; |
871 | 864 | if (td->rows < 1) td->rows = 1; |
872 | -#endif | |
873 | 865 | } |
874 | 866 | |
875 | 867 | /* Minimal tile size */ |
@@ -921,6 +913,7 @@ static void term_data_check_size(term_data *td) | ||
921 | 913 | td->r.bottom = td->r.top + td->size_hgt; |
922 | 914 | |
923 | 915 | /* Assume no graphics */ |
916 | + td->t->higher_pict = FALSE; | |
924 | 917 | td->t->always_pict = FALSE; |
925 | 918 | |
926 | 919 | #ifdef ANGBAND_LITE_MAC |
@@ -930,9 +923,26 @@ static void term_data_check_size(term_data *td) | ||
930 | 923 | #else /* ANGBAND_LITE_MAC */ |
931 | 924 | |
932 | 925 | /* Handle graphics */ |
933 | - td->t->higher_pict = TRUE; | |
926 | + if (use_graphics) | |
927 | + { | |
928 | + /* Use higher_pict whenever possible */ | |
929 | + if (td->font_mono) td->t->higher_pict = TRUE; | |
930 | + | |
931 | + /* Use always_pict only when necessary */ | |
932 | + else td->t->always_pict = TRUE; | |
933 | + } | |
934 | 934 | |
935 | 935 | #endif /* ANGBAND_LITE_MAC */ |
936 | + | |
937 | + /* Fake mono-space */ | |
938 | + if (!td->font_mono || | |
939 | + (td->font_wid != td->tile_wid) || | |
940 | + (td->font_hgt != td->tile_hgt)) | |
941 | + { | |
942 | + /* Handle fake monospace -- this is SLOW */ | |
943 | + if (td->t->higher_pict) td->t->higher_pict = FALSE; | |
944 | + td->t->always_pict = TRUE; | |
945 | + } | |
936 | 946 | } |
937 | 947 | |
938 | 948 | static OSErr XDDSWUpDateGWorldFromPict( term_data *td ); |
@@ -990,10 +1000,10 @@ static void term_data_redraw(term_data *td) | ||
990 | 1000 | * Constants |
991 | 1001 | */ |
992 | 1002 | |
993 | -static int pictID = 1001; /* 8x8 tiles; 16x16 tiles are 1002 */ | |
1003 | +static int pictID = 1001; /* 8x8 tiles; 16x16 tiles are 1002 */ | |
994 | 1004 | |
995 | -static int grafWidth = 8; /* Always equal to grafHeight */ | |
996 | -static int grafHeight = 8; /* Either 8 or 16 */ | |
1005 | +static int grafWidth = 8; /* Always equal to grafHeight */ | |
1006 | +static int grafHeight = 8; /* Either 8 or 16 */ | |
997 | 1007 | |
998 | 1008 | static bool arg_newstyle_graphics; |
999 | 1009 | static bool use_newstyle_graphics; |
@@ -1236,21 +1246,23 @@ static OSErr XDDSWUpDateGWorldFromPict( term_data *td ) | ||
1236 | 1246 | //SysBeep(0); |
1237 | 1247 | return; |
1238 | 1248 | } |
1239 | - | |
1249 | + | |
1250 | +#if 0 | |
1240 | 1251 | /* Save GWorld */ |
1241 | -/* GetGWorld(&saveGWorld, &saveGDevice); */ | |
1252 | + GetGWorld(&saveGWorld, &saveGDevice); | |
1242 | 1253 | |
1243 | 1254 | /* Activate */ |
1244 | -/* SetGWorld(td->bufferPort, nil); */ | |
1255 | + SetGWorld(td->bufferPort, nil); | |
1245 | 1256 | |
1246 | 1257 | /* Dump the pict into the GWorld */ |
1247 | -/* (void)LockPixels(GetGWorldPixMap(td->bufferPort)); */ | |
1248 | -/* EraseRect(&td->bufferPort->portRect); */ | |
1258 | + (void)LockPixels(GetGWorldPixMap(td->bufferPort)); | |
1259 | + EraseRect(&td->bufferPort->portRect); | |
1249 | 1260 | |
1250 | -/* UnlockPixels(GetGWorldPixMap(td->bufferPort)); */ | |
1261 | + UnlockPixels(GetGWorldPixMap(td->bufferPort)); | |
1251 | 1262 | |
1252 | 1263 | /* Restore GWorld */ |
1253 | -/* SetGWorld(saveGWorld, saveGDevice); */ | |
1264 | + SetGWorld(saveGWorld, saveGDevice); | |
1265 | +#endif | |
1254 | 1266 | |
1255 | 1267 | } |
1256 | 1268 |
@@ -1855,7 +1867,12 @@ static errr Term_text_mac(int x, int y, int n, byte a, const char *cp) | ||
1855 | 1867 | * |
1856 | 1868 | * Erase "n" characters starting at (x,y) |
1857 | 1869 | */ |
1870 | +#ifdef USE_TRANSPARENCY | |
1871 | +static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp, | |
1872 | + const byte *tap, const char *tcp) | |
1873 | +#else | |
1858 | 1874 | static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) |
1875 | +#endif | |
1859 | 1876 | { |
1860 | 1877 | int i; |
1861 | 1878 | Rect r2; |
@@ -1901,7 +1918,6 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) | ||
1901 | 1918 | { |
1902 | 1919 | /* Destination rectangle */ |
1903 | 1920 | r2.left = x * td->tile_wid + td->size_ow1; |
1904 | - r2.right = r2.left + td->tile_wid; | |
1905 | 1921 | r2.top = y * td->tile_hgt + td->size_oh1; |
1906 | 1922 | r2.bottom = r2.top + td->tile_hgt; |
1907 | 1923 |
@@ -1918,19 +1934,55 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) | ||
1918 | 1934 | byte a = ap[i]; |
1919 | 1935 | char c = cp[i]; |
1920 | 1936 | |
1937 | + /* Second byte of bigtile */ | |
1938 | + if (use_bigtile && a == 255) | |
1939 | + { | |
1940 | + /* Advance */ | |
1941 | + r2.left += td->tile_wid; | |
1942 | + | |
1943 | + continue; | |
1944 | + } | |
1945 | + | |
1946 | + /* Prepare right of rectangle now */ | |
1947 | + r2.right = r2.left + td->tile_wid; | |
1948 | + | |
1921 | 1949 | #ifdef ANGBAND_LITE_MAC |
1922 | 1950 | |
1923 | - /* Nothing */ | |
1951 | + /* No graphics */ | |
1924 | 1952 | |
1925 | 1953 | #else /* ANGBAND_LITE_MAC */ |
1926 | 1954 | |
1927 | 1955 | /* Graphics -- if Available and Needed */ |
1928 | - if (use_graphics && | |
1929 | - ((byte)a & 0x80) && ((byte)c & 0x80)) | |
1956 | + if (use_graphics && ((byte)a & 0x80) && ((byte)c & 0x80)) | |
1930 | 1957 | { |
1958 | + BitMapPtr srcBitMap = (BitMapPtr)(frameP->framePix); | |
1959 | + BitMapPtr destBitMap; | |
1960 | + | |
1931 | 1961 | int col, row; |
1932 | 1962 | Rect r1; |
1933 | 1963 | |
1964 | +#ifdef USE_TRANSPARENCY | |
1965 | + Rect terrain_r; | |
1966 | + bool terrain_flag = FALSE; | |
1967 | + byte ta = tap[i]; | |
1968 | + char tc = tcp[i]; | |
1969 | + | |
1970 | + if (a != ta || c != tc) | |
1971 | + { | |
1972 | + /* Row and Col */ | |
1973 | + row = ((byte)ta & 0x7F); | |
1974 | + col = ((byte)tc & 0x7F); | |
1975 | + | |
1976 | + /* Terrain Source rectangle */ | |
1977 | + terrain_r.left = col * grafWidth; | |
1978 | + terrain_r.top = row * grafHeight; | |
1979 | + terrain_r.right = terrain_r.left + grafWidth; | |
1980 | + terrain_r.bottom = terrain_r.top + grafHeight; | |
1981 | + | |
1982 | + terrain_flag = TRUE; | |
1983 | + } | |
1984 | +#endif | |
1985 | + | |
1934 | 1986 | /* Row and Col */ |
1935 | 1987 | row = ((byte)a & 0x7F); |
1936 | 1988 | col = ((byte)c & 0x7F); |
@@ -1946,28 +1998,44 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) | ||
1946 | 1998 | ForeColor(blackColor); |
1947 | 1999 | |
1948 | 2000 | /* Draw the picture */ |
1949 | - { | |
1950 | - BitMapPtr srcBitMap = (BitMapPtr)(frameP->framePix); | |
1951 | - BitMapPtr destBitMap; | |
2001 | + | |
2002 | + if (use_buffer) | |
2003 | + destBitMap = (BitMapPtr)(td->bufferPix); | |
2004 | + else | |
2005 | + destBitMap = (BitMapPtr)&(td->w->portBits); | |
1952 | 2006 | |
1953 | - if( use_buffer ) | |
1954 | - { | |
1955 | - destBitMap = (BitMapPtr)(td->bufferPix); | |
1956 | - } | |
1957 | - else | |
1958 | - { | |
1959 | - destBitMap = (BitMapPtr)&(td->w->portBits); | |
1960 | - } | |
2007 | + if (use_bigtile) r2.right += td->tile_wid; | |
2008 | + | |
2009 | +#ifdef USE_TRANSPARENCY | |
2010 | + if (terrain_flag) | |
2011 | + { | |
2012 | + /* | |
2013 | + * Source mode const = srcCopy: | |
2014 | + * | |
2015 | + * determine how close the color of the source | |
2016 | + * pixel is to black, and assign this relative | |
2017 | + * amount of foreground color to the | |
2018 | + * destination pixel; determine how close the | |
2019 | + * color of the source pixel is to white, and | |
2020 | + * assign this relative amount of background | |
2021 | + * color to the destination pixel | |
2022 | + */ | |
2023 | + CopyBits( srcBitMap, destBitMap, &terrain_r, &r2, srcCopy, NULL ); | |
1961 | 2024 | |
1962 | - /* draw transparent tile */ | |
1963 | - /* BackColor is ignored and the destination is left untouched */ | |
2025 | + /* | |
2026 | + * Draw transparent tile | |
2027 | + * BackColor is ignored and the destination is | |
2028 | + * left untouched | |
2029 | + */ | |
1964 | 2030 | BackColor(blackColor); |
1965 | - | |
1966 | - if (use_bigtile) r2.right += td->tile_wid; | |
1967 | - | |
1968 | 2031 | CopyBits( srcBitMap, destBitMap, &r1, &r2, transparent, NULL ); |
1969 | - if (use_bigtile) r2.right -= td->tile_wid; | |
1970 | 2032 | } |
2033 | + else | |
2034 | +#endif /* USE_TRANSPARENCY */ | |
2035 | + { | |
2036 | + CopyBits( srcBitMap, destBitMap, &r1, &r2, srcCopy, NULL ); | |
2037 | + } | |
2038 | + | |
1971 | 2039 | /* Restore colors */ |
1972 | 2040 | BackColor(blackColor); |
1973 | 2041 | ForeColor(whiteColor); |
@@ -1985,51 +2053,46 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) | ||
1985 | 2053 | if (!done) |
1986 | 2054 | { |
1987 | 2055 | int xp, yp; |
1988 | -#ifndef JP | |
1989 | - /* Erase */ | |
1990 | - EraseRect(&r2); | |
1991 | 2056 | |
1992 | 2057 | /* Set the color */ |
1993 | 2058 | term_data_color(td, (a & 0x0F)); |
1994 | - | |
1995 | - /* Starting pixel */ | |
1996 | - xp = r2.left + td->tile_o_x; | |
1997 | - yp = r2.top + td->tile_o_y; | |
1998 | - | |
1999 | - /* Move to the correct location */ | |
2000 | - MoveTo(xp, yp); | |
2001 | - | |
2002 | - /* Draw the character */ | |
2003 | - DrawChar(c); | |
2004 | -#else | |
2005 | - /* Set the color */ | |
2006 | - term_data_color(td, (a & 0x0F)); | |
2007 | 2059 | |
2008 | 2060 | /* Starting pixel */ |
2009 | 2061 | xp = r2.left + td->tile_o_x; |
2010 | - yp = td->tile_o_y; | |
2062 | + yp = r2.top + td->tile_o_y; | |
2011 | 2063 | |
2012 | 2064 | /* Move to the correct location */ |
2013 | 2065 | MoveTo(xp, yp); |
2014 | 2066 | |
2015 | - if(iskanji(c)){ | |
2067 | +#ifdef JP | |
2068 | + if (iskanji(c)) | |
2069 | + { | |
2070 | + /* Double width rectangle */ | |
2071 | + r2.right += td->tile_wid; | |
2072 | + | |
2073 | + /* Erase */ | |
2074 | + EraseRect(&r2); | |
2075 | + | |
2016 | 2076 | /* Draw the character */ |
2017 | 2077 | DrawText(cp, i, 2); |
2018 | 2078 | |
2019 | 2079 | i++; |
2020 | 2080 | |
2021 | 2081 | r2.left += td->tile_wid; |
2022 | - r2.right += td->tile_wid; | |
2023 | - } else { | |
2082 | + } | |
2083 | + else | |
2084 | +#endif | |
2085 | + { | |
2086 | + /* Erase */ | |
2087 | + EraseRect(&r2); | |
2088 | + | |
2024 | 2089 | /* Draw the character */ |
2025 | 2090 | DrawChar(c); |
2026 | 2091 | } |
2027 | -#endif | |
2028 | 2092 | } |
2029 | 2093 | |
2030 | 2094 | /* Advance */ |
2031 | 2095 | r2.left += td->tile_wid; |
2032 | - r2.right += td->tile_wid; | |
2033 | 2096 | } |
2034 | 2097 | |
2035 | 2098 | if( use_buffer ) |
@@ -2053,6 +2116,7 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) | ||
2053 | 2116 | destRect.top = y * td->tile_hgt + td->size_oh1; |
2054 | 2117 | destRect.bottom = destRect.top + td->tile_hgt; |
2055 | 2118 | |
2119 | + /* Double width rectangle */ | |
2056 | 2120 | if (use_bigtile) |
2057 | 2121 | { |
2058 | 2122 | srcRect.right += td->tile_wid * n; |
@@ -2068,9 +2132,7 @@ static errr Term_pict_mac(int x, int y, int n, const byte *ap, const char *cp) | ||
2068 | 2132 | BackColor(whiteColor); |
2069 | 2133 | ForeColor(blackColor); |
2070 | 2134 | |
2071 | - //CopyBits( srcBitMap, destBitMap, &srcRect, &destRect, srcCopy, NULL ); | |
2072 | - CopyBits( (BitMapPtr)(td->bufferPix) | |
2073 | - , &(td->w->portBits), &srcRect, &destRect, srcCopy, NULL ); | |
2135 | + CopyBits( srcBitMap, destBitMap, &srcRect, &destRect, srcCopy, NULL ); | |
2074 | 2136 | |
2075 | 2137 | /* Restore colors */ |
2076 | 2138 | BackColor(blackColor); |
@@ -3408,7 +3470,6 @@ static void setup_menus(void) | ||
3408 | 3470 | if (TRUE) |
3409 | 3471 | { |
3410 | 3472 | EnableItem(m, 7); |
3411 | -/* EnableItem(m, 8); */ | |
3412 | 3473 | } |
3413 | 3474 | |
3414 | 3475 |
@@ -3579,9 +3640,6 @@ static void setup_menus(void) | ||
3579 | 3640 | EnableItem(m, 9); |
3580 | 3641 | CheckItem(m, 9, arg_bigtile); |
3581 | 3642 | |
3582 | - /* Item "Hack" */ | |
3583 | - /* EnableItem(m, 9); */ | |
3584 | - | |
3585 | 3643 | |
3586 | 3644 | /* TileWidth menu */ |
3587 | 3645 | m = GetMenuHandle(135); //m = GetMHandle(135); |
@@ -4472,9 +4530,6 @@ static bool CheckEvents(bool wait) | ||
4472 | 4530 | /* Hack -- Prepare the menus */ |
4473 | 4531 | setup_menus(); |
4474 | 4532 | |
4475 | - /* Mega-Hack -- allow easy exit if nothing to save */ | |
4476 | -/* if (!character_generated && (ch=='Q' || ch=='q')) ch = 'e'; */ | |
4477 | - | |
4478 | 4533 | /* Run the Menu-Handler */ |
4479 | 4534 | menu(MenuKey(ch)); |
4480 | 4535 |
@@ -4627,7 +4682,7 @@ static bool CheckEvents(bool wait) | ||
4627 | 4682 | |
4628 | 4683 | case inGrow: |
4629 | 4684 | { |
4630 | - int x, y; | |
4685 | + s16b x, y; | |
4631 | 4686 | |
4632 | 4687 | term *old = Term; |
4633 | 4688 |
@@ -4656,7 +4711,6 @@ static bool CheckEvents(bool wait) | ||
4656 | 4711 | |
4657 | 4712 | /* Apply and Verify */ |
4658 | 4713 | term_data_check_size(td); |
4659 | - | |
4660 | 4714 | /* Activate */ |
4661 | 4715 | Term_activate(td->t); |
4662 | 4716 |
@@ -5238,11 +5292,6 @@ BackColor(blackColor); | ||
5238 | 5292 | |
5239 | 5293 | /* Note the "system" */ |
5240 | 5294 | ANGBAND_SYS = "mac"; |
5241 | -/* #if 0 | |
5242 | - ANGBAND_GRAF = "new"; | |
5243 | -#else | |
5244 | - ANGBAND_GRAF = "old"; | |
5245 | -#endif */ | |
5246 | 5295 | |
5247 | 5296 | /* Initialize */ |
5248 | 5297 | init_stuff(); |