DECL(int, FSAddClientEx, void *r3, void *r4, void *r5) { int res = real_FSAddClientEx(r3, r4, r5); if ((int)bss_ptr != 0x0a000000 && res >= 0) { if (GAME_RPX_LOADED != 0) { int client = client_num_alloc(r3); if (client >= 0) { if (fs_connect(&bss.socket_fs[client]) != 0) client_num_free(client); } } } return res; }
DECL(int, FSInit, void) { if ((int)bss_ptr == 0x0a000000) { bss_ptr = memalign(sizeof(struct bss_t), 0x40); memset(bss_ptr, 0, sizeof(struct bss_t)); // setup exceptions setup_os_exceptions(); // create game mount path prefix __os_snprintf(bss.mount_base, sizeof(bss.mount_base), "%s%s/%s%s", CAFE_OS_SD_PATH, SD_GAMES_PATH, GAME_DIR_NAME, CONTENT_PATH); // create game save path prefix __os_snprintf(bss.save_base, sizeof(bss.save_base), "%s%s/%s", CAFE_OS_SD_PATH, SD_SAVES_PATH, GAME_DIR_NAME); fs_connect(&bss.global_sock); // Call real FSInit int result = real_FSInit(); // Mount sdcard FSClient *pClient = (FSClient*) MEMAllocFromDefaultHeap(sizeof(FSClient)); if (!pClient) return 0; FSCmdBlock *pCmd = (FSCmdBlock*) MEMAllocFromDefaultHeap(sizeof(FSCmdBlock)); if (!pCmd) { MEMFreeToDefaultHeap(pClient); return 0; } FSInitCmdBlock(pCmd); FSAddClientEx(pClient, 0, FS_RET_NO_ERROR); fs_mount_sd(bss.global_sock, pClient, pCmd); FSDelClient(pClient); MEMFreeToDefaultHeap(pCmd); MEMFreeToDefaultHeap(pClient); return result; } return real_FSInit(); }
/* * lcd_an_register * @lcd: LCD data. * This function will register a LCD driver. */ void lcd_an_register(LCD_AN *lcd) { int32_t status = SUCCESS; /* Initialize LCD. */ LCD_AN_TGT_CLR_RS(lcd); LCD_AN_TGT_SET_RW(lcd); LCD_AN_TGT_CLR_EN(lcd); #if (LCD_AN_INIT_DELAY > 0) /* Need to wait at least 15ms on power up. */ sleep_ms(LCD_AN_INIT_DELAY); #endif /* Send first 0x3. */ lcd_an_send_nibble(lcd, 0x3); /* Controller still think that we are using 8bit mode so we can still read * the status bit. */ status = lcd_an_wait_8bit(lcd); if (status == SUCCESS) { /* Send second 0x3. */ LCD_AN_TGT_CLR_RW(lcd); lcd_an_send_nibble(lcd, 0x3); /* Wait for LCD to process the command in 8 bit mode. */ status = lcd_an_wait_8bit(lcd); } if (status == SUCCESS) { /* Send third 0x3. */ LCD_AN_TGT_CLR_RW(lcd); lcd_an_send_nibble(lcd, 0x3); /* Wait for LCD to process the command in 8 bit mode. */ status = lcd_an_wait_8bit(lcd); } if (status == SUCCESS) { /* Switch to 4-bit mode. */ LCD_AN_TGT_CLR_RW(lcd); lcd_an_send_nibble(lcd, 0x2); /* Wait for LCD to process the command in 8 bit mode. */ status = lcd_an_wait_8bit(lcd); } /* LCD configuration. */ if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x28); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x28); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x08); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x01); #if (LCD_AN_CLEAR_DELAY > 0) /* Wait for sometime before writing any more data. */ sleep_ms(LCD_AN_CLEAR_DELAY); #endif } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x06); } if (status == SUCCESS) { status = lcd_an_write_register(lcd, FALSE, 0x0C); } if (status == SUCCESS) { /* Reset the cursor location. */ lcd->cur_column = lcd->cur_row = 0; /* Register this LCD driver with console. */ lcd->console.fs.write = &lcd_an_write; lcd->console.fs.ioctl = &lcd_an_ioctl; console_register(&lcd->console); /* There is always some space available for data to be sent. */ lcd->console.fs.flags |= FS_SPACE_AVAILABLE; #ifdef LCD_AN_DEBUG lcd_an_fd = fs_open("\\console\\lcd1", 0); /* Connect LCD with debug console. */ fs_connect(lcd_an_fd, debug_fd); #endif } } /* lcd_an_register */