2019-03-16 15:57:17 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "amex/jvs.h"
|
|
|
|
|
|
|
|
#include "board/io3.h"
|
|
|
|
|
|
|
|
#include "jvs/jvs-bus.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out);
|
2019-05-02 23:38:39 +00:00
|
|
|
static uint16_t diva_jvs_read_coin_counter(void *ctx, uint8_t slot_no);
|
2019-03-16 15:57:17 +00:00
|
|
|
|
|
|
|
static const struct io3_ops diva_jvs_io3_ops = {
|
2019-05-02 23:38:39 +00:00
|
|
|
.read_switches = diva_jvs_read_switches,
|
|
|
|
.read_coin_counter = diva_jvs_read_coin_counter,
|
2019-03-16 15:57:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct io3 diva_jvs_io3;
|
|
|
|
static bool diva_jvs_coin;
|
2019-05-02 23:38:39 +00:00
|
|
|
static uint16_t diva_jvs_coins;
|
2019-03-16 15:57:17 +00:00
|
|
|
|
|
|
|
void diva_jvs_init(void)
|
|
|
|
{
|
|
|
|
io3_init(&diva_jvs_io3, NULL, &diva_jvs_io3_ops, NULL);
|
|
|
|
jvs_attach(&diva_jvs_io3.jvs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out)
|
|
|
|
{
|
|
|
|
assert(out != NULL);
|
|
|
|
|
|
|
|
/* Update gameplay buttons (P2 JVS input is not even polled) */
|
|
|
|
|
|
|
|
if (GetAsyncKeyState('S')) {
|
|
|
|
out->p1 |= 1 << 9;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetAsyncKeyState('F')) {
|
|
|
|
out->p1 |= 1 << 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetAsyncKeyState('J')) {
|
|
|
|
out->p1 |= 1 << 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetAsyncKeyState('L')) {
|
|
|
|
out->p1 |= 1 << 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update start button */
|
|
|
|
|
|
|
|
if (GetAsyncKeyState(VK_SPACE)) {
|
|
|
|
out->p1 |= 1 << 15;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Update test/service buttons */
|
|
|
|
|
|
|
|
if (GetAsyncKeyState('1')) {
|
|
|
|
out->system = 0x80;
|
|
|
|
} else {
|
|
|
|
out->system = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetAsyncKeyState('2')) {
|
|
|
|
out->p1 |= 0x4000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-02 23:38:39 +00:00
|
|
|
static uint16_t diva_jvs_read_coin_counter(void *ctx, uint8_t slot_no)
|
2019-03-16 15:57:17 +00:00
|
|
|
{
|
|
|
|
if (slot_no > 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetAsyncKeyState('3')) {
|
2019-05-02 23:38:39 +00:00
|
|
|
if (!diva_jvs_coin) {
|
2019-03-16 15:57:17 +00:00
|
|
|
dprintf("Diva JVS: Coin drop\n");
|
|
|
|
diva_jvs_coin = true;
|
2019-05-02 23:38:39 +00:00
|
|
|
diva_jvs_coins++;
|
2019-03-16 15:57:17 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
diva_jvs_coin = false;
|
|
|
|
}
|
2019-05-02 23:38:39 +00:00
|
|
|
|
|
|
|
return diva_jvs_coins;
|
2019-03-16 15:57:17 +00:00
|
|
|
}
|