add joystick control to doom
This commit is contained in:
parent
29900964d6
commit
6b7c820da6
12 changed files with 2285 additions and 2209 deletions
|
|
@ -6,7 +6,7 @@
|
|||
#define HAS_T4_VGA 1
|
||||
|
||||
//#define HAS_SND 1
|
||||
#define INVX 1
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
|
|
|||
|
|
@ -2,5 +2,6 @@
|
|||
#define _ARDUINOPROTO_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#define BOOLDEFINED
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@
|
|||
typedef bool boolean;
|
||||
|
||||
#else
|
||||
|
||||
#ifndef BOOLDEFINED
|
||||
typedef enum
|
||||
{
|
||||
false = 0,
|
||||
true = 1,
|
||||
undef = 0xFFFFFFFF
|
||||
} boolean;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef uint8_t byte;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
#define EXTRA_HEAP 0x10
|
||||
|
||||
// Title: < >
|
||||
#define TITLE " DATA directory "
|
||||
#define TITLE " Doom data directory "
|
||||
#define ROMSDIR "/data"
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
#define MIN_RAM 8 /* MiB */
|
||||
|
||||
|
||||
extern unsigned char MemPool[6*1024*1024];
|
||||
extern unsigned char MemPool[8*1024*1024];
|
||||
typedef struct atexit_listentry_s atexit_listentry_t;
|
||||
|
||||
struct atexit_listentry_s
|
||||
|
|
|
|||
|
|
@ -103,13 +103,6 @@ typedef struct
|
|||
|
||||
static uint16_t rgb565_palette[256];
|
||||
|
||||
// Last touch state
|
||||
|
||||
|
||||
// Last button state
|
||||
|
||||
static bool last_button_state;
|
||||
|
||||
// run state
|
||||
|
||||
static bool run;
|
||||
|
|
@ -132,27 +125,79 @@ void I_ShutdownGraphics (void)
|
|||
|
||||
void I_StartFrame (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static int oldjoystick=0;
|
||||
extern int joystick;
|
||||
|
||||
void I_GetEvent (void)
|
||||
{
|
||||
event_t event;
|
||||
bool button_state;
|
||||
event_t event;
|
||||
event.data2 = -1;
|
||||
event.data3 = -1;
|
||||
if ( (!(oldjoystick & 0x04)) && (joystick & 0x04) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_LEFTARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x04)) && (oldjoystick & 0x04) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_LEFTARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
if ( (!(oldjoystick & 0x08)) && (joystick & 0x08) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_RIGHTARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x08)) && (oldjoystick & 0x08) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_RIGHTARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
if ( (!(oldjoystick & 0x01)) && (joystick & 0x01) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_UPARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x01)) && (oldjoystick & 0x01) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_UPARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
if ( (!(oldjoystick & 0x02)) && (joystick & 0x02) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_DOWNARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x02)) && (oldjoystick & 0x02) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_DOWNARROW;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
|
||||
// button_state = button_read ();
|
||||
if ( (!(oldjoystick & 0x10)) && (joystick & 0x10) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_FIRE;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x10)) && (oldjoystick & 0x10) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_FIRE;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
if ( (!(oldjoystick & 0x20)) && (joystick & 0x20) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_ENTER;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x20)) && (oldjoystick & 0x20) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_ENTER;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
|
||||
if (last_button_state != button_state)
|
||||
{
|
||||
last_button_state = button_state;
|
||||
|
||||
event.type = last_button_state ? ev_keydown : ev_keyup;
|
||||
event.data1 = KEY_FIRE;
|
||||
event.data2 = -1;
|
||||
event.data3 = -1;
|
||||
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
oldjoystick = joystick;
|
||||
}
|
||||
|
||||
void I_StartTic (void)
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#include "arduinoproto.h"
|
||||
|
||||
// Data.
|
||||
#include "sounds.h"
|
||||
#include "m_fixed.h"
|
||||
|
|
@ -29,7 +32,8 @@
|
|||
|
||||
#include "p_mobj.h"
|
||||
|
||||
char *sprnames[] = {
|
||||
|
||||
PROGMEM char *sprnames[] = {
|
||||
"TROO","SHTG","PUNG","PISG","PISF","SHTF","SHT2","CHGG","CHGF","MISG",
|
||||
"MISF","SAWG","PLSG","PLSF","BFGG","BFGF","BLUD","PUFF","BAL1","BAL2",
|
||||
"PLSS","PLSE","MISL","BFS1","BFE1","BFE2","TFOG","IFOG","PLAY","POSS",
|
||||
|
|
@ -124,7 +128,7 @@ void A_SpawnFly();
|
|||
void A_BrainExplode();
|
||||
|
||||
|
||||
state_t states[NUMSTATES] = {
|
||||
PROGMEM state_t states[NUMSTATES] = {
|
||||
{SPR_TROO,0,-1,{NULL},S_NULL,0,0}, // S_NULL
|
||||
{SPR_SHTG,4,0,{A_Light0},S_NULL,0,0}, // S_LIGHTDONE
|
||||
{SPR_PUNG,0,1,{A_WeaponReady},S_PUNCH,0,0}, // S_PUNCH
|
||||
|
|
@ -1095,7 +1099,7 @@ state_t states[NUMSTATES] = {
|
|||
};
|
||||
|
||||
|
||||
mobjinfo_t mobjinfo[NUMMOBJTYPES] = {
|
||||
PROGMEM mobjinfo_t mobjinfo[NUMMOBJTYPES] = {
|
||||
|
||||
{ // MT_PLAYER
|
||||
-1, // doomednum
|
||||
|
|
|
|||
|
|
@ -28,21 +28,21 @@
|
|||
// NET_MAXPLAYERS, as there may be observers that are not participating
|
||||
// (eg. left/right monitors)
|
||||
|
||||
#define MAXNETNODES 16
|
||||
#define MAXNETNODES 1 //JMH 16
|
||||
|
||||
// The maximum number of players, multiplayer/networking.
|
||||
// This is the maximum supported by the networking code; individual games
|
||||
// have their own values for MAXPLAYERS that can be smaller.
|
||||
|
||||
#define NET_MAXPLAYERS 8
|
||||
#define NET_MAXPLAYERS 1 //JMH 8
|
||||
|
||||
// Maximum length of a player's name.
|
||||
|
||||
#define MAXPLAYERNAME 30
|
||||
#define MAXPLAYERNAME 2 //JMH 30
|
||||
|
||||
// Networking and tick handling related.
|
||||
|
||||
#define BACKUPTICS 128
|
||||
#define BACKUPTICS 16 //JMH 128
|
||||
|
||||
typedef struct _net_module_s net_module_t;
|
||||
typedef struct _net_packet_s net_packet_t;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#define _PLATFORM_CONFIG_H_
|
||||
|
||||
//#define OLD_LAYOUT 1
|
||||
//#define HAS_T4_VGA 1
|
||||
#define HAS_T4_VGA 1
|
||||
|
||||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
//#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
||||
#define ILI9341 1
|
||||
//#define ILI9341 1
|
||||
//#define ST7789 1
|
||||
//#define SWAP_JOYSTICK 1
|
||||
//#define LOHRES 1
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,3 @@
|
|||
|
||||
|
||||
|
||||
#include "iopins.h"
|
||||
#include "emuapi.h"
|
||||
#include "keyboard_osd.h"
|
||||
|
|
@ -19,12 +16,19 @@ TFT_T_DMA tft = TFT_T_DMA(TFT_CS, TFT_DC, TFT_RST, TFT_MOSI, TFT_SCLK, TFT_MISO,
|
|||
static IntervalTimer myTimer;
|
||||
static unsigned char palette8[PALETTE_SIZE];
|
||||
static unsigned short palette16[PALETTE_SIZE];
|
||||
volatile boolean vbl=true;
|
||||
static int skip=0;
|
||||
|
||||
static unsigned long long mscount=0;
|
||||
volatile unsigned int systime;
|
||||
int joystick=0;
|
||||
|
||||
static void vblCount() {
|
||||
static void vblCount() {
|
||||
if (vbl) {
|
||||
vbl = false;
|
||||
} else {
|
||||
vbl = true;
|
||||
}
|
||||
mscount += 20;
|
||||
systime += 20;
|
||||
}
|
||||
|
|
@ -91,6 +95,17 @@ int emu_FrameSkip(void)
|
|||
return skip;
|
||||
}
|
||||
|
||||
void emu_DrawVsync(void)
|
||||
{
|
||||
volatile boolean vb=vbl;
|
||||
skip += 1;
|
||||
skip &= VID_FRAME_SKIP;
|
||||
#ifdef HAS_T4_VGA
|
||||
tft.waitSync();
|
||||
#else
|
||||
while (vbl==vb) {};
|
||||
#endif
|
||||
}
|
||||
|
||||
// ****************************************************
|
||||
// the setup() method runs once, when the sketch starts
|
||||
|
|
@ -133,12 +148,25 @@ void loop(void)
|
|||
delay(20);
|
||||
}
|
||||
else {
|
||||
D_DoomLoop();
|
||||
int k=emu_ReadKeys();
|
||||
joystick = 0;
|
||||
if ( (k & MASK_JOY1_DOWN) || (k & MASK_JOY2_DOWN) ) joystick|=0x02;
|
||||
if ( (k & MASK_JOY1_UP) || (k & MASK_JOY2_UP) ) joystick|=0x01;
|
||||
if ( (k & MASK_JOY1_LEFT) || (k & MASK_JOY2_LEFT) ) joystick|=0x04;
|
||||
if ( (k & MASK_JOY1_RIGHT) || (k & MASK_JOY2_RIGHT) ) joystick|=0x08;
|
||||
if ( (k & MASK_JOY1_BTN) || (k & MASK_JOY2_BTN) ) joystick|=0x10;
|
||||
if ( (k & MASK_KEY_USER1) ) joystick|=0x20;
|
||||
D_DoomLoop();
|
||||
emu_DrawVsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue