Friday, January 02, 2015

TRS-80 Model 100 Super Mario Brothers Theme

I have been messing around with interfacing my raspberry pi with the keyboard and somewhere in the future the lcd.  Yesterday I was bored and decided to fool around with the speaker.  I found this post and followed it to figure out how to work the speaker. I then found this post that has code to play the mario theme using an arduino. I took his code and melded it with the softone example from wiringpi to make it work on the raspberry pi. I also added some code from okLed.c to get the ACT light to blink in time with the song kind of. The code I ended up with is is below.

 * softTone.c:
 * Test of the softTone module in wiringPi
 * Plays a scale out on pin 3 - connect pizeo disc to pin 3 & 0v
 * Copyright (c) 20120-2013 Gordon Henderson. <>
 * This file is part of wiringPi:
 *    wiringPi is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU Lesser General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *    wiringPi is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    GNU Lesser General Public License for more details.
 *    You should have received a copy of the GNU Lesser General Public License
 *    along with wiringPi.  If not, see <>.

  Arduino Mario Bros Tunes
  With Piezo Buzzer and PWM

  Connect the positive side of the Buzzer to pin 3,
  then the negative side to a 1k ohm resistor. Connect
  the other side of the 1 k ohm resistor to
  ground(GND) pin on the Arduino.

  by: Dipto Pratyaksa
  last updated: 31/3/13

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <math.h>

#include <wiringpi.h>
#include <softtone.h>
#include <softpwm.h>

#define PIN 21
#define OK_LED  47

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  1203
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 12045
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978

int tempo[160] = {
  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,

  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,

  90, 90, 90,
  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,

  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,

  90, 90, 90,
  120, 120, 120, 120,
  120, 120, 120, 120,
  120, 120, 120, 120,

int scale [160] = { NOTE_E7, NOTE_E7, 0, NOTE_E7,
  0, NOTE_C7, NOTE_E7, 0,
  NOTE_G7, 0, 0,  0,
  NOTE_G6, 0, 0, 0,

  NOTE_C7, 0, 0, NOTE_G6,
  0, 0, NOTE_E6, 0,
  0, NOTE_A6, 0, NOTE_B6,
  0, NOTE_AS6, NOTE_A6, 0,

  NOTE_A7, 0, NOTE_F7, NOTE_G7,
  0, NOTE_E7, 0, NOTE_C7,
  NOTE_D7, NOTE_B6, 0, 0,

  NOTE_C7, 0, 0, NOTE_G6,
  0, 0, NOTE_E6, 0,
  0, NOTE_A6, 0, NOTE_B6,
  0, NOTE_AS6, NOTE_A6, 0,

  NOTE_A7, 0, NOTE_F7, NOTE_G7,
  0, NOTE_E7, 0, NOTE_C7,
  NOTE_D7, NOTE_B6, 0, 0 } ;

int main ()

  int i ;
  int j;

  wiringPiSetupGpio () ;

  softToneCreate (PIN) ;
  softPwmCreate (OK_LED, 0, 1) ;

  printf ("Super Mario Brothers\n");

    for (i = 0 ; i < 160 ; ++i)
      if (scale[i] >= 1) {j = 1;}
      else {j = 0;}

      softToneWrite (PIN, scale [i]) ;
      softPwmWrite (OK_LED, j) ;
      delay (tempo [i]) ;

    softPwmWrite (OK_LED, 0) ;
 return 0;


Thursday, November 06, 2014

AssCreed Unity Quest Lines

  Main Quest
  1. Save a quite friendly chap, named Max, from unjust execution.
  2. Dime out the bourgeois pastry chef who totally stole your girlfriend.
  3. Stab someone in the throat for failing to address you as Citizen.
  4. Issue citation to prostitute for unhealthily inadequate armpit hair.
  5. Draw a bath for Marat.
  6. Deliver writ to Desmoulins family; I bet it is really great news.
  7. Celebrate 20 Prairial Year II.
  8. Break Monsieur Virtue's jaw the night before his execution.

Side Quests
  1. Eat frogs.
  2. Be cruel to geese.
  3. Urinate in the streets.

Friday, October 10, 2014

UltraVNC Single Click Creator Confusion

I was trying to create a single click executable using the online creator.  I followed the instructions to create my own version and tried to upload it to the online creator; but I kept getting an "unable to validate userid" error.  Despite all convention.  It turns out that when the online creator page says foo is username and foobar is the password, they mean it literally.  This would have been easier to troubleshoot if the forum post entitled "Common mistakes with creator tool" had mentioned that.  It helpfully states that the files must be in the root of the zip file and that the bmp files are limited to 256 colors, but nothing about the username and password using the common placeholders of foo and foobar.  Only until I did some further searching did I find another thread that enlightened me.  In my head scratching I came to understand that this tool was made by non english speakers, but I have also dealt with enough non english speakers to know that foo and foobar are used universally as they are here.

Wednesday, January 01, 2014

Life Hack Everyone, We've got a Life Hack here.

The wall street fat-cats have your nuts in a vice?  Are you tired of choking on a handful of filberts?  There is a simple way to make your own mixed nuts at only 5x the cost.  That way is to buy the individual nuts you want and mix them yourself.  BWAAM, Life Hack.  No more picking almonds, or california commie pills as they are known in these parts, out of your nuts. You really can't put a price on getting enough pecans in your hand; other than $12 a pound, that's a price.  Most lifehackers wildly exaggerate how inexpensive their idea is; here's a life hack for you: pallets cost money.

Monday, August 05, 2013

Future Benefits of the Past Present

The NCAA has, in a move that is characterized by experts as baffling, suspended all players on top 25 football and basketball teams. The NCAA claims the ruling is a proactive reaction to improper benefits that players will receive when they go on to careers as professional athletes. Based on the theory of quantum trickle down economics the NCAA says that a player's athletic ability provides them with the potential to profit that other students do not have access to. The amateur status of student athletes now reinforced the NCAA says it is looking forward to an exciting football season full of dropped passes, fumbles, and low scoring. When asked one rules committee member was unable to correctly describe a football and said they were not really "into" sports; another member replied "green" when asked the color of a basketball.

This is not the only action the NCAA is going to make, they are also consulting with physicist in an effort to sanction programs that do the wrong thing in alternate universes.  One unnamed scientist said, "Those people (the NCAA) are crazy, crazy rich."  Another said that they are using NCAA funding to complete the scrapped super collider in Texas, "They think I am going to provide a way to keep student athletes from ever making any money in any field ever; but I'm going to provide myself with a nobel prize."  When asked for comment about this newest plan the NCAA said that "they would totally get back at those jocks even if it brings about the apocalypse."

In an unrelated note, SEC, PAC 12, Big Ten, and Big XII schools are expected to announce their withdrawal from the NCAA.   The organization already has a proposed name the Collegiate Football League,  There is some concern over confusion with the Canadian Football league.  Canadians however are historically baffled by football's, or summer hockey, lack of sticks and ice and therefore the Canadians are not expected to put up much of a fight.  Americans on the other hand do not care what it is called as long as an oblong spheroid is fought over.  The schools plan to create a new league where championships are decided by playing games rather than by sports writers have not gone unnoticed by the NCAA who were seen shaking their fists in the air and yelling, "****ing jocks!"  Wait what did that last sentence say?  Oh hell no I'm not going back to writing reviews of garden fertilizers.  Screw the fans, the NCAA knows all and is our beneficent overlord.  No you can't take my keyboard from me, I bought it with my own money.  Don't pull that

Monday, February 25, 2013

The Over Militarfacation of Civilian Police

I feel that it is a big problem that civilian police forces are becoming militarized. To me if there is a local problem that truly requires military action, they should call up a local militia or national guard. Right now we have swat teams shooting first and then letting their target die to cover their asses. With all that said above is at least one officer that I don't have worry about, give that guy a m249 and I still only have to worry about getting licked to death.

Monday, February 18, 2013

The Jedi Council were Jackasses

This has been bothering me for over a decade now. There were thousands of jedis and only two siths, but the jedis were seeking someone who would bring "balance" to the force. It should have been obvious what was going to happen when the balancer emerged. Clearly if the force ledger was going to be balanced it would not be in favor of the jedis. If anything the jedis should have been looking for the one who was going to bring balance to the force so they could throw him in the deepest darkest hole in the galaxy or shove a light saber through his face.


Thursday, February 14, 2013

Sunday, August 12, 2012

The Bourne Legacy

Flowers for Algernon Has apparently been remade as an action movie with a happy ending.

Friday, March 02, 2012

Crosspost: My thoughts on Windows 8

From my other blog: Microsoft has been using the same, more or less, user interface concept for the last seventeen years and for about ten of those years the vast majority of Microsoft users have used only the Windows XP version of this concept. When Vista came out in 2007 many customers complained to me that they didn't like vista because "everything" was different. When in fact everything was mostly the same with a different coat of paint.

So we went from this:

To this:

And the impression that the average user got was that "everything" was different. Now Microsoft is working on Windows 8 and a new user interface called Metro, the same interface from Windows Phone 7. Below is a screenshot of Windows 8 from the customer preview released this week.

I would like to know what Microsoft think is going to happen when they unleash their newest operating system on an unsuspecting public. Microsoft has been trying to ween their users off of XP since 2007 and now they really are making a significant change to the user interface. So now they apparently think this going to convince the people who were freaked out by Vista and 7 to stop using XP? My personal opinion is that Metro is a neat idea which works good on touchscreens, but Metro does not work so great with a mouse and keyboard. Maybe Microsoft is trying to work the New Coke marketing strategy.