mirror of
https://github.com/suloku/gcmm.git
synced 2026-04-24 23:08:10 -05:00
Added GC/Wii_prepare.bat files for calling before Make. This gets the correct makefile and background picture before compiling.
Clear the CommentBuffer and FileBuffer prior to loading a sd file. Clear CommentBuffer in ReadFileHeader (mcard.c) Modified video initialization to support widescreen and progressive cable. Display will always have 480 lines height (program compatible with all tv modes)
This commit is contained in:
parent
e65f977bd6
commit
5c7b0ecbe0
4
GC_prepare.bat
Normal file
4
GC_prepare.bat
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
echo cp Makefile.gc Makefile
|
||||
cp Makefile.gc Makefile
|
||||
echo cp ./source/gcmm-bk.gc ./source/gcmm-bk.s
|
||||
cp ./source/gcmm-bk.gc ./source/gcmm-bk.s
|
||||
4
Wii_prepare.bat
Normal file
4
Wii_prepare.bat
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
echo cp Makefile.wii Makefile
|
||||
cp Makefile.wii Makefile
|
||||
echo cp ./source/gcmm-bk.wii ./source/gcmm-bk.s
|
||||
cp ./source/gcmm-bk.wii ./source/gcmm-bk.s
|
||||
|
|
@ -16,12 +16,14 @@
|
|||
#include "mcard.h"
|
||||
#include "sdsupp.h"
|
||||
#include "bitmap.h"
|
||||
#define MCDATAOFFSET 64
|
||||
|
||||
#ifdef HW_RVL
|
||||
#include <wiiuse/wpad.h>
|
||||
#endif
|
||||
|
||||
#define MCDATAOFFSET 64
|
||||
#define FONT_SIZE 16 //pixels
|
||||
|
||||
/*** Globals ***/
|
||||
FT_Library ftlibrary;
|
||||
FT_Face face;
|
||||
|
|
@ -99,7 +101,7 @@ int FT_Init (){
|
|||
if (err)
|
||||
return 1;
|
||||
|
||||
setfontsize (16);
|
||||
setfontsize (FONT_SIZE);
|
||||
setfontcolour (0xff, 0xff, 0xff);
|
||||
|
||||
slot = face->glyph;
|
||||
|
|
@ -406,8 +408,8 @@ void WaitPrompt (char *msg){
|
|||
ShowScreen ();
|
||||
WaitButtonA ();
|
||||
//clear the text
|
||||
int bgcolor = getcolour(0xff,0xff,0xff);
|
||||
DrawBoxFilled(10, 430, 510, 485, bgcolor);
|
||||
writeStatusBar(" "," ");
|
||||
|
||||
}
|
||||
|
||||
void DrawLineFast (int startx, int endx, int y, u8 r, u8 g, u8 b){
|
||||
|
|
@ -425,12 +427,12 @@ void DrawLineFast (int startx, int endx, int y, u8 r, u8 g, u8 b){
|
|||
}
|
||||
|
||||
void showSaveInfo(int sel) {
|
||||
int y = 190, x = 380, j;
|
||||
int y = 160, x = 380, j;
|
||||
char gamecode[5], company[3], txt[1024];
|
||||
|
||||
//clear right pane, but we don't want to erase previous text
|
||||
//clear right pane, but just the save info
|
||||
int bgcolor = getcolour(84,174,211);
|
||||
DrawBoxFilled(375, 175, 605, 410, bgcolor);
|
||||
DrawBoxFilled(375, 145, 605, 380, bgcolor);
|
||||
|
||||
// read file, display some more info
|
||||
// TODO: only read the necessary header + comment, display banner and icon files
|
||||
|
|
@ -508,26 +510,33 @@ void showSaveInfo(int sel) {
|
|||
y += 20;
|
||||
|
||||
//Bad way to display the file comment, should reposition to just show the full 32 char lines instead of spliting.
|
||||
char comment1[32];
|
||||
//For testing how many chars fit the screen (they might not be all upper case in savegames so...)
|
||||
/*DrawText(x, y, "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEF");
|
||||
y += 20;
|
||||
*/
|
||||
strncpy(comment1, CommentBuffer, 25);
|
||||
//This relies in FONT_SIZE being 16 pixels
|
||||
char comment1[26];
|
||||
char comment2[6];
|
||||
|
||||
strncpy(comment1, CommentBuffer, 26);
|
||||
DrawText(x, y, comment1);
|
||||
y += 20;
|
||||
memset(comment1, 0, sizeof(comment1));
|
||||
strncpy(comment1, CommentBuffer+25, 7);
|
||||
|
||||
strncpy(comment2, CommentBuffer+26, 6);
|
||||
DrawText(x, y, comment2);
|
||||
y += 20;
|
||||
memset(comment2, 0, sizeof(comment2));
|
||||
|
||||
strncpy(comment1, CommentBuffer+32, 26);
|
||||
DrawText(x, y, comment1);
|
||||
y += 20;
|
||||
memset(comment1, 0, sizeof(comment1));
|
||||
strncpy(comment1, CommentBuffer+32, 25);
|
||||
DrawText(x, y, comment1);
|
||||
|
||||
strncpy(comment2, CommentBuffer+58, 6);
|
||||
DrawText(x, y, comment2);
|
||||
y += 20;
|
||||
memset(comment1, 0, sizeof(comment1));
|
||||
strncpy(comment1, CommentBuffer+57, 7);
|
||||
DrawText(x, y, comment1);
|
||||
y += 20;
|
||||
memset(comment1, 0, sizeof(comment1));
|
||||
memset(comment2, 0, sizeof(comment2));
|
||||
|
||||
/* // Comment at MCDATAOFFSET+(comment addr)
|
||||
//char *comment = (char*) (FileBuffer+MCDATAOFFSET+gci.comment_addr);
|
||||
|
|
@ -729,15 +738,11 @@ int ShowSelector (){
|
|||
|
||||
void writeStatusBar(char *line1, char *line2) {
|
||||
int bgcolor = getcolour(0xff,0xff,0xff);
|
||||
#ifdef HW_RVL
|
||||
DrawBoxFilled(10, 430, 510, 485, bgcolor);
|
||||
#else
|
||||
DrawBoxFilled(10, 404, 510, 455, bgcolor);
|
||||
#endif
|
||||
//setfontcolour(84,174,211);
|
||||
setfontcolour(28,28,28);
|
||||
DrawText(40, 450, line1);
|
||||
DrawText(40, 475, line2);
|
||||
DrawBoxFilled(10, 404, 510, 455, bgcolor);
|
||||
//setfontcolour(84,174,211);
|
||||
setfontcolour(28,28,28);
|
||||
DrawText(40, 425, line1);
|
||||
DrawText(40, 450, line2);
|
||||
}
|
||||
|
||||
void clearLeftPane() {
|
||||
|
|
@ -747,11 +752,7 @@ void clearLeftPane() {
|
|||
|
||||
void clearRightPane() {
|
||||
int bgcolor = getcolour(84,174,211);
|
||||
#ifdef HW_RVL
|
||||
DrawBoxFilled(375, 140, 605, 410, bgcolor);
|
||||
#else
|
||||
DrawBoxFilled(375, 110, 605, 380, bgcolor);
|
||||
#endif
|
||||
DrawBoxFilled(376, 112, 605, 380, bgcolor);
|
||||
}
|
||||
|
||||
void DrawHLine (int x1, int x2, int y, int color)
|
||||
|
|
|
|||
6
source/gcmm-bk.gc
Normal file
6
source/gcmm-bk.gc
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
.rodata
|
||||
.globl bitmapfile
|
||||
.balign 32
|
||||
bitmapfile:
|
||||
.incbin "../source/gcbk.bmp"
|
||||
|
||||
100
source/main.c
100
source/main.c
|
|
@ -35,6 +35,7 @@ GXRModeObj *vmode; /*** Graphics Mode Object ***/
|
|||
u32 *xfb[2] = { NULL, NULL }; /*** Framebuffers ***/
|
||||
int whichfb = 0; /*** Frame buffer toggle ***/
|
||||
int screenheight;
|
||||
static int vmode_60hz = 0;
|
||||
|
||||
extern u8 filelist[1024][1024];
|
||||
|
||||
|
|
@ -97,51 +98,75 @@ Initialise (void)
|
|||
WPAD_Init ();
|
||||
#endif
|
||||
|
||||
/*** Try to match the current video display mode
|
||||
using the higher resolution interlaced.
|
||||
// get default video mode
|
||||
vmode = VIDEO_GetPreferredMode(NULL);
|
||||
|
||||
So NTSC/MPAL gives a display area of 640x480
|
||||
PAL display area is 640x528
|
||||
***/
|
||||
switch (VIDEO_GetCurrentTvMode ())
|
||||
{
|
||||
case VI_NTSC:
|
||||
vmode = &TVNtsc480IntDf;
|
||||
break;
|
||||
switch (vmode->viTVMode >> 2)
|
||||
{
|
||||
case VI_PAL:
|
||||
// 576 lines (PAL 50Hz)
|
||||
// display should be centered vertically (borders)
|
||||
//Make all video modes the same size so menus doesn't screw up
|
||||
vmode = &TVPal574IntDfScale;
|
||||
vmode->xfbHeight = 480;
|
||||
vmode->viYOrigin = (VI_MAX_HEIGHT_PAL - 480)/2;
|
||||
vmode->viHeight = 480;
|
||||
|
||||
case VI_PAL:
|
||||
vmode = &TVPal528IntDf;
|
||||
break;
|
||||
vmode_60hz = 0;
|
||||
break;
|
||||
|
||||
case VI_MPAL:
|
||||
vmode = &TVMpal480IntDf;
|
||||
break;
|
||||
case VI_NTSC:
|
||||
// 480 lines (NTSC 60hz)
|
||||
vmode_60hz = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
vmode = &TVNtsc480IntDf;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// 480 lines (PAL 60Hz)
|
||||
vmode_60hz = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/*** Let libogc configure the mode ***/
|
||||
VIDEO_Configure (vmode);
|
||||
#ifdef HW_DOL
|
||||
/* we have component cables, but the preferred mode is interlaced
|
||||
* why don't we switch into progressive?
|
||||
* on the Wii, the user can do this themselves on their Wii Settings */
|
||||
if(VIDEO_HaveComponentCable())
|
||||
vmode = &TVNtsc480Prog;
|
||||
#endif
|
||||
|
||||
/* // check for progressive scan // bool progressive = FALSE;
|
||||
if (vmode->viTVMode == VI_TVMODE_NTSC_PROG)
|
||||
progressive = true;
|
||||
*/
|
||||
|
||||
#ifdef HW_RVL
|
||||
// widescreen fix
|
||||
if(CONF_GetAspectRatio())
|
||||
{
|
||||
vmode->viWidth = 678;
|
||||
vmode->viXOrigin = (VI_MAX_WIDTH_PAL - 678) / 2;
|
||||
}
|
||||
#endif
|
||||
|
||||
// configure VI
|
||||
VIDEO_Configure (vmode);
|
||||
|
||||
// always 480 lines /*** Update screen height for font engine ***/
|
||||
screenheight = vmode->xfbHeight;
|
||||
|
||||
/*** Now configure the framebuffer.
|
||||
Really a framebuffer is just a chunk of memory
|
||||
to hold the display line by line.
|
||||
***/
|
||||
|
||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
// Allocate the video buffers
|
||||
xfb[0] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
/*** I prefer also to have a second buffer for double-buffering.
|
||||
This is not needed for the console demo.
|
||||
***/
|
||||
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
xfb[1] = (u32 *) MEM_K0_TO_K1 (SYS_AllocateFramebuffer (vmode));
|
||||
|
||||
/*** Define a console ***/
|
||||
console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight,
|
||||
vmode->fbWidth * 2);
|
||||
|
||||
/*** Update screen height for font engine ***/
|
||||
screenheight = vmode->xfbHeight;
|
||||
console_init (xfb[0], 20, 64, vmode->fbWidth, vmode->xfbHeight, vmode->fbWidth * 2);
|
||||
|
||||
/*** Clear framebuffer to black ***/
|
||||
VIDEO_ClearFrameBuffer (vmode, xfb[0], COLOR_BLACK);
|
||||
|
|
@ -176,8 +201,7 @@ void SD_BackupMode (){
|
|||
int bytestodo;
|
||||
|
||||
clearRightPane();
|
||||
//DrawText(390,130,"B a c k u p M o d e");
|
||||
DrawText(388,160,"B a c k u p M o d e");
|
||||
DrawText(390,130,"B a c k u p M o d e");
|
||||
writeStatusBar("Pick a file using UP or DOWN ", "Press A to backup to SD Card ") ;
|
||||
/*** Get the directory listing from the memory card ***/
|
||||
memitems = CardGetDirectory (CARD_SLOTB);
|
||||
|
|
@ -222,8 +246,7 @@ void SD_RestoreMode (){
|
|||
int selected;
|
||||
|
||||
clearRightPane();
|
||||
//DrawText(390,130,"R e s t o r e M o d e");
|
||||
DrawText(388,160,"R e s t o r e M o d e");
|
||||
DrawText(390,130,"R e s t o r e M o d e");
|
||||
writeStatusBar("Pick a file using UP or DOWN", "Press A to restore to Memory Card ") ;
|
||||
files = SDGetFileList ();
|
||||
if (!files) {WaitPrompt ("No saved games in SD Card to restore !");}
|
||||
|
|
@ -232,7 +255,7 @@ else
|
|||
{
|
||||
selected = ShowSelector ();
|
||||
|
||||
if (cancel) {WaitPrompt ("restore action cancelled !");}
|
||||
if (cancel) {WaitPrompt ("Restore action cancelled !");}
|
||||
else
|
||||
{
|
||||
ShowAction ("Reading from SD Card");
|
||||
|
|
@ -314,7 +337,7 @@ int main (){
|
|||
Initialise (); /*** Start video ***/
|
||||
FT_Init (); /*** Start FreeType ***/
|
||||
if(!initFAT())
|
||||
WaitPrompt("Insert SDCARD");
|
||||
WaitPrompt("No SDCard!");
|
||||
|
||||
#ifdef HW_RVL
|
||||
initialise_power();
|
||||
|
|
@ -344,11 +367,12 @@ int main (){
|
|||
break;
|
||||
case 500 :
|
||||
#ifdef HW_RVL
|
||||
//if there's a loader stub load it, if not return to wii menu.
|
||||
if (!!*(u32*)0x80001800) exit(1);
|
||||
else SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
#else
|
||||
if (psoid[0] == PSOSDLOADID)
|
||||
PSOReload ();
|
||||
if (psoid[0] == PSOSDLOADID) PSOReload ();
|
||||
else SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
|
||||
#endif
|
||||
break; //PSO_Reload
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ int CardReadFileHeader (int slot, int id){
|
|||
|
||||
/*** Clear the work buffers ***/
|
||||
memset (FileBuffer, 0, MAXFILEBUFFER);
|
||||
memset (CommentBuffer, 0, 64);
|
||||
memset (SysArea, 0, CARD_WORKAREA);
|
||||
company[2] = 0;
|
||||
gamecode[4] = 0;
|
||||
|
|
@ -507,7 +508,7 @@ void MC_DeleteMode(int slot) {
|
|||
int memitems, err;
|
||||
int selected = 0;
|
||||
clearRightPane();
|
||||
DrawText(388,160,"D e l e t e M o d e");
|
||||
DrawText(390,130,"D e l e t e M o d e");
|
||||
writeStatusBar("Choose a file with UP button or DOWN button ", "Press A button to delete ") ;
|
||||
char msg[1024];
|
||||
|
||||
|
|
@ -521,7 +522,7 @@ else
|
|||
{
|
||||
// TODO: implement showselector
|
||||
selected = ShowSelector ();
|
||||
if (cancel) {WaitPrompt ("delete action cancelled !");}
|
||||
if (cancel) {WaitPrompt ("Delete action cancelled !");}
|
||||
else{
|
||||
// selected = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@ int SDLoadMCImage(char *sdfilename){
|
|||
//int bytesToRead = 0;
|
||||
long bytesToRead = 0;
|
||||
|
||||
/*** Clear the work buffers ***/
|
||||
memset (FileBuffer, 0, MAXFILEBUFFER);
|
||||
memset (CommentBuffer, 0, 64);
|
||||
|
||||
/*** Make fullpath filename ***/
|
||||
//sprintf (filename, "dev0:\\%s\\%s", MCSAVES, sdfilename);
|
||||
sprintf (filename, "fatX:/%s/%s", MCSAVES, sdfilename);
|
||||
|
|
@ -156,6 +160,10 @@ int SDLoadMCImageHeader(char *sdfilename){
|
|||
//int bytesToRead = 0;
|
||||
long bytesToRead = 0;
|
||||
|
||||
/*** Clear the work buffers ***/
|
||||
memset (FileBuffer, 0, MAXFILEBUFFER);
|
||||
memset (CommentBuffer, 0, 64);
|
||||
|
||||
/*** Make fullpath filename ***/
|
||||
sprintf (filename, "fatX:/%s/%s", MCSAVES, sdfilename);
|
||||
#ifdef HW_RVL
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user