Skip to content

Commit

Permalink
- Fix empty memory card crash, fix blocks label
Browse files Browse the repository at this point in the history
  • Loading branch information
emukidid committed Aug 8, 2019
1 parent 0948c79 commit b2d694c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cube/swiss/source/devices/memcard/deviceHandler-CARD.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ device_info* deviceHandler_CARD_info() {

s32 deviceHandler_CARD_readDir(file_handle* ffile, file_handle** dir, u32 type){

int num_entries = 1, ret = 0, i = 0, slot = (!strncmp((const char*)initial_CARDB.name, ffile->name, 7));
int num_entries = 1, ret = 0, i = 1, slot = (!strncmp((const char*)initial_CARDB.name, ffile->name, 7));
card_dir *memcard_dir = NULL;

if(!card_init[slot]) { //if some error
Expand All @@ -116,7 +116,9 @@ s32 deviceHandler_CARD_readDir(file_handle* ffile, file_handle** dir, u32 type){
memset(memcard_dir, 0, sizeof(card_dir));

/* Convert the Memory Card "file" data to fileBrowser_files */
*dir = malloc( num_entries * sizeof(file_handle) );
*dir = calloc(sizeof(file_handle), 1);
(*dir)[0].fileAttrib = IS_SPECIAL;
strcpy((*dir)[0].name, "..");

int usedSpace = 0;
ret = CARD_FindFirst (slot, memcard_dir, true);
Expand Down
10 changes: 8 additions & 2 deletions cube/swiss/source/gui/FrameBufferMagic.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,10 +992,10 @@ static void _DrawFileBrowserButton(uiDrawObj_t *evt) {
sprintf(fbTextBuffer,"Partition: %i, ISO: %i", isoInfo->iso_partition,isoInfo->iso_number);
}
else if(devices[DEVICE_CUR] == &__device_card_a || devices[DEVICE_CUR] == &__device_card_b) {
sprintf(fbTextBuffer,"%.2fKB (%ul blocks)", (float)file->size/1024, file->size/8192);
sprintf(fbTextBuffer,"%.2fKB (%d blocks)", (float)file->size/1024, file->size/8192);
}
else if(devices[DEVICE_CUR] == &__device_qoob) {
sprintf(fbTextBuffer,"%.2fKB (%ul blocks)", (float)file->size/1024, file->size/0x10000);
sprintf(fbTextBuffer,"%.2fKB (%d blocks)", (float)file->size/1024, file->size/0x10000);
}
else {
sprintf(fbTextBuffer,"%.2f %s",file->size > (1024*1024) ? (float)file->size/(1024*1024):(float)file->size/1024,file->size > (1024*1024) ? "MB":"KB");
Expand Down Expand Up @@ -1376,6 +1376,12 @@ void DrawCheatsSelector(char *fileName) {
DrawDispose(container);
}


void DrawGetTextEntry(int mode, void *src, int size) {
// TODO
}


static void videoDrawEvent(uiDrawObj_t *videoEvent) {
//print_gecko("Draw event: %08X (type %s)\r\n", (u32)videoEvent, typeStrings[videoEvent->type]);
drawInit();
Expand Down
11 changes: 11 additions & 0 deletions cube/swiss/source/gui/FrameBufferMagic.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ enum TextureId
TEX_UNCHECKED
};

typedef struct kbBtn_ {
int supportedEntryMode;
char *val;
} kbBtn;

#define ENTRYMODE_ALPHA (1)
#define ENTRYMODE_NUMERIC (1<<1)
#define ENTRYMODE_IP (1<<2)
#define ENTRYMODE_MASKED (1<<3)

uiDrawObj_t* DrawImage(int textureId, int x, int y, int width, int height, int depth, float s1, float s2, float t1, float t2, int centered);
uiDrawObj_t* DrawTexObj(GXTexObj *texObj, int x, int y, int width, int height, int depth, float s1, float s2, float t1, float t2, int centered);
uiDrawObj_t* DrawProgressBar(bool indeterminate, int percent, char *message);
Expand All @@ -150,6 +160,7 @@ uiDrawObj_t* DrawFileBrowserButton(int x1, int y1, int x2, int y2, char *message
uiDrawObj_t* DrawVertScrollBar(int x, int y, int width, int height, float scrollPercent, int scrollHeight);
void DrawArgsSelector(char *fileName);
void DrawCheatsSelector(char *fileName);
void DrawGetTextEntry(int entryMode, void *src, int size);
void DrawInit();
void DrawShutdown();

Expand Down

0 comments on commit b2d694c

Please sign in to comment.