
Media X Menu Version 0.9c Beta


NOTE: Do not use 0.5 or 0.6 on a DVD-R. There was a bug that is now fixed in
0.7 and above... sorry for the confusion.

Media X Menu is a menu system to launch applications from a DVD collection or from 
a hard drive. It is intended to be very configurable and allow new "themes" to be added 
in, both with simple visual changes, or adding 3D effects to the presentation of the 
menus by re-writing the software.

It is now in "Beta" status. It should be stable to use on DVD-R discs, but who knows?
As usual, use at your own risk. 


I am releasing this source code for others to use for both their own projects, and 
hopefully, to enhance this project. The current features are as follows:

There *ARE* still some bugs with this thing.... but I've tried to do as much testing as 
possible without spending three weeks on it. I believe most of it relates to the 
handling of the soundtracks at the moment, but tracking down everything is time consuming
and at the moment, it seems to work 99.9% of the time. My suggestion would be to not use 
"random" soundtrack play, and it will be turned of by default.

* Impliments the "Simple" theme, allowing a title screen, menu screen, loading screen 
  and saver screen, each with configurable elements (custom backgrounds, custom bouncing 
  logo for the screen saver)
* Simple theme uses Skins based in subdirectories, and can use randomly selected skins 
  on every run of the program.
* Launches applications from the hard drive and the CD/DVD drive.
* Screen saver! 
* Can play one or more music tracks, with multiple options, such as-
  - Disc-specific tracks (played from subdirectory, for example)
  - Can play from the XBox soundtracks the user has on his hard drive
  - Can play random or in order
* Supports BMP, PNG, TGA, and JPG image formats
* All settings are done via XML file support, a format familiar to many users.
* Supports 640x480 at the moment. Sorry, just ran out of time to get the multi-res
  support in.

==================================================
===   IR Remote Support                        ===
==================================================

Thanks to d7o3g4q and RUNTiME for releasing their source code as without this Remote support wouldn't have been possible.

Here is the latest Build with full IR Remote Support.

The COntrols are as Follows:
============================

IR Remote up/down = scroll trhough the menu list
IR Remote Select  = Select's the Game / Emulator
IR Remote Info    = Media X Menu Version Info Displayed
IR Remote Back    = Return To Media X Menu Title Screen
IR Remote 0       = Reboot XBOX back to Dashboard

Any button on the IR Remote will come out of the screensaver and skip past menu's like the 
Controller does.

IR Support By SpOoK with thanks to d7o3g4q and RUNTiME for their IR Remote Code.

Note from BenJeremy: I don't have the remote, but the code looks good and SpOok has tested this
with most of the releases. 

==================================================
===   A Note about XML                         ===
==================================================

For those not familiar with XML, it's basically a method of tagging information in a text file.

Configuration XML files in MXM, for example take on the following structure:

<Config>
 <Main>
  <DiscTitle>My Collection</DiscTitle>
  <DiscSubtitle>MAME</DiscSubtitle>
  <Theme>1</Theme>
 </Main>
</Config>


The entire config is surrounded by the <Config> tags, and each section has their own group.

Complex skins will get much more sophisticated, due to the nature of what needs to be done...
When these are implimented, there will be a very detailed description of how these XML
files must be built.

In the meantime, all INI files can be converted into MXM XML files using the INItoXML 
converter for Windows in this binary release.



==================================================
===   Auto-Config Items                        ===
==================================================

To make things a bit more bulletproof, MXM now supports "Auto-config" I would
encourage those who make software releases for the Xbox to include a game/logo
screenshot and an MXM_Entry.ini file as part of the release.

Auto-config loading sequence:
1. First MXM loads all the entries in the MXM.ini file
2. MXM then searches the IMMEDIATE subdirectories for MXM_Entry.ini
   files. If found it will attempt to load those values... missing values
   or non-existant files will cause MXM to fall back to the following steps.
3. If an executable has not been assigned by the MXM_Entry.ini file, MXM will 
   look for "default.xbe", failing to find default.xbe, it will search for the 
   FIRST *.xbe file it finds in the directory and use that.
4. If an executable has been found, but no title has been assigned, it will
   use the title stored as part of the XBE's built-in certificate.
5. Lastly, if there is no game/logo screenshot assigned at this point, the system
   will look for the first MXM_SS.* file that is a JPG, BMP, TGA, PNG or GIF and use
   that file.

So the easiest thing to do, for each game, is to simply through a screenshot in the 
directory named "MXM_SS.jpg" (or whatever the extension is for the chosen format).

Next easiest thing is the above screenshot file, with an MXM_Entry.ini file including 
the following:

----------

[Item]
Title=Mame Vol#3
Description=CAPCOM collection!


----------

The [Item] Section may also include the following:

Media=<image filename>
  The image file, relative to the location of this entry ini file.
Exe=<xbe filename>
  The filename only, of the XBE to use in this directory.
  Ex: "Exe=XMarbles.xbe"




===================================================================
FAQ:
===================================================================
Q: I've got an Enigmah Beta, why doesn't this run?
A: I don't have a patch tool for Enigmah users. Sorry.... if you 
   have such a tool, please get a hold of me at xbox-scene or 
   xboxhacker.net.

Q: I don't like the title screen. Can you get rid of it?
A: Well, it's simple enough to give the title screen delay a value of '0'
   to skip by it.

Q: I don't like the screen saver feature, how do I get rid of that?
A: Same thing, a delay time of zero will de-activate the saver.

Q: Where can I find skins?
A: I'll try and release a few, but at the moment, nobody is hosting 
   skins specifically for my menu system; HOWEVER, since the 'default'
   layout for simple happens to match up to Complex MenuX, you can use
   skins created for that system with this menu (of course, MXM is far
   more flexible in positioning screens and items)

Q: How about a tutorial on using this?
A: I'd love to put one together for it, but to be honest, I'm probably 
   the wrong person to do the job (as the developer, I'd have a hard 
   time making a tutorial from a nontechnical perspective). If anybody out 
   there feels up to the task, please do and send it to our good 
   friends at xbox-scene.

Q: I can't get this to boot.
A: Well, I need a copy of your INI file, at the very least, in order to 
   determine what the problem is. Try checking your image files and make
   sure they are there and are correctly formatted. Get a hold of me at 
   xbox-scene if all else fails.

===================================================================
HISTORY:
===================================================================

Alpha 0.2
  Minor bug fix release
* Fixed problem identifying the correct partitions. (Thanks ITM of xboxhacker.net for the fix)
* Added speed enhancement, again, thanks ITM for this code.
* Moved soundtrack to it's own thread to prevent pausing in screen saver
* "About" box added  when pressing "White button" in the menu screen
* Added the  PersistDisplay() call, but didn't notice a difference. No loading screen joy.
* Added "DrawDescription" to Menu section to allow you the ability to turn off the description.
* Keyboard support - Cursor Up/Down, ENTER to select. Keys skip title and saver, F1 brings up 
  "about box" and PrintScreen key will reboot to the dashboard.

Alpha 0.3
  Minor bug fix release
* Fixed problem identifying the correct partition for F:. AGAIN.
  Bah! The generic code didn't want to work, even after I identified
  a problem with the code. Fixed it with a specific case for F:

Alpha 0.4
* More bug fixes! Didn't realize that C:, E:, and F: were unmounted, causing 
  problems when the image files didn't "live" in the directory below the 
  menu system and get called as "D:\***" This problem is now fixed.
* Changed option "Theme" in section [Main] to "Style" This will represent the
  type of menu displayed (simple, or in the future, 3-D styles)
* Smooth scrolling menu items and descriptions.
* Menus and description placement are fully configurable. Defaults to MenuX style,
  to be compatible with existing MenuX skins. Now menus, screenshots, and the 
  description can be placed anywhere on the screen and in just about any size.
  You can also select the maximum number of options displayed at any given time
  (that is, how many item rows are displayed in the menu item box)

Alpha 0.5
* Phew. Bug fix. Sorry about that, people, but there was a big bug causing 
  instability in the system. It's very difficult to debug an app wthout a 
  debug console. Many problems solved now.
* SKINS! SKINS! SKINS! SKINS! This is the first release supporting 
  self-contained skins! "DefaultSkin" is included with the release,
  basically the same images and sounds as in the previous releases, now
  in a handly subdirectory with their own ini file.
 
Beta 0.6
* Cleaned up a couple of cosmetic bugs.
* Fixed a problem with the skin soundtracks
* Implimented a few more skin attributes. Not all are there yet.
* Changed the screensaver slightly.
* Release will be a bit cleaner than before, with the ini files 
  cleaned up.

Beta 0.7
* Fixed a bug that prevented skins from working in 0.5 and 0.6
  I now will test each release with a XDFS formatted CD-RW (problems and
  time make testing on DVD-RW or DVD-R prohibitive at the moment)

Beta 0.8
* Fixed issue with descriptions that are missing.
* Cleaned up message box popping up when a screenshot is missing.

Beta 0.9
* AutoConfig!! See the section on AutoConfig for complete details.
* Sped up menuing by offloading screenshots to a seperate thread.

Beta 0.9b
* Added IR support, courtesy of SpOoK from the  xboxhacker.net forums
  (See the section on the IR support)
* Fixed 'overzealous' keypress issue.
* Changed dashboard sequence for the controller from BACK+START to RIGHT STICK+LEFT STICK
  It remains "PrntScr" for the keyboard.

Beta 0.9c
* Added the ability to navigate using the thumbsticks
* Fixed the PersistDisplay() issue. Loading screens now display.
* WMV is now a supported format! The videos will loop, and sound is disabled
  in this release by default. I'll add parameters to change those (sound does
  work) shortly. WMV files can be used ANYWHERE an image file is used.
  Thanks go out to Syn3rgy @ the xboxhacker.net forums for knocking down the
  remaining barriers on this feature.
* Moving away from ini files. XML will be the new standard (faster loading)
  To make things easier, I've included a converter, to modify existing files to 
  the new format.
* Disable for auto-config - Set Main->AllowAutoConfig to No (or Off/false)
* Main->MoveDelay - Time between pressing down/up and the menu changing selections in Repeat mode.
* Main->RepeatDelay - Time between holding down/up and the program repeating the move.
* Main->LoadSkin parameter to select a specific skin (Based on directory name)
* Main->ExitApp allows you to specify a dashboard other than the 'default' one, such 
  as "C:\evoxdash.xbe" when using the dashboard sequence. This solves a problem
  when using MXM as your default dashboard application.


At the moment, I'm looking at cleaning up the remaining skinnable items, random local soundtrack.


KNOWN ISSUES:
* MoveDelay and RepeatDelay are currently only implimented for the stick.
* Title screen does not come up quickly. This needs to be improved, and it would also be nice
  to fade it in.
* Users have expressed a desire to see the screenshots fade from one to another.
* Items loaded from the MXM.ini are not checked yet for validity. If they don't exist,
  the entries should be tossed.
* WMV files *MUST* have sound present, even if you are not playing sound.
* Support for XMV is not present.
* Not all skinning options supported yet - Still working on these.
* Setting Random on with Global off prevents local skin track from working.
* Global off may prevent the local music directory from working
* There is a slight "stutter" from the music when MXM starts up.
* More themes needed (this is beyond the skinnable "simple theme", referring to 3D themes
  like a spinning screenshot cube, for example.)
* Circular menus option


===================================================================
Things that couldn't make it into this release, but are planned:
===================================================================
* Passcode access to specific games. This option would allow the person configuring MXM to
  prevent access to an option based on a passcode.
* Help screens for games. This will be implemented as images displayed when you hit a particular
  button.
* More detailed directions. Look, this stuff takes forever, and this will
  have to do until the later. Sorry.
* XMV and other animated format support. WMV is supported for now, though.
* Smarter relative paths. For now, we must assume any relative path is a CD/DVD. There
  is still work to be done to examine symbolic links so the menu system knows "where" it 
  actually  is being run from.
* More eye-candy. 
  - Animated menus (M$ Dash style or a rotating screenshot cube, for example)
  - Soundtrack-aware visuals in a screensaver
* Support for all video modes (HDTV, PAL).
* Full support for external fonts.


===================================================================
Other ideas:
===================================================================

* A PC-side app to handhold through the process of making and verifying a menu.



===================================================================
Configuring MXM:
===================================================================
Most users only need to modify the Menu Item entries and a couple of 
"Main" items (DiscTitle and DiscSubTitle). Everything else can be left
alone or modified using the "skin" feature. They are only included for
backwards compatibility now.

Items marked with "*" are now better handled by the skin configuration
files.

Please refer to the skin configuration files for more information.


-------------------
Menu items:	
-------------------

Each menu item will be listed in its own section, using "Item_x" as the name.
It will read each item in order, starting with Item_1, until it fails to find 
the "next" one.... See the sample INI file for a detailed example.


Example:

[Item_1]
Title=ToeJam and Earl III
Description=Platforming classic returns!
Media=TOEJAM3.png
Dir=TOEJAM


Title=<title string>
  The title that's displayed in the menu selection

Description=<text to be displayed at the bottom of the selection menu>
  The text displayed at teh bottom of the menu selection box

Media=<filename (may include absolute or relative path) of image>
  The bitmap (BMP,TGA,PNG,JPG) used to display a screenshot or title screen

Dir=<Relative or absolute path to program>
  The directory the exeutable resides in

Exe=<executable filename>
  The executable filename, defaults to default.xbe





Main options:
DiscTitle=<Title String Here>
  The title displayed in the title screen

DiscSubtitle=<Subtitle String Here>
  Text displayed below title in title screen

*TitleScreen=<Filepath of title background bitmap>
  Background used for title screen

*MenuBack=<Filepath of menu background bitmap>
  Background for menu screen

*SaverLogo=<Filepath of SaverLogo bitmap>
  Logo used for screen saver (Solid black is transparent)

*WaitScreen=<Filepath of Wait screen background bitmap>
  Displayed when program is launched.

Theme=<Theme ID>
  Theme ID, currently unsupported

*TitleDelay=<Delay in seconds>
  Delay, in seconds, for the display of the title screen on startup. (Default 20sec)
  Hitting a button will bypass the title screen.

*SaverDelay=<Delay in seconds>
  Delay before launching the screen saver from the menu screen. 
  (Default 300sec, or 5 min)

*TitleColor=<32-bit color value, in decimal or hex>
*SubTitleColor=<32-bit color value, in decimal or hex>
  Colors used in display of title

*ShadowTitle=<on/true/1/yes or off/false/0/no>
*ShadowSubTitle=<on/true/1/yes or off/false/0/no>
  Display shadows

MXMPath=<Absolute path>
  Defaults to D:\, this represents the path the menu is being run from.
  Used to launch apps run from relative paths. This is only useful when running 
  the app from the hard drive, otherwise, just leave it off.


[Main]
DiscTitle=MediaX Menu
DiscSubtitle=
TitleScreen=
MenuBack=
SaverLogo=
WaitScreen=
Style=-1
TitleDelay=20
SaverDelay=300
TitleColor=0xffffffff
SubTitleColor=0xffffffff
ShadowTitle=on
ShadowSubTitle=on
MXMPath=D:\

ScreenShot Options:

*Top=<pixel row>
*Left=<pixel column>
*Width=<Pixel width>
*Height=<Pixel Height>
  Defines the location of the screenshot on the menu screen

Example:

[ScreenShot]
Top=120
Left=334
Width=193
Height=260


Menu section options:

*Top=<pixel row>
*Left=<Pixel column>
  Location of upper left of selection menu
*Width=<pixel width>
*Height=<pixel height>
  Size of the menu item box
*Items=<number of display items>
  Number of selection items that may be displayed in the menu box. This
  does not limit the number of menu items, only the number of items 
  that show in the box at any given time.
*MenuBorderColor=<32-bit color value, in decimal or hex>
*MenuBackColor=<32-bit color value, in decimal or hex>
*SelItemColor=<32-bit color value, in decimal or hex>
*ItemColor=<32-bit color value, in decimal or hex>
*DescrColor=<32-bit color value, in decimal or hex>
  Colors used in menu elements
*DrawDescription=<on/true/1/yes or off/false/0/no>
  This could also be the done by using "DescrColor=0"

*ShadowSelItem=<on/true/1/yes or off/false/0/no>
*ShadowItem=<on/true/1/yes or off/false/0/no>
*ShadowDescr=<on/true/1/yes or off/false/0/no>
AllowSaverMusic=<on/true/1/yes or off/false/0/no>
AllowSaverSound=<on/true/1/yes or off/false/0/no>
  These are pretty much self-explanatory

*SndUp=<file path>
*SndDn=<file path>
*SndLaunch=<file path>
  Use these to choose differrent sound files


Example:

[Menu]
Top=100
Left=63
Width=230
Height=200
Items=7
MenuBorderColor=0xa04444ff
MenuBackColor=0x80000000
SelItemColor=0xffffffff
ItemColor=0xa0808080
DescrColor=0xffffffff
ShadowSelItem=on
ShadowItem=on
ShadowDescr=on
AllowSaverMusic=on
AllowSaverSound=on
SndUp=
SndDn=
SndLaunch=

Descr section options:

*Top=<pixel row>
*Left=<Pixel column>
  Location of upper left of description "box"
*Width=<pixel width>
*Height=<pixel height>
  Size of the description "box"
  NOTE: these default to -1, which means it will automatically be positioned
  under the menu box.

*SmoothScroll=<on/true/1/yes or off/false/0/no>
  Enables the smooth scrolling of this item. Defaults to "on"


[Descr]
Top=-1
Height=-1
Left=-1
Width=-1
SmoothScroll=on





Adding music tracks to the menu system

You have several basic options:
1. Playing a specific file
2. Playing a directory of music
3. Playing the Xbox's own soundtrack

You should always have something to play.

Options under [Music]:

UseMusic=<on/off>
  If on (Default), music will play, if off, no music will be played.

Background=<filename>
  This option allows you to place a single file into the "local" soundtrack. Use this
  to select a single file to play during the menu operation.

Directory=<directory>
  This option will cause the menu system to read an entire directory and add it to the 
  "local" soundtrack.

Global=<on/off>
  This option, when activated (default) will play any tracks contained on the Xbox's 
  regular soundtracks.

Random=<on/off>
  Default is on. This randomizes the order used to play the soundtrack files. If off,
  it will play the local soundtrack (in order) followed by the Xbox soundtracks (if 
  Global is on, of course)


[Music]
UseMusic=true
Background=MyTrack.wma
Directory=MUSIC
Global=true
Random=off




Note to developers:

Sorry this is in such a messy state.

I'd like to acknowledge CodeProject as the source of the CStdString class.
I've discovered that it really helps with the Xbox APIs, particularly with 
conversion, but it's a bit kludgy. Best to use CStdString natively (compiles 
as 8-bit ASCII strings) and whenever you need wchar_t types, simply assign 
to a temporary CStdStringW object and pass out "wsTemp.c_str()" for the 
desired wchar format. You could even use:

    CStdString sThis String(_T("test"));

	SomeFunctionW( CStdStringW(sThis).c_str() );

to pass in the value.

The INI classes were built specifically with the Xbox in mind, They utilize
STL templates for mapping the parameters and CStdString as the basis for
the strings. Feel free to port this to your own applications. I intended 
this implementation to support other formats as well, on multiple platforms,
such as XML and registry configurations on desktop systems or handhelds.
Support may be added for more data types, as well.

The application is laid out with the idea of operating the applications
in different states. Each state has it's own initialization, activation, 
movement and rendering functions. This makes it easier to bounce between 
the different modes. This is in it's second incarnation, and I've got some 
ideas to improve it further. I plan on integrating the music manager further
as well as more utility functions.

Did I mention it's rather messy right now? Ugh. I'm working on cleaning it up.

The music manager required quite a bit of work to make it more robust. Please 
keep in mind I'm not working with a debug console, so when something breaks, 
the system just doesn't work at all.... MusicManager was a big headache. I plan
enhancing the current classes with more dynamic support in the future, but for now,
it's pretty complete. Callbacks into the Application class (or access to buffers 
for the app) would be nice, particularly for the visualization stuff.


"xntdll.h" The magic NTDLL routines are generally the realm of device driver 
programmers. There's a lot of cool stuff in here. As I said online, I think 
new BIOSes could theoretically support LAN drives through enhancing the driver 
support in the BIOS. This file will hopefully grow with other functions, as well.

CStdString GetRealCDROMPath( void ): :::sigh::: This should have worked, but
it's not at the moment. If anybody can figure this one out, I'd greatly appreciate
it. I'd prefer not to have to kludge up some detect based on writing to D:\ to see
if I'm on the hard drive or not - and it makes it absolutely impossible to see if
I'm running from a subdirectory of the hard drive. This routine was supposed to
unravel the symbolic links that convert the menu program's directory to be seen
as "D:\" instead of what it really is. Microsoft has even been so kind as to 
change the parameters used by NtOpenSymbolicLinkObject() call in the Xbox.

Video support: I'm probably missing something simple, something I'll see a half hour
after I send this whole thing out.... but it's not working at the moment. Everything 
is in place.... it's just broken as it sits. Dunno why at the moment. It should load
up the video info initially, then when "getting" the texture, load up the next frame, 
and send the texture from the "current" frame. Seems pretty simple. Once it's working,
any video should be able to be used where a bitmap is.

Modularizing the themes: I'd like to look at doing sections for this, but even better if 
there is a way to do it like a DLL. Again, I don't know if this will be possible, given
the way the XBEs are loaded, but I get the impression the dashboard uses standard XBEs in
EXACTLY this fashion, when they are renamed .xip's. I suspect there is a kernel function
to load these by section to run. Anybody look at this?


Thoughts on initialization:
  Currently, MXM is using the XBApplication helper class. This will soon be modified to allow 
different display standards. Because the previous application may have left a persistent display
in a different resolution from what we are running, we need to save off the persistent display
immediately after running to a texture, so we can use it.
  A flag, "m_bAllowAppRender" will be set to false initially, while a seperate thread runs to 
display an init "loading" screen with throbbing logo. Since the D3D presentation parameters are 
initialized in the app constructor, but not used until the "Create()" has been called, we
can modify these parameters in our "local" MXMApp object's constructor before the Create() is 
called.

XBApp()
MXMApp()
XBApp->Create()
 MXMApp->Initialize()  ---> Grab PersistImage, Load Init Screen data, spin thread
  States->Initialize()
XBApp->Run()
 MXMApp->FrameMove()
  States->FrameMove()
 MXMApp->Render()
  States->Render()

Thread will slowly blend the PersistImage out and the loadscreen render in with throbbing "Initializing"