summaryrefslogtreecommitdiff
path: root/apps/plugins/doom/r_data.c
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2006-04-02 01:52:44 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2006-04-02 01:52:44 +0000
commit51db2d3f2cfddfb1c94de1085d130c817bcd953f (patch)
treea8452577070b7febf0ec640d2a065cd7e2c89847 /apps/plugins/doom/r_data.c
parente61b079c26e5eaa12f403da6964ac20282df248e (diff)
downloadrockbox-51db2d3f2cfddfb1c94de1085d130c817bcd953f.tar.gz
rockbox-51db2d3f2cfddfb1c94de1085d130c817bcd953f.zip
Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9418 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/doom/r_data.c')
-rw-r--r--apps/plugins/doom/r_data.c151
1 files changed, 82 insertions, 69 deletions
diff --git a/apps/plugins/doom/r_data.c b/apps/plugins/doom/r_data.c
index aad16e4d95..1d5c6ad272 100644
--- a/apps/plugins/doom/r_data.c
+++ b/apps/plugins/doom/r_data.c
@@ -63,7 +63,8 @@ typedef struct
63 short patch; 63 short patch;
64 short stepdir; // unused in Doom but might be used in Phase 2 Boom 64 short stepdir; // unused in Doom but might be used in Phase 2 Boom
65 short colormap; // unused in Doom but might be used in Phase 2 Boom 65 short colormap; // unused in Doom but might be used in Phase 2 Boom
66} PACKEDATTR mappatch_t; 66}
67PACKEDATTR mappatch_t;
67 68
68typedef struct 69typedef struct
69{ 70{
@@ -74,7 +75,8 @@ typedef struct
74 char pad[4]; // unused in Doom but might be used in Boom Phase 2 75 char pad[4]; // unused in Doom but might be used in Boom Phase 2
75 short patchcount; 76 short patchcount;
76 mappatch_t patches[1]; 77 mappatch_t patches[1];
77} PACKEDATTR maptexture_t; 78}
79PACKEDATTR maptexture_t;
78 80
79// A maptexturedef_t describes a rectangular texture, which is composed 81// A maptexturedef_t describes a rectangular texture, which is composed
80// of one or more mappatch_t structures that arrange graphic patches. 82// of one or more mappatch_t structures that arrange graphic patches.
@@ -247,7 +249,8 @@ static void R_GenerateLookup(int texnum, int *const errors)
247 249
248 struct { 250 struct {
249 unsigned short patches, posts; 251 unsigned short patches, posts;
250 } *count = calloc(sizeof *count, texture->width); 252 }
253 *count = calloc(sizeof *count, texture->width);
251 254
252 { 255 {
253 int i = texture->patchcount; 256 int i = texture->patchcount;
@@ -300,9 +303,11 @@ static void R_GenerateLookup(int texnum, int *const errors)
300 { 303 {
301 //jff 8/3/98 use logical output routine 304 //jff 8/3/98 use logical output routine
302 printf("\nR_GenerateLookup: Column %d is without a patch in texture %s", 305 printf("\nR_GenerateLookup: Column %d is without a patch in texture %s",
303 x, texture->name); 306 x, texture->name);
304 if (errors) ++*errors; 307 if (errors)
305 else I_Error("R_GenerateLookup: Failed"); 308 ++*errors;
309 else
310 I_Error("R_GenerateLookup: Failed");
306 } 311 }
307 if (count[x].patches > 1) // killough 4/9/98 312 if (count[x].patches > 1) // killough 4/9/98
308 { 313 {
@@ -333,7 +338,8 @@ static void R_GenerateLookup(int texnum, int *const errors)
333const byte *R_GetColumn(int tex, int col) 338const byte *R_GetColumn(int tex, int col)
334{ 339{
335 const texture_t *texture = textures[tex]; 340 const texture_t *texture = textures[tex];
336 if (!texture->columnlump) R_GenerateLookup(tex, NULL); 341 if (!texture->columnlump)
342 R_GenerateLookup(tex, NULL);
337 { 343 {
338 int lump = texture->columnlump[col &= texture->widthmask]; 344 int lump = texture->columnlump[col &= texture->widthmask];
339 int ofs = texture->columnofs[col]; // cph - WARNING: must be after the above line 345 int ofs = texture->columnofs[col]; // cph - WARNING: must be after the above line
@@ -345,7 +351,8 @@ const byte *R_GetColumn(int tex, int col)
345 if ((lump<=0) && (lastlump<=0)) 351 if ((lump<=0) && (lastlump<=0))
346 lump = lastlump; // cph - force equal 352 lump = lastlump; // cph - force equal
347 353
348 if (lump != lastlump) { 354 if (lump != lastlump)
355 {
349 // cph - must change the cached lump 356 // cph - must change the cached lump
350 if (lastlump>0) 357 if (lastlump>0)
351 W_UnlockLumpNum(lastlump); 358 W_UnlockLumpNum(lastlump);
@@ -353,9 +360,11 @@ const byte *R_GetColumn(int tex, int col)
353 if ((lastlump = lump) > 0) 360 if ((lastlump = lump) > 0)
354 lastlumpdata = W_CacheLumpNum(lump); 361 lastlumpdata = W_CacheLumpNum(lump);
355#ifdef RANGECHECK 362#ifdef RANGECHECK
363
356 else 364 else
357 lastlumpdata = NULL; 365 lastlumpdata = NULL;
358#endif 366#endif
367
359 } 368 }
360 369
361 if (lump > 0) 370 if (lump > 0)
@@ -533,12 +542,13 @@ void R_InitTextures (void)
533 { 542 {
534 //jff 8/3/98 use logical output routine 543 //jff 8/3/98 use logical output routine
535 printf("\nR_InitTextures: Missing patch %d in texture %s", 544 printf("\nR_InitTextures: Missing patch %d in texture %s",
536 SHORT(mpatch->patch), texture->name); // killough 4/17/98 545 SHORT(mpatch->patch), texture->name); // killough 4/17/98
537 ++errors; 546 ++errors;
538 } 547 }
539 } 548 }
540 549
541 texture->columnofs = NULL; texture->columnlump = NULL; 550 texture->columnofs = NULL;
551 texture->columnlump = NULL;
542 552
543 for (j=1; j*2 <= texture->width; j<<=1) 553 for (j=1; j*2 <= texture->width; j<<=1)
544 ; 554 ;
@@ -687,7 +697,8 @@ int R_ColormapNumForName(const char *name)
687struct _cache { 697struct _cache {
688 unsigned char pct; 698 unsigned char pct;
689 unsigned char playpal[256]; 699 unsigned char playpal[256];
690} cache; 700}
701cache;
691 702
692int tran_filter_pct = 66; // filter percent 703int tran_filter_pct = 66; // filter percent
693 704
@@ -712,10 +723,10 @@ void R_InitTranMap(int progress)
712 // Use cached translucency filter if it's available 723 // Use cached translucency filter if it's available
713 724
714 if ((cachefd<0) ? cachefd = open(GAMEBASE"tranmap.dat",O_WRONLY | O_CREAT) , 1 : 725 if ((cachefd<0) ? cachefd = open(GAMEBASE"tranmap.dat",O_WRONLY | O_CREAT) , 1 :
715 read(cachefd, &cache, sizeof(cache)) != sizeof(cache) || 726 read(cachefd, &cache, sizeof(cache)) != sizeof(cache) ||
716 cache.pct != tran_filter_pct || 727 cache.pct != tran_filter_pct ||
717 memcmp(cache.playpal, playpal, sizeof cache.playpal) || 728 memcmp(cache.playpal, playpal, sizeof cache.playpal) ||
718 read(cachefd, my_tranmap, 256*256) != 256*256 ) // killough 4/11/98 729 read(cachefd, my_tranmap, 256*256) != 256*256 ) // killough 4/11/98
719 { 730 {
720 731
721 long *stackdeath=malloc(256*7*sizeof(long)); // This was a bunch of static varibles, way too big for rockbox 732 long *stackdeath=malloc(256*7*sizeof(long)); // This was a bunch of static varibles, way too big for rockbox
@@ -733,7 +744,7 @@ void R_InitTranMap(int progress)
733 if (progress) 744 if (progress)
734 printf("Please wait: Tranmap build"); 745 printf("Please wait: Tranmap build");
735 // First, convert playpal into long int type, and transpose array, 746 // First, convert playpal into long int type, and transpose array,
736 // for fast inner-loop calculations. Precompute tot array. 747 // for fast inner-loop calculations. Precompute tot array.
737 748
738 { 749 {
739 register int i = 255; 750 register int i = 255;
@@ -749,7 +760,8 @@ void R_InitTranMap(int progress)
749 d += t*t; 760 d += t*t;
750 p -= 3; 761 p -= 3;
751 tot[i] = d << (TSC-1); 762 tot[i] = d << (TSC-1);
752 } while (--i>=0); 763 }
764 while (--i>=0);
753 } 765 }
754 766
755 // Next, compute all entries using minimum arithmetic. 767 // Next, compute all entries using minimum arithmetic.
@@ -775,9 +787,10 @@ void R_InitTranMap(int progress)
775 long best = LONG_MAX; 787 long best = LONG_MAX;
776 do 788 do
777 if ((err = tot[color] - pal[0][color]*r 789 if ((err = tot[color] - pal[0][color]*r
778 - pal[1][color]*g - pal[2][color]*b) < best) 790 - pal[1][color]*g - pal[2][color]*b) < best)
779 best = err, *tp = color; 791 best = err, *tp = color;
780 while (--color >= 0); 792 while (--color >= 0)
793 ;
781 } 794 }
782 } 795 }
783 } 796 }
@@ -886,78 +899,78 @@ int R_TextureNumForName(const char *name) // const added -- killough
886 899
887void R_PrecacheLevel(void) 900void R_PrecacheLevel(void)
888{ 901{
889 register int i; 902 register int i;
890 register byte *hitlist; 903 register byte *hitlist;
891 904
892 if (demoplayback) 905 if (demoplayback)
893 return; 906 return;
894 907
895 { 908 {
896 size_t size = numflats > numsprites ? numflats : numsprites; 909 size_t size = numflats > numsprites ? numflats : numsprites;
897 hitlist = malloc((size_t)numtextures > size ? (unsigned)numtextures : size); 910 hitlist = malloc((size_t)numtextures > size ? (unsigned)numtextures : size);
898 } 911 }
899 // Precache flats. 912 // Precache flats.
900 913
901 memset(hitlist, 0, numflats); 914 memset(hitlist, 0, numflats);
902 915
903 for (i = numsectors; --i >= 0; ) 916 for (i = numsectors; --i >= 0; )
904 hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1; 917 hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1;
905 918
906 for (i = numflats; --i >= 0; ) 919 for (i = numflats; --i >= 0; )
907 if (hitlist[i]) 920 if (hitlist[i])
908 (W_CacheLumpNum)(firstflat + i, 0); 921 (W_CacheLumpNum)(firstflat + i, 0);
909 922
910 // Precache textures. 923 // Precache textures.
911 924
912 memset(hitlist, 0, numtextures); 925 memset(hitlist, 0, numtextures);
913 926
914 for (i = numsides; --i >= 0;) 927 for (i = numsides; --i >= 0;)
915 hitlist[sides[i].bottomtexture] = 928 hitlist[sides[i].bottomtexture] =
916 hitlist[sides[i].toptexture] = 929 hitlist[sides[i].toptexture] =
917 hitlist[sides[i].midtexture] = 1; 930 hitlist[sides[i].midtexture] = 1;
918 931
919 // Sky texture is always present. 932 // Sky texture is always present.
920 // Note that F_SKY1 is the name used to 933 // Note that F_SKY1 is the name used to
921 // indicate a sky floor/ceiling as a flat, 934 // indicate a sky floor/ceiling as a flat,
922 // while the sky texture is stored like 935 // while the sky texture is stored like
923 // a wall texture, with an episode dependend 936 // a wall texture, with an episode dependend
924 // name. 937 // name.
925 938
926 hitlist[skytexture] = 1; 939 hitlist[skytexture] = 1;
927 940
928 for (i = numtextures; --i >= 0; ) 941 for (i = numtextures; --i >= 0; )
929 if (hitlist[i]) 942 if (hitlist[i])
930 { 943 {
931 texture_t *texture = textures[i]; 944 texture_t *texture = textures[i];
932 int j = texture->patchcount; 945 int j = texture->patchcount;
933 while (--j >= 0) 946 while (--j >= 0)
934 (W_CacheLumpNum)(texture->patches[j].patch, 0); 947 (W_CacheLumpNum)(texture->patches[j].patch, 0);
935 } 948 }
936 949
937 // Precache sprites. 950 // Precache sprites.
938 memset(hitlist, 0, numsprites); 951 memset(hitlist, 0, numsprites);
939 952
940 { 953 {
941 thinker_t *th; 954 thinker_t *th;
942 for (th = thinkercap.next ; th != &thinkercap ; th=th->next) 955 for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
943 if (th->function == P_MobjThinker) 956 if (th->function == P_MobjThinker)
944 hitlist[((mobj_t *)th)->sprite] = 1; 957 hitlist[((mobj_t *)th)->sprite] = 1;
945 } 958 }
946 959
947 for (i=numsprites; --i >= 0;) 960 for (i=numsprites; --i >= 0;)
948 if (hitlist[i]) 961 if (hitlist[i])
949 { 962 {
950 int j = sprites[i].numframes; 963 int j = sprites[i].numframes;
951 while (--j >= 0) 964 while (--j >= 0)
952 { 965 {
953 short *sflump = sprites[i].spriteframes[j].lump; 966 short *sflump = sprites[i].spriteframes[j].lump;
954 int k = 7; 967 int k = 7;
955 do 968 do
956 (W_CacheLumpNum)(firstspritelump + sflump[k], 0); 969 (W_CacheLumpNum)(firstspritelump + sflump[k], 0);
957 while (--k >= 0); 970 while (--k >= 0);
958 } 971 }
959 } 972 }
960 free(hitlist); 973 free(hitlist);
961} 974}
962 975
963// Proff - Added for OpenGL 976// Proff - Added for OpenGL