Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion src/openmenu/src/backend/gdemu_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "backend/gdemu_sdk.h"
#include "backend/gdmenu_binary.h"
#include "vm2/vm2_api.h"

extern maple_device_t* vm2_dev;

static void
Expand All @@ -19,7 +20,37 @@ wait_cd_ready(void) {
}
thd_sleep(20);
}
return;
}

void
bloom_launch(gd_item* disc) {
file_t fd;
uint32_t bloom_size;
uint8_t* bloom_buf;

fd = fs_open("/cd/BLOOM.BIN", O_RDONLY);

if (fd == -1) {
printf("Can't open %s\n", "/cd/BLOOM.BIN");
return;
}

fs_seek(fd, 0, SEEK_END);
bloom_size = fs_tell(fd);
fs_seek(fd, 0, SEEK_SET);
bloom_buf = (uint8_t*)malloc(bloom_size + 32);
bloom_buf = (uint8_t*)(((uint32_t)bloom_buf & 0xffffffe0) + 0x20);
fs_read(fd, bloom_buf, bloom_size);
fs_close(fd);

gdemu_set_img_num((uint16_t)disc->slot_num);

wait_cd_ready();

/* Patch */
((uint16_t*)0xAC000198)[0] = 0xFF86;

arch_exec(bloom_buf, bloom_size);
}

void
Expand Down
18 changes: 5 additions & 13 deletions src/openmenu/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
#include <dc/maple/controller.h>
#include <dc/pvr.h>
#include <dc/video.h>
#include <kos/thread.h>

#include <backend/db_list.h>
#include <backend/gd_list.h>
#include "vm2/vm2_api.h"
#include <openmenu_savefile.h>
#include <openmenu_settings.h>
#include "ui/common.h"
#include "ui/dc/input.h"
#include "ui/ui_common.h"
#include "ui/draw_prototypes.h"
#include <openmenu_settings.h>
#include <openmenu_savefile.h>
#include "ui/ui_common.h"
#include "ui/ui_menu_credits.h"
#include "vm2/vm2_api.h"

/* UI Collection */
#include "ui/ui_grid.h"
Expand Down Expand Up @@ -88,15 +89,6 @@ ui_set_choice(int choice) {
(*current_ui_setup)();
}

int
round(float x) {
if (x < 0.0f) {
return (int)(x - 0.5f);
} else {
return (int)(x + 0.5f);
}
}

void
reload_ui(void) {
need_reload_ui = 1;
Expand Down
9 changes: 1 addition & 8 deletions src/openmenu/src/texture/simple_texture_allocator.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include <stdlib.h>
#include <string.h>

#include "texture/txr_manager.h"
#include "texture/simple_texture_allocator.h"
#include "texture/txr_manager.h"

static struct Simple_Texture textures[32];
static void* tex_buffer = NULL;
Expand All @@ -34,16 +34,13 @@ texman_inited(void) {

void
texman_reset(void* buf, uint32_t size) {
// txr_empty_small_pool();
// txr_empty_large_pool();
memset(textures, 0, sizeof(textures));
tex_number = 0;
tex_buffer = tex_buffer_start = buf;
tex_buffer_max = buf + size;
#ifdef DEBUG
char msg[64];
sprintf(msg, "TEXMAN: reset @ %p size %d bytes\n", buf, size);
// sceIoWrite(1, msg, strlen(msg));
printf(msg);
#endif
}
Expand All @@ -56,7 +53,6 @@ texman_clear(void) {
#ifdef DEBUG
char msg[64];
sprintf(msg, "TEXMAN: clear %p size %d bytes!\n", tex_buffer, TEXMAN_BUFFER_SIZE);
// sceIoWrite(1, msg, strlen(msg));
printf(msg);
#endif
}
Expand Down Expand Up @@ -114,7 +110,4 @@ texman_upload(uint32_t width, uint32_t height, int bpp, const void* buffer) {
current->width = width;
current->height = height;
memcpy(current->location, buffer, getMemorySize(width, height, bpp));
#ifdef DEBUG
// printf("TEX_MAN upload plain [%d]\n", tex_number);
#endif
}
6 changes: 3 additions & 3 deletions src/openmenu/src/ui/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

#pragma once

#include <sys/stat.h>
#include <kos/fs.h>

#include <easing.h>

enum control { NONE = 0, LEFT, RIGHT, UP, DOWN, A, B, X, Y, START, TRIG_L, TRIG_R };

static inline int
file_exists(const char* path) {
struct stat buffer;
return (stat(path, &buffer) == 0);
struct stat st;
return (fs_stat(path, &st, STAT_TYPE_NONE) == 0);
}
15 changes: 0 additions & 15 deletions src/openmenu/src/ui/dc/font_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ font_bmp_begin_draw() {
font.texture.texture, PVR_FILTER_BILINEAR);
pvr_poly_compile(&font_header, &tmp);
#endif

/* Start a textured polygon set (with the font texture) */
// pvr_prim(&font_header, sizeof(font_header));
}

void
Expand Down Expand Up @@ -203,18 +200,6 @@ _font_bmp_draw_string(int x1, int y1, const char* str) {
void
font_bmp_draw_sub_wrap(int x1, int y1, int width, const char* str) {
(void)width;
#if 0
int x_start = x1;
do {
unsigned char chr = (*str) + (1 * 128);
font_draw_char(x1, y1, color, chr, 0);
x1 += (int)(char_widths[chr - 32] * FONT_SIZE_SUB + 1);
if ((x1 - x_start >= width) && (*str == ' ')) {
y1 += (FONT_HEIGHT * FONT_SIZE_SUB) + 4;
x1 = x_start;
}
} while (*++str) {
#endif
_font_bmp_draw_string(x1, y1, str);
}

Expand Down
11 changes: 2 additions & 9 deletions src/openmenu/src/ui/dc/font_bmf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
*/

#include <dc/pvr.h>
#include <kos/fs.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <gdrom/gdrom_fs.h>
#include <dbgprint.h>
#include "ui/draw_prototypes.h"

Expand Down Expand Up @@ -256,12 +256,6 @@ static int
BMF_parse_kerning(file_t fd, size_t block_size, bm_font* font) {
DBG_PRINT("BMF found kerning block!\n");

/* Do nothing! */
/*
fseek(fd, block_size, SEEK_CUR);
font->kerns = NULL;
*/

/* Parse and save */
int num_pairs = block_size / sizeof(bm_kern_pair);

Expand Down Expand Up @@ -407,8 +401,7 @@ font_bmf_init(const char* fnt, const char* texture, int is_wide) {
}
int ret = 0;
char temp_fnt[128];
memcpy(temp_fnt, DISC_PREFIX, strlen(DISC_PREFIX) + 1);
strcat(temp_fnt, fnt);
snprintf(temp_fnt, 127, "/cd/%s", fnt);

/* If we arent loaded then load eveyrthing, otherwise just load texture */
if (!font_loaded) {
Expand Down
4 changes: 0 additions & 4 deletions src/openmenu/src/ui/dc/input.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ INPT_ReceiveFromHost(inputs _in) {

/* Handle Analog Axes Values */
/* Loops through 4 Axes for 2 Analog Sticks */
/*for (int index = 0; index < 2; index++)
{
uint8_t *axes_in = (&_in.axes_1) + index;
}*/
_current.axes_1 = _in.axes_1;
_current.axes_2 = _in.axes_2;

Expand Down
9 changes: 3 additions & 6 deletions src/openmenu/src/ui/dc/pvr_texture.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
* -----
* Copyright (c) 2019 Hayden Kowalchuk
*/
#include "pvr_texture.h"

#include <kos/fs.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <gdrom/gdrom_fs.h>
#include "pvr_texture.h"

#define PVR_HDR_SIZE 0x20

Expand Down Expand Up @@ -139,9 +138,7 @@ static void
pvr_read_to_internal(const char* filename) {
uint32_t texSize;
file_t tex_fd;
// memcpy(filename_safe, DISC_PREFIX, strlen(DISC_PREFIX) + 1);
// strcat(filename_safe, filename);
snprintf(filename_safe, 127, "%s%s", DISC_PREFIX, filename);
snprintf(filename_safe, 127, "/cd/%s", filename);

/* replace all - with _ */
char* iter = filename_safe;
Expand Down
14 changes: 6 additions & 8 deletions src/openmenu/src/ui/draw_kos.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* http://www.opensource.org/licenses/BSD-3-Clause
*/

#include <math.h>
#include <stdio.h>

#include <backend/dat_format.h>
Expand All @@ -17,8 +18,6 @@

#include "ui/draw_kos.h"

extern int round(float x);

image img_empty_boxart;
image img_dir_boxart;

Expand Down Expand Up @@ -148,13 +147,12 @@ draw_load_texture_from_DAT_to_buffer(const struct dat_file* bin, const char* ID,
img->height = img_empty_boxart.height;
img->format = img_empty_boxart.format;
return img;
} else {
txr =
load_pvr_from_buffer_to_buffer(pvr_get_internal_buffer(), &img->width, &img->height, &img->format, buffer);
img->texture = txr;

return user;
}

txr = load_pvr_from_buffer_to_buffer(pvr_get_internal_buffer(), &img->width, &img->height, &img->format, buffer);
img->texture = txr;

return user;
}

/* draws an image at coords of a given size */
Expand Down
1 change: 1 addition & 0 deletions src/openmenu/src/ui/draw_prototypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void draw_draw_quad(int x, int y, float width, float height, uint32_t color);

/* exec proto */
struct gd_item;
void bloom_launch(const struct gd_item* disc);
void bleem_launch(const struct gd_item* disc);
void dreamcast_launch_disc(const struct gd_item* disc);
void dreamcast_launch_cb(const struct gd_item* disc);
Expand Down
7 changes: 3 additions & 4 deletions src/openmenu/src/ui/theme_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
* http://www.opensource.org/licenses/BSD-3-Clause
*/

#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>

#include <ini.h>
#include <gdrom/gdrom_fs.h>
#include "ui/draw_prototypes.h"

#include "ui/theme_manager.h"
Expand Down Expand Up @@ -238,15 +238,14 @@ theme_read(const char* filename, void* theme, int type) {
static void
load_themes(char* basePath) {
char path[128];
DIRENT_TYPE dp;
DIR_TYPE dir = opendir(basePath);
struct dirent* dp;
DIR* dir = opendir(basePath);

if (!dir) {
return;
}

while ((dp = readdir(dir)) != NULL) {
// printf("load_themes: %s\n", dp->d_name);
if (strcmp(dp->d_name, ".") != 0 && strcmp(dp->d_name, "..") != 0) {
if (strncasecmp(dp->d_name, "CUST_", 5) == 0) {
int theme_num = dp->d_name[5] - '0';
Expand Down
10 changes: 6 additions & 4 deletions src/openmenu/src/ui/ui_grid.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ draw_grid_boxes(void) {

/* Draw multiple discs and how many */
draw_draw_quad(x_pos, y_pos, TILE_SIZE_X * X_SCALE * 0.5f, 28, current_theme_colors->menu_bkg_color);
char disc_str[8];
snprintf(disc_str, 8, "%d Discs", disc_set);
char disc_str[12];
snprintf(disc_str, 11, "%d Discs", disc_set);
font_bmf_begin_draw();
font_bmf_set_height(24);
font_bmf_draw_sub(x_pos + 8, y_pos + 2, current_theme_colors->text_color, disc_str);
Expand Down Expand Up @@ -463,8 +463,10 @@ menu_cb(void) {
return;
}

if (!strncmp(list_current[current_selected()]->disc, "PS1", 3)
|| !strncmp(list_current[current_selected()]->disc, "DIR", 3)) {
if (!strncmp(list_current[current_selected()]->disc, "DIR", 3)) {
return;
} else if (!strncmp(list_current[current_selected()]->disc, "PS1", 3)) {
bloom_launch(list_current[current_selected()]);
return;
}

Expand Down
14 changes: 8 additions & 6 deletions src/openmenu/src/ui/ui_line_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ draw_game_meta(void) {
{
if (disc_set > 1) {
if (!hide_multidisc) {
char disc_str[8];
snprintf(disc_str, 8, "Disc %d", disc_num);
char disc_str[12];
snprintf(disc_str, 11, "Disc %d", disc_num);
font_bmf_draw_sub(316 + 22 + 4, 36, current_theme_colors->text_color, disc_str);
} else {
/* Draw multiple discs and how many */
char disc_str[8];
snprintf(disc_str, 8, "%d Discs", disc_set);
char disc_str[12];
snprintf(disc_str, 11, "%d Discs", disc_set);
font_bmf_draw_sub(316 + 22 + 4, 36, current_theme_colors->text_color, disc_str);
}
}
Expand Down Expand Up @@ -411,8 +411,10 @@ menu_cb(void) {
return;
}

if (!strncmp(list_current[current_selected_item]->disc, "PS1", 3)
|| !strncmp(list_current[current_selected_item]->disc, "DIR", 3)) {
if (!strncmp(list_current[current_selected_item]->disc, "DIR", 3)) {
return;
} else if (!strncmp(list_current[current_selected_item]->disc, "PS1", 3)) {
bloom_launch(list_current[current_selected_item]);
return;
}

Expand Down
Loading