Skip to content

Instantly share code, notes, and snippets.

@pmalin
Last active December 18, 2020 11:46
Show Gist options
  • Save pmalin/6928c11309c8c92c5372f7f8c3fc3cc2 to your computer and use it in GitHub Desktop.
Save pmalin/6928c11309c8c92c5372f7f8c3fc3cc2 to your computer and use it in GitHub Desktop.
BBC Micro Bot VDU String Example
using System;
using System.Diagnostics;
// Example C# program to make a VDU string for BBC Micro Bot
// @P_Malin
// Based on stuff from @rheolism and @Kweepa
namespace MakeData
{
class Program
{
static string GetOutputString(int[] OutputData)
{
string outString = "";
foreach (int k in OutputData)
{
if (k == 13 )
Debug.WriteLine("Cannot encode end of string terminator 13");
if (k == '"')
outString += '"'; // Add an extra quote to escape quote character
outString += (char)((k < 32 || k > 126) ? k + 256 : k); // add 256 to any invalid characters (the bot will use them MOD 256)
}
return outString;
}
static void Main(string[] args)
{
// Put the array of bytes you want to encode in here
// In this case it is a string of characters to print
// Which will be the equivalent of doing
// VDU 17,130,12,19,.... etc.
// in BASIC (but much fewer characters)
int[] VDUData = {
17,130, // COLOUR 130
12, // CLS
19, 1, 5, 0, 0, 0, // Set palette 1=5
19, 2, 1, 0, 0, 0, // Set palette 2=1
19, 3, 2, 0, 0, 0, // Set palette 3=2
5, // TEXT AT GRAPHICS CURSOR (CURSOR OFF)
};
Debug.WriteLine( String.Format("PRINT\"{0}\"", GetOutputString(VDUData) ));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment