SpriteFont


The right click of the Content project.
"Sprite Font" is added from a template.
As an example it named "SpriteFont1.spritefont".
Please set up the font of liking(.spritefont file is an easy XML format).

And coding.
// Game1.cs

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace Sample
{
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;

        SpriteBatch spriteBatch;
        SpriteFont spriteFont;

        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = Content.Load<SpriteFont>("SpriteFont1");
        }

        protected override void UnloadContent()
        {
        }

        protected override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();
            spriteBatch.DrawString(spriteFont, "Hello, XNA world!", new Vector2(0, 0), Color.White);
            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}

4xMSAA(Multi Sampling Anti Aliasing)


Let's use multisample anti-aliasing(MSAA).

The code hooked in a PreparingDeviceSetting event is added to the constructor of a Game1 class.
    graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(GraphicsPreparingDeviceSettings);
And the following codes are added.
void GraphicsPreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
{
    PresentationParameters pp = e.GraphicsDeviceInformation.PresentationParameters;
#if XBOX
    pp.MultiSampleQuality = 1;
    pp.MultiSampleType = MultiSampleType.FourSamples;
    return;
#endif
    GraphicsAdapter adapter = e.GraphicsDeviceInformation.Adapter;
    SurfaceFormat format = adapter.CurrentDisplayMode.Format;

    int quality = 0;
    if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.FourSamples, out quality))
    {
        pp.MultiSampleQuality = 0;
        pp.MultiSampleType = MultiSampleType.FourSamples;
    }
    else if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format, false, MultiSampleType.TwoSamples, out quality))
    {
        pp.MultiSampleQuality = 0;
        pp.MultiSampleType = MultiSampleType.TwoSamples;
    }
}
Reference
Higeneko diary

Multi-core in Xbox 360


Xbox 360 has 3 core composition which can use 6 hardware threads (HWT).
The number is shaken at HWT.

Core HWT Use
0 0 Use is impossible. System notice, Transformer port, Service.
0 1 Use is possible. Game main thread, GSE host, .NetCF.
1 2 Use is impossible. Asynchronous Xbox 360 content operation.
1 3 Use is possible. Xbox 360 guide, Dashboard.
2 4 Use is possible. Xbox Live market place download.
2 5 Use is possible. Xbox 360 guide, Dashboard.

Thread.SetProcessorAffinity method is used for assignment of HWT.
However, since only assignment of the thread under execution can do this method now, it is necessary to specify it as the beginning of the entry point of a thread.
The technique of the multithread of C#/.NET can be used as it is.

Reference
Higeneko diary

Inline method by XNA on Xbox 360


The inline method which mitigates the overhead of a call of a method.
JIT forms into an inline what fulfills the following conditions.
  • The IL code size is 16 bytes or less.
  • The branch command is not used (if sentence etc.).
  • The local variable is not used.
  • Exception handling has not been carried out (try, catch, etc.).
  • float is not used as the argument or return value of a method (probably by the Xbox 360, not applied).
  • When two or more arguments are in a method, it uses for the turn declared.
However, a virtual function is not formed into an inline.

Reference
Higeneko diary

TCR(Technical Certification Requirements)

  • If connection of a controller goes out, the message which changes a game into a pause state and demands re-connection of a controller from a user will be displayed.
  • The same screen is not displayed continuously 5 seconds or more.
  • When the state where a user cannot operate it continues 15 seconds or more, the work in which a user is not bored is carried out.
  • A message is displayed in safe area.
  • Antialiasing is used.
Reference
Hinikeni XNA