Neo TeAm Forum

The 10th. NEO Project for N64 => The 10th. NEO Project for N64 Dev kit. => N64 development section => Topic started by: sanni on August 02, 2010, 03:07:12 AM

Title: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 03:07:12 AM
I inserted this into main.c at line 1062 to get save and cic info:
Code: [Select]
// get cic and save options
                char cartid[]="AA";
int i=0;
int romcic=2;
int romsave=0;
sprintf(cartid, "%c%c", gTable[bselect].rom[0x1C], gTable[bselect].rom[0x1D]);
// CARD: 0
// 6101: 1
// 6102: 2
// 6103: 3
// 6105: 5
// 6106: 6

//ciclist[0][0] to ciclist[0][16] cart ids of all 6101 games
//ciclist[1][0] to ciclist[1][16] cart ids of all 6103 games
//ciclist[2][0] to ciclist[2][16] cart ids of all 6105 games
//ciclist[3][0] to ciclist[3][16] cart ids of all 6106 games
char *ciclist[4][17] = {
{ "FX", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
{ "TE", "BK", "DY", "NX", "MX", "KJ", "K4", "NB", "KG", "MQ", "PF", "PH", "PO", "PS", "P2", "P3", "AL" },
{ "B7", "FU", "DO", "DP", "JD", "JF", "ZS", "DL", "ZL", "ML", "PD", "", "", "", "", "", "" },
{ "CW", "FZ", "YS", "", "", "", "", "", "", "", "", "", "", "", "", "", "" }
};

for (i=0; i<17; i++)
{
if (strcmp(cartid, ciclist[0][i]) == 0)
{
romcic=1;
break;
}
}

for (i=0; i<17; i++)
{
if (strcmp(cartid, ciclist[1][i]) == 0)
{
romcic=3;
break;
}
}

for (i=0; i<17; i++)
{
if (strcmp(cartid, ciclist[2][i]) == 0)
{
romcic=5;
break;
}
}

for (i=0; i<17; i++)
{
if (strcmp(cartid, ciclist[3][i]) == 0)
{
romcic=6;
break;
}
}

// CARD: 0
// SRAM 256: 1
// Flash: 4
// 4Kb Eeprom: 5
// 16Kb Eeprom: 6

//savelist[0][0] to savelist[0][20] cart ids of all 4kb eeprom games 1
//savelist[1][0] to savelist[1][20] cart ids of all 4kb eeprom games 2
//savelist[2][0] to savelist[2][20] cart ids of all 4kb eeprom games 3
//savelist[3][0] to savelist[3][20] cart ids of all 16kb eeprom games
//savelist[4][0] to savelist[4][20] cart ids of all sram games
//savelist[5][0] to savelist[5][20] cart ids of all flash games
char *savelist[6][21] = {
{ "SA", "ER", "BK", "TN", "FH", "MU", "BC", "BH", "BM", "HA", "BV", "BD", "CT", "CH", "XO", "CU", "DY", "DQ", "N6", "JM", "FW" },
{ "KA", "GV", "GE", "GC", "PG", "IJ", "IC", "KI", "K4", "LR", "DU", "KT", "LB", "MW", "ML", "TM", "MI", "MO", "MR", "CR", "EA" },
{ "PW", "SU", "K2", "SV", "FX", "S6", "NA", "SW", "RS", "SC", "SM", "TP", "TJ", "RC", "VL", "VY", "WL", "WR", "WU", "AD", "" },
{ "B7", "FU", "CW", "DO", "DP", "MX", "NX", "NB", "MV", "M8", "PD", "RZ", "EP", "YS", "", "", "", "", "", "", "" },
{ "TE", "FZ", "YW", "ZL", "KG", "MF", "RI", "OB", "RE", "AL", "W2", "WX", "", "", "", "", "", "", "", "", "" },
{ "CC", "JD", "JF", "KJ", "ZS", "DL", "M6", "CK", "MQ", "PN", "PF", "PO", "PS", "P3", "P2", "SQ", "T9", "W4", "", "", "" }
};

for (i=0; i<21; i++)
{
if (strcmp(cartid, savelist[0][i]) == 0)
{
romsave=5;
break;
}
}

for (i=0; i<21; i++)
{
if (strcmp(cartid, savelist[1][i]) == 0)
{
romsave=5;
break;
}
}
for (i=0; i<21; i++)
{
if (strcmp(cartid, savelist[2][i]) == 0)
{
romsave=5;
break;
}
}

for (i=0; i<21; i++)
{
if (strcmp(cartid, savelist[3][i]) == 0)
{
romsave=6;
break;
}
}

for (i=0; i<21; i++)
{
if (strcmp(cartid, savelist[4][i]) == 0)
{
romsave=1;
break;
}
}

for (i=0; i<21; i++)
{
if (strcmp(cartid, savelist[5][i]) == 0)
{
romsave=4;
break;
}
}

// update Tables
gTable[bselect].options[5]=romsave;
gTable[bselect].options[6]=romcic;

But Nintendo does not approve of my coding skills  >:(
Compiler said everything is fine though.

As soon as I press Z to see if it works it locks up.  :'(

Edit: Updated it, now it works I hope  :P
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 02, 2010, 03:25:45 AM
You forgot something...

Code: [Select]
      char *ciclist[4][17] = {
         { "FX" }, //cartids of all 6101 games

Means one string of "FX", and 16 NULL pointers. You forgot to test for NULL before doing the strcmp in the loops. Trying to use a NULL pointer is the quickest path to hell there is.  ^-^

If you wanted an empty string, you'd need 16 "" to avoid the issue.
Title: Re: Need a little help with coding for menu
Post by: Conle on August 02, 2010, 05:22:58 AM
Edit: Updated it, now it works for Starfox. But most other games lock up. I need a debugger  ~sm-79.gif~.gif

If it works for some and some others just hang(  O0O ) then probably the configuration is bad   ~sm-69.gif~.gif
Try to put some debug messages to figure out where it hangs....That's the only thing you can do actually  ::sm-12.gif::
Title: Re: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 05:59:03 AM
Ok, I now know, that it locks up when searching the savetype while searching for cic seems to be fine.  ~sm-39.gif~
Also the first for loop of the save determination is fine too.

It can only take more hours until I find the faulty line, just commenting it out line by line and see if it locks up  ~sm-62.gif~.gif

Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 02, 2010, 05:59:37 AM
Ugh - that's such ugly code. I recommend doing it this way:

make one array with the cart ids
search through that array for the id match
if no match, cic = 2 and save = 5
if match, use index into table with cic values and table with save values

That needs only one string table, and two int tables. You only do one search as well. That code would be MUCH easier to debug and maintain.  :D
Title: Re: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 06:18:59 AM
I forgot this , in one line. A little , Who cares about a ,  ::sm-05::

Yeah I know the code looks ugly, but it's the first time I used these matrix arrays and stuff like that, so it's ok for now.
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 02, 2010, 06:37:45 AM
I forgot this , in one line. A little , Who cares about a ,  ::sm-05::

The CPU does.  ~sm-82.gif~.gif

Quote
Yeah I know the code looks ugly, but it's the first time I used these matrix arrays and stuff like that, so it's ok for now.

Just a suggestion for when you feel like cleaning it up. If you did, it might even wind up in the official code.  8)
Title: Re: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 08:07:33 AM
Well that would be nice  ;)

Next week I will read more about this stuff:
if match, use index into table with cic values and table with save values
Because right now I have absolutely no glue how to do that. I found the tables I'm using now somewhere in your code and just adjusted them to my needs and filled them with the cart id I extracted out of the roms.
And from there if was just 10h of trial and error, no real coding involved. I'm surprised that it even worked in the end  ::sm-05::

I already got a new project  ~sm-92.gif~.gif

Code: [Select]
// load boxart sprites
    dfs_init(0xB0101000);
int fp = dfs_open("/FX.sprite");
sprite_t *FX = malloc(dfs_size(fp));
dfs_read(FX, 1, dfs_size(fp), fp);
dfs_close(fp);

// Draw boxart sprite
                sprintf(temp, "%c%c", gTable[bselect].rom[0x1C], gTable[bselect].rom[0x1D]);
if (strcmp(temp, "FX") == 0)
graphics_draw_sprite_trans(dcon, 4, 18, FX);

But it would be a lot nicer if I would not need the if:
Code: [Select]
// Draw boxart sprite
                sprintf(temp, "%c%c", gTable[bselect].rom[0x1C], gTable[bselect].rom[0x1D]);
graphics_draw_sprite_trans(dcon, 4, 18, temp);

But of course once again Nintendo does not approve  ~sm-80.gif~.gif
The gcc compiler also does not approve and most likely the rest of the coding world won't approve but it should be possible with a little imagination  ~sm-46.gif~.gif

Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 02, 2010, 08:27:57 AM
I just meant something like this:

Code: [Select]
char *cartIDs[] = { "FX", .... };
int cicTypes[] = { 1, .... };
int saveTypes[] = { 5, .... };

            for (i=0; NUM_CARTS; i++)
               if (strcmp(cartid, cartIDs[i]) == 0)
                  break;
            if (i == NUM_CARTS)
            {
                // cart not in list
                cic = 2;
                save = 5;
            }
            else
            {
                cic = cicTypes[i];
                save = saveTypes[i];
            }

where NUM_CARTS is the number of entries in the arrays. See how simple and clean that code is? The only real work is making sure the cic and save entries match the proper cartID entry.

As to sprites with libdragon, you need to make the height and width powers of two AND less than 4KBytes in size for hardware drawing, or you need to use the software drawing routine. The hardware sprite drawing is constrained to the size of the texture cache in the RDP, which is 4KB (2KB if you use mipmaps). The software routine draws the sprites manually via the CPU a pixel at a time, so it can be used with any size... but remember that the sprite structure in libdragon uses unsigned bytes for the height and width, so the max size for a sprite is 255x255. Well, it's meant for SPRITES, and if your sprite is larger than that, you should be drawing it another way. :)
Title: Re: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 05:42:54 PM
Is there a way to convert this table I made:

Code: [Select]
NAME ID SAVE CIC BOXART
Worms Armageddon AD 5 2 1
Super Smash Bros. AL 1 3 2
Banjo-Tooie B7 6 5 3
Blast Corps BC 5 2 4
Bomberman Hero BD 5 2 5
Body Harvest BH 5 2 6
Banjo-Kazooie BK 5 3 7
Bomberman 64 BM 5 2 8
Bomberman 64: Second Attack BV 5 2 9
Command & Conquer CC 4 2 10
Chopper Attack CH 5 2 11
NBA Courtside 2 featuring Kobe Bryant CK 4 2 12
Penny Racers CR 5 2 13
Chameleon Twist CT 5 2 14
Cruis'n USA CU 5 2 15
Cruis'n World CW 6 6 16
Legend of Zelda: Majora's Mask, The DL 4 5 17
Donkey Kong 64 DO 6 5 18
Donkey Kong 64 DP 6 5 19
Donald Duck: Goin' Quackers DQ 5 2 20
Loony Toons: Duck Dodgers DU 5 2 21
Diddy Kong Racing DY 5 3 22
PGA European Tour EA 5 2 23
Star Wars Episode 1 Racer EP 6 2 24
AeroFighters Assault ER 5 2 25
Bass Hunter 64 FH 5 2 26
Conker's Bad Fur Day FU 6 5 27
F-1 World Grand Prix FW 5 2 28
Star Fox 64 FX 5 1 29
F-Zero X FZ 1 6 30
GT64 Championship Edition GC 5 2 31
GoldenEye 007 GE 5 2 32
Glover GV 5 2 33
Bomberman 64 HA 5 2 34
Indy Racing 2000 IC 5 2 35
Indiana Jones and the Infernal Machine IJ 5 2 36
Jet Force Gemini JD 4 5 37
Jet Force Gemini JF 4 5 38
Earthworm Jim 3D JM 5 2 39
Snowboard Kids 2 K2 5 2 40
Kirby 64: The Crystal Shards K4 5 3 41
Fighters Destiny KA 5 2 42
Major League Baseball featuring Ken Griffey Jr. KG 1 3 43
Killer Instinct Gold KI 5 2 44
Ken Griffey Jr's Slugfest KJ 4 3 45
Mario Kart 64 KT 5 2 46
Mario Party LB 5 2 47
Lode Runner 3D LR 5 2 48
Megaman 64 M6 4 2 49
Mario Tennis M8 6 2 50
Mario Golf MF 1 2 51
Mission: Impossible MI 5 2 52
Mickey's Speedway USA ML 5 5 53
Monopoly MO 5 2 54
Paper Mario MQ 4 3 55
Multi-Racing Championship MR 5 2 56
Big Mountain 2000 MU 5 2 57
Mario Party 3 MV 6 2 58
Mario Party 2 MW 5 2 59
Excitebike 64 MX 6 3 60
Dr. Mario 64 N6 5 2 61
Star Wars Episode 1: Battle for Naboo NA 5 2 62
Kobe Bryant in NBA Courtside NB 6 3 63
Excitebike 64 NX 6 3 64
Ogre Battle 64: Person of Lordly Caliber OB 1 2 65
Pokémon Stadium 2 P2 4 3 66
Pokémon Stadium 2 P3 4 3 67
Perfect Dark PD 6 5 68
Pokémon Snap PF 4 3 69
Hey you, Pikachu! PG 5 2 70
Pokémon Snap PH 4 3 71
Pokémon Puzzle League PN 4 2 72
Pokémon Stadium PO 4 3 73
Pokémon Stadium PS 4 3 74
Pilotwings 64 PW 5 2 75
Top Gear Overdrive RC 5 2 76
Resident Evil 2 RE 1 2 77
New Tetris, The RI 1 2 78
Star Wars: Rogue Squadron RS 5 2 79
Ridge Racer 64 RZ 6 2 80
Star Soldier: Vanishing Earth S6 5 2 81
AeroFighters Assault SA 5 2 82
Starshot Space Circus SC 5 2 83
Super Mario 64 SM 5 2 84
Starcraft 64 SQ 4 2 85
Rocket: Robot on Wheels SU 5 2 86
Space Station Silicon Valley SV 5 2 87
Star Wars: Shadows of the Empire SW 5 2 88
Tigger's Honey Hunt T9 4 2 89
1080º Snowboarding TE 1 3 90
Tom & Jerry in Fists of Furry TJ 5 2 91
Mischief Makers TM 5 2 92
All-Star Tennis '99 TN 5 2 93
Tetrisphere TP 5 2 94
V-Rally Edition '99 VL 5 2 95
V-Rally Edition '99 VY 5 2 96
WCW/NWO Revenge W2 1 2 97
WWF: No Mercy W4 4 2 98
Waialae Country Club: True Golf Classics WL 5 2 99
Wave Race 64 WR 5 2 100
Worms Armageddon WU 5 2 101
WWF: Wrestlemania 2000 WX 1 2 102
Cruis'n Exotica XO 5 2 103
Yoshi's Story YS 6 6 104
Harvest Moon 64 YW 1 2 105
Legend of Zelda: Ocarina of Time, The ZL 1 5 106
Legend of Zelda: Majora's Mask, The ZS 4 5 107


into this format:

Code: [Select]
char *names[] = {"Starfox",....};
char *cartIDs[] = { "FX", .... };
int saveTypes[] = { 5, .... };
int cicTypes[] = { 1, .... };

without typing it manually?
Because that would be exhausting  ~sm-39.gif~

Layout of the Table: NAME/CARTID/ALTERNATE CARTID/SAVE/CIC
ALTERNATE CARTID is when there are two different versions of the same games, like Jet Force Gemini and Jet Force Gemini Kiosk. The have different Cartids, sometimes the same game but from an different region hs also a different id.
Title: Re: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 07:47:17 PM
This is how far I am right now:

making array for the boxarts(line 58)
Code: [Select]
sprite_t *boxart[299];

loading boxartsprite sprite into array (879)
Code: [Select]
// load boxart sprites
    dfs_init(0xB0101000);
    int fp = dfs_open("/FX.sprite");
    boxart[0] = malloc(dfs_size(fp));
    dfs_read(boxart[0], 1, dfs_size(fp), fp);
    dfs_close(fp);

main code (1049)
Code: [Select]
if ((gTable[bselect].type == 255))
{
//data arrays
//char *names[] = {"Starfox"};
char *cartIDs[] = {"FX"};
int saveTypes[] = {5};
int cicTypes[] = {1};
int boxartArrayNr[] = {0};

// variables
int NUM_CARTS = 1;
int cic = 2;
int save = 0;
int i=0;
int b= 0;
char cartid[]="AA";

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

// search for cartid
for (i=0; 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, 4, 17);
cic = 2;
save = 0;
}
else
{
// cart found
b = boxartArrayNr[i];
cic = cicTypes[i];
save = saveTypes[i];
}

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

//draw boxart
graphics_draw_sprite_trans(dcon, 8, 100, boxart[b]);
}

Of course it crashes so i will search for that "," again  ~sm-59.gif~.gif
Title: Re: Need a little help with coding for menu
Post by: Conle on August 02, 2010, 08:01:54 PM
Code: [Select]
int boxartArrayNr[] = {0};
b = boxartArrayNr[i];


This : "int boxartArrayNr[] = {0};"
Is the same as doing :
Code: [Select]
int boxartArrayNr = 0;

So , right now , the compiler is doing something like :
Code: [Select]
[4byte long]

ptr = addressOf([4byte long])

b = *(int*)(ptr + i * sizeof(int));

Which when i > 0 it goes out of range.

You should replace it to this :
Code: [Select]
static int boxartArrayNr[NUM_CARTS] = {0};
b = boxartArrayNr[i];

or allocate/free it dynamically.

Same applies for all the arrays you got there

edit : Also , this :  for (i=0; NUM_CARTS; i++) is inf loop  ~sm-75.gif~.gif
Replace it to  for (i=0;i < NUM_CARTS; i++)
...And maybe read some C tutorials  ~sm-70.gif~.gif
Title: Re: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 09:23:59 PM
Found the cause for the crashes, apparently you can't just throw 300 sprites(64x64 8kB 16Bit) into the filesystem  ::sm-05::
Seems like there is a limit on how many files you can have in there.

Now it works, I just have to fill the arrays with information and find out how many files you can store in the filesystem. Maybe it supports folders and only like 230 or so files per folder like old computers  ~sm-75.gif~.gif
Title: Re: Need a little help with coding for menu
Post by: Conle on August 02, 2010, 09:40:20 PM
Well , lets see..

64w * 64h  * bytes per pixel * 300 / 131072 is about 150Mbit of uncompresed rom data for 16bit textures.
But , you must pad the menu to that size and because of how the bank is configured , you have to set the core to load a 256Mb rom  :P
and of course you must pad the menu to that size ( 150Mbit + 2-3Mb reserved ). (Maybe you also have to setup the alignment also but im not sure
about that).

But the question is ... what's the point of storing so many textures in the .rom section when you can just upload the textures on the psram or ram(and the n64 has enough to store temporary a few at a time) after reading it from the SD cart  ~sm-73.gif~.gif 

If you want textures , do exactly what Sony is doing for PSP/PS3.Read the directory , load as many texture as you can on PSRAM without having to change bank
then while the user is moving through the entries just copy it to the frame buffer & sync rdp(That's the easiest way but not very efficient). And for sure you want them compressed.Maybe use APLIB for that purpose.

Title: Re: Need a little help with coding for menu
Post by: sanni on August 02, 2010, 10:03:46 PM
(http://www.abload.de/img/dsc01760xf4z.jpg)

(http://www.abload.de/img/dsc01761yc6x.jpg)
Title: Re: Need a little help with coding for menu
Post by: ronaldo_76 on August 03, 2010, 12:07:16 AM
whooooo sanni thats great.  :)

can't wait to test it! looks amazing.  :-*
Title: Re: Need a little help with coding for menu
Post by: stefan_iro on August 03, 2010, 01:50:03 AM
This one looks amazing!  :)
Good work!
Title: Re: Need a little help with coding for menu
Post by: mic_ on August 03, 2010, 02:00:26 AM
Boxarts are nice. Now make it look something like this:
 (http://www.consolemax.nl/images/wii-usb-loader.png)
 ~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.
Title: Re: Need a little help with coding for menu
Post by: sanni 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::
Title: Re: Need a little help with coding for menu
Post by: stefan_iro on August 03, 2010, 02:09:50 AM
Thanks a lot for your efforts!  ~sm-36.gif~
Title: Re: Need a little help with coding for menu
Post by: sanni 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.
Title: Re: Need a little help with coding for menu
Post by: ronaldo_76 on August 03, 2010, 03:03:49 AM
the n64 menu have a fressstyledash update...  ~sm-43.gif~
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly 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.
Title: Re: Need a little help with coding for menu
Post by: Conle on August 03, 2010, 02:15:13 PM
(http://www.abload.de/img/dsc01760xf4z.jpg)

(http://www.abload.de/img/dsc01761yc6x.jpg)

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  )
Title: Re: Need a little help with coding for menu
Post by: sanni 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:
(http://www.abload.de/img/menu85aj.png)

(http://www.abload.de/img/backn64y.png)
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly 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).
Title: Re: Need a little help with coding for menu
Post by: Conle on August 04, 2010, 11:49:49 AM
Just some Paint mockups:
(http://www.abload.de/img/menu85aj.png)

(http://www.abload.de/img/backn64y.png)

That looks really nice  :D
Title: Re: Need a little help with coding for menu
Post by: sanni 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.
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly 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.
Title: Re: Need a little help with coding for menu
Post by: stefan_iro 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 ...
Title: Re: Need a little help with coding for menu
Post by: Conle on August 05, 2010, 01:43:48 PM
By the way,this loop needs unrolling :
Code: [Select]
        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;
            }

to
Code: [Select]
        for (int j=0; j<240; j+=back[b]->height)
        for (int i=0; i<320; i+=back[b]->width)
       {
            rdp_load_texture(0, 0, MIRROR_DISABLED, back[b++]);
            rdp_draw_sprite(0, i, j);
        }
~sm-36.gif~
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 05, 2010, 02:22:01 PM
Err - you didn't unroll it, you just flipped the order the tiles are drawn in.  ^-^
Title: Re: Need a little help with coding for menu
Post by: Conle on August 05, 2010, 02:45:55 PM
That!   ::sm-02::
Title: Re: Need a little help with coding for menu
Post by: sanni on August 05, 2010, 04:47:07 PM
(http://www.abload.de/img/dsc01766zfnq.jpg)

Seems like I messed up while cutting the image in 80 pieces, stupid black line  :-\

Title: Re: Need a little help with coding for menu
Post by: Conle on August 05, 2010, 05:11:20 PM
Don't edit manually each tile...Just store the background somewhere in rom or ram or psram and just do something like :

Code: [Select]
void upload_tiles(const unsigned char* buffer,int tileW,int tileH)
{
const char* end;
sprite_t* img = (sprite_t*)buffer;
const int blockSize = (tileW * tileH * img->bitdepth);

buffer += sizeof(sprite_t); //Skip lib dragon header

for(end = img->w * img->h * img->bitdepth - sizeof(sprite_t); buffer < end; buffer += blockSize)
{
img.data = buffer;
sync pipe
upload data
display data
}
}

Then you do :
Code: [Select]
upload_tiles(buffer,32,32); to fill the screen with 32x32 tiles.
 ::sm-10.gif::

ps - By the way , the image looks pretty good.Is it 32 or 16 bit?  ~sm-55.gif~.gif
ps2 - forgot to tell you that of course you must calculate the offset of each tile.
Its extremely simple.You'll need a variable for X and Y axis. Then , while looping , you increase X axis equally to tileW.
When X axis reaches screen width , you increase the Y axis by tileH pixels and you set the x pointer back to offset 0.
 8)

Edit again - Anyway here's the code if you feel puzzled :D
Code: [Select]
void upload_tiles(const unsigned char* buffer,int tileW,int tileH)
{
   const char* end;
   int x,y;
   sprite_t* img = (sprite_t*)buffer;
   const int blockSize = (tileW * tileH * img->bitdepth);

   buffer += sizeof(sprite_t); //Skip lib dragon header

   for(x = y = 0,end = img->w * img->h * img->bitdepth - sizeof(sprite_t); buffer < end; buffer += blockSize)
   {
  if(x >= img->w)
  {
         x = 0;
         y += tileH;
      }

      img.data = buffer;
      sync pipe
      upload data
      display img , x , y

  x += tileW;
   }
}
Title: Re: Need a little help with coding for menu
Post by: sanni on August 05, 2010, 07:14:35 PM
Thats great, I will try that soon. That way changing the background would be a lot easier.  :)
The background is made with paint.net in 32bit, then sliced into 80 pieces, each saved as bmp and then batch converted to a 8Bit(256 Colors) png with Irfanview and finally with mksprite to a 16bit sprite. And TV is a 42" plasma. Picture made with Sony K750i mobile phone.

Anyway here the current state, it's not perfect but it's slowly progressing.  ::sm-29.gif::

(http://www.abload.de/img/dsc01781mmmm.jpg)
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 05, 2010, 08:40:41 PM
That's coming along rather well.  ::sm-09.gif::
Title: Re: Need a little help with coding for menu
Post by: Conle on August 05, 2010, 09:10:21 PM
Indeed it looks really good.   :) The only thing i don't like is the font color for the entry list.Maybe pick a bit darker colors.

Quote
Thats great, I will try that soon. That way changing the background would be a lot easier.

Just don't forget to fix this line in the code i posted:
Code: [Select]
for(x = y = 0,end = img->w * img->h * img->bitdepth - sizeof(sprite_t); buffer < end; buffer += blockSize)

To
Code: [Select]
for(x = y = 0,end = buffer + (( img->w * img->h * img->bitdepth) - sizeof(sprite_t)); buffer < end; buffer += blockSize)

Because the offset must be relative to the buffer address.
I haven't tested the code(written it just off the top of my head) but the algorithm looks fine.
Title: Re: Need a little help with coding for menu
Post by: sanni on August 06, 2010, 03:18:25 PM
Is there anything better than Geany for programming on kubuntu?
Title: Re: Need a little help with coding for menu
Post by: Conle on August 06, 2010, 03:27:37 PM
Is there anything better than Geany for programming on kubuntu?

 O0O  O0O There's nothing better than Gedit with oblivion theme.  (Edit-->I think it must be called Kedit on Kubuntu  ~sm-79.gif~.gif )
 ^-^   8)
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 06, 2010, 04:01:39 PM
Is there anything better than Geany for programming on kubuntu?

Are you looking for something lighter, or heavier? Lighter - gedit. Heavier - Code Blocks or Eclipse.
Title: Re: Need a little help with coding for menu
Post by: sanni on August 06, 2010, 04:10:45 PM
Oh, I meant xubuntu of course, sorry ::sm-02::

Thank you I will try gedit, I already did try Eclipse on Windows but that was too much.
Title: Re: Need a little help with coding for menu
Post by: Conle on August 06, 2010, 06:24:35 PM
Oh, I meant xubuntu of course, sorry ::sm-02::

I believe that this is the purpose of those distros : to confuse us  ::sm-05::
You've   lost the battle  ::sm-16.gif::  , but not the war   O0O
Title: Re: Need a little help with coding for menu
Post by: madmonkey on August 06, 2010, 06:57:36 PM
heavier: qt creator.
you don't need to use qt or qt project system to use it, and it's definitely convenient, but it's heavy :)
Title: Re: Need a little help with coding for menu
Post by: sanni on August 06, 2010, 07:23:02 PM
- What I need is, when I write as example:
rdp_load_texture(
Then it should tell me if rdp_load_texture returns an int or what and also what I have to put into the parentheses. Right now if allways have to search through all header files and look by myself.

- Also I need more colors.
It should color all different kind of keywords
Like if I write:
sprite_t *images[2] = {NULL, NULL};
Then sprite_t and such things e.g. int or so should be colored, because that all are those definition things that define what type it is. So if I see that color, I know, here something gets defined.
And then *images[2] should be in an color for arrays and so on.

And when I write:
if
{
    if
  {
  }
   else
 {
 }
}
Then the matching brackets  should be in the same color as the if but in an other color then other brackets and other ifs so I know this bracket belongs to that bracket and that if.

Also if I write it like this:
   else
 {
 {
I would notice it because the brackets would be of different color.

- And also I don't wanna type make in the shell. Because it just says look in line 745 you messed up. But it would be better if I could just compile from within the editor and it would highlight the lines in the editor so I don't have to search. Because I do allot of line searching.

- Also very important i would like some sort of  book mark function, where I can label bookmarks in the code for quick jumping to different parts of the code.
Title: Re: Need a little help with coding for menu
Post by: madmonkey on August 06, 2010, 07:44:50 PM
I doubt something like this even exists, particularly different color bracket highlighting :)
just try qt creator. it has most of the stuff you want.
Title: Re: Need a little help with coding for menu
Post by: Conle on August 06, 2010, 07:51:39 PM
Gedit has a full set of plugins :
http://live.gnome.org/Gedit/Plugins

LIke the bookmarking that you asked for. Gedit + plugins is the best combo  8)
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 07, 2010, 04:39:10 AM
Geany shows the info on functions  - what they return and the args they take... but only if the file where the function is defined (either the c or h file) is currently in one of the tabs. I find it one of the handiest features of geany.
 ~sm-51.gif~.gif

Geany also has auto-completion on variables, defines, functions, and structure fields... again when the file where they are defined is open in one of the tabs.
Title: Re: Need a little help with coding for menu
Post by: sanni on August 07, 2010, 05:30:28 AM
Thank you Chillywilly  :-* I didn't know that.
I will continue to use Geany now.
I should read the manual first before complaining :-\

Tommorrow I have some time again, I then will try to back up the gba sram from within the menu and split it to savefiles. I already done that once with my *.bat files I posted here and there is madmonkeys programmer code that also contains how to do that.
The best thing about not knowig how hard things are is that you are not afraid of trying  I guess ~sm-79.gif~.gif
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 07, 2010, 05:48:07 AM
Thank you Chillywilly  :-* I didn't know that.
I will continue to use Geany now.
I should read the manual first before complaining :-\

Who ever reads the manuals?  ~sm-64.gif~.gif  ~sm-82.gif~.gif


Quote
Tommorrow I have some time again, I then will try to back up the gba sram from within the menu and split it to savefiles. I already done that once with my *.bat files I posted here and there is madmonkeys programmer code that also contains how to do that.
The best thing about not knowig how hard things are is that you are not afraid of trying  I guess ~sm-79.gif~.gif

Um, you mean the N64 Myth sram. The GBA sram isn't used on the N64 Myth. As the comments on the update indicate, the code to read/write the gba sram on the N64 Myth don't even work (yet).

I am going to get them working if at all possible. It would allow people on flash-only carts another place to backup sram to.
Title: Re: Need a little help with coding for menu
Post by: sanni on August 08, 2010, 01:01:50 AM
I search for a place where I could store the cart id of the last played game.
So that when you turn the Neo Myth on, it will automatily backup the nsram and save it under that cartid. Then when you start another game I could let it auto load it's save without worrying about overwriting an other games save.

I can't use the upper half of the nsram because it would be overwritten when playing a game from bank 4. I don't want to write it to the U2 menu area, because it will unnecessary wear it with time.
The psram will lose the info without power.
So there is either the gba sram or the gba menu area left.
I would prefer the menu area but someone could have flashed an MF version of the menu there. So all comes down to the gbasram again  ~sm-79.gif~.gif
Or could you tell me an offset in the gbamenu area where I can savely write without killing the MF menu, if there is one flashed?
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 08, 2010, 03:07:56 AM
There are no banks in the N64 save ram. The sram is used in the emulation of the other save forms, so the 128KB of FRAM would use half the sram. The other half is essentially "free" as nothing uses more sram. I was already planning to reserve the last 512 bytes of N64 sram for our own purposes - right now, I use the last 16 bytes for when games run from the SD card need to reset to game, but have a different CIC than the boot CIC. We could use part of that area for save info as well... the first 256 bytes (of the last 512 bytes) would be a 255 char long array holding the name of the last rom run,with a couple extra bytes for a flag that it needs saving on boot, and what save type the last rom was so that you save the correct amount.
Title: Re: Need a little help with coding for menu
Post by: sanni on August 10, 2010, 07:06:14 AM
I have a problem .. again  :(

As soon as I put #include <mikmod.h> togehter in one main.c with #include <diskio.h> and #include <ff.h> I get this error:

Quote
/home/sanni/dragon/mips64-elf/bin/mips64-elf-gcc -std=gnu99 -march=vr4300 -mtune=vr4300 -O1 -G0 -Wall -I/home/sanni/dragon/mips64-elf/include -I/home/sanni/dragon/mips64-elf/mips64-elf/include -DRUN_FROM_U2   -c -o main.o main.c
In file included from main.c:11:
/home/sanni/dragon/mips64-elf/include/mikmod.h:83: error: conflicting types for 'CHAR'
/home/sanni/dragon/mips64-elf/include/integer.h:16: note: previous declaration of 'CHAR' was here
/home/sanni/dragon/mips64-elf/include/mikmod.h:108: error: redefinition of typedef 'ULONG'
/home/sanni/dragon/mips64-elf/include/integer.h:28: note: previous declaration of 'ULONG' was here
/home/sanni/dragon/mips64-elf/include/mikmod.h:109: error: conflicting types for 'BOOL'
/home/sanni/dragon/mips64-elf/include/integer.h:32: note: previous declaration of 'BOOL' was here
make[1]: *** [main.o] Error 1
make[1]: Leaving directory `/home/sanni/dragon/src/NeoMenu/NeoN64Menu-v1.4S2/src'
make: *** [NEON64.v64] Error 2

I have absolutely no clue what it is trying to tell me  ~sm-39.gif~
Title: Re: Need a little help with coding for menu
Post by: Conle on August 10, 2010, 11:14:16 AM
It says that the defined types in mikmod.h have been defined already in the included file integer.h.
So , you either remove the include , or you remove the (already)defined types from mikmod.h ..or put them between #if #endif blocks that check if those types have been defined in another header.
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 10, 2010, 11:31:41 AM
I really wish everybody would just use stdint.h... it's what it's for!!  >:D
Title: Re: Need a little help with coding for menu
Post by: sanni on August 10, 2010, 11:39:49 PM
Is there a way to assign priorities to processes?
I have the backgroundmusic working in the menu but to keep it playing I have to do

Code: [Select]
MikMod_Update();

all the time.
So I put it in the main while(1) but when I move the cursur for game selection the music plays slower but goes back to normal speed as soon as I do nothing again and when it loads/displays a boxart it plays so slow it almost stops and while loading a rom, well guess what   ~sm-62.gif~.gif
So if I could somehow tell the N64 that MikMod_Update(); is super important and it should not wait to execute it, that would be nice.

I guess the mikmod thing is not the best way to play audio, way to cpu depending.
Title: Re: Need a little help with coding for menu
Post by: Conle on August 11, 2010, 12:39:08 AM
Well , your best bet is to let the 2nd cpu do the audio decoding/playing or maybe try to split the render/audio playback to threads.
Give higher priority to audio thread and a bit lower to the render function.

Or .. play with the time and add 2 states.When the timer reaches a fixed time it will swap state but this is not a real solution :D
Also check to see if that lib has some kind of status flags that tell when the audio buffer needs syncing...   ~sm-72.gif~.gif
Title: Re: Need a little help with coding for menu
Post by: ChillyWilly on August 11, 2010, 03:05:38 AM
Is there a way to assign priorities to processes?
I have the backgroundmusic working in the menu but to keep it playing I have to do

Code: [Select]
MikMod_Update();

all the time.
So I put it in the main while(1) but when I move the cursur for game selection the music plays slower but goes back to normal speed as soon as I do nothing again and when it loads/displays a boxart it plays so slow it almost stops and while loading a rom, well guess what   ~sm-62.gif~.gif
So if I could somehow tell the N64 that MikMod_Update(); is super important and it should not wait to execute it, that would be nice.

I guess the mikmod thing is not the best way to play audio, way to cpu depending.

The issue is that nothing (much) is done at an interrupt level on the N64. If you can guarantee that all your resources are in ram and that it won't be TOO intensive, you could add a callback to the audio interrupt that did the update. That would cure your priority issue.

That's all you have until a threading system is made - then you could make an audio thread with a higher priority than the main thread. Until then, just adding update calls all over is your only other option.