NS BASIC Tech Note                                        April 3, 1997

42 New Features in OS 2.1
-----------------------------------------------------------------

1. Card Games
-------------
The new Newton OS2.1 units contain a couple of hidden 
card games - Poker and Patience. It's easy to start them from NS BASIC.

For Poker, type buildContext(© 830):open()

For Patience, type buildContext(© 831):open()

In fact, this trick will work from other places, too. For example, 

type =buildContext(© 830):open() 

into a spreadsheet cell in Quickfigure and watch what happens!

Some rules for the Patience Easter Egg from Dave Miller: 

Each row and column of 5 cards make up poker hands. That's 25 total 
hands. Points are assigned to the hands as follows: 

1 pair = 2 points 
2 pair = 5 points 
3 of a kind = 10 points 
straight = 15 points 
flush = 20 points 
4 of a kind = 50 points 
straight flush = 100 points 

The object is to swap cards to make the best possible hands, maximizing 
the number of points. You get $1 for each point over 200. You lose money 
if you come in under 200. 



2. Recordings
-------------
To record and playback sound, type the following into NS BASIC:

getroot().soundrecorder:open()

It will display tape recorder controls. The MP 2000 
has a built in mike and will record for you! 



3. Get the temperature
----------------------

To get the current temperature, type the following into NS BASIC:

PRINT batteryStatus(0).ambientTemp

You'll get the answer, to 13 decimal places!




4. Gray Scale Images
--------------------
Newton OS 2.1 supports 16 shades of gray in its display. Depending on what 
you're trying to do, you'll have to do different things to get it to work 
for you.

A. Widgets: There are a couple of properties that can be set to make the 
border and fill of a widget a shade of gray. In the viewBounds property, 
set the color to 14 for the fill and 244 for the frame. (If you have NS 
BASIC 3.60i or later, you can use the constants vfFillCustom and 
vfFrameCustom.) Add a new property called viewFillPattern (or 
viewFramePattern), and give it a value of 2<<27+n*1118481, where n=0 is 
black and n=15 is white. (With NS BASIC 3.60i or later you can use the 
constants RGB_Gray0 to RGB_Gray15 for values from white to black).

The Visual Designer will let you set the fill pattern to Custom. You then 
add the property viewFillPattern and put the shade of gray you want in, 
using the same formula: 2<<27+n*1118481, where n=0 is black and n=15 is 
white.

B. Drawing: The WDRAW statement has a styleFrame argument, that has slots 
called penPattern and fillPattern. You can set these to the values from 
the same formula as used by the Widgets. (With NS BASIC 3.60i or later you 
can use the constants RGB_Gray0 to RGB_Gray15 for values from white to 
black).

C. PICT images: The PictureButton widget will display grayscale images 
properly. The problem is, however, that it's tough to get the images into 
the Newton in the first place.

The usual recommendation for downloading pictures, NewtonPress, is of no 
help here. Until a new rev comes out, it cannot handle grayscale images. 
It may be possible to download the image into Works, then grab it from the 
NewtWorks file, but I'm not sure the result is grayscale. Xport from 
Landware may also have this capability in the future. It can be done using 
the Newton Tool Kit, but that's hardly a simple solution.

We will update this section as better tools appear.