diff options
-rw-r--r-- | src/iso/hackdef.h | 44 | ||||
-rw-r--r-- | src/iso/readme.txt | 6 | ||||
-rw-r--r-- | src/iso/simgraph.c | 1429 | ||||
-rw-r--r-- | src/iso/simgraph.h | 159 | ||||
-rw-r--r-- | src/iso/simsys.h | 197 | ||||
-rw-r--r-- | src/iso/simview.c | 87 | ||||
-rw-r--r-- | src/iso/simview.h | 41 | ||||
-rw-r--r-- | src/iso/walls4.h | 288 | ||||
-rw-r--r-- | src/iso/walls9.h | 288 | ||||
-rw-r--r-- | src/iso/world_adaptor.c | 226 | ||||
-rw-r--r-- | src/iso/world_adaptor.h | 117 | ||||
-rw-r--r-- | src/iso/world_view.c | 499 | ||||
-rw-r--r-- | src/iso/world_view.h | 49 | ||||
-rw-r--r-- | src/maim-iso.c | 873 | ||||
-rw-r--r-- | src/main-sdl-iso.c | 1905 | ||||
-rw-r--r-- | src/main-sdl.c | 607 | ||||
-rw-r--r-- | src/main.c | 17 |
17 files changed, 0 insertions, 6832 deletions
diff --git a/src/iso/hackdef.h b/src/iso/hackdef.h deleted file mode 100644 index 413d77ad..00000000 --- a/src/iso/hackdef.h +++ /dev/null @@ -1,44 +0,0 @@ -/* hackdef.h - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph<->Angband adaption code. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* hackdef.c - * definion of hacklevel for iso view - * - * Hj. Maltahner, Feb. 2001 - */ - - -/* - * this enables somthing like a bigscreen mode but keeps a - * resonable clean interfacing between iso-view and angband - * this requires changes to map_info() to support clipping. - * - * Hj. Maltahner, Feb. 2001 - */ -#define USE_SMALL_ISO_HACK diff --git a/src/iso/readme.txt b/src/iso/readme.txt deleted file mode 100644 index ecef9638..00000000 --- a/src/iso/readme.txt +++ /dev/null @@ -1,6 +0,0 @@ -The iso view sources will reside here. - -At the moment this is just a test for CVS access. - --- -Hansjoerg Malthaner diff --git a/src/iso/simgraph.c b/src/iso/simgraph.c deleted file mode 100644 index 1797f037..00000000 --- a/src/iso/simgraph.c +++ /dev/null @@ -1,1429 +0,0 @@ -/* simgraph.c - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph graphics engine. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - - -/* simgraph.c - * - * Versuch einer Graphic fuer Simulationsspiele - * Hj. Malthaner, Aug. 1997 - * - * A try to create a graphics engine for simulation games. - * - * 3D, isometrische Darstellung - * - * 3D, isometric display - * - * - * 18.11.97 lineare Speicherung fuer Images -> hoehere Performance - * 22.03.00 run längen Speicherung fuer Images -> hoehere Performance - * 15.08.00 dirty tile verwaltung fuer effizientere updates - */ - -//#define DEBUG 1 - - -#if defined(MSDOS) || defined(__MINGW32__) -#define USE_SOFTPOINTER -#endif - -#include <stdlib.h> -#include <string.h> -#include <stdio.h> -#include <math.h> - -#include "simgraph.h" -#include "simsys.h" - -extern unsigned int class; -extern unsigned int code; -extern int mx,my; /* es sind negative Koodinaten mgl */ - -#ifdef USE_SOFTPOINTER -static int softpointer = 261; -static int old_my = -1; // die icon leiste muss neu gezeichnet werden wenn der - // Mauszeiger darueber schwebt -#endif - -static unsigned char dr_fonttab[2048]; /* Unser Zeichensatz sitzt hier */ - -/* - * pixel value type, RGB 555 - */ -typedef unsigned short PIXVAL; - - -struct imd { - int y; // offset top - int h; // image height - int len; // data length in entities of PIXVAL size - PIXVAL * data; // iamge data -}; - - -static int anz_images = 0; - -static int disp_width = 640; -static int disp_height = 480; - -/** - * Tile size in pixels - * - * @author Hj. Malthaner - */ -static int tile_size = 32; - -static struct imd *images = NULL; -static struct imd *images1 = NULL; -static struct imd *images2 = NULL; - - -static PIXVAL *textur = NULL; - - -static struct clip_dimension clip_rect; - - -// dirty tile management strcutures - -#define DIRTY_TILE_SIZE 32 -#define DIRTY_TILE_SHIFT 5 - -static char *tile_dirty = NULL; -static char *tile_dirty_old = NULL; - -static int tiles_per_line = 0; -static int tile_lines = 0; - - -// colormap management structures - -static unsigned char day_pal[256*3]; -static unsigned char night_pal[256*3]; -static unsigned char base_pal[256*3]; - -static int light_level = 0; -static int color_level = 1; - - -// ------------ procedure like defines -------------------- - - -#define mark_tile_dirty(x,y) tile_dirty[(x) + (y)*tiles_per_line] = 1 -#define is_tile_dirty(x,y) ((tile_dirty[(x) + (y)*tiles_per_line]) || (tile_dirty_old[(x) + (y)*tiles_per_line]) ) - -// ----------------- procedures --------------------------- - - -/** - * Markiert ein Tile as schmutzig, ohne Clipping - * @author Hj. Malthaner - */ -static void mark_rect_dirty_nc(int x1, int y1, int x2, int y2) -{ - int x, y; - - // floor to tile size - - x1 >>= DIRTY_TILE_SHIFT; - y1 >>= DIRTY_TILE_SHIFT; - x2 >>= DIRTY_TILE_SHIFT; - y2 >>= DIRTY_TILE_SHIFT; - - for(y=y1; y<=y2; y++) { - for(x=x1; x<=x2; x++) { - mark_tile_dirty(x, y); - } - } -} - -/** - * Markiert ein Tile as schmutzig, mit Clipping - * @author Hj. Malthaner - */ -void mark_rect_dirty_wc(int x1, int y1, int x2, int y2) -{ - if(x1 < 0) x1 = 0; - if(x1 >= disp_width) x1 = disp_width-1; - - if(y1 < 0) y1 = 0; - if(y1 >= disp_height) y1 = disp_height-1; - - if(x2 < 0) x2 = 0; - if(x2 >= disp_width) x2 = disp_width-1; - - if(y2 < 0) y2 = 0; - if(y2 >= disp_height) y2 = disp_height-1; - - mark_rect_dirty_nc(x1, y1, x2, y2); -} - -/** - * Clipped einen Wert in Intervall - * @author Hj. Malthaner - */ -static int clip(int w, int u, int o) -{ - return w < u ? u : w > o ? o : w; -} - - -/** - * Laedt den Font - * @author Hj. Malthaner - */ -static void init_font() -{ - FILE *f = NULL; - - // suche in ./draw.fnt - - if(f==NULL ) { - f=fopen("./draw.fnt","rb"); - } - - if(f==NULL) { - printf("Cannot open draw.fnt!\n"); - exit(1); - } else { - int i; - for(i=0;i<2048;i++) dr_fonttab[i]=getc(f); - fclose(f); - } -} - -/** - * Laedt die Palette - * @author Hj. Malthaner - */ -static int -load_palette(const char *fname, unsigned char *palette) -{ - FILE *file = fopen(fname,"rb"); - - if(file) { - - int x; - int anzahl=256; - int r,g,b; - - fscanf(file, "%d", &anzahl); - - for(x=0; x<anzahl; x++) { - fscanf(file,"%d %d %d", &r, &g, &b); - - palette[x*3+0] = r; - palette[x*3+1] = g; - palette[x*3+2] = b; - } - dr_setRGB8multi(0, anzahl, palette); - - fclose(file); - - return TRUE; - } else { - fprintf(stderr, "Error: can't open file '%s' for reading\n", fname); - return FALSE; - } -} - - -/** - * Dims (darkens) a color. - * @return darkended color. - * @author Hj. Malthaner - */ -static inline int darken(const int dunkel, const PIXVAL farbe) -{ - int r,g,b; - - r = (farbe & 0x7C00) - (dunkel << 10); - - if(r < 0) { - r = 0; - } - - g = (farbe & 0x03E0) - (dunkel << 5); - - if(g < 0) { - g = 0; - } - - b = (farbe & 0x001F) - dunkel; - - if(b < 0) { - b = 0; - } - - return (r & 0x7C00) + (g & 0x03E0) + b; -} - - -int display_get_width() -{ - return disp_width; -} - -int display_get_height() -{ - return disp_height; -} - - -/** - * returns the currently used tile size in pixels - * - * @author Hj. Malthaner - */ -int display_get_tile_size() -{ - return tile_size; -} - - -/** - * selects a tile size - * - * @param n 0 means 64x64 tiles, 1 are 32x32 tiles - * @author Hj. Malthaner - */ -void display_select_tile_size(int n) -{ - switch(n) { - case 0: - tile_size = 64; - images = images1; - break; - - case 1: - tile_size = 32; - images = images2; - break; - - default: - tile_size = 64; - images = images1; - } - - printf("Switching to tile size %d\n", tile_size); -} - - -/** - * Holt Helligkeitseinstellungen - * @author Hj. Malthaner - */ -int display_get_light() -{ - return light_level; -} - - -/** - * Setzt Helligkeitseinstellungen - * @author Hj. Malthaner - */ -void display_set_light(int new_light_level) -{ - unsigned char palette[256*3]; - const double ll = 1.0 - light_level/20.0; - int i; - - light_level = new_light_level; - - for(i=0; i<256; i++) { - const int n = i*3; - palette[n+0] = clip(pow(base_pal[n+0]/255.0, ll)*255.0, 0, 255); - palette[n+1] = clip(pow(base_pal[n+1]/255.0, ll)*255.0, 0, 255); - palette[n+2] = clip(pow(base_pal[n+2]/255.0, ll)*255.0, 0, 255); - } - - dr_setRGB8multi(0, 256, palette); -} - -/** - * Holt Farbeinstellungen - * @author Hj. Malthaner - */ -int display_get_color() -{ - return color_level; -} - - -/** - * Setzt Farbeinstellungen - * @author Hj. Malthaner - */ -void display_set_color(int new_color_level) -{ - color_level = new_color_level; - - if(color_level < 0) { - color_level = 0; - } - - if(color_level > 3) { - color_level = 3; - } - - switch(color_level) { - case 0: - load_palette("./simud70.pal", day_pal); - load_palette("./simun70.pal", night_pal); - break; - case 1: - load_palette("./simud80.pal", day_pal); - load_palette("./simun80.pal", night_pal); - break; - case 2: - load_palette("./simud90.pal", day_pal); - load_palette("./simun90.pal", night_pal); - break; - case 3: - load_palette("./simud100.pal", day_pal); - load_palette("./simun100.pal", night_pal); - break; - } - - memcpy(base_pal, day_pal, 256*3); - display_set_light(display_get_light()); -} - - -static int night_shift = -1; - -static void calc_base_pal_from_night_shift(const int night) -{ - const int day = 4 - night; - int i; - - for(i=0; i<256; i++) { - base_pal[i*3+0] = (day_pal[i*3+0] * day + night_pal[i*3+0] * night) >> 2; - base_pal[i*3+1] = (day_pal[i*3+1] * day + night_pal[i*3+1] * night) >> 2; - base_pal[i*3+2] = (day_pal[i*3+2] * day + night_pal[i*3+2] * night) >> 2; - } -} - - -void display_day_night_shift(int night) -{ - if(night != night_shift) { - night_shift = night; - - calc_base_pal_from_night_shift(night); - - display_set_light(light_level); - mark_rect_dirty_nc(0,0, disp_width-1, disp_height-1); - } -} - - - -/** - * Setzt Farbeintrag - * @author Hj. Malthaner - */ -void display_set_player_colors(const unsigned char *day, const unsigned char *night) -{ - memcpy(day_pal, day, 12); - memcpy(night_pal, night, 12); - - calc_base_pal_from_night_shift(night_shift); - - display_set_light(light_level); - mark_rect_dirty_nc(0,0, disp_width-1, disp_height-1); -} - - -/** - * Liest 32Bit wert Plattfromunabhängig - * @author Hj. Malthaner - */ -static int fread_int(FILE *f) -{ - int i = 0; - - i += fgetc(f); - i += fgetc(f) << 8; - i += fgetc(f) << 16; - i += fgetc(f) << 24; - - return i; -} - - -/** - * Laedt daten.pak - * @author Hj. Malthaner - */ -static struct imd * init_images(const char *filename) -{ - FILE *f = fopen(filename, "rb"); - struct imd * images = NULL; - - if( f ) { - int i; - - anz_images = fread_int(f); - images = malloc(sizeof(struct imd)*anz_images); - - - for(i=0; i<anz_images; i++) { - images[i].y = fread_int(f); - images[i].h = fread_int(f); - images[i].len = fread_int(f); - -// printf("len = %d\n", images[i].len); - - if(images[i].h > 0) { - images[i].data = malloc(images[i].len*sizeof(PIXVAL)); - fread(images[i].data, images[i].len*sizeof(PIXVAL), 1, f); - - } else { - images[i].data = NULL; - } - } - - fclose(f); - } else { - printf("Kann '%s' nicht lesen.\n", filename); - exit(1); - } - - return images; -} - -/** - * Holt Maus X-Position - * @author Hj. Malthaner - */ -int gib_maus_x() -{ - return mx; -} - -/** - * Holt Maus y-Position - * @author Hj. Malthaner - */ -int gib_maus_y() -{ - return my; -} - - -/** - * this sets width < 0 if the range is out of bounds - * so check the value after calling and before displaying - * @author Hj. Malthaner - */ -static int clip_wh(int *x, int *width, const int min_width, const int max_width) -{ - // doesnt check "wider than image" case - - if(*x < min_width) { - const int xoff = min_width - (*x); - - *width += *x; - *x = min_width; - return xoff; - } else if(*x + *width >= max_width) { - *width = max_width - *x; - } - return 0; -} - - -/** - * Ermittelt Clipping Rechteck - * @author Hj. Malthaner - */ -struct clip_dimension display_gib_clip_wh(void) -{ - return clip_rect; -} - - -/** - * Setzt Clipping Rechteck - * @author Hj. Malthaner - */ -void display_setze_clip_wh(int x, int y, int w, int h) -{ - clip_wh(&x, &w, 0, disp_width); - clip_wh(&y, &h, 0, disp_height); - - clip_rect.x = x; - clip_rect.y = y; - clip_rect.w = w; - clip_rect.h = h; - - clip_rect.xx = x+w-1; - clip_rect.yy = y+h-1; -} - -// ----------------- basic painting procedures ---------------- - - -/** - * Kopiert Pixel von src nach dest - * @author Hj. Malthaner - */ -static void pixcopy(PIXVAL *dest, - const PIXVAL *src, - int len) -{ - memcpy(dest, src, len*sizeof(PIXVAL)); -} - - -/** - * Zeichnet Bild mit Clipping - * @author Hj. Malthaner - */ -static void -display_img_wc(const int n, const int xp, const int yp, const int dirty) -{ - if(n >= 0 && n < anz_images) { - - int h = images[n].h; - int y = yp + images[n].y; - - int yoff = clip_wh(&y, &h, 0, clip_rect.yy); - - if(h > 0) { - const int width = disp_width; - const PIXVAL *sp = images[n].data; - PIXVAL *tp = textur + y*width; - - if(dirty) { - mark_rect_dirty_wc(xp, y, xp+tile_size-1, y+h+1); - } - - // oben clippen - - while(yoff) { - yoff --; - do { - if(*(++sp)) { - sp += *sp + 1; - } - } while(*sp); - sp ++; - } - - do { // zeilen dekodieren - int xpos = xp; - - // bild darstellen - - int runlen = *sp++; - - do { - // wir starten mit einem clear run - - xpos += runlen; - - // jetzt kommen farbige pixel - runlen = *sp++; - - if(runlen) { - - if(xpos >= 0 && runlen+xpos < width) { -// pixcopy(tp+xpos, sp, runlen); - memcpy(tp+xpos, sp, runlen*sizeof(PIXVAL)); - } else if(xpos < 0) { - if(runlen+xpos > 0) { -// pixcopy(tp, sp-xpos, runlen+xpos); - memcpy(tp, sp-xpos, (runlen+xpos)*sizeof(PIXVAL)); - } - } else if(width > xpos) { -// pixcopy(tp+xpos, sp, width-xpos); - memcpy(tp+xpos, sp, (width-xpos)*sizeof(PIXVAL)); - } - sp += runlen; - xpos += runlen; - runlen = *sp ++; - } - } while(runlen); - - tp += width; - - } while(--h > 0); - } - } -} - -/** - * Zeichnet Bild ohne Clipping - * @author Hj. Malthaner - */ -static void -display_img_nc(const int n, const int xp, const int yp, const int dirty) -{ - if(n >= 0 && n < anz_images) { - - int h = images[n].h; - - if(h > 0) { - const PIXVAL *sp = images[n].data; - PIXVAL *tp = textur + (yp + images[n].y)*disp_width + xp; - - if(dirty) { - mark_rect_dirty_nc(xp, yp+images[n].y, xp+tile_size-1, yp+images[n].y+h-1); - } - - do { // zeilen dekodieren - - // bild darstellen - - int runlen = *sp++; - - do { - - // wir starten mit einem clear run - tp += runlen; - - // jetzt kommen farbige pixel - runlen = *sp++; - - if(runlen) { -// pixcopy(tp, sp, runlen); - memcpy(tp, sp, runlen*sizeof(PIXVAL)); - sp += runlen; - tp += runlen; - runlen = *sp++; - } - } while(runlen); - - tp += (disp_width-tile_size); - - } while(--h); - } - } -} - -/** - * Zeichnet Bild - * @author Hj. Malthaner - */ -void -display_img(const int n, const int xp, const int yp, const int dirty) -{ - if(xp>=0 && yp>=0 && xp < disp_width-tile_size-1 && yp < disp_height-tile_size-1) { - display_img_nc(n, xp, yp, dirty); - } else { - if(xp>-tile_size && yp>-tile_size && xp < disp_width && yp < disp_height) { - display_img_wc(n, xp, yp, dirty); - } - } -} - - - -/** - * Copies and shades colors - * @param shade the amount to darken the color - * @author Hj. Malthaner - */ -static void colorpixcpy(PIXVAL *dest, const PIXVAL *src, - const PIXVAL * const end, - const PIXVAL shade) -{ - while(src < end) { - *dest++ = darken(shade, *src++); - } -} - - -/** - * Zeichnet Bild, ersetzt Spielerfarben - * @author Hj. Malthaner - */ -static void -display_color_img_aux(const int n, const int xp, const int yp, const int color, const int dirty) -{ - if(n >= 0 && n < anz_images) { - - int h = images[n].h; - int y = yp + images[n].y; - - int yoff = clip_wh(&y, &h, 0, clip_rect.yy); - - if(h > 0) { - const int width = disp_width; - const PIXVAL *sp = images[n].data; - PIXVAL *tp = textur + y*width; - -// printf("textur = %p tp = %p\n", textur, tp); - - if(dirty) { - mark_rect_dirty_wc(xp, y+yoff, xp+tile_size-1, y+yoff+h-1); - } - - // oben clippen - - while(yoff) { - yoff --; - do { - if(*(++sp)) { - sp += *sp + 1; - } - } while(*sp); - sp ++; - } - - do { // zeilen dekodieren - int xpos = xp; - - // bild darstellen - - do { - // wir starten mit einem clear run - - xpos += *sp ++; - - // jetzt kommen farbige pixel - - if(*sp) { - const int runlen = *sp++; - - if(xpos >= 0 && runlen+xpos < width) { - colorpixcpy(tp+xpos, sp, sp+runlen, color); - } else if(xpos < 0) { - if(runlen+xpos > 0) { - colorpixcpy(tp, sp-xpos, sp+runlen, color); - } - } else if(width > xpos) { - colorpixcpy(tp+xpos, sp, sp+width-xpos, color); - } - - sp += runlen; - xpos += runlen; - } - } while(*sp); - - tp += width; - sp ++; - - } while(--h); - } - } -} - - -/** - * Zeichnet Bild, ersetzt Farben - * @author Hj. Malthaner - */ -void -display_color_img(const int n, const int xp, const int yp, const int color, const int dirty) -{ - // since the colors for player 0 are already right, - // only use the expensive replacement routine for colored images - // of other players - - // printf("color=%d\n", color); - - if(color) { - display_color_img_aux(n, xp, yp, color, dirty); - } else { - display_img_wc(n, xp, yp, dirty); - } -} - -/** - * Zeichnet ein Pixel - * @author Hj. Malthaner - */ -void -display_pixel(int x, int y, const int color) -{ - if(x >= clip_rect.x && x<=clip_rect.xx && - y >= clip_rect.y && y<clip_rect.yy) { - - PIXVAL * const p = textur + x + y*disp_width; - *p = color; - - mark_tile_dirty(x >> DIRTY_TILE_SHIFT, y >> DIRTY_TILE_SHIFT); - } -} - - -/** - * Zeichnet einen Text, lowlevel Funktion - * @author Hj. Malthaner - */ -static void -dr_textur_text(PIXVAL *textur,int x,int y,const char *txt, - const int chars, const int fgpen, const int dirty) -{ - int p; - - y+=4; /* Korektu amiga <-> pc */ - - if(y < 0 || y+8 >= disp_height) - return; /* out of clip */ - - - if(dirty) { - mark_rect_dirty_nc(x, y, x+chars*8-1, y+8-1); - } - - - for(p=0; p<chars; p++) { /* Zeichen fuer Zeichen ausgeben */ - int base=((unsigned char *)txt)[p] << 3; /* 8 Byte je Zeichen */ - const int end = base+8; - int screen_pos = x + (p << 3) + y*disp_width; - - - do { - const int c=dr_fonttab[base++]; /* Eine Zeile des Zeichens */ - int b; - - for(b=0; b<8; b++) { - if(c & (128 >> b)) { - textur[screen_pos+b] = fgpen; - } - } - screen_pos += disp_width; - }while(base < end); - } -} - - -/** - * Zeichnet Text, highlevel Funktion - * @author Hj. Malthaner - */ -void -display_text(int x, int y, const char *txt, const int color, int dirty) -{ - const int chars = strlen(txt); - const int text_width = chars*8; - - if(y >= 8 && y < disp_height-12) { - - if(x >= 0 && x+text_width < disp_width) { - dr_textur_text(textur, x, y, txt, chars, color, dirty); - } else { - if(x < 0 && x+text_width > 8) { - const int left_chars = (-x+7)/8; - - dr_textur_text(textur, (x & 7), y, txt+left_chars, chars-left_chars, color, dirty); - } else if(x > 0 && x < disp_width-7) { - const int rest_chars = (disp_width-x-1) / 8; - - dr_textur_text(textur, x, y, txt, rest_chars, color, dirty); - } - } - } -} - -/** - * Zeichnet gefuelltes Rechteck, ohne clipping - * @author Hj. Malthaner - */ -void display_fb_internal(int xp, int yp, int w, int h, - const int color, const int dirty, - int cL, int cR, int cT, int cB) -{ - clip_wh(&xp, &w, cL, cR); - clip_wh(&yp, &h, cT, cB); - - if(w > 0 && h > 0) { - PIXVAL *p = textur + xp + yp*disp_width; - - if(dirty) { - mark_rect_dirty_nc(xp, yp, xp+w-1, yp+h-1); - } - - do { - memset(p, color, w*sizeof(PIXVAL)); - p += disp_width; - } while(--h); - } -} - -void -display_fillbox_wh(int xp, int yp, int w, int h, - const int color, const int dirty) -{ - display_fb_internal(xp,yp,w,h,color,dirty, - 0,disp_width-1,0,disp_height-1); -} -void -display_fillbox_wh_clip(int xp, int yp, int w, int h, - const int color, const int dirty) -{ - display_fb_internal(xp,yp,w,h,color,dirty, - clip_rect.x, clip_rect.xx, clip_rect.y, clip_rect.yy); -} - -/** - * Zeichnet vertikale Linie - * @author Hj. Malthaner - */ -void -display_vl_internal(const int xp, int yp, int h, const int color, int dirty, - int cL, int cR, int cT, int cB) -{ - clip_wh(&yp, &h, cT, cB); - - if(xp >= cL && xp <= cR && h > 0) { - PIXVAL *p = textur + xp + yp*disp_width; - - if (dirty) { - mark_rect_dirty_nc(xp, yp, xp, yp+h-1); - } - - do { - *p = color; - p += disp_width; - } while(--h); - } -} - -void -display_vline_wh(int xp, int yp, int h, const int color, const int dirty) -{ - display_vl_internal(xp,yp,h,color,dirty, - 0,disp_width-1,0,disp_height-1); -} - -void -display_vline_wh_clip(int xp, int yp, int h, const int color, const int dirty) -{ - display_vl_internal(xp,yp,h,color,dirty, - clip_rect.x, clip_rect.xx, clip_rect.y, clip_rect.yy); -} - -/** - * Zeichnet rohe Pixeldaten - * @author Hj. Malthaner - */ -void -display_array_wh(int xp, int yp, int w, int h, const unsigned char *arr) -{ - const int arr_w = w; - - clip_wh(&xp, &w, 0, disp_width); - clip_wh(&yp, &h, 0, disp_height); - - if(w > 0 && h > 0) { - PIXVAL *p = textur + xp + yp*disp_width; - - mark_rect_dirty_nc(xp, yp, xp+w-1, yp+h-1); - - if(xp == 0) { - arr += arr_w - w; - } - - do { - // FIXME!!! - memcpy(p, arr, w); - p += disp_width; - arr += arr_w; - } while(--h); - } -} - - -// --------------- compound painting procedures --------------- - - -/** - * Zeichnet schattiertes Rechteck - * @author Hj. Malthaner - */ -void -display_ddd_box(int x1, int y1, int w, int h, int tl_color, int rd_color) -{ - display_fillbox_wh(x1, y1, w, 1, tl_color, TRUE); - display_fillbox_wh(x1, y1+h-1, w, 1, rd_color, TRUE); - - h-=2; - - display_vline_wh(x1, y1+1, h, tl_color, TRUE); - display_vline_wh(x1+w-1, y1+1, h, rd_color, TRUE); -} - -/** - * Zeichnet schattierten Text - * @author Hj. Malthaner - */ -void -display_ddd_text(int xpos, int ypos, int hgt, - int ddd_farbe, int text_farbe, - const char *text, int dirty) -{ - const int len = strlen(text)*4; - - display_fillbox_wh(xpos-2-len, - ypos-hgt-6, - 4 + len*2, 1, - ddd_farbe+1, - dirty); - display_fillbox_wh(xpos-2-len, - ypos-hgt-5, - 4 + len*2, 8, - ddd_farbe, - dirty); - display_fillbox_wh(xpos-2-len, - ypos-hgt+3, - 4 + len*2, 1, - ddd_farbe-1, - dirty); - - display_text(xpos - len, - ypos-hgt-9, - text, - text_farbe, - dirty); -} - - -/** - * Zaehlt Vorkommen eines Buchstabens in einem String - * @author Hj. Malthaner - */ -int -count_char(const char *str, const char c) -{ - int count = 0; - - while(*str) { - count += (*str++ == c); - } - return count; -} - -/** - * Zeichnet einen mehrzeiligen Text - * @author Hj. Malthaner - */ -void -display_multiline_text(int x, int y, const char *inbuf, int color) -{ - char tmp[4096]; - char *buf = tmp; - char *next; - int y_off = 0; - - // be sure not to copy more than buffer size - strncpy(buf, inbuf, 4095); - - // always close with a 0 byte - buf[4095] = 0; - - while( (*buf != 0) && (next = strchr(buf,'\n')) ) { - *next = 0; - display_text(x,y+y_off, buf, color, TRUE); - buf = next+1; - y_off += LINESPACE; - } -} - - -/** - * Loescht den Bildschirm - * @author Hj. Malthaner - */ -void -display_clear() -{ - memset(textur+32*disp_width, 32, disp_width*(disp_height-17-32)); - - mark_rect_dirty_nc(0, 0, disp_width-1, disp_height-1); -} - - -#if 0 -void display_flush_buffer() -{ - int x, y; - char * tmp; - -#ifdef USE_SOFTPOINTER - display_img(softpointer, mx, my, TRUE); - old_my = my; -#endif - -#ifdef DEBUG - // just for debugging - int tile_count = 0; -#endif - - for(y=0; y<tile_lines; y++) { -#ifdef DEBUG - - for(x=0; x<tiles_per_line; x++) { - if(is_tile_dirty(x, y)) { - display_fillbox_wh(x << DIRTY_TILE_SHIFT, - y << DIRTY_TILE_SHIFT, - DIRTY_TILE_SIZE/4, - DIRTY_TILE_SIZE/4, - 3, - FALSE); - - - - dr_textur(x << DIRTY_TILE_SHIFT, - y << DIRTY_TILE_SHIFT, - DIRTY_TILE_SIZE, - DIRTY_TILE_SIZE); - - tile_count ++; - } else { - display_fillbox_wh(x << DIRTY_TILE_SHIFT, - y << DIRTY_TILE_SHIFT, - DIRTY_TILE_SIZE/4, - DIRTY_TILE_SIZE/4, - 0, - FALSE); - - - - dr_textur(x << DIRTY_TILE_SHIFT, - y << DIRTY_TILE_SHIFT, - DIRTY_TILE_SIZE, - DIRTY_TILE_SIZE); - - } - } -#else - x = 0; - - do { - if(is_tile_dirty(x, y)) { - const int xl = x; - do { - x++; - } while(x < tiles_per_line && is_tile_dirty(x, y)); - - dr_textur(xl << DIRTY_TILE_SHIFT, - y << DIRTY_TILE_SHIFT, - (x-xl)<<DIRTY_TILE_SHIFT, - DIRTY_TILE_SIZE); - - } - x++; - } while(x < tiles_per_line); -#endif - } - -#ifdef DEBUG -// printf("%d von %d tiles wurden gezeichnet\n", tile_count, tile_lines*tiles_per_line); -#endif - - dr_flush(); - - // swap tile buffers - tmp = tile_dirty_old; - tile_dirty_old = tile_dirty; - - tile_dirty = tmp; - memset(tile_dirty, 0, tile_lines*tiles_per_line); -} -#endif /* 0 */ - -void display_flush_buffer() -{ - dr_textur(0, 0, disp_width, disp_height); -} - -/** - * Bewegt Mauszeiger - * @author Hj. Malthaner - */ -void display_move_pointer(int dx, int dy) -{ - move_pointer(dx, dy); -} - - -/** - * Schaltet Mauszeiger sichtbar/unsichtbar - * @author Hj. Malthaner - */ -void display_show_pointer(int yesno) -{ -#ifdef USE_SOFTPOINTER - if(yesno) { - softpointer = 261; - } else { - softpointer = 52; - } -#else - show_pointer(yesno); -#endif -} - -/** - * unbenutzt ? - * @author Hj. Malthaner - */ -void -my_save_exit() -{ - dr_os_close(); -} - - -/** - * Inits. Grafikmodul - * @author Hj. Malthaner - */ -int -simgraph_init(int width, int height) -{ - int parameter[2]; - int ok; - - dr_os_init(0, parameter); - - ok = dr_os_open(width, height); - - if(ok) { - - disp_width = dr_get_width(); - disp_height = dr_get_height(); - - textur = dr_textur_init(); - - // not needed for iso-band - // init_font(".drawrc"); - - -// display_set_color(1); - - - images1 = init_images("daten.pak"); - - images2 = init_images("daten2.pak"); - - display_select_tile_size(0); - - printf("Init. done.\n"); - -// dr_use_color(rp, SCHWARZ); -// dr_fillbox_wh(rp, 0, 0, disp_width, WIN_disp_height); - - } else { - puts("Error : can't open window!"); - exit(-1); - } - - - // allocate dirty tile flags - tiles_per_line = (disp_width + DIRTY_TILE_SIZE - 1) / DIRTY_TILE_SIZE; - tile_lines = (disp_height + DIRTY_TILE_SIZE - 1) / DIRTY_TILE_SIZE; - - tile_dirty = malloc( tile_lines*tiles_per_line ); - tile_dirty_old = malloc( tile_lines*tiles_per_line ); - - memset(tile_dirty, 1, tile_lines*tiles_per_line); - memset(tile_dirty_old, 1, tile_lines*tiles_per_line); - - display_setze_clip_wh(0, 0, disp_width, disp_height); - - return TRUE; -} - -/** - * Prueft ob das Grafikmodul schon init. wurde - * @author Hj. Malthaner - */ -int is_display_init() -{ - return textur != NULL; -} - -/** - * Schliest das Grafikmodul - * @author Hj. Malthaner - */ -int -simgraph_exit() -{ - free(tile_dirty); - free(tile_dirty_old); - - - return dr_os_close(); -} - - -/** - * Laedt Einstellungen - * @author Hj. Malthaner - */ -void display_laden(FILE* file) -{ - int i,r,g,b; - - unsigned char day[12]; - unsigned char night[12]; - - fscanf(file, "%d %d %d\n", &light_level, &color_level, &night_shift); - - display_set_light(light_level); - display_set_color(color_level); - - for(i=0; i<4; i++) { - fscanf(file, "%d %d %d\n", &r, &g, &b); - day[i*3+0] = r; - day[i*3+1] = g; - day[i*3+2] = b; - - fscanf(file, "%d %d %d\n", &r, &g, &b); - night[i*3+0] = r; - night[i*3+1] = g; - night[i*3+2] = b; - } - - display_set_player_colors(day, night); -} - - -/** - * Speichert Einstellungen - * @author Hj. Malthaner - */ -void display_speichern(FILE* file) -{ - int i; - fprintf(file, "%d %d %d\n", light_level, color_level, night_shift); - - for(i=0; i<4; i++) { - fprintf(file, "%d %d %d\n", day_pal[i*3+0], day_pal[i*3+1], day_pal[i*3+2]); - fprintf(file, "%d %d %d\n", night_pal[i*3+0], night_pal[i*3+1], night_pal[i*3+2]); - } -} - diff --git a/src/iso/simgraph.h b/src/iso/simgraph.h deleted file mode 100644 index 938edb95..00000000 --- a/src/iso/simgraph.h +++ /dev/null @@ -1,159 +0,0 @@ -/* simgraph.h - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph graphics engine. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* simgraph.h - * - * Versuch einer Graphic fuer Simulationsspiele - * Hj. Malthaner, Aug. 1997 - * - * - * 3D, isometrische Darstellung - * - */ - -#ifndef simgraph_h -#define simgraph_h - -#ifdef __cplusplus -extern "C" { -#endif - - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#define LINESPACE 11 - - -struct clip_dimension { - int x, xx, w, y, yy, h; -}; - - -// helper macros - -// save the current clipping and set a new one -#define PUSH_CLIP(x,y,w,h) \ -{\ -const struct clip_dimension p_cr = display_gib_clip_wh(); \ -display_setze_clip_wh(x, y, w, h); - -// restore a saved clipping rect -#define POP_CLIP() \ -display_setze_clip_wh(p_cr.x, p_cr.y, p_cr.w, p_cr.h); \ -} - - -// function prototypes - -int simgraph_init(int width, int height); -int is_display_init(); -int simgraph_exit(); - -int gib_maus_x(); -int gib_maus_y(); - -void mark_rect_dirty_wc(int x1, int y1, int x2, int y2); - - -/** - * returns the currently used tile size in pixels - * - * @author Hj. Malthaner - */ -int display_get_tile_size(); - - -/** - * selects a tile size - * - * @param n 0 means 64x64 tiles, 1 are 32x32 tiles - * @author Hj. Malthaner - */ -void display_select_tile_size(int n); - - - -int display_get_width(); -int display_get_height(); - - -int display_get_light(); -void display_set_light(int new_light_level); - -int display_get_color(); -void display_set_color(int new_color_level); - -void display_day_night_shift(int night); - -//void display_set_rgb(int n, int r, int g, int b); -void display_set_player_colors(const unsigned char *day, const unsigned char *night); - -void display_img(const int n, const int xp, const int yp, const int dirty); -void display_color_img(const int n, const int xp, const int yp, const int color, const int dirty); -void display_fillbox_wh(int xp, int yp, int w, int h, int color, int dirty); -void display_fillbox_wh_clip(int xp, int yp, int w, int h, int color, int d); -void display_vline_wh(const int xp, int yp, int h, const int color, int dirty); -void display_vline_wh_clip(const int xp, int yp, int h, const int c, int d); -void display_clear(); - -void display_flush_buffer(); - -void display_move_pointer(int dx, int dy); -void display_show_pointer(int yesno); - - -void display_pixel(int x, int y, int color); - -void display_ddd_text(int xpos, int ypos, int hgt, - int ddd_farbe, int text_farbe, - const char *text, int dirty); - -void display_text(int x, int y, const char *txt, const int color, int dirty); -void display_array_wh(int xp, int yp, int w, int h, const unsigned char *arr); -void display_ddd_box(int x1, int y1, int w, int h, int tl_color, int rd_color); - -// compound painting routines - -int count_char(const char *str, const char c); -void display_multiline_text(int x, int y, const char *inbuf, int color); - -void zeige_banner(void); - -void display_setze_clip_wh(int x, int y, int w, int h); -struct clip_dimension display_gib_clip_wh(void); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/iso/simsys.h b/src/iso/simsys.h deleted file mode 100644 index c4b7dd6c..00000000 --- a/src/iso/simsys.h +++ /dev/null @@ -1,197 +0,0 @@ -/* simsys.h - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph graphics engine. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef simsys_h -#define simsys_h - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - - -/* Variablen zur Messageverarbeitung */ - -/* Klassen */ - -#define SIM_NOEVENT 0 -#define SIM_MOUSE_BUTTONS 1 -#define SIM_KEYBOARD 2 -#define SIM_MOUSE_MOVE 3 -#define SIM_IGNORE_EVENT 255 - -/* Aktionen */ /* added RIGHTUP and MIDUP */ -#define SIM_MOUSE_LEFTUP 1 -#define SIM_MOUSE_RIGHTUP 2 -#define SIM_MOUSE_MIDUP 3 -#define SIM_MOUSE_LEFTBUTTON 4 -#define SIM_MOUSE_RIGHTBUTTON 5 -#define SIM_MOUSE_MIDBUTTON 6 -#define SIM_MOUSE_MOVED 7 - - -/** - * inits operating system stuff - * @author Hj. Malthaner - */ -int dr_os_init(int n, int *parameter); - - -/** - * opens graphics device/context/window of size w*h - * @param w width - * @param h height - * @author Hj. Malthaner - */ -int dr_os_open(int w, int h); - - -/** - * closes operating system stuff - * @author Hj. Malthaner - */ -int dr_os_close(); - - -/** - * retrieve display width - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_get_width(); - - -/** - * retrieve display height - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_get_height(); - - -/** - * creates a (maybe virtual) array of graphics data - * @author Hj. Malthaner - */ -unsigned short * dr_textur_init(); - - -/** - * displays the array of graphics data - * @author Hj. Malthaner - */ -void dr_textur(int xp, int yp, int w, int h); - - -/** - * use this method to flush graphics pipeline (undrawn stuff) onscreen. - * @author Hj. Malthaner - */ -void dr_flush(); - - -/** - * set colormap entries - * @author Hj. Malthaner - */ -void dr_setRGB8multi(int first, int count, unsigned char * data); - - -/** - * display/hide mouse pointer - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void show_pointer(int yesno); - - -/** - * move mouse pointer - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void move_pointer(int x, int y); - - -/** - * update softpointer position - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void ex_ord_update_mx_my(); - - -/** - * get events from the system - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void GetEvents(); - - -/** - * get events from the system without waiting - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void GetEventsNoWait(); - - -/** - * @returns time since progrma start in milliseconds - * @author Hj. Malthaner - */ -long long dr_time(void); - - -/** - * sleeps some microseconds - * @author Hj. Malthaner - */ -void dr_sleep(unsigned long usec); - - -/** - * loads a sample - * @return a handle for that sample or -1 on failure - * @author Hj. Malthaner - */ -int dr_load_sample(const char *filename); - - -/** - * plays a sample - * @param key the key for the sample to be played - * @author Hj. Malthaner - */ -void dr_play_sample(int key, int volume); - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/src/iso/simview.c b/src/iso/simview.c deleted file mode 100644 index 4e972841..00000000 --- a/src/iso/simview.c +++ /dev/null @@ -1,87 +0,0 @@ -/* simview.c - * - * Copyright (c) 2001,2002 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#include "simview.h" -#include "world_view.h" -#include "world_adaptor.h" -#include "simgraph.h" - - -/** - * Draws the full iso-view display - * @author Hj. Malthaner - */ -void display() -{ - const int IMG_SIZE = display_get_tile_size(); - - const int const_x_off = display_get_width()/2 + get_x_off(); - const int dpy_width = display_get_width()/IMG_SIZE + 2; - const int dpy_height = (display_get_height()*4)/IMG_SIZE; - - - const int i_off = get_i_off(); - const int j_off = get_j_off(); - - int x,y; - -// puts("displaying"); - - - // Hajo: draw grounds first - - for(y=-5; y<dpy_height+10; y++) { - const int ypos = y*IMG_SIZE/4+16 + get_y_off(); - - for(x=-dpy_width + (y & 1); x<=dpy_width+2; x+=2) { - - const int i = ((y+x) >> 1) + i_off; - const int j = ((y-x) >> 1) + j_off; - const int xpos = x*IMG_SIZE/2 + const_x_off; - - display_boden(i, j, xpos, ypos); - } - } - - // Hajo: then draw the objects - - for(y=-5; y<dpy_height+10; y++) { - const int ypos = y*IMG_SIZE/4+16 + get_y_off(); - - for(x=-dpy_width + (y & 1); x<=dpy_width+2; x+=2) { - - const int i = ((y+x) >> 1) + i_off; - const int j = ((y-x) >> 1) + j_off; - const int xpos = x*IMG_SIZE/2 + const_x_off; - - - display_dinge(i, j, xpos, ypos); - } - } -} - diff --git a/src/iso/simview.h b/src/iso/simview.h deleted file mode 100644 index a1cac864..00000000 --- a/src/iso/simview.h +++ /dev/null @@ -1,41 +0,0 @@ -/* simview.h - * - * Copyright (c) 2001, 2002 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph graphics engine. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef simview_h -#define simview_h - - -/** - * Draws the full iso-view display - * @author Hj. Malthaner - */ -void display(); - - -#endif diff --git a/src/iso/walls4.h b/src/iso/walls4.h deleted file mode 100644 index 5f57d09e..00000000 --- a/src/iso/walls4.h +++ /dev/null @@ -1,288 +0,0 @@ -/* walls4.h - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph<->Angband adaption code. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -int wall_table[256] = -{ -0, // 0 -0, // 1 -2, // 2 -0, // 3 -0, // 4 -0, // 5 -0, // 6 -0, // 7 -1, // 8 -0, // 9 -3, // 10 -3, // 11 -0, // 12 -0, // 13 -3, // 14 -3, // 15 -4, // 16 -0, // 17 -6, // 18 -6, // 19 -0, // 20 -0, // 21 -6, // 22 -0, // 23 -5, // 24 -5, // 25 -7, // 26 -0, // 27 -5, // 28 -0, // 29 -7, // 30 -5, // 31 -0, // 32 -0, // 33 -0, // 34 -0, // 35 -0, // 36 -0, // 37 -0, // 38 -0, // 39 -0, // 40 -0, // 41 -0, // 42 -0, // 43 -0, // 44 -0, // 45 -0, // 46 -0, // 47 -0, // 48 -0, // 49 -0, // 50 -0, // 51 -0, // 52 -0, // 53 -0, // 54 -0, // 55 -5, // 56 -5, // 57 -0, // 58 -0, // 59 -5, // 60 -0, // 61 -0, // 62 -0, // 63 -8, // 64 -0, // 65 -10, // 66 -10, // 67 -0, // 68 -0, // 69 -10, // 70 -10, // 71 -9, // 72 -9, // 73 -0, // 74 -10, // 75 -0, // 76 -0, // 77 -0, // 78 -0, // 79 -12, // 80 -0, // 81 -0, // 82 -0, // 83 -0, // 84 -0, // 85 -10, // 86 -0, // 87 -13, // 88 -0, // 89 -0, // 90 -0, // 91 -13, // 92 -0, // 93 -0, // 94 -0, // 95 -0, // 96 -0, // 97 -10, // 98 -0, // 99 -0, // 100 -0, // 101 -10, // 102 -0, // 103 -9, // 104 -0, // 105 -10, // 106 -10, // 107 -0, // 108 -0, // 109 -0, // 110 -10, // 111 -12, // 112 -0, // 113 -0, // 114 -0, // 115 -0, // 116 -0, // 117 -0, // 118 -0, // 119 -0, // 120 -12, // 121 -0, // 122 -0, // 123 -0, // 124 -0, // 125 -0, // 126 -0, // 127 -0, // 128 -0, // 129 -0, // 130 -0, // 131 -0, // 132 -0, // 133 -0, // 134 -0, // 135 -0, // 136 -0, // 137 -0, // 138 -0, // 139 -0, // 140 -0, // 141 -0, // 142 -0, // 143 -0, // 144 -0, // 145 -0, // 146 -6, // 147 -0, // 148 -0, // 149 -0, // 150 -0, // 151 -5, // 152 -5, // 153 -0, // 154 -0, // 155 -5, // 156 -0, // 157 -0, // 158 -0, // 159 -0, // 160 -0, // 161 -0, // 162 -0, // 163 -0, // 164 -0, // 165 -0, // 166 -0, // 167 -0, // 168 -0, // 169 -0, // 170 -0, // 171 -0, // 172 -0, // 173 -0, // 174 -0, // 175 -0, // 176 -0, // 177 -0, // 178 -0, // 179 -0, // 180 -0, // 181 -0, // 182 -0, // 183 -5, // 184 -0, // 185 -7, // 186 -0, // 187 -0, // 188 -0, // 189 -0, // 190 -0, // 191 -0, // 192 -0, // 193 -10, // 194 -10, // 195 -0, // 196 -0, // 197 -0, // 198 -0, // 199 -9, // 200 -0, // 201 -0, // 202 -0, // 203 -0, // 204 -0, // 205 -0, // 206 -0, // 207 -12, // 208 -0, // 209 -10, // 210 -0, // 211 -0, // 212 -0, // 213 -10, // 214 -10, // 215 -0, // 216 -0, // 217 -0, // 218 -0, // 219 -0, // 220 -0, // 221 -0, // 222 -0, // 223 -0, // 224 -0, // 225 -10, // 226 -0, // 227 -0, // 228 -0, // 229 -0, // 230 -0, // 231 -0, // 232 -0, // 233 -0, // 234 -10, // 235 -0, // 236 -0, // 237 -0, // 238 -0, // 239 -0, // 240 -0, // 241 -14, // 242 -0, // 243 -0, // 244 -0, // 245 -10, // 246 -0, // 247 -5, // 248 -0, // 249 -0, // 250 -0, // 251 -0, // 252 -0, // 253 -0, // 254 -0, // 255 -}; diff --git a/src/iso/walls9.h b/src/iso/walls9.h deleted file mode 100644 index 038dadf1..00000000 --- a/src/iso/walls9.h +++ /dev/null @@ -1,288 +0,0 @@ -/* walls9.h - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph<->Angband adaption code. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -int wall_table[256] = -{ -0, // 0 -1, // 1 -2, // 2 -3, // 3 -4, // 4 -5, // 5 -2, // 6 -7, // 7 -8, // 8 -8, // 9 -10, // 10 -11, // 11 -12, // 12 -13, // 13 -10, // 14 -11, // 15 -16, // 16 -17, // 17 -18, // 18 -18, // 19 -16, // 20 -21, // 21 -22, // 22 -22, // 23 -24, // 24 -24, // 25 -26, // 26 -27, // 27 -24, // 28 -24, // 29 -30, // 30 -31, // 31 -32, // 32 -33, // 33 -34, // 34 -35, // 35 -36, // 36 -37, // 37 -38, // 38 -39, // 39 -40, // 40 -41, // 41 -10, // 42 -43, // 43 -44, // 44 -45, // 45 -46, // 46 -47, // 47 -48, // 48 -49, // 49 -50, // 50 -51, // 51 -52, // 52 -53, // 53 -54, // 54 -55, // 55 -24, // 56 -24, // 57 -58, // 58 -27, // 59 -24, // 60 -61, // 61 -62, // 62 -31, // 63 -64, // 64 -65, // 65 -66, // 66 -66, // 67 -68, // 68 -69, // 69 -66, // 70 -66, // 71 -72, // 72 -72, // 73 -74, // 74 -75, // 75 -76, // 76 -77, // 77 -74, // 78 -75, // 79 -80, // 80 -81, // 81 -82, // 82 -82, // 83 -80, // 84 -85, // 85 -86, // 86 -86, // 87 -88, // 88 -88, // 89 -90, // 90 -91, // 91 -88, // 92 -93, // 93 -94, // 94 -95, // 95 -64, // 96 -97, // 97 -66, // 98 -66, // 99 -100, // 100 -101, // 101 -66, // 102 -103, // 103 -104, // 104 -105, // 105 -106, // 106 -107, // 107 -108, // 108 -109, // 109 -106, // 110 -107, // 111 -80, // 112 -113, // 113 -82, // 114 -115, // 115 -116, // 116 -117, // 117 -118, // 118 -119, // 119 -120, // 120 -121, // 121 -122, // 122 -123, // 123 -124, // 124 -125, // 125 -126, // 126 -127, // 127 -128, // 128 -129, // 129 -130, // 130 -131, // 131 -132, // 132 -133, // 133 -134, // 134 -135, // 135 -136, // 136 -137, // 137 -138, // 138 -139, // 139 -140, // 140 -141, // 141 -142, // 142 -143, // 143 -16, // 144 -145, // 145 -18, // 146 -147, // 147 -148, // 148 -149, // 149 -22, // 150 -22, // 151 -24, // 152 -24, // 153 -154, // 154 -155, // 155 -24, // 156 -157, // 157 -158, // 158 -31, // 159 -160, // 160 -161, // 161 -66, // 162 -163, // 163 -164, // 164 -165, // 165 -166, // 166 -167, // 167 -168, // 168 -169, // 169 -170, // 170 -171, // 171 -172, // 172 -173, // 173 -174, // 174 -175, // 175 -176, // 176 -177, // 177 -178, // 178 -179, // 179 -180, // 180 -181, // 181 -182, // 182 -183, // 183 -24, // 184 -185, // 185 -26, // 186 -187, // 187 -24, // 188 -189, // 189 -190, // 190 -31, // 191 -64, // 192 -193, // 193 -66, // 194 -66, // 195 -196, // 196 -197, // 197 -66, // 198 -66, // 199 -72, // 200 -201, // 201 -74, // 202 -203, // 203 -204, // 204 -205, // 205 -206, // 206 -207, // 207 -208, // 208 -209, // 209 -210, // 210 -211, // 211 -208, // 212 -213, // 213 -214, // 214 -214, // 215 -216, // 216 -217, // 217 -218, // 218 -219, // 219 -220, // 220 -221, // 221 -222, // 222 -223, // 223 -224, // 224 -225, // 225 -66, // 226 -227, // 227 -228, // 228 -229, // 229 -230, // 230 -231, // 231 -104, // 232 -233, // 233 -234, // 234 -107, // 235 -236, // 236 -237, // 237 -238, // 238 -239, // 239 -208, // 240 -241, // 241 -210, // 242 -243, // 243 -244, // 244 -245, // 245 -214, // 246 -214, // 247 -248, // 248 -248, // 249 -250, // 250 -251, // 251 -248, // 252 -248, // 253 -254, // 254 -255, // 255 -}; diff --git a/src/iso/world_adaptor.c b/src/iso/world_adaptor.c deleted file mode 100644 index a483780f..00000000 --- a/src/iso/world_adaptor.c +++ /dev/null @@ -1,226 +0,0 @@ -/* world_adaptor.cc - * - * Copyright (c) 2001, 2002 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph<->Angband adaption code. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -/* world_adaptor.c - * - * adaption between angband world and simugraph data model - * Hj. Maltahner, Jan. 2001 - */ - -#include "hackdef.h" - -#include "world_adaptor.h" -#include "world_view.h" -#include "simview.h" -#include "simgraph.h" - -#undef MIN -#undef MAX - -#include "../angband.h" - - -/* - * Highlit location - */ -int high_x = -1; -int high_y = -1; - -/** - * remember targetted location - * (hook is ToME3 only, for now) - * @author J. Frieling - */ -bool iso_target_hook(char* fmt) -{ - high_y = get_next_arg(fmt); - high_x = get_next_arg(fmt); - - return FALSE; -} - -/** - * Highlite (mark) location x,y - * @author Hj. Malthaner - */ -void highlite_spot(int x, int y) -{ - high_x = x; - high_y = y; -} - - -/** - * Grid type, default is grid for items and monsters - * 0: No grid - * 1: Item/monster grid - * 2: Full grid - * @author Hj. Malthaner - */ -static int grid = 1; - - -/** - * Show shadow below items and monsters? - * 0 = no - * 1 = yes - * @author Hj. Malthaner - */ -//int shadow = 1; - - -/** - * Set a grid type (takes argument modulo 3) - * @author Hj. Malthaner - */ -void set_grid(int no) -{ - grid = no % 3; -} - - -/** - * Show which grid type ? - * @author Hj. Malthaner - */ -int get_grid() -{ - return grid; -} - - -/** - * Turn shadows on/off (0=off, 1=on) - * @author Hj. Malthaner - */ -/*void set_shadow(int yesno) -{ - shadow = yesno; -} -*/ - - -/** - * Determines i-offset of the watch point - * @author Hj. Malthaner - */ -int get_i_off() -{ - const int p_off = display_get_width() >> 7; - const int mult = display_get_tile_size() == 32 ? 2 : 1; - -#ifdef USE_SMALL_ISO_HACK - - int i_off; - - if(p_ptr) { - i_off = p_ptr->px-p_off*mult; - } - - return i_off; -#else - - return 47-p_off; - - -#endif -} - - -/** - * Determines j-offset of the watch point - * @author Hj. Malthaner - */ -int get_j_off() -{ - const int p_off = display_get_width() >> 7; - const int mult = display_get_tile_size() == 32 ? 2 : 1; - -#ifdef USE_SMALL_ISO_HACK - - int j_off; - if(p_ptr) { - j_off = p_ptr->py-p_off*mult; - } - - return j_off; -#else - - return 10-p_off; - -#endif -} - - - -/** - * Ermittelt x-Offset gescrollter Karte - * @author Hj. Malthaner - */ -int get_x_off() -{ - return 0; -} - - -/** - * Ermittelt y-Offset gescrollter Karte - * @author Hj. Malthaner - */ -int get_y_off() -{ - return 0; -} - - - -int init_adaptor() -{ - printf("Preparing display ...\n"); - simgraph_init(672, 480); - - return TRUE; -} - - -int refresh_display() -{ - display(); - display_flush_buffer(); - - return TRUE; -} - - -int close_adaptor() -{ - simgraph_exit(); - - return TRUE; -} diff --git a/src/iso/world_adaptor.h b/src/iso/world_adaptor.h deleted file mode 100644 index d5b5b63e..00000000 --- a/src/iso/world_adaptor.h +++ /dev/null @@ -1,117 +0,0 @@ -/* world_adaptor.h - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph<->Angband adaption code. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - - -#ifndef hajo_world_adaptor_h -#define hajo_world_adaptor_h - -/* world_adapter.h - * - * adpater between angband code and simugraph engine - * Hj. Malthaner, Jan 2001 - */ - -// I need angband's bool -#include "../h-type.h" - -/* - * Highlit location - use read only! - */ -extern int high_x; -extern int high_y; - -int init_adaptor(); -int close_adaptor(); - -int refresh_display(); - -/** - * remember targetted location - * @author J. Frieling - */ -bool iso_target_hook(char *fmt); - -/** - * Highlite (mark) location x,y - * @author Hj. Malthaner - */ -void highlite_spot(int x, int y); - -/** - * Set a grid type (takes argument modulo 3) - * @author Hj. Malthaner - */ -void set_grid(int no); - - -/** - * Show which grid type ? - * @author Hj. Malthaner - */ -int get_grid(); - - -/** - * Turn shadows on/off (0=off, 1=on) - * @author Hj. Malthaner - */ -//void set_shadow(int yesno); - - - -/** - * Ermittelt x-Offset gescrollter Karte - * @author Hj. Malthaner - */ -int get_x_off(); - - -/** - * Ermittelt y-Offset gescrollter Karte - * @author Hj. Malthaner - */ -int get_y_off(); - - -/** - * Determines i-offset of the watch point - * @author Hj. Malthaner - */ -int get_i_off(); - - -/** - * Determines j-offset of the watch point - * @author Hj. Malthaner - */ -int get_j_off(); - - -#endif - diff --git a/src/iso/world_view.c b/src/iso/world_view.c deleted file mode 100644 index 0a4b47fe..00000000 --- a/src/iso/world_view.c +++ /dev/null @@ -1,499 +0,0 @@ -/* world_view.c
- *
- * Copyright (c) 2001, 2002 Hansjörg Malthaner
- * hansjoerg.malthaner@gmx.de
- *
- * This file is part of the Simugraph<->Angband adaption code.
- *
- *
- * This file may be copied and modified freely so long as the above credits,
- * this paragraph, and the below disclaimer of warranty are retained; no
- * financial profit is derived from said modification or copying; and all
- * licensing rights to any modifications are granted to the original author,
- * Hansjörg Malthaner.
- *
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
- * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
- * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
- * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#include <stdio.h>
-#include "simgraph.h"
-#include "world_view.h"
-#include "world_adaptor.h"
-
-//#include "walls4.h"
-#include "walls9.h"
-
-#include "hackdef.h"
-
-
-#undef MIN
-#undef MAX
-
-
-#include "../angband.h"
-#include "../defines.h"
-
-
-/* from isov-x11.c */
-extern unsigned char **iso_ap;
-extern unsigned char **iso_cp;
-extern unsigned char **iso_atp;
-extern unsigned char **iso_ctp;
-# ifdef USE_EGO_GRAPHICS
-extern unsigned char **iso_aep;
-extern unsigned char **iso_cep;
-# endif /* USE_EGO_GRAPHICS */
-
-
-#ifdef USE_SMALL_ISO_HACK
-
-static bool is_valid_position(int x, int y) {
- return x >= 0 && y >= 0 && x<cur_wid && y<cur_hgt;
-}
-
-static bool is_valid_to_show(int x, int y) {
- return is_valid_position(x, y);
-}
-
-static int get_feat_nc(int x, int y)
-{
- /* this is for Angabdn 2.9.1
- return cave_feat[y][x];
- */
-
- /* Pernangband 4.1.5 */
- cave_type *c_ptr;
-
- /* Get the cave */
- c_ptr = &cave[y][x];
-
-
- /* Feature code */
- return c_ptr->feat;
-}
-
-
-static int get_feat_wc(int x, int y)
-{
- if(is_valid_position(x,y)) {
- return get_feat_nc(x,y);
- } else {
- return FEAT_PERM_SOLID;
- }
-}
-
-
-static int get_info_nc(int x, int y)
-{
- /* this is for Angabdn 2.9.1
- return cave_info[y][x];
- */
-
- /* Pernangband 4.1.5 */
- cave_type *c_ptr;
-
- /* Get the cave */
- c_ptr = &cave[y][x];
-
-
- /* Info code */
- return c_ptr->info;
-}
-
-
-static int get_info_wc(int x, int y)
-{
- if(is_valid_position(x,y)) {
- return get_info_nc(x,y);
- } else {
- return 0;
- }
-}
-
-
-static bool is_door(int feat)
-{
- return
- (feat == FEAT_OPEN) ||
- (feat == FEAT_BROKEN) ||
- (feat == FEAT_SECRET) ||
- (feat >= FEAT_DOOR_HEAD && feat <= FEAT_DOOR_TAIL) ||
- (feat == FEAT_SHOP);
-}
-
-
-static bool is_wall(int feat)
-{
- return
- (feat >= FEAT_MAGMA && feat <= FEAT_PERM_SOLID) ||
- (feat >= FEAT_TREES && feat <= FEAT_SANDWALL_K) ||
- (feat >= FEAT_QUEST1 && feat <= FEAT_QUEST4);
-}
-
-
-static int is_wall_or_door(int x, int y)
-{
- const int feat = get_feat_wc(x, y);
-
- return is_door(feat) || is_wall(feat);
-}
-
-
-static bool is_lit(int x, int y)
-{
- const int info = get_info_wc(x, y);
-
- return (info & CAVE_GLOW) && (info & CAVE_VIEW) && (info & CAVE_MARK);
-}
-
-
-static bool is_torch_lit(int x, int y)
-{
- const int info = get_info_wc(x, y);
-
- return (info & CAVE_PLIT) && (info & CAVE_VIEW) && (info & CAVE_MARK);
-}
-
-
-static bool is_only_torch_lit(int x, int y)
-{
- return is_torch_lit(x, y) & !is_lit(x, y);
-}
-
-
-static bool is_blind()
-{
- // PernAngband variant
- return p_ptr->blind;
-}
-
-
-/**
- * Calculates distance from player to point (x,y).
- * Uses the distance guess from cave.c
- * @author Hj. Malthaner
- */
-static int get_distance_to_player(int x, int y)
-{
- return distance(y, x, p_ptr->py, p_ptr->px);
-}
-
-#else
-
-
-static int iso_access(unsigned char **field, int x, int y)
-{
- if(x >= 0 && y >= 0 && x<80 && y<24) {
- return field[y][x] & 0x7f;
- } else {
- return 0;
- }
-}
-
-static int is_wall_or_door(int x, int y)
-{
- const int atp = iso_access(iso_atp, x, y);
- const int ctp = iso_access(iso_ctp, x, y);
-
- return (atp == 0x01 && (ctp >= 0x70 && ctp <= 0x75)) ||
- (atp == 0x00 && (ctp =='+' || ctp == '\'')) ;
-}
-
-#endif
-
-
-/**
- * Draw ground of location i,j onto screen position xpos,ypos
- * @author Hj. Malthaner
- */
-void display_boden(int x, int y, int xpos, int ypos)
-{
- // unused in Iso-Angband
-}
-
-
-static int check_wall(int x, int y)
-{
-
- int o = 0;
-
-#if 0
- o |= (is_wall_or_door(x-1, y-1)) << 0;
- o |= (is_wall_or_door(x , y-1)) << 1;
- o |= (is_wall_or_door(x+1, y-1)) << 2;
- o |= (is_wall_or_door(x-1, y )) << 3;
- o |= (is_wall_or_door(x+1, y )) << 4;
- o |= (is_wall_or_door(x-1, y+1)) << 5;
- o |= (is_wall_or_door(x , y+1)) << 6;
- o |= (is_wall_or_door(x+1, y+1)) << 7;
-
-
- return wall_table[o];
-#endif
- // jue: new algorithm as suggested by James Andrewartha
- //
- o |= (is_wall_or_door(x-1, y-1)
- && is_wall_or_door(x, y-1)
- && is_wall_or_door(x-1,y)) << 0;
-
- o |= (is_wall_or_door(x , y-1)) << 1;
-
- o |= (is_wall_or_door(x+1, y-1)
- && is_wall_or_door(x, y-1)
- && is_wall_or_door(x+1, y)) << 2;
-
- o |= (is_wall_or_door(x-1, y )) << 3;
-
- o |= (is_wall_or_door(x+1, y )) << 4;
-
- o |= (is_wall_or_door(x-1, y+1)
- && is_wall_or_door(x-1, y)
- && is_wall_or_door(x, y+1)) << 5;
-
- o |= (is_wall_or_door(x , y+1)) << 6;
-
- o |= (is_wall_or_door(x+1, y+1)
- && is_wall_or_door(x+1, y)
- && is_wall_or_door(x, y+1)) << 7;
-
- return o;
-}
-
-
-static int door_direction(int x, int y)
-{
- if(is_wall_or_door(x-1, y) && is_wall_or_door(x+1, y)) {
- return 1;
- } else {
- return 0;
- }
-}
-
-static int calc_nc(int c, int a)
-{
- return ((a & 0x7F) << 7) + (c & 0x7F);
-}
-
-
-/**
- * Draw objects of location i,j onto screen position xpos,ypos
- * @author Hj. Malthaner
- */
-void display_dinge(int x, int y, int xpos, int ypos)
-{
- const int grid = get_grid();
-
- int feat_nc = -1;
- int obj_nc = -1;
-#ifdef USE_EGO_GRAPHICS
- int ego_nc = -1;
-#endif
-
- int shade;
- int i;
-
- // relative to view position
-// int xoff = x - p_ptr->px + (SCREEN_WID/2 + 13);
-// int xoff = x - p_ptr->px + (SCREEN_WID/2 + 13);
-//
-// new (jue):
-// look at cave.c, panel_col_of and the places it's used...
- int xoff = x - panel_col_min + COL_MAP;
- int yoff = y - panel_row_prt;
-
- // try to use output of the term package
- if(xoff >= 0 && yoff >= 1 && xoff < 80 && yoff < 23) {
- // floor, walls
-
- const int c = iso_cp[yoff][xoff];
- const int a = iso_ap[yoff][xoff];
-
- // object/monster
- const int tc = iso_ctp[yoff][xoff];
- const int ta = iso_atp[yoff][xoff];
-
-#ifdef USE_EGO_GRAPHICS
- // transparent overlay
- const int ec = iso_cep[yoff][xoff];
- const int ea = iso_aep[yoff][xoff];
-
- ego_nc = calc_nc(ec, ea);
-#endif
- feat_nc = calc_nc(tc, ta);
- obj_nc = calc_nc(c, a);
-
- } else {
- // outside 80x24 view, try to read map
-
- if(is_valid_to_show(x,y)) {
-
- byte a, ta;
- char c, tc;
-#ifdef USE_EGO_GRAPHICS
- byte ea;
- char ec;
-
- map_info(y, x, &a, &c, &ta, &tc, &ea, &ec);
- ego_nc = calc_nc(ec, ea);
-#else
- map_info(y, x, &a, &c, &ta, &tc);
-#endif
- feat_nc = calc_nc(tc, ta);
- obj_nc = calc_nc(c, a);
- }
-
- }
-
-
-
- shade = 1;
-
- if(is_lit(x, y)) {
- shade = 2;
- } else if(is_torch_lit(x, y)) {
- shade = 0;
- }
-
-
- // did we get some data ?
- if(feat_nc != -1) {
-
- // check shading
- // printf("%d %d -> %d\n", x, y, shade);
-
- if(feat_nc >= 240 && feat_nc <= 245) {
- // old shading
- // const int shade = (feat_nc-240);
- const int set_base = 240+shade*9;
- const int bits = check_wall(x, y);
-
-
- display_img(316+(shade%3), xpos, ypos, TRUE);
-
- if(bits) {
- for(i=0; i<4; i++) {
- if(bits & (1 << i)) {
- display_img(set_base+i, xpos, ypos, TRUE);
- }
- }
-
- display_img(set_base+8, xpos, ypos, TRUE);
-
- for(i=4; i<8; i++) {
- if(bits & (1 << i)) {
- display_img(set_base+i, xpos, ypos, TRUE);
- }
- }
-
- } else {
- // a pillar
- display_img(set_base+8, xpos, ypos, TRUE);
- }
-
- // fields with walls never contain anything else
- // so we can quit now
- return;
-
- } else if(feat_nc == 0x27) {
- // open doors
- display_img(138+door_direction(x,y), xpos, ypos, TRUE);
-
-
- } else if(feat_nc == 0x2B) {
- // closed doors
- display_img(136+door_direction(x,y), xpos, ypos, TRUE);
-
- } else if(feat_nc == 0x8C || // a between gate
- feat_nc == 0x20 || // empty square
- feat_nc == 0x16E || // brick roof
- feat_nc == 0x16F || // brick roof top
- feat_nc == 0x176 || // grass roof
- feat_nc == 0x177 || // grass roof chimney
- feat_nc == 0x17E || // grass roof top
- (feat_nc >= 0x31 && feat_nc <= 0x39) || // shop with number
- (feat_nc >= 0x576 && feat_nc <= 0x57D) || // trap
- feat_nc == 0x3E || // down stairs
- feat_nc == 0x3C // up stairs
- ) {
- // this features should not be shaded
-
- display_img(feat_nc, xpos, ypos, TRUE);
-
- } else if(feat_nc > 2){
- // this features should be shaded
-
- // floor
- // known grids get shaded floors
- if(is_only_torch_lit(x,y)) {
- display_color_img(feat_nc+2,
- xpos, ypos,
- get_distance_to_player(x, y) << 1,
- TRUE);
- } else {
- display_img(feat_nc+shade, xpos, ypos, TRUE);
- }
- }
-
- // printf("%d a=%x c=%x (%c)\n", nc, a, c, c);
-
- /* Hajo: display a complete grid if the user wants to */
- if(grid == 2) {
- display_img(6, xpos, ypos, TRUE);
- }
-
-
-#ifdef USE_EGO_GRAPHICS
- if( ego_nc != feat_nc &&
- ego_nc > 2 &&
- ego_nc != 0x27 &&
- ego_nc != 0x2B ) {
-
- display_img(ego_nc, xpos, ypos, TRUE);
- }
-#endif
-
- if( obj_nc != feat_nc &&
- obj_nc > 2 &&
- obj_nc != 0x27 &&
- obj_nc != 0x2B ) {
-
- /* Hajo: display a grid below items/monsters if the user wants to */
- if(grid == 1) {
- display_img(5, xpos, ypos, TRUE);
- }
-
- display_img(obj_nc, xpos, ypos, TRUE);
-
- }
- } else {
-
- // outside of dungeon
- display_img(32, xpos, ypos, TRUE);
- }
-
- /* display cursor ? */
- if(
- high_x >= 1 &&
- high_y >= 1) {
- if(xoff == high_x &&
- yoff == high_y) {
- display_img(7, xpos, ypos, TRUE);
-
- /* only draw once, wait until next request */
- high_x = high_y = -1;
- }
- }
-}
-
diff --git a/src/iso/world_view.h b/src/iso/world_view.h deleted file mode 100644 index 426627e2..00000000 --- a/src/iso/world_view.h +++ /dev/null @@ -1,49 +0,0 @@ -/* world_view.h - * - * Copyright (c) 2001 Hansjörg Malthaner - * hansjoerg.malthaner@gmx.de - * - * This file is part of the Simugraph<->Angband adaption code. - * - * - * This file may be copied and modified freely so long as the above credits, - * this paragraph, and the below disclaimer of warranty are retained; no - * financial profit is derived from said modification or copying; and all - * licensing rights to any modifications are granted to the original author, - * Hansjörg Malthaner. - * - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE - * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef hajo_world_view_h -#define hajo_world_view_h - - - -/** - * Draw ground of location i,j onto screen position xpos,ypos - * @author Hj. Malthaner - */ -void display_boden(int i, int j, int xpos, int ypos); - - -/** - * Draw objects of location i,j onto screen position xpos,ypos - * @author Hj. Malthaner - */ -void display_dinge(int i, int j, int xpos, int ypos); - - -#endif diff --git a/src/maim-iso.c b/src/maim-iso.c deleted file mode 100644 index c217ca84..00000000 --- a/src/maim-iso.c +++ /dev/null @@ -1,873 +0,0 @@ -/* - * - * This file contains routines for maiming bitmaps as well as other - * supplemental routines, all for SDL. - * - * Copyright 2001 Gregory Velichansky (hmaon@bumba.net) - * You may use it under the terms of the standard Angband license (below) or - * the GNU General Public License (GPL) Version 2 or greater. (see below) - * - * The Angband license states: - * This software may be copied and distributed for educational, research, - * and not for profit purposes provided that this copyright and statement - * are included in all such copies. Other copyrights may also apply. - * - * The GNU GPL notice: - main-sdl.c - SDL (http://libsdl.org) Term implementation for Angband. - Copyright (C) 2001 Gregory Velichansky (hmaon@bumba.net) - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - 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. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, please see - http://www.gnu.org/copyleft/gpl.html - - - Please see the file COPYING for more detail regarding Angband's current - license situation. -*/ - - -#include "angband.h" - -#if defined(USE_ISO) || defined(USE_LUA_GUI) - - -#include "SDL/SDL.h" -#include <string.h> -#include <math.h> /* for scaling blits */ -//#include "bits/nan.h" - -/* - * - * Supplemental SDL bitmap manipulation functions. - * - * These could be moved to a separate file. In mai?-x11.c, similar routines - * are separate from the main display module implementation. - * - */ - - -/* The most pedantic-a%& getpixel and putpixel ever, hopefully. */ -/* There may still be endianness bugs! These will be fixed after adequte testing. XXX XXX XXX */ -inline errr SDL_GetPixel (SDL_Surface *f, Uint32 x, Uint32 y, Uint8 *r, Uint8 *g, Uint8 *b) -{ - /*const Uint32 mask[] = {0x0, 0xff, 0xffff, 0xffffff, 0xffffffff};*/ - Uint32 pixel; - - Uint8 *pp; - - int n; /* general purpose 'n'. */ - - if (f == NULL) return -1; - - pp = (Uint8 *) f->pixels; - - if (x >= f->w || y >= f->h) return -1; - - pp += (f->pitch * y); - - pp += (x * f->format->BytesPerPixel); - - /* we do not lock the surface here, it would be inefficient XXX */ - /* this reads the pixel as though it was a big-endian integer XXX */ - /* I'm trying to avoid reading part the end of the pixel data by - * using a data-type that's larger than the pixels */ - for (n = 0, pixel = 0; n < f->format->BytesPerPixel; ++n, ++pp) - { -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - pixel >>= 8; - pixel |= *pp << (f->format->BitsPerPixel - 8); -#else -pixel |= *pp; - pixel <<= 8; -#endif - } - - SDL_GetRGB(pixel, f->format, r, g, b); - return 0; -} - -/* This function looks remarkably similar to the one above. Yes, it's cut - * and paste. */ -inline errr SDL_PutPixel (SDL_Surface *f, Uint32 x, Uint32 y, Uint8 r, Uint8 g, Uint8 b) -{ - Uint32 pixel; - - Uint8 *pp; - - int n; - - if (f == NULL) return -1; - - pp = (Uint8 *) f->pixels; - - if (x >= f->w || y >= f->h) return -1; - - pp += (f->pitch * y); - - pp += (x * f->format->BytesPerPixel); - - pixel = SDL_MapRGB(f->format, r, g, b); - - for (n = 0; n < f->format->BytesPerPixel; ++n, ++pp) - { - *pp = (Uint8) (pixel & 0xFF); - pixel >>= 8; - } - - return 0; -} - - -/* This routine performs a scaling blit. It will shrink and magnify. :) */ -/* It uses floating point arithmetic (because I am lazy) so it's not too fast - * but I only intend for it to be used in pre-processing, that is image - * processing at load time. It's fast enough for that, at least. - * Actually on my machine it IS fast enough to scale fonts and bitmaps - * in real-time. :) - * This routine uses a weighted average, the weight being based on overlapping - * pixel area. - */ -inline errr SDL_ScaleBlit(SDL_Surface *src, SDL_Rect *sr, SDL_Surface *dst, SDL_Rect *dr) -{ - Uint8 r, g, b; - - float rs, gs, bs; /* sums */ - - float area; - - float sx, sy; /* current source x and y */ - float dsx, dsy; /* source increment, per increment of 1 in destination */ - - float wsx, wsy; - /* width of source box. Equal to dsx,dsy except when either of then are - * smaller than 1. This is a hack for smoother magnification. XXX */ - - - float x, y; /* x and y in sub-area */ - - Uint32 tx, ty; /* "to" x and y */ - Uint32 lx, ly; - - float w, e, n, s; /* some temporary variables, named after orientations */ - - - if (src == NULL || sr == NULL || dst == NULL || dr == NULL) return -1; - - /* these are meaningless and would cause a divide by zero: */ - if (!dr->w || !dr->h) return -1; - - wsx = dsx = ((float) sr->w) / dr->w; - if (wsx < 1) wsx = 1; - wsy = dsy = ((float) sr->h) / dr->h; - if (wsy < 1) wsy = 1; - - lx = dr->x + dr->w; - ly = dr->y + dr->h; - - area = wsx * wsy; - - - - for (ty = dr->y, sy = (float)sr->y; ty < ly; ++ty, sy += dsy) - { - for (tx = dr->x, sx = (float)sr->x; tx < lx; ++tx, sx += dsx) - { - rs = gs = bs = 0.0; - for (y = floor(sy) - 1; ceil(sy + wsy) > y; ++y) - { - for (x = floor(sx) - 1; ceil(sx + wsx) > x; ++x) - { - w = (x > sx) ? 0 : sx - x; - n = (y > sy) ? 0 : sy - y; - - e = (sx + wsx >= x + 1) ? 1 : sx + wsx - x; - s = (sy + wsy >= y + 1) ? 1 : sy + wsy - y; - - if (w > e || s < n ) continue; - -#define gsx ((Uint32)x >= sr->x+sr->w ? sr->x+sr->w-1 : (Uint32)x) -#define gsy ((Uint32)y >= sr->y+sr->h ? sr->y+sr->h-1 : (Uint32)y) - SDL_GetPixel (src, gsx, gsy, &r, &g, &b); - - - - rs += (e - w) * (s - n) * (float)r; - gs += (e - w) * (s - n) * (float)g; - bs += (e - w) * (s - n) * (float)b; - } - } - rs /= area; - gs /= area; - bs /= area; - - if (rs >= 256.0 || gs >= 256.0 || bs > 256.0) - { - plog("weighted average error!"); - plog(format("Values: %f, %f, %f\n", rs, gs, bs)); - /**((char *)0) = 0;*/ - } - if (rs > 255.0) rs = 255.0; - if (gs > 255.0) gs = 255.0; - if (bs > 255.0) bs = 255.0; - - r = (Uint8)rs; - g = (Uint8)gs; - b = (Uint8)bs; - - SDL_PutPixel (dst, tx, ty, r, g, b); - } - } - - return 0; -#undef gsx -#undef gsy -} - - -/* Integer math version of SDL_ScaleBlit(). - * Where necessary, a number uses the 16 high bits for the integer - * and the 16 low bits for the decimal portion. - * - * eg: - * float a = (float) (b >> 16) + (b & 0xFFFF)/65536.0; - */ - -inline Uint32 ifloor(Uint32 i) -{ - return i & 0xFFFF0000; -} - -inline Uint32 iceil(Uint32 i) -{ - return (i & 0xFFFF) ? i : ifloor(i) + (1 << 16); -} - - -errr SDL_FastScaleBlit(SDL_Surface *src, SDL_Rect *sr, SDL_Surface *dst, SDL_Rect *dr) -{ - Uint8 r, g, b; - Uint32 rs, gs, bs; /* sums. */ - - /* temp storage for large int multiplies. Uint64 doen't exist anywhere */ - double farea; - Uint32 area; - - Uint32 sx, sy; - Uint32 dsx, dsy; - - Uint32 wsx, wsy; - - Uint32 x, y; /* x and y, for sub-area */ - - Uint32 tx, ty; /* normal integers */ - Uint32 lx, ly; /* normal integers */ - - Uint32 w, e, n, s; /* temp variables, named after compass directions */ - - if (src == NULL || sr == NULL || dst == NULL || dr == NULL) return -1; - - if (!dr->w || !dr->h) return -1; - - - /* TODO FIXME check for possible overflows! */ - - wsx = dsx = (sr->w << 16) / dr->w; - if (!(wsx & 0xFFFF0000)) wsx = 1 << 16; - wsy = dsy = (sr->h << 16) / dr->h; - if (!(wsy & 0xFFFF0000)) wsy = 1 << 16; - - lx = dr->x + dr->w; - ly = dr->y + dr->h; - - /* lazy multiplication. Hey, it's only once per blit. :P */ - farea = ((double)wsx) * ((double)wsy); - farea /= (double)(1 << 16); - area = (Uint32) farea; - - /* For optimization, those setup routines should be moved into - * SDL_ScaleTiledBitmap() for that function. - */ - - for (ty = dr->y, sy = sr->y << 16; ty < ly; ++ty, sy += dsy) - { - for (tx = dr->x, sx = sr->x << 16; tx < lx; ++tx, sx += dsx) - { - rs = gs = bs = 0; - for (y = ifloor(sy); iceil(sy + wsy) > y; y += (1 << 16)) - { - for (x = ifloor(sx); iceil(sx + wsx) > x; x += (1 << 16)) - { - w = (x > sx) ? 0 : sx - x; - n = (y > sy) ? 0 : sy - y; - - e = (sx + wsx >= x + (1 << 16)) ? 1 << 16 : sx + wsx - x; - s = (sy + wsy >= y + (1 << 16)) ? 1 << 16 : sy + wsy - y; - - if (w > e || s < n) continue; - -#define gsx ((x >> 16) >= sr->x+sr->w ? sr->x+sr->w-1 : x >> 16) -#define gsy ((y >> 16) >= sr->y+sr->h ? sr->y+sr->h-1 : y >> 16) - - SDL_GetPixel (src, gsx, gsy, &r, &g, &b); - - rs += ((e - w) >> 8) * ((s - n) >> 8) * r; - gs += ((e - w) >> 8) * ((s - n) >> 8) * g; - bs += ((e - w) >> 8) * ((s - n) >> 8) * b; - } - } - rs /= area; - gs /= area; - bs /= area; - - if (rs >= 256 || gs >= 256 || bs >= 256) - { - plog("fixed point weighted average overflow!"); - plog(format("Values: %d, %d, %d\n", rs, gs, bs)); - } - - r = (Uint8) rs; - g = (Uint8) gs; - b = (Uint8) bs; - - SDL_PutPixel (dst, tx, ty, r, g, b); - } - } - - return 0; -#undef gsx -#undef gsy -} - - - -#if 0 /* the procedure above is a more generalized version of the one below */ - -/* The following is a function to perform a Blit while magnifying */ -/* Anti-aliasing is performed. :) */ -/* It is probably very SLOW on most systems. Use it for pre-processing. XXX */ -/* a Blit while shrinking is handled by a different function */ -errr SDL_StretchBlit(SDL_Surface *src, SDL_Rect *sr, SDL_Surface *dst, SDL_Rect *dr) -{ - double sx, sy; /* current source x and y */ - Uint32 isx, isy; /* temp. values for convenience in calculation code */ - double dsx, dsy; /* source increment, per increment of 1 in destination */ - double wx, wy; /* temp. weight values for the color mixing calculations */ - double weight; /* temp. weight of pixel */ - - /* coordinates to get pixels from: ... */ -#undef gsx -#define gsx (isx >= sr->x+sr->w ? sr->x+sr->w-1 : isx) -#undef gsy -#define gsy (isy >= sr->y+sr->h ? sr->y+sr->h-1 : isy) - - - Uint32 tx, ty; /* "to" x and y. "dx, dy" would be too confusing. */ - Uint32 lx, ly; /* end x and y in destination, not inclusive */ - - double r, g, b; /* temporary values on which we perform calculations */ - /*double s;*/ /* scale factor calculation thing. gross hack. don't ask. */ - Uint8 ir, ig, ib; /* same here. */ - - if (src == NULL || sr == NULL || dst == NULL || dr == NULL) return -1; - - /* these are meaningless and would cause a divide by zero: */ - if (!dr->w || !dr->h) return -1; - - dsx = ((double) sr->w) / dr->w; - dsy = ((double) sr->h) / dr->h; - - lx = dr->x + dr->w; - ly = dr->y + dr->h; - - for (ty = dr->y, sy = (double)sr->y; ty < ly; ++ty, sy += dsy) - { - for (tx = dr->x, sx = (double)sr->x; tx < lx; ++tx, sx += dsx) - { - /* here we must consider four pixels and mix them together */ - /* the further away we are from a pixel, the less weight it has - * when we mix in its color. Hence the "1 - hypot(..." etc. - * Actually, no. Let's not use hypot(). - */ - /* - * upper left pixel - */ - wx = ((floor(sx) + 1) - sx); - wy = ((floor(sy) + 1) - sy); - - isx = (Uint32) floor(sx); - isy = (Uint32) floor(sy); - - if (SDL_GetPixel(src, gsx, gsy, &ir, &ig, &ib)) return -1; - - weight = wx * wy; - /* the area of the overlap of our hypothetical and real pixel!!! */ - if (weight < 1 / 1024.0) weight = 0; - r = weight * (double)ir; - g = weight * (double)ig; - b = weight * (double)ib; - /*s = weight * 255.0;*/ - - /* - * upper right pixel - */ - wx = 1 - wx; - isx += 1; - - if (SDL_GetPixel(src, gsx, gsy, &ir, &ig, &ib)) return -1; - - weight = wx * wy; - if (weight < 1 / 1024.0) weight = 0; - r += weight * (double)ir; - g += weight * (double)ig; - b += weight * (double)ib; - /*s += weight * 255.0;*/ - - /* - * lower right pixel - */ - wy = 1 - wy; - isy += 1; - - if (SDL_GetPixel(src, gsx, gsy, &ir, &ig, &ib)) return -1; - - weight = wx * wy; - if (weight < 1 / 1024.0) weight = 0; - r += weight * (double)ir; - g += weight * (double)ig; - b += weight * (double)ib; - /*s += weight * 255.0;*/ - - /* - * lower left pixel - */ - wx = 1 - wx; - isx -= 1; - - if (SDL_GetPixel(src, gsx, gsy, &ir, &ig, &ib)) return -1; - - weight = wx * wy; - if (weight < 1 / 1024.0) weight = 0; - r += weight * (double)ir; - g += weight * (double)ig; - b += weight * (double)ib; - /*s += weight * 255.0;*/ - - - /* - r = 255 * (r/s); - g = 255 * (g/s); - b = 255 * (b/s); - */ - - if (r >= 256.0 || g >= 256.0 || b > 256.0) - { - plog("mixing error!"); - plog(format("Values: %f, %f, %f\n", (double)r, (double)g, (double)b)); - /**((char *)0) = 0;*/ - } - if (r > 255.0) r = 255.0; - if (g > 255.0) g = 255.0; - if (b > 255.0) b = 255.0; - ir = (Uint8) r; - ig = (Uint8) g; - ib = (Uint8) b; - - SDL_PutPixel(dst, tx, ty, ir, ig, ib); - } - } - - return 0; -} - -#endif - - - - -/* This function will take an SDL_Surface, allocate a new surface to hold - * the resized surface, perform the scaling operation, free the old surface - * and return the new one. This behaviour is vaguely modeled after C library - * string functions. Returns NULL on grievous errors! - * - * The scaling operation is performed one or more times to accomodate - * images comprised by a number of sub-images whose edges must not be blurred - * with the edges of adjacent sub-images. (Think fonts and tile sets.) - * - * If t_oldw and t_oldh are set to src->w and src->h respectively - * - * t_oldw, t_oldh are the size of the old tiles - */ -SDL_Surface *SDL_ScaleTiledBitmap (SDL_Surface *src, - Uint32 t_oldw, - Uint32 t_oldh, - Uint32 t_neww, - Uint32 t_newh, - int dealloc_src) - -{ - SDL_Surface *dst; - SDL_Rect sr, dr; - Uint32 x, y; - Uint32 nx, ny; - - if (!t_oldw || !t_oldh || !t_neww || !t_newh || !src) return NULL; /*dummy!*/ - - if (t_oldw == t_neww && t_oldh == t_newh) return src; /* OK... */ - - /* Get the number of tiles in the image. - * Any possible clipped tiles at the edges are ignored. - */ - nx = src->w / t_oldw; - ny = src->h / t_oldh; - - /* Allocate a new SDL_Surface of appropriate size, with settings otherwise - * identical to src. - */ - dst = SDL_CreateRGBSurface(src->flags, - nx * t_neww, - ny * t_newh, - /*src->format->BitsPerPixel,*/ - 16, - src->format->Rmask, - src->format->Gmask, - src->format->Bmask, - src->format->Amask); - - - for (y = 0; y < ny; ++y) - { - for (x = 0; x < nx; ++x) - { - sr.w = t_oldw; - sr.h = t_oldh; - sr.x = x * t_oldw; - sr.y = y * t_oldh; - - dr.w = t_neww; - dr.h = t_newh; - dr.x = x * t_neww; - dr.y = y * t_newh; - - /*printf("%d,%d -> %d,%d (%d,%d -> %d, %d)\n", sr.x, sr.y, dr.x, dr.y, sr.w, sr.h, dr.w, dr.h);*/ - - /* scale-blit one tile and check for error - * although SDl_ScaleBlit() might not have any errors to return. - */ - if (SDL_FastScaleBlit(src, &sr, dst, &dr)) return NULL; - } - } - - if (dealloc_src) SDL_FreeSurface(src); - - return dst; -} - - -/* The following function will extract height and width info from a filename - * such as 16x16.xyz or 8X13.bar or even argle8ook16.foo - * - * I realize now that it's also useful for reading integers out of an argument - * such as --fooscale1=2 - */ - -errr strtoii(const char *str, Uint32 *w, Uint32 *h) -{ - char buf[1024]; - char *s = buf; - char *tok; - char *numeric = "0123456789"; - - size_t l; /* length of numeric string */ - - if (!str || !w || !h) return -1; - - if (strlen(str) < 3) return -1; /* must have room for at least "1x1" */ - - strncpy(buf, str, 1023); - buf[1023] = '\0'; - - tok = strpbrk(buf, numeric); - if (!tok) return -1; - - l = strspn(tok, numeric); - if (!l) return -1; - - tok[l] = '\0'; - - s = tok + l + 1; - - if (!sscanf(tok, "%d", w)) return -1; - - /* next token */ - tok = strpbrk(s, numeric); - if (!tok) return -1; - - l = strspn(tok, numeric); - if (!l) return -1; - - tok[l] = '\0'; - /* no need to set s since this is the last token */ - - if (!sscanf(tok, "%d", h)) return -1; - - return 0; - -} - - - - -char *formatsdlflags(Uint32 flags) -{ - return format ("%s%s%s%s%s%s%s%s%s%s (%x)", - (flags & SDL_HWSURFACE) ? "SDL_HWSURFACE " : "", - (flags & SDL_ANYFORMAT) ? "SDL_ANYFORMAT " : "", - (flags & SDL_HWPALETTE) ? "SDL_HWPALETTE " : "", - (flags & SDL_DOUBLEBUF) ? "SDL_DOUBLEBUF " : "", - (flags & SDL_FULLSCREEN) ? "SDL_FULLSCREEN " : "", - (flags & SDL_RESIZABLE) ? "SDL_RESIZABLE " : "", - (flags & SDL_HWACCEL) ? "SDL_HWACCEL " : "", - (flags & SDL_SRCCOLORKEY) ? "SDL_SRCCOLRKEY " : "", - (flags & SDL_RLEACCEL) ? "SDL_RLEACCEL " : "", - (flags & SDL_SRCALPHA) ? "SDL_SRCALPHA " : "", - flags); -}; - - - - - - -/* A lot of code for handling keystrokes follow. */ - - -typedef struct sdl_keymapt sdl_keymapt; - -struct sdl_keymapt -{ - SDLKey k; /* what we get from SDL */ - char *s; /* what we feed to the Term_keypress */ - char *ctrl; /* what if CTRL is pressed? (NULL if the same) */ - char *shift; /* what if SHIFT is pressed? */ -}; - -/* XXX XXX XXX the following keymap sucks. More comments below. */ -sdl_keymapt sdl_keymap[] = -{ - /*{SDLK_UP, "[A", "Oa", "Ox"}, - {SDLK_DOWN, "[B", "Ob", "Or"}, - {SDLK_RIGHT, "[C", "Oc", "Ot"}, - {SDLK_LEFT, "[D", "Od", "Ov"}, - {SDLK_INSERT, "[2~", "[2^", "Op"}, - {SDLK_HOME, "[1~", "[1^", "Ow"}, - {SDLK_END, "[4~", "[4^", "Oq"}, - {SDLK_PAGEUP, "[5~", "[5^", "Oy"}, - {SDLK_PAGEDOWN, "[6~", "[6^", "Os"},*/ - {SDLK_F1, "[[A", NULL, NULL}, - {SDLK_F2, "[[B", NULL, NULL}, - {SDLK_F3, "[[C", NULL, NULL}, - {SDLK_F4, "[[D", NULL, NULL}, - {SDLK_F5, "[[E", NULL, NULL}, - {SDLK_F6, "[[17~", NULL, NULL}, - {SDLK_F7, "[[18~", NULL, NULL}, - {SDLK_F8, "[[19~", NULL, NULL}, - {SDLK_F9, "[[20~", NULL, NULL}, - {SDLK_F10, "[[21~", NULL, NULL}, - {SDLK_F11, "[[23~", NULL, NULL}, - {SDLK_F12, "[[24~", NULL, NULL}, - /* I have no machines with F13, F14, F15. Is that a Sun thing? */ - {SDLK_F13, "", NULL, NULL}, - {SDLK_F14, "", NULL, NULL}, - {SDLK_F15, "", NULL, NULL}, - {SDLK_RSHIFT, "", NULL, NULL}, - {SDLK_LSHIFT, "", NULL, NULL}, - {SDLK_RALT, "", NULL, NULL}, - {SDLK_LALT, "", NULL, NULL}, - {SDLK_RCTRL, "", NULL, NULL}, - {SDLK_LCTRL, "", NULL, NULL}, - {SDLK_RMETA, "", NULL, NULL}, - {SDLK_LMETA, "", NULL, NULL}, - {SDLK_NUMLOCK, "", NULL, NULL}, - {SDLK_CAPSLOCK, "", NULL, NULL}, - {SDLK_SCROLLOCK, "", NULL, NULL}, - {SDLK_LSUPER, "", NULL, NULL}, - {SDLK_RSUPER, "", NULL, NULL}, - {SDLK_HELP, "?", NULL, NULL}, - {SDLK_PRINT, "", NULL, NULL}, - {SDLK_SYSREQ, "", NULL, NULL}, - {SDLK_BREAK, "", NULL, NULL}, - {SDLK_MENU, "", NULL, NULL}, - {SDLK_POWER, "", NULL, NULL}, - {SDLK_EURO, "", NULL, NULL}, - {SDLK_0, "0", NULL, ")"}, /* XXX XXX XXX The CTRL-number keys need to be */ - {SDLK_1, "1", NULL, "!"}, /* defined since they represent digging for */ - {SDLK_2, "2", NULL, "@"}, /* some people!. Really, this whole table */ - {SDLK_3, "3", NULL, "#"}, /* should be replaced with something cleaner */ - {SDLK_4, "4", NULL, "$"}, /* and an SDL pref file should be created. */ - {SDLK_5, "5", NULL, "%"}, - {SDLK_6, "6", NULL, "^"}, - {SDLK_7, "7", NULL, "&"}, - {SDLK_8, "8", NULL, "*"}, - {SDLK_9, "9", NULL, "("}, - {SDLK_SEMICOLON, ";", NULL, ":"}, - {SDLK_COMMA, ",", NULL, "<"}, - {SDLK_PERIOD, ".", NULL, ">"}, - {SDLK_BACKSLASH, "\\", NULL, "|"}, - {SDLK_BACKQUOTE, "`", NULL, "~"}, - {SDLK_LEFTBRACKET, "[", NULL, "{"}, - {SDLK_RIGHTBRACKET, "]", NULL, "}"}, - {SDLK_MINUS, "-", NULL, "_"}, - {SDLK_EQUALS, "=", NULL, "+"}, - {SDLK_SLASH, "/", NULL, "?"}, - {SDLK_UNKNOWN, NULL, NULL, NULL} /* terminator */ -}; - -void Multikeypress(char *k) -{ - printf("zog : '%s'\n", k); - while (*k) Term_keypress(*k++); -} - -int IsMovement(SDLKey k) -{ - switch (k) - { - case SDLK_UP: - case SDLK_DOWN: - case SDLK_RIGHT: - case SDLK_LEFT: - case SDLK_INSERT: - case SDLK_HOME: - case SDLK_END: - case SDLK_PAGEUP: - case SDLK_PAGEDOWN: - case SDLK_KP0: - case SDLK_KP1: - case SDLK_KP2: - case SDLK_KP3: - case SDLK_KP4: - case SDLK_KP5: - case SDLK_KP6: - case SDLK_KP7: - case SDLK_KP8: - case SDLK_KP9: - return TRUE; - - default: - return FALSE; - } - return 1234567; /* all good children go to heaven */ -} - - -char *SDL_keysymtostr(SDL_keysym *ks) -{ -#ifdef bufsize -#error bufsize steps on previous define! -#endif -#define bufsize 1024 - int bufused = 0; - - /* I am returning a pointer to the below variable. - * I /think/ this is legal but I am not sure! XXX XXX XXX - * It certainly seems to work fine, at least under GCC. - * It can easily be changed to a pointer passed as an argument. - */ - static char buf[bufsize]; - Uint8 ch; - - /* cat for strings and app[end] for characters */ -#define sdlkcat(a) strncat(buf,(a),bufsize-bufused-1); bufused+=strlen((a)); -#define sdlkapp(a) if(bufused<bufsize-1) { buf[bufused]=a; buf[bufused+1]='\0'; bufused++; } - - buf[0] = '\0'; - - // printf("%c\n", ks->unicode); - - - if (IsMovement(ks->sym)) - { - sprintf(buf, "%c%s%s%s%s_%lX%c", 31, - ks->mod & KMOD_CTRL ? "N" : "", - ks->mod & KMOD_SHIFT ? "S" : "", - "", /* for future expansion. */ - ks->mod & KMOD_ALT ? "M" : "", - (unsigned long) ks->sym, 13); - ch = 0; - } - else - { - if (ks->mod & KMOD_ALT) - { - sdlkapp(''); - } - ch = ks->unicode; - - } - - if (ch) sdlkapp(ch); - - return buf; - - -#undef bufsize -#undef sdlkcat -#undef sdlkapp - -} /* SDL_keystring */ - - - -/* Cursor hack, for testing of ideas. XXX XXX XXX */ - -SDL_Surface *sdl_screen_cursor = NULL; -SDL_Rect sdl_screen_cursor_sr; - - -/* it must be true that w * h * 4 <= maxUint32 */ - -errr SDL_init_screen_cursor(Uint32 w, Uint32 h) -{ - Uint32 i; - - sdl_screen_cursor_sr.x = sdl_screen_cursor_sr.y = 0; - sdl_screen_cursor_sr.w = w; - sdl_screen_cursor_sr.h = h; - - sdl_screen_cursor = NULL; - sdl_screen_cursor = SDL_CreateRGBSurface(SDL_SRCALPHA, w, h, 32, - 0xff000000, - 0x00ff0000, - 0x0000ff00, - 0x00000000); - - if (!sdl_screen_cursor) return -1; - - SDL_SetAlpha(sdl_screen_cursor, SDL_SRCALPHA | SDL_RLEACCEL, 0x80); - for (i = 0; i < w*h*4; ++i) - { - ((Uint8 *)(sdl_screen_cursor->pixels))[i] = !(i & 2) ? 0x80 : 0xFF; - } - - return 0; -} - -errr SDL_DrawCursor(SDL_Surface *dst, SDL_Rect *dr) -{ - if (!dst || !dr || !sdl_screen_cursor) return -1; - if (SDL_BlitSurface(sdl_screen_cursor, &sdl_screen_cursor_sr, dst, dr)) return -1; - SDL_UpdateRect(dst, dr->x, dr->y, dr->w, dr->h); - return 0; -} - -#endif diff --git a/src/main-sdl-iso.c b/src/main-sdl-iso.c deleted file mode 100644 index 62aa05d9..00000000 --- a/src/main-sdl-iso.c +++ /dev/null @@ -1,1905 +0,0 @@ -/* Copyright (C) 2003-2004 Neil Stevens <neil@hakubi.us> - // Copyright (C) 2004 Ethan Stump <estump@seas.upenn.edu> - // - // Permission is hereby granted, free of charge, to any person obtaining a copy - // of this software and associated documentation files (the "Software"), to deal - // in the Software without restriction, including without limitation the rights - // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - // copies of the Software, and to permit persons to whom the Software is - // furnished to do so, subject to the following conditions: - // - // The above copyright notice and this permission notice shall be included in - // all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - // THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - // AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - // - // Except as contained in this notice, the name(s) of the author(s) shall not be - // used in advertising or otherwise to promote the sale, use or other dealings - // in this Software without prior written authorization from the author(s). - */ - -#ifdef USE_SDL - -#include "angband.h" -#include <SDL.h> -#include <SDL_image.h> -#include <SDL_ttf.h> - -#include <math.h> - -#ifdef USE_ISO -/* - * Simugraph system (Hj. Malthaner) - */ -#include "iso/simsys.h" -#include "iso/simgraph.h" -#include "iso/world_adaptor.h" -#include "iso/world_view.h" -/* - * Simugraph specific routines - * by Hj. Malthaner - */ -#include "iso/hackdef.h" - -/* - * Text place marker function protype (Hj. Malthaner) - */ -static void set_spots(int x, int y, int n, bool_ v); - -/** - * we need to track spots with text to avoid overdrawing text with images - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -bool_ spots[80][24]; - -/** - * mouse coordinates for Simugraph engine - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int mx, my; - -/* - * Hajo: this flags need to be set when opening windows - */ - -static int tex_width; -static int tex_height; -static int tex_xoff; -static int tex_yoff; - -static unsigned int tab16[1 << 16]; - -/** - * this is used if we need to fake an 8 bit array - * @author Hj. Malthaner - */ -static unsigned short * data8; - -// buffers to store char code/attr for graphics -unsigned char **iso_ap; -unsigned char **iso_cp; -unsigned char **iso_atp; -unsigned char **iso_ctp; -unsigned char **iso_aep; -unsigned char **iso_cep; - -#endif /* USE_ISO */ - - -/************************************************* - GLOBAL SDL-ToME PROPERTIES - *************************************************/ - -/* Default window properties - used if none are available -from other places*/ -#define DEF_SCREEN_WIDTH 800 -#define DEF_SCREEN_HEIGHT 600 -#define DEF_SCREEN_BPP 16 - -/*Main window properties that may be loaded at runtime from -a preference file or environmental variables. However, -default values (defined above) can be used. */ -static int arg_width = DEF_SCREEN_WIDTH; -static int arg_height = DEF_SCREEN_HEIGHT; -static int arg_bpp = DEF_SCREEN_BPP; - -/**************/ - -/* Default font properties - used unless otherwise changed. -These properties are the size and also default font to load. */ -#define DEF_FONT_SIZE 16 -#define DEF_FONT_FILE "lib/xtra/font/VeraMono.ttf" - -/* The font properties that may perhaps be changed at runtime, -due to environmental variables, preference files, or in-program -commands.*/ -static int arg_font_size = DEF_FONT_SIZE; -static char arg_font_name[64] = DEF_FONT_FILE; - -/**************/ - -/* The number of term_data structures to set aside mem for */ -#define MAX_CONSOLE_COUNT 8 - -/* The number of consoles that are actually being used. -This number could be changed via preference files, environmental -variables, command-line arguments, or possibly even in-game -keypresses or menu-selections. */ -static int arg_console_count = 1; - -/* When rendering multiple terminals, each is drawn with a -surrounding border. These values control the width of this -border and also the color to use when drawing it. */ -#define BORDER_THICKNESS 1 -static int border_color = 0; - -/**************/ - -/* some miscellaneous settings which have not been dealt -with yet */ -static bool_ arg_old_graphics = FALSE; -static bool_ arg_double_width = FALSE; - -/* not dealt with yet (although full screen toggle -is available using Alt-Enter) */ -static bool_ arg_full_screen = FALSE; - - -/************************************************* - GLOBAL SDL-ToME VARIABLES - *************************************************/ - -/* the main screen to draw to */ -static SDL_Surface *screen; - -/* some helper surfaces that are used for rendering -characters */ -static SDL_Surface *worksurf; -static SDL_Surface *crayon; - -/* the array of pre-rendered characters -(see loadAndRenderFont() below) */ -SDL_Surface *text[128]; - -/* the actual TTF_Font used (XXX should get rid of this)*/ -TTF_Font *font=0; - -/* the width and height of the uniformly-sized pre-rendered -characters */ -int t_width = 1, t_height = 1; - - -/************************************************* - COLOR SETUP - *************************************************/ -int screen_black; -int screen_white; - -static int color_data[16]; -/* The following macro is for color defining... - Note that the color is fully opaque... */ -#define COLOR(r,g,b) \ - SDL_MapRGBA(crayon->format,r,g,b,SDL_ALPHA_OPAQUE) - -/*These color macros will setup the colors to use, but must be called after - the SDL video has been set. That way SDL can correct for any funky video - setttings. */ - -#define BLACK COLOR(0x00,0x00,0x00) -#define WHITE COLOR(0xff,0xff,0xff) -#define MID_GREY COLOR(0x80,0x80,0x80) -#define BRIGHT_ORANGE COLOR(0xff,0x80,0x00) -#define RED COLOR(0xc0,0x00,0x00) -#define GREEN COLOR(0x00,0x80,0x40) -#define BRIGHT_BLUE COLOR(0x00,0x00,0xff) -#define DARK_ORANGE COLOR(0x80,0x40,0x00) -#define DARK_GREY COLOR(0x40,0x40,0x40) -#define BRIGHT_GREY COLOR(0xc0,0xc0,0xc0) -#define PURPLE COLOR(0xff,0x00,0xff) -#define YELLOW COLOR(0xff,0xff,0x00) -#define BRIGHT_RED COLOR(0xff,0x00,0x00) -#define BRIGHT_GREEN COLOR(0x00,0xff,0x00) -#define AQUAMARINE COLOR(0x00,0xff,0xff) -#define BROWN COLOR(0xc0,0x80,0x40) - -/************************************************* - TERMINAL DATA STRUCTURE SETUP - *************************************************/ - -/* Forward declare */ -typedef struct _term_data term_data; - -/* A structure for each "term" */ -struct _term_data -{ - term t; /* the term structure, defined in z-term.h */ - cptr name; /* name of this term sub-window */ - - uint rows, cols; /* row/column count */ - uint pos_x, pos_y; /* upper left corner of rendering box */ - uint size_w, size_h; /* width, height of rendering box */ - - bool_ has_border; /* whether this sub-window has a border or not */ - uint border_thick; /* thickness of border to draw around window */ -#ifdef USE_GRAPHICS -#ifdef USE_TRANSPARENCY -#endif -#endif -}; - -/* The array of term data structures */ -static term_data data[MAX_CONSOLE_COUNT]; - -/************************************************* - FILE-SPECIFIC MACROS - *************************************************/ - -/* Debug macros! */ -#define DB(str) \ - printf("main-sdl: %s\n",str); - -/************************************************* - COLOR SETUP - *************************************************/ - -/* SDL Quitting function... declare a few functions first.*/ -void killFontAndAlphabet(void); -static void sdl_quit(cptr string) -{ - printf("sdl_quit called.\n"); - printf("message: %s\n",string); - /* Need to take care of font and rendered characters */ - killFontAndAlphabet(); - if (TTF_WasInit()) - TTF_Quit(); - /* Then exit SDL */ - SDL_Quit(); - /* And now for the default quit behavior */ - quit_aux = 0; - quit(string); -} - -/************************************************* - FONT SUPPORT FUNCTIONS - *************************************************/ - -/* killFontAndAlphabet will effectively de-initialize the font system; -it does this by closing the font and destroying any pre-rendered -text in memory */ -void killFontAndAlphabet(void) -{ - int i; - /* need to close a font and free all of its corresponding pre-rendered - surfaces */ - if (font) - { - TTF_CloseFont(font); - font = 0; - } - for (i=0;i<128;i++) - { - if(text[i]) - { - SDL_FreeSurface(text[i]); - text[i] = NULL; - } - } -} - -/* loadAndRenderFont is responsible for loading and initializing -a font. First, SDL_ttf calls are made to load and set the style -for the desired font. Next, a character alphabet is rendered and -each character is placed onto a uniformly-sized surface within -the text[] array. Whenever text is needed for displaying on-screen, -this array is referenced and the desired character picture is used. */ -void loadAndRenderFont(char *fname, int size) -{ - int minx,maxx,miny,maxy,advance,i,midline = 0; - SDL_Color base_color = {255,255,255,255}; - SDL_Surface *temp_surf; - SDL_Rect tgt = {0,0,0,0}; - - /* Assuming that the filename is valid, - open the font (pointer is global var)*/ - if (fname == NULL) - sdl_quit("Gimme a font to load!"); - font = TTF_OpenFont(fname,size); - if (font == NULL) - sdl_quit("Error loading that font!"); - /* Set the font style to normal */ - TTF_SetFontStyle(font,TTF_STYLE_NORMAL); - - /* Collect some measurements on this font - - arbitrarily choose the letter 'a' to get width*/ - TTF_GlyphMetrics(font,'a',&minx,&maxx,&miny,&maxy,&advance); - /* the width of each character tile */ - t_width = advance; - /* the height of each character tile */ - t_height = TTF_FontHeight(font); - /* position of the y=0 line in each tile */ - midline = TTF_FontAscent(font); - - /* now... render each of the individual characters */ - for (i=0;i<128;i++) - { - /* make a pretty blended glyph */ - temp_surf=TTF_RenderGlyph_Blended(font,i,base_color); - /* and make sure that we got it right! */ - if (temp_surf == NULL) - sdl_quit("Glyph failed to render!"); - /* get the metrics of this particular glyph so we can position it */ - TTF_GlyphMetrics(font,i,&minx,&maxx,&miny,&maxy,&advance); - /* copy rendered glyph into text queue, at the right position*/ - tgt.x = minx; - tgt.y = midline-maxy; - /* but first... we'll need a surface in the text queue to blit to! */ - text[i] = SDL_CreateRGBSurface(SDL_HWSURFACE,t_width,\ - t_height,16,0xf000,0x0f00,0x00f0,0x000f); - /* turn OFF src-alpha... results in brute - copy of the RGBA contents of surf */ - SDL_SetAlpha(temp_surf,0,0); - SDL_BlitSurface(temp_surf,NULL,text[i],&tgt); - /* turn OFF src-alpha since we'll be using worksurf for blitting */ - SDL_SetAlpha(text[i],0,0); - /* kill the surface to patch up memory leaks */ - SDL_FreeSurface(temp_surf); - } -} - -/***********************************************/ - -#ifdef USE_ISO -/************************************************* - ISO SUPPORT FUNCTIONS - *************************************************/ -/** - * inits operating system stuff - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_os_init(int n, int *parameter) -{ - // Hajo: - // unused in isov-x11 - return TRUE; -} - - -/** - * opens graphics device/context/window of size w*h - * @param w width - * @param h height - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_os_open(int w, int h) -{ - const int left = 13; - -/* tex_width = (data[0].fd->dw * (data[0].t.wid - left + 2) + 3) & 0xFFFC; - tex_height = data[0].fd->dh * (data[0].t.hgt - 2); - - tex_xoff = data[0].fd->dw * left; - tex_yoff = data[0].fd->dh * 1 + 1; -*/ - - //tex_width = (data[0].size_w - (left - 2) * (data[0].size_w / data[0].cols) + 3) & 0xFFFC; - // this is too big (but works :-)) - tex_width = data[0].size_w & 0xfffc; - tex_height = (data[0].size_h / data[0].rows) * (data[0].rows-2); - - tex_xoff = (tex_width / data[0].cols) * left; - tex_yoff = (tex_height / data[0].rows) * 1 + 1; - - return TRUE; -} - - -/** - * closes operating system stuff - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_os_close() -{ - // Hajo: - // unused in isov-x11 - return TRUE; -} - - -/** - * retrieve display width - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_get_width() -{ - return data[0].size_w; -} - - -/** - * retrieve display height - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_get_height() -{ - return data[0].size_h; -} - - -/** - * this is used if we need to fake an 8 bit array - * @author Hj. Malthaner - */ -static unsigned short * data8; - - -/** - * creates a (maybe virtual) array of graphics data - * @author Hj. Malthaner - */ -unsigned short * dr_textur_init() -{ - int i; - - printf("isov-sdl::dr_textur_init()\n"); - printf(" width = %d\n", data[0].size_w); - printf(" height = %d\n", data[0].size_h); - - for (i = 0; i < (1 << 16); i++) - { - // FIXME!!! - // must consider color bits, or breaks in anything else but RGB 555 - unsigned int R; - unsigned int G; - unsigned int B; - - // RGB 555 - R = (i & 0x7C00) >> 10; - G = (i & 0x03E0) >> 5; - B = (i & 0x001F) >> 0; - - - tab16[i] = SDL_MapRGB(screen->format, R << 3, G << 3, B << 3); - } - - - - data8 = malloc((data[0].size_w) * (data[0].size_h) * 2); - - printf(" textur = %p\n", data8); - - // fake an 16 bit array and convert data before displaying - return data8; -} - -static void flush_area(int dest_x, int dest_y, - int x, int y, int w, int h) -{ - SDL_Surface *face = screen; - - if (SDL_LockSurface(face) == 0) - { - int i, j; - const int bpp = screen->format->BytesPerPixel; - - for (j = 0; j < h; j++) - { - unsigned short * p = data8 + (y + j) * tex_width + x; - unsigned char * row = face->pixels + (dest_y + j) * face->pitch + dest_x * bpp; - - - for (i = 0; i < w; i++) - { - *((unsigned short*)row) = tab16[ *p++ ]; - row += bpp; - } - } - SDL_UnlockSurface(face); - } -} - -/** - * displays the array of graphics data - * @author Hj. Malthaner - */ -void dr_textur(int xp, int yp, int w, int h) -{ - int y; - - // clipping unten - if (yp + h > tex_height) - { - h = tex_height - yp; - } - - /* debug spots - for(y=0; y<24; y++) { - int x; - - for(x=0; x<80; x++) { - if(spots[x][y]) { - printf("X"); - } else { - printf("."); - } -} - printf("\n"); -} - */ - - for (y = 0; y < SCREEN_HGT; y++) - { - const int left = 13; - const int y1 = y + 1; - int x = 0; - - yp = data[0].size_h / data[0].rows * y; - - spots[79][y1] = FALSE; - - do - { - int n = 0; - while (x + n + left < 80 && !spots[x + n + left][y1]) - { - n++; - } - - xp = data[0].size_w / data[0].cols * x; - - - flush_area(tex_xoff + xp, tex_yoff + yp, - xp, yp, - data[0].size_w / data[0].cols*(n), - data[0].size_h / data[0].rows); - - x += n; - - while (x + left < 80 && spots[x + left][y1]) - { - x++; - } - } - while (x + left < 80); - } -} - - -/** - * use this method to flush graphics pipeline (undrawn stuff) onscreen. - * @author Hj. Malthaner - */ -void dr_flush() -{ - // Iso-view for angband needs no sync. - // XSync(md,FALSE); -} - - -/** - * set colormap entries - * @author Hj. Malthaner - */ -void dr_setRGB8multi(int first, int count, unsigned char * data) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * display/hide mouse pointer - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void show_pointer(int yesno) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * move mouse pointer - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void move_pointer(int x, int y) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * update softpointer position - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void ex_ord_update_mx_my() -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * get events from the system - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void GetEvents() -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * get events from the system without waiting - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void GetEventsNoWait() -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * @returns time since progrma start in milliseconds - * @author Hj. Malthaner - */ -long long dr_time(void) -{ - // Hajo: - // unused in isov-x11 - return 0; -} - - -/** - * sleeps some microseconds - * @author Hj. Malthaner - */ -void dr_sleep(unsigned long usec) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * loads a sample - * @return a handle for that sample or -1 on failure - * @author Hj. Malthaner - */ -int dr_load_sample(const char *filename) -{ - // Hajo: - // unused in isov-x11 - return TRUE; -} - - -/** - * plays a sample - * @param key the key for the sample to be played - * @author Hj. Malthaner - */ -void dr_play_sample(int key, int volume) -{ - // Hajo: - // unused in isov-x11 -} - -static unsigned char ** halloc(int w, int h) -{ - unsigned char **field = (unsigned char **)malloc(sizeof(unsigned char *) * h); - int i; - - for (i = 0; i < h; i++) - { - field[i] = (unsigned char *)malloc(sizeof(unsigned char) * w); - memset(field[i], 32 , w); - } - - return field; -} - -/** - * spot array access procedure. Mark text output spots - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -static void set_spots(const int x, const int y, const int n, const bool_ v) -{ - int i; - - for (i = x; i < x + n; i++) - { - spots[i][y] = v; - } -} - - -/***********************************************/ -#endif /* USE_ISO */ - - -/*** Function hooks needed by "Term" ***/ - -static void Term_init_sdl(term *t) -{ - term_data *td = (term_data*)(t->data); - DB("Term_init_sdl"); - /* XXX XXX XXX */ -} - -static void Term_nuke_sdl(term *t) -{ - term_data *td = (term_data*)(t->data); - DB("Term_nuke_sdl"); - /* XXX XXX XXX */ -} - -static errr Term_user_sdl(int n) -{ - term_data *td = (term_data*)(Term->data); - DB("Term_user_sdl"); - /* XXX XXX XXX */ - - /* Unknown */ - return (1); -} - -/* KEYPRESS_STRING repeatedly sends characters to the terminal -XXX - should implement routine from maim-sdl.c, it's sooo much -cleaner */ -#define KEYPRESS_STRING(str) \ -strcpy(buf,str); \ -n = buf; \ -while (*n != '\0') { \ - Term_keypress((int)(*(n++))); \ -} - -/* This is the main event handling routine that will be called -whenever an event is pulled off of the queue (in Term_xtra_sdl())*/ -void handleEvent(SDL_Event *event) -{ - static char buf[24]; /* a buffer used when passing key names */ - char *n; /* and a pointer to manipulate this buffer */ - - switch( event->type ) - { - case SDL_KEYDOWN: - { - /* handle key presses */ - - /* I'm reading that as long as the upper 9 bits of the unicode - * value are zero, then the lower 7 bits are direct ASCII characters. - * Furthermore, it seems that all basic keys return non-zero values - * for the lower 7 bits, but function keys and other various things - * return 0000000 for the lower 7 bits. - * Basically, if the lower 7 bits are zero, do something special - * (like start a macro), but otherwise just pass along the ASCII - * code! - */ - byte ascii_part = event->key.keysym.unicode & 0x00ff; - - /* gimme the key name */ - printf("Key is: %s\n",SDL_GetKeyName(event->key.keysym.sym)); - - /* allow for full screen toggling! */ - if ((event->key.keysym.sym == SDLK_RETURN) && \ - (SDL_GetModState() & KMOD_ALT)) - { - SDL_WM_ToggleFullScreen(screen); - } -#ifdef USE_ISO - /* toggle tile size */ - if (event->key.keysym.sym == SDLK_SCROLLOCK) - { - switch (display_get_tile_size()) - { - case 32: - display_select_tile_size(0); - break; - case 64: - display_select_tile_size(1); - break; - default: - display_select_tile_size(0); - break; - } - reset_visuals(); - strcpy(buf, "graf-iso.prf"); - process_pref_file(buf); - refresh_display(); - SDL_UpdateRect(screen, 0, 0, data[0].size_w, data[0].size_h); - } - - /* cycle grid type none/objects+monsters only/full */ - if ((event->key.keysym.sym == '#') && \ - (SDL_GetModState() & KMOD_ALT)) - { - set_grid(get_grid()+1); - refresh_display(); - } - -#endif - - /*printf("ascii_part: %d\n",ascii_part);*/ - if (ascii_part) - { - /* We have now determined that the ASCII part is not '0', so - we can safely pass along the ASCII value! */ - Term_keypress(ascii_part); - } - else - { - /* We want to ignore keypresses that are simply the modifier - keys*/ - if (!( (event->key.keysym.sym == SDLK_RSHIFT) | - (event->key.keysym.sym == SDLK_LSHIFT) | - (event->key.keysym.sym == SDLK_RALT) | - (event->key.keysym.sym == SDLK_LALT) | - (event->key.keysym.sym == SDLK_RCTRL) | - (event->key.keysym.sym == SDLK_LCTRL) )) - { - - /* now build a macro string using the modifiers together - with the key that was just pressed*/ - - /* As for the formatting... - * We pass the key press and modifiers as follows: - * \[ctrl-alt-shift-"key name"] - * following the previously established convention... - * - * All of the things that happen are defined in pref-sdl.prf - */ - - KEYPRESS_STRING("\["); /*Output the first part... */ - /* See if a control key is down */ - if (event->key.keysym.mod & KMOD_CTRL) - { - KEYPRESS_STRING("ctrl-"); - } - /* See if an alt key is down */ - if (event->key.keysym.mod & KMOD_ALT) - { - KEYPRESS_STRING("alt-"); - } - /* See if a shift key is down */ - if (event->key.keysym.mod & KMOD_SHIFT) - { - KEYPRESS_STRING("shift-"); - } - - /* Add in the name of whatever key was pressed */ - KEYPRESS_STRING(SDL_GetKeyName(event->key.keysym.sym)); - - /* and end it... */ - KEYPRESS_STRING("]"); - } - } - break; - } - case SDL_QUIT: - { - /* handle quit requests */ - sdl_quit("Quitting!\n"); - break; - } - default: - { - break; - } - } -} - -static errr Term_xtra_sdl(int n, int v) -{ - static SDL_Event event; - term_data *td; - char buf[1024]; - - /* Analyze */ - switch (n) - { - case TERM_XTRA_EVENT: - { - if (v) - { - /* Perform event checking with blocking */ - SDL_WaitEvent( &event ); - handleEvent( &event ); - } else { - /* Perform event checking without blocking */ - if (SDL_PollEvent(&event)){ - /* We found an event! */ - handleEvent(&event); - } - } - return(0); - } - - case TERM_XTRA_FLUSH: - { - /* Keep doing events until the queue is empty! */ - while (SDL_PollEvent(&event)) - { - handleEvent(&event); - } - return (0); - } - - case TERM_XTRA_CLEAR: - { - /* Perform a full screen clear; redraw the sub-window borders.*/ - static SDL_Rect base; - base.x = 0; - base.y = 0; - base.w = arg_width; - base.h = arg_height; - - td = (term_data*)(Term->data); - - /* Lock the screen */ - if (SDL_MUSTLOCK(screen) ){ - if (SDL_LockSurface(screen) < 0) { - printf("Can't lock the screen: %s\n", SDL_GetError()); - exit(1); - } - } - - /* blank the screen area */ - SDL_FillRect(screen, &base, screen_black); - - /* Unlock the screen */ - if (SDL_MUSTLOCK(screen) ){ - SDL_UnlockSurface(screen); - } - - /* And... UPDATE the whole screen */ - SDL_Flip(screen); - - return (0); - } - - case TERM_XTRA_SHAPE: - { - /* - * Set the cursor visibility XXX XXX XXX - * - * This action should change the visibility of the cursor, - * if possible, to the requested value (0=off, 1=on) - * - * This action is optional, but can improve both the - * efficiency (and attractiveness) of the program. - */ - - return (0); - } - - case TERM_XTRA_FROSH: - { - /* - * Flush a row of output XXX XXX XXX - * - * This action should make sure that row "v" of the "output" - * to the window will actually appear on the window. - * - * This action is optional, assuming that "Term_text_xxx()" - * (and similar functions) draw directly to the screen, or - * that the "TERM_XTRA_FRESH" entry below takes care of any - * necessary flushing issues. - */ - - return (1); - } - - case TERM_XTRA_FRESH: - { - /* - * Flush output XXX XXX XXX - * - * This action should make sure that all "output" to the - * window will actually appear on the window. - * - * This action is optional, assuming that "Term_text_xxx()" - * (and similar functions) draw directly to the screen, or - * that the "TERM_XTRA_FROSH" entry above takes care of any - * necessary flushing issues. - */ -#ifdef USE_ISO - // Hajo: - // refresh the graphical view - - refresh_display(); - SDL_UpdateRect(screen, 0, 0, data[0].size_w, data[0].size_h); -// SDL_UpdateRect(td->face, 0, 0, 80*td->w, 24*td->h); -#endif /* USE_ISO */ - return (1); - } - - case TERM_XTRA_NOISE: - { - /* - * Make a noise XXX XXX XXX - * - * This action should produce a "beep" noise. - * - * This action is optional, but convenient. - */ - - return (1); - } - - case TERM_XTRA_SOUND: - { - /* - * Make a sound XXX XXX XXX - * - * This action should produce sound number "v", where the - * "name" of that sound is "sound_names[v]". This method - * is still under construction. - * - * This action is optional, and not very important. - */ - - return (1); - } - - case TERM_XTRA_BORED: - { - /* Perform event checking without blocking */ - if (SDL_PollEvent(&event)){ - /* We found an event! */ - handleEvent(&event); - } - return(0); - } - - case TERM_XTRA_REACT: - { - /* - * React to global changes XXX XXX XXX - * - * For example, this action can be used to react to - * changes in the global "color_table[256][4]" array. - * - * This action is optional, but can be very useful for - * handling "color changes" and the "arg_sound" and/or - * "arg_graphics" options. - */ -#ifdef USE_ISO - strcpy(buf, "graf-iso.prf"); - process_pref_file(buf); -#endif /* USE_ISO */ - return (1); - } - - case TERM_XTRA_ALIVE: - { - /* - * Change the "hard" level XXX XXX XXX - * - * This action is used if the program changes "aliveness" - * by being either "suspended" (v=0) or "resumed" (v=1) - * This action is optional, unless the computer uses the - * same "physical screen" for multiple programs, in which - * case this action should clean up to let other programs - * use the screen, or resume from such a cleaned up state. - * - * This action is currently only used by "main-gcu.c", - * on UNIX machines, to allow proper "suspending". - */ - - return (1); - } - - case TERM_XTRA_LEVEL: - { - /* - * Change the "soft" level XXX XXX XXX - * - * This action is used when the term window changes "activation" - * either by becoming "inactive" (v=0) or "active" (v=1) - * - * This action can be used to do things like activate the proper - * font / drawing mode for the newly active term window. This - * action should NOT change which window has the "focus", which - * window is "raised", or anything like that. - * - * This action is optional if all the other things which depend - * on what term is active handle activation themself, or if only - * one "term_data" structure is supported by this file. - */ - - return (1); - } - - case TERM_XTRA_DELAY: - { - /* - * Delay for some milliseconds XXX XXX XXX - * - * This action is useful for proper "timing" of certain - * visual effects, such as breath attacks. - * - * This action is optional, but may be required by this file, - * especially if special "macro sequences" must be supported. - */ - - /* I think that this command is system independent... */ - /*sleep(v/1000);*/ - /* main-x11 uses usleep(1000*v); */ - /* main-win uses Sleep(v); */ - return (1); - } - - case TERM_XTRA_GET_DELAY: - { - /* - * Get Delay of some milliseconds XXX XXX XXX - * place the result in Term_xtra_long - * - * This action is useful for proper "timing" of certain - * visual effects, such as recording cmovies. - * - * This action is optional, but cmovies wont perform - * good without it - */ - - return (1); - } - } - - /* Unknown or Unhandled action */ - return (1); -} - -#define TYPECOLOR(i) printf(" R:%d\tG:%d\tB:%d\tA:%d\t\n",\ - color_data[i]>>24,(color_data[i]&0x00ff0000)>>16,\ - (color_data[i]&0x0000ff00)>>8,(color_data[i]&0x000000ff)); -/* - * Display the cursor - * - * This routine should display the cursor at the given location - * (x,y) in some manner. On some machines this involves actually - * moving the physical cursor, on others it involves drawing a fake - * cursor in some form of graphics mode. Note the "soft_cursor" - * flag which tells "z-term.c" to treat the "cursor" as a "visual" - * thing and not as a "hardware" cursor. - * - * You may assume "valid" input if the window is properly sized. - * - * You may use the "Term_grab(x, y, &a, &c)" function, if needed, - * to determine what attr/char should be "under" the new cursor, - * for "inverting" purposes or whatever. - */ -static errr Term_curs_sdl(int x, int y) -{ - term_data *td = (term_data*)(Term->data); - DB("Term_curs_sdl"); - /* XXX XXX XXX */ -#ifdef USE_ISO - highlite_spot(x, y); -#endif - - /* Success */ - return (0); -} - - -/* - * Erase some characters - * - * This function should erase "n" characters starting at (x,y). - * - * You may assume "valid" input if the window is properly sized. - */ -static errr Term_wipe_sdl(int x, int y, int n) -{ - static SDL_Rect base; - term_data *td = (term_data*)(Term->data); - DB("Wiping"); - /* calculate boundaries of the area to clear */ - base.x = td->pos_x + x*t_width; - base.y = td->pos_y + y*t_height; - base.w = n*t_width; - base.h = t_height; - - /* Lock the screen */ - if (SDL_MUSTLOCK(screen) ){ - if (SDL_LockSurface(screen) < 0) { - printf("Can't lock the screen: %s\n", SDL_GetError()); - sdl_quit("Bah"); - } - } - - /* blank the screen area */ - SDL_FillRect(screen, &base, screen_black); - - /* Unlock the screen */ - if (SDL_MUSTLOCK(screen) ){ - SDL_UnlockSurface(screen); - } - - /* And... UPDATE the rectangle we just wrote to! */ - SDL_UpdateRects(screen,1,&base); - - /* Success */ - return (0); -} - - -/* - * Draw some text on the screen - * - * This function should actually display an array of characters - * starting at the given location, using the given "attribute", - * and using the given string of characters, which contains - * exactly "n" characters and which is NOT null-terminated. - * - * You may assume "valid" input if the window is properly sized. - * - * You must be sure that the string, when written, erases anything - * (including any visual cursor) that used to be where the text is - * drawn. On many machines this happens automatically, on others, - * you must first call "Term_wipe_xxx()" to clear the area. - * - * In color environments, you should activate the color contained - * in "color_data[a & 0x0F]", if needed, before drawing anything. - * - * You may ignore the "attribute" if you are only supporting a - * monochrome environment, since this routine is normally never - * called to display "black" (invisible) text, including the - * default "spaces", and all other colors should be drawn in - * the "normal" color in a monochrome environment. - * - * Note that if you have changed the "attr_blank" to something - * which is not black, then this function must be able to draw - * the resulting "blank" correctly. - * - * Note that this function must correctly handle "black" text if - * the "always_text" flag is set, if this flag is not set, all the - * "black" text will be handled by the "Term_wipe_xxx()" hook. - */ -static errr Term_text_sdl(int x, int y, int n, byte a, const char *cp) -{ - term_data *td = (term_data*)(Term->data); - static SDL_Rect base; - SDL_Rect base_back; - int i = n; - char old = 0; - - /* calculate place to clear off and draw to */ - base.x = td->pos_x + x*t_width; - base.y = td->pos_y + y*t_height; - base.w = n*t_width; - base.h = t_height; - - base_back = base; - - /* Lock the screen */ - if (SDL_MUSTLOCK(screen) ){ - if (SDL_LockSurface(screen) < 0) { - printf("Can't lock the screen: %s\n", SDL_GetError()); - sdl_quit("Bah"); - } - } - - /* blank the screen area */ - SDL_FillRect(screen, &base, screen_black); - - /* Unlock the screen */ - if (SDL_MUSTLOCK(screen) ){ - SDL_UnlockSurface(screen); - } - - /* Note that SDL docs specify that SDL_BlitSurface should not be called - on locked surfaces... since the character printing routine below revolves - around blitting, the surface has been unlocked first*/ - - /* loop through the input string, drawing characters */ - i = n; - old = 0; - while (i--) - { - /* Output the character... */ - /* If character has not changed, then just blit the old surface into - the new location to save effort*/ - if (*cp == old) - { - /* the desired character/color combo is already on the work surf */ - /* just blit it! */ - SDL_BlitSurface(worksurf,NULL,screen,&base); - } else { - /* copy the desired character onto working surface */ - SDL_BlitSurface(text[*cp],NULL,worksurf,NULL); - /* color our crayon surface with the desired color */ - SDL_FillRect(crayon,NULL,color_data[a&0x0f]); - /* apply the color to the character on the working surface */ - SDL_BlitSurface(crayon,NULL,worksurf,NULL); - /* and blit it onto our screen! */ - SDL_BlitSurface(worksurf,NULL,screen,&base); - } - /* Move to the next position */ - base.x += t_width; - /* Store the old character */ - old = *cp; - /* Increment the character pointer */ - cp++; - } - - // And... UPDATE the rectangle we just wrote to! - SDL_UpdateRects(screen,1,&base_back); - -#ifdef USE_ISO - if (a < 16) - { - set_spots(x, y, n, TRUE); - } - else - { - set_spots(x, y, n, FALSE); - } -#endif /* USE_ISO */ - - /* Success */ - return (0); -} - -/* - * Draw some attr/char pairs on the screen - * - * This routine should display the given "n" attr/char pairs at - * the given location (x,y). This function is only used if one - * of the flags "always_pict" or "higher_pict" is defined. - * - * You must be sure that the attr/char pairs, when displayed, will - * erase anything (including any visual cursor) that used to be at - * the given location. On many machines this is automatic, but on - * others, you must first call "Term_wipe_xxx(x, y, 1)". - * - * With the "higher_pict" flag, this function can be used to allow - * the display of "pseudo-graphic" pictures, for example, by using - * the attr/char pair as an encoded index into a pixmap of special - * "pictures". - * - * With the "always_pict" flag, this function can be used to force - * every attr/char pair to be drawn by this function, which can be - * very useful if this file can optimize its own display calls. - * - * This function is often associated with the "arg_graphics" flag. - * - * This function is only used if one of the "higher_pict" and/or - * "always_pict" flags are set. - */ -#ifndef USE_ISO -static errr Term_pict_sdl(int x, int y, int n, const byte *ap, const char *cp) -{ - term_data *td = (term_data*)(Term->data); - DB("Term_pict_sdl"); - /* XXX XXX XXX */ -#else -// for ISO-view we need USE_TRANSPARENCY and USE_EGO_GRAPHICS defined -static errr Term_pict_sdl(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp, const byte *eap, const char *ecp) -{ - /* Hajo: memorize output */ - memcpy(&iso_ap[y][x], ap, n); - memcpy(&iso_cp[y][x], cp, n); - memcpy(&iso_atp[y][x], tap, n); - memcpy(&iso_ctp[y][x], tcp, n); - memcpy(&iso_aep[y][x], eap, n); - memcpy(&iso_cep[y][x], ecp, n); - - // here is no text - set_spots(x, y, n, FALSE); - -#endif /* USE_ISO */ - - /* Success */ - return (0); -} - -static errr term_data_init(term_data *td, int i) -{ - term *t = &(td->t); - int x = 0; - int y = 0; - int cols = 80; - int rows = 24; - - /* Initialize the term */ - // gets: pointer to address, number of columns, number of rows, number - // of keypresses to queue up (guess 24?) - term_init(t, cols, rows, 24); - - /* Use a "soft" cursor */ - t->soft_cursor = TRUE; - - // Picture routine flags - t->always_pict = FALSE; - t->higher_pict = FALSE; - t->always_text = FALSE; - - /* Erase with "white space" */ - t->attr_blank = TERM_WHITE; - t->char_blank = ' '; - - /* Hooks */ - t->xtra_hook = Term_xtra_sdl; - t->curs_hook = Term_curs_sdl; - t->wipe_hook = Term_wipe_sdl; - t->text_hook = Term_text_sdl; -#ifdef USE_ISO - t->pict_hook = Term_pict_sdl; -#endif /* USE_ISO */ - - - /* Save the data */ - t->data = td; - - /* Activate (important) */ - Term_activate(t); - - // *** Initialize the rest of the term_data stuff.... - td->name = angband_term_name[i];// name of this term window - - td->rows = rows; - td->cols = cols; - td->pos_x = x; - td->pos_y = y; - - - td->size_w = cols*t_width; - td->size_h = rows*t_height; - - /* Turn on a border, thickness specified by BORDER_THICKNESS */ - td->has_border = TRUE; - td->border_thick = BORDER_THICKNESS; - -#ifdef USE_GRAPHICS -#ifdef USE_TRANSPARENCY -#endif -#endif - - /* Success */ - return (0); -} - -/* - * Check and create if needed the directory dirpath -- copied from main.c - */ -bool_ private_check_user_directory(cptr dirpath) -{ - /* Is this used anywhere else in *bands? */ - struct stat stat_buf; - - int ret; - - /* See if it already exists */ - ret = stat(dirpath, &stat_buf); - - /* It does */ - if (ret == 0) - { - /* Now we see if it's a directory */ - if ((stat_buf.st_mode & S_IFMT) == S_IFDIR) return (TRUE); - - /* - * Something prevents us from create a directory with - * the same pathname - */ - return (FALSE); - } - - /* No - this maybe the first time. Try to create a directory */ - else - { - /* Create the ~/.ToME directory */ - ret = mkdir(dirpath, 0700); - - /* An error occured */ - if (ret == -1) return (FALSE); - - /* Success */ - return (TRUE); - } -} - -/* - * Check existence of ".ToME/" directory in the user's - * home directory or try to create it if it doesn't exist. - * Returns FALSE if all the attempts fail. - */ -static bool_ check_create_user_dir(void) -{ - char dirpath[1024]; - char versionpath[1024]; - char savepath[1024]; - - /* Get an absolute path from the filename */ - path_parse(dirpath, 1024, PRIVATE_USER_PATH); - strcpy(versionpath, dirpath); - strcat(versionpath, USER_PATH_VERSION); - strcpy(savepath, versionpath); - strcat(savepath, "/save"); - - return private_check_user_directory(dirpath) && private_check_user_directory(versionpath) && private_check_user_directory(savepath); -} - -/* - * Init some stuff - copied from main.c - */ -static void init_stuff(void) -{ - char path[1024]; - - cptr tail; - - /* Get the environment variable */ - tail = getenv("TOME_PATH"); - - /* Use the angband_path, or a default */ -#ifndef ENABLE_BINRELOC - strcpy(path, tail ? tail : DEFAULT_PATH); -#else /* Runtime lookup of location */ - strcpy(path, br_strcat(DATADIR, "/tome/lib")); -#endif - - /* Hack -- Add a path separator (only if needed) */ - if (!suffix(path, PATH_SEP)) strcat(path, PATH_SEP); - - /* Initialize */ - init_file_paths(path); -} - - -errr init_sdl(int argc, char **argv) -{ - return 0; -} - -int main(int argc, char *argv[]) -{ - int i; - - bool_ done = FALSE; - - bool_ new_game = FALSE; - - int show_score = 0; - - cptr mstr = NULL; - - bool_ args = TRUE; - - float gamma; - char filename[PATH_MAX + 1]; - /* Flags to pass to SDL_SetVideoMode */ - int videoFlags; - /* this holds some info about our display */ - const SDL_VideoInfo *videoInfo; - - -#ifdef CHECK_MEMORY_LEAKS - GC_find_leak = 1; -#endif /* CHECK_MEMORY_LEAKS */ - - - /* Save the "program name" XXX XXX XXX */ - argv0 = argv[0]; - - -#ifdef SET_UID - - /* Default permissions on files */ - (void)umask(022); - -#endif /* SET_UID */ - - - /* Get the file paths */ - init_stuff(); - - -#ifdef SET_UID - - /* Get the user id (?) */ - player_uid = getuid(); - -# ifdef SAFE_SETUID - -# ifdef _POSIX_SAVED_IDS - - /* Save some info for later */ - player_euid = geteuid(); - player_egid = getegid(); - -# endif - -# if 0 /* XXX XXX XXX */ - - /* Redundant setting necessary in case root is running the game */ - /* If not root or game not setuid the following two calls do nothing */ - - if (setgid(getegid()) != 0) - { - sdl_quit("setgid(): cannot set permissions correctly!"); - } - - if (setuid(geteuid()) != 0) - { - sdl_quit("setuid(): cannot set permissions correctly!"); - } - -# endif /* XXX XXX XXX */ - -# endif /* SAFE_SETUID */ - -#endif /* SET_UID */ - - -#ifdef SET_UID - - /* Acquire the "user name" as a default player name */ - user_name(player_name, player_uid); - - - /* - * On multiuser systems, users' private directories are - * used to store pref files, chardumps etc. - */ - { - bool_ ret; - - /* Create a directory for the user's files */ - ret = check_create_user_dir(); - - /* Oops */ - if (ret == FALSE) sdl_quit("Cannot create directory " PRIVATE_USER_PATH); - } - -#endif /* SET_UID */ - - /* Before sdl_quit could possible be called, need to make sure that the text - array is zeroed, so that sdl_quit->killFontAndAlphabet() doesn't try to free - SDL_Surfaces that don't exist ! */ - memset(text,0,sizeof(text)); - - /* Initialize the SDL window*/ - filename[PATH_MAX] = 0; - - /* initialize SDL */ - if ( SDL_Init( SDL_INIT_VIDEO ) < 0 ) - { - sdl_quit("Video initialization failed!"); - } - DB("SDL Initialized!"); - - /* Skip to our arguments -- (Neil)*/ - /* for (i = 1; (i < argc) && (0 != strcmp(argv[i], "--")); ++i); */ - /* Handle our arguments -- (Neil)*/ - /* for (++i; i < argc ; ++i) - { - if (0 == strcmp(argv[i], "-n")) - { - if (++i == argc) - { - printf("Argument missing for option -n\n"); - return -1; - } - - arg_console_count = atoi(argv[i]); - if (arg_console_count <= 0 || arg_console_count > MAX_CONSOLE_COUNT) - { - printf("Invalid console count given.\n"); - arg_console_count = 1; - } - } - else if (0 == strcmp(argv[i], "-o")) - { - arg_old_graphics = TRUE; - } - else if (0 == strcmp(argv[i], "-b")) - { - arg_double_width = TRUE; - } - else if (0 == strcmp(argv[i], "-w")) - { - if (++i == argc) - { - printf("Argument missing for option -w\n"); - return -1; - } - - arg_width = atoi(argv[i]); - } - else if (0 == strcmp(argv[i], "-h")) - { - if (++i == argc) - { - printf("Argument missing for option -h\n"); - return -1; - } - - arg_height = atoi(argv[i]); - } - else if (0 == strcmp(argv[i], "-fs")) - { - arg_full_screen = TRUE; - } - else if (0 == strcmp(argv[i], "-bpp")) - { - if (++i == argc) - { - printf("Argument missing for option -bpp\n"); - return -1; - } - - arg_bpp = atoi(argv[i]); - } - } - */ - - - /* Now for the meat of the initialization -- (Neil)*/ - quit_aux = sdl_quit; - - /* Window Manager stuff -- (Neil)*/ - path_build(filename, PATH_MAX, ANGBAND_DIR_XTRA, "graf/icon.png"); - SDL_WM_SetIcon(IMG_Load(filename), 0); - SDL_WM_SetCaption("ToME", "tome"); - - /* how about a hardware surface with hardware palette? - XXX XXX XXX should probably be chosen at compile-time! */ - videoFlags = SDL_HWSURFACE | SDL_HWPALETTE; - - /* XXX XXX XXX */ - if(getenv("TOME_SCREEN_WIDTH")) arg_width = atoi(getenv("TOME_SCREEN_WIDTH")); - if(getenv("TOME_SCREEN_HEIGHT")) arg_height = atoi(getenv("TOME_SCREEN_HEIGHT")); - if(getenv("TOME_SCREEN_BPP")) arg_bpp = atoi(getenv("TOME_SCREEN_BPP")); - - /* get a SDL surface */ - screen = SDL_SetVideoMode( arg_width, arg_height, arg_bpp, videoFlags ); - - DB("Video Mode Set!"); - - /* Verify there is a surface */ - if ( !screen ) - { - DB("No screen!"); - sdl_quit("Failed to set SDL Surface."); - } - - DB("SDL Window Created!"); - - /* Now ready the fonts! */ - - DB("initializing SDL_ttf"); - if(TTF_Init()==-1) { - printf("TTF_Init: %s\n", TTF_GetError()); - sdl_quit("Bah"); - } - - DB("loading font..."); - /* XXX centralize these environment calls*/ - if(getenv("TOME_FONT_SIZE")) arg_font_size = atoi(getenv("TOME_FONT_SIZE")); - - /* load and render the font */ - loadAndRenderFont(arg_font_name,arg_font_size); - - /* Initialize the working surface and crayon surface used for rendering - text in different colors... */ - worksurf = SDL_CreateRGBSurface(SDL_HWSURFACE,t_width,\ - t_height,16,0xf000,0x0f00,0x00f0,0x000f); - crayon = SDL_CreateRGBSurface(SDL_HWSURFACE,t_width,\ - t_height,16,0xf000,0x0f00,0x00f0,0x000f); - - /* The working surface will blit using alpha values... */ - SDL_SetAlpha(worksurf,SDL_SRCALPHA,0); - - /* Set up the colors using the great little color macros! */ - color_data[0] = BLACK; - color_data[1] = WHITE; - color_data[2] = MID_GREY; - color_data[3] = BRIGHT_ORANGE; - color_data[4] = RED; - color_data[5] = GREEN; - color_data[6] = BRIGHT_BLUE; - color_data[7] = DARK_ORANGE; - color_data[8] = DARK_GREY; - color_data[9] = BRIGHT_GREY; - color_data[10] = PURPLE; - color_data[11] = YELLOW; - color_data[12] = BRIGHT_RED; - color_data[13] = BRIGHT_GREEN; - color_data[14] = AQUAMARINE; - color_data[15] = BROWN; - - /* And setup the screen black color */ - screen_black = SDL_MapRGB(screen->format,0,0,0); - screen_white = SDL_MapRGB(screen->format,255,255,255); - - /* Initialize the windows, or whatever that means in this case */ - for (i = 0; i < MAX_CONSOLE_COUNT; i++) - { - term_data *td = &data[i]; - - /* Initialize the term_data */ - term_data_init(td, i); - /* Save global entry */ - angband_term[i] = Term; - } - - /* Enable UNICODE keysyms */ - SDL_EnableUNICODE(1); - - /* By setting this value, 'pref-sdl.prf' will be loaded on start. - Since this contains mappings for various keys, this is important! */ - ANGBAND_SYS = "sdl"; -#ifdef USE_ISO - DB("Isometric view uses always graphics mode.\n"); - use_graphics = TRUE; - - - /* Hajo: allocate memory for output data */ - /* These arrays are read by the iso-view and written from this file */ - iso_cp = halloc(data[0].t.wid, data[0].t.hgt); - iso_ap = halloc(data[0].t.wid, data[0].t.hgt); - iso_ctp = halloc(data[0].t.wid, data[0].t.hgt); - iso_atp = halloc(data[0].t.wid, data[0].t.hgt); - iso_cep = halloc(data[0].t.wid, data[0].t.hgt); - iso_aep = halloc(data[0].t.wid, data[0].t.hgt); - - // Hmm, no ANGBAND_SYS in old iso-code - // if I change this I don't have to load the *.prf manually? - // - // seems not to work for the following: - /* Hajo: set mode */ - ANGBAND_GRAF = "iso"; - - /* Hajo: init view */ - init_adaptor(); - - center_player = TRUE; -#endif /* USE_ISO */ - - printf("Signals?\n"); - - /* Catch nasty signals */ - signals_init(); - - printf("Initialize Angband!\n"); - /* Initialize */ - init_angband(); - - printf("Angband Initialized!\n"); - - /* Hack -- If requested, display scores and quit */ - if (show_score > 0) display_scores(0, show_score); - - /* Wait for response */ - pause_line(23); - - printf("Play the game!\n"); -#ifdef USE_ISO - // Juergen: HACK, but this all is just for testing ... - data[0].t.higher_pict = TRUE; -#endif - - /* Play the game */ - play_game(new_game); - - /* Quit */ - sdl_quit("Game over, man"); - - /* Exit */ - return (0); - -} - -#endif diff --git a/src/main-sdl.c b/src/main-sdl.c index 4e9adb4f..c3bff0f9 100644 --- a/src/main-sdl.c +++ b/src/main-sdl.c @@ -32,64 +32,6 @@ #include <math.h> -#ifdef USE_ISO -/* - * Simugraph system (Hj. Malthaner) - */ -#include "iso/simsys.h" -#include "iso/simgraph.h" -#include "iso/world_adaptor.h" -#include "iso/world_view.h" -/* - * Simugraph specific routines - * by Hj. Malthaner - */ -#include "iso/hackdef.h" - -/* - * Text place marker function protype (Hj. Malthaner) - */ -static void set_spots(int x, int y, int n, bool_ v); - -/** - * we need to track spots with text to avoid overdrawing text with images - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -bool_ spots[80][24]; - -/** - * mouse coordinates for Simugraph engine - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int mx, my; - -/* - * Hajo: this flags need to be set when opening windows - */ - -static int tex_width; -static int tex_height; -static int tex_xoff; -static int tex_yoff; - -static unsigned int tab16[1 << 16]; - -/** - * this is used if we need to fake an 8 bit array - * @author Hj. Malthaner - */ -static unsigned short * data8; - -// buffers to store char code/attr for graphics -unsigned char **iso_ap; -unsigned char **iso_cp; -unsigned char **iso_atp; -unsigned char **iso_ctp; -unsigned char **iso_aep; -unsigned char **iso_cep; - -#endif /* USE_ISO */ - /************************************************* GLOBAL SDL-ToME PROPERTIES *************************************************/ @@ -452,406 +394,6 @@ void loadAndRenderFont(char *fname, int size) } } -#ifdef USE_ISO -/************************************************* - ISO SUPPORT FUNCTIONS - *************************************************/ -/** - * inits operating system stuff - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_os_init(int n, int *parameter) -{ - // Hajo: - // unused in isov-x11 - return TRUE; -} - - -/** - * opens graphics device/context/window of size w*h - * @param w width - * @param h height - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_os_open(int w, int h) -{ - const int left = 13; - -/* tex_width = (data[0].fd->dw * (data[0].t.wid - left + 2) + 3) & 0xFFFC; - tex_height = data[0].fd->dh * (data[0].t.hgt - 2); - - tex_xoff = data[0].fd->dw * left; - tex_yoff = data[0].fd->dh * 1 + 1; -*/ - - //tex_width = (data[0].size_w - (left - 2) * (data[0].size_w / data[0].cols) + 3) & 0xFFFC; - // this is too big (but works :-)) - tex_width = data[0].size_w & 0xfffc; - tex_height = (data[0].size_h / data[0].rows) * (data[0].rows-2); - - tex_xoff = (tex_width / data[0].cols) * left; - tex_yoff = (tex_height / data[0].rows) * 1 + 1; - - return TRUE; -} - - -/** - * closes operating system stuff - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_os_close() -{ - // Hajo: - // unused in isov-x11 - return TRUE; -} - - -/** - * retrieve display width - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_get_width() -{ - return data[0].size_w; -} - - -/** - * retrieve display height - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -int dr_get_height() -{ - return data[0].size_h; -} - - -/** - * this is used if we need to fake an 8 bit array - * @author Hj. Malthaner - */ -static unsigned short * data8; - - -/** - * creates a (maybe virtual) array of graphics data - * @author Hj. Malthaner - */ -unsigned short * dr_textur_init() -{ - int i; - - printf("isov-sdl::dr_textur_init()\n"); - printf(" width = %d\n", data[0].size_w); - printf(" height = %d\n", data[0].size_h); - - for (i = 0; i < (1 << 16); i++) - { - // FIXME!!! - // must consider color bits, or breaks in anything else but RGB 555 - unsigned int R; - unsigned int G; - unsigned int B; - - // RGB 555 - R = (i & 0x7C00) >> 10; - G = (i & 0x03E0) >> 5; - B = (i & 0x001F) >> 0; - - - tab16[i] = SDL_MapRGB(screen->format, R << 3, G << 3, B << 3); - } - - - - data8 = malloc((data[0].size_w) * (data[0].size_h) * 2); - - printf(" textur = %p\n", data8); - - // fake an 16 bit array and convert data before displaying - return data8; -} - -static void flush_area(int dest_x, int dest_y, - int x, int y, int w, int h) -{ - SDL_Surface *face = screen; - - if (SDL_LockSurface(face) == 0) - { - int i, j; - const int bpp = screen->format->BytesPerPixel; - - for (j = 0; j < h; j++) - { - unsigned short * p = data8 + (y + j) * tex_width + x; - unsigned char * row = face->pixels + (dest_y + j) * face->pitch + dest_x * bpp; - - - for (i = 0; i < w; i++) - { - *((unsigned short*)row) = tab16[ *p++ ]; - row += bpp; - } - } - SDL_UnlockSurface(face); - } -} - -/** - * displays the array of graphics data - * @author Hj. Malthaner - */ -void dr_textur(int xp, int yp, int w, int h) -{ - int y; - - // clipping unten - if (yp + h > tex_height) - { - h = tex_height - yp; - } - - /* debug spots - for(y=0; y<24; y++) { - int x; - - for(x=0; x<80; x++) { - if(spots[x][y]) { - printf("X"); - } else { - printf("."); - } -} - printf("\n"); -} - */ - - for (y = 0; y < SCREEN_HGT; y++) - { - const int left = 13; - const int y1 = y + 1; - int x = 0; - - yp = data[0].size_h / data[0].rows * y; - - spots[79][y1] = FALSE; - - do - { - int n = 0; - while (x + n + left < 80 && !spots[x + n + left][y1]) - { - n++; - } - - xp = data[0].size_w / data[0].cols * x; - - - flush_area(tex_xoff + xp, tex_yoff + yp, - xp, yp, - data[0].size_w / data[0].cols*(n), - data[0].size_h / data[0].rows); - - x += n; - - while (x + left < 80 && spots[x + left][y1]) - { - x++; - } - } - while (x + left < 80); - } -} - - -/** - * use this method to flush graphics pipeline (undrawn stuff) onscreen. - * @author Hj. Malthaner - */ -void dr_flush() -{ - // Iso-view for angband needs no sync. - // XSync(md,FALSE); -} - - -/** - * set colormap entries - * @author Hj. Malthaner - */ -void dr_setRGB8multi(int first, int count, unsigned char * data) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * display/hide mouse pointer - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void show_pointer(int yesno) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * move mouse pointer - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void move_pointer(int x, int y) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * update softpointer position - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void ex_ord_update_mx_my() -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * get events from the system - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void GetEvents() -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * get events from the system without waiting - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -void GetEventsNoWait() -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * @returns time since progrma start in milliseconds - * @author Hj. Malthaner - */ -long long dr_time(void) -{ - // Hajo: - // unused in isov-x11 - return 0; -} - - -/** - * sleeps some microseconds - * @author Hj. Malthaner - */ -void dr_sleep(unsigned long usec) -{ - // Hajo: - // unused in isov-x11 -} - - -/** - * loads a sample - * @return a handle for that sample or -1 on failure - * @author Hj. Malthaner - */ -int dr_load_sample(const char *filename) -{ - // Hajo: - // unused in isov-x11 - return TRUE; -} - - -/** - * plays a sample - * @param key the key for the sample to be played - * @author Hj. Malthaner - */ -void dr_play_sample(int key, int volume) -{ - // Hajo: - // unused in isov-x11 -} - -static unsigned char ** halloc(int w, int h) -{ - unsigned char **field = (unsigned char **)malloc(sizeof(unsigned char *) * h); - int i; - - for (i = 0; i < h; i++) - { - field[i] = (unsigned char *)malloc(sizeof(unsigned char) * w); - memset(field[i], 32 , w); - } - - return field; -} - -/** - * spot array access procedure. Mark text output spots - * @author Hj. Malthaner (hansjoerg.malthaner@gmx.de) - */ -static void set_spots(const int x, const int y, const int n, const bool_ v) -{ - int i; - - for (i = x; i < x + n; i++) - { - spots[i][y] = v; - } -} - - -/***********************************************/ -#endif /* USE_ISO */ - -/***********************************************/ - -/*** Function hooks needed by "Term" ***/ - -static void Term_init_sdl(term *t) -{ - term_data *td = (term_data*)(t->data); - DB("Term_init_sdl"); - /* XXX XXX XXX */ -} - -static void Term_nuke_sdl(term *t) -{ - term_data *td = (term_data*)(t->data); - DB("Term_nuke_sdl"); - /* XXX XXX XXX */ -} - -static errr Term_user_sdl(int n) -{ - term_data *td = (term_data*)(Term->data); - DB("Term_user_sdl"); - /* XXX XXX XXX */ - - /* Unknown */ - return (1); -} - /* KEYPRESS_STRING repeatedly sends characters to the terminal XXX - should implement routine from maim-sdl.c, it's sooo much cleaner */ @@ -909,39 +451,6 @@ void handleEvent(SDL_Event *event) manipulationMode(); } -#ifdef USE_ISO - /* toggle tile size */ - if (event->key.keysym.sym == SDLK_SCROLLOCK) - { - switch (display_get_tile_size()) - { - case 32: - display_select_tile_size(0); - break; - case 64: - display_select_tile_size(1); - break; - default: - display_select_tile_size(0); - break; - } - reset_visuals(); - strcpy(buf, "graf-iso.prf"); - process_pref_file(buf); - refresh_display(); - SDL_UpdateRect(screen, 0, 0, data[0].size_w, data[0].size_h); - } - - /* cycle grid type none/objects+monsters only/full */ - if ((event->key.keysym.sym == '#') && \ - (SDL_GetModState() & KMOD_ALT)) - { - set_grid(get_grid()+1); - refresh_display(); - } - -#endif - /*printf("ascii_part: %d\n",ascii_part);*/ if (ascii_part) { @@ -1107,14 +616,6 @@ static errr Term_xtra_sdl(int n, int v) * necessary flushing issues. */ -#ifdef USE_ISO - // Hajo: - // refresh the graphical view - - refresh_display(); - SDL_UpdateRect(screen, 0, 0, data[0].size_w, data[0].size_h); -// SDL_UpdateRect(td->face, 0, 0, 80*td->w, 24*td->h); -#else /* regular SDL */ /* If terminal display has been held for any reason, then update the whole thing now!*/ DB("TERM_XTRA_FRESH"); @@ -1125,7 +626,6 @@ static errr Term_xtra_sdl(int n, int v) suspendUpdate = FALSE; drawTermStuff(td,NULL); } -#endif /* USE_ISO */ return (0); } @@ -1179,10 +679,6 @@ static errr Term_xtra_sdl(int n, int v) * handling "color changes" and the "arg_sound" and/or * "arg_graphics" options. */ -#ifdef USE_ISO - strcpy(buf, "graf-iso.prf"); - process_pref_file(buf); -#endif /* USE_ISO */ return (1); } @@ -1541,9 +1037,6 @@ void createCursor(byte r, byte g, byte b, byte a) surface onto the correct location */ static errr Term_curs_sdl(int x, int y) { -#ifdef USE_ISO - highlite_spot(x, y); -#else /* regular SDL */ term_data *td = (term_data*)(Term->data); static SDL_Rect base; @@ -1560,7 +1053,6 @@ static errr Term_curs_sdl(int x, int y) /* Now draw to the main screen */ drawTermStuff(td,&base); -#endif /* USE_ISO */ /* Success */ return (0); } @@ -1662,16 +1154,6 @@ void eraseTerminal(void) */ static errr Term_text_sdl(int x, int y, int n, byte a, const char *cp) { -#ifdef USE_ISO - if (a < 16) - { - set_spots(x, y, n, TRUE); - } - else - { - set_spots(x, y, n, FALSE); - } -#else term_data *td = (term_data*)(Term->data); static SDL_Rect base; SDL_Rect base_back; @@ -1731,60 +1213,6 @@ static errr Term_text_sdl(int x, int y, int n, byte a, const char *cp) /* And update */ drawTermStuff(td,&base_back); -#endif /* USE_ISO */ - /* Success */ - return (0); -} - -/* - * Draw some attr/char pairs on the screen - * - * This routine should display the given "n" attr/char pairs at - * the given location (x,y). This function is only used if one - * of the flags "always_pict" or "higher_pict" is defined. - * - * You must be sure that the attr/char pairs, when displayed, will - * erase anything (including any visual cursor) that used to be at - * the given location. On many machines this is automatic, but on - * others, you must first call "Term_wipe_xxx(x, y, 1)". - * - * With the "higher_pict" flag, this function can be used to allow - * the display of "pseudo-graphic" pictures, for example, by using - * the attr/char pair as an encoded index into a pixmap of special - * "pictures". - * - * With the "always_pict" flag, this function can be used to force - * every attr/char pair to be drawn by this function, which can be - * very useful if this file can optimize its own display calls. - * - * This function is often associated with the "arg_graphics" flag. - * - * This function is only used if one of the "higher_pict" and/or - * "always_pict" flags are set. - */ -#ifndef USE_ISO -static errr Term_pict_sdl(int x, int y, int n, const byte *ap, const char *cp) -{ - term_data *td = (term_data*)(Term->data); - DB("Term_pict_sdl"); - /* XXX XXX XXX */ - -#else -// for ISO-view we need USE_TRANSPARENCY and USE_EGO_GRAPHICS defined -static errr Term_pict_sdl(int x, int y, int n, const byte *ap, const char *cp, const byte *tap, const char *tcp, const byte *eap, const char *ecp) -{ - /* Hajo: memorize output */ - memcpy(&iso_ap[y][x], ap, n); - memcpy(&iso_cp[y][x], cp, n); - memcpy(&iso_atp[y][x], tap, n); - memcpy(&iso_ctp[y][x], tcp, n); - memcpy(&iso_aep[y][x], eap, n); - memcpy(&iso_cep[y][x], ecp, n); - - // here is no text - set_spots(x, y, n, FALSE); - -#endif /* USE_ISO */ /* Success */ return (0); } @@ -2438,9 +1866,6 @@ static errr term_data_init(term_data *td, int i) t->curs_hook = Term_curs_sdl; t->wipe_hook = Term_wipe_sdl; t->text_hook = Term_text_sdl; -#ifdef USE_ISO - t->pict_hook = Term_pict_sdl; -#endif /* USE_ISO */ /* Save the data */ t->data = td; @@ -2826,38 +2251,6 @@ errr init_sdl(int argc, char **argv) /* Enable key repeat! */ SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL); - #ifdef USE_ISO - DB("Isometric view uses always graphics mode.\n"); - use_graphics = TRUE; - - - /* Hajo: allocate memory for output data */ - /* These arrays are read by the iso-view and written from this file */ - iso_cp = halloc(data[0].t.wid, data[0].t.hgt); - iso_ap = halloc(data[0].t.wid, data[0].t.hgt); - iso_ctp = halloc(data[0].t.wid, data[0].t.hgt); - iso_atp = halloc(data[0].t.wid, data[0].t.hgt); - iso_cep = halloc(data[0].t.wid, data[0].t.hgt); - iso_aep = halloc(data[0].t.wid, data[0].t.hgt); - - // Hmm, no ANGBAND_SYS in old iso-code - // if I change this I don't have to load the *.prf manually? - // - // seems not to work for the following: - /* Hajo: set mode */ - ANGBAND_GRAF = "iso"; - - /* Hajo: init view */ - init_adaptor(); - - center_player = TRUE; -#endif /* USE_ISO */ - -#ifdef USE_ISO - // Juergen: HACK, but this all is just for testing ... - data[0].t.higher_pict = TRUE; -#endif - /* main-sdl initialized! */ return 0; } @@ -573,10 +573,6 @@ usage: puts(" -msla To use SLang"); #endif /* USE_SLA */ -#ifdef USE_ISO - puts(" -miso To use ISO"); -#endif /* USE_ISO */ - #ifdef USE_SDL puts(" -msdl To use SDL"); puts(" -- Sub options"); @@ -759,19 +755,6 @@ usage: } #endif -#ifdef USE_ISO - /* Attempt to use the "main-iso.c" support */ - if (!done && (!mstr || (streq(mstr, "iso")))) - { - extern errr init_iso(int, char**); - if (0 == init_iso(argc, argv)) - { - ANGBAND_SYS = "iso"; - done = TRUE; - } - } -#endif - #ifdef USE_LUA_GUI /* Attempt to use the "main-lua.c" support */ if (!done && (!mstr || (streq(mstr, "lua")))) |