Skip to content

Commit

Permalink
Joystick HAT isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
DirtBagXon committed Aug 16, 2024
1 parent 9afc634 commit c1e95b9
Show file tree
Hide file tree
Showing 31 changed files with 755 additions and 170 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ Configure **joystick controls** in [hypinput.ini](doc/hypinput.ini) or via [Game

## Extended arguments and keys

The following additional, and reimplemented, arguments have been added to Hypseus Singe:
Highlighted additional, and reimplemented, arguments that have been added to Hypseus Singe:

Refer to [CmdLine.md](doc/CmdLine.md) for a full argument list.

-bezel <lair.png> [ Specify a png bezel in 'bezels' sub-folder ]
-blank_blue [ VLDP blank using YUV#1DEB6B ]
Expand Down
2 changes: 0 additions & 2 deletions doc/Bezels.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,3 @@ Refer also to **CmdLine arguments** [here](CmdLine.md)
| ace | - bezels/offcadet.bmp |
| | |
| tq | - bezels/tqkeys.png |
| | |
| badlands | - bezels/shoot.bmp |
1 change: 1 addition & 0 deletions doc/CmdLine.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Refer also to **bezel arguments** [here](Bezels.md)
| -nospeech | Disables speech for Thayer's Quest. |
| -novsync | Disable VSYNC presentation on Renderer. |
| -opengl | Enforces SDL_WINDOW_OPENGL |
| -openhat | Allow HAT input from any Joystick |
| -original_overlay | Enable daphne style overlays (lair, ace, lair2) |
| -pal_dl | Tells Hypseus that you are using a PAL Philips Dragon's Lair disc instead of an NTSC Dragon's Lair disc. *Only relevant when playing the USA version of Dragon's Lair.* |
| -pal_dl_sc | Tells Hypseus that you are using a PAL Software Corner Dragon's Lair disc instead of an NTSC Dragon's Lair disc. *Only relevant when playing the USA version of Dragon's Lair.* |
Expand Down
4 changes: 4 additions & 0 deletions doc/hypinput.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
# Defining 001 (or 1) identifies first joystick(0) button 0
# Defining 111 identifies second joystick(1) button 10
#
# HAT assignment to joystick, can be attributed using the 'Button' entry
# against 'KEY_UP'. Using the same numeric calculations as above.
# e.g. 0, 100, 200 etc. Assignment will be displayed in log.
#
# The fourth number in config (if specified) is the joystick axis
# configuration (or 0 for "none"). Since 0 is reserved for
# special meaning, joystick axis 0 is identified as 1.
Expand Down
1 change: 0 additions & 1 deletion src/game/astron.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "../ldp-in/vip9500sg.h"
#include "../ldp-out/ldp.h"
#include "../video/palette.h"
#include "../video/video.h"
#include "../sound/sound.h"
#include "../cpu/cpu.h"
#include "../cpu/generic_z80.h"
Expand Down
42 changes: 17 additions & 25 deletions src/game/badlands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "../ldp-in/ldv1000.h"
#include "../ldp-out/ldp.h"
#include "../video/palette.h"
#include "../video/video.h"
#include "../video/led.h"
#include "../sound/sound.h"

Expand Down Expand Up @@ -84,6 +83,7 @@ badlands::badlands()
shoot_led = false;
shoot_led_overlay = false;
shoot_led_numlock = false;
m_shoot = 0x0A;
char_base = 0x4000;
charx_offset = 6;
chary_offset = 2;
Expand All @@ -109,6 +109,7 @@ badlandp::badlandp()
{
m_shortgamename = "badlandp";
irq_on = firq_on = nmi_on = true;
m_shoot = 0x01;
char_base = 0x2000;
charx_offset = 12;
chary_offset = 1;
Expand Down Expand Up @@ -162,8 +163,8 @@ void badlands::do_nmi()
}

if (!yuv_on)
if (video::get_yuv_overlay_ready()) {
video::set_video_blank(true);
if (palette::get_yuv_overlay_ready()) {
palette::set_yuv_transparency(false);
yuv_on = true;
}

Expand Down Expand Up @@ -229,14 +230,7 @@ void badlands::cpu_mem_write(Uint16 addr, Uint8 value)

// DSP On
else if (addr == 0x1003) {

if (yuv_on) {
if (value) {
video::set_video_blank(true);
} else {
video::set_video_blank(false);
}
}
palette::set_yuv_transparency(!value);
}

// nmi on
Expand Down Expand Up @@ -360,14 +354,7 @@ void badlandp::cpu_mem_write(Uint16 addr, Uint8 value)
}
// display disable
else if (addr == 0x0803) {

if (yuv_on) {
if (value) {
video::set_video_blank(true);
} else {
video::set_video_blank(false);
}
}
palette::set_yuv_transparency(!value);
}
// ?
else if (addr == 0x0804) {
Expand Down Expand Up @@ -461,15 +448,20 @@ void badlands::draw_char(Uint8 char_value, int x_offset, int y_offset)
}
}

void badlands::draw_shoot(const char* w, int x_offset, int y_offset, Uint8 game)
void badlands::draw_shoot()
{
if (game > GAME_BADLANDS) y_offset++;
const char f[6] = "shoot";
int i, x_offset = 0x1f;
int y_offset = (m_shoot & 0x01) ? 0x02 : 0x01;

for (int i = 0; w[i] != '\0'; i++)
draw_char(m_shoot, x_offset - 0x02, y_offset);

for (i = 0; f[i] != '\0'; i++)
{
Uint8 l = w[i] - 0x40;
draw_char(l, x_offset + i, y_offset);
draw_char(f[i] - 0x40, x_offset + i, y_offset);
}

draw_char(m_shoot, x_offset + ++i, y_offset);
}

// updates badlands's video
Expand Down Expand Up @@ -498,7 +490,7 @@ void badlands::repaint()
}
}

if (shoot_led) draw_shoot("shoot", 0x1e, 0x01, m_game_type);
if (shoot_led) draw_shoot();
}

// this gets called when the user presses a key or moves the joystick
Expand Down
3 changes: 2 additions & 1 deletion src/game/badlands.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ class badlands : public game
void update_shoot_led(Uint8);
Uint8 charx_offset;
Uint8 chary_offset;
Uint8 m_shoot;
Uint16 char_base;
Uint8 m_soundchip_id;
void draw_char(Uint8, int, int);
void draw_shoot(const char*, int, int, Uint8);
void draw_shoot();
bool shoot_led_overlay;
bool shoot_led_numlock;
bool shoot_led;
Expand Down
1 change: 0 additions & 1 deletion src/game/bega.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "../ldp-in/ldp1000.h"
#include "../ldp-out/ldp.h"
#include "../video/palette.h"
#include "../video/video.h"

////////////////

Expand Down
1 change: 0 additions & 1 deletion src/game/cobraconv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "../ldp-in/ldv1000.h"
#include "../ldp-out/ldp.h"
#include "../video/palette.h"
#include "../video/video.h"

////////////////

Expand Down
1 change: 0 additions & 1 deletion src/game/esh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "../ldp-in/ldv1000.h"
#include "../ldp-out/ldp.h"
#include "../video/palette.h"
#include "../video/video.h"

enum { S_ESH_BEEP };

Expand Down
1 change: 0 additions & 1 deletion src/game/firefox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include "../io/conout.h"
#include "../ldp-in/vp931.h"
#include "../ldp-out/ldp.h"
#include "../video/video.h"
#include "../video/palette.h"
#include "../cpu/cpu-debug.h" // for cpu debugging

Expand Down
67 changes: 46 additions & 21 deletions src/game/gpworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#include "../ldp-in/ldv1000.h"
#include "../ldp-out/ldp.h"
#include "../video/palette.h"
#include "../video/video.h"
#include "../sound/sound.h"
#include "../sound/samples.h"
#include "../cpu/cpu.h"
Expand Down Expand Up @@ -84,11 +83,12 @@ gpworld::gpworld()
ldp_output_latch = 0xff;
nmie = false;
m_align = false;
m_shifter = true;

m_num_sounds = 10;
// With the lack of any hardware reference....
m_sound_name[S_GP_ENGINE1] = "gp_engine1.wav";
m_sound_name[S_GP_ENGINE2] = "gp_engine2.wav";
m_sound_name[S_GP_ENG1] = "gp_engine1.wav";
m_sound_name[S_GP_ENG2] = "gp_engine2.wav";
m_sound_name[S_GP_COUNT] = "gp_count.wav";
m_sound_name[S_GP_START] = "gp_signal.wav";
m_sound_name[S_GP_TIRE] = "gp_tires.wav";
Expand Down Expand Up @@ -292,9 +292,7 @@ void gpworld::cpu_mem_write(Uint16 addr, Uint8 value)
break;
case 0xfe:
if (++ign > 0x0a) {
if (banks[2])
sound::play(S_GP_ENGINE2);
else sound::play(S_GP_ENGINE1);
sound::play(banks[2] ? S_GP_ENG2 : S_GP_ENG1);
ign--;
}
break;
Expand Down Expand Up @@ -519,17 +517,51 @@ void gpworld::recalc_palette()
palette_modified = false;
}

void gpworld::draw_char(char l, int x_offset, int y_offset)
{
int i = -1;
Uint8 c = 0x01;

switch (l) {
case 0x44: i = 0; c = 0xf3; break;
case 0x48: i = 1; break;
case 0x49: i = 2; break;
case 0x4c: i = 3; break;
case 0x4f: i = 4; break;
case 0x55: i = 5; c = 0xeb; break;
default: return;
}

const Uint8* char_bitmap = gear[i];

for (int y = 0; y < 8; y++) {
Uint8 pixel_row = char_bitmap[y];
for (int x = 0; x < 8; x++) {
Uint8 pixel = (pixel_row & (0x80 >> x)) >> (7 - x);

if (pixel) {
int pixel_index = (y_offset * 8 + y) * GPWORLD_OVERLAY_W + (x_offset * 8 + x);
*((Uint8 *)m_video_overlay[m_active_video_overlay]->pixels + pixel_index) = c;
}
}
}
}

void gpworld::draw_shift(const char* w)
{
const int x_offset = 0x01, y_offset = 0x1c;

for (int i = 0; w[i] != '\0'; i++) {
draw_char(w[i], x_offset + i, y_offset);
}
}

// updates gpworld's video
void gpworld::repaint()
{
// This should be much faster
SDL_FillRect(m_video_overlay[m_active_video_overlay], NULL, m_transparent_color);

// draw low or high depending on the state of the shifter
const char *t = "HIGH";
if (banks[2]) t = "LOW";
video::draw_string(t, 1, 225, m_video_overlay[m_active_video_overlay]);

// The sprites are bottom priority so we draw them first
// START modified Mame code
// check if sprites need to be drawn
Expand Down Expand Up @@ -591,16 +623,8 @@ void gpworld::repaint()
}
}

// test - make an 8x8 block of every color
// for (x = 0; x < 256; x++)
// {
// for (int y = 0; y <256; y++)
// {
// *((Uint8 *) m_video_overlay[m_active_video_overlay]->pixels + y *
//GPWORLD_OVERLAY_W + x) = x / 16 + (y / 16) * 16;
// }
// }

// draw state of the shifter
if (m_shifter) draw_shift(banks[2] ? "DLO" : "UHI");
}

// this gets called when the user presses a key or moves the joystick
Expand Down Expand Up @@ -822,6 +846,7 @@ void gpworld::draw_sprite(int spr_number)
void gpworld::set_preset(int preset)
{
if (preset == 1) m_align = true;
if (preset == 2) m_shifter = false;
}

void gpworld::align()
Expand Down
14 changes: 13 additions & 1 deletion src/game/gpworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class gpworld : public game
public:

typedef enum {
S_GP_ENGINE1, S_GP_ENGINE2, S_GP_CRASH, S_GP_COUNT, S_GP_START,
S_GP_ENG1, S_GP_ENG2, S_GP_CRASH, S_GP_COUNT, S_GP_START,
S_GP_COIN, S_GP_DINK, S_GP_TIRE, S_GP_GEAR, S_GP_REV
} GPWorldSound;

Expand All @@ -80,6 +80,8 @@ class gpworld : public game
void align();
void recalc_palette();
void draw_sprite(int);
void draw_char(char, int, int);
void draw_shift(const char*);
Uint8 rombank[0x8000];
Uint8 character[0x1000];
Uint8 sprite[0x30000];
Expand All @@ -95,7 +97,17 @@ class gpworld : public game
Uint8 ign;
bool nmie;
bool m_align;
bool m_shifter;
Uint8 banks[7];

const Uint8 gear[6][8] = {
{0x00,0x18,0x18,0x18,0x7e,0x7e,0x3c,0x18},
{0x24,0x24,0x24,0x7E,0x24,0x24,0x24,0x24},
{0x00,0x00,0x38,0x10,0x10,0x10,0x10,0x38},
{0x70,0x20,0x20,0x20,0x20,0x20,0x24,0x7c},
{0x00,0x00,0x38,0x44,0x44,0x44,0x44,0x38},
{0x18,0x3c,0x7e,0x7e,0x18,0x18,0x18,0x00}
};
};

#endif
5 changes: 2 additions & 3 deletions src/game/laireuro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,6 @@ Uint8 laireuro::cpu_mem_read(Uint16 addr)

// video ram
else if (addr >= 0xc000 && addr <= 0xc7ff) {
// MPO : video shouldn't change on a READ. I'm assuming this was an
// oversight.
// m_video_overlay_needs_update = true;
}

// ?
Expand Down Expand Up @@ -236,6 +233,7 @@ void laireuro::cpu_mem_write(Uint16 addr, Uint8 value)
// video ram
else if (addr >= 0xc000 && addr <= 0xc7ff) {
m_video_overlay_needs_update = true;
palette::set_yuv_transparency(false);
m_cpumem[addr] = value;
}

Expand Down Expand Up @@ -265,6 +263,7 @@ void laireuro::cpu_mem_write(Uint16 addr, Uint8 value)
}

m_video_overlay_needs_update = true;
palette::set_yuv_transparency(true);
m_cpumem[addr] = value;
}
// watchdog reset
Expand Down
1 change: 0 additions & 1 deletion src/game/lgp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
#include "../ldp-in/ldv1000.h"
#include "../ldp-out/ldp.h"
#include "../video/palette.h"
#include "../video/video.h"
#include "../sound/sound.h"
#include "../cpu/cpu.h"
#include "../cpu/generic_z80.h"
Expand Down
2 changes: 1 addition & 1 deletion src/game/singe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void singe::start()
if (blanking) {
if (video::get_video_blank()) {
if (intTimer > delay)
video::set_video_blank(false);
palette::set_yuv_transparency(true);
intTimer++;
} else intTimer = 0;
}
Expand Down
Loading

0 comments on commit c1e95b9

Please sign in to comment.