Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
pad strings in maple responses with spaces
- Loading branch information
Showing
with
55 additions
and
30 deletions.
-
+15
−13
src/hw/maple/controller.c
-
+13
−0
src/hw/maple/maple.h
-
+14
−6
src/hw/maple/maple_types.h
-
+13
−11
src/hw/maple/vmu.c
|
@@ -46,23 +46,25 @@ static int controller_frame(struct maple_device *dev, |
|
|
|
|
|
switch (frame->header.command) { |
|
|
case MAPLE_REQ_DEVINFO: { |
|
|
static struct maple_device_info controller_devinfo = { |
|
|
MAPLE_FUNC_CONTROLLER, |
|
|
{0xfe060f00, 0x0, 0x0}, |
|
|
0xff, |
|
|
0, |
|
|
"Dreamcast Controller", |
|
|
"Produced By or Under License From SEGA ENTERPRISES,LTD.", |
|
|
0x01ae, |
|
|
0x01f4}; |
|
|
/* based on captured result of real Dreamcast controller */ |
|
|
struct maple_device_info info = {0}; |
|
|
info.func = MAPLE_FUNC_CONTROLLER; |
|
|
info.data[0] = 0xfe060f00; |
|
|
info.region = 0xff; |
|
|
maple_strncpy(info.name, "Dreamcast Controller", sizeof(info.name)); |
|
|
maple_strncpy(info.license, |
|
|
"Produced By or Under License From SEGA ENTERPRISES,LTD.", |
|
|
sizeof(info.license)); |
|
|
info.standby_power = 0x01ae; |
|
|
info.max_power = 0x01f4; |
|
|
|
|
|
res->header.command = MAPLE_RES_DEVINFO; |
|
|
res->header.recv_addr = frame->header.send_addr; |
|
|
res->header.send_addr = frame->header.recv_addr; |
|
|
res->header.num_words = sizeof(controller_devinfo) >> 2; |
|
|
memcpy(res->params, &controller_devinfo, sizeof(controller_devinfo)); |
|
|
} |
|
|
res->header.num_words = sizeof(info) >> 2; |
|
|
memcpy(res->params, &info, sizeof(info)); |
|
|
return 1; |
|
|
} |
|
|
|
|
|
case MAPLE_REQ_GETCOND: { |
|
|
controller_update(ctrl); |
|
@@ -72,8 +74,8 @@ static int controller_frame(struct maple_device *dev, |
|
|
res->header.send_addr = frame->header.recv_addr; |
|
|
res->header.num_words = sizeof(ctrl->cnd) >> 2; |
|
|
memcpy(res->params, &ctrl->cnd, sizeof(ctrl->cnd)); |
|
|
} |
|
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
return 0; |
|
|
|
@@ -18,6 +18,19 @@ struct maple_device { |
|
|
struct maple_frame *); |
|
|
}; |
|
|
|
|
|
/* strings passed as responses to maple queries are not null-terminated, and |
|
|
instead padded with spaces to their maximum width */ |
|
|
static inline void maple_strncpy(char *dst, const char *str, int size) { |
|
|
int len = strlen(str); |
|
|
size -= len; |
|
|
while (len--) { |
|
|
*(dst++) = *(str++); |
|
|
} |
|
|
while (size--) { |
|
|
*(dst++) = ' '; |
|
|
} |
|
|
} |
|
|
|
|
|
struct maple *maple_create(struct dreamcast *dc); |
|
|
void maple_destroy(struct maple *mp); |
|
|
|
|
|
|
@@ -90,13 +90,21 @@ struct maple_frame { |
|
|
|
|
|
/* response to MAPLE_REQ_DEVINFO */ |
|
|
struct maple_device_info { |
|
|
uint32_t function; |
|
|
uint32_t function_data[3]; |
|
|
uint8_t area_code; |
|
|
uint8_t connector_direction; |
|
|
char product_name[30]; |
|
|
char product_license[60]; |
|
|
/* function codes supported by this peripheral */ |
|
|
uint32_t func; |
|
|
/* additional data for the function codes (3 max) */ |
|
|
uint32_t data[3]; |
|
|
/* region code of peripheral */ |
|
|
uint8_t region; |
|
|
/* physical orientation of bus connection */ |
|
|
uint8_t direction; |
|
|
/* name of peripheral */ |
|
|
char name[30]; |
|
|
/* license statement */ |
|
|
char license[60]; |
|
|
/* standby power consumption */ |
|
|
uint16_t standby_power; |
|
|
/* max power consumption */ |
|
|
uint16_t max_power; |
|
|
}; |
|
|
|
|
|
|
@@ -82,21 +82,23 @@ static int vmu_frame(struct maple_device *dev, const struct maple_frame *frame, |
|
|
|
|
|
switch (frame->header.command) { |
|
|
case MAPLE_REQ_DEVINFO: { |
|
|
static struct maple_device_info vmu_devinfo = { |
|
|
MAPLE_FUNC_MEMORYCARD, |
|
|
{0x00410f00, 0x0, 0x0}, |
|
|
0xff, |
|
|
0x0, |
|
|
"Visual Memory", |
|
|
"Produced By or Under License From SEGA ENTERPRISES,LTD.", |
|
|
0x007c, |
|
|
0x0082}; |
|
|
/* based on captured result of real Dreamcast VMU */ |
|
|
struct maple_device_info info; |
|
|
info.func = MAPLE_FUNC_MEMORYCARD; |
|
|
info.data[0] = 0x00410f00; |
|
|
info.region = 0xff; |
|
|
maple_strncpy(info.name, "Visual Memory", sizeof(info.name)); |
|
|
maple_strncpy(info.license, |
|
|
"Produced By or Under License From SEGA ENTERPRISES,LTD.", |
|
|
sizeof(info.license)); |
|
|
info.standby_power = 0x007c; |
|
|
info.max_power = 0x0082; |
|
|
|
|
|
res->header.command = MAPLE_RES_DEVINFO; |
|
|
res->header.recv_addr = frame->header.send_addr; |
|
|
res->header.send_addr = frame->header.recv_addr; |
|
|
res->header.num_words = sizeof(vmu_devinfo) >> 2; |
|
|
memcpy(res->params, &vmu_devinfo, sizeof(vmu_devinfo)); |
|
|
res->header.num_words = sizeof(info) >> 2; |
|
|
memcpy(res->params, &info, sizeof(info)); |
|
|
return 1; |
|
|
} |
|
|
|
|
|