2006-03-28 15:44:01 +00:00
|
|
|
/* Emacs style mode select -*- C++ -*-
|
|
|
|
*-----------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
2007-01-17 18:52:24 +00:00
|
|
|
* $Log: i_video.c,v $
|
|
|
|
* Revision 1.26 2006-12-13 04:44:17 kkurbjun
|
2006-12-13 04:44:17 +00:00
|
|
|
* Dehacked and BEX support for Doom - currently only supports a DEHACKED file in a WAD (not as a standalone file yet).
|
|
|
|
*
|
|
|
|
* Revision 1.25 2006-10-26 13:38:04 barrywardell
|
2006-10-26 13:38:09 +00:00
|
|
|
* Allow the Sansa e200 UI simulator to be built. Thanks to Andre Smith for the nice image of the Sansa. Lots more to be done including testing and tweaking the keymaps and modifying the plugins for the Sansa's 176x220 LCD.
|
|
|
|
*
|
|
|
|
* Revision 1.24 2006-09-05 00:23:06 barrywardell
|
2006-09-05 00:23:06 +00:00
|
|
|
* Fix not being able to exit Doom on the H10.
|
|
|
|
*
|
|
|
|
* Revision 1.23 2006-08-10 18:34:43 amiconn
|
2006-08-10 18:34:43 +00:00
|
|
|
* Correct calculation of necessary buffer size to give maximum number of shades on iPod Mini.
|
|
|
|
*
|
|
|
|
* Revision 1.22 2006-08-07 02:44:18 amiconn
|
2006-08-07 02:44:18 +00:00
|
|
|
* Use striped buffering for grayscale targets to make the buffer fit on iPod g3/g4. Also slightly faster (at least on H1x0) with the buffer in IRAM.
|
|
|
|
*
|
|
|
|
* Revision 1.21 2006-08-07 01:57:29 amiconn
|
2006-08-07 01:57:29 +00:00
|
|
|
* Fix red iPod g3 build.
|
|
|
|
*
|
|
|
|
* Revision 1.20 2006-08-07 01:46:41 amiconn
|
2006-08-07 01:46:42 +00:00
|
|
|
* Grayscale library ported to the grayscale iPods, first version. Added C reference versions of gray_update_rect() for both horizontal and vertical pixel packing. gray_update_rect() and gray_ub_gray_bitmap_part() not yet assembler optimised. Grayscale screendump doesn't work yet. * Fixed button assignments for iPod in grayscale.c
|
|
|
|
*
|
|
|
|
* Revision 1.19 2006-08-03 20:17:22 bagder
|
2006-08-03 20:17:25 +00:00
|
|
|
* Barry Wardell's keymappings for H10
|
|
|
|
*
|
|
|
|
* Revision 1.18 2006-08-02 00:21:59 amiconn
|
2006-08-02 00:22:01 +00:00
|
|
|
* Grayscale library: LCD linearisation and gamma correction.
|
|
|
|
*
|
|
|
|
* Revision 1.17 2006-04-22 03:48:15 kkurbjun
|
2006-04-22 03:48:15 +00:00
|
|
|
* Better video update, add options to startup menu, change default screensize
|
|
|
|
*
|
|
|
|
* Revision 1.16 2006-04-20 19:39:56 kkurbjun
|
2006-04-20 19:39:56 +00:00
|
|
|
* Optimizations for doom: coldfire asm drawspan routine = not much, fixed point multiply changes = not much, H300 asm lcd update = some, IRAM sound updates and simplifications = more
|
|
|
|
*
|
|
|
|
* Revision 1.15 2006-04-16 23:14:04 kkurbjun
|
2006-04-16 23:14:04 +00:00
|
|
|
* Fix run so that it stays enabled across level loads. Removed some unused code and added some back in for hopeful future use.
|
|
|
|
*
|
|
|
|
* Revision 1.14 2006-04-15 22:08:36 kkurbjun
|
2006-04-15 22:08:36 +00:00
|
|
|
* Slight code cleanups, fixed sound parameter - now it saves. Old configurations will be reset.
|
|
|
|
*
|
|
|
|
* Revision 1.13 2006-04-06 21:31:49 kkurbjun
|
2006-04-06 21:31:49 +00:00
|
|
|
* Scaling code fixed by clamping down the width to a max of SCREENWIDTH. Removed some #ifdefs for glprboom
|
|
|
|
*
|
|
|
|
* Revision 1.12 2006-04-05 06:37:37 kkurbjun
|
2006-04-05 06:37:37 +00:00
|
|
|
* Fix finale text and try and prevent some data corruption due to the scaling code. Also allows the non-standard GP32 mods to work with some bounds checking. More comments are in v_video.c
|
|
|
|
*
|
|
|
|
* Revision 1.11 2006-04-04 19:39:31 amiconn
|
2006-04-04 19:39:31 +00:00
|
|
|
* Doom on H1x0: Don't waste memory, the grayscale lib doesn't need that much, but properly tell the lib how much memory it may use.
|
|
|
|
*
|
|
|
|
* Revision 1.10 2006-04-04 12:00:53 dave
|
2006-04-04 12:00:53 +00:00
|
|
|
* iPod: Make the hold switch bring up the in-game menu.
|
|
|
|
*
|
|
|
|
* Revision 1.9 2006-04-03 20:03:02 kkurbjun
|
2006-04-03 20:03:02 +00:00
|
|
|
* Updates doom menu w/ new graphics, now requires rockdoom.wad: http://alamode.mines.edu/~kkurbjun/rockdoom.wad
|
|
|
|
*
|
|
|
|
* Revision 1.8 2006-04-03 17:11:42 kkurbjun
|
2006-04-03 17:11:42 +00:00
|
|
|
* Finishing touches
|
|
|
|
*
|
|
|
|
* Revision 1.7 2006-04-03 16:30:12 kkurbjun
|
2006-04-03 16:30:12 +00:00
|
|
|
* Fix #if
|
2006-04-03 16:13:15 +00:00
|
|
|
*
|
|
|
|
* Revision 1.5 2006-04-03 08:51:08 bger
|
2006-04-03 08:51:08 +00:00
|
|
|
* Patch #4864 by Jonathan Gordon: text editor plugin, with some changes by me.
|
|
|
|
* Also correct a var clash between the rockbox's gui api and doom plugin
|
|
|
|
*
|
|
|
|
* Revision 1.4 2006-04-02 20:45:24 kkurbjun
|
2006-04-02 20:45:24 +00:00
|
|
|
* Properly ifdef H300 video code, fix commented line handling rockbox volume
|
|
|
|
*
|
|
|
|
* Revision 1.3 2006-04-02 01:52:44 kkurbjun
|
2006-04-03 17:11:42 +00:00
|
|
|
* 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.
|
2006-04-02 01:52:44 +00:00
|
|
|
*
|
|
|
|
* Revision 1.2 2006-03-28 17:20:49 christian
|
2006-03-28 17:20:49 +00:00
|
|
|
* added good (tm) button mappings for x5, and added ifdef for HAS_BUTTON_HOLD
|
|
|
|
*
|
|
|
|
* Revision 1.1 2006-03-28 15:44:01 dave
|
2006-03-28 15:44:01 +00:00
|
|
|
* Patch #2969 - Doom! Currently only working on the H300.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* DESCRIPTION:
|
|
|
|
* DOOM graphics and buttons. H300 Port by Karl Kurbjun
|
2006-04-03 17:11:42 +00:00
|
|
|
* H100 Port by Dave Chapman, Karl Kurbjun and Jens Arnold
|
2006-03-28 15:44:01 +00:00
|
|
|
* IPOD port by Dave Chapman and Paul Louden
|
|
|
|
* Additional work by Thom Johansen
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "doomstat.h"
|
|
|
|
#include "i_system.h"
|
|
|
|
#include "v_video.h"
|
|
|
|
#include "m_argv.h"
|
|
|
|
#include "d_main.h"
|
|
|
|
|
|
|
|
#include "doomdef.h"
|
|
|
|
|
|
|
|
#include "rockmacros.h"
|
2006-04-03 16:13:15 +00:00
|
|
|
|
|
|
|
#ifndef HAVE_LCD_COLOR
|
2008-01-04 23:42:38 +00:00
|
|
|
#include "../lib/grey.h"
|
2008-01-13 00:11:43 +00:00
|
|
|
GREY_INFO_STRUCT_IRAM
|
2008-01-04 23:42:38 +00:00
|
|
|
static unsigned char greybuffer[LCD_WIDTH] IBSS_ATTR; /* off screen buffer */
|
2006-04-03 16:13:15 +00:00
|
|
|
static unsigned char *gbuf;
|
2006-08-10 18:34:43 +00:00
|
|
|
#if LCD_PIXELFORMAT == HORIZONTAL_PACKING
|
2008-01-04 23:42:38 +00:00
|
|
|
#define GREYBUFSIZE (((LCD_WIDTH+7)/8)*LCD_HEIGHT*16+200)
|
2006-08-10 18:34:43 +00:00
|
|
|
#else
|
2008-01-04 23:42:38 +00:00
|
|
|
#define GREYBUFSIZE (LCD_WIDTH*((LCD_HEIGHT+7)/8)*16+200)
|
2006-08-10 18:34:43 +00:00
|
|
|
#endif
|
2006-04-03 16:13:15 +00:00
|
|
|
#endif
|
|
|
|
|
2007-01-17 18:52:24 +00:00
|
|
|
#if defined(CPU_COLDFIRE)
|
|
|
|
static char fastscreen[LCD_WIDTH*LCD_HEIGHT] IBSS_ATTR;
|
2006-04-02 01:52:44 +00:00
|
|
|
#endif
|
2007-01-17 18:52:24 +00:00
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
static fb_data palette[256] IBSS_ATTR;
|
|
|
|
static fb_data *paldata=NULL;
|
|
|
|
|
|
|
|
//
|
2007-01-17 18:52:24 +00:00
|
|
|
// I_ShutdownGraphics
|
2006-03-28 15:44:01 +00:00
|
|
|
//
|
|
|
|
void I_ShutdownGraphics(void)
|
|
|
|
{
|
2006-04-03 17:11:42 +00:00
|
|
|
#ifndef HAVE_LCD_COLOR
|
2008-01-04 23:42:38 +00:00
|
|
|
grey_release();
|
2006-04-03 17:11:42 +00:00
|
|
|
#endif
|
2006-04-03 20:03:02 +00:00
|
|
|
noprintf=0;
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_StartTic
|
|
|
|
//
|
|
|
|
|
2007-07-27 09:57:27 +00:00
|
|
|
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2006-03-28 15:44:01 +00:00
|
|
|
//#define DOOMBUTTON_SCROLLWHEEL
|
|
|
|
#define DOOMBUTTON_UP BUTTON_MENU
|
|
|
|
#define DOOMBUTTON_WEAPON BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_PLAY
|
|
|
|
#define DOOMBUTTON_ENTER BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_OPEN BUTTON_MENU
|
2007-03-16 23:02:39 +00:00
|
|
|
#elif CONFIG_KEYPAD == IAUDIO_X5M5_PAD
|
2006-03-28 17:20:49 +00:00
|
|
|
#define DOOMBUTTON_UP BUTTON_UP
|
|
|
|
#define DOOMBUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_OPEN BUTTON_PLAY
|
|
|
|
#define DOOMBUTTON_ESC BUTTON_POWER
|
|
|
|
#define DOOMBUTTON_ENTER BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_WEAPON BUTTON_REC
|
2006-08-03 20:17:25 +00:00
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
#define DOOMBUTTON_UP BUTTON_SCROLL_UP
|
|
|
|
#define DOOMBUTTON_DOWN BUTTON_SCROLL_DOWN
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_REW
|
|
|
|
#define DOOMBUTTON_OPEN BUTTON_PLAY
|
|
|
|
#define DOOMBUTTON_ESC BUTTON_POWER
|
2006-09-05 00:23:06 +00:00
|
|
|
#define DOOMBUTTON_ENTER BUTTON_REW
|
2006-08-03 20:17:25 +00:00
|
|
|
#define DOOMBUTTON_WEAPON BUTTON_FF
|
2006-10-26 13:38:09 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
2007-05-22 06:31:44 +00:00
|
|
|
#define DOOMBUTTON_SCROLLWHEEL
|
2008-01-10 08:08:31 +00:00
|
|
|
#define DOOMBUTTON_SCROLLWHEEL_CC BUTTON_SCROLL_BACK
|
|
|
|
#define DOOMBUTTON_SCROLLWHEEL_CW BUTTON_SCROLL_FWD
|
2006-10-26 13:38:09 +00:00
|
|
|
#define DOOMBUTTON_UP BUTTON_UP
|
|
|
|
#define DOOMBUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_OPEN BUTTON_REC
|
|
|
|
#define DOOMBUTTON_ESC BUTTON_POWER
|
2007-05-22 06:31:44 +00:00
|
|
|
#define DOOMBUTTON_ENTER BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_WEAPON DOOMBUTTON_SCROLLWHEEL_CW
|
2007-09-20 10:49:48 +00:00
|
|
|
#elif CONFIG_KEYPAD == SANSA_C200_PAD
|
|
|
|
#define DOOMBUTTON_UP BUTTON_UP
|
|
|
|
#define DOOMBUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_OPEN BUTTON_REC
|
|
|
|
#define DOOMBUTTON_ESC BUTTON_POWER
|
|
|
|
#define DOOMBUTTON_ENTER BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_WEAPON BUTTON_VOL_UP
|
2007-01-17 18:52:24 +00:00
|
|
|
#elif CONFIG_KEYPAD == GIGABEAT_PAD
|
|
|
|
#define DOOMBUTTON_UP BUTTON_UP
|
|
|
|
#define DOOMBUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_A
|
|
|
|
#define DOOMBUTTON_OPEN BUTTON_MENU
|
|
|
|
#define DOOMBUTTON_ESC BUTTON_POWER
|
|
|
|
#define DOOMBUTTON_ENTER BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_WEAPON BUTTON_VOL_DOWN
|
|
|
|
#define DOOMBUTTON_MAP BUTTON_VOL_UP
|
2007-11-02 05:21:34 +00:00
|
|
|
#elif CONFIG_KEYPAD == MROBE500_PAD
|
2007-11-02 07:09:46 +00:00
|
|
|
#define DOOMBUTTON_ESC BUTTON_POWER
|
2007-11-02 05:21:34 +00:00
|
|
|
#define DOOMBUTTON_UP BUTTON_RC_PLAY
|
|
|
|
#define DOOMBUTTON_DOWN BUTTON_RC_DOWN
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_RC_REW
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RC_FF
|
2007-11-02 07:09:46 +00:00
|
|
|
#define DOOMBUTTON_OPEN BUTTON_RC_VOL_DOWN
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_RC_VOL_UP
|
|
|
|
#define DOOMBUTTON_ENTER BUTTON_RC_MODE
|
|
|
|
#define DOOMBUTTON_WEAPON BUTTON_RC_HEART
|
|
|
|
#elif CONFIG_KEYPAD == IRIVER_H100_PAD || \
|
|
|
|
CONFIG_KEYPAD == IRIVER_H300_PAD
|
|
|
|
#define DOOMBUTTON_UP BUTTON_UP
|
|
|
|
#define DOOMBUTTON_DOWN BUTTON_DOWN
|
|
|
|
#define DOOMBUTTON_LEFT BUTTON_LEFT
|
|
|
|
#define DOOMBUTTON_RIGHT BUTTON_RIGHT
|
|
|
|
#define DOOMBUTTON_SHOOT BUTTON_REC
|
|
|
|
#define DOOMBUTTON_OPEN BUTTON_MODE
|
|
|
|
#define DOOMBUTTON_ESC BUTTON_OFF
|
|
|
|
#define DOOMBUTTON_ENTER BUTTON_SELECT
|
|
|
|
#define DOOMBUTTON_WEAPON BUTTON_ON
|
2006-03-28 15:44:01 +00:00
|
|
|
#else
|
2007-11-02 05:21:34 +00:00
|
|
|
#error Keymap not defined!
|
2006-03-28 15:44:01 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-22 06:31:44 +00:00
|
|
|
#ifdef DOOMBUTTON_SCROLLWHEEL
|
|
|
|
/* Scrollwheel events are posted directly and not polled by the button
|
|
|
|
driver - synthesize polling */
|
|
|
|
static inline unsigned int read_scroll_wheel(void)
|
|
|
|
{
|
|
|
|
unsigned int buttons = BUTTON_NONE;
|
|
|
|
unsigned int btn;
|
|
|
|
|
|
|
|
/* Empty out the button queue and see if any scrollwheel events were
|
|
|
|
posted */
|
|
|
|
do
|
|
|
|
{
|
|
|
|
btn = rb->button_get_w_tmo(0);
|
|
|
|
buttons |= btn;
|
|
|
|
}
|
|
|
|
while (btn != BUTTON_NONE);
|
|
|
|
|
|
|
|
return buttons & (DOOMBUTTON_SCROLLWHEEL_CC | DOOMBUTTON_SCROLLWHEEL_CW);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-04-15 22:08:36 +00:00
|
|
|
inline void getkey()
|
2006-03-28 15:44:01 +00:00
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event_t event;
|
2006-04-22 03:48:15 +00:00
|
|
|
/* Same button handling as rockboy */
|
|
|
|
static unsigned int oldbuttonstate IDATA_ATTR = 0;
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-04-22 03:48:15 +00:00
|
|
|
unsigned int released, pressed, newbuttonstate;
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-03-28 17:20:49 +00:00
|
|
|
#ifdef HAS_BUTTON_HOLD
|
2006-04-15 22:08:36 +00:00
|
|
|
static unsigned int holdbutton IDATA_ATTR=0;
|
2006-04-22 03:48:15 +00:00
|
|
|
static bool hswitch IDATA_ATTR=0;
|
2006-03-28 15:44:01 +00:00
|
|
|
if (rb->button_hold()&~holdbutton)
|
|
|
|
{
|
|
|
|
if(hswitch==0)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.type = ev_keydown;
|
2006-03-28 15:44:01 +00:00
|
|
|
hswitch=1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.type = ev_keyup;
|
2006-03-28 15:44:01 +00:00
|
|
|
hswitch=0;
|
|
|
|
}
|
2007-07-27 09:57:27 +00:00
|
|
|
#if (CONFIG_KEYPAD == IPOD_4G_PAD) || (CONFIG_KEYPAD == IPOD_3G_PAD) || \
|
|
|
|
(CONFIG_KEYPAD == IPOD_1G2G_PAD)
|
2006-04-04 12:00:53 +00:00
|
|
|
/* Bring up the menu */
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_ESCAPE;
|
2006-04-04 12:00:53 +00:00
|
|
|
#else
|
|
|
|
/* Enable run */
|
2006-04-16 23:14:04 +00:00
|
|
|
event.data1=KEY_CAPSLOCK;
|
2006-04-04 12:00:53 +00:00
|
|
|
#endif
|
2006-04-15 22:08:36 +00:00
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
holdbutton=rb->button_hold();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
newbuttonstate = rb->button_status();
|
2007-05-22 06:31:44 +00:00
|
|
|
#ifdef DOOMBUTTON_SCROLLWHEEL
|
|
|
|
newbuttonstate |= read_scroll_wheel();
|
|
|
|
#endif
|
|
|
|
|
2006-04-22 03:48:15 +00:00
|
|
|
if(newbuttonstate==oldbuttonstate) /* Don't continue, nothing left to do */
|
|
|
|
return;
|
2006-03-28 15:44:01 +00:00
|
|
|
released = ~newbuttonstate & oldbuttonstate;
|
|
|
|
pressed = newbuttonstate & ~oldbuttonstate;
|
|
|
|
oldbuttonstate = newbuttonstate;
|
|
|
|
if(released)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.type = ev_keyup;
|
2006-03-28 15:44:01 +00:00
|
|
|
if(released & DOOMBUTTON_LEFT)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_LEFTARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
if(released & DOOMBUTTON_RIGHT)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_RIGHTARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#ifdef DOOMBUTTON_DOWN
|
|
|
|
if(released & DOOMBUTTON_DOWN)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_DOWNARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if(released & DOOMBUTTON_UP)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_UPARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
if(released & DOOMBUTTON_SHOOT)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_RCTRL;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
if(released & DOOMBUTTON_OPEN)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=' ';
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#ifdef DOOMBUTTON_ESC
|
|
|
|
if(released & DOOMBUTTON_ESC)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_ESCAPE;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if(released & DOOMBUTTON_ENTER)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_ENTER;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#ifdef DOOMBUTTON_WEAPON
|
|
|
|
if(released & DOOMBUTTON_WEAPON)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1 ='w';
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
2007-01-17 18:52:24 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DOOMBUTTON_MAP
|
|
|
|
if(released & DOOMBUTTON_MAP)
|
|
|
|
{
|
|
|
|
event.data1 =KEY_TAB;
|
|
|
|
D_PostEvent(&event);
|
|
|
|
}
|
2006-03-28 15:44:01 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
if(pressed)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.type = ev_keydown;
|
2006-03-28 15:44:01 +00:00
|
|
|
if(pressed & DOOMBUTTON_LEFT)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_LEFTARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
if(pressed & DOOMBUTTON_RIGHT)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_RIGHTARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#ifdef DOOMBUTTON_DOWN
|
|
|
|
if(pressed & DOOMBUTTON_DOWN)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_DOWNARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if(pressed & DOOMBUTTON_UP)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_UPARROW;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
if(pressed & DOOMBUTTON_SHOOT)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_RCTRL;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
if(pressed & DOOMBUTTON_OPEN)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=' ';
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#ifdef DOOMBUTTON_ESC
|
|
|
|
if(pressed & DOOMBUTTON_ESC)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_ESCAPE;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef DOOMBUTTON_ENTER
|
|
|
|
if(pressed & DOOMBUTTON_ENTER)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1=KEY_ENTER;
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef DOOMBUTTON_WEAPON
|
|
|
|
if(pressed & DOOMBUTTON_WEAPON)
|
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
event.data1='w';
|
|
|
|
D_PostEvent(&event);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
2007-01-17 18:52:24 +00:00
|
|
|
#endif
|
|
|
|
#ifdef DOOMBUTTON_MAP
|
|
|
|
if(pressed & DOOMBUTTON_MAP)
|
|
|
|
{
|
|
|
|
event.data1 =KEY_TAB;
|
|
|
|
D_PostEvent(&event);
|
|
|
|
}
|
2006-03-28 15:44:01 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-04-15 22:08:36 +00:00
|
|
|
inline void I_StartTic (void)
|
2006-03-28 15:44:01 +00:00
|
|
|
{
|
2006-04-15 22:08:36 +00:00
|
|
|
getkey();
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Palette stuff.
|
|
|
|
//
|
|
|
|
static void I_UploadNewPalette(int pal)
|
|
|
|
{
|
|
|
|
// This is used to replace the current 256 colour cmap with a new one
|
|
|
|
// Used by 256 colour PseudoColor modes
|
|
|
|
static int cachedgamma;
|
|
|
|
static size_t num_pals;
|
|
|
|
|
|
|
|
if ((paldata == NULL) || (cachedgamma != usegamma)) {
|
|
|
|
int lump = W_GetNumForName("PLAYPAL");
|
|
|
|
const byte *pall = W_CacheLumpNum(lump);
|
|
|
|
register const byte *const gtable = gammatable[cachedgamma = usegamma];
|
|
|
|
register int i;
|
|
|
|
|
|
|
|
num_pals = W_LumpLength(lump) / (3*256);
|
|
|
|
num_pals *= 256;
|
|
|
|
|
|
|
|
if (!paldata) {
|
|
|
|
// First call - allocate and prepare colour array
|
|
|
|
paldata = malloc(sizeof(*paldata)*num_pals);
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the colormap entries
|
|
|
|
for (i=0 ; (size_t)i<num_pals ; i++) {
|
|
|
|
int r = gtable[pall[0]];
|
|
|
|
int g = gtable[pall[1]];
|
|
|
|
int b = gtable[pall[2]];
|
|
|
|
pall+=3;
|
2006-04-03 16:13:15 +00:00
|
|
|
#ifndef HAVE_LCD_COLOR
|
2006-04-03 17:11:42 +00:00
|
|
|
paldata[i]=(3*r+6*g+b)/10;
|
2006-04-03 16:13:15 +00:00
|
|
|
#else
|
2006-03-28 15:44:01 +00:00
|
|
|
paldata[i] = LCD_RGBPACK(r,g,b);
|
2006-04-03 16:13:15 +00:00
|
|
|
#endif
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
W_UnlockLumpNum(lump);
|
|
|
|
num_pals/=256;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RANGECHECK
|
|
|
|
if ((size_t)pal >= num_pals)
|
|
|
|
I_Error("I_UploadNewPalette: Palette number out of range (%d>=%d)",
|
|
|
|
pal, num_pals);
|
|
|
|
#endif
|
|
|
|
memcpy(palette,paldata+256*pal,256*sizeof(fb_data));
|
|
|
|
}
|
|
|
|
|
2006-04-22 03:48:15 +00:00
|
|
|
|
2006-03-28 15:44:01 +00:00
|
|
|
//
|
|
|
|
// I_FinishUpdate
|
|
|
|
//
|
|
|
|
|
|
|
|
void I_FinishUpdate (void)
|
|
|
|
{
|
2008-01-06 23:48:30 +00:00
|
|
|
int count;
|
|
|
|
byte *src = d_screens[0];
|
2006-04-03 16:30:12 +00:00
|
|
|
#if (CONFIG_LCD == LCD_H300) && !defined(SIMULATOR)
|
2008-01-06 23:48:30 +00:00
|
|
|
count = SCREENWIDTH*SCREENHEIGHT;
|
|
|
|
|
|
|
|
/* ASM screen update (drops ~300 tics) */
|
|
|
|
asm volatile (
|
|
|
|
"move.w #33, (%[LCD]) \n" /* Setup the LCD controller */
|
|
|
|
"nop \n"
|
|
|
|
"clr.w (%[LCD2]) \n"
|
|
|
|
"nop \n"
|
|
|
|
"move.w #34, (%[LCD]) \n" /* End LCD controller setup */
|
|
|
|
"clr.l %%d1 \n"
|
|
|
|
".loop: \n"
|
|
|
|
"move.l (%[scrp])+, %%d0 \n"
|
|
|
|
"swap.w %%d0 \n"
|
|
|
|
"move.w %%d0, %%d1 \n"
|
|
|
|
"lsr.l #8,%%d1 \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), (%[LCD2]) \n"
|
|
|
|
"move.b %%d0,%%d1 \n"
|
|
|
|
"swap.w %%d0 \n"
|
|
|
|
"nop \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), (%[LCD2]) \n"
|
|
|
|
"move.w %%d0, %%d1 \n"
|
|
|
|
"lsr.l #8,%%d1 \n"
|
|
|
|
"nop \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), (%[LCD2]) \n"
|
|
|
|
"move.b %%d0,%%d1 \n"
|
|
|
|
"nop \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), (%[LCD2]) \n"
|
|
|
|
"subq.l #4,%[cnt] \n"
|
|
|
|
"bne.b .loop \n"
|
|
|
|
: /* outputs */
|
|
|
|
[scrp]"+a"(src),
|
|
|
|
[cnt] "+d"(count)
|
|
|
|
: /* inputs */
|
|
|
|
[pal] "a" (palette),
|
|
|
|
[LCD] "a" (0xf0000000),
|
|
|
|
[LCD2]"a" (0xf0000002)
|
|
|
|
: /* clobbers */
|
|
|
|
"d0", "d1"
|
|
|
|
);
|
2008-01-07 00:01:32 +00:00
|
|
|
#elif (CONFIG_LCD == LCD_X5) && !defined(SIMULATOR) \
|
|
|
|
&& defined(CPU_COLDFIRE) /* protect from using it on e200 (sic!) */
|
2008-01-06 23:48:30 +00:00
|
|
|
count = SCREENWIDTH*SCREENHEIGHT;
|
|
|
|
|
|
|
|
/* ASM screen update (drops ~230 tics) */
|
|
|
|
asm volatile (
|
|
|
|
"clr.w (%[LCD]) \n" /* Setup the LCD controller */
|
|
|
|
"move.w #(33<<1), (%[LCD]) \n"
|
|
|
|
"clr.w (%[LCD2]) \n"
|
|
|
|
"clr.w (%[LCD2]) \n"
|
|
|
|
"clr.w (%[LCD]) \n" /* End LCD controller setup */
|
|
|
|
"move.w #(34<<1), (%[LCD]) \n"
|
|
|
|
"clr.l %%d1 \n"
|
|
|
|
".loop: \n"
|
|
|
|
"move.l (%[scrp])+, %%d0 \n"
|
|
|
|
"swap.w %%d0 \n"
|
|
|
|
"move.w %%d0, %%d1 \n"
|
|
|
|
"lsr.l #8,%%d1 \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), %%d2 \n"
|
|
|
|
"move.l %%d2, %%d3 \n"
|
|
|
|
"lsr.l #7, %%d3 \n"
|
|
|
|
"move.w %%d3, (%[LCD2]) \n"
|
|
|
|
"lsl.l #1, %%d2 \n"
|
|
|
|
"move.w %%d2, (%[LCD2]) \n"
|
|
|
|
"move.b %%d0,%%d1 \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), %%d2 \n"
|
|
|
|
"move.l %%d2, %%d3 \n"
|
|
|
|
"lsr.l #7, %%d3 \n"
|
|
|
|
"move.w %%d3, (%[LCD2]) \n"
|
|
|
|
"lsl.l #1, %%d2 \n"
|
|
|
|
"move.w %%d2, (%[LCD2]) \n"
|
|
|
|
"swap.w %%d0 \n"
|
|
|
|
"move.w %%d0, %%d1 \n"
|
|
|
|
"lsr.l #8,%%d1 \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), %%d2 \n"
|
|
|
|
"move.l %%d2, %%d3 \n"
|
|
|
|
"lsr.l #7, %%d3 \n"
|
|
|
|
"move.w %%d3, (%[LCD2]) \n"
|
|
|
|
"lsl.l #1, %%d2 \n"
|
|
|
|
"move.w %%d2, (%[LCD2]) \n"
|
|
|
|
"move.b %%d0,%%d1 \n"
|
|
|
|
"move.w (%[pal], %%d1.l:2), %%d2 \n"
|
|
|
|
"move.l %%d2, %%d3 \n"
|
|
|
|
"lsr.l #7, %%d3 \n"
|
|
|
|
"move.w %%d3, (%[LCD2]) \n"
|
|
|
|
"lsl.l #1, %%d2 \n"
|
|
|
|
"move.w %%d2, (%[LCD2]) \n"
|
|
|
|
"subq.l #4,%[cnt] \n"
|
|
|
|
"bne.b .loop \n"
|
|
|
|
: /* outputs */
|
|
|
|
[scrp]"+a"(src),
|
|
|
|
[cnt] "+d"(count)
|
|
|
|
: /* inputs */
|
|
|
|
[pal] "a" (palette),
|
|
|
|
[LCD] "a" (0xf0008000),
|
|
|
|
[LCD2]"a" (0xf0008002)
|
|
|
|
: /* clobbers */
|
|
|
|
"d0", "d1", "d2", "d3"
|
2006-04-20 19:39:56 +00:00
|
|
|
);
|
|
|
|
#else
|
2006-08-07 02:44:18 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2007-01-17 18:52:24 +00:00
|
|
|
#if(LCD_HEIGHT>LCD_WIDTH)
|
|
|
|
if(rotate_screen)
|
|
|
|
{
|
2008-01-06 23:48:30 +00:00
|
|
|
int y;
|
|
|
|
|
|
|
|
for (y = 0; y < SCREENHEIGHT; y++)
|
2007-01-17 18:52:24 +00:00
|
|
|
{
|
2008-01-06 23:48:30 +00:00
|
|
|
fb_data *dst = rb->lcd_framebuffer + LCD_WIDTH - y;
|
|
|
|
count = SCREENWIDTH;
|
|
|
|
|
|
|
|
do
|
2007-01-17 18:52:24 +00:00
|
|
|
{
|
2008-01-06 23:48:30 +00:00
|
|
|
*dst = palette[*src++];
|
|
|
|
dst += LCD_WIDTH;
|
2007-01-17 18:52:24 +00:00
|
|
|
}
|
2008-01-06 23:48:30 +00:00
|
|
|
while (--count);
|
2007-01-17 18:52:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2008-01-06 23:48:30 +00:00
|
|
|
fb_data *dst = rb->lcd_framebuffer;
|
|
|
|
count = SCREENWIDTH*SCREENHEIGHT;
|
|
|
|
|
|
|
|
do
|
|
|
|
*dst++ = palette[*src++];
|
|
|
|
while (--count);
|
2007-01-17 18:52:24 +00:00
|
|
|
}
|
|
|
|
rb->lcd_update();
|
2006-08-07 02:44:18 +00:00
|
|
|
#else /* !HAVE_LCD_COLOR */
|
2008-01-06 23:48:30 +00:00
|
|
|
unsigned char *dst;
|
|
|
|
int y;
|
2006-08-07 02:44:18 +00:00
|
|
|
|
2008-01-06 23:48:30 +00:00
|
|
|
for (y = 0; y < SCREENHEIGHT; y++)
|
|
|
|
{
|
|
|
|
dst = greybuffer;
|
|
|
|
count = SCREENWIDTH;
|
|
|
|
|
|
|
|
do
|
|
|
|
*dst++ = palette[*src++];
|
|
|
|
while (--count);
|
|
|
|
|
|
|
|
grey_ub_gray_bitmap(greybuffer, 0, y, SCREENWIDTH, 1);
|
|
|
|
}
|
2006-08-07 02:44:18 +00:00
|
|
|
#endif /* !HAVE_LCD_COLOR */
|
2006-04-03 16:13:15 +00:00
|
|
|
#endif
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_ReadScreen
|
|
|
|
//
|
|
|
|
void I_ReadScreen (byte* scr)
|
|
|
|
{
|
2007-01-17 18:52:24 +00:00
|
|
|
memcpy (scr, d_screens[0], LCD_WIDTH*LCD_HEIGHT);
|
2006-03-28 15:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_SetPalette
|
|
|
|
//
|
|
|
|
void I_SetPalette (int pal)
|
|
|
|
{
|
|
|
|
I_UploadNewPalette(pal);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// I_InitGraphics
|
|
|
|
//
|
|
|
|
void I_InitGraphics(void)
|
|
|
|
{
|
|
|
|
printf("Starting Graphics engine\n");
|
|
|
|
|
2006-04-03 17:11:42 +00:00
|
|
|
noprintf=1;
|
|
|
|
|
2006-04-02 20:45:24 +00:00
|
|
|
/* Note: The other screens are allocated as needed */
|
2006-03-28 15:44:01 +00:00
|
|
|
|
2006-04-03 16:13:15 +00:00
|
|
|
#ifndef HAVE_LCD_COLOR
|
2008-01-04 23:42:38 +00:00
|
|
|
gbuf=malloc(GREYBUFSIZE);
|
|
|
|
grey_init(rb, gbuf, GREYBUFSIZE, false, LCD_WIDTH, LCD_HEIGHT, NULL);
|
|
|
|
/* switch on greyscale overlay */
|
|
|
|
grey_show(true);
|
2006-04-03 16:13:15 +00:00
|
|
|
#endif
|
|
|
|
|
2007-05-10 13:16:08 +00:00
|
|
|
#ifdef CPU_COLDFIRE
|
2006-03-28 15:44:01 +00:00
|
|
|
coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
|
2006-04-03 08:51:08 +00:00
|
|
|
d_screens[0] = fastscreen;
|
2006-03-28 15:44:01 +00:00
|
|
|
#else
|
2006-04-02 01:52:44 +00:00
|
|
|
// Don't know if this will fit in other IRAMs
|
2007-01-17 18:52:24 +00:00
|
|
|
d_screens[0] = malloc (LCD_WIDTH * LCD_HEIGHT * sizeof(unsigned char));
|
2006-03-28 15:44:01 +00:00
|
|
|
#endif
|
|
|
|
}
|