mirror of
https://gitea.tendokyu.moe/TeamTofuShop/taitools.git
synced 2026-09-29 10:18:15 +03:00
card reader: progress
This commit is contained in:
+42
-85
@@ -17,84 +17,22 @@
|
||||
|
||||
// JVS card reader, A/B/C vairants
|
||||
|
||||
static const uint8_t k92x0249_ident[] = "TAITO CORP.;JVS Reader;Ver1.00;0000.00.00";
|
||||
//static const uint8_t k92x0249_ident[] = "TAITO CORP.;JVS Reader;Ver0.20;0000.00.00";
|
||||
static const uint8_t k92x0249_ident[] = "TAITO CORP.;RFID CTRL P.C.B.;Ver1.11;"; // non-AICC: TAITO CORP.;JVS Reader;Ver1.00;
|
||||
|
||||
static uint8_t k92x0249_features[] = {
|
||||
/* Feature : 0x01 : Players and switches
|
||||
Param1 : 1 : Number of players
|
||||
Param2 : 18 : Number of switches per player
|
||||
Param3 : 0 : N/A */
|
||||
|
||||
0x01,
|
||||
0x01,
|
||||
0x18,
|
||||
// Misc. SW
|
||||
0x07,
|
||||
0x00,
|
||||
0x08,
|
||||
0x00,
|
||||
|
||||
/* Feature : 0x02 : Coin slots
|
||||
Param1 : 2 : Number of coin slots
|
||||
Param2 : 0 : N/A
|
||||
Param3 : 0 : N/A */
|
||||
|
||||
0x02,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
|
||||
/* Feature : 0x03 : Analog inputs
|
||||
Param1 : 8 : Number of ADC channels
|
||||
Param2 : 10 : Effective bits of resolution per ADC
|
||||
Param3 : 0 : N/A */
|
||||
|
||||
0x03,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
|
||||
/* Feature : 0x04 : Rotary Input
|
||||
Param1 : 4 : Number of Rotary channels
|
||||
Param2 : 0 : N/A
|
||||
Param3 : 0 : N/A */
|
||||
|
||||
0x04,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
|
||||
/* Feature : 0x12 : GPIO outputs
|
||||
Param1 : 3 : Number of ports (8 bits per port)
|
||||
Param2 : 0 : N/A
|
||||
Param3 : 0 : N/A
|
||||
*/
|
||||
|
||||
// GPIO Out
|
||||
0x12,
|
||||
0x00,
|
||||
0x00,
|
||||
0x00,
|
||||
|
||||
/* Feature : 0x13 : Analog outputs
|
||||
Param1 : 2 : Number of channels
|
||||
Param2 : 0 : N/A
|
||||
Param3 : 0 : N/A
|
||||
*/
|
||||
|
||||
0x13,
|
||||
0x00,
|
||||
0x08,
|
||||
0x00,
|
||||
0x00,
|
||||
|
||||
/* Feature : 0x14 : Character Output
|
||||
Param1 : 0x50 : Width
|
||||
Param2 : 0x19 : Height
|
||||
Param3 : 0 : Type
|
||||
*/
|
||||
0x14,
|
||||
0x50,
|
||||
0x19,
|
||||
0x00,
|
||||
|
||||
/* Feature : 0x00 : End of capabilities */
|
||||
|
||||
// End
|
||||
0x00,
|
||||
};
|
||||
|
||||
@@ -118,7 +56,9 @@ static HRESULT k92x0249_cmd_get_cmd_version(struct k92x0249 *k92x0249, struct co
|
||||
static HRESULT k92x0249_cmd_get_jvs_version(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_get_comm_version(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_get_features(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_write_gpio1(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_read_misc_switches(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, uint8_t req_len, struct iobuf *resp_buf);
|
||||
static HRESULT k92x0249_cmd_nesica_read(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, uint8_t req_len, struct iobuf *resp_buf);
|
||||
|
||||
void k92x0249_init(
|
||||
struct k92x0249 *k92x0249,
|
||||
@@ -134,6 +74,7 @@ void k92x0249_init(
|
||||
k92x0249->jvs.sense = k92x0249_sense;
|
||||
k92x0249->jvs.sense_out = true;
|
||||
k92x0249->addr = 0xFF;
|
||||
k92x0249->state = IDLE;
|
||||
k92x0249->ops = ops;
|
||||
k92x0249->ops_ctx = ops_ctx;
|
||||
}
|
||||
@@ -183,7 +124,7 @@ static HRESULT k92x0249_cmd(
|
||||
|
||||
iobuf_read_8(req, &req_len); // Read the length for variable-length commands
|
||||
|
||||
k92x0249 = ctx;
|
||||
k92x0249 = (struct k92x0249 *)ctx;
|
||||
|
||||
switch (req->bytes[req->pos]) {
|
||||
case JVS_CMD_RESET:
|
||||
@@ -207,8 +148,14 @@ static HRESULT k92x0249_cmd(
|
||||
case JVS_CMD_GET_FEATURES:
|
||||
return k92x0249_cmd_get_features(k92x0249, req, resp);
|
||||
|
||||
case JVS_CMD_READ_MISC_SWITCHES:
|
||||
case JVS_CMD_WRITE_GPIO1:
|
||||
return k92x0249_cmd_write_gpio1(k92x0249, req, resp);
|
||||
|
||||
case JVS_CMD_READ_MISC_SWITCHES: // used to check reader state?
|
||||
return k92x0249_cmd_read_misc_switches(k92x0249, req, req_len, resp);
|
||||
|
||||
case JVS_CMD_TAITO_NESICA_READ:
|
||||
return k92x0249_cmd_nesica_read(k92x0249, req, req_len, resp);
|
||||
|
||||
default:
|
||||
dprintf("K92X0249: Node %02x: Unhandled command byte %02x\n",
|
||||
@@ -381,6 +328,21 @@ static HRESULT k92x0249_cmd_get_features(struct k92x0249 *k92x0249, struct const
|
||||
return iobuf_write(resp_buf, k92x0249_features, sizeof(k92x0249_features));
|
||||
}
|
||||
|
||||
static HRESULT k92x0249_cmd_write_gpio1(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, struct iobuf *resp_buf)
|
||||
{
|
||||
uint8_t state;
|
||||
HRESULT hr = iobuf_read_8(req_buf, &state); // set reader state
|
||||
|
||||
if (FAILED(hr)) {
|
||||
return hr;
|
||||
}
|
||||
|
||||
k92x0249->state = state;
|
||||
|
||||
dprintf("K92X0249: Set state %02X", state);
|
||||
return iobuf_write_8(resp_buf, 0x01); /* Write report byte */
|
||||
}
|
||||
|
||||
static HRESULT k92x0249_cmd_read_misc_switches(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, uint8_t req_len, struct iobuf *resp_buf)
|
||||
{
|
||||
uint8_t req[255];
|
||||
@@ -404,19 +366,14 @@ static HRESULT k92x0249_cmd_read_misc_switches(struct k92x0249 *k92x0249, struct
|
||||
return hr;
|
||||
}
|
||||
|
||||
return iobuf_write_8(resp_buf, 0x00); /* Write switch byte */
|
||||
// Below will trip a card request with blank info
|
||||
// hr = iobuf_write(resp_buf, (uint8_t *)"7020000000000000", 16); /* Nesica ID */
|
||||
if (k92x0249->state == POLL_NESICA && (GetAsyncKeyState(VK_RETURN) & 0x8000)) {
|
||||
return iobuf_write_8(resp_buf, BLUE_NESICA | CARD_TOUCHED | SUCCESS);
|
||||
}
|
||||
|
||||
// if (FAILED(hr)) {
|
||||
// return hr;
|
||||
// }
|
||||
return iobuf_write_8(resp_buf, NO_CARD); /* Write status byte */
|
||||
}
|
||||
|
||||
// hr = iobuf_write(resp_buf, (uint8_t *)"00000000000000000000", 20); /* Access Code */
|
||||
|
||||
// if (FAILED(hr)) {
|
||||
// return hr;
|
||||
// }
|
||||
|
||||
// return iobuf_write_8(resp_buf, 0x01); /* is AICC */
|
||||
static HRESULT k92x0249_cmd_nesica_read(struct k92x0249 *k92x0249, struct const_iobuf *req_buf, uint8_t req_len, struct iobuf *resp_buf)
|
||||
{
|
||||
return iobuf_write_8(resp_buf, 0x01); /* Write status byte */
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "jvs/jvs-bus.h"
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct k92x0249_ops {
|
||||
void (*reset)(void *ctx);
|
||||
void (*write_led)(void *ctx, uint32_t state);
|
||||
@@ -11,11 +12,33 @@ struct k92x0249_ops {
|
||||
|
||||
struct k92x0249 {
|
||||
struct jvs_node jvs;
|
||||
uint8_t state;
|
||||
uint8_t addr;
|
||||
const struct k92x0249_ops *ops;
|
||||
void *ops_ctx;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
enum k92x0249_state {
|
||||
IDLE = 0x00,
|
||||
READY = 0x80, // unsure
|
||||
POLL_NESICA = 0xC0, // Blue or red
|
||||
POLL_AICC = 0xC2, // any AmusementIC card
|
||||
};
|
||||
|
||||
enum k92x0249_card_status {
|
||||
NO_CARD = 0x00,
|
||||
BLUE_NESICA = 0x01,
|
||||
AICC = 0x02,
|
||||
UNK04 = 0x04,
|
||||
CARD_TOUCHED = 0x08,
|
||||
SUCCESS = 0x10,
|
||||
ERR = 0x20,
|
||||
UNK40 = 0x40,
|
||||
UNK80 = 0x80,
|
||||
};
|
||||
|
||||
void k92x0249_init(
|
||||
struct k92x0249 *k92x0249,
|
||||
struct jvs_node *next,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct mifare_block {
|
||||
uint8_t bytes[16];
|
||||
};
|
||||
@@ -13,3 +14,10 @@ struct mifare_sector {
|
||||
struct mifare {
|
||||
struct mifare_sector sectors[16];
|
||||
};
|
||||
|
||||
struct nesica_mifare {
|
||||
uint8_t uid[7];
|
||||
char nesica_id[16];
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
@@ -30,6 +30,14 @@ enum {
|
||||
JVS_CMD_WRITE_GPIO2 = 0x37,
|
||||
JVS_CMD_WRITE_GPIO3 = 0x38,
|
||||
|
||||
JVS_CMD_TAITO_60 = 0x60,
|
||||
JVS_CMD_TAITO_NESICA_READ = 0x61,
|
||||
JVS_CMD_TAITO_NOOP_62 = 0x62,
|
||||
JVS_CMD_TAITO_NOOP_63 = 0x63,
|
||||
JVS_CMD_TAITO_NOOP_64 = 0x64,
|
||||
JVS_CMD_TAITO_UNK65 = 0x65,
|
||||
JVS_CMD_TAITO_AIC_READ = 0x65,
|
||||
|
||||
JVS_CMD_RESET = 0xF0,
|
||||
JVS_CMD_ASSIGN_ADDR = 0xF1,
|
||||
JVS_CMD_CHANGE_COMM_METHOD = 0xF2,
|
||||
|
||||
Reference in New Issue
Block a user