Author Topic: Need a little help with coding for menu  (Read 25603 times)

0 Members and 1 Guest are viewing this topic.

Offline ronaldo_76

  • Full Member
  • ***
  • Posts: 196
Re: Need a little help with coding for menu
« Reply #15 on: August 03, 2010, 12:07:16 AM »
whooooo sanni thats great.  :)

can't wait to test it! looks amazing.  :-*

Offline stefan_iro

  • Full Member
  • ***
  • Posts: 218
  • It´s a me, Mario
Re: Need a little help with coding for menu
« Reply #16 on: August 03, 2010, 01:50:03 AM »
This one looks amazing!  :)
Good work!
-----------------------------------
8bit & 16bit
the golden age of videogames

Offline mic_

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 632
Re: Need a little help with coding for menu
« Reply #17 on: August 03, 2010, 02:00:26 AM »
Boxarts are nice. Now make it look something like this:
 
 ~sm-37.gif~  (but with N64-ish color scheme of course: black, red, green, blue, yellow).

The N64 can do 640x480, can't it? Most games avoided it because of poor performance (and probably other reasons, like the limited texture memory). But for a menu like this it doesn't really matter if it doesn't run at 60 fps, or even 30.

Offline sanni

  • Moderator
  • Hero Member
  • *****
  • Posts: 502
Re: Need a little help with coding for menu
« Reply #18 on: August 03, 2010, 02:00:55 AM »
Database is done, contains 107 roms. That should be all roms that either use a savetype other than controller pack or a cic other then 6102. All games that are not in this database are 6102/mempack or some japanese games I don't care about xd .. I take request to add them though  ~sm-54.gif~.gif

Code: [Select]
if ((gTable[bselect].type == 255))
{
// variables
int NUM_CARTS = 107;
int cic, save, i;
char cartid[3];

//data arrays
//char *names[] = {"Worms Armageddon", "Super Smash Bros.", "Banjo-Tooie", "Blast Corps", "Bomberman Hero", "Body Harvest", "Banjo-Kazooie", "Bomberman 64", "Bomberman 64: Second Attack", "Command & Conquer", "Chopper Attack", "NBA Courtside 2 featuring Kobe Bryant", "Penny Racers", "Chameleon Twist", "Cruis'n USA", "Cruis'n World", "Legend of Zelda: Majora's Mask, The", "Donkey Kong 64", "Donkey Kong 64", "Donald Duck: Goin' Quackers", "Loony Toons: Duck Dodgers", "Diddy Kong Racing", "PGA European Tour", "Star Wars Episode 1 Racer", "AeroFighters Assault", "Bass Hunter 64", "Conker's Bad Fur Day", "F-1 World Grand Prix", "Star Fox 64", "F-Zero X", "GT64 Championship Edition", "GoldenEye 007", "Glover", "Bomberman 64", "Indy Racing 2000", "Indiana Jones and the Infernal Machine", "Jet Force Gemini", "Jet Force Gemini", "Earthworm Jim 3D", "Snowboard Kids 2", "Kirby 64: The Crystal Shards", "Fighters Destiny", "Major League Baseball featuring Ken Griffey Jr.", "Killer Instinct Gold", "Ken Griffey Jr's Slugfest", "Mario Kart 64", "Mario Party", "Lode Runner 3D", "Megaman 64", "Mario Tennis", "Mario Golf", "Mission: Impossible", "Mickey's Speedway USA", "Monopoly", "Paper Mario", "Multi-Racing Championship", "Big Mountain 2000", "Mario Party 3", "Mario Party 2", "Excitebike 64", "Dr. Mario 64", "Star Wars Episode 1: Battle for Naboo", "Kobe Bryant in NBA Courtside", "Excitebike 64", "Ogre Battle 64: Person of Lordly Caliber", "Pokémon Stadium 2", "Pokémon Stadium 2", "Perfect Dark", "Pokémon Snap", "Hey you, Pikachu!", "Pokémon Snap", "Pokémon Puzzle League", "Pokémon Stadium", "Pokémon Stadium", "Pilotwings 64", "Top Gear Overdrive", "Resident Evil 2", "New Tetris, The", "Star Wars: Rogue Squadron", "Ridge Racer 64", "Star Soldier: Vanishing Earth", "AeroFighters Assault", "Starshot Space Circus", "Super Mario 64", "Starcraft 64", "Rocket: Robot on Wheels", "Space Station Silicon Valley", "Star Wars: Shadows of the Empire", "Tigger's Honey Hunt", "1080º Snowboarding", "Tom & Jerry in Fists of Furry", "Mischief Makers", "All-Star Tennis '99", "Tetrisphere", "V-Rally Edition '99", "V-Rally Edition '99", "WCW/NWO Revenge", "WWF: No Mercy", "Waialae Country Club: True Golf Classics", "Wave Race 64", "Worms Armageddon", "WWF Wrestlemania 2000", "Cruisn Exotica", "Yoshis Story", "Harvest Moon 64", "Ocarina of Time", "Majoras Mask"};
char *cartIDs[] = {"AD","AL","B7","BC","BD","BH","BK","BM","BV","CC","CH","CK","CR","CT","CU","CW","DL","DO","DP","DQ","DU","DY","EA","EP","ER","FH","FU","FW","FX","FZ","GC","GE","GV","HA","IC","IJ","JD","JF","JM","K2","K4","KA","KG","KI","KJ","KT","LB","LR","M6","M8","MF","MI","ML","MO","MQ","MR","MU","MV","MW","MX","N6","NA","NB","NX","OB","P2","P3","PD","PF","PG","PH","PN","PO","PS","PW","RC","RE","RI","RS","RZ","S6","SA","SC","SM","SQ","SU","SV","SW","T9","TE","TJ","TM","TN","TP","VL","VY","W2","W4","WL","WR","WU","WX","XO","YS","YW","ZL","ZS"};
int saveTypes[] = {5,1,6,5,5,5,5,5,5,4,5,4,5,5,5,6,4,6,6,5,5,5,5,6,5,5,6,5,5,1,5,5,5,5,5,5,4,4,5,5,5,5,1,5,4,5,5,5,4,6,1,5,5,5,4,5,5,6,5,6,5,5,6,6,1,4,4,6,4,5,4,4,4,4,5,5,1,1,5,6,5,5,5,5,4,5,5,5,4,1,5,5,5,5,5,5,1,4,5,5,5,1,5,6,1,1,4};
int cicTypes[] = {2,3,5,2,2,2,3,2,2,2,2,2,2,2,2,6,5,5,5,2,2,3,2,2,2,2,5,2,1,6,2,2,2,2,2,2,5,5,2,2,3,2,3,2,3,2,2,2,2,2,2,2,5,2,3,2,2,2,2,3,2,2,3,3,2,3,3,5,3,2,3,2,3,3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,2,2,2,2,2,2,2,2,2,2,2,2,2,6,2,5,5};
int overflowControl[107];

// get cartid
sprintf(cartid, "%c%c", gTable[bselect].rom[0x1C], gTable[bselect].rom[0x1D]);

// search for cartid
for (i=0; i < NUM_CARTS; i++)
if (strcmp(cartid, cartIDs[i]) == 0)
break;
if (i == NUM_CARTS)
{
// cart not in list
sprintf(temp, "%c%c not in database", gTable[bselect].rom[0x1C], gTable[bselect].rom[0x1D]);
printText(dcon, temp, 14, 20);
cic = 2;
save = 0;
}
else
{
// cart found
cic = cicTypes[i];
save = saveTypes[i];
if(overflowControl[i] != 1)
{
// load boxart sprite into memory
dfs_init(0xB0101000);
sprintf(temp, "/%c%c.sprite", gTable[bselect].rom[0x1C], gTable[bselect].rom[0x1D]);
int fp = dfs_open(temp);
boxart[i] = malloc(dfs_size(fp));
dfs_read(boxart[i], 1, dfs_size(fp), fp);
dfs_close(fp);
overflowControl[i] = 1;
}
//draw boxart
graphics_draw_sprite_trans(dcon, 60, 140, boxart[i]);
}

// update tables
gTable[bselect].options[5]=save;
gTable[bselect].options[6]=cic;
}

I think it works  ::sm-18.gif::
« Last Edit: August 03, 2010, 02:57:15 AM by sanni »

Offline stefan_iro

  • Full Member
  • ***
  • Posts: 218
  • It´s a me, Mario
Re: Need a little help with coding for menu
« Reply #19 on: August 03, 2010, 02:09:50 AM »
Thanks a lot for your efforts!  ~sm-36.gif~
-----------------------------------
8bit & 16bit
the golden age of videogames

Offline sanni

  • Moderator
  • Hero Member
  • *****
  • Posts: 502
Re: Need a little help with coding for menu
« Reply #20 on: August 03, 2010, 03:00:59 AM »
The N64 can do 640x480, can't it?

Thats a very good idea. I tried this and all you have to change in the source is delete 320x240 and write 640x480. But the text gets unreadable small. I gues we would needd a new bitmap font or something like that.
Because right now a 64x50 boxart does not look good on a 42" Plasma TV  ~sm-31.gif~  ::sm-05::

More resolution would be a nice thing.

Offline ronaldo_76

  • Full Member
  • ***
  • Posts: 196
Re: Need a little help with coding for menu
« Reply #21 on: August 03, 2010, 03:03:49 AM »
the n64 menu have a fressstyledash update...  ~sm-43.gif~

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: Need a little help with coding for menu
« Reply #22 on: August 03, 2010, 04:37:42 AM »
I didn't see any limits in the mkdfs app, but it does build the entire file in ram, then write the ram out to the file. I didn't see any limits in the fs, other than filenames have to be less than 243 chars, you can only have subdirectories 100 deep (wild - I think the most I ever saw was maybe 20 deep), and whatever fits into the recursive use of stack space while following the directory path (seriously, I think you'll run out of stack space before you hit 100 subdirectories deep).

And yes, I've thought of going to 640x480 on the N64... it would make a nice looking menu a little easier. 320x240 is a little cluttered. However, remember that 640x480 will be interlaced for most people (most folks are probably still using the composite video out, not some converter to a monitor). That means nothing that uses really fine lines or it will flicker too much.

Oh, and sanni, you don't need to use dfs_init() in your routine - the program already uses it in the init_n64() routine. It only needs to be done once, unless you have multiple dfs files at different offsets in the rom, then you have to do it each time you want to read from a different dfs.
« Last Edit: August 03, 2010, 04:50:30 AM by ChillyWilly »

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: Need a little help with coding for menu
« Reply #23 on: August 03, 2010, 02:15:13 PM »




That looks ok , but maybe re-arrange the rendering a bit  :)

By the way , one correction to my post above yours(not the typos  ::sm-01:: but count them in) , but this:
Quote
64w * 64h  * bytes per pixel * 300 / 131072 is about 150Mbit of uncompresed rom data for 16bit textures.

I must have turned the tenths (w or h) to hundreds by adding an extra zero when typing because you would need
Quote
64w * 500h * bytes per pixel * 300 / 131072
 
To reach that size  ::sm-07.gif::


(by the way that expression estimates only the size of raw pixels.It doesn't include header info , FS header , FS entry info and all that  ~sm-58.gif~.gif  )
« Last Edit: August 03, 2010, 02:19:38 PM by Conle »

Offline sanni

  • Moderator
  • Hero Member
  • *****
  • Posts: 502
Re: Need a little help with coding for menu
« Reply #24 on: August 03, 2010, 10:07:36 PM »
I uploaded some boxarts taken from DaedalusX64 and renamed according to the cartid's: http://www.megaupload.com/?d=UG53EXIE

Just if someone want to try adding more files to the filesystem.
I think it has something to do with this line in the makefile:

$(N64TOOL) -b -l 1280K -t "N64 Myth Menu (SD)" -h $(HEADERPATH)/$(HEADERNAME) -o $(PROG_NAME).v64 $(PROG_NAME).bin -s 1M $(PROG_NAME).dfs

As soon as the filesystem gets bigger than 1MB probems occur so maybe I have to change  "-s 1M $(PROG_NAME).dfs" to  "-s 2M $(PROG_NAME).dfs" or "-l 1280K" to  "-l 2560K"

Also how does "(dfs_init(0xB0101000)" from main.c relate to this two setting in above line?
And can I disable the 1MByte padding of the finished *.v64 because I would rather use that space for more boxarts?

(but with N64-ish color scheme of course: black, red, green, blue, yellow).

Things to find out:
- how to do a background image
- how to move the text
- how to enable 32bit mode without crashing menu
- how to add more boxart sprites without crashing the menu
- how to make boxart sprites that don't look like **** after conversion
- how to fit 8MB of boxarts into 4MB menu

Just some Paint mockups:


« Last Edit: August 04, 2010, 12:11:02 AM by sanni »

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: Need a little help with coding for menu
« Reply #25 on: August 04, 2010, 02:33:55 AM »
Nice mockup. Backgrounds are fairly simple... just require them to be the same size as the screen and then just copy them to screen buffer after it's been locked instead of clearing the screen (filling it with 0).

Offline Conle

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2203
Re: Need a little help with coding for menu
« Reply #26 on: August 04, 2010, 11:49:49 AM »
Just some Paint mockups:




That looks really nice  :D

Offline sanni

  • Moderator
  • Hero Member
  • *****
  • Posts: 502
Re: Need a little help with coding for menu
« Reply #27 on: August 05, 2010, 04:34:21 AM »
Ok, I want to draw the background with the rdp. I read Chillywilly's post about the image needing to be alligned to powers of two, can be max. 255x255 and less than 4kB.
To achive that I split the background in 80 sprites. 1.sprite - 80.sprite in directory back in filesystem. Each sprite is 32x32px and 2kB, so ~160kB in total.

So inside init_n64() I first create an array for those sprites:
Code: [Select]
    //create image array for background and boxart
sprite_t *back[80];

next I load the sprites into the memory
Code: [Select]
//load backgroundsprites into array
for(int b=0; b<80; b++)
{
sprintf(temp, "/back/%d.sprite", b);
fp = dfs_open(temp);
back[b] = malloc(dfs_size(fp));
dfs_read(back[b], 1, dfs_size(fp), fp);
dfs_close(fp);
}
int b=0; //need that later in while(1)

in while(1) I copied cw's function to draw background.
The sprites are ordered like this:
[1][4][7]
[2][5][8]
[3][6][9]

Code: [Select]
//puzzle background together
        rdp_sync(SYNC_PIPE);
        rdp_set_default_clipping();
        rdp_enable_texture_copy();
        rdp_attach_display(dcon);
        // Draw pattern
        rdp_sync(SYNC_PIPE);
        for (int i=0; i<320; i+=back[b]->width)
            for (int j=0; j<240; j+=back[b]->height)
            {
rdp_load_texture(0, 0, MIRROR_DISABLED, back[b]);
                rdp_draw_sprite(0, i, j);
                b=b+1;
            }
        rdp_detach_display();

Just crashes with black screen. I want to draw back[0] at 0x0, then back[1] at 0x32, until it reaches 240. Then draw back[9] to 32x0 and so on.

Offline ChillyWilly

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1751
  • Just a coding machine.
Re: Need a little help with coding for menu
« Reply #28 on: August 05, 2010, 04:52:11 AM »
You need to do the rdp_sync(SYNC_PIPE) inside the loop before the texture load. You aren't waiting for the previous draw to finish before trying to load the texture for the next draw, and then starting a new draw before the last one is done.

Offline stefan_iro

  • Full Member
  • ***
  • Posts: 218
  • It´s a me, Mario
Re: Need a little help with coding for menu
« Reply #29 on: August 05, 2010, 01:35:31 PM »
Sanni, you really seem to love the N64!  :-*
When I see your background picture I can feel what the N64 is all about ...
-----------------------------------
8bit & 16bit
the golden age of videogames