Thursday, March 31, 2005

 

Simple Keyboard Console (repeat keyboard)

This program repeats what has been typed to the Console.

// TestConsole.hcc
// TestConsole and keyboard

#define PAL_TARGET_CLOCK_RATE 25175000
#include "pal_master.hch"
#include "pal_console.hch"
#include "pal_keyboard.hch"
#include "stdlib.hch"

// Declaration
static macro expr ClockRate = PAL_ACTUAL_CLOCK_RATE;
static macro proc MyConsole(ConsolePtr, KeyboardPtr);
static macro expr VideoOut = PalVideoOutOptimalCT (ClockRate);

// Main program

void main (void)
{
PalConsole *ConsolePtr;

macro expr PS2 = PalPS2PortCT(1);
PalKeyboard *KeyboardPtr;

// Check we've got everything we need
PalVersionRequire (1, 0);
PalVideoOutRequire (1);
PalPS2PortRequire(2);

//
par
{
PalConsoleRun (&ConsolePtr, PAL_CONSOLE_FONT_NORMAL,
VideoOut, ClockRate);
PalKeyboardRun(&KeyboardPtr, PS2, ClockRate);

seq
{
PalVideoOutEnable (VideoOut);
PalConsoleEnable (ConsolePtr);
PalKeyboardEnable(KeyboardPtr);
MyConsole (ConsolePtr, KeyboardPtr);
}
}
}

static macro proc MyConsole(ConsolePtr, KeyboardPtr)
{
macro expr endl = '\n';
static unsigned int 32 unInt;
static ram unsigned char string[80] = "\n\nShaohen's Celoxica Console\n"
"======================================\n\n";

unsigned int charEntered;

// Clear the screen
PalConsoleClear (ConsolePtr);

// Print the string
PalConsolePutString (ConsolePtr, string);

while( 1 )
{
PalKeyboardReadASCII(KeyboardPtr, &charEntered);

PalConsolePutChar(ConsolePtr, charEntered);
}
}

Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?