Blog

Category Archives: Technology


Relearning MSX #40: Functions in MSX-C (Part 1)

Posted by in How-to,MSX,Retro,Technology | December 21, 2015

DSC_1680

We’ve covered a lot of ground already, but so far we haven’t seen anything about MSX-C that couldn’t be done with some effort with MSX-BASIC. That changes with the posts that follow.

Today we’re going to see one of the strengths of the C programming language: functions.

Let’s get to it.

Defining and using functions

When we write a program, as the source code becomes bigger and bigger it becomes much more complex and more difficult to maintain. Because of this, no matter what programming language we use, we normally divide a big program into smaller parts that perform a specific action. For example, in BASIC we used to write subroutines and call them with GOSUB.

In C we do this with functions.

Defining a function

Before we can use a function we have to indicate what code it is going to execute and what name we’re going to give to it. We call this the function definition.

The way we define a function changes slightly depending on whether it takes parameters or not, and whether it returns any data or not. Let’s start with the simplest cases and then look at more complex scenarios.

Function without parameters nor return value

The simplest case is a function that doesn’t take any parameters and that performs some action, but doesn’t return any data. It’s basically just a bunch of C statements grouped together and given a name. This is how we define such a function:

(Click to enlarge)

(Click to enlarge)

Read more ›

Relearning MSX #39: Graphic characters and additional quoted symbols

Posted by in How-to,MSX,Retro,Technology | December 16, 2015

relearningMSX39cover

In the last few posts we’ve learnt how to control what’s being printed on the screen. Soon we’ll move on to something else (functions!), but first we’re going to see how to handle graphical characters and how to print any character inside a double-quoted string.

The MSX graphic characters

MSX computers have a set of 32 special characters known as graphic characters. These only occupy one position on the screen and one byte in the video RAM, but in order to display them we have to print a 2-byte sequence.

We can type all of these characters by pressing the GRAPH key together with normal alphanumeric characters on the keyboard, but not all the characters generated with GRAPH are 2-byte codes: some are normal characters from the ASCII table (we’ll see these in the future).

The GRAPH key on a Japanese MSX computer

The GRAPH key on a Japanese MSX computer

Also, it’s important to remember that most of these graphic characters will be different from one MSX to another depending on the country of origin of the computer. For example, a Japanese MSX computer would display several commonly used kanji characters, while an European MSX would display several other useful symbols:

Read more ›

Relearning MSX #38: Screen escape sequences

Posted by in How-to,MSX,Retro,Technology | December 11, 2015

Relevo Videogames' Ninja Savior

In the last post we learned about control characters and the C escape sequences that represent some of them. Today we’re going to see a different kind of escape sequences: the ones that control the console.

You may remember that among the list of control characters we saw there were two that weren’t used to control the screen, but instead mark the beginning of either a graphic character or a terminal escape sequence. In this chapter we’re going to see how to use one of these (character code 27, or \33, or 0x1B):

control_characters_without_escape_sequence

Printing this character by itself does nothing. However, when it is followed by certain sequences of characters we can control several aspects of the text screen such as the position and shape of the cursor.

Read more ›

Relearning MSX #37: Control characters and C escape sequences

Posted by in How-to,MSX,Retro,Technology | November 28, 2015

Screenshot from the original Tron movie

The MSX supports several control characters. Those are special characters that when printed on the screen don’t display any letter, number or symbol, but instead perform some special function such as clearing the screen or moving the cursor.

Let’s go take a look.

Read more ›

Relearning MSX #36: Formatted output with printf()

Posted by in How-to,MSX,Retro,Technology | November 26, 2015

fs-a1gt_keyboard

At this point we already know a decent amount about programming in C and we can create some useful (although simple) programs. We’ve seen how to display text and numbers on the screen, but we haven’t paid much attention to the presentation yet. We’re going to take care of this in the next few chapters.

There are several statements in MSX BASIC such as CLS and LOCATE to help determine where and how things will be displayed on the screen. The C language doesn’t have functions to do the same thing, but we use control characters and escape sequences to achieve the same thing.

Let’s start.

Read more ›

Retro event in Akihabara: MyCOM Infinite PRO-68K

Posted by in Culture,Gadgets,Hardware,Japan,MSX,Retro,Technology | November 23, 2015

Yesterday I attended MyCOM Infinite PRO-68K, a small event about retro computers at the conference floor of the Akihabara UDX building.

I arrived a little bit after 1pm, in the middle of a talk by Mr. Mikito Ichikawa, president of Mindware.

Mr. Ichikawa during his talk (Click to enlarge)

Mr. Ichikawa during his talk (Click to enlarge)

The lights were dimmed during the talk, so I waited until it ended before visiting the stands.

Read more ›

Update on the DRIVER TEST hardware

Posted by in Gadgets,Hardware,MSX,Retro,Technology | November 21, 2015

You may remember that last May I wrote about the Spanish government using MSX computers in their coordination tests to obtain a driver’s license.

Shortly after publishing that article a user on Facebook wrote to let us know that in some locations (such as his city) these machines are still in operation. However, he was unable to send any photos.

Recently another user from Spain (Valkyr on msx.org) went to renew his driver’s license and found out that the examination center in his city is still using an MSX computer: a Mitsubishi ML-G1. Valkyr was kind enough to take some photos. These were taken on November 6th, 2015:

Digital StillCamera

Digital StillCamera

Digital StillCamera

Digital StillCamera

Who knows how many of these are still in operation!

Relearning MSX #35: Checking consistency of data types with FPC.COM

Posted by in How-to,MSX,Retro,Technology | November 19, 2015

Input MSX #2, page 48

In the previous post we learnt about the data types in MSX-C and how important it is to use the right one in order to keep our programs free of bugs. However, when bugs happen it’s not always easy to track them down and fix them, so it would be nice to have a tool to help with this. MSX-C’s Type Parameter Checker (FPC.COM) is such a tool. We already saw it back in chapter #14, but we talked mostly about ist command line parameters. Today we’re going to actually see how it works and use it to locate bugs in our programs.

Read more ›

Relearning MSX #34: Data types in MSX-C

Posted by in How-to,MSX,Retro,Technology | November 13, 2015

 

SD Mesxes #15 cover. 34!

In the previous post we learnt how to display numbers in different notations. The output was different for each numeric base (for the convenience of the user of the program), but from the computer’s point of view it didn’t make a difference: all these values were stored and handled internally in exactly the same way.

Today we’re going to look at data types. These have an impact on how numbers (and characters) are stored in the computer’s memory, and how the computer handles the data during arithmetic operations, comparisons and function calls.

What we’re going to see in this post is extremely important for coding error-free programs. Try not to skip it even if it may seem boring (I’ll try and keep things interesting). If anything isn’t clear then ask in the comments below. I’ll be happy to help.

What are data types?

Let’s start with a small experiment. Imagine that we have two numbers written in hexadecimal, 0x9000 and 0x3000. If we print these numbers in decimal we see that 0x9000 is -28672 and 0x3000 is 12288:

Read more ›

Relearning MSX #33: Numeric notations in MSX-C

Posted by in How-to,MSX,Retro,Technology,Uncategorized | November 8, 2015

eeprom_salad

In previous posts we’ve seenhow to perform operations with numbers, and we also know how to print decimal numbers on the screen.

During the next two posts we’re going to learn what numeric types MSX-C supports, how we (the programmers) can represent numbers in our programs, and how to print numbers in different notations.

Let’s dig in:

Four different notations

MSX-C understands four different numeric notations: decimal, hexadecimal, octal and character constants (remember that internally the computer sees these as a number).

Number formats in C

Number formats in C

Let’s see what they’re useful for:

Read more ›