Other Stuff‎ > ‎

Custom Boot Intro for Xbox (and other consoles)



I created a custom boot intro for my xbox arcade cabinet to replace the default Microsoft flubber animation.  
I think this makes for a more authentic arcade experience and with a little effort the intro can be customised to match the theme of the arcade cabinet.

My custom intro is generated by a circuit which runs 15 seconds of video and audio.  The video and audio signal from the circuit will temporarily override the signal generated by the xbox for the duration of the boot.  The duration of the intro and the content is controlled by custom programming and can be configured.  

The video below shows an example of the boot intro compared to the default Microsoft flubber.  
My custom intro shows a CoinOPS logo immediately when the machine is powered on.  A progress bar works its way across the screen and sampled sound which speaks "Welcome to CoinOPS".



Development was done using Arduino Pro Mini, a TellyMate Tiny and 5V relays.
It's quite a simple circuit to build.

Here's a photo of my breadboard circuit with basic annotation. 



Arduino
The Arduino Pro Mini controls the production of video and audio signals and controls xbox audio and video outputs via the connected relays.
Serial commands are sent to the connected TellyMate Tiny circuit. 
I have used an Arduino Pro Mini with ATMEGA168 microcontroller running at 16mhz and 5V power.
Source code is included below.

Relays
Relays control the switching on and off of the xbox  video and audio signals.  
You really need a 3 channel relay,  1 video line and 2 audio lines for stereo.  In my breadboard circuit,  I have used a 2 channel relay (with 1 audio line) - I didn't have a 3 way relay handy!
You should look for relays similar to these.   5V input on each channel controls a switch.

Video
TellyMate is a serial to video converter. The TellyMate receives serial data from the arduino (TX/RX pins) and generates composite video output.
I reprogrammed the default TellyMate font bank via an Arduino sketch. The characters in the fontbank combine as sprites to produce a graphic on screen. 
TellyMate caters for screen output of 38 chars wide x 25 chars high
The TellyMate characters are 8px wide x 9px high so this works out at max resolution of 304x225 pixels.
There are 256 fonts in a TellyMate fontbank
I have developed a program (in Python) to generate the font data based on an input image.  I also created a simple command line version of this program.
Check out the program source for more information on how the images are converted to TellyMate format.

Audio
The audio is sampled as 8bit PCM and is included in the Arduino source and loaded in firmware.
Sound output is sent to AVR pin 11.  It is a short sample.  
There is not much room on an ATMEGA168 for sound!
I adapted the PCMAudio source found in the Arduino library
A good reference to creating sound data can be found at: http://avrpcm.blogspot.co.uk/2010/11/playing-8-bit-pcm-using-any-avr.html

Image to TellyMate Source Code (Python 2.6)

# img2tm: Image to TellyMate Font generator
# by Degenatrons - https://sites.google.com/site/degenatrons/
# v1.0 24/07/2012
#------------------------------------------------------------------------------
# Generates font data based on an image file.  This tab-delimited data can be 
# copied into the Batsocks spreadsheet (column E) to generate the font hex.
# You need to choose which characters to overwrite (recommend avoid first 32).
# http://www.batsocks.co.uk/products/Other/TellyMate_UserGuide_Fontbanks.htm
#
# The characters combine in TellyMate as sprites to produce a screen image.
# This should work with all popular image formats.
#
# Image should be sized in multiples of 8 pixels wide and 9 pixels high or it 
# will be cropped.
# RGB(0,0,0) pixels become the black background, any other colour becomes white
#------------------------------------------------------------------------------
# Inputs:
#   <image> - Path to a source image file
# Outputs:
#   TMdata.txt - tab delimeted font data
#   TMinfo.txt - useful information about the output data
#------------------------------------------------------------------------------
# Notes:
# TellyMate screen is 38 chars wide x 25 chars high
# TellyMate characters are 8px wide x 9px high
# There are 256 fonts in a TellyMate fontbank
# Max screen res is 304x225
# Most TellyMates have only fontbank-0 available
# Fontbank-0 is based on codepage 437.
# You can safely redefine at least half the font (127 to 256) if you
#   want to retain all common text characters.
# You can redefine all chars in the font but first 32 are control chars so best
#   leave them alone to avoid unpredictable results
#------------------------------------------------------------------------------
import sys
import os
import Image
from ImageColor import getrgb

try:
  source_image = sys.argv[1]
  if not os.path.exists(source_image):
    print "Source image was not found"
    sys.exit()
except IndexError:
  print "An image file must be specified"
  sys.exit()

#read properties from image
try:
  im = Image.open(source_image)
  im_width = im.size[0]
  im_height = im.size[1]
  im_format = im.format    
except IOError:
  print "Error opening file"
  sys.exit()  

#reduce width and height if necessary to fit in 8x9 blocks
if im_width % 8 != 0: 
  im_width = ( im_width / 8 ) * 8
if im_height % 9 != 0: 
  im_height = ( im_height / 9 ) * 9
if im_width == 0 or im_height == 0:
  print "Image width or height is smaller than 1 block"
  sys.exit()
  
#calc tellymate size
tm_cols = (im_width / 8) + (im_width % 8)
tm_rows = (im_height / 9) + (im_height % 9)

im = im.convert("RGB")
data = list(im.getdata())
 
#build a monochrome array, 1 for white, 0 for black, with same structure as source image
index = 0
lines = []
  
for y in range(0, im.size[1]):
  line = ""
  for x in range(0, im.size[0]):
    if data[index][0] + data[index][1] + data[index][2] <> 0:
      line += "1"  #Pixel is not black so make it white
    else:
      line += "0"  #Pixel is black
    index += 1
  lines.append(line)
  
#sort the data into fonts
fonts = []
for row in range(tm_rows):
  y = row * 9
  for col in range(tm_cols):    
    x = col * 8  
    for char in range(9):
      fonts.append(lines[y+char][x:x+8])  

try:
  #output delimited list which can be copied into font column of batsocks sheet  
  f1 = open("TMdata.txt", "w")
  for line in fonts:  
    f1.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (tuple(list(line))))
  f1.close()
  print "TMdata.txt created"

  #output some useful information
  f2 = open("TMinfo.txt", "w")
  f2.write("""About output.txt:
  
  Image Info               
    * Image Width:      %s  
    * Image Height:     %s  
    * Image Format:     %s  
                            
  TellyMate Character Info
    * Columns:          %s  
    * Rows:             %s  
    * Total Characters: %s  
  """ % (im_width, im_height, im_format, tm_cols, tm_rows, tm_cols * tm_rows))
  f2.close()
  print "TMinfo.txt created"
except:
  print "Problem saving output files.  Check that files are not open"
  sys.exit()


Arduino Source Code

/* 
Boot Intro for Arcades by Degenatrons
https://sites.google.com/site/degenatrons/

This intro shows a CoinOPS logo, progress bar and sampled sound: "Welcome to CoinOPS".
It runs for about 15 seconds to avoid the default Xbox "flubber" animation.  I did this
to provide a better arcade experience. The intro starts immediately.

Development was done using Arduino Pro Mini, TellyMate Tiny and a 5V relays
It's quite a simple circuit to build.

VIDEO
-----
The video capability is provided by a TellyMate Tiny PCB
http://www.batsocks.co.uk/products/Other/TellyMate%20Tiny.htm
This TellyMate receives serial data from the arduino (TX/RX pins) and it generates 
composite video output.
I reprogrammed the default TellyMate font bank (via a seperate sketch). The characters
combine as sprites to produce a graphic on screen. 
I have developed another program to generate the font data based on an input image.

AUDIO
-----
The audio is sampled as 8bit PCM and the sound data is included in this sketch.
Sound output is sent to pin 11.  It is a short sample.  There is not much room on an 
ATMEGA168 for sound!
PCMAudio adapted from source found in the Arduino Library at:
http://www.arduino.cc/playground/Code/PCMAudio
A good reference to creating sound data can be found at:
http://avrpcm.blogspot.co.uk/2010/11/playing-8-bit-pcm-using-any-avr.html

SWITCHES
--------
Some pins are connected to 5V relays to control output of xbox video and 
audio.
This switching is necessary because it is not possible to combine video signals over 
one composite video line.
*/

//libraries
#include <stdint.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>

//defines for sound
#define SAMPLE_RATE 7000 

//defines for video/telly mate
#define FONT_START 64    //Position of first redefined character within font
#define CHAR_COUNT 192   //Number of chars used to constuct image
#define COLUMN_COUNT 32  //Width of image in columns (of characters)
#define BOOT_DELAY 15000 //15 seconds
#define ROW_POS 8        //Image top/left start row
#define COL_POS 3        //Image top/left start column
#define ESCAPE '\x1B'    //TellyMate escape sequence
#define BAUD 57600       //Set communication baud rate for TellyMate

//define input/output pins
int switchVideoPin = 8;  //Control switch to external video (via relay)
int switchAudioPin = 9;  //Control switch to external audio (via relay) 
int switchTMatePin = 10; //Control power to the TellyMate circuit
int speakerPin = 11;     //Audio output from the Arduino 
int ledPin = 13;         //LED output from the Arduino

//sound data as 8 bit PCM
volatile uint16_t sample;
byte lastSample;
const int sounddata_length=11129;
const unsigned char sounddata_data[] PROGMEM = {
117,43,0,0,128,127,128,127,127,127,127,128,127,126,127,126,126,127,126,125,125,126,125,126,127,126,127,126,127,128,127,128,128,127,128,129,128,129,129,128,129,128,128,129,128,127,128,127,128,127,126,127,126,125,126,124,125,124,123,124,123,124,123,124,125,125,126,127,128,129,129,130,131,132,131,132,133,132,133,132,131,131,132,131,130,130,129,129,127,126,125,123,122,120,118,117,115,114,113,112,
112,113,115,119,122,127,132,137,142,146,148,149,148,146,143,138,135,133,131,130,131,130,129,127,125,123,121,120,119,118,116,113,110,108,106,105,106,108,112,117,125,131,138,144,148,150,149,146,141,135,130,126,124,123,126,128,129,131,131,132,133,134,135,136,137,136,135,132,129,125,120,117,113,109,108,105,104,105,106,109,113,119,124,130,135,139,142,143,143,142,140,136,135,133,132,132,131,132,131,132,
132,133,134,135,136,135,133,130,127,123,119,115,111,108,104,102,101,102,104,108,115,120,127,134,139,143,145,145,143,140,137,134,133,132,133,132,132,131,131,132,134,136,138,139,139,137,134,130,126,122,119,115,111,108,104,102,100,100,102,105,110,118,125,132,139,143,146,146,145,142,139,135,133,132,131,132,131,132,133,134,137,140,142,143,141,139,134,129,124,120,116,111,108,104,102,99,97,96,99,103,
110,119,128,137,144,148,148,148,145,141,138,134,132,130,129,129,130,132,136,140,144,147,149,148,143,137,130,124,118,114,109,104,100,97,93,90,90,93,99,110,122,134,144,150,151,151,149,146,144,141,137,132,126,121,118,120,127,138,150,159,164,162,155,144,132,124,119,116,111,104,94,86,81,79,81,88,98,110,123,135,145,151,153,153,152,150,147,143,136,129,121,115,114,119,127,141,154,164,170,170,
164,154,143,130,118,107,98,91,85,80,76,76,77,82,93,111,131,150,161,161,156,147,141,140,141,141,135,125,115,110,115,128,143,159,170,174,173,168,160,151,138,123,108,95,86,81,78,76,75,74,74,82,101,127,154,169,169,158,144,135,135,140,139,131,117,107,110,123,142,156,163,166,169,173,174,168,152,133,117,106,101,98,91,80,72,69,72,76,78,91,113,144,167,174,165,147,136,133,138,136,
124,112,106,117,135,151,158,160,164,173,180,175,160,138,124,118,115,109,97,87,80,80,81,77,68,64,85,122,159,174,164,149,141,144,143,135,118,106,110,123,137,141,143,151,168,184,182,168,149,142,140,138,126,110,101,98,99,90,79,68,66,68,72,94,126,161,175,168,155,140,135,126,119,111,110,121,132,144,148,153,160,171,175,168,157,145,143,141,136,124,115,110,102,94,78,71,66,63,62,71,
111,153,180,175,158,145,134,123,107,106,114,129,138,141,149,156,162,158,158,158,158,154,147,147,143,141,127,116,106,96,84,69,64,62,65,63,90,139,176,185,162,145,131,118,100,97,116,136,150,146,151,157,156,147,140,151,160,162,151,151,155,153,136,112,105,96,86,67,59,66,72,72,80,128,172,187,162,136,130,117,102,94,120,148,158,149,145,153,148,136,131,150,168,168,157,155,161,153,135,112,
105,96,85,71,65,73,74,71,71,116,167,182,162,136,133,120,101,92,121,154,159,149,144,153,145,126,120,146,174,173,162,160,166,153,128,108,106,103,87,73,69,75,78,72,72,116,164,178,157,135,132,120,100,97,128,158,159,143,140,149,140,123,124,152,175,172,161,163,165,147,124,109,105,99,85,77,75,76,76,67,76,124,169,178,154,135,128,115,95,102,139,164,161,144,141,143,131,117,129,163,
181,174,161,161,155,134,114,105,107,97,83,77,77,80,73,65,91,146,179,170,142,131,124,106,94,116,154,167,156,141,142,138,122,118,141,173,179,166,155,151,139,120,100,100,112,107,96,86,89,87,72,79,121,167,174,152,136,132,120,100,103,132,157,158,149,148,151,141,125,124,140,153,149,144,140,135,120,99,82,76,72,81,120,156,160,134,114,112,108,104,108,133,154,156,148,143,137,118,103,107,
130,149,158,163,165,159,140,123,118,124,130,133,129,123,115,101,77,63,57,75,134,185,192,162,128,110,93,85,95,130,160,167,157,146,134,115,100,103,125,149,162,162,161,157,143,124,115,123,133,136,128,119,112,102,81,64,55,75,137,188,193,158,125,107,94,87,98,132,161,168,156,143,131,115,102,103,127,152,163,161,157,154,144,126,117,122,132,136,128,116,110,99,80,64,53,81,146,194,193,151,
118,103,96,92,102,133,163,171,156,139,125,114,106,108,127,151,164,162,156,150,142,129,118,120,130,135,128,114,104,92,79,61,56,101,168,205,182,133,104,97,101,102,113,140,167,172,152,126,113,113,117,124,135,150,162,161,151,139,131,128,126,124,122,117,110,104,93,82,69,71,110,165,193,174,130,100,96,108,116,121,132,150,163,158,135,112,106,118,135,147,154,157,157,149,135,124,123,130,136,131,
119,104,95,92,91,86,78,86,122,168,190,170,128,95,91,110,127,130,127,132,148,159,151,126,106,110,132,158,167,158,144,135,135,134,131,128,127,127,121,109,95,88,89,93,91,91,113,150,177,173,142,106,93,105,126,137,133,130,136,149,152,140,121,114,129,152,164,156,138,129,133,141,142,132,120,113,111,109,102,93,87,86,88,101,126,153,167,160,137,114,104,111,124,133,136,135,137,141,144,140,
133,130,136,145,150,146,138,134,135,139,138,130,119,108,103,103,102,98,93,86,88,107,136,161,165,149,125,111,113,123,134,135,129,127,133,143,149,146,139,134,136,141,144,143,137,133,133,135,133,125,112,103,99,101,101,98,89,86,99,126,154,166,156,134,116,113,123,135,138,131,125,126,137,148,152,147,138,134,136,140,142,138,132,128,127,128,126,118,109,102,99,99,97,92,90,101,124,146,158,154,
138,124,120,127,136,138,133,125,124,132,144,151,151,144,137,135,137,139,136,131,123,120,120,121,120,115,108,102,99,98,96,99,109,123,137,146,145,139,133,130,133,137,138,134,128,126,130,138,144,146,145,142,138,135,135,132,127,122,117,115,117,117,116,114,109,103,100,101,108,117,126,133,135,134,134,135,138,141,141,137,132,128,130,134,137,139,139,138,137,138,137,134,130,124,118,116,117,118,119,117,
114,111,110,109,112,115,120,124,126,128,130,132,135,138,140,139,137,134,132,133,133,134,134,135,134,134,134,133,132,129,125,122,121,120,121,120,119,118,117,116,117,117,118,120,121,123,124,126,128,129,131,133,135,135,134,134,133,133,132,133,132,132,131,132,131,130,128,127,125,124,125,124,123,122,121,122,121,122,123,123,122,122,122,123,125,126,127,127,128,129,130,131,132,132,131,130,131,130,131,130,
129,129,128,128,128,127,127,126,126,125,127,126,126,125,125,126,126,125,126,125,125,124,125,126,127,128,127,126,126,127,128,128,129,128,127,128,127,128,129,129,128,127,128,127,128,127,128,128,127,126,127,127,128,127,128,126,127,126,127,128,127,126,126,127,126,127,128,128,127,126,126,127,126,127,128,128,127,126,127,126,127,128,127,128,127,126,126,127,128,127,128,127,126,127,126,127,128,127,126,127,
126,127,128,127,128,126,127,126,127,127,128,127,127,126,127,128,128,127,128,127,128,127,128,127,128,127,128,128,127,128,127,128,127,126,127,126,127,128,127,126,127,126,127,126,127,126,127,126,127,126,126,127,128,126,127,128,127,128,127,127,126,127,126,127,127,128,127,127,126,127,128,127,128,127,126,126,127,128,127,128,127,126,127,126,127,128,127,127,127,127,128,127,128,127,126,127,127,128,127,128,
127,126,127,128,128,127,128,127,128,127,127,128,128,127,128,127,126,127,128,127,127,127,126,127,127,126,127,126,127,126,127,126,127,126,127,126,127,127,126,127,126,127,128,127,128,127,127,128,127,128,127,128,127,128,128,127,128,127,128,128,128,128,128,128,128,128,128,128,127,128,127,128,127,128,128,127,128,127,128,127,126,127,126,127,127,126,127,126,127,126,127,126,127,127,127,127,127,127,126,127,
126,127,126,127,126,127,126,125,126,125,130,141,143,129,113,109,121,136,140,132,121,117,122,129,133,133,129,124,122,123,127,130,132,130,124,121,123,128,132,132,129,124,121,124,127,129,129,126,124,123,125,127,129,128,126,125,127,129,129,128,126,124,125,126,128,129,130,132,135,133,128,123,121,124,127,129,128,126,125,126,128,129,129,127,126,125,126,127,128,127,128,127,126,127,127,128,127,127,125,126,
125,126,126,127,127,128,127,126,127,128,127,128,128,127,127,128,127,128,127,126,126,127,128,128,127,128,127,126,127,128,127,127,126,125,126,127,128,129,128,127,126,127,128,127,126,126,125,126,127,128,127,127,128,128,127,127,126,127,127,127,126,127,126,128,129,128,127,127,126,127,128,127,127,128,127,128,127,126,127,128,128,127,126,127,126,127,128,127,126,127,126,127,126,127,126,126,127,128,127,126,
125,126,125,126,125,124,125,126,126,127,127,128,129,128,129,130,130,131,131,132,132,133,132,132,133,132,131,130,129,128,127,126,124,122,120,117,113,110,108,107,106,103,102,105,115,132,148,156,155,149,142,139,141,146,151,153,153,153,151,147,141,134,125,117,111,103,93,83,72,63,63,78,108,140,161,166,154,136,122,116,120,128,135,141,147,153,158,158,151,137,125,121,127,139,149,152,147,139,132,127,
119,111,104,99,94,90,84,79,85,105,132,153,157,145,127,114,111,118,127,135,140,143,147,151,153,150,141,132,128,130,137,146,152,151,146,138,132,126,118,111,103,97,94,89,85,79,82,100,127,149,157,149,133,119,114,119,127,135,139,142,145,148,151,149,143,135,129,129,134,140,146,149,147,143,137,131,126,121,115,108,102,94,87,81,76,79,97,122,143,152,148,137,125,121,123,128,133,136,139,143,
147,150,151,147,141,134,132,133,136,140,143,145,143,140,137,132,125,118,110,104,98,91,85,76,74,86,108,131,144,147,140,133,130,129,131,132,132,134,136,141,146,149,149,146,142,137,136,136,135,137,139,140,140,138,136,132,127,121,115,109,102,93,85,77,74,84,102,121,132,136,136,137,138,139,138,137,136,134,135,138,140,142,144,145,144,142,141,140,139,138,138,136,134,133,132,133,130,126,122,117,
110,102,93,85,78,81,92,104,114,120,125,131,137,141,143,143,142,143,142,141,139,139,140,140,141,140,139,139,140,141,140,137,135,134,134,133,131,129,126,124,120,114,106,98,91,86,88,95,99,102,106,111,118,126,132,136,140,144,148,150,150,148,148,148,147,145,142,139,139,140,140,139,137,136,137,138,137,134,131,128,125,119,113,105,97,90,85,85,86,85,86,90,98,110,121,129,138,147,156,162,
165,164,163,162,161,156,149,143,137,134,134,132,128,126,126,129,131,130,128,127,127,124,120,114,107,99,93,89,89,88,87,89,94,103,114,123,131,139,149,157,161,162,161,160,160,158,153,145,140,137,135,135,133,129,127,130,132,133,130,129,128,128,125,119,112,105,99,93,88,88,87,87,88,94,103,113,122,130,139,148,156,160,162,161,160,161,158,153,146,140,139,138,135,131,129,128,131,133,132,130,
129,129,129,126,120,113,107,102,97,89,87,88,88,89,92,99,109,119,127,135,144,152,158,160,161,160,161,159,154,148,143,140,139,136,132,130,129,131,132,131,130,129,130,129,126,121,116,111,106,100,92,87,89,89,91,93,99,108,118,127,135,142,150,155,159,158,157,155,154,149,145,140,137,135,133,131,129,130,131,132,133,134,133,134,132,130,127,122,118,113,105,99,93,89,89,90,91,96,103,112,
121,128,137,146,152,156,157,157,156,153,148,144,140,135,131,129,127,125,125,126,128,130,131,134,136,136,137,136,134,131,127,122,116,109,103,97,92,89,90,91,94,101,109,117,125,133,142,149,153,156,157,157,155,151,146,142,138,134,131,128,126,125,126,127,128,130,132,134,135,136,135,134,132,129,125,120,114,108,103,97,93,91,92,93,98,104,111,120,127,135,144,149,153,156,157,155,152,149,145,141,
137,134,132,129,126,127,126,127,129,131,133,133,134,134,133,132,130,127,123,118,113,108,103,98,94,93,94,96,100,105,112,120,127,135,142,148,152,155,156,154,152,149,145,142,138,135,132,129,128,127,126,127,128,130,132,132,134,133,133,131,129,127,123,119,115,109,104,101,97,95,96,97,101,105,111,117,124,131,138,144,149,152,153,154,152,150,147,143,141,137,134,131,129,128,127,126,127,128,129,130,
131,131,132,131,130,127,124,121,118,114,110,106,103,101,100,100,101,105,109,113,118,125,131,137,141,145,149,150,151,150,147,146,143,140,138,135,133,130,129,128,129,129,129,128,129,130,129,130,129,128,127,125,122,119,117,114,112,109,108,106,106,106,107,109,112,116,120,125,130,134,138,141,143,145,146,145,144,143,142,139,137,135,133,132,131,130,129,128,129,128,128,129,128,127,128,128,127,126,125,123,
121,119,117,115,114,112,112,111,112,113,115,117,119,122,125,128,130,133,135,136,137,138,138,137,138,137,136,135,134,133,132,132,131,130,131,130,130,129,129,128,127,127,124,126,128,128,124,121,122,124,123,121,118,119,120,119,117,120,119,120,123,122,123,125,127,128,128,129,131,131,131,132,133,132,132,133,133,131,133,133,131,131,131,129,129,129,128,128,127,126,127,126,125,126,125,125,126,125,125,125,
125,125,125,123,125,124,125,126,126,125,126,125,126,125,126,126,127,128,128,127,127,128,127,128,128,128,129,128,129,129,128,129,128,129,129,128,129,128,128,129,128,127,128,127,127,126,127,126,127,126,126,126,127,126,127,125,126,126,127,126,127,126,127,127,126,127,126,127,128,128,127,126,126,127,128,127,127,128,128,127,128,127,127,128,127,128,127,126,126,127,128,127,128,127,128,127,128,127,128,127,
128,127,127,126,127,126,127,127,126,127,126,127,128,127,126,127,126,127,128,127,127,128,127,126,127,126,127,126,127,126,127,127,126,127,126,127,128,127,128,127,127,128,127,128,127,128,128,127,126,126,127,126,127,126,127,127,127,127,125,129,130,126,127,127,126,127,127,127,127,128,127,131,135,127,124,128,125,127,127,126,127,126,127,127,127,128,127,127,128,127,128,127,128,126,126,127,126,125,126,126,
125,127,125,126,126,126,126,126,125,127,126,127,126,127,126,127,128,127,133,143,138,126,126,124,120,128,123,122,125,126,127,125,131,129,127,131,130,128,128,130,125,126,127,125,125,126,126,126,128,128,126,126,125,127,126,127,127,127,127,128,128,126,128,128,126,128,127,127,126,127,128,125,127,128,125,126,127,127,125,127,128,125,127,129,128,127,128,129,127,128,129,127,126,128,127,125,127,127,126,126,
127,127,126,128,128,126,127,129,127,127,129,127,126,127,128,126,126,128,127,127,128,127,126,128,128,126,127,127,126,126,127,127,127,128,127,127,128,128,127,127,128,127,126,127,126,127,127,127,127,127,127,128,128,127,127,128,127,126,128,126,126,127,127,126,127,128,127,127,128,127,128,127,128,127,127,128,127,127,127,127,127,126,128,126,127,127,125,128,126,128,127,127,127,126,130,125,125,129,126,126,
128,129,125,127,130,124,128,129,125,125,128,128,125,129,128,124,127,128,125,124,130,127,124,129,128,125,126,130,127,126,129,127,126,127,130,125,127,130,125,127,128,127,127,127,128,126,128,128,126,126,129,126,125,129,126,127,128,127,126,127,129,126,127,128,126,126,127,128,125,128,128,126,126,128,128,125,129,128,125,127,128,125,126,129,126,127,127,128,126,127,130,125,127,127,128,125,127,130,125,129,
129,125,124,127,126,124,130,127,125,128,128,126,128,129,127,127,127,126,125,126,126,126,127,128,127,128,128,127,128,128,127,126,127,127,126,126,127,126,128,128,126,128,128,127,127,128,128,125,127,128,125,125,129,127,125,130,127,126,128,127,126,127,127,125,126,127,125,127,127,128,128,128,128,127,128,128,127,128,127,127,128,127,126,127,128,127,127,127,125,126,128,125,127,128,126,125,129,127,124,128,
127,124,126,129,126,125,130,127,124,128,129,124,127,130,126,128,131,126,125,129,128,125,127,128,126,128,130,127,127,128,128,126,128,128,125,127,129,125,125,127,125,124,129,128,124,127,128,125,126,129,126,126,129,128,126,128,129,126,128,129,127,127,129,128,127,129,128,127,128,128,127,126,126,127,126,126,125,125,126,125,126,125,124,125,125,126,125,126,127,126,127,127,127,128,128,129,128,129,129,130,
132,131,133,132,133,132,132,132,130,129,129,128,127,126,125,123,121,120,118,117,115,114,113,114,115,117,118,120,124,125,129,132,135,137,139,140,140,141,142,141,140,141,140,139,139,137,135,132,130,127,123,121,117,112,108,103,101,98,97,101,105,109,117,124,131,135,140,144,144,145,145,141,139,138,136,134,135,138,139,140,143,144,143,142,137,130,128,122,113,109,104,98,94,93,91,96,105,111,118,128,
134,137,141,145,144,142,143,138,135,134,132,129,131,135,136,140,146,146,146,147,144,138,133,126,120,113,108,103,96,94,90,88,96,105,111,121,131,137,141,146,148,146,144,141,136,132,130,127,125,127,129,134,140,144,148,149,150,146,141,138,130,122,118,112,104,102,97,92,90,88,96,105,111,123,131,138,143,147,150,146,146,143,136,131,128,124,123,125,129,132,139,146,147,151,151,147,143,139,133,123,
118,115,105,101,100,92,91,87,92,104,109,119,130,138,142,147,151,148,146,145,138,132,129,125,121,123,126,129,135,142,147,149,153,150,145,142,137,129,121,118,111,104,102,97,93,91,85,94,107,110,121,134,139,142,149,152,146,145,144,134,128,127,123,120,123,127,129,136,144,147,149,153,151,144,142,137,129,123,118,113,108,104,101,95,92,88,87,102,109,114,129,137,141,146,153,151,145,146,139,129,
127,124,118,118,125,126,132,141,145,149,152,152,147,143,141,133,128,124,118,113,111,108,102,98,97,90,86,101,109,109,127,136,138,144,152,152,144,147,142,129,127,125,118,116,123,126,128,138,143,146,151,153,149,145,143,135,129,128,122,116,116,114,108,104,102,96,89,88,102,106,110,127,134,138,144,152,151,145,148,141,130,128,124,118,117,123,125,129,138,144,146,151,152,148,144,141,135,130,128,123,
118,118,116,110,107,104,97,91,89,95,105,107,119,131,136,143,149,153,149,147,145,135,128,125,120,116,118,124,127,134,142,145,149,152,149,145,142,137,132,128,127,124,120,120,119,113,110,106,98,94,88,90,104,105,114,129,136,143,147,156,152,146,147,137,128,124,121,115,116,123,126,132,140,146,148,151,151,146,141,138,132,127,126,126,122,122,122,119,114,110,105,96,91,85,94,104,105,120,133,139,
145,152,157,150,147,144,133,125,122,119,113,118,125,127,134,143,147,148,150,149,143,140,136,130,127,127,127,123,123,123,120,115,110,105,96,91,86,93,104,106,119,132,140,146,151,156,151,147,143,134,125,121,119,115,116,124,129,134,141,147,147,149,149,144,138,135,131,128,128,129,128,125,126,124,120,114,108,101,93,87,84,95,104,109,123,137,144,148,154,157,148,145,141,130,121,119,117,114,117,126,
131,136,143,148,147,148,147,142,137,133,131,127,128,130,128,126,126,125,120,112,107,101,92,87,85,96,105,110,125,138,145,148,154,156,148,144,139,129,120,117,116,114,118,125,131,137,143,148,148,147,146,142,137,132,131,128,128,130,131,129,129,127,123,117,110,102,96,90,85,88,101,108,116,131,142,148,150,155,154,144,140,134,125,117,116,116,115,120,128,135,139,145,149,147,146,143,140,134,131,130,
128,128,130,132,132,129,130,125,118,111,104,97,90,86,86,96,106,114,127,140,147,150,153,154,147,140,134,127,120,115,116,117,119,125,134,139,142,146,148,145,142,139,136,131,129,129,130,130,132,133,133,131,128,123,116,108,101,94,89,86,88,98,110,119,130,141,150,151,151,151,145,138,130,125,120,115,115,118,123,128,135,141,144,145,145,143,140,136,134,130,129,128,130,132,134,135,134,133,129,123,
117,111,103,97,92,89,90,94,107,117,127,136,145,151,149,149,147,141,133,126,124,119,116,118,123,127,132,137,142,144,143,142,140,137,133,130,129,129,130,132,135,137,136,135,133,129,122,116,110,105,99,94,92,92,95,104,116,125,133,140,147,149,146,144,141,135,128,124,122,120,119,122,126,131,135,138,142,142,141,138,137,135,132,130,130,131,132,134,136,137,135,133,130,126,120,113,108,104,99,96,
95,97,99,107,118,127,133,138,145,147,144,141,138,135,129,125,122,123,122,123,127,131,135,137,139,141,140,138,135,135,133,131,132,132,133,134,135,136,134,131,128,125,119,113,109,106,102,98,97,99,101,106,115,124,131,136,141,144,143,141,138,135,132,126,123,123,124,125,126,130,134,136,138,139,140,139,136,135,134,133,132,132,133,134,135,134,133,131,129,125,120,115,111,107,104,100,98,99,101,105,
113,122,129,134,139,142,144,141,138,136,133,129,125,123,124,125,126,128,133,136,138,139,139,138,138,136,134,133,132,133,132,133,134,134,132,130,128,126,121,115,111,108,105,100,98,99,101,106,113,122,130,135,139,143,143,142,139,135,132,129,125,123,123,125,127,129,132,135,138,139,138,139,138,137,135,132,132,133,132,132,133,134,134,131,128,126,121,116,112,108,105,102,98,98,101,105,111,119,128,134,
139,142,143,144,140,137,133,130,127,124,123,124,126,129,132,135,137,140,139,138,138,137,135,133,131,131,132,132,133,134,133,132,129,126,122,117,112,108,106,102,98,98,101,105,112,120,128,134,138,141,142,143,141,137,133,131,127,124,123,124,126,129,132,135,137,139,140,139,138,137,135,134,132,131,132,132,133,133,132,131,129,125,121,117,112,109,106,103,99,99,102,105,112,119,127,134,138,140,141,142,
140,138,134,130,128,125,124,125,127,129,132,135,137,139,139,138,137,136,135,133,132,131,131,132,133,133,132,131,129,126,123,119,114,110,107,104,101,100,101,104,110,117,125,131,135,138,140,141,140,138,135,131,129,127,125,124,126,128,131,134,136,138,139,138,137,136,135,134,132,131,131,132,133,132,133,132,129,128,125,121,117,113,110,107,104,102,102,104,107,113,119,127,132,136,138,139,140,139,137,133,
130,128,126,126,125,127,129,132,135,137,137,138,137,137,136,134,133,132,131,131,132,133,133,132,131,129,127,124,121,116,113,110,108,105,104,105,107,110,115,120,126,131,134,136,137,137,137,136,134,131,129,128,127,127,129,130,132,134,136,137,136,137,136,135,135,134,132,131,131,132,131,132,131,130,128,126,123,120,117,114,111,109,108,107,107,109,111,115,119,124,129,132,134,135,136,136,135,134,132,130,
129,128,127,129,130,132,133,135,136,137,137,136,135,134,133,132,131,132,131,132,131,130,129,127,126,124,121,118,115,112,110,109,108,108,110,112,115,119,124,129,132,134,135,134,135,134,133,132,130,129,128,129,129,131,132,134,135,136,135,136,135,134,133,132,131,132,132,131,132,131,130,129,128,127,125,122,119,116,113,112,111,110,110,111,112,115,118,120,124,128,130,132,133,132,131,131,132,133,132,131,
130,129,131,133,134,134,135,134,135,136,135,134,133,132,131,132,133,132,131,129,128,126,126,125,123,120,117,115,114,113,113,112,112,113,116,118,121,123,126,128,129,130,131,132,132,131,131,132,131,132,131,131,132,132,134,134,135,134,134,135,134,133,132,131,132,131,132,131,129,128,127,126,125,124,122,120,117,115,115,114,115,114,115,116,118,120,122,124,126,127,128,129,130,131,130,131,130,131,132,132,
131,132,132,133,133,134,134,135,134,134,133,133,132,131,132,131,130,130,129,128,127,126,124,123,122,120,119,116,115,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,128,129,130,131,132,133,132,133,133,134,134,133,132,132,133,132,133,133,132,131,130,131,130,129,129,128,126,125,124,123,122,121,119,118,118,119,119,120,120,121,122,121,122,123,122,122,123,124,126,127,128,129,129,130,131,132,
133,133,134,133,133,133,132,133,132,133,134,133,133,132,130,129,129,128,128,127,126,125,123,122,123,122,122,121,120,121,121,122,123,122,123,122,122,123,122,123,124,123,124,125,126,127,128,129,130,131,132,133,132,131,132,131,132,131,131,132,131,132,131,131,130,130,129,129,128,127,126,126,125,124,124,125,124,123,124,123,124,125,124,125,124,123,124,125,124,125,124,123,124,124,125,126,125,126,127,127,
128,129,130,130,129,130,130,131,130,130,129,130,129,130,129,130,129,128,129,128,127,127,128,127,126,127,126,125,126,125,126,126,125,125,126,125,126,127,126,127,126,127,126,127,126,127,126,127,126,126,127,128,127,128,127,128,127,128,127,128,127,128,128,127,128,127,128,127,128,127,126,127,126,126,127,126,127,127,126,127,127,126,127,126,127,128,127,128,127,128,127,128,128,127,126,126,127,128,127,128,
127,126,126,127,127,128,127,128,127,128,128,127,128,127,128,127,126,127,127,126,127,126,126,127,126,127,126,127,128,127,126,126,127,128,127,127,128,127,126,127,128,127,128,127,128,128,127,126,127,126,127,127,126,127,126,127,126,127,127,127,127,127,126,127,126,127,126,127,128,128,127,128,127,127,128,127,128,128,127,128,127,128,127,128,127,128,127,126,127,126,127,126,127,126,127,126,127,126,126,127,
128,127,128,127,128,127,126,127,128,127,128,127,128,127,126,127,128,128,127,126,127,127,126,127,126,127,128,127,128,128,127,128,127,126,127,126,126,127,128,128,127,126,127,126,127,127,126,127,126,127,126,127,127,128,127,128,127,128,127,128,127,128,127,126,127,126,127,128,127,128,127,126,127,127,126,127,128,128,127,126,127,126,127,128,127,128,127,126,126,127,128,127,128,128,127,126,127,127,128,127,
128,127,127,126,126,127,127,128,127,128,127,127,126,127,127,126,127,126,127,127,126,127,126,127,128,127,128,127,127,128,127,128,127,128,128,127,128,127,126,127,126,127,126,127,126,127,127,126,127,128,128,127,127,126,127,127,128,127,128,127,126,127,126,127,127,127,127,126,127,126,127,128,127,128,127,128,127,127,127,127,128,127,128,128,127,128,127,127,128,127,126,127,126,127,128,127,127,127,127,127,
127,126,127,126,127,126,127,126,127,126,127,126,127,126,127,128,127,126,126,127,128,127,127,128,127,128,127,128,127,128,128,128,127,128,127,128,127,128,127,128,127,127,128,127,127,128,127,128,127,126,127,127,126,127,126,126,127,126,127,127,127,126,127,127,128,127,127,128,127,128,127,126,127,126,127,128,127,127,127,127,128,127,126,127,128,127,128,127,127,128,127,126,126,127,127,127,128,127,128,127,
128,127,128,127,128,127,126,127,126,127,128,128,127,126,127,127,126,127,127,127,126,127,128,127,126,127,127,127,127,126,127,126,127,128,127,127,127,126,127,128,127,128,127,128,127,128,128,127,128,127,128,128,127,128,126,127,127,126,127,128,127,128,127,128,127,128,127,126,127,126,127,127,126,127,128,127,126,127,126,127,126,127,126,127,128,127,128,127,127,128,127,128,128,127,126,127,127,128,127,127,
128,127,128,127,127,127,127,127,128,126,127,127,128,127,127,126,127,128,127,128,127,126,126,127,127,126,127,126,127,128,127,126,127,127,126,127,126,127,126,127,127,127,128,127,128,127,128,127,127,128,127,128,127,128,127,128,128,128,128,128,128,128,127,128,128,127,128,127,128,127,128,128,127,128,127,128,127,126,127,126,127,126,126,127,126,127,127,126,126,127,128,127,126,126,127,128,127,126,127,126,
127,128,127,126,127,128,127,127,126,127,127,128,127,126,127,128,127,128,127,126,127,128,127,128,127,127,128,127,128,128,127,128,127,128,127,128,127,128,127,128,127,128,127,128,128,127,126,127,126,127,127,126,127,126,127,126,126,125,126,126,125,126,126,125,125,124,126,125,131,145,136,123,124,128,128,122,119,122,127,127,124,127,134,143,146,125,98,102,135,156,146,118,105,115,135,148,143,127,118,120,
121,116,118,132,142,134,118,112,124,140,142,131,119,116,121,125,127,126,127,129,127,122,119,122,127,129,129,135,144,149,143,127,110,103,110,125,137,141,134,126,123,124,129,133,132,127,121,119,121,126,129,131,129,126,124,126,128,130,129,126,124,123,124,127,129,130,129,128,127,128,129,129,128,127,126,124,124,125,126,127,127,128,129,128,127,126,127,128,127,128,128,127,126,126,127,128,128,129,128,128,
126,124,123,125,127,129,128,126,123,124,128,130,129,128,127,127,126,127,128,127,126,127,126,127,128,130,129,128,128,125,125,127,128,129,127,125,126,129,132,130,127,126,125,127,130,131,127,122,120,123,127,130,131,128,123,120,123,128,129,127,125,125,126,127,127,126,121,121,127,129,128,129,128,126,127,126,127,130,128,127,131,133,133,131,129,129,130,129,130,130,128,126,125,124,125,129,129,124,121,121,
124,129,132,128,121,119,122,127,130,127,119,117,126,134,136,134,131,126,121,123,128,127,130,132,130,129,129,132,131,127,125,122,119,125,131,131,129,128,131,131,129,129,130,125,120,118,122,124,123,127,130,129,123,122,126,123,124,126,129,134,136,138,134,128,125,123,120,121,123,125,126,127,129,127,125,127,130,133,131,129,128,127,128,124,124,130,131,130,129,128,128,129,126,124,121,121,128,133,133,127,
121,123,130,134,133,129,121,118,121,125,126,127,128,129,132,131,128,126,126,125,123,124,123,125,129,131,133,130,128,126,123,124,127,130,129,126,126,125,124,126,130,132,131,132,132,131,129,123,119,119,123,128,131,132,134,132,129,125,122,123,126,128,127,125,124,125,126,127,128,129,131,131,130,127,123,121,122,124,127,131,131,132,130,127,125,122,123,126,125,128,128,126,127,127,127,128,127,127,127,126,
126,128,129,130,129,127,125,123,125,127,129,131,132,132,130,125,122,123,125,126,128,129,128,127,125,124,125,128,130,130,127,125,124,125,126,125,125,127,129,132,132,131,128,123,122,122,125,128,129,130,128,127,127,126,127,129,129,128,126,125,125,126,127,127,126,128,129,128,129,128,127,126,124,125,125,128,130,129,128,127,126,125,125,126,126,127,127,128,127,126,126,127,128,128,129,129,128,127,126,127,
128,129,129,127,127,125,126,125,126,125,124,126,126,127,127,126,125,124,125,126,127,128,129,129,128,129,129,130,131,130,131,130,129,130,129,128,129,128,127,125,124,123,122,121,122,122,121,122,121,122,122,123,125,127,127,129,129,130,132,134,135,136,137,136,136,135,134,135,134,132,130,127,123,119,118,117,116,115,113,111,110,111,113,116,120,125,130,134,138,140,141,142,143,142,143,142,141,140,138,136,
134,132,128,124,120,117,115,112,108,102,97,94,97,104,114,126,137,143,145,143,139,137,137,139,141,142,141,140,139,139,140,141,141,139,135,128,120,113,107,103,99,95,92,90,94,104,120,136,149,154,150,142,133,127,126,131,137,142,144,142,139,140,141,144,147,146,142,134,122,112,103,97,95,93,90,86,88,99,116,136,153,160,155,143,130,121,121,130,141,149,153,150,145,140,138,139,141,142,141,136,
128,117,106,99,95,92,90,85,83,89,105,126,148,161,163,154,138,124,118,121,133,146,153,154,149,143,139,139,141,144,144,142,137,128,117,107,99,94,92,87,81,79,86,103,126,148,161,160,149,133,120,117,124,137,150,158,157,151,144,139,139,141,143,142,140,136,128,118,108,101,95,92,88,81,78,84,101,123,146,161,163,152,135,120,115,120,134,149,157,159,153,144,139,137,139,142,144,143,139,133,
124,114,105,99,94,90,86,79,79,89,108,132,153,162,159,145,127,115,115,125,140,153,158,156,149,142,139,139,140,143,144,142,138,132,123,114,107,101,97,93,87,79,77,86,106,130,153,163,160,145,127,114,114,124,140,153,157,155,148,141,138,139,142,144,144,142,137,132,126,120,112,107,103,98,92,83,75,77,90,114,140,159,164,155,137,120,112,117,130,146,155,156,151,145,140,139,141,143,144,142,
139,135,130,126,122,117,113,108,102,95,84,73,72,85,108,136,157,165,158,140,121,111,114,127,143,154,157,153,146,142,140,141,142,142,140,138,135,131,130,128,124,120,114,108,100,90,78,68,71,88,115,143,162,166,155,134,116,109,116,131,147,157,157,150,143,139,140,141,142,141,139,135,133,133,132,133,131,126,120,112,102,92,80,68,66,79,103,133,157,166,159,141,121,109,112,125,143,156,159,153,
144,139,137,139,141,141,138,134,132,133,134,136,137,135,130,121,112,102,91,81,70,67,77,99,128,153,164,159,142,122,110,111,124,142,156,159,153,143,136,136,139,142,141,137,133,131,132,135,139,140,140,135,126,118,109,100,91,82,71,67,78,101,130,154,163,156,138,119,108,113,129,147,159,159,150,138,132,133,138,142,141,137,132,130,132,137,141,144,143,138,130,122,114,107,99,89,78,68,67,82,
109,138,158,162,149,128,111,108,120,139,156,162,156,143,132,129,134,141,143,139,133,128,128,134,140,145,146,143,138,131,126,121,113,105,93,81,71,64,74,97,126,151,160,152,134,115,108,118,136,154,162,156,143,133,130,134,141,142,138,131,126,127,134,142,146,146,143,139,136,133,129,123,114,102,91,81,74,69,76,96,122,145,155,148,132,118,115,125,141,153,156,151,144,138,136,137,137,135,133,132,
133,136,139,140,141,141,140,139,136,132,128,123,115,105,95,86,80,75,70,76,99,128,151,155,142,123,114,120,135,149,153,150,147,148,149,146,135,125,125,132,143,149,146,139,134,136,142,145,143,136,130,127,128,123,110,94,84,83,86,84,73,73,94,130,157,159,139,116,112,126,144,153,148,141,144,153,155,144,125,114,123,141,153,150,137,130,134,144,149,145,137,134,137,138,133,122,106,95,92,93,
92,82,74,70,83,115,142,152,142,127,122,128,136,139,138,141,149,156,154,141,125,119,123,136,145,143,140,138,139,141,139,139,142,146,148,143,135,126,122,118,107,93,86,88,90,88,80,74,90,123,147,148,134,124,127,137,138,134,135,145,154,155,142,129,123,124,127,132,137,142,145,142,138,135,138,144,148,148,145,142,138,132,123,116,110,102,95,92,91,89,84,81,81,100,127,144,144,135,131,133,
134,130,131,141,150,153,145,137,130,125,120,121,132,143,147,142,137,138,140,140,141,145,150,150,144,137,131,125,118,111,105,99,93,90,88,86,84,83,93,119,139,142,137,134,135,133,130,132,141,147,147,143,140,136,125,116,116,126,139,143,142,143,142,139,135,138,145,151,150,147,145,139,129,120,116,113,104,94,94,96,93,87,86,90,96,115,133,140,141,138,137,133,131,133,138,142,140,142,140,134,
124,119,118,120,127,137,146,146,142,139,138,139,141,147,151,151,147,142,137,127,120,116,110,106,101,96,95,92,91,89,92,95,109,132,137,140,141,140,134,129,134,134,137,137,141,142,132,128,123,122,120,123,135,141,144,145,144,140,137,140,144,149,148,147,144,137,130,123,119,111,108,105,101,97,93,93,92,92,94,103,124,133,137,143,142,136,130,134,133,133,136,139,139,135,131,126,121,119,122,125,
131,141,145,145,143,142,140,140,145,146,147,146,143,138,131,125,118,115,111,106,103,103,100,95,97,95,95,97,110,128,131,139,144,140,136,133,134,128,131,135,135,137,133,131,125,122,123,122,126,132,140,143,145,146,141,140,141,143,144,146,145,141,139,131,126,120,117,112,109,108,102,102,97,96,97,96,99,108,126,129,136,146,138,137,134,132,129,130,135,131,136,134,130,128,123,124,121,125,127,134,
140,142,146,144,143,142,141,143,143,144,142,140,136,130,126,119,115,112,109,107,105,102,99,99,96,97,100,112,125,129,142,142,138,139,133,130,128,130,130,132,136,131,131,128,124,124,123,124,126,134,136,140,145,143,144,143,142,143,143,143,141,140,135,130,125,121,117,113,112,108,107,105,101,100,97,98,97,107,121,124,139,142,139,142,135,133,130,129,129,130,134,131,132,130,126,126,124,124,124,129,
132,135,141,141,144,145,142,144,142,142,141,140,137,133,129,123,121,117,114,113,109,109,104,103,101,97,98,98,112,120,126,142,139,142,142,134,134,128,128,128,130,131,130,132,127,127,126,124,125,125,130,131,135,138,139,144,142,145,144,143,142,140,139,136,133,128,125,121,118,116,113,111,109,107,105,102,100,98,101,109,117,125,135,138,140,141,136,136,132,130,131,130,131,131,131,129,128,128,127,128,
128,130,130,132,136,136,140,141,142,142,141,140,139,138,135,133,129,126,123,120,118,115,113,111,109,108,105,103,103,102,104,112,117,123,130,131,135,136,135,137,136,136,135,134,134,132,131,131,130,132,132,132,132,132,132,134,133,136,137,138,140,139,139,139,137,136,133,130,127,124,122,118,115,113,111,109,108,105,104,103,104,105,110,116,120,127,131,132,136,136,137,137,136,137,136,135,134,132,131,130,
131,132,132,131,132,132,133,134,135,136,138,138,139,138,138,137,135,133,131,129,125,123,119,117,114,112,111,108,107,105,105,106,107,110,114,119,123,128,131,133,134,135,136,137,137,136,136,135,133,131,132,130,132,131,131,132,132,131,133,133,134,134,136,136,137,137,136,136,135,133,131,129,126,124,121,118,116,113,110,108,107,106,106,105,105,107,109,112,116,120,124,129,134,137,140,142,143,144,143,143,
141,139,137,135,133,133,132,132,131,132,131,133,133,134,134,135,136,135,134,133,132,130,127,124,121,118,115,111,107,104,102,101,100,101,103,106,110,116,121,126,131,135,140,142,144,146,145,144,142,140,138,136,134,132,132,130,129,130,130,131,132,133,134,135,136,137,137,136,135,134,132,130,126,124,120,116,113,109,107,104,103,102,102,103,105,108,112,116,121,126,130,134,138,141,142,143,144,143,142,141,
139,137,135,134,133,133,132,133,133,132,133,133,134,135,135,135,134,133,132,131,128,126,124,120,117,114,111,108,106,105,103,104,103,104,106,108,112,116,121,126,130,135,139,142,145,147,146,146,145,142,139,137,134,133,131,131,130,131,131,132,133,134,135,136,137,138,138,137,136,134,132,129,125,121,116,110,104,98,93,89,90,90,93,98,104,112,121,131,138,145,151,155,156,156,153,149,144,139,135,131,
128,127,126,127,127,129,131,133,135,137,139,141,142,141,140,139,137,134,131,126,119,112,107,100,93,87,84,85,87,91,99,107,115,125,134,142,149,153,157,158,156,152,148,143,137,133,130,128,127,126,127,129,129,131,133,136,137,140,141,143,142,142,142,138,131,127,124,119,110,101,96,92,85,82,85,88,94,102,111,121,130,138,144,149,152,153,152,150,147,142,137,133,131,130,129,130,133,134,133,135,
135,134,134,138,143,144,145,143,139,134,127,124,116,107,104,98,92,81,77,82,88,111,135,143,141,137,133,123,121,132,142,144,144,146,141,128,120,121,122,124,132,143,148,147,145,142,137,132,137,145,148,147,144,137,129,121,118,115,106,102,103,101,92,79,84,91,105,134,151,144,126,121,120,122,129,143,152,147,136,129,127,123,120,125,132,134,136,144,150,146,138,135,136,136,140,148,153,146,133,125,
123,121,117,115,109,105,102,98,89,82,85,96,126,153,149,129,115,115,118,128,143,154,150,136,125,124,125,123,125,130,134,134,136,144,149,142,134,133,135,139,145,151,150,140,128,121,123,123,120,116,108,106,104,102,93,84,84,94,125,154,153,131,111,112,121,131,141,150,150,136,122,122,128,130,127,126,129,133,137,140,145,146,139,131,131,140,149,151,147,139,131,123,121,127,128,121,111,102,104,107,
105,94,81,81,101,140,162,149,119,104,111,125,137,146,151,144,130,119,122,130,132,127,123,125,133,139,141,143,143,137,132,132,140,150,153,145,135,129,126,126,127,128,125,115,102,100,107,111,102,86,78,89,128,161,158,127,101,104,123,139,144,145,143,135,124,119,126,134,133,125,121,127,137,144,143,138,136,136,136,137,143,148,147,140,132,129,128,129,128,125,118,108,104,110,115,110,96,84,80,95,
134,164,156,122,98,104,128,145,145,140,136,133,128,125,127,131,132,124,120,125,136,146,145,137,131,133,137,141,144,145,144,140,133,129,128,129,129,125,120,112,108,110,113,111,99,85,80,92,129,162,159,126,98,100,125,147,147,139,133,132,131,127,125,128,131,127,121,123,133,143,145,136,127,127,137,148,149,142,138,139,139,134,129,128,129,128,125,119,111,109,112,114,110,98,89,85,97,131,158,153,
124,100,104,128,147,146,136,130,131,133,131,127,126,128,127,124,125,132,142,143,135,128,130,141,147,144,139,138,141,141,135,128,125,128,130,126,119,112,110,113,113,109,99,93,90,98,125,150,152,130,107,104,122,142,145,138,131,131,134,132,126,123,126,129,127,127,129,135,139,136,131,129,137,146,146,140,136,139,143,140,130,124,126,130,129,123,114,110,112,112,108,100,95,92,96,117,144,153,137,112,
102,115,137,146,141,132,129,132,132,128,123,124,128,129,128,128,132,138,138,132,127,132,144,151,146,135,133,138,143,138,128,123,126,130,130,122,110,105,107,111,109,100,92,91,111,138,150,140,118,107,115,133,142,141,135,131,133,132,128,125,125,127,128,127,128,131,135,135,132,128,128,136,147,151,144,134,132,137,142,137,128,123,125,129,129,122,112,106,106,109,110,105,96,94,110,134,145,138,121,112,
118,131,139,138,135,133,133,131,127,125,127,129,128,127,127,131,135,136,133,129,130,138,147,149,141,133,134,139,140,134,127,125,127,128,125,117,110,107,109,111,107,101,92,97,121,143,147,131,114,110,122,136,140,138,132,132,132,130,126,125,127,129,128,127,128,133,136,135,130,127,131,141,147,146,139,134,134,138,138,132,127,125,125,126,125,118,110,107,110,114,111,101,92,97,122,144,146,130,114,113,
123,135,138,135,134,133,133,129,126,125,128,129,127,126,127,133,136,135,131,128,133,140,145,143,139,137,137,137,135,131,128,127,126,125,123,119,114,109,108,109,109,105,97,97,116,140,148,136,117,109,118,133,140,139,134,130,131,130,126,125,127,129,129,127,128,132,136,137,133,129,132,142,146,141,134,135,140,142,136,126,123,125,130,130,123,114,108,108,112,114,109,101,94,101,126,145,146,129,112,111,
123,136,140,138,132,131,129,127,126,127,129,129,127,126,128,134,137,136,133,132,138,143,141,136,135,138,141,138,131,125,124,127,130,128,122,113,108,110,113,111,104,98,96,109,131,146,142,124,112,113,125,136,140,138,132,129,128,126,126,128,130,130,128,127,129,134,137,136,134,137,140,139,134,133,139,144,142,132,124,123,128,132,129,122,116,111,110,113,115,113,106,98,97,112,136,147,137,120,110,116,
130,138,137,134,131,131,128,126,127,130,131,129,126,127,132,136,137,135,136,141,141,135,131,134,142,146,140,129,123,124,128,131,129,124,115,108,109,113,115,111,103,96,97,115,138,149,139,121,111,115,127,136,139,138,134,129,124,123,126,131,133,130,128,127,131,135,137,141,144,140,131,126,132,143,149,144,134,126,123,124,126,129,131,125,112,103,109,119,120,111,98,95,100,116,135,144,140,127,116,113,
120,131,140,142,136,129,124,124,126,129,131,131,132,131,132,136,143,146,140,130,126,132,140,143,143,139,134,127,123,121,124,131,130,122,110,107,112,116,110,99,94,97,109,128,144,147,135,119,111,115,125,136,141,142,136,129,124,121,123,127,131,134,136,139,139,138,137,136,135,134,135,138,140,140,138,135,130,126,124,124,127,127,123,115,109,110,115,114,105,98,97,103,118,133,141,139,131,123,118,119,
124,131,137,139,136,132,128,125,125,127,130,134,137,139,140,138,136,134,133,134,135,137,137,136,135,131,126,124,125,126,125,122,119,117,116,115,114,114,111,110,112,115,120,126,130,131,130,129,130,130,131,130,131,131,131,130,131,130,131,130,131,130,131,130,129,129,128,127,127,128,127,126,126,127,128,127,127,128,127,128,127,127,128,128,127,126,126,125,124,125,124,125,124,124,125,126,125,126,127,128,
128,129,128,129,128,129,128,128,127,128,127,127,126,127,126,125,126,127,126,127,126,127,128,127,128,128,127,128,127,128,127,128,128,127,128,127,126,127,126,127,127,126,127,128,127,128,127,128,127,128,128,127,128,127,128,127,128,127,127,126,127,126,127,126,127,127,126,127,126,127,127,126,127,126,127,128,127,127,128,127,126,127,127,126,127,128,127,128,127,128,127,126,127,126,127,126,127,127,126,127,
126,127,127,127,127,127,127,126,127,126,127,126,127,127,126,127,126,127,126,127,128,127,128,128,127,128,127,128,127,128,127,128,128,128,128,128,128,128,128,128,127,128,128,128,128,127,128,127,128,127,128,127,128,127,127,126,127,126,127,126,127,126,126,127,126,127,126,127,126,125,126,125,126,125,126,125,126,127,126,128,130,128,128,128,127,127,128,128,129,128,127,126,127,127,126,127,128,127,127,128,
129,128,128,127,129,127,128,127,128,127,126,126,125,126,125,125,126,125,127,127,127,127,127,127,127,127,126,127,126,126,127,126,127,126,126,126,127,127,126,127,127,127,127,127,128,127,128,127,127,128,127,128,127,128,127,127,127,128,127,128,127,127,126,127,127,127,127,126,127,127,126,127,127,127,128,127,128,127,127,128,127,126,127,126,127,127,126,127,127,126,127,128,127,127,126,127,128,127,127,128,
127,127,126,128,128,127,128,126,127,127,127,128,127,127,128,127,128,127,128,127,127,127,127,128,127,126,126,127,128,128,127,126,127,126,127,128,127,126,126,127,127,127,127,126,127,126,127,127,127,128,127,127,127,126,128,127,127,126,127,126,127,128,127,128,127,128,127,127,127,127,128,127,127,128,127,126,127,128,127,126,127,126,127,127,127,128,128,127,126,127,127,127,128,127,127,126,127,127,126,128,
127,127,126,128,127,127,127,127,128,127,126,126,127,127,128,127,127,128,127,127,127,127,127,127,127,126,126,127,128,127,127,127,126,126,127,128,127,128,127,126,126,127,128,127,126,126,127,128,127,128,127,126,128,127,127,126,127,127,128,127,127,128,127,126,127,126,127,127,127,128,127,126,127,128,127,126,127,128,127,126,126,127,127,126,127,128,127,127,128,127,126,127,128,127,126,127,128,127,127,127,
127,127,128,127,127,127,127,127,127,126,128,127,126,127,128,127,127,128,127,127,126,127,127,127,127,127,127,126,127,127,126,127,128,127,126,126,127,128,127,127,128,127,127,126,127,128,127,128,127,126,127,128,127,127,126,127,128,126,127,127,127,128,127,127,128,126,127,127,127,128,127,127,128,128,127,127,128,127,126,127,126,127,126,127,127,126,127,126,127,128,127,127,127,126,126,127,128,127,127,127,
126,127,127,128,127,128,128,127,128,127,127,128,127,127,128,128,127,127,126,127,128,127,128,127,126,127,127,126,127,126,127,128,126,127,127,126,127,128,127,128,127,126,127,127,127,127,126,127,128,127,128,127,127,126,125,128,128,127,126,128,127,126,127,128,127,126,127,128,128,127,128,127,127,127,126,127,128,127,126,126,127,127,128,127,127,128,129,127,126,127,128,127,126,128,127,126,127,127,128,127,
128,128,126,127,127,127,127,126,127,127,127,126,127,128,127,126,127,127,128,127,126,127,126,127,126,127,128,127,128,127,128,127,126,127,127,126,127,128,127,127,128,127,128,128,127,126,126,127,127,126,127,127,127,127,126,128,127,126,127,128,128,127,128,127,126,127,126,127,128,128,127,127,128,127,126,127,128,127,126,127,126,127,127,127,127,127,128,127,126,126,127,127,127,127,127,128,126,127,128,127,
127,128,127,126,128,127,127,127,126,128,127,127,128,126,126,127,127,128,127,127,128,127,127,127,126,127,126,127,126,127,127,127,128,127,127,128,127,126,127,128,127,126,127,127,127,127,127,128,127,126,127,127,127,127,127,127,127,127,127,127,127,126,127,127,128,127,127,127,127,127,126,127,127,127,127,127,128,127,126,127,127,126,127,128,127,128,127,127,128,127,126,127,128,127,126,127,126,127,127,128,
127,128,127,127,127,127,126,127,128,127,127,127,126,127,128,127,128,127,128,127,128,127,127,126,127,127,127,128,127,127,127,126,127,126,127,126,127,127,127,128,127,127,126,127,128,127,126,127,128,127,127,128,127,128,127,126,127,127,128,127,126,128,127,127,127,127,127,127,127,126,127,127,127,127,127,127,126,127,128,128,127,127,128,128,127,127,128,127,126,126,127,127,126,126,127,127,126,127,127,127,
127,127,127,127,128,127,126,127,127,127,127,126,127,127,127,127,127,127,128,127,127,128,127,126,126,127,128,128,127,126,127,127,127,127,126,127,127,128,128,127,127,128,127,126,127,127,127,127,127,126,127,128,127,127,126,127,126,127,127,126,127,127,126,127,128,127,127,126,127,127,126,127,127,127,127,126,126,127,128,127,127,127,127,127,126,127,127,127,127,127,128,127,127,127,128,127,126,126,127,127,
126,127,127,127,128,127,127,126,128,127,126,127,128,128,127,126,127,128,127,126,127,128,127,128,127,126,127,128,127,126,127,127,126,127,128,127,128,127,126,127,128,127,126,126,127,128,127,128,127,127,128,127,126,128,128,127,126,127,127,127,126,127,128,128,126,126,127,128,127,126,127,128,128,127,126,127,128,127,126,127,128,128,126,126,127,128,127,126,127,128,128,127,126,127,128,127,126,127,128,128,
127,126,127,128,127,127,126,128,127,126,127,128,127,126,127,128,128,127,126,127,128,127,126,127,128,127,126,126,127,   
};

//load sound sample
ISR(TIMER1_COMPA_vect) {
    if (sample >= sounddata_length) {
        if (sample == sounddata_length + lastSample) {
            stopPlayback();            
            //sample = 0;    //infinite loop
        }
        else {
            OCR2A = sounddata_length + lastSample - sample;
        }
    }
    else {
        OCR2A = pgm_read_byte(&sounddata_data[sample]);
    }
    ++sample;
}

//setup the arduino and start the intro
void setup()
{
    int boot_time = BOOT_DELAY;   
    int row = ROW_POS;
    int col = COL_POS;
    int group = 1;

    //ensure external video and sound is switched off during the intro
    pinMode(switchVideoPin, OUTPUT);
    pinMode(switchAudioPin, OUTPUT);
    digitalWrite(switchVideoPin, LOW);  //turn off the video      
    digitalWrite(switchAudioPin, LOW);  //turn off the audio      

    //power up the TellyMate circuit
    pinMode(switchTMatePin, OUTPUT);
    digitalWrite(switchTMatePin, HIGH);
  
    //send serial commands to TellyMate to control video intro
    Serial.begin( BAUD ) ;

    cursor_off();
    pinMode(ledPin, OUTPUT);

    //display CoinOPS logo
    set_cursor(row, col);        
    for (int i=FONT_START; i < (FONT_START + CHAR_COUNT); i++){       
      Serial.write(i);
      
      if (group == COLUMN_COUNT) {
        row += 1;        
        set_cursor(row, col);       
        group = 0;
      }
      group += 1;
    }    
        
    // show animated progress bar
    for (int col=COL_POS; col < (COL_POS + COLUMN_COUNT); col ++) {
      for (int i=40; i < 48; i++) {
        set_cursor(row+1, col); 
        Serial.write(i);        
        delay(BOOT_DELAY / 265);      
      }  
      if (col == (COL_POS + 3) ) {
        startPlayback();
      }
    }
    
    //Done with intro so turn off the TellyMate circuit and switch to the externals
    digitalWrite(switchVideoPin, HIGH);
    digitalWrite(switchAudioPin, HIGH);
    digitalWrite(switchTMatePin, LOW);
}

//position cursor on screen using a given row and column
void set_cursor( uint8_t row , uint8_t col )
{
    Serial.write( ESCAPE ) ;
    Serial.write( 'Y' ) ;
    Serial.write( 32 + row ) ;
    Serial.write( 32 + col ) ;
}

//switch the cursor graphic off
void cursor_off( )
{
    Serial.write( ESCAPE ) ;
    Serial.write( 'f' ) ;
}

//start playback of the audio sample
void startPlayback()
{
    pinMode(speakerPin, OUTPUT);

    ASSR &= ~(_BV(EXCLK) | _BV(AS2));
    TCCR2A |= _BV(WGM21) | _BV(WGM20);
    TCCR2B &= ~_BV(WGM22);
    TCCR2A = (TCCR2A | _BV(COM2A1)) & ~_BV(COM2A0);
    TCCR2A &= ~(_BV(COM2B1) | _BV(COM2B0));
    TCCR2B = (TCCR2B & ~(_BV(CS12) | _BV(CS11))) | _BV(CS10);
    OCR2A = pgm_read_byte(&sounddata_data[0]);
    cli();

    TCCR1B = (TCCR1B & ~_BV(WGM13)) | _BV(WGM12);
    TCCR1A = TCCR1A & ~(_BV(WGM11) | _BV(WGM10));
    TCCR1B = (TCCR1B & ~(_BV(CS12) | _BV(CS11))) | _BV(CS10);
    OCR1A = F_CPU / SAMPLE_RATE;
    TIMSK1 |= _BV(OCIE1A);

    lastSample = pgm_read_byte(&sounddata_data[sounddata_length-1]);
    sample = 0;

    sei();
}

void stopPlayback()
{
    TIMSK1 &= ~_BV(OCIE1A);
    TCCR1B &= ~_BV(CS10);
    TCCR2B &= ~_BV(CS10);
    digitalWrite(speakerPin, LOW);
}

void loop()
{
    // do nothing!    
}


The attached zip file includes.
  1. My Arduino source code for the CoinOPS intro .
  2. A python program (and Windows command line version) of my image to TellyMate font conversion.

ċ
Boot_Intro_by_Degenatrons.zip
(2109k)
Jon Wilson,
21 Aug 2012, 01:22
Comments