74a3c0f898f2a776467ecd3c134161d82fca6e1f
3 #include <stdlib.h> // abs()
28 static vgaimg
*scrnh
[3]; // TITLEPIC INTERPIC ENDPIC
29 static vgaimg
*ltn
[2][2];
32 static vgaimg
*smk_spr
[SMSN
];
33 static vgaimg
*smk_fspr
[FLSN
];
35 static vgaimg
*fx_spr
[15];
36 static char fx_sprd
[15];
38 static vgaimg
*wp_spr
[49*2];
39 static char wp_sprd
[49*2];
41 static vgaimg
*item_spr
[58];
42 static char item_sprd
[58];
44 static vgaimg
*plr_spr
[27*2];
45 static char plr_sprd
[27*2];
46 static vgaimg
*plr_wpn
[11][6];
48 static vgaimg
*pl_spr
[2];
49 static vgaimg
*mn_spr
[MN_TN
][29*2];
50 static char mn_sprd
[MN_TN
][29*2];
51 static vgaimg
*mn_fspr
[8];
52 static vgaimg
*mn_sgun
[2];
55 static vgaimg
*sth
[22], *bfh
[160 - '!'], *sfh
[160 - '!'], *stone
, *stone2
, *keys
[3];
56 static int prx
= 0, pry
= 0;
58 static vgaimg
*msklh
[2], *mbarl
, *mbarm
, *mbarr
, *mbaro
, *mslotl
, *mslotm
, *mslotr
;
60 static int gammaa
= 0;
61 static char main_pal
[256][3];
62 static char std_pal
[256][3];
63 static byte gamcor
[5][64]={
69 static int w_o
, w_x
, w_y
;
70 static vgaimg
*walp
[256];
72 static byte walani
[256];
73 static int anih
[ANIT
][5];
74 static byte anic
[ANIT
];
75 static int max_textures
;
80 static void *Z_getspr (char n
[4], int s
, int d
, char *dir
) {
81 int h
= F_getsprid(n
, s
, d
);
83 *dir
= (h
& 0x8000) ? 1 : 0;
85 return V_getvgaimg(h
);
88 static void Z_putbfch (int c
) {
90 if (c
> 32 && c
< 160) {
103 static void Z_putsfch (int c
) {
105 if (c
> 32 && c
< 160) {
118 static void Z_gotoxy (int x
, int y
) {
123 static void Z_printbf (char *s
, ...) {
128 vsprintf(buf
, s
, ap
);
130 for (i
= 0; buf
[i
]; ++i
) {
138 Z_putbfch((byte
)buf
[i
]);
143 static void Z_printsf (char *s
, ...) {
148 vsprintf(buf
, s
, ap
);
150 for (i
= 0; buf
[i
]; ++i
) {
158 Z_putsfch((byte
)buf
[i
]);
163 static void Z_drawspr (int x
, int y
, void *p
, char d
) {
165 V_spr2(x
- w_x
+ WD
/ 2, y
- w_y
+ HT
/ 2 + 1 + w_o
, p
);
167 V_spr(x
- w_x
+ WD
/ 2, y
- w_y
+ HT
/ 2 + 1 + w_o
, p
);
171 static void Z_clrst (void) {
172 V_pic(SCRW
- 120, w_o
, stone
);
173 int y
= ((vgaimg
*)stone
)->h
;
175 V_pic(SCRW
- 120, w_o
+ y
, stone2
);
176 y
+= ((vgaimg
*)stone
)->h
;
180 static void Z_drawstlives (char n
) {
181 V_setrect(SCRW
- 40, 30, w_o
, 40);
182 V_spr(SCRW
- 35, w_o
+ 17, sth
[n
]);
185 static void Z_drawstkeys (byte k
) {
187 V_setrect(SCRW
- 120, 70, w_o
+ 77, 23);
188 for (k
>>= 4, n
= 0, x
= SCRW
- 75; n
< 3; ++n
, k
>>= 1, x
+= 9) {
190 V_spr(x
, w_o
+ 91, keys
[n
]);
195 static void Z_drawstair (int a
) {
196 V_setrect(SCRW
- 120, 120, w_o
+ 49, 2);
201 a
= a
* 100 / MAXAIR
;
202 V_clr(SCRW
- 110, a
, w_o
+ 49, 2, 0xC8);
206 static void Z_drawstprcnt (int y
, int n
) {
209 V_setrect(SCRW
- 120, 70, y
* 19 + 7 + w_o
, 19);
210 sprintf(s
, "%3d%%", n
);
213 for (i
= 0; i
< l
; ++i
, x
+= 14) {
214 if (s
[i
] >='0' && s
[i
] <= '9') {
216 } else if (s
[i
] == '-') {
218 } else if (s
[i
] == '%') {
224 V_spr(x
, y
* 19 + 7 + w_o
, sth
[c
]);
229 static void Z_drawstnum (int n
) {
232 V_setrect(SCRW
- 50, 50, w_o
+ 77, 23);
236 x
= (115 - l
* 14) + SCRW
- 120;
237 for (i
= 0; i
< l
; ++i
, x
+= 14) {
238 if (s
[i
] >= '0' && s
[i
] <= '9') {
240 } else if (s
[i
] == '-') {
242 } else if(s
[i
] == '%') {
248 V_spr(x
, w_o
+ 77 + 5, sth
[c
]);
254 static void Z_drawstwpn (int n
, int a
) {
258 V_setrect(SCRW
- 120, 120, w_o
+ 58, 23);
260 V_spr(SCRW
- 88, w_o
+ 58 + 19, sth
[i
+ 12]);
265 x
= SCRW
- 10 - l
* 14;
266 for (i
= 0; i
< l
; ++i
, x
+= 14) {
267 if (s
[i
] >= '0' && s
[i
] <= '9') {
269 } else if (s
[i
] == '-') {
271 } else if (s
[i
] == '%') {
277 V_spr(x
, w_o
+ 58 + 2, sth
[c
]);
283 static void Z_drawmanspr (int x
, int y
, void *p
, char d
, byte color
) {
285 V_manspr2(x
- w_x
+ WD
/ 2, y
- w_y
+ HT
/ 2 + 1 + w_o
, p
, color
);
287 V_manspr(x
- w_x
+ WD
/ 2, y
- w_y
+ HT
/ 2 + 1 + w_o
, p
, color
);
291 static void Z_drawfld (byte
*fld
, int bg
) {
294 for (y
= 0; y
< FLDH
; y
++) {
295 for (x
= 0; x
< FLDW
; x
++) {
296 int sx
= x
* CELW
- w_x
+ WD
/ 2;
297 int sy
= y
* CELH
- w_y
+ HT
/ 2 + 1 + w_o
;
300 //intptr_t spc = (intptr_t) walp[id];
301 int spc
= R_get_special_id(id
);
302 if (spc
>= 0 && spc
<= 3) {
304 byte
*cmap
= clrmap
+ (spc
+ 7) * 256;
305 V_remap_rect(sx
, sy
, CELW
, CELH
, cmap
);
308 V_pic(sx
, sy
, walp
[id
]);
318 static int gm_tm
= 0; // ???
320 static vgaimg
*PL_getspr (int s
, int d
) {
321 return plr_spr
[(s
- 'A') * 2 + d
];
324 static int GM_draw (void) {
325 enum {MENU
, MSG
}; // copypasted from menu.c!
327 CANCEL
, NEWGAME
, LOADGAME
, SAVEGAME
, OPTIONS
, QUITGAME
, QUIT
, ENDGAME
, ENDGM
,
328 PLR1
, PLR2
, COOP
, DM
, VOLUME
, GAMMA
, LOAD
, SAVE
, PLCOLOR
, PLCEND
, MUSIC
, INTERP
,
329 SVOLM
, SVOLP
, MVOLM
, MVOLP
, GAMMAM
, GAMMAP
, PL1CM
, PL1CP
, PL2CM
, PL2CP
330 }; // copypasted from menu.c!
333 V_setrect(0, SCRW
, 0, SCRH
);
334 if (!mnu
&& !gm_redraw
) {
341 if (mnu
->type
== MENU
) {
342 y
= (200 - mnu
-> n
* 16 - 20) / 2;
343 Z_gotoxy(mnu
->x
, y
- 10); Z_printbf(mnu
->ttl
);
344 for (i
= 0; i
< mnu
->n
; ++i
) {
345 if (mnu
->t
[i
] == LOAD
|| mnu
->t
[i
] == SAVE
) {
347 V_spr(mnu
->x
, j
, mslotl
);
348 for (k
= 8; k
< 184; k
+= 8) {
349 V_spr(mnu
->x
+ k
, j
, mslotm
);
351 V_spr(mnu
->x
+ 184, j
, mslotr
);
352 Z_gotoxy(mnu
->x
+ 4, j
- 8);
353 if (input
&& i
== save_mnu
.cur
) {
354 Z_printsf("%s_", ibuf
);
356 Z_printsf("%s", savname
[i
]);
359 Z_gotoxy(mnu
->x
+ (mnu
->t
[i
] >= SVOLM
? (mnu
->t
[i
] >= PL1CM
? 50 : 152) : 0), y
+ i
* 16 + 20);
360 Z_printbf(mnu
->m
[i
]);
362 if (mnu
->t
[i
] == MUSIC
) {
363 Z_printbf(" '%.8s'", g_music
);
364 } else if(mnu
->t
[i
] == INTERP
) {
365 Z_printbf("%s", fullscreen
? "ON" : "OFF");
366 } else if(mnu
->t
[i
] >= PL1CM
) {
367 V_manspr(mnu
->x
+ (mnu
->t
[i
] == PL1CM
? 15 : 35), y
+ i
* 16 + 20 + 14, PL_getspr(*panimp
, 0), pcolortab
[(mnu
->t
[i
] == PL1CM
) ? p1color
: p2color
]);
368 } else if(mnu
->t
[i
] >= SVOLM
) {
370 V_spr(mnu
->x
, j
, mbarl
);
371 for (k
= 8; k
< 144; k
+= 8) {
372 V_spr(mnu
->x
+ k
, j
, mbarm
);
374 V_spr(mnu
->x
+ 144, j
, mbarr
);
376 case SVOLM
: k
= snd_vol
; break;
377 case MVOLM
: k
= mus_vol
; break;
378 case GAMMAM
: k
= gammaa
<< 5; break;
380 V_spr(mnu
->x
+ 8 + k
, j
, mbaro
);
383 V_spr(mnu
->x
- 25, y
+ mnu
->cur
* 16 + 20 - 8, msklh
[(gm_tm
/ 6) & 1]);
385 Z_gotoxy((320 - strlen(mnu
->ttl
) * 7) / 2, 90); Z_printsf(mnu
->ttl
);
386 Z_gotoxy(136, 100); Z_printsf("(Y/N)");
393 static void DOT_draw (void) {
395 for (i
= 0; i
< MAXDOT
; i
++) {
397 V_dot(dot
[i
].o
.x
- w_x
+ WD
/ 2, dot
[i
].o
.y
- w_y
+ HT
/ 2 + 1 + w_o
, dot
[i
].c
);
404 static void IT_draw (void) {
406 for (i
= 0; i
< MAXITEM
; ++i
) {
408 if (it
[i
].t
&& it
[i
].s
>= 0) {
409 switch(it
[i
].t
& 0x7FFF) {
411 s
= it
[i
].s
/ 9 + 18;
414 s
= it
[i
].s
/ 9 + 20;
417 s
= it
[i
].s
/ 2 + 22;
420 s
= it
[i
].s
/ 2 + 26;
426 s
= it
[i
].s
/ 2 + (it
[i
].t
- I_SUPER
) * 4 + 35;
428 case I_GOR1
: case I_FCAN
:
429 s
= it
[i
].s
/ 2 + (it
[i
].t
- I_GOR1
) * 3 + 51;
440 s
= (it
[i
].t
& 0x7FFF) - I_KEYR
+ 31;
446 s
= (it
[i
].t
& 0x7FFF) - 1;
450 Z_drawspr(it
[i
].o
.x
, it
[i
].o
.y
, item_spr
[s
], item_sprd
[s
]);
457 static int standspr (player_t
*p
) {
460 } else if (p
->f
& PLF_DOWN
) {
467 static int wpnspr (player_t
*p
) {
470 } else if(p
->f
& PLF_DOWN
) {
477 static void PL_draw (player_t
*p
) {
478 enum {STAND
, GO
, DIE
, SLOP
, DEAD
, MESS
, OUT
, FALL
}; // copypasted from player.c!
479 static int wytab
[] = {-1, -2, -1, 0};
486 if (p
->f
& PLF_FIRE
) {
489 } else if (p
->pain
) {
512 s
= plr_goanim
[p
->s
/ 8];
513 w
= (p
->f
& PLF_FIRE
) ? 'B' : 'A';
515 wy
= 1 + wytab
[s
- 'A'];
519 s
= plr_dieanim
[p
->s
];
522 s
= plr_slopanim
[p
->s
];
532 Z_drawspr(p
->o
.x
+ wx
, p
->o
.y
+ wy
, plr_wpn
[p
->wpn
][w
- 'A'], p
->d
);
535 Z_drawmanspr(p
->o
.x
, p
->o
.y
, plr_spr
[(s
- 'A') * 2 + p
->d
], plr_sprd
[(s
- 'A') * 2 + p
->d
], p
->color
);
539 static void PL_drawst (player_t
*p
) {
541 V_setrect(WD
, 120, w_o
, HT
);
543 if (p
->drawst
& PL_DRAWAIR
) {
544 if (p
->air
< PL_AIR
) {
548 if (p
->drawst
& PL_DRAWLIFE
) {
549 Z_drawstprcnt(0, p
->life
);
551 if (p
->drawst
& PL_DRAWARMOR
) {
552 Z_drawstprcnt(1, p
->armor
);
554 if (p
->drawst
& PL_DRAWWPN
) {
576 Z_drawstwpn(p
->wpn
, i
);
578 if (p
->drawst
& PL_DRAWFRAG
) {
579 Z_drawstnum(p
->frag
);
581 if (p
->drawst
& PL_DRAWKEYS
) {
582 Z_drawstkeys(p
->keys
);
585 if (p
->drawst
& PL_DRAWLIVES
) {
586 Z_drawstlives(p
->lives
);
591 /* --- monster --- */
593 #define MANCOLOR 0xD0
595 static void MN_draw (void) {
596 enum {SLEEP
, GO
, RUN
, CLIMB
, DIE
, DEAD
, ATTACK
, SHOOT
, PAIN
, WAIT
, REVIVE
, RUNOUT
}; // copypasted from monster.c!
598 for (i
= 0; i
< MAXMN
; i
++) {
600 if (mn
[i
].t
>= MN_PL_DEAD
) {
601 Z_drawmanspr(mn
[i
].o
.x
, mn
[i
].o
.y
, pl_spr
[mn
[i
].t
- MN_PL_DEAD
], 0, mn
[i
].d
);
604 if ((mn
[i
].t
!= MN_SOUL
&& mn
[i
].t
!= MN_PAIN
) || mn
[i
].st
!= DEAD
) {
605 if (mn
[i
].t
!= MN_MAN
) {
606 Z_drawspr(mn
[i
].o
.x
, mn
[i
].o
.y
, mn_spr
[mn
[i
].t
- 1][(mn
[i
].ap
[mn
[i
].ac
] - 'A') * 2 + mn
[i
].d
], mn_sprd
[mn
[i
].t
- 1][(mn
[i
].ap
[mn
[i
].ac
] - 'A') * 2 + mn
[i
].d
]);
608 if (mn
[i
].ap
[mn
[i
].ac
] == 'E' || mn
[i
].ap
[mn
[i
].ac
] == 'F') {
609 Z_drawspr(mn
[i
].o
.x
, mn
[i
].o
.y
, mn_sgun
[mn
[i
].ap
[mn
[i
].ac
] - 'E'], mn
[i
].d
);
611 Z_drawmanspr(mn
[i
].o
.x
, mn
[i
].o
.y
, mn_spr
[mn
[i
].t
- 1][(mn
[i
].ap
[mn
[i
].ac
] - 'A') * 2 + mn
[i
].d
], mn_sprd
[mn
[i
].t
- 1][(mn
[i
].ap
[mn
[i
].ac
] - 'A') * 2 + mn
[i
].d
], MANCOLOR
);
614 if (mn
[i
].t
== MN_VILE
&& mn
[i
].st
== SHOOT
) {
615 Z_drawspr(mn
[i
].tx
, mn
[i
].ty
, mn_fspr
[mn
[i
].ac
/ 3], 0);
623 static void WP_draw (void) {
624 enum {NONE
, ROCKET
, PLASMA
, APLASMA
, BALL1
, BALL2
, BALL7
, BFGBALL
, BFGHIT
, MANF
, REVF
, FIRE
}; // copypasted from weapons.c!
626 for (i
= 0; i
< MAXWPN
; ++i
) {
637 d
= wp
[i
].o
.xv
> 0 ? 1 : 0;
685 d
= wp
[i
].o
.xv
>= 0 ? 1 : 0;
689 d
= wp
[i
].o
.xv
>=0 ? 1 : 0;
701 s
= wp
[i
].s
/ 2 + 26;
705 Z_drawspr(wp
[i
].o
.x
, wp
[i
].o
.y
, wp_spr
[s
* 2 + d
], wp_sprd
[s
* 2 + d
]);
712 static void SMK_draw (void) {
714 for (i
= 0; i
< MAXSMOK
; ++i
) {
719 if (s
>= (SMSN
- 1) * 3) {
722 s
= SMSN
- 1 - s
/ 3;
724 V_sprf((sm
[i
].x
>> 8) - w_x
+ WD
/ 2, (sm
[i
].y
>> 8) - w_y
+ HT
/ 2 + 1 + w_o
, smk_spr
[s
], &smoke_sprf
);
733 V_sprf((sm
[i
].x
>> 8) - w_x
+ WD
/ 2, (sm
[i
].y
>> 8) - w_y
+ HT
/ 2 + 1 + w_o
, smk_fspr
[s
], &flame_sprf
);
742 static void FX_draw (void) {
743 enum {NONE
, TFOG
, IFOG
, BUBL
}; // copypasted from fx.c
745 for (i
= 0; i
< MAXFX
; ++i
) {
752 s
= fx
[i
].s
/ 2 + 10;
755 V_dot((fx
[i
].x
>> 8) - w_x
+ WD
/ 2, (fx
[i
].y
>> 8) - w_y
+ HT
/ 2 + 1 + w_o
, 0xC0 + fx
[i
].s
);
759 Z_drawspr(fx
[i
].x
, fx
[i
].y
, fx_spr
[s
], fx_sprd
[s
]);
766 static void W_adjust (void) {
767 int MAXX
= FLDW
* CELW
- WD
/ 2;
768 int MAXY
= FLDH
* CELH
- HT
/ 2;
769 if (w_x
< WD
/ 2) w_x
= WD
/ 2;
770 if (w_y
< HT
/ 2) w_y
= HT
/ 2;
771 if (w_x
> MAXX
) w_x
= MAXX
;
772 if (w_y
> MAXY
) w_y
= MAXY
;
775 static void W_draw(void) {
777 V_setrect(0, WD
, w_o
+ 1, HT
);
779 vgaimg
*img
= (vgaimg
*)horiz
;
786 V_rotspr(x
, y
, img
, d
);
789 } while (y
< HT
+ w_o
);
796 V_spr(0, w_o
+ lt_ypos
, ltn
[lt_type
][lt_time
< -5 ? 0 : 1]);
798 V_spr2(WD
- 1, w_o
+ lt_ypos
, ltn
[lt_type
][lt_time
< -5 ? 0 : 1]);
803 V_clr(0, WD
, w_o
+ 1, HT
, 0x97);
805 Z_drawfld((byte
*)fldb
, 1);
816 Z_drawfld((byte
*)fldf
, 0);
818 if (lt_time
== -4 || lt_time
== -2) {
819 V_remap_rect(0, WD
, w_o
+ 1, HT
, clrmap
+ 256 * 11);
828 static void drawview (player_t
*p
) {
829 if (p
->looky
< -SCRH
/ 4) {
830 p
->looky
= -SCRH
/ 4;
831 } else if (p
->looky
> SCRH
/ 4) {
835 w_y
= p
->o
.y
- 12 + p
->looky
;
840 static int get_pu_st (int t
) {
843 } else if((t
/ 9) & 1) {
850 static void pl_info (player_t
*p
, int y
) {
851 dword t
= p
->kills
* 10920 / g_time
;
852 Z_gotoxy(25, y
); Z_printbf("KILLS");
853 Z_gotoxy(25, y
+ 15); Z_printbf("KPM");
854 Z_gotoxy(25, y
+ 30); Z_printbf("SECRETS %u / %u", p
->secrets
, sw_secrets
);
855 Z_gotoxy(255, y
); Z_printbf("%u", p
->kills
);
856 Z_gotoxy(255, y
+ 15); Z_printbf("%u.%u", t
/ 10, t
% 10);
859 static void W_act (void) {
861 if (g_time
% 3 == 0) {
862 for (i
= 1; i
< 256; i
++) {
866 if (anih
[a
][anic
[a
]] == -1) {
869 walp
[i
] = V_getvgaimg(anih
[a
][anic
[a
]]);
879 if (g_trans
&& !transdraw
) {
892 V_pic(0, 0, scrnh
[0]);
897 V_clr(0, SCRW
, 0, SCRH
, 0);
898 V_pic(0, 0, scrnh
[2]);
903 V_clr(0, SCRW
, 0, SCRH
, 0);
904 V_pic(0, 0, scrnh
[1]);
906 Z_printbf("LEVEL COMPLETE");
907 Z_calc_time(g_time
, &hr
, &mn
, &sc
);
909 Z_printbf("TIME %u:%02u:%02u", hr
, mn
, sc
);
913 Z_printbf("PLAYER ONE");
914 Z_gotoxy(80, h
+ 70);
915 Z_printbf("PLAYER TWO");
920 pl_info(&pl2
, h
+ 70);
926 if (g_st
!= GS_GAME
) {
931 V_copytoscr(0, SCRW
, 0, SCRH
);
957 V_copytoscr(0,SCRW
,0,SCRH
);
962 h
= get_pu_st(pl1
.invl
) * 6;
963 } else if (pl1
.pain
< 15) {
965 } else if (pl1
.pain
< 35) {
967 } else if (pl1
.pain
< 55) {
969 } else if (pl1
.pain
< 75) {
971 } else if (pl1
.pain
< 95) {
977 V_maptoscr(0, SCRW
- 120, 1, _2pl
? SCRH
/ 2 - 2 : SCRH
- 2, clrmap
+ h
* 256);
979 V_copytoscr(0, SCRW
- 120, 1, _2pl
? SCRH
/ 2 - 2 : SCRH
- 2);
982 V_copytoscr(SCRW
- 120, 120, 0, _2pl
? SCRH
/ 2 : SCRH
);
987 h
= get_pu_st(pl2
.invl
) * 6;
988 } else if (pl2
.pain
< 15) {
990 } else if (pl2
.pain
< 35) {
992 } else if (pl2
.pain
< 55) {
994 } else if (pl2
.pain
< 75) {
996 } else if (pl2
.pain
< 95) {
1002 V_maptoscr(0, SCRW
- 120, SCRH
/ 2 + 1, SCRH
/ 2 - 2, clrmap
+ h
* 256);
1004 V_copytoscr(0, SCRW
- 120, SCRH
/ 2 + 1, SCRH
/ 2 - 2);
1007 V_copytoscr(SCRW
- 120, 120, SCRH
/ 2, SCRH
/ 2);
1013 void R_alloc (void) {
1016 logo("R_alloc: загрузка графики\n");
1018 scrnh
[0] = V_loadvgaimg("TITLEPIC");
1019 scrnh
[1] = V_loadvgaimg("INTERPIC");
1020 scrnh
[2] = V_loadvgaimg("ENDPIC");
1021 cd_scr
= M_lock(F_getresid("CD1PIC"));
1022 for (i
= 0; i
< 2; ++i
) {
1023 sprintf(s
, "LTN%c", i
+ '1');
1024 for (j
= 0; j
< 2; ++j
) {
1025 ltn
[i
][j
] = Z_getspr(s
, j
, 0, NULL
);
1029 for (i
= 0; i
< SMSN
; ++i
) {
1030 smk_spr
[i
] = Z_getspr("SMOK", i
, 0, NULL
);
1032 for (i
= 0; i
< FLSN
; ++i
) {
1033 smk_fspr
[i
] = Z_getspr("FLAM", i
, 0, NULL
);
1036 for (i
= 0; i
< 10; ++i
) {
1037 fx_spr
[i
] = Z_getspr("TFOG", i
, 0, fx_sprd
+ i
);
1039 for (; i
< 15; ++i
) {
1040 fx_spr
[i
] = Z_getspr("IFOG", i
- 10, 0, fx_sprd
+ i
);
1043 for (i
= 0; i
< 4; ++i
) {
1044 wp_spr
[i
* 2] = Z_getspr("MISL", i
, 1, wp_sprd
+ i
* 2);
1045 wp_spr
[i
* 2 + 1] = Z_getspr("MISL", i
, 2, wp_sprd
+ i
* 2 + 1);
1047 for (; i
< 6; ++i
) {
1048 wp_spr
[i
* 2] = Z_getspr("PLSS", i
- 4, 1, wp_sprd
+ i
* 2);
1049 wp_spr
[i
* 2 + 1] = Z_getspr("PLSS", i
- 4, 2, wp_sprd
+ i
* 2 + 1);
1051 for (; i
< 11; ++i
) {
1052 wp_spr
[i
* 2] = Z_getspr("PLSE", i
- 6, 1, wp_sprd
+ i
* 2);
1053 wp_spr
[i
* 2 + 1] = Z_getspr("PLSE", i
- 6, 2, wp_sprd
+ i
* 2 + 1);
1055 for (; i
< 13; ++i
) {
1056 wp_spr
[i
* 2] = Z_getspr("APLS", i
- 11, 1, wp_sprd
+ i
* 2);
1057 wp_spr
[i
* 2 + 1] = Z_getspr("APLS", i
- 11, 2, wp_sprd
+ i
* 2 + 1);
1059 for (; i
< 18; ++i
) {
1060 wp_spr
[i
* 2] = Z_getspr("APBX", i
- 13, 1, wp_sprd
+ i
* 2);
1061 wp_spr
[i
* 2 + 1] = Z_getspr("APBX", i
- 13, 2, wp_sprd
+ i
* 2 + 1);
1063 for(; i
< 20; ++i
) {
1064 wp_spr
[i
* 2] = Z_getspr("BFS1", i
- 18, 1, wp_sprd
+ i
* 2);
1065 wp_spr
[i
* 2 + 1] = Z_getspr("BFS1", i
- 18, 2, wp_sprd
+ i
* 2 + 1);
1067 for (; i
< 26; ++i
) {
1068 wp_spr
[i
* 2] = Z_getspr("BFE1", i
- 20, 1, wp_sprd
+ i
* 2);
1069 wp_spr
[i
* 2 + 1] = Z_getspr("BFE1", i
- 20, 2, wp_sprd
+ i
* 2 + 1);
1071 for (; i
< 30; ++i
) {
1072 wp_spr
[i
* 2] = Z_getspr("BFE2", i
- 26, 1, wp_sprd
+ i
* 2);
1073 wp_spr
[i
* 2 + 1] = Z_getspr("BFE2", i
- 26, 2, wp_sprd
+ i
* 2 + 1);
1075 for (; i
< 32; ++i
) {
1076 wp_spr
[i
* 2] = Z_getspr("MISL", i
- 30 + 4, 1, wp_sprd
+ i
* 2);
1077 wp_spr
[i
* 2 + 1] = Z_getspr("MISL", i
- 30 + 4, 2, wp_sprd
+ i
* 2 + 1);
1079 for (; i
< 37; ++i
) {
1080 wp_spr
[i
* 2] = Z_getspr("BAL1", i
- 32, 1, wp_sprd
+ i
* 2);
1081 wp_spr
[i
* 2 + 1] = Z_getspr("BAL1", i
- 32, 2, wp_sprd
+ i
* 2 + 1);
1083 for (; i
< 42; ++i
) {
1084 wp_spr
[i
* 2] = Z_getspr("BAL7", i
- 37, 1, wp_sprd
+ i
* 2);
1085 wp_spr
[i
* 2 + 1] = Z_getspr("BAL7", i
- 37, 2, wp_sprd
+ i
* 2 + 1);
1087 for (; i
< 47; ++i
) {
1088 wp_spr
[i
* 2] = Z_getspr("BAL2", i
- 42, 1, wp_sprd
+ i
* 2);
1089 wp_spr
[i
* 2 + 1] = Z_getspr("BAL2", i
- 42, 2, wp_sprd
+ i
* 2 + 1);
1091 for (; i
< 49; ++i
) {
1092 wp_spr
[i
* 2] = Z_getspr("MANF", i
- 47, 1, wp_sprd
+ i
* 2);
1093 wp_spr
[i
* 2 + 1] = Z_getspr("MANF", i
- 47, 2, wp_sprd
+ i
* 2 + 1);
1096 static char snm
[18][4] = {
1097 "CLIP", "SHEL", "ROCK", "CELL", "AMMO", "SBOX", "BROK", "CELP",
1098 "STIM", "MEDI", "BPAK",
1099 "CSAW", "SHOT", "SGN2", "MGUN", "LAUN", "PLAS", "BFUG"
1101 static char n4
[4][4] = {
1102 "SOUL", "SMRT", "SMGT", "SMBT"
1104 static char n3
[2][4] = {
1107 for (i
= 0; i
< 18; ++i
) {
1108 item_spr
[i
] = Z_getspr(snm
[i
], 0, 0, item_sprd
+ i
);
1110 for (; i
< 20; ++i
) {
1111 item_spr
[i
] = Z_getspr("ARM1", i
- 18, 0, item_sprd
+ i
);
1112 item_spr
[i
+ 2] = Z_getspr("ARM2", i
- 18, 0, item_sprd
+ i
);
1115 for (; i
< 26; ++i
) {
1116 item_spr
[i
] = Z_getspr("MEGA", i
- 22, 0, item_sprd
+ i
);
1118 for (; i
< 30; ++i
) {
1119 item_spr
[i
] = Z_getspr("PINV", i
- 26, 0, item_sprd
+ i
);
1121 item_spr
[30] = Z_getspr("AQUA", 0, 0, item_sprd
+ 30);
1122 item_spr
[31] = Z_getspr("KEYR", 0, 0, item_sprd
+ 31);
1123 item_spr
[32] = Z_getspr("KEYG", 0, 0, item_sprd
+ 32);
1124 item_spr
[33] = Z_getspr("KEYB", 0, 0, item_sprd
+ 33);
1125 item_spr
[34] = Z_getspr("SUIT", 0, 0, item_sprd
+ 34);
1126 for (n
= 35, j
= 0; j
< 4; ++j
) {
1127 for (i
= 0; i
< 4; ++i
, ++n
) {
1128 item_spr
[n
] = Z_getspr(n4
[j
], i
, 0, item_sprd
+ n
);
1131 for (j
= 0; j
< 2; ++j
) {
1132 for (i
= 0; i
< 3; ++i
, ++n
) {
1133 item_spr
[n
] = Z_getspr(n3
[j
], i
, 0, item_sprd
+ n
);
1136 item_spr
[57] = Z_getspr("GUN2", 0, 0, item_sprd
+ 57);
1138 for (i
= 0; i
< 27; ++i
) {
1139 plr_spr
[i
* 2] = Z_getspr("PLAY", i
, 1, plr_sprd
+ i
* 2);
1140 plr_spr
[i
* 2 + 1] = Z_getspr("PLAY", i
, 2, plr_sprd
+ i
* 2 + 1);
1142 strncpy(s
, "PWPx", 4);
1143 for (i
= 1; i
< 11; ++i
) {
1144 s
[3] = (i
< 10 ? '0' : 'A' - 10) + i
;
1145 for (j
= 0; j
< 6; ++j
) {
1146 plr_wpn
[i
][j
] = Z_getspr(s
, j
, 1, NULL
);
1150 static char msn
[MN_TN
][4] = {
1151 "SARG", "TROO", "POSS", "SPOS", "CYBR", "CPOS", "BOSS", "BOS2", "HEAD", "SKUL",
1152 "PAIN", "SPID", "BSPI", "FATT", "SKEL", "VILE", "FISH", "BAR1", "ROBO", "PLAY"
1154 static int mms
[MN_TN
] = {
1155 14*2, 21*2, 21*2, 21*2, 16*2, 20*2, 15*2, 15*2, 12*2, 11*2, 13*2, 19*2, 16*2,
1156 20*2, 17*2, 29*2, 6*2, 2*2, 17*2, 23*2
1158 mn_sgun
[0] = Z_getspr("PWP4", 0, 1, NULL
);
1159 mn_sgun
[1] = Z_getspr("PWP4", 1, 1, NULL
);
1160 for (j
= 0; j
< MN_TN
; ++j
) {
1161 for (i
= 0; i
< mms
[j
]; ++i
) {
1162 mn_spr
[j
][i
] = Z_getspr(msn
[j
], i
/ 2, (i
& 1) + 1, &mn_sprd
[j
][i
]);
1164 if (j
== MN_BARREL
- 1) {
1165 for (i
= 4; i
< 14; ++i
) {
1166 mn_spr
[j
][i
] = Z_getspr("BEXP", i
/ 2 - 2, (i
& 1) + 1, &mn_sprd
[j
][i
]);
1170 for (i
= 0; i
< 8; ++i
) {
1171 mn_fspr
[i
] = Z_getspr("FIRE", i
, 0, NULL
);
1173 pl_spr
[0] = Z_getspr("PLAY", 'N' - 'A', 0, NULL
);
1174 pl_spr
[1] = Z_getspr("PLAY", 'W' - 'A', 0, NULL
);
1176 static char mnm
[22][8]={
1177 "STTNUM0","STTNUM1","STTNUM2","STTNUM3","STTNUM4",
1178 "STTNUM5","STTNUM6","STTNUM7","STTNUM8","STTNUM9",
1179 "STTMINUS","STTPRCNT",
1180 "FISTA0","CSAWA0","PISTA0","SHOTA0","SGN2A0","MGUNA0","LAUNA0",
1181 "PLASA0","BFUGA0","GUN2A0"
1183 stone
=V_loadvgaimg("STONE");
1184 stone2
=V_loadvgaimg("STONE2");
1185 keys
[0]=V_loadvgaimg("KEYRA0");
1186 keys
[1]=V_loadvgaimg("KEYGA0");
1187 keys
[2]=V_loadvgaimg("KEYBA0");
1188 for (i
= 0; i
< 22; ++i
) {
1189 sth
[i
] = V_loadvgaimg(mnm
[i
]);
1191 strcpy(s
, "STBF_*");
1192 for (i
= '!'; i
< 160; ++i
) {
1194 bfh
[i
- '!'] = V_getvgaimg(F_findres(s
));
1196 for (i
= '!'; i
< 160; ++i
) {
1197 sprintf(s
, "STCFN%03d", i
);
1198 sfh
[i
- '!'] = V_getvgaimg(F_findres(s
));
1200 strcpy(s
, "WINUM*");
1201 for (i
= '0'; i
<= '9'; ++i
) {
1203 bfh
[i
- '!'] = V_loadvgaimg(s
);
1205 bfh
[':' - '!'] = V_loadvgaimg("WICOLON");
1207 msklh
[0] = V_loadvgaimg("M_SKULL1");
1208 msklh
[1] = V_loadvgaimg("M_SKULL2");
1209 mbarl
= V_loadvgaimg("M_THERML");
1210 mbarm
= V_loadvgaimg("M_THERMM");
1211 mbarr
= V_loadvgaimg("M_THERMR");
1212 mbaro
= V_loadvgaimg("M_THERMO");
1213 mslotl
= V_loadvgaimg("M_LSLEFT");
1214 mslotm
= V_loadvgaimg("M_LSCNTR");
1215 mslotr
= V_loadvgaimg("M_LSRGHT");
1217 static char *anm
[ANIT
- 1][5] = {
1218 {"WALL22_1", "WALL23_1", "WALL23_2", NULL
, NULL
},
1219 {"WALL58_1", "WALL58_2", "WALL58_3", NULL
, NULL
},
1220 {"W73A_1", "W73A_2", NULL
, NULL
, NULL
},
1221 {"RP2_1", "RP2_2", "RP2_3", "RP2_4", NULL
}
1223 for (i
= 1; i
< ANIT
; i
++) {
1224 for (j
= 0; anm
[i
- 1][j
]; j
++) {
1225 anih
[i
][j
] = F_getresid(anm
[i
- 1][j
]);
1233 void R_get_name (int n
, char s
[8]) {
1234 if (walh
[n
] == -1) {
1236 } else if (walh
[n
] == -2) {
1237 memcpy(s
, "_WATER_", 8);
1238 s
[7] = (char)((intptr_t)walp
[n
] - 1 + '0');
1240 F_getresname(s
, walh
[n
] & 0x7FFF);
1244 static short getani (char n
[8]) {
1245 if (strncasecmp(n
, "WALL22_1", 8) == 0) {
1247 } else if (strncasecmp(n
, "WALL58_1", 8) == 0) {
1249 } else if (strncasecmp(n
, "W73A_1", 8) == 0) {
1251 } else if (strncasecmp(n
, "RP2_1", 8) == 0) {
1258 int R_get_special_id (int n
) {
1259 assert(n
>= 0 && n
< 256);
1260 intptr_t x
= (intptr_t)walp
[n
];
1261 return x
>= 0 && x
<= 3 ? x
: -1;
1264 void R_begin_load (void) {
1266 for (i
= 0; i
< 256; i
++) {
1267 if (walp
[i
] != NULL
&& walh
[i
] >= 0) {
1275 memset(anic
, 0, sizeof(anic
));
1279 void R_load (char s
[8], int f
) {
1280 assert(max_textures
< 256);
1282 walh
[max_textures
] = -1;
1283 walp
[max_textures
] = NULL
;
1285 if (strncasecmp(s
, "_WATER_", 7) == 0) {
1286 walh
[max_textures
] = -2;
1287 walp
[max_textures
] = (void*)((intptr_t)s
[7] - '0' + 1);
1289 walh
[max_textures
] = F_getresid(s
);
1290 walp
[max_textures
] = V_getvgaimg(walh
[max_textures
]);
1292 walh
[max_textures
] |= 0x8000;
1294 if (s
[0] == 'S' && s
[1] == 'W' && s
[4] == '_') {
1295 walswp
[max_textures
] = 0;
1298 walani
[max_textures
] = getani(s
);
1303 void R_end_load (void) {
1307 for (i
= 1; i
< 256 && j
< 256; i
++) {
1308 if (walswp
[i
] == 0) {
1311 g
= F_getresid(s
) | (walh
[i
] & 0x8000);
1313 while (k
< 256 && walh
[k
] != g
) {
1320 walp
[k
] = V_getvgaimg(g
);
1321 walf
[k
] = g
& 0x8000 ? 1 : 0;
1329 void R_loadsky (int sky
) {
1334 horiz
= V_loadvgaimg(s
);
1337 void R_setgamma(int g
) {
1339 g
= g
< 0 ? 0 : (g
> 4 ? 4 : g
);
1341 for (t
= 0; t
< 256; ++t
) {
1342 std_pal
[t
][0]=gamcor
[gammaa
][main_pal
[t
][0]];
1343 std_pal
[t
][1]=gamcor
[gammaa
][main_pal
[t
][1]];
1344 std_pal
[t
][2]=gamcor
[gammaa
][main_pal
[t
][2]];
1346 Y_set_vga_palette(std_pal
);
1349 int R_getgamma (void) {
1353 void R_set_videomode (int w
, int h
, int fullscreen
) {
1356 int was
= Y_videomode_setted();
1357 int res
= Y_set_videomode_software(w
, h
, fullscreen
);
1360 ERR_failinit("Unable to set video mode");
1363 Y_get_videomode(&SCRW
, &SCRH
);
1364 Y_get_buffer(&buffer
, &buf_w
, &buf_h
, &pitch
);
1369 void R_toggle_fullscreen (void) {
1370 Y_set_fullscreen(!Y_get_fullscreen());
1371 fullscreen
= Y_get_fullscreen();
1372 Y_get_videomode(&SCRW
, &SCRH
);
1373 Y_get_buffer(&buffer
, &buf_w
, &buf_h
, &pitch
);
1379 logo("R_init: initialize software render\n");
1380 F_loadres(F_getresid("PLAYPAL"), main_pal
, 0, 768);
1381 for (i
= 0; i
< 256; ++i
) {
1382 bright
[i
] = ((int) main_pal
[i
][0] + main_pal
[i
][1] + main_pal
[i
][2]) * 8 / (63 * 3);
1384 F_loadres(F_getresid("MIXMAP"), mixmap
, 0, 0x10000);
1385 F_loadres(F_getresid("COLORMAP"), clrmap
, 0, 256*12);
1386 R_set_videomode(SCRW
, SCRH
, fullscreen
);
1387 V_setrect(0, SCRW
, 0, SCRH
);
1388 V_clr(0, SCRW
, 0, SCRH
, 0);
1392 void R_done (void) {
1397 Y_unset_videomode();