Introduction
Long ago, in a distant galaxy, when hard drives were no more than 100 MB (and some where there were none at all), the address bus was only 16 bits, no one, or almost no one even thought of 3D graphic accelerators, and the Internet came to rare houses, on wet clothesline through squeaking boxes ...
In general, then people also wrote programs. Learned to write them, wrote, and even sold later.
Nostalgia for old school computers led me, armed with an emulator, Google, and my own hands, of varying radius of curvature, to remember how it was myself, and then tell you. Welcome under cat.
')
Warm and, in a sense, a lamp monitor of the past ...
What you need to develop? At all times the necessary minimum consisted of:
- Source Editor
- Translator source code into machine instructions
- Debugger
and nothing new here, in general, and no. We also have to decide on the operating system, where we will work. I will explain all of the following with regard to MSX-DOS version 2.20, since I myself went through it in due time (there was also CP / M, but I didn’t work with it, but I’ll touch on this topic in other publications as well, because than)
Let's collect the necessary set of software for the MSX-computer and see how the development for these machines looked like.
1. OpenMSX - file processing
First you need to talk about the settings of the emulator. Last time, we used the Catapult graphical frontend, but it has several limitations on the emulator startup parameters (for example, you can connect rom for a single hardware expansion, although there may be up to four, depending on the computer model chosen). The CLI interface will allow us to fully unleash the power of the emulator without losing anything in usability.
So, run the emulator from the command line.
$ openmsx -machine Yamaha_YIS-805-128R2 &
The
-machine key sets the hardware configuration of the MSX running. The configuration is determined by * .xml-configs located in Linux by the path
/ usr / share / openmsx / machines / . With the presence of "Roma" and the idea of ​​the hardware architecture of these computers, such a config can be bungled on its own, but so far I have had enough of the mined in the open spaces of the network (all links are in the
last article ).
I choose the Yamaha YIS-805/128 localized by the Japanese for the USSR (what the small letter R in the name of the config eloquently says). This is a teacher's car, for which I spent a total of most of the time. Localization will not hurt us, as we will see later.
So, we will see the BASIC interpreter, but for now we do not need it. And we need this
Embedded OpenMSX command interpreter
The window at the bottom of the screen pops up / out by pressing F10 and allows you to "steer" the emulator using the built-in command shell. You can even write scripts, of which decently comes bundled with the program along the path
/ usr / share / openmsx / scripts / .
For example, we want to connect a mouse (the mouse was on the teacher’s computer, the photo was placed under the spoiler)
To do this, run the command
> plug joyporta mouse
and we will have a mouse, which can now be used in its supporting programs.
To work with floppy disks we use the following commands:
put a floppy disk in a virtual drive
> diska < A> > diskb < B>
remove floppy from drive
> diska eject > diskb eject
If we need a blank floppy disk, then we can create it.
> diskmanipulator create < > < >
format
>virtual_drive < > >diskmanipulator format virtual_drive
and copy on it
> diskmanipulator import virtual_drive < | , >
as well as with it, the files we need
> diskmanipulator export virtual_drive < , >
It is possible to create directories on diskette
> diskmanipulator mkdir virtual_drive < >
and navigate through them
> diskmanipulator chdir virtual_drive < >
In addition, as a floppy disk, you can specify the directory on the host machine
> diska < >
However, if someone thinks that you can bypass the 720 KB limit (I thought so, although you should have guessed that the emulator views this directory as a disk device with a well-defined geometry), then you will be disappointed - as soon as the amount of recorded data exceeds the specified the limit, the emulator will tell you that the disk is full - everything is fair.
So we are armed to the teeth. KUVT2 supported disks with a capacity of 360 and 720 kilobytes, which is not very thick at the present time, but what to do - at that time this state of affairs did not upset anyone. The main thing is that we have carriers for the transport of the software we need inside the emulator.
"To heap" a few more useful commands emulator
hardware reset
> reset
power off / on the machine
> set power off > set power on
You can take a screenshot like this
> screenshot < >
without specifying the file name, the emulator will put the screen in
~ / .openMSX / screenshots /2. Booting the OS, setting up the terminal and editing texts
MSX-DOS can be found
here . Unpack the archive, and run the emulator
$ openmsx -exta msxdos2 -machine Yamaha_YIS-805-128R2 -diska MSXDOS2T.DSK
The
-exta switch connects the hardware extension msxdos2 which will allow us to use this OS on the pits. In total, up to 4 extensions are allowed (depending on the emulated computer) added by the
-exta ...
-extd keys . The
-diska switch means the start of the emulator with a diskette inserted in drive A.
After loading we will see the screen in the “non-kosher” 40x25 mode. We will be inconvenient to work there, so you need to switch to the normal 80x25 mode
A> mode 80
Mode 80x25. Well, you can already live in this console
Autoexec.bat content
ramdisk 4064/d copy %1command2.com h:\ reboot.bat %1
informs us that a RAM disk H is created: with a capacity of 4064 KB, where the command processor command2.com is placed and the environment variables are re-initialized with the reboot.bat script
set temp=h:\ set shell=h:\command2.com path %1\kids;%1\tools;%1\utility
This is so that we do not lose the ability to use the command shell if we suddenly need to temporarily remove the floppy disk with the system. And such a need arises in a preyodic way - there is little space on floppy disks, there are only two disk drives (this is at best), so it was quite often necessary to shuffle floppy disks. It didn’t bother me, before the university didn’t see the company with HDD, but it was pretty annoying.
The diskette also contains the simplest text editors KID and AKID from ASCII, the main system software provider for MSX.
A> akid
We will be asked to name the file.
and you can type
exit from the editor, save and so on - by hotkeys. Basic operations can be performed through the menu, called by F1.
Prostitsky is such a notebook / nano-like text editor. For the rest of the information about him
follow the link . The KID editor turned out to be a buggy version of AKID, so I didn’t evoke any particular interest.
Well, if we write a megaprogram in assembly language consisting of several source files? We would have at least vi here ... M-de, well, we will not have vi, but something simpler, but rather solid, called TOR (not to be confused with a tor-browser). TOR is a translit from the Russian abbreviation TOR - Text Window Editor. You can download it
here . Unpack the archive into a separate directory, pull it up to drive B: and see what we have
in the emulator console
> diskb /home/$USER/msx/tor
in MSX-DOS
A>B:\tor
The Russian version of the Russian editor of TOR from Leonid Baraz - screen saver
Yeah, localization is very nice. It only works on the localized version of the Yamaha, that is, on KUVT. On TURBO-R, you will be met by hierogly or other cracks (at first I thought that the editor was in Japanese, and then I guessed that the matter was in the ASCII table). In this case, there is an English version, run by the command
A>B:\tor\tore
Enemy Interface Option - TORE Inside the editor looks like a commodity
TOR editing window
and allows you to work with several (up to ten) files in different buffers (almost like vim / emacs). Management may seem to be "moved", but for that time, probably everything was ok and a matter of habit (well, you had already forgotten ...). For example, to insert a line between two lines, you must slap Ctrl + Enter and not just Enter. Well, and so on. Fortunately, help and menu in Russian and in some detail
Some more screenshotsESC menu
Exit editor
3. MSX BASIC
The BASIC interpreter in 8-bit computers played a special role - it was for you and the OS, and the shell, and the code editor, and the IDE and the debugger - the program stopped at its disrupting line and gave out curses in English, dirty and not so much. By default, after downloading, you got into the BASIC. From Dos it’s easy to get into
A>basic
MSX BASIC - the first PL of many Soviet and Russian schoolchildren
To set the 80x25 mode, type the command
width 80
You can also change the coloring of the background and letters on the screen
color 15,1,1
type the program, run it (F5), save to disk with the command
save "A:\answer.bas"

Then you can download it back.
load "A:\answer.bas"
Get listing (F4) and run again (F5)

You can go back to DOS with the command
call system
The language bribed and captivates with its exceptional simplicity and obviousness of constructions. In addition, it consisted of libraries of functions that simplify working with graphics — 8x8 and 16x16 pixel sprites, working with video memory pages, if it was necessary to do quick animation of large pieces of an image. In general, many programs have been written on it (that's just where they are now ???).
Well, well, if we want to translate our Basic code into an executable file, is it possible? Can. For this we need
SOLiD VBasic - toolchain for compiling * .BAS files into executable code of the * .COM format. Archive content is connected to the emulator
> diskb solidvbasic/
On disk - a set of utilities for compiling

Let's try to collect some "hellovord." Return to the interpreter and write the code

Save the file to disk, MANDATORY indicating the key "A" at the end, so that the source is saved as ASCII text, and return to DOs
save "b:\hello.bas",A call system
We translate the code in basic in assembler
B>vbc hello.bas
We compile
B>as hello.asm
and layout
B>ld hello=bk,hello.rel,ilib/s,basend
Everything passes ok, yup. This command apparently compiles the object code of our program with MSX-BASIC RTL libraries.

At the output we have the executable file HELLO.COM, which runs from the shell

Interesting assembler exhaust
Assembled source generated by VBC translator ; Solid Soft V-BASIC compiler V2.5 ; Demo version -- buy normal version from SOLID .Z80 ; CALLF MACRO ADR IF2 IFNDEF ADR EXTRN ADR ENDIF ENDIF CALL ADR ENDM CSEG _000A: call ?FINIT## push hl ld hl,?const+00000h call ?LDSTR## call ?INCLF## pop de call ?CPUTS## _0014: call ?EXIT?## ret ?CONST: db 048h,065h,06Ch,06Ch,06Fh,02Ch,020h,032h,030h,031h,035h,074h,068h,020h,070h,065h,06Fh db 070h,06Ch,065h,021h,000h,00h END
which cannot be called optimal, nevertheless, if you wrote on BASIC and wanted to distribute your works in the form of executable files - you had such an opportunity.
4. Turbo Pascal 3.0 for MSX-DOS and CP / M
Pascal became my second programming language. And I studied it in the "pits". Unfortunately, I do not remember the version of Pascal that we had in school. But it was a strange pascal - you want to cut me, mother, throw food waste and other filth, but that version was REGISTRATE !!! Yes, I know that Pascal is a case-insensitive language, after all, it worked for quite a long time, but this was surprising at the university - it turned out that the classics of the genre differs in this sense from what I came across. I would be extremely grateful if someone from my readers will confirm my memory and tell me what kind of pascal this is.
For the experiments, the Turbo Pascal 3.0 distribution kit from the late Borland was assembled in pieces.
This is Pascal. Turbo Pascal. Did you expect a colorful menu, a blue background and syntax highlighting? Nah, it's MSX, it's Sparta !!!
A color interface with menus and mouse support will appear a bit later (I remember that in 5.0 I was already). And before that, he was so, and very (one to one) similar to the interface of the editor that was in school pascal.
Main menu
All menu items are on hotkeys - slap the letter that is in upper case. Navigation is pretty simple. Click E. enter the name of the source code and get into the code editor
The code editor has a special feature - the function of the BS key is performed by DEL, and for BS there is a hot key.
To exit the edit mode, press Ctrl + T, compile by clicking on "C"

By default, the compilation was done directly into memory, which seriously accelerated the process. If you want to get * .COM, you had to select the compile mode to disk in the "Options" menu

and compile a binary that was already going to be much slower

but then it started normally from DOS

5. Assembler Great and Awful
All the "notorious" spektrumisty, playing enough BASIC on the ZX Spectrum sooner or later came to the conclusion that all the possibilities of this piece of iron can be squeezed only with the help of the assembler. MSX was not an exception, but I didn’t have time to join codding on “asm” (I first met the 386th assembler in 2004) and dig into this question solely for the sake of writing this article.
As for the compiler, it is, for example, in the Turbo Pascal distribution and is called GEN80.COM. Just open any text editor and start typing code.
B>akid
write such a simple code
;-------------------------------------------------- ; Sipmles asm program for MSX ;-------------------------------------------------- ld C, 09h ld DE, MESSAGE call 05h ret MESSAGE defm "I'm Z80 CPU. I'll be back!!!" defb 24h defb 0
We collect it with a team
B> gen80 hasm=hasm.asm
and get the result

To work on an assembler, you had to have an idea of ​​the
MSX-DOS system calls , the
convention on calling system functions . And this is the minimum. You may also need
the BIOS functions , and the idea of ​​direct access to the equipment of the target machine. All this information can be found on the wonderful
MSX Assembly Page where a bunch of links to useful information is gathered.
But where would I take all this in 1998 ...
In the above example, the system function 09h is called — the line is output to the screen. The function number is transmitted through the C register, the address of the string — via the DE, the call itself — by the command call 05h. The line must end with the character '$' (code 24h) otherwise the entire contents of the RAM will be displayed on the screen, and it’s good if 24h falls on the way :).
With direct hands, information and free time, you could create a lot of great things.
6. MSX-C - the dark side of the Force
Honestly, I was somewhat surprised - C on an 8-bit machine. It turned out that it was possible to program well on it, for example using
MSX-C . Downloading the Complete Package
of MSX-C . Unpack Yes, there are a lot of things.
[maisvendoo@arch-host MSX-C-package]$ ls -l 948 drwx------ 6 maisvendoo users 4096 7 19:59 bootDisk -rw-rw-r-- 1 maisvendoo users 172574 11 2013 bootDisk.zip drwx------ 2 maisvendoo users 4096 14 2012 msxC-1.10 -rw-rw-r-- 1 maisvendoo users 176785 11 2013 msxC-1.10.zip drwx------ 6 maisvendoo users 4096 15 2012 msxC-1.20 -rw-rw-r-- 1 maisvendoo users 136565 11 2013 msxC-1.20.zip drwx------ 2 maisvendoo users 4096 22 2012 msxC-Lib -rw-rw-r-- 1 maisvendoo users 95508 11 2013 msxC-Lib.zip -rwxr-xr-x 1 maisvendoo users 230623 23 2002 msxCMan.htm -rw-rw-r-- 1 maisvendoo users 33410 11 2013 msxCMan.htm.zip drwx------ 2 maisvendoo users 4096 15 2012 msxC-Utils -rw-rw-r-- 1 maisvendoo users 83571 11 2013 msxC-Utils.zip
We will be interested in the bootDisk / directory - the boot disk of the development environment.
[maisvendoo@arch-host MSX-C-package]$ ls -l bootDisk 56 -rwxr-xr-x 1 maisvendoo users 536 31 1994 AUTOEXEC.BAK -rwxr-xr-x 1 maisvendoo users 664 7 19:59 AUTOEXEC.BAT drwx------ 2 maisvendoo users 4096 15 2012 BIN -rwxr-xr-x 1 maisvendoo users 15744 1 1980 COMMAND2.COM drwx------ 2 maisvendoo users 4096 15 2012 INCLUDE drwx------ 2 maisvendoo users 4096 15 2012 MAIN -rwxr-xr-x 1 maisvendoo users 4992 1 1980 MSXDOS2.SYS -rwxr-xr-x 1 maisvendoo users 6144 23 1993 RRAMDISK.COM drwx------ 2 maisvendoo users 4096 7 19:55 UTILS
Create a boot disk using emulator
> diskmanipulator create msxc.dsk 720 > virtual_drive msxc.dsk >diskmanipulator format virtual_drive
We created a new disk and formatted it, adding the boot sector to run MSX-DOS. Now podshamani little its contents. First, we add AKID.COM to the UTILS / editor directory, because the bundled E.COM is terrible. Next, edit autoexec.bat so that the 80x25 mode is immediately turned on and the AKID.COM editor is copied to the RAM disk.
MODE 80 PATH \ SET PROMPT=ON SET ECHO=OFF SET UPPER=ON SET REDIR=ON SET TIME 24 SET DATE dd-mm-yy SET HELP=A:\HELP utils\RRAMDISK 720 SET TEMP=H:\ COPY COMMAND2.COM H:\ SET SHELL=H:\COMMAND2.COM mkdir h:\utils mkdir h:\include mkdir h:\src path=h:\;h:\utils; set include=h:\include REM Copy system to ramdisk only if ramdisk was not recovered SET COPY2RAM=NO if not exist h:\utils\e.com set COPY2RAM=YES if %COPY2RAM%==YES copy \utils\e.com + \utils\akid.com + \utils\meek.com + \bin h:\utils if %COPY2RAM%==YES copy \main h:\ if %COPY2RAM%==YES copy \include h:\include if %COPY2RAM%==YES b: if %COPY2RAM%==NO h: set COPY2RAM=
then copy all the data in the bootdisk directory / to the virtual flop
> diskmanipulator import virtual_drive MSX-C-packege/bootDisk/
And yet - we do not have enough RAM. RAM disk for MSX-C requests 720 Kb. And we have only 128 KB. So we have to connect at least 1MB of memory. In reality, we would have had to buy a memory expansion module to the “pits” —that were apparently, once we are offered to use “Roma” memory expanders in the emulator. We connect the ram1mb extension when starting the emulator
$ openmsx -exta msxdos2 -extb ram1mb -machine Yamaha_YIS-805-128R2 -diska msxc.dsk
and, apparently, everything is OK, since the ramdisk was created in the required amount and the copying of files began. We are waiting for the end of the process.

Upon its completion, go to the H: drive and see that it has created the development environment directories in C. In addition, during the boot, all the necessary environment variables were set and we can proceed to the system test

Start the editor
H:\> akid
And we fill there the code of the file hello.c

exit the editor with saving (F1 -> E). A C.BAT script is provided for the build. When feeding him the source DO NOT specify the file extension, otherwise there will be a "bjaka"
H:\> c hello
and watch the build process. The process is filterable — the source is parsed, which reveals syntax errors (CF.COM utility), function parameter check (FPC.COM), assembly code generation (CG.COM), compilation by the Microsoft macro assembler (M80.COM), and finally layout with RTL libraries (L80.COM). After everything is finished successfully (I took a long time to deal with all this before I gathered the helloWorld), you can try running the program

and ... it started!
So, yes, yes, there was C on the pits. And it was possible to write programs on it
7. Debugging
I did not find step-by-step debuggers inside the IDE, I was probably looking badly. Back in the days when I used the only debugging method, view the source code. And he could use, for example, MON80.COM, which comes bundled with Turbo Pascal 3.0.
MON80 - debugger for MSX
Offhand, working with him was not easy, so leave the topic of debugging for the continuation of the cycle. I hope you enjoyed this article.
To be continued...