Relearning MSX #29: Conditional statements in MSX-C

Yearly Archives: 2015


Relearning MSX #29: Conditional statements in MSX-C

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

We’ve seen already how to read from the keyboard, perform some basic operations, and print results on the screen. This may be enough for a few very especific situations, but even the simplest programs will at some point need to take decisions based on the value of a certain variable. This is where conditional statements come in.

The smallest component of a program: statements

Before I explain conditional statements we need to understand what a statement is. To put it simply, a statement in C is a piece of code that performs an operation. So far we’ve seen two types of statements:

  • Assignment statements (assigning a value to a variable):
    i = 1234;
    c = 'a';
    c = getch();
    
    
  • Calls to functions (performing an operation by calling a single function):
    putchar('a');
    puts("abc");
    
    

Note something very important: all of these end in a semicolon (;). While not technically correct, we could think of the semicolon as part of the statement.

These two types of statements are essential. We can’t write useful programs without them. However, they are not enough. We can’t code useful programs with just these two either. We need something else: conditional statements and loops.

Read more ›

Relearning MSX #28: Keyboard input

Posted by in How-to,MSX,Retro | October 6, 2015

In the previous two posts we learnt how to operate with values stored inside variables in our program.

This time we’re going to see how to read characters and text strings from the keyboard in MSX-C.

Reading a single key press: getch()

MSX-C comes with a few functions to read a single character from the keyboard, but probably the easiest to understand is getch(). Let’s see an example:

GETCH1.C (Click to enlarge)

GETCH1.C (Click to enlarge)

Read more ›

Tecnobytes’ MSX Ethernet cartridge

Posted by in Gadgets,Hardware,MSX,Retro,Technology | October 3, 2015

I finally got my Ethernet cartridge from Tecnobytes Classic Computers. It works like a charm on my FS-A1GT with the Internestor Lite TCP/IP stack and related network utilities.

Tecnobytes' MSX Ethernet on the FS-A1GT (click to enlarge)

Tecnobytes’ MSX Ethernet on the FS-A1GT (click to enlarge)

The cartridge is very well built. It has a single Ethernet port mounted on the right side of the case, with two status LEDs next to it: one for power and another for link/operation.

obsonet_msx_ethernet_cartridge

Click to enlarge

Click to enlarge

Click to enlarge

The Ethernet controller supports only 10 mbps links, but that’s not a problem because the TCP/IP stack can only reach a theoretical 30 KB/s transfer speed tops. According to Konamiman, this is because Internestor Lite sends and receives a single 512 byte packet per interrupt, or every 1/60 of a second. In practice, during my tests the average speed I saw was about 8 KB/s when downloading a file from an FTP server.

Konamiman has developed several applications that work with his TCP/IP stack. They’re available in his home page. Among these there are:

  • An FTP client, to transfer files from servers on the Internet
  • An NTP client to synchronize the clock of your MSX with an Internet server
  • A basic telnet client
  • A text-based Twitter client
  • A Dropbox client
  • FTP and SMB servers, to share the files hosted in your MSX

Hopefully we’ll see support for this board in the openMSX emulator in order to do some development.

 

Relearning MSX #27: Variables and arithmetic operations in MSX-C (part 2)

Posted by in How-to,MSX,Retro,Technology | September 30, 2015

In the previous post we saw a couple of variable types and the basic arithmetic operators. Today we’ll complete this part by taking a look at the bitwise operators and seeing a couple of characteristics of the char type.

Bitwise arithmetic operators

You may be aware already that computers store all data internally in binary. This is also the case with all the data types in MSX-C. As an example, the table below shows how some integer values are represented internally in the MSX computer memory:

Integer values represented in binary

Integer values represented in binary

The computer always works in binary, but in most cases we don’t care how MSX-C stores data internally because the compiler handles these details for us. However, there are situations when working with binary data makes sense, as in the case of working with graphics or programming hardware devices.

Read more ›

Relearning MSX #26: Variables and arithmetic operations in MSX-C (part 1)

Posted by in How-to,MSX,Retro,Technology | September 29, 2015

In the previous post we saw how to print text and numbers on the screen. This time we’ll learn how to use variables and how to operate with them.

You probably know already what a variable is. It’s just some place in the computer memory that we use to store a piece of data. In C, a variable can contain data of one of several basic types. Let’s take a look at them.

Character variables – the char type

We have already seen this type in some of the examples in previous posts. The program below assigns the character ‘X’ to the character variable c and prints it to the screen using putchar():

26-1.C (Click to enlarge)

26-1.C (Click to enlarge)

Read more ›

Memories from 1993

Posted by in MSX,Personal,Photography,Retro | September 18, 2015

I had these very old photos lying around and scanned them. This was my desk in my room around 1993. The computer on the left is an MSX2 (a Philips NMS 8280). The other one is a Commodore Amiga 500 with a 1084S display.

JaviLM_room_1993_1

On the shelf to the right there were a few boxes of floppy disks containing several hundreds of them. (Click to enlarge)

JaviLM_room_1993_2

Philips NMS 8280 with an FM-PAC clone and Philips’ Music Module. I used the cassette deck to amplify the sound from the MSX2. (Click to enlarge)

How about yours? Do you also have photos of your old computers?

Relearning MSX #25: Printing on the screen in MSX-C

Posted by in How-to,MSX,Retro,Technology | September 14, 2015

The last two posts were very technical: we saw how to write assembler routines and use them in MSX-C and also the opposite, how to write MSX-C code and then use it in assembler programs.

Today we’re going to go back to where we left it in chapter 18 and continue learning the basics of MSX-C. First, we’re going to see how to display text and numbers on the screen.

Displaying characters one at a time: putchar()

We already saw the function putchar() in chapter 18, but we didn’t explain at the time what this function does.

putchar() outputs a single character to the screen. We can pass the character inside single quotes (this is known as a character constant), or we can pass a variable that contains the character we want to output.

Let’s see a very simple example:

25-1

25-1.C (Click to enlarge)

Read more ›

Let me explain with a quick diagram…

Posted by in Culture,Fun,Japan,Pets | September 12, 2015

Today I took Yuki to the vet for her vaccination. I always take her to the Nomura Veterinary Clinic in Nakano because this doctor is especialized in exotic pets. Not just ferrets, but all kind of animals that other doctors wouldn’t even dare to touch. Almost everybody in Tokyo who owns a ferret brings his to this clinic.

doctor_nomura_marmosets

As an example, one day I saw a man come to Dr. Nomura with his 5-6 marmosets on his back . Click to enlarge.

Dr. Nomura’s clinic is a bit far from home, so I can’t just take Yuki and bring her there. I have to put her in her carrier cage and either take the train (inconvenient) or a taxi. We took a taxi today.

yuki_in_carrier_cage

Yuki relaxing in her carrier on the taxi to the vet.

Every time you take your pet to Dr. Nomura he does a checkup to check that your little furry (or scaly, if you’re bringing a snake) is healthy. Usually there are no problems and your pet gets a vaccine or some other medication, and then you pay and go home.

Today it was a bit different…

Read more ›

Relearning MSX #24: Calling MSX-C functions from assembler

Posted by in How-to,MSX,Retro,Technology | September 9, 2015

We saw in the previous post how to run assembler routines from MSX-C. I’m sure you’re about to ask whether it’s possible to do the opposite: Is it possible to write programs in assembler and use the functions from the MSX-C Standard Library or the MSX-C Library disk?

I’m glad you asked. Yes, it’s possible, and it’s actually very easy to do.

Here’s how.

Calling MSX-C library functions from assembler programs

The rules that we saw for how MSX-C passes parameters to assembler functions also apply to MSX-C’s own library functions. This means that we can leave arguments in the CPU registers or in the stack as appropriate and call the function just like that.

As always, let’s see an example:

example

EXAMPLE.MAC (Click to enlarge)

Read more ›

New retro shop opening in Akihabara

Posted by in Gadgets,Hardware,Japan,MSX,Retro,Technology | September 5, 2015

Good news for all retro computer users, including MSX:

A new retro shop will be opening in Akihabara during the next few weeks. The name: BEEP.

According to their still under construction website (http://www.akihabara-beep.com), they’ll deal with retro computers, retro games, arcade games, and fanmade items. In the updates they’re posting on Twitter (@BEEP_akihabara) we can see that they have lots and lots of MSX-related stuff, including several piles of unopened, brand new Pioneer PX-V60 MSX computers that they’re selling for 19,800 yen each (they sell used ones for 8,000 yen).

They’re planning to open during the Japanese silver week, which is the week from September 21st to 25th. Unfortunately, that week I’ll be traveling out of the country, so I really, really hope they get a bit delayed so I can attend during the opening. :-)

Take a look at their Twitter feed: it’s worth it.

URL: http://www.akihabara-beep.com
Twitter: @BEEP_akihabara

Address:

Akihabara BEEP
Nakaei Building (basement)
3-9-8 Sotokanda, Chiyoda-ku
Tokyo 101-0021