2019-03-16 16:57:17 +01:00
|
|
|
#include <windows.h>
|
|
|
|
|
2019-09-01 17:40:25 +02:00
|
|
|
#include <assert.h>
|
2019-03-16 16:57:17 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "amex/jvs.h"
|
|
|
|
|
|
|
|
#include "board/io3.h"
|
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
#include "divaio/divaio.h"
|
|
|
|
|
2019-03-16 16:57:17 +01:00
|
|
|
#include "jvs/jvs-bus.h"
|
|
|
|
|
|
|
|
#include "util/dprintf.h"
|
|
|
|
|
|
|
|
static void diva_jvs_read_switches(void *ctx, struct io3_switch_state *out);
|
2019-08-03 23:41:39 +02:00
|
|
|
static void diva_jvs_read_coin_counter(
|
|
|
|
void *ctx,
|
|
|
|
uint8_t slot_no,
|
|
|
|
uint16_t *out);
|
2019-03-16 16:57:17 +01:00
|
|
|
|
|
|
|
static const struct io3_ops diva_jvs_io3_ops = {
|
2019-05-03 01:38:39 +02:00
|
|
|
.read_switches = diva_jvs_read_switches,
|
|
|
|
.read_coin_counter = diva_jvs_read_coin_counter,
|
2019-03-16 16:57:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct io3 diva_jvs_io3;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2019-05-03 20:47:09 +02:00
|
|
|
uint8_t opbtn;
|
|
|
|
uint8_t gamebtn;
|
|
|
|
|
2019-03-16 16:57:17 +01:00
|
|
|
assert(out != NULL);
|
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
opbtn = 0;
|
|
|
|
gamebtn = 0;
|
2019-03-16 16:57:17 +01:00
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
diva_io_jvs_poll(&opbtn, &gamebtn);
|
2019-03-16 16:57:17 +01:00
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
if (gamebtn & 0x01) {
|
|
|
|
out->p1 |= 1 << 6;
|
2019-03-16 16:57:17 +01:00
|
|
|
}
|
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
if (gamebtn & 0x02) {
|
2019-03-16 16:57:17 +01:00
|
|
|
out->p1 |= 1 << 7;
|
|
|
|
}
|
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
if (gamebtn & 0x04) {
|
|
|
|
out->p1 |= 1 << 8;
|
2019-03-16 16:57:17 +01:00
|
|
|
}
|
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
if (gamebtn & 0x08) {
|
|
|
|
out->p1 |= 1 << 9;
|
|
|
|
}
|
2019-03-16 16:57:17 +01:00
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
if (gamebtn & 0x10) {
|
2019-03-16 16:57:17 +01:00
|
|
|
out->p1 |= 1 << 15;
|
|
|
|
}
|
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
if (opbtn & 0x01) {
|
2019-03-16 16:57:17 +01:00
|
|
|
out->system = 0x80;
|
|
|
|
} else {
|
|
|
|
out->system = 0;
|
|
|
|
}
|
|
|
|
|
2019-05-03 20:47:09 +02:00
|
|
|
if (opbtn & 0x02) {
|
|
|
|
out->p1 |= 1 << 14;
|
2019-03-16 16:57:17 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-03 23:41:39 +02:00
|
|
|
static void diva_jvs_read_coin_counter(
|
|
|
|
void *ctx,
|
|
|
|
uint8_t slot_no,
|
|
|
|
uint16_t *out)
|
2019-03-16 16:57:17 +01:00
|
|
|
{
|
|
|
|
if (slot_no > 0) {
|
2019-08-03 23:41:39 +02:00
|
|
|
return;
|
2019-03-16 16:57:17 +01:00
|
|
|
}
|
|
|
|
|
2019-08-03 23:41:39 +02:00
|
|
|
diva_io_jvs_read_coin_counter(out);
|
2019-03-16 16:57:17 +01:00
|
|
|
}
|