Alcatel’s Idol 4s With Windows 10 Mobile

WP_20170103_21_30_52_Pro (2)Ever since I saw the announcement for the Alcatel Idol 4s With Windows 10 Mobile, I’ve wanted that phone.  Well, it is out and I finally bought it.  Why? Well, many reasons, biggest being its ability to support Continuum and its price: $469 from T-Mobile, in the United States.

The current package also includes Alcatel’s VR headset and the phone comes with a smattering of impressive imagery and a couple of VR games, both of which seem more like tech demos than actual games.

The phone is gorgeous, one of the prettiest phones I’ve ever seen, on par with the Apple iPhone 4, which I previously regarded as the best LOOKING piece of hardware.  The Idol 4s looks better.  It’s glass back, metallic rim and a screen that, for now, never WP_20170103_21_31_23_Pro (2)seems to get finger prints. It is just the right weight and the screen is amazing.

The phone sports a Snapdragon 820 CPU, which is a quad core processor running at 2.15ghz.  It has 4gb of RAM and 64gb of storage, expandable with an SD card.  It also features a 21megapixel back camera and an 8 megapixel forward camera.  The camera can be started via a hardware button on the side of the device, a convenient if annoying feature.

The phone ships with a release of Windows 10 Mobile that was a bit behind. It immediately wanted to update to, I think, the ‘anniversary update’ rollup.  Fortunately, it went off without a problem.

The camera, which I had read was a weak point, is actually pretty decent.  In lower light, the colors are a bit washed out, just like the Alcatel Fierce XL I have, but the resolution is excellent and the images still look really nice.  I have not yet tried outdoors at night, but will do so soon.

Perhaps the best thing about the phone…and Windows 10…is the ability to use the device as a deWP_20170103_20_06_00_Prosktop or laptop computer.  That is where this device really shines.  While I had to purchase a USB C to HDMI converter, the converter works great and also sports a spare USB 3.0 connector (for a keyboard or mouse) and a USB C female connector for charging the device while connected.  The HDMI port is 4k capable and is full size, so you don’t need any funky sized connector or adaptor. The particular hub I purchased was from Mokin and sold via Amazon. I paid $23 for the device.

Connecting the phone to the Mokin switched it to Continuum and presented the desktop, as you would expect from a desktop PC.  The phone screen turns into a mouse, though using this instead of an actual mouse can be frustrating as there is no obvious way to ‘click and hold’ to drag things. At least, I have not figured that out yet. A bluetooth keyboard was paired to the deviwp_ss_20170103_0001ce and, bam! There I was, using my phone as a desktop.

Continuum, admittedly, is not perfect. For example, nothing I had on the SD card would work. For whatever the reason, Microsoft is not allowing applications on the SD card to run in Continuum. Also, not every application is Continuum compatible either.  And, protected content will not work in this mode.

Overall, however, Continuum seems, to me, to be the killer feature (until MS introduces x86 emulation to the Snapdragon) for Windows Mobile 10.  I can see carrying just the phone and adapter.  Most places one would need a computer will, very likely, have an HDMI monitor along with keyboard and mouse. Or, you can take the travel size keyboard/mouse.  I can forsee this more than taking my old laptop or even a tablet, though, admittedly, tablets can be just as productive.

61tocr  emL._SL1500_While running Continuum, I was able to run Word, Excel, OneNote, Facebook and take a call…at the same time.  The phone showed no perceptible slowdown at all.

The VR gimmick is just that, a gimmick and really not a reason to buy this phone.  That said, and taking into account the limitation of the screen, it is still rather impressive, at first.  The screen is HD, 1080p.  That’s a problem only because the screen gets split in two to present the left and right images.  This makes things a bit fuzzy and pixelated. However, it is not so bad as to make the experience a poor one.  Quite the contrary, it works well.  Too well, I got a headache and was a bit nauseated by it because my brain knew I was not really experiencing anything, though my eyes said otherwise.

Overall, the Alcatel Idol 4s with Windows 10 Mobile is an excellent, premium phone at a great price…half what most others would cost.  It looks great, works well and is fast.  Windows 10 Mobile needs a little work, but it is, overall, a great operating system and works very well. Don’t let the notion of a poor ‘store’ steer you away. The app system on all of the mobile devices is bad, I don’t care if there aren’t five hundred fart apps.  I don’t even care that there is no Youtube app, the web site works and there are a few third party apps that fill in for what is missing.

I think you’d be satisfied with this phone. I sure am.

Advertisements

Flappy Bit: writing a Tiny Basic game that uses a light sensor and you as the game controller

FlappyBitPhotoHere’s a very rough, very crude game, in HalfByte Tiny Basic, of Flappy Bird. I call it Flappy Bit. You use the Light Sensor to control your bit. Cover the sensor and your bit moves up, shine light on it and you go down. As I have not built much logic into it, weird things happen, like sometimes the pipes blend together and you will hit it, sometimes, you go through the pipe, etc. It only uses about 400 or bytes, so there is plenty of room to play with.

Game Features:

  • Use your hand as the controller!
  • Ultra realistic blocky graphics!
  • Stunning sound!
  • Full Color Black and White!
  • True to physics!

100 CLS
110 X=1:Y=20
120 P=50:Q=0
130 L=RND(20):M=RND(20)
135 W=-1
140 A=0:Z=0
150 S=0
160 D=1
170 C=0
200 LINE P,0,P,L,1
210 LINE P,44,P,44-M,1
220 SET X,Y
225 DELAY 50
230 Z=AREAD(A)
240 IF Z<300 K=-1
250 IF Z>299 K=1
260 IF GET(X,Y+K)=1 GOTO 500
270 RESET X,Y
280 X=X+D
290 IF X>75 X=1:D=1
300 LINE P,44,P,44-M,0
310 LINE P,0,P,L,0
320 P=P+W
330 IF P<1 P=RND(75):M=RND(20):L=RND(20)
340 IF M<15 M=M+10
345 IF L<15 L=L+10
350 Y=Y+K
360 IF Y>40 Y=40
370 IF Y<1 Y=1
380 DELAY 50
385 IF X=P+1 C=C+1:TONE 2000,200
386 CURSOR 0,6:?C;
390 GOTO 200
500 CLS
510 ?”You hit the pipe!”
520 DELAY 5000
590 GOTO 100

Flappy Bit: writing a Tiny Basic game that uses a light sensor and you as the game controller

FlappyBitPhotoHere’s a very rough, very crude game, in HalfByte Tiny Basic, of Flappy Bird. I call it Flappy Bit. You use the Light Sensor to control your bit. Cover the sensor and your bit moves up, shine light on it and you go down. As I have not built much logic into it, weird things happen, like sometimes the pipes blend together and you will hit it, sometimes, you go through the pipe, etc. It only uses about 400 or bytes, so there is plenty of room to play with.

Game Features:

  • Use your hand as the controller!
  • Ultra realistic blocky graphics!
  • Stunning sound!
  • Full Color Black and White!
  • True to physics!

100 CLS
110 X=1:Y=20
120 P=50:Q=0
130 L=RND(20):M=RND(20)
135 W=-1
140 A=0:Z=0
150 S=0
160 D=1
170 C=0
200 LINE P,0,P,L,1
210 LINE P,44,P,44-M,1
220 SET X,Y
225 DELAY 250
230 Z=AREAD(A)
240 IF Z<300 K=-1
250 IF Z>299 K=1
260 IF GET(X,Y+K)=1 GOTO 500
270 RESET X,Y
280 X=X+D
290 IF X>75 X=1:D=1
300 LINE P,44,P,44-M,0
310 LINE P,0,P,L,0
320 P=P+W
330 IF P<1 P=RND(75):M=RND(20):L=RND(20)
340 IF M<15 M=M+10
345 IF L<15 L=L+10
350 Y=Y+K
360 IF Y>40 Y=40
370 IF Y<1 Y=1
380 DELAY 100
385 IF X=P+1 C=C+1:TONE 2000,200
386 CURSOR 0,6:?C;
390 GOTO 200
500 CLS
510 ?”You hit the pipe!”
520 DELAY 5000
590 GOTO 100

The archive. Confetti. Type in programs. Read.

syncmagAs part of putting together a package of materials for Half-Byte Tiny Basic, I came across several gems that either reminded me of my early computing days or are cool enough for me to write about.

One such site is the Internet Archive. (The link takes you to the magazine rack. From there, use the search bar near the top of the page, and search for, say, ‘Byte’. Or computer magazines.)

Now, this site has a treasure trove of material, including the Way-Back machine. The Way-Back machine allows you to enter a URL and then see it in various incarnation through the years. It’s really interesting to see how the Internet and web design have developed. But, that’s not what caught my eye, as cool as that is.

No, it was the site’s collection of magazines, specifically, computer magazines. You can download scanned images of whole magazines, going back to the mid 1970’s.  I remember quite a few and even had many of them. At one point, I had the first ten years of Byte Magazine, THE computer magazine of the 1970’s and ‘80s.

Now, the magazines I was looking for, Dr Dobb’s (another one that I had the first seven years worth, but, no longer) Journal and a bunch of Sinclair ZX related magazines. Unfortunately, CMP has Dr Dobbs, so you won’t find it here, however, you will find Byte and a whole slew of Tandy, Commodore, Atari and, of course, Sinclair related magazines.

The quality of the scans various widely. Some are really nicely done and care taken to line them up correctly, etc. BUT…some were not cared for very well. But, hey, they ARE scanned and there’s no charge to download them, so…all considered, it is a treasure trove that I’ll not complain about.

So, I did find a few things that I was looking for, namely some type-in BASIC programs.  I am putting together a booklet of short type-in programs-games-to use on the Half-Byte Console and Tiny Basic. And, the Sinclair flavour of BASIC is close and the ZX-81 lunarzx81specs are very close to the Half-Byte Console, so the conversion is pretty easy. I will also be writing about such a conversion process. The downside is that there are few examples of Tiny Basic software, or other BASIC for that matter.  Type in software is a thing of the past and pre-dates the Internet. 

I certainly remember the thrill of getting my next issue of Computer Shopper, Compute! or Sync Magazine and anxiously looking at the type in games or utilities and converting them to whatever computer I wanted to use them on.  I had my ZX-81, my TRS-80 Color Computer and, eventually, a Xerox 820 that ran CP/M and several flavors of Basic. Of course, the 32k Extended Microsoft Basic was my favorite, but the Xerox had no graphics, so I spent a lot of time on the ZX or the CoCo. 

Typing in games was great. I got to learn what the program did, hone my typing skills and felt accomplished when I typed that last line, saved and then type RUN.  Inevitably, of course, I would have made a mistake and would have to fix it. Sometimes, I made no mistake-the listing was just wrong. Other times, I made a mistake converting the code and would have to correct it. Sometimes, that took minutes. Other times…DAYS. Oh my. I remember one game that took me hours to type in on my CoCo. I had an original CoCo, which had a crummy key board. UGH.  I hated that thing.  Never replaced it though.  Should have. 

Anyway, I get through typing in this game. Saved it on two different tapes, just to make sure. I type RUN, press RETURN and…nothing.  The damned computer hung.  I had to TURN IT OFF! Now, this meant re-loading the game and trying to figure out why it choked.  Loading anything from a tape was a laborious and risky task.  Will it load? You pray, even if you don’t believe, you pray that the Tape Gods are  favorable to you today and will allow the software to load.  Fortunately, I had not upset the Tape Gods and all was good.  I figured out that I had reversed two numbers that were in some MACHINE CODE that was getting POKED into memory and run.  So, I fix that.  Re-save. On three tapes, this time. I want to be safe.

I type RUN.

Boom! Confetti!

It started. 

I followed the directions and pressed the space bar to start the game.

Boom! No Jimmy Johnson. No Confetti. Only a damned Syntax Error and that stupid multi-colored cursor blink at me.

This problem, a multi-statement line where I left out a bloody colon in the middle of the line. That…took a week to find.  I ended up just retyping the line. Three times! I mistyped that same line two different times. The third time was the charm.  This time, there was confetti. And, it was good.

Ah, those were the days. ‘Free’ and open source software before it was called that. Well, not totally free. You still had to buy the magazine.

So, sit right back my friends, you are sure to get a smile…or a chuckle. Once the console is out of the door, expect to see a few type in games or utilities on these pages from time to time.

HALFBYTE Console Tiny BASIC update

XANDER - WIN_20140222_110454 (2)The HalfByte Console is nearly complete. The hardware design is pretty much done and a prototype built. It is a fairly simple ATMega328 based computer with audio and video out, Wii Nunchuck interface (the Wii Classic Controller also works), PS/2 Keyboard support and will run off of battery, wall wart or can be powered via FTDI.  It is pretty small, about the size of an Arduino UNO. It is designed to be easy to use and build. (The console featured in the photo above is the first prototype and is not the final design. The final prototype is not presentable here, this one looks nicer.)

One of the goals of the console is to aid in learning to program.  For now, this can be done in two ways: standard Arduino IDE or on console via Tiny Basic.

Yes, Tiny Basic. 

I have adapted the wonderful little version of Tiny Basic from Mike Field.  I did this for the XGamestation and have done it for the HalfByte Console as well. This version of the language supports graphics, low level hardware access and the Nunchuck. It is standard Tiny Basic in every other aspect: integer variables, single letter variables, line numbers, GOTO, small memory footprint and is easy to learn. It makes the perfect introduction to programming.

Because the 328 is limited, RAM wise AND the video takes up most of that RAM, we are left with only 726 bytes of memory to use for programming. The 52 bytes for variable storage and stack already have RAM dedicated, so you do not need to factor that in.  As such, the big feature I wanted to include, SD Card support, could not be done.  To implement FAT16, you need a 512 byte buffer and we simply do not have that, so, for now, EEPROM is used to store a program. Again, memory issues only allow for ONE saved program.  Since RAM is low anyway, we can fit it in the 1k EEPROM space we have.  And, remember, this is more of a learning tool than a ‘serious’ development platform.  The console can, of course, be programmed for games and other applications outside of Tiny Basic and there are a lot of really clever games that utilize the TV OUT library.

So, what can we do with Tiny Basic? Well, even with these limitations, a lot.  Throw some motors on the console and control them with Tiny Basic.  Add some LED’s and make them blink.  Create small, clever games.  Your imagination is the limit.

I won’t discuss the basics of BASIC, but would like to touch on the hardware specific enhancements, like graphics and controller support.

GRAPHICS

There are five graphics statements and one function.  The five statements are:

  • SET x,y
  • RESET x,y
  • LINE startx,starty,endx,endy,on or off
  • BOX startx,starty,endx,endy,on or off
  • CIRCLE startx,starty,radius,on or off

The function is:

  • <var>=GET(x,y)

GET will return the setting of a pixel at x,y. If the pixel is lit, it returns a TRUE (1) otherwise a FALSE (zero).

For LINE, BOX and CIRCLE, ‘on or off’ means a one for on and a zero for off.  If you BOX a section of the screen with text or other graphics, you can set ‘on or off’ as a 2 and it will invert that section of the screen. This is a good way to highlight text.

HARDWARE ACCESS

There are two statements that can set pins on the 328:

  • AWRITE <pin>,on or off or value (sets the ANALOG pin)
  • DWRITE <pin>,on or off or value (sets the DIGITAL pin)

There are three functions to read values from the hardware:

  • <var>=AREAD(<pin>)
  • <var>=DREAD(<pin>)
  • <var>=IN( 0 )

AWRITE and DWRITE will send a value to the specified pin. A zero sets the pin LOW, a one sets it HIGH, any other value is simply sent to the pin. AREAD and DREAD will return a value from the specified pin. NOTE: the ‘A’ in AREAD and AWRITE specify the ANALOG pins, while the ‘D’ means DIGITAL pin.

IN( 0 ) returns the current value from the RX pin (D0) on the 328p chip. This could be useful to monitor the serial interface for incoming data.

SAMPLE CODE

Since adding support for graphics and the Nunchuck, simple games like Space Invaders or simple shoot them ups are fairly easy.  Nunchuck support is complete, too…you can not only read the buttons and the thumbstick, but also the accelerometer. While the Classic Controller will work, no support for it is included. Maybe a later version.

The first sample I want to show is Kaliedoscope:

100 CLS
110 X=RND(40)
120 Y=RND(20)
130 P=RND(40)
140 Q=RND(20)
150 SET X,Y
160 SET 80-X,Y
170 SET 80-X,40-Y
180 SET X,40-Y
200 RESET P,Q
210 RESET 80-P,40-Q
220 RESET 80-P,Q
230 RESET P,40-Q
240 IF INKEY(0)=27 STOP
250 IF RND(100)<95 GOTO 290
260 BOX 0,0,79,39,0
270 FOR I=1 TO 500
280 NEXT I
290 GOTO 110

This little gem will display random pixels that are mirrored in four quadrants on the screen.  Randomly, the screen will invert. It can be quite mesmerizing.

Here’s a Nunchuck example:

100 X=1: Y=1 #INITIALIZE OUR START
110 SET(X,Y)
120 P=PAD(0) #GET THE X VALUE
130 Q=PAD(1) #GET THE Y VALUE
140 IF P>200 X=X+1 #IF VALUE IS MORE THAN 200, GO RIGHT
150 IF P<100 X=X-1 #IF VALUE IS LESS THAN 100, GO LEFT
160 IF Q>200 Y=Y+1
170 IF Q<100 Y=Y-1
180 SET(X,Y) #LIGHT UP THE PIXEL
190 IF PAD(3) STOP #IF Z BUTTON IS PRESSED, STOP
200 IF PAD(2) RUN #IF C BUTTON IS PRESSED, RESTART
210 GOTO 120 #DO IT AGAIN

This bit of code is akin to an etch-a-sketch. PAD is the function which reads the controller. The parameter passed tells Tiny Basic which part of the controller to return a value: the x and y axis for the stick, the C and Z buttons and the accelerometer.  the modes are:

PAD number

Return value

0

Thumbstick x

1

Thumbstick y

2

‘C’ button

3

‘Z’button

4

Accelerometer x

5

Accelerometer y

6

Accelerometer z

BLINKY

This example will blink the PIN 13 LED:

100 FOR K=1 TO 50
110 DWRITE 13,1 #TURN ON LED ON PIN 13
120 FOR I=1 TO 500 #DELAY
130 NEXT I
140 DWRITE 13,0 #TURN OFF THE LED
150 FOR I=1 TO 500
160 NEXT I
170 NEXT K

Looking at the code, you see that line 110 turns on the LED and 140 turns it off.  120 and 150 create a delay so you can actually see the LED turn on and off.  We could add a line between 120 and 140 to test for the status of pin 13:

115 IF DREAD(13)=1 PRINT “LED IS ON.”

165 IF DREAD(13)=0 PRINT”LED IS OFF.”

Now, these lines are rather pointless in the example, because we know they SHOULD be set accordingly, you can see the utility of them. 

As you can see, there is a nice foundation here for something that can be quite useful in not only teaching a child how to program (or, anyone) but it is also useful for scripting hardware functions as well.  This version of Tiny Basic should run, as is, on an Arduino Mega2560. On that board, you will have more RAM to work with and create some really nice, useful or fun code.  You could also modify the interpreter for a slightly high resolution.

I have prototyped using a second 328 strictly for video generation. This gave me an effective resolution of 128 x 96 graphics and 22 by 12 text.  However, communication between the two is serial and I did not fully implement graphics. Once the console is complete, I will return to this side project and fully develop it. Perhaps HB Console II will feature two 328 chips.

Developing this Tiny Basic has been fun and brought up many memories of when I was a wee lad, experimenting with this new thing called a home computer with my Dad.  I hope this can create similar memories for parents and children going forward and, along the way, spark an interest in these nifty little computers.

NOTE: I am currently stumped with the PIC16 version of TINY BASIC.  I have the interpreter working very nicely with low res color graphics, sound and hardware support. BUT…I’ve been stumped with a big bug in the SAVE-LOAD code.  We utilize the SD Card (FAT16) library and can read and write and get the directory listing. If you are familiar with the PIC and know C and would like to help, PLEASE drop me a note.  I can’t reward you with a financial reward, but you will have my eternal thanks and recognition both here and in the Tiny Basic code.

EDIT: since publishing this post, I have been able to squeeze 200 more bytes into RAM by moving the keyword scan tables into PROGRAM MEMORY. More optimization may be possible. Who knows, maybe I can get a whole 1k of RAM. That’s what the original ZX-81 had.

A Video Game on my Trinket, take 2

Several posts ago, I wrote about writing a video game for the Trinket from Adafruit. Well, since then, I have added scoring, sound and a bit more animation (very crude, mind you, I can only do so much in the small memory and limited screen.)

The setup uses the Trinket, Parallax’s 2×16 LCD panel and a switch connected to Pin 0. The LCD panel is connected to Pin 2.  You will need to import the SoftwareSerial library for the LCD.

The premise of the game is based on the Battlestar Galactica TV show from 2003-2010.  The Galactica was engaged in heavy battle and barely managed to escape before certain destruction. All of her gun turrets, save the forward torpedo launcher, are damaged and non-functional, meaning she can only fight head on.  The Viper squads are still engaging the enemy.  A group of Cylon raiders have found the mighty Battlestar and are taking her on, one by one. Oh, you only have ten torpedo’s left, so use them wisely.

The game ends when you use up your ten torpedo’s.

Below is the revised listing for the game.  Apologies to Glen Larsen.

 

Listing 1.

#include <SoftwareSerial.h>

SoftwareSerial s(0,2);
 
// globals
int  cylonpos;
int  oldcylonpos;
int  cyDirection;
int  button;
int  posStart;
int  lin2Start;
int  bsgpos;
 
// special characters
int  bsg;
int  cylon;
 
// total number of torpedos the ship has left
int  tShots=10;
 
// the setup routine runs once when you press reset:
void waitforbutton();
void moveCylon();
 
void setup() {  // initialize the digital pin as an output. 
   s.begin(9600);
   s.write(12);
   s.write(17);
  
   //define the ship character
   s.write(249);
   s.write(0x4);
   s.write(0xE);
   s.write(0xE);
   s.write(0x15);
   s.write(0x1F);
   s.write(0x15);
   s.write(0xE);
   s.write(0xE);
  
   // baddies
   s.write(251);

   s.write(uint8_t(0x0));//to handle a goofy issue with ‘0’
   s.write(uint8_t(0x0));
   s.write(0xE);
   s.write(0x15);
   s.write(0x1F);
   s.write(uint8_t(0x0));
   s.write(uint8_t(0x0));
   s.write(uint8_t(0x0));
 
// the button is on pin 0 
   pinMode(0,INPUT);
  
// the initial direction is right
   cyDirection=1;
  
} // the loop routine runs over and over again forever:
void loop() {
  int score;
  score=0;
 
  s.write(12); // clear the screen and show the instructions
  s.println("Shoot the Cylon\n");
  s.println("press btn 2 strt");
 
  // wait for the button
  waitforbutton();
 
  // define somethings before we start the game loop
  tShots=10;
  cylon=3;
  bsg=1;
  lin2Start=148; // the baddies appear on line 1
  posStart=128;  // the good guys on line 2
  randomSeed(analogRead(0)); // gen a random seed
 
  bsgpos = 8;  // our ship starts in the middle of the sector
  cylonpos=random(0,15); // baddies warp in at a random spot
  oldcylonpos=cylonpos;
 
  s.write(12);  // clear screen
  s.write(17);  // turn on backlight so we can see
  s.write(posStart + cylonpos);  // uh oh…the Cylon appeared!
 
  s.write(cylon);
  s.write(lin2Start+bsgpos);
  s.write(bsg); // and here we are
 
  // begin the game
  while(1){
    /* Game loop */
    int button;
    s.write(22); // kill the cursor
    moveCylon();
    delay(200);
    button=digitalRead(0);  // check the button
    if(button==HIGH){ // torpedo fired?
      if(cylonpos==bsgpos){ // Hit?
        s.write(132); // center ‘Hit’ on screen
        s.print("** HIT **");
        score ++;  // update score
        s.write(213); // noise (C at half note, 3rd scale)
        s.write(215); // play the note
        s.write(224);
        s.write(225);
        if(score==10){  // did we win?
           s.write(12); // clear screen
           s.write(128);// start at beginning
           s.print("You have saved\nthe Galactica.");
           delay(2000);
           loop();  // start game again
        }
        delay(3000); // did not win yet
        s.write(12); // clear screen
        s.write(lin2Start); // move cursor to beginning of line
        s.write("Score:");  // put up score
        s.print(score);
        s.write(lin2Start+bsgpos); // Since we shot the Cylon, we have to leave the sector, so…
        s.write(0x20); // go into hyperdrive and erase the BSG
        bsgpos=random(9,15);  // calculate new position
        s.write(lin2Start+bsgpos); //…and, we are here
        s.write(bsg);
        s.write(posStart+cylonpos);
        s.write(0x20);
        cylonpos=random(0,15); // Damn, they found us!
        oldcylonpos=cylonpos;
        moveCylon();
      }
     
      tShots –; // decrement our torpedo inventory
      if(tShots<1){ // out of ammo?
        s.write(12);  // clear screen
        s.write(posStart); // start at beginning of line
        s.print("The Cylons win.\n");
        int count=1;
        // show animation of our ship exploding
        while (count<10){
          s.write(lin2Start+bsgpos);
          s.write(bsg);
          delay(500);
          s.write(lin2Start+bsgpos);
          s.write(‘*’);
          delay(500);
          count++;
        }       
        loop(); // Play again
      }
    } 
  }
}
void moveCylon(){
  // sneaky Cylons…they show up anywhere!
  s.write(posStart+oldcylonpos);
  s.write(0x20);
  if (random(0,6)>3){
      //Cylon warped
      cylonpos=random(0,15);
      oldcylonpos=cylonpos;
  }
 
  cylonpos += cyDirection; // figure out which way to move
  if (cylonpos>15){
   cylonpos=15;
   cyDirection=-1;
  }
 
  if (cylonpos<0){
    cylonpos=0;
    cyDirection=1;
  }
  // erase from old spot
  s.write(posStart+oldcylonpos);
  s.write(0x20);
  s.write(posStart+cylonpos);
  s.write(cylon);
  oldcylonpos=cylonpos;
}

void waitforbutton(){
  SoftwareSerial s(0,1);
 
  int button;
  button=digitalRead(0);
  while(button==LOW){
    button=digitalRead(0);
    delay(1);
  } 
  s.write(1); 
  delay(1000);
  s.write(12);
}