shithub: riscv

Download patch

ref: f369fa9d46d67019efd2ebff2556d5092e791613
parent: f47f6af382228431fa363198ebf9d6d9424c5b56
author: cinap_lenrek <[email protected]>
date: Sun Aug 16 18:09:46 EDT 2015

games/doom: fix gamma correction and key translation (thanks qu7uux)

KEY_F11 and KEY_F12 are not KEY_F1+11 and KEY_F1+12 as it is assumed in
runetokey(), which prevents these keystrokes from being used. rather than
change runetokey(), it seems better to just change the key definitions in
doomdef.h (the new values don't correspond to any other keys anyway).

F11 is the gamma correction key. to make gamma correction actually work,
i_video.c:I_SetPalette must also take into account usegamma (this was just
never ported). cf i_video.c:UploadNewPalette in source code release.

F12 is the spycam key. the spycam switches the renderview to a different player
during a coop game, or when watching a multiplayer demo. this feature only
changes the renderview; sounds, palette effects, status bar, etc. are still
from the first player's perspective.

--- a/sys/src/games/doom/doomdef.h
+++ b/sys/src/games/doom/doomdef.h
@@ -248,8 +248,8 @@
 #define KEY_F8		(0x80+0x42)
 #define KEY_F9		(0x80+0x43)
 #define KEY_F10		(0x80+0x44)
-#define KEY_F11		(0x80+0x57)
-#define KEY_F12		(0x80+0x58)
+#define KEY_F11		(0x80+0x45)
+#define KEY_F12		(0x80+0x46)
 
 #define KEY_BACKSPACE	127
 #define KEY_PAUSE	0xff
--- a/sys/src/games/doom/i_video.c
+++ b/sys/src/games/doom/i_video.c
@@ -73,7 +73,11 @@
 
 void I_SetPalette(byte *palette)
 {
-	memcpy(cmap, palette, 3*256);
+	uchar *c;
+
+	c = cmap;
+	while(c < cmap+3*256)
+		*c++ = gammatable[usegamma][*palette++];
 }
 
 void I_UpdateNoBlit(void)