Skip to content

Commit

Permalink
extended arguments for VM2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
megavolt85 committed Apr 3, 2024
1 parent b40aaba commit 73e5db7
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 35 deletions.
1 change: 1 addition & 0 deletions backend/gd_item.h
Expand Up @@ -20,3 +20,4 @@ typedef struct gd_item {
unsigned int slot_num;
char vga[1];
} gd_item;

4 changes: 2 additions & 2 deletions backend/gdemu_control.c
Expand Up @@ -93,7 +93,7 @@ void dreamcast_launch_disc(gd_item *disc) {

if (vm2_dev)
{
vm2_set_id(vm2_dev, disc->product);
vm2_set_id(vm2_dev, disc->product, disc->name);
}

wait_cd_ready();
Expand Down Expand Up @@ -190,7 +190,7 @@ void dreamcast_launch_cb(gd_item *disc) {

if (vm2_dev)
{
vm2_set_id(vm2_dev, disc->product);
vm2_set_id(vm2_dev, disc->product, disc->name);
}

wait_cd_ready();
Expand Down
2 changes: 1 addition & 1 deletion inc/vm2_api.h
Expand Up @@ -14,5 +14,5 @@ typedef struct maple_alldevinfo {
} maple_alldevinfo_t;


int vm2_set_id(maple_device_t * dev, const char *ID);
int vm2_set_id(maple_device_t * dev, const char *ID, const char *name);
int check_vm2_present(maple_device_t * dev);
36 changes: 21 additions & 15 deletions main.c
Expand Up @@ -311,23 +311,28 @@ int main(int argc, char *argv[]) {

//gdemu_set_img_num(1);
//thd_sleep(500);
maple_device_t * vmu = maple_enum_type(0, MAPLE_FUNC_MEMCARD);

if (vmu && check_vm2_present(vmu))
for (int i = 0; i < 8; i++)
{
int port, unit;

port = vmu->port;
unit = vmu->unit;

vm2_set_id(vmu, "openmenu");
vm2_dev = vmu;
maple_device_t * vmu = maple_enum_type(i, MAPLE_FUNC_MEMCARD);

thd_sleep(200);

while (!maple_enum_dev(port, unit))
if (vmu && check_vm2_present(vmu))
{
thd_pass();
int port, unit;

port = vmu->port;
unit = vmu->unit;

vm2_set_id(vmu, "openmenu", NULL);
vm2_dev = vmu;

thd_sleep(200);

while (!maple_enum_dev(port, unit))
{
thd_pass();
}

break;
}
}

Expand Down Expand Up @@ -368,7 +373,8 @@ void exit_to_bios(void) {

if (vm2_dev)
{
vm2_set_id(vm2_dev, get_cur_game_id());
const gd_item *item = get_cur_game_item();
vm2_set_id(vm2_dev, item->product, item->name);
}

arch_exec_at(bloader_data, bloader_size, 0xacf00000);
Expand Down
2 changes: 1 addition & 1 deletion ui/ui_grid.c
Expand Up @@ -565,7 +565,7 @@ static void menu_exit(void) {
return;
}

set_cur_game_id(list_current[current_selected()]->product);
set_cur_game_item(list_current[current_selected()]);
draw_current = DRAW_EXIT;
popup_setup(&draw_current, current_theme_colors, &navigate_timeout);
}
Expand Down
2 changes: 1 addition & 1 deletion ui/ui_line_desc.c
Expand Up @@ -413,7 +413,7 @@ static void menu_exit(void) {
return;
}

set_cur_game_id(list_current[current_selected_item]->product);
set_cur_game_item(list_current[current_selected_item]);
draw_current = DRAW_EXIT;
popup_setup(&draw_current, &region_themes[region_current].colors, &navigate_timeout);
}
Expand Down
11 changes: 5 additions & 6 deletions ui/ui_menu_credits.c
Expand Up @@ -42,8 +42,7 @@ static theme_scroll* custom_scroll;
static int num_custom_themes;
int cb_multidisc = 0;
int start_cb = 0;
static const char * cur_game_pid = NULL;

static const gd_item * cur_game_item = NULL;

#define MENU_OPTIONS ((int)(sizeof(menu_choice_text) / sizeof(menu_choice_text)[0]))
#define MENU_CHOICES (MENU_OPTIONS) /* Only those with selectable options */
Expand Down Expand Up @@ -110,14 +109,14 @@ static uint32_t menu_bkg_color;
static uint32_t menu_bkg_border_color;
static openmenu_settings* settings = NULL;

void set_cur_game_id(const char *id)
void set_cur_game_item(const gd_item *id)
{
cur_game_pid = id;
cur_game_item = id;
}

const char *get_cur_game_id()
const gd_item *get_cur_game_item()
{
return cur_game_pid;
return cur_game_item;
}

static void common_setup(enum draw_state* state, theme_color* _colors, int* timeout_ptr) {
Expand Down
5 changes: 3 additions & 2 deletions ui/ui_menu_credits.h
Expand Up @@ -12,6 +12,7 @@

#include "common.h"
#include "global_settings.h"
#include "backend/gd_item.h"

struct theme_color;

Expand Down Expand Up @@ -39,5 +40,5 @@ void draw_exit_tr(void);
void draw_codebreaker_op(void);
void draw_codebreaker_tr(void);

void set_cur_game_id(const char *id);
const char *get_cur_game_id();
void set_cur_game_item(const gd_item *id);
const gd_item *get_cur_game_item();
2 changes: 1 addition & 1 deletion ui/ui_scroll.c
Expand Up @@ -449,7 +449,7 @@ static void menu_exit(void) {
return;
}

set_cur_game_id(list_current[current_selected_item]->product);
set_cur_game_item(list_current[current_selected_item]);

draw_current = DRAW_EXIT;
popup_setup(&draw_current, &cur_theme->colors, &navigate_timeout);
Expand Down
17 changes: 11 additions & 6 deletions vm2_api.c
Expand Up @@ -19,11 +19,12 @@ static void vbl_allinfo_callback(maple_frame_t * frm)
/* Copy in the new buff */
memcpy(recv_buff, resp, 196);
}
else
/*else
{
printf("maple: bad response %d on device\n",resp->response);
memcpy(recv_buff, resp, 196);
}
}*/

maple_frame_unlock(frm);
genwait_wake_all(frm);
Expand Down Expand Up @@ -87,7 +88,7 @@ static void vm2_reply(maple_frame_t * frm)
genwait_wake_all(frm);
}

int vm2_set_id(maple_device_t * dev, const char *ID)
int vm2_set_id(maple_device_t * dev, const char *ID, const char *name)
{
maple_response_t *resp;
uint32_t *send_buf;
Expand All @@ -100,11 +101,15 @@ int vm2_set_id(maple_device_t * dev, const char *ID)
maple_frame_init(&dev->frame);
send_buf = (uint32_t *)dev->frame.recv_buf;
send_buf[0] = MAPLE_FUNC_MEMCARD;
strncpy((char *) &dev->frame.recv_buf[4], ID, 11);
strncpy((char *) &dev->frame.recv_buf[4], ID, 12);
if (name)
{
strncpy((char *) &dev->frame.recv_buf[16], name, 128);
}
dev->frame.cmd = 33;
dev->frame.dst_port = dev->port;
dev->frame.dst_unit = dev->unit;
dev->frame.length = 4;
dev->frame.length = name ? 36 : 4;
dev->frame.callback = vm2_reply;
dev->frame.send_buf = send_buf;
maple_queue_frame(&dev->frame);
Expand Down Expand Up @@ -153,7 +158,7 @@ int check_vm2_present(maple_device_t * dev)
return 1;
}

printf("check_vm2_present ERROR: %s", info->extended);
printf("check_vm2_present ERROR: %s\n", info->extended);

return 0;
}
Expand Down

0 comments on commit 73e5db7

Please sign in to comment.