Next Previous Contents

4. Advanced topics

4.1 Shell scripts

Many commands in WiNGs are actually shell scripts. A shell script is just a series of instructions in a text file that are performed sequentially. For example the command "gui".

#! sh                              # "#! sh" identifies shell script
echo Loading gui... # print "Loading gui..." to the screen
win.drv # load window driver
winman # load window manager
exec wavplaythreads /media/*.wav # start playing all the wav files in /media/
ajirc # run ajirc
credits & # show the credit file as active window

As of this writing it is not possible to pass variables to a shell script.

4.2 Configuration files

Under the hood of WiNGs apps are the config files. They are in xml markup language and easily edited if you are so inclined, but you should always make a copy first. A corrupt config file can crash an application. Here is a sample configuration file for mail, /wings/programs/net/
<!-- SERVERS -->
<!-- SOUNDS -->
<sounds active="no">
<hello file="/music/wavs/startrek/hellocmp.wav"/>
<newmail file="/music/wavs/startrek/beam.wav"/>
<nonewmail file="/music/wavs/startrek/spockd.wav"/>
<downloaddone file="/music/wavs/startrek/tcompet.wav"/>
<mailsent file="/music/wavs/startrek/messsent.wav"/>
<goodbye file="/music/wavs/startrek/powerl.wav"/>
<!-- COLOURS -->
<logofg value="3"/>
<logobg value="0"/>
<serverselectfg value="3"/>
<serverselectbg value="0"/>
<listfg value="3"/>
<listbg value="0"/>
<listheadfg value="3"/>
<listheadbg value="0"/>
<listmenufg value="3"/>
<listmenubg value="0"/>
<messagefg value="3"/>
<messagebg value="0"/>
//////-- --\\\\\\
//// In 2003, APOSTASY presents \\\\
__ /// _ _ _ __ __ ___ _ _ \\\__
| \/ | / \ (_) | / _| ___ _ __ \ \ / (_) \ | |/ ___|___
|| |\/| | / _ \ | | | | |_ / _ \| '__| \ \ /\ / /| | \| | | _/ __||
|| | | |/ ___ \| | |___ | _| (_) | | \ V V / | | |\ | |_| \__ \|
||_| |_/_/ \_\_|_____| |_| \___/|_| \_/\_/ |_|_| \_|\____|___/|
\\\ __ __ ___ ///
\\\\ \ \ / /|__ \ __ __ ////
\\\\\\-- \ \ / / ) | \ \/ / --//////
\ \/ / / / \ /
\ / / /_ _ / \
\/ |____|(_)/_/\_\

Here's the configuration file for qsend, /wings/programs/net/ You can edit your signature file here.

Qsend v2.0 for WiNGs
<joe address=""/>

If there is a corrupt addressbook.xml file, mail may crash. Here is a sample file:

<entry lastname="Doe" firstname="Joe" email=""/>
<entry lastname="Smith" firstname="Jane" email=""/>

4.3 Pipes and redirects

A pipe "|" is a way of sending the output of one process through another. A redirect ">" redirects output normally intended for the screen to another device. For example:

			</>% ls |more
lists a directory one screen at a time. While:
			</>% ls >directory.txt
sends the output of the ls command to a file called directory.txt. The use of pipes and redirects can combine many simple commands into powerful commands.

4.4 Movies

Believe it or not WiNGs can play movies in the GUI. Several movie samples can be downloaded from the Official WiNGs website. There are several tools here that are needed to create and play WiNGs movies.

To play movies download vidviewer from the WiNGs website. You can do this from a console using the "update" command too.

To create movies you will need "converter" and "composer" as well. In addition you will need a Mac, or Windows box with a version of QuickTime Pro, or a Linux box with mplayer and sox installed. Using the linux box is very cool because if you have a telnet connection to it you can do everything right from the WiNGs console!

QuickTime Pro method

You can start with any movie that quicktime can play. That can even be a flash movie, or an mpeg, or an avi, or a .mov. Whatever.

You open it up with Quicktime... It has to be quicktime PRO. This usually costs 30 dollars to buy.

When you open a movie, you choose get movie properties from the movie menu. Then there are two selection lists in the popup properties window. The left list lets you choose a component of the movie, audio tracks and video tracks etc. Choose the main video track. Now in the right hand selection list are properties. Choose size. Click adjust, and drag the movie so that it's size is something less than 320x200. You should make sure the size you resize it to is divisible by 8 because you want the size of the movie to fall on the C64's 8x8 pixel card boundaries.

When you've finished resizing the movie you can close the properties popup window, and then from the file menu, choose export. There are two export options at the bottom of the export window. They let you choose the type of file it will export to. First choose Movie to Image sequence. Beside the select list now is an options button. Click it, and that lets you set the type and quality of image. Adjust these settings so that it uses JPEG. Specify greyscale and low quality just to make the C64's converter utility go faster. It doesn't really drop the quality any.

Before pressing Export, make sure you save these to a new folder, because it will export potentially hundreds of image files. Click export. Each image is now a jpeg representing one frame in the movie. and the filenames are numbered sequentially. You should make sure the name is only 4 or 5 characters long so that the resultant filenames are something like "movie 965.jpg" (notice the space) and that this filename is 16 characters or less... so that the c64 can handle them, and the converter can find them.

Next, choose export from the file menu a second time. This time choose "sound to wave" as the export type. And the options button will again appear. Click it and set the wav sound settings to something like "8bit mono 11kHz". You can set it higher, but it will produce a much larger file that will get embedded into the c64 movie, which will take up more space and take a longer time to load in.

Zip all these files into one file and transfer them to the C64. Unfortunately gunzip seems to have a bug when unzipping tons and tons of files, you may need to use unzip64 from the ready prompt. Then boot wings, and run the converter.

The converter only needs to know how many frames to convert, and the filename prefix. In the example above, the prefix would be "movie". The converter will try to find "movie" and append to the end of that the first number which is 001.jpg. It should find this file, convert it from a jpeg to a c64 bitmap, then compresses and pack it into an .rvd, or Raw Video Data file. In this case "movie.rvd"

Next you run the composer. You have to specify the x and y resolution of the movie. This was set when you resized the movie using QuickTime. Then you specify the .wav filename and the frame rate specified in the Movie to image sequence export options. Then you specify the number of frames, an output filename, and the name of the .rvd file you've just converted. Because there is a bug in the way WiNGs reports the byte size of files on a CMD drive, use the -b switch to set the correct byte size of the .wav file unless you use an IDE64 drive.

The composer puts the .rvd and the .wav together and gives the file a header which contains the specifications of resolution and frame rate etc., so that the movie player can properly play it back.

Linux method

Before you do this read the section above to get an idea of what's going on, especially convert and compose. You will need mplayer and sox. Mplayer has a plethora of options of which we use only a few.

mplayer [options]

where options are:

-lavdopts gray # sets output to grayscale
-no sound # helps with a slow processor
-vop scale=x:y[,eq=brightness] # scale output, brightness -100 to 100
-vo jpeg # export all frames to jpeg files
-jpeg [optimize=a,quality=b] # optimize 0-10, quality 0-10

To export any movie mplayer can play to jpegs:

mplayer -vop scale=x:y,eq=10 -lavdopts gray -nosound \
-vo jpeg -jpeg optimize=0:quality=0 name_of_original_movie

where x=width, y=height. 186x112 is a good size, but it should be proportional to the original.

This creates jpegs at the same rate of the original, which may be more than WiNGs can handle. We'll deal with that later.

To extract the audio:

mplayer -vo null -nogui -ao pcm -aofile audio.wav name_of_original_movie

To convert the .wav to 11kHz, 8-bit, mono:

sox audio.wav -r 11000 -c 1 -b result.wav

(make a note of the byte size of this file)

If the original movie was 25 frames/sec we'll need to reduce that. To delete all even numbered files, effectively reducing resolution to 13 frames/sec:

rm -f *[02468].jpg

To rename all files in numerical order use this script:

#! /bin/bash

n=1                ## initialize first file number
z=0000             ## a string for padding with zeroes
for file in *.jpg  ## for each file ending with .jpg
    f=$z$n                    ## put the zeroes ahead of the number
    newfile=file${f: -4}.jpg  ## use the last 4 characters of $f
    mv "$file" "$newfile"     ## move 'em out
    n=$(( $n + 1 ))           ## add one to $n

Now we need to transfer the jpg and wav files to the Commodore. Try zipping with the -o switch and then ftp from WiNGs. Or if you have the Wave use Y-modem batch.

Now boot WiNGs, extract the jpegs if necessary and use 'trim' and 'add' to get the filenames to conform to what vidconvert expects.

	file 01.jpg
file 20.jpg
file 100.jpg

Run vidconvert as above.

Run vidcompose as above. Use the -b switch to set the correct byte size of the .wav file if not using an IDE64 drive.

4.5 Development

WiNGs can use developers. See the Official WiNGs website for more details.

Next Previous Contents