mirror of
https://github.com/suloku/gcmm.git
synced 2026-09-07 19:05:38 -05:00
Icon centered when there's no banner
Function to get free blocks in card library Save permissions display is more user friendly Better screen cleanup Some helper macros in gci.h
This commit is contained in:
@@ -14,8 +14,10 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "bitmap.h"
|
||||
|
||||
#include "bitmap.h"
|
||||
#include "gci.h"
|
||||
|
||||
extern GCI gci;
|
||||
//*extern GXRModeObj *vmode; /*** Graphics Mode Object ***/
|
||||
//extern u32 *xfb[2] = { NULL, NULL }; /*** Framebuffers ***/
|
||||
//extern int whichfb = 0; /*** Frame buffer toggle ***/
|
||||
@@ -163,7 +165,7 @@ u32 ShowBMP(u8 * bmpfile) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/***
|
||||
/***
|
||||
ShowBanner is ShowBMP but modified to be simpler. We don't need to
|
||||
check for a header since we generated the bmp BGR values directly for each save game.
|
||||
***/
|
||||
@@ -189,10 +191,10 @@ void ShowBanner(u8 *banner) {
|
||||
fboffset -= (height * 90);
|
||||
fboffset += width/2+3; //at this point the banner is perfectly aligned with right window
|
||||
fboffset += ((height *320)>>1)+3;
|
||||
|
||||
|
||||
//fboffset += 24; //force banner to display to the right of icon
|
||||
fboffset += 44; //force banner to display to the right of icon
|
||||
|
||||
fboffset += 43; //force banner to display to the right of icon
|
||||
|
||||
for (rows = 0; rows < height; rows++) {
|
||||
for (cols = 0; cols < (fbwidth >> 1); cols++) {
|
||||
xfb[whichfb][fboffset + cols] =CvtRGB (bgr[2], bgr[1], bgr[0],
|
||||
@@ -232,9 +234,16 @@ void ShowIcon(u8 *icon) {
|
||||
fboffset -= (height * 90);
|
||||
fboffset += width/2+3;
|
||||
fboffset += ((height *320)>>1)+3;
|
||||
|
||||
fboffset += 20; //center icon
|
||||
|
||||
|
||||
if (SDCARD_GetBannerFmt(gci.banner_fmt) == 1 || SDCARD_GetBannerFmt(gci.banner_fmt) == 2 )
|
||||
{
|
||||
fboffset += 20;
|
||||
}else
|
||||
{
|
||||
fboffset += 47; //center icon
|
||||
}
|
||||
|
||||
|
||||
for (rows = 0; rows < height; rows++) {
|
||||
for (cols = 0; cols < (fbwidth >> 1); cols++) {
|
||||
xfb[whichfb][fboffset + cols] =CvtRGB (bgr[2], bgr[1], bgr[0],
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
extern GXRModeObj *vmode; /*** Graphics Mode Object ***/
|
||||
extern u32 *xfb[2]; /*** Framebuffers ***/
|
||||
extern int whichfb; /*** Frame buffer toggle ***/
|
||||
extern u8 bitmapfile[];
|
||||
extern u8 bitmapfile[];
|
||||
u32 CvtRGB(u8 r1, u8 g1, u8 b1, u8 r2, u8 g2, u8 b2);
|
||||
u32 ShowBMP (u8 *bmpfile);
|
||||
void ShowBanner ();
|
||||
void ShowIcon ();
|
||||
|
||||
409
source/card.c
409
source/card.c
File diff suppressed because it is too large
Load Diff
@@ -31,11 +31,11 @@ distribution.
|
||||
#ifndef __CARD_H__
|
||||
#define __CARD_H__
|
||||
|
||||
/*!
|
||||
\file card.h
|
||||
/*!
|
||||
\file card.h
|
||||
\brief Memory card subsystem
|
||||
|
||||
*/
|
||||
*/
|
||||
|
||||
|
||||
#include <gctypes.h>
|
||||
@@ -52,7 +52,7 @@ distribution.
|
||||
|
||||
#define CARD_WORKAREA (5*8*1024) /*!< minimum size of the workarea passed to Mount[Async]() */
|
||||
#define CARD_READSIZE 512 /*!< minimum size of block to read from memory card */
|
||||
#define CARD_FILENAMELEN 32 /*!< maximum filename length */
|
||||
#define CARD_FILENAMELEN 32 /*!< maximum filename length */
|
||||
#define CARD_MAXFILES 128 /*!< maximum number of files on the memory card */
|
||||
|
||||
/*! \addtogroup card_errors Memory card error codes
|
||||
@@ -145,16 +145,16 @@ typedef struct _card_file {
|
||||
\param company[2] string identifier <=2.
|
||||
\param showall boolean flag whether to showall entries or ony those identified by card_gamecode and card_company, previously set within the call to CARD_Init()
|
||||
*/
|
||||
typedef struct _card_dir {
|
||||
s32 chn;
|
||||
u32 fileno;
|
||||
typedef struct _card_dir {
|
||||
s32 chn;
|
||||
u32 fileno;
|
||||
u32 filelen;
|
||||
u8 permissions;
|
||||
u8 filename[CARD_FILENAMELEN];
|
||||
u8 gamecode[4];
|
||||
u8 filename[CARD_FILENAMELEN];
|
||||
u8 gamecode[4];
|
||||
u8 company[2];
|
||||
bool showall;
|
||||
} card_dir;
|
||||
} card_dir;
|
||||
|
||||
|
||||
/*! \typedef struct card_stat
|
||||
@@ -163,7 +163,7 @@ typedef struct _card_dir {
|
||||
\param len length of file.
|
||||
\param gamecode[4] string identifier <=4.
|
||||
\param company[2] string identifier <=2.
|
||||
\param banner_fmt format of banner.
|
||||
\param banner_fmt format of banner.
|
||||
\param icon_addr icon image address in file.
|
||||
\param icon_speed speed of an animated icon.
|
||||
\param comment_addr address in file of the comment block.
|
||||
@@ -461,7 +461,7 @@ s32 CARD_GetErrorCode(s32 chn);
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_FindFirst(s32 chn, card_dir *dir, bool showall);
|
||||
|
||||
|
||||
|
||||
/*! \fn s32 CARD_FindNext(card_dir *dir)
|
||||
\brief Returns the next directory entry from the memory cards directory structure.
|
||||
@@ -469,7 +469,7 @@ s32 CARD_FindFirst(s32 chn, card_dir *dir, bool showall);
|
||||
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_FindNext(card_dir *dir);
|
||||
s32 CARD_FindNext(card_dir *dir);
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetDirectory(s32 chn, card_dir *dir_entries, s32 *count, bool showall)
|
||||
@@ -482,7 +482,7 @@ s32 CARD_FindNext(card_dir *dir);
|
||||
\return \ref card_errors "card error codes"
|
||||
*/
|
||||
s32 CARD_GetDirectory(s32 chn, card_dir *dir_entries, s32 *count, bool showall);
|
||||
|
||||
|
||||
|
||||
/*! \fn s32 CARD_GetSectorSize(s32 chn,u32 *sector_size)
|
||||
\brief Returns the next directory entry from the memory cards directory structure.
|
||||
@@ -598,6 +598,14 @@ s32 CARD_SetCompany(const char *company);
|
||||
*/
|
||||
s32 CARD_SetGamecode(const char *gamecode);
|
||||
|
||||
/*! \fn s32 CARD_GetFreeBlocks(s32 chn)
|
||||
\brief Get the free blocks in memory card
|
||||
\param[in] chn CARD slot.
|
||||
\param[in] freeblocks pointer to receive freeblocks value.
|
||||
|
||||
\return \ref card_errors "card error codes" or free blocks
|
||||
*/
|
||||
s32 CARD_GetFreeBlocks(s32 chn, u16* freeblocks);
|
||||
|
||||
/*! \fn s32 __card_getstatusex(s32 chn,s32 fileno,struct card_direntry *entry)
|
||||
\brief Get the directory entry (GCI header)
|
||||
|
||||
@@ -773,7 +773,11 @@ void showSaveInfo(int sel)
|
||||
|
||||
//clear right pane, but just the save info
|
||||
int bgcolor = getcolour(84,174,211);
|
||||
DrawBoxFilled(375, 145, 605, 390, bgcolor);
|
||||
DrawBoxFilled(375, 145, 605, 390, bgcolor);
|
||||
//clear the right side just in case we went offscreen with previous comment
|
||||
DrawVLine (606, 145, 390, CvtRGB(84,174,211,183,209,240));
|
||||
DrawVLine (608, 145, 390, CvtRGB(230,232,250,242,243,252));
|
||||
DrawBoxFilled(610, 145, 640, 390, getcolour(255,255,255));
|
||||
|
||||
// read file, display some more info
|
||||
// TODO: only read the necessary header + comment, display banner and icon files
|
||||
@@ -796,18 +800,31 @@ void showSaveInfo(int sel)
|
||||
// struct gci now contains header info
|
||||
|
||||
}
|
||||
|
||||
//Draw nice gradient background for banner and icon
|
||||
DrawBox (410, 163, 410+160, 163+39, getcolour (255,255,255));
|
||||
DrawBoxFilledGradient(412, 164, (410+159), (164+37), BLUECOL, PURPLECOL);
|
||||
|
||||
//Show icon and banner
|
||||
if ((gci.banner_fmt&CARD_BANNER_MASK) == CARD_BANNER_RGB) {
|
||||
bannerloadRGB(bannerdata);
|
||||
}
|
||||
else if ((gci.banner_fmt&CARD_BANNER_MASK) == CARD_BANNER_CI) {
|
||||
bannerloadCI(bannerdataCI, tlutbanner);
|
||||
}
|
||||
|
||||
//Draw nice gradient background for banner and icon
|
||||
if(SDCARD_GetBannerFmt(gci.banner_fmt) == 1 || SDCARD_GetBannerFmt(gci.banner_fmt) == 2){
|
||||
//Box for icon+banner
|
||||
DrawHLine (410, 410+160, 162, getcolour (255,255,255));
|
||||
DrawBox (410, 163, 410+160, 163+39, getcolour (255,255,255));
|
||||
DrawHLine (410, 410+160, 164+39, getcolour (255,255,255));
|
||||
DrawBoxFilledGradient(412, 164, (410+158), (164+37), BLUECOL, PURPLECOL);
|
||||
}else
|
||||
{
|
||||
//Box for icon
|
||||
DrawHLine (468, 468+42, 162, getcolour (255,255,255));
|
||||
DrawBox (468, 163, 468+42, 163+39, getcolour (255,255,255));
|
||||
DrawHLine (468, 468+42, 164+39, getcolour (255,255,255));
|
||||
DrawBoxFilledGradient(468+2, 164, (468+40), (164+37), BLUECOL, PURPLECOL);
|
||||
}
|
||||
|
||||
//Show banner if there is one
|
||||
if (SDCARD_GetBannerFmt(gci.banner_fmt) == CARD_BANNER_RGB) {
|
||||
bannerloadRGB(bannerdata);
|
||||
}
|
||||
else if (SDCARD_GetBannerFmt(gci.banner_fmt) == CARD_BANNER_CI) {
|
||||
bannerloadCI(bannerdataCI, tlutbanner);
|
||||
}
|
||||
|
||||
//Show first icon
|
||||
if ((gci.icon_fmt&CARD_ICON_MASK)== 1) {
|
||||
//CI with shared palette
|
||||
@@ -822,14 +839,14 @@ void showSaveInfo(int sel)
|
||||
|
||||
/*** Display relevant info for this save ***/
|
||||
sprintf(txt, "#%d %s/%s", sel, gamecode, company);
|
||||
DrawText(x, y, txt);
|
||||
y += 60;
|
||||
DrawText(x, y-4, txt);
|
||||
y += 65;
|
||||
|
||||
//DrawText(x, y, "File Description:");
|
||||
//y += 20;
|
||||
|
||||
char comment1[26];
|
||||
char comment2[6];
|
||||
char comment1[32];
|
||||
char comment2[32];
|
||||
|
||||
//We go ahead and print the full 32byte comment lines - could go offscreen
|
||||
//but we like to live dangerously
|
||||
@@ -850,7 +867,7 @@ void showSaveInfo(int sel)
|
||||
DrawText(x, y, comment2);
|
||||
y += 20;
|
||||
memset(comment2, 0, sizeof(comment2));
|
||||
y += 20;
|
||||
y += 10;
|
||||
|
||||
// Compute date/time
|
||||
u32 t = gci.time; // seconds since jan 1, 2000
|
||||
@@ -861,7 +878,15 @@ void showSaveInfo(int sel)
|
||||
y += 20;
|
||||
*/
|
||||
|
||||
t += 946684800; //let's add seconds since Epoch (jan 1, 1970 to jan 1,2000)
|
||||
t += 946684800; //let's add seconds since Epoch (jan 1, 1970 to jan 1,2000)
|
||||
|
||||
//Dolphin memory card manager and some homebrew store time with seconds since Epoch, which results in time being +30 years
|
||||
/*
|
||||
if (time(NULL) < 1893456000 && t > 1893456000)
|
||||
t -= 946684800;
|
||||
*/
|
||||
//Above's solution will stop working after the year 2030... so better not to depend on current time, as it might be wrong
|
||||
|
||||
int month, day, year, hour, min, sec;
|
||||
month = day = year = hour = min = sec = 0;
|
||||
char monthstr[12][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
|
||||
@@ -905,15 +930,19 @@ void showSaveInfo(int sel)
|
||||
DrawText(x, y, txt);
|
||||
y += 20;
|
||||
//M-> Cant' move the file //C->can't copy the file //P->public file //Most frecuent: xxP
|
||||
sprintf(txt, "Perm: %s%s%s",
|
||||
(gci.unknown1 & 16) ? "M " : "x ",
|
||||
(gci.unknown1 & 8) ? "C " : "x ",
|
||||
(gci.unknown1 & 4) ? "P" : "x");
|
||||
/* sprintf(txt, "Perm: %s%s%s",
|
||||
(gci.unknown1 & 16) ? "M " : "x ",
|
||||
(gci.unknown1 & 8) ? "C " : "x ",
|
||||
(gci.unknown1 & 4) ? "P" : "x");
|
||||
*/
|
||||
sprintf(txt, "Perm: %s%s%s",
|
||||
(gci.unknown1 & 16) ? "" : "Move | ",
|
||||
(gci.unknown1 & 8) ? "" : "Copy | ",
|
||||
(gci.unknown1 & 4) ? "Public" : "Private");
|
||||
DrawText(x, y, txt);
|
||||
y += 20;
|
||||
sprintf(txt, "Copy Count: %02d", gci.unknown2);
|
||||
DrawText(x, y, txt);
|
||||
//y += 20;
|
||||
|
||||
#ifdef DEBUG_VALUES
|
||||
/*** Uncomment to print some debug info ***/
|
||||
@@ -1282,7 +1311,7 @@ int ShowSelector (int saveinfo)
|
||||
void writeStatusBar( char *line1, char *line2)
|
||||
{
|
||||
int bgcolor = getcolour(0xff,0xff,0xff);
|
||||
DrawBoxFilled(10, 404, 610, 455, bgcolor);
|
||||
DrawBoxFilled(10, 404, 640, 455, bgcolor);
|
||||
//setfontcolour(84,174,211);
|
||||
setfontcolour(28,28,28);
|
||||
DrawText(40, 425, line1);
|
||||
|
||||
@@ -14,6 +14,11 @@
|
||||
// Also, libogc creates card entries with time since 1970 and gamecube uses time since 2000... thus libogc adds 30 years!
|
||||
|
||||
//#define STATUSOGC
|
||||
|
||||
#define SDCARD_GetBannerFmt(banner_fmt) ((banner_fmt) & 0x03)
|
||||
#define SDCARD_GetIconFmt(icon_fmt,n) (((icon_fmt)>>(2*(n))) & 0x03)
|
||||
#define SDCARD_GetIconSpeed(icon_speed,n) (((icon_speed)>>(2*(n))) & 0x03)
|
||||
#define SDCARD_GetIconAnim(banner_fmt) ((banner_fmt) & 0x04)
|
||||
|
||||
typedef struct {
|
||||
u8 gamecode[4];
|
||||
|
||||
Reference in New Issue
Block a user