Category Archives: Retro
Wow, it’s been already almost 30 posts of the Relearning MSX series. Thanks so much for your encouragement and nice comments! And especial thanks to the supporters who are making this possible.
I think this is a good time to see what’s going to come in the future posts. The remaining subjects covering MSX-C are these:
- Other control structures (break, continue, case…)
- Handling numeric values with printf()
- How values are stored in the MSX memory
- Formatted output with printf()
- Screen control characters
- Escape sequences
- Graphical characters
- Functions (2-3 chapters)
- Storage classes and scope of variables
- Pointers (2-3 chapters)
- String arrays
- Structured data and creating types (1-2 chapters)
- Creating and reading files (2-3 chapters)
- Essential library functions (3-5 chapters)
This will keep us busy for about 25-30 more chapters and the schedule is well defined already. After completing these we’ll have a pretty solid base of the C language to tackle what’s coming next: the fun stuff, the MSX-especific subjects.
In no particular order:
- The MSX graphic modes
- Organization of the video memory
- Game control: cursor keys, triggers, joystick, mouse
- Slots and subslots
- Memory mappers
- Sound effects
- Playing music
- BIOS routines
- System work area and variables
All these subjects will come from the several books I have here:
- MSX2 Technical Handbook
- MSX turbo R Technical Handbook
- MSX-Datapack I, II and III
- …and others
There’s no schedule decided for these yet. We’ll talk about these subjects in the order we need them, so if there’s anything you’d like to see covered, don’t wait and just ask for it!
And now the important part: please support these posts with a small donation, because I write during my free time and sometimes other priorities take precedence. Increasing the amount of donations increases the priority of writing these articles.
Thanks for your support!
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):
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 ›
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:Read more ›
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.
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.
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:
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 ›
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():Read more ›
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.
How about yours? Do you also have photos of your old computers?
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:Read more ›
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.
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:Read more ›
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.
Akihabara BEEP Nakaei Building (basement) 3-9-8 Sotokanda, Chiyoda-ku Tokyo 101-0021
— BEEP＠秋葉原 (@BEEP_akihabara) August 10, 2015
並べるとそれらしくなってきました これから防犯の準備します pic.twitter.com/Qfza2OxCP4
— BEEP＠秋葉原 (@BEEP_akihabara) September 3, 2015