MTXLib

Everything about programming, including VDP and Sound programming.
Post Reply
Bill B
Posts: 346
Joined: 26 Jan 2014 16:31

MTXLib

Post by Bill B »

I have started a new thread for this, so that I can have the first topic, which I can keep updated with any revisions, where they can be easily found.

This is a follow up of a request from Jim for an easy environment in which to develop programs for the MTX using C. In response I suggested using the Code::Blocks IDE, and developed an initial library, reproducing a number of the MTX BASIC commands.

The attached files are the latest version of this. For ease of maintenance I have split the installation into three parts. Create a top-level folder in which to do your MTX development, I suggest calling this MTX_Projects, and then unzip each of the attached files in this folder.

The three bundles are:
  • MTXLib - This contains the library source, documentation and build scripts. The library has now been extended and includes:
    • The routines reproducing the BASIC commands.
    • Routines for reading and writing disk files. These routines only read or write whole 128-byte disk sectors. It would be possible for someone to write a C wrapper around these to read or write arbitrary length records.
    • Routines for searching for files, renaming or deleting them.
    • Routines for providing direct access to the VDP memory and registers.
    • Routines for handling CTC and VDP interrupts.
  • MEMU - The Memotech emulator. This has been updated yet again. I found that when a RUN file was loaded from the command line, the disk system was not even initialised. On a real MTX, RUN files of course have to be read from disk.
  • demo - The demo program has been extended to illustrate and test a representative sample of all the routines in MTXLib. Note that not everything has been tested.
Important Note: In extending the library I discovered an issue with the way SDCC links together the code and data parts of a program. As a result, to work around this, the instructions on how to configure Code::Blocks to compile the library and MTX programs have changed. If you have already installed and configured Code::Blocks, carefully read the documentation in MTXLib\docs\codeblocks.html and update your configuration accordingly.

Other than perhaps posting the code on GitHub I have no intention of doing any more work on this in the near future.
Attachments
MTXLib_220723.zip
Library & Documentation
(458.05 KiB) Downloaded 27 times
MEMU_220723.zip
MTX Emulator
(1.73 MiB) Downloaded 28 times
demo_220723.zip
Demonstration & Test program
(5.87 KiB) Downloaded 28 times
User avatar
gunrock
Posts: 158
Joined: 28 Oct 2020 21:17

Re: MTXLib

Post by gunrock »

Thanks Bill, sterling work.

I will take a look at this some time over the summer.
Steve G
Danish Memotech MTX 512, MFX and loving it
User avatar
gunrock
Posts: 158
Joined: 28 Oct 2020 21:17

Re: MTXLib

Post by gunrock »

Hi Bill,

Just got a little time to have a look at this. Firstly, thank you - this is really well put together.

I had a couple of slight incidents during the setup (Windows 11).

I let SDCC install itself to my hdd and it wanted to go into the C:\Program Files folder but I switched it to D:\Program Files (I try to keep my C: drive install minimal). This was detected by CodeBlocks perfectly well but trying to build MTXLib led to errors complaining about the SDCC binaries being missing, primarily objecting to the space in the path.

Normally here I try two things, surround in double quotes or drop back to DOS 8.3 file and directory names. The former didn't work, but did change the error messages. The latter was problematic as my D: drive lacked the DOS 8.3 name support (didn't know that was possible, tbh). This reenabled with:

Code: Select all

fsutil behavior set disable8dot3 <DriveLetter>: 0

It doesn't add the DOS short names to existing filesystem items, so I still had to rename D:\Program Files to something else, create a new directory D:\Program Files and cut/paste the contents from the old to the new. I could then set SDCC configuration in Codeblocks to D:\PROGRA~1\SDCC, which worked.

The only other thing, was the instructions referring to using git to update the library to the latest version, but there is no public git as far as I can see.

Anyway, I managed to build the demo and run it. Now I just have to examine the demo code and the library documentation and see what I can do with it.

Thanks again.
Steve G
Danish Memotech MTX 512, MFX and loving it
Bill B
Posts: 346
Joined: 26 Jan 2014 16:31

Re: MTXLib

Post by Bill B »

Steve,

Thanks for the feedback. Spaces in a path name are a pain, need to make sure there are double quotes in all the right places.

I will have to check where I installed SDCC on my Windows 10 PC. Like you I normally avoid C, however since I was trying to make everything easy to use I probably accepted the default location in this case.
User avatar
gunrock
Posts: 158
Joined: 28 Oct 2020 21:17

Re: MTXLib

Post by gunrock »

Hi Bill,

So I went back to this and got Codeblocks to self-discover SDCC again, which finds the location in it's "long-names" form. And... this time, building code works as it should.

I definitely tried hitting to button to auto-locate before I wrote my post above (not sure what it the button name is, as I don't have my machine in front of me). I suspect it might be related to the lack of short-name support on the disk, as that's the only thing I changed. Now, I would remove short-name support and try it again, but as it warns about potential data-loss, etc. I'll just put it down to gremlins or user error on my part, instead.
Steve G
Danish Memotech MTX 512, MFX and loving it
Bill B
Posts: 346
Joined: 26 Jan 2014 16:31

Re: MTXLib

Post by Bill B »

Steve,

Thanks for the feedback. I must admit I never found the time to go back and look at my Windows installation.

With regard to hosting on GitHub, my theory was that when I got bug reports it would be easier for me to just push updates to a repository, rather than having to create a new zip file and upload it to the forum. Since there have been no bug reports (yet), I have had no incentive to create the repository :)
Post Reply