9front - general discussion about 9front
 help / color / mirror / Atom feed
From: qux <qu7uux@gmail.com>
To: 9front@9front.org
Subject: games/doom: fix gamma correction and key translation
Date: Sun, 16 Aug 2015 23:02:08 +0300	[thread overview]
Message-ID: <CAAGZaiKX-Q1tgb6DufDivgxuGga9=twacyL2Ja9ydK3fzZ8iwg@mail.gmail.com> (raw)

games/doom: fix gamma correction and key translation

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.

diff -Naur a/sys/src/games/doom/doomdef.h b/sys/src/games/doom/doomdef.h
--- a/sys/src/games/doom/doomdef.h	Sun Apr 26 00:08:10 2015
+++ b/sys/src/games/doom/doomdef.h	Sun Aug 16 20:13:42 2015
@@ -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
diff -Naur a/sys/src/games/doom/i_video.c b/sys/src/games/doom/i_video.c
--- a/sys/src/games/doom/i_video.c	Wed Jul 29 13:45:35 2015
+++ b/sys/src/games/doom/i_video.c	Sun Aug 16 20:20:57 2015
@@ -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)


                 reply	other threads:[~2015-08-16 20:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAAGZaiKX-Q1tgb6DufDivgxuGga9=twacyL2Ja9ydK3fzZ8iwg@mail.gmail.com' \
    --to=qu7uux@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).