kopia lustrzana https://github.com/Jean-MarcHarvengt/MCUME
add usb keyboard support to doom
rodzic
bccd64b03e
commit
e2d33a53eb
|
@ -1153,15 +1153,14 @@ FRESULT f_read (FIL* fp, void* buff, unsigned int btr, unsigned int * br)
|
|||
int nr = fds[i].f.read(buff, btr);
|
||||
//emu_printf("fread");
|
||||
//emu_printi(btr);
|
||||
emu_printi(nr);
|
||||
//emu_printi(nr);
|
||||
*br = nr;
|
||||
if (nr <= 0)
|
||||
return(FR_DISK_ERR);
|
||||
else
|
||||
return(FR_OK);
|
||||
}
|
||||
//else {
|
||||
//}
|
||||
|
||||
|
||||
unsigned char buffer[256];
|
||||
|
||||
|
@ -1185,8 +1184,8 @@ FRESULT f_read (FIL* fp, void* buff, unsigned int btr, unsigned int * br)
|
|||
}
|
||||
}
|
||||
*br = byteread;
|
||||
emu_printi(byteread);
|
||||
if (byteread <= 0)
|
||||
//emu_printi(byteread);
|
||||
if (byteread <= 0)
|
||||
return(FR_DISK_ERR);
|
||||
else
|
||||
return(FR_OK);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "platform_config.h"
|
||||
|
||||
#define CUSTOM_SND 1
|
||||
//#define CUSTOM_SND 1
|
||||
//#define TIMER_REND 1
|
||||
|
||||
#define EXTRA_HEAP 0x10
|
||||
|
|
Plik diff jest za duży
Load Diff
|
@ -1,53 +0,0 @@
|
|||
//
|
||||
// Copyright(C) 1993-1996 Id Software, Inc.
|
||||
// Copyright(C) 2005-2014 Simon Howard
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// DESCRIPTION:
|
||||
// Pixel-doubling scale up functions.
|
||||
//
|
||||
|
||||
|
||||
#ifndef __I_SCALE__
|
||||
#define __I_SCALE__
|
||||
|
||||
#include "doomtype.h"
|
||||
|
||||
void I_InitScale(byte *_src_buffer, byte *_dest_buffer, int _dest_pitch);
|
||||
void I_ResetScaleTables(byte *palette);
|
||||
|
||||
// Scaled modes (direct multiples of 320x200)
|
||||
|
||||
extern screen_mode_t mode_scale_1x;
|
||||
extern screen_mode_t mode_scale_2x;
|
||||
extern screen_mode_t mode_scale_3x;
|
||||
extern screen_mode_t mode_scale_4x;
|
||||
extern screen_mode_t mode_scale_5x;
|
||||
|
||||
// Vertically stretched modes (320x200 -> multiples of 320x240)
|
||||
|
||||
extern screen_mode_t mode_stretch_1x;
|
||||
extern screen_mode_t mode_stretch_2x;
|
||||
extern screen_mode_t mode_stretch_3x;
|
||||
extern screen_mode_t mode_stretch_4x;
|
||||
extern screen_mode_t mode_stretch_5x;
|
||||
|
||||
// Horizontally squashed modes (320x200 -> multiples of 256x200)
|
||||
|
||||
extern screen_mode_t mode_squash_1x;
|
||||
extern screen_mode_t mode_squash_2x;
|
||||
extern screen_mode_t mode_squash_3x;
|
||||
extern screen_mode_t mode_squash_4x;
|
||||
extern screen_mode_t mode_squash_5x;
|
||||
|
||||
#endif /* #ifndef __I_SCALE__ */
|
||||
|
|
@ -196,7 +196,26 @@ void I_GetEvent (void)
|
|||
event.data1 = KEY_ENTER;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
|
||||
if ( (!(oldjoystick & 0x40)) && (joystick & 0x40) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_USE;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x40)) && (oldjoystick & 0x40) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_USE;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
if ( (!(oldjoystick & 0x80)) && (joystick & 0x80) ) {
|
||||
event.type = ev_keydown;
|
||||
event.data1 = KEY_TAB;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
else if ( (!(joystick & 0x80)) && (oldjoystick & 0x80) ) {
|
||||
event.type = ev_keyup;
|
||||
event.data1 = KEY_TAB;
|
||||
D_PostEvent (&event);
|
||||
}
|
||||
oldjoystick = joystick;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
//#define INVX 1
|
||||
//#define INVY 1
|
||||
//#define HAS_SND 1
|
||||
//#define HAS_USBKEY 1
|
||||
#define HAS_USBKEY 1
|
||||
//#define HAS_I2CKBD 1
|
||||
|
||||
//#define ILI9341 1
|
||||
|
|
|
@ -90,12 +90,13 @@ angle_t clipangle;
|
|||
// maps the visible view angles to screen X coordinates,
|
||||
// flattening the arc to a flat projection plane.
|
||||
// There will be many angles mapped to the same X.
|
||||
int viewangletox[FINEANGLES/2];
|
||||
int * viewangletox = NULL;
|
||||
|
||||
// The xtoviewangleangle[] table maps a screen pixel
|
||||
// to the lowest viewangle that maps back to x ranges
|
||||
// from clipangle to -clipangle.
|
||||
angle_t xtoviewangle[SCREENWIDTH+1];
|
||||
angle_t * xtoviewangle = NULL;
|
||||
|
||||
|
||||
lighttable_t* scalelight[LIGHTLEVELS][MAXLIGHTSCALE];
|
||||
lighttable_t* scalelightfixed[MAXLIGHTSCALE];
|
||||
|
@ -504,6 +505,8 @@ fixed_t R_ScaleFromGlobalAngle (angle_t visangle)
|
|||
//
|
||||
void R_InitTables (void)
|
||||
{
|
||||
|
||||
|
||||
// UNUSED: now getting from tables.c
|
||||
#if 0
|
||||
int i;
|
||||
|
@ -544,6 +547,9 @@ void R_InitTextureMapping (void)
|
|||
int t;
|
||||
fixed_t focallength;
|
||||
|
||||
if (xtoviewangle == NULL) xtoviewangle = emu_Malloc(sizeof(angle_t)*(SCREENWIDTH+1));
|
||||
if (viewangletox == NULL) viewangletox = emu_Malloc(sizeof(int)*(FINEANGLES/2));
|
||||
|
||||
// Use tangent table to generate viewangletox:
|
||||
// viewangletox will give the next greatest x
|
||||
// after the view angle.
|
||||
|
|
|
@ -105,8 +105,8 @@ extern player_t* viewplayer;
|
|||
// ?
|
||||
extern angle_t clipangle;
|
||||
|
||||
extern int viewangletox[FINEANGLES/2];
|
||||
extern angle_t xtoviewangle[SCREENWIDTH+1];
|
||||
extern int * viewangletox;
|
||||
extern angle_t * xtoviewangle;
|
||||
//extern fixed_t finetangent[FINEANGLES/2];
|
||||
|
||||
extern fixed_t rw_distance;
|
||||
|
|
|
@ -22,6 +22,7 @@ static int skip=0;
|
|||
static unsigned long long mscount=0;
|
||||
volatile unsigned int systime;
|
||||
int joystick=0;
|
||||
static int usbjoystick=0;
|
||||
|
||||
static void vblCount() {
|
||||
if (vbl) {
|
||||
|
@ -137,18 +138,21 @@ void loop(void)
|
|||
if (action == ACTION_RUNTFT) {
|
||||
toggleMenu(false);
|
||||
tft.fillScreenNoDma( RGBVAL16(0x00,0x00,0x00) );
|
||||
tft.startDMA();
|
||||
tft.startDMA();
|
||||
char filepath[80];
|
||||
strcpy(filepath, ROMSDIR);
|
||||
strcat(filepath, "/");
|
||||
strcat(filepath, wad);
|
||||
D_DoomMain(filepath);
|
||||
Serial.println("init end");
|
||||
usbjoystick=0;
|
||||
emu_start();
|
||||
}
|
||||
delay(20);
|
||||
}
|
||||
else {
|
||||
int k=emu_ReadKeys();
|
||||
int k = usbjoystick;
|
||||
if (k==0) 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;
|
||||
|
@ -156,6 +160,8 @@ void loop(void)
|
|||
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;
|
||||
if ( (k & MASK_KEY_USER2) ) joystick|=0x40;
|
||||
if ( (k & MASK_KEY_USER3) ) joystick|=0x80;
|
||||
D_DoomLoop();
|
||||
emu_DrawVsync();
|
||||
}
|
||||
|
@ -163,9 +169,25 @@ void loop(void)
|
|||
|
||||
|
||||
void emu_KeyboardOnDown(int keymodifer, int key) {
|
||||
if (key == 218) usbjoystick|=MASK_JOY1_UP; // UP
|
||||
else if (key == 217) usbjoystick|=MASK_JOY1_DOWN; // DOWN
|
||||
else if (key == 216) usbjoystick|=MASK_JOY1_LEFT; // LEFT
|
||||
else if (key == 215) usbjoystick|=MASK_JOY1_RIGHT; // RIGHT
|
||||
else if (key == 102) usbjoystick|=MASK_JOY1_BTN; // FIRE
|
||||
else if (key == 10) usbjoystick|=MASK_KEY_USER1; // RETURN
|
||||
else if (key == 32) usbjoystick|=MASK_KEY_USER2; // USE
|
||||
else if (key == 9) usbjoystick|=MASK_KEY_USER3; // TAB
|
||||
}
|
||||
|
||||
void emu_KeyboardOnUp(int keymodifer, int key) {
|
||||
if (key == 218) usbjoystick&=~MASK_JOY1_UP; // UP
|
||||
else if (key == 217) usbjoystick&=~MASK_JOY1_DOWN; // DOWN
|
||||
else if (key == 216) usbjoystick&=~MASK_JOY1_LEFT; // LEFT
|
||||
else if (key == 215) usbjoystick&=~MASK_JOY1_RIGHT; // RIGHT
|
||||
else if (key == 102) usbjoystick&=~MASK_JOY1_BTN; // FIRE
|
||||
else if (key == 10) usbjoystick&=~MASK_KEY_USER1; // RETURN
|
||||
else if (key == 32) usbjoystick&=~MASK_KEY_USER2; // USE
|
||||
else if (key == 9) usbjoystick&=~MASK_KEY_USER3; // TAB
|
||||
}
|
||||
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue