FUSION-C the C library for MSX (SDCC)

FUSION-C the C library for MSX (SDCC)

van ericb59 op 15-01-2019, 09:27
Onderwerp: Development
Talen:

FUSION-C Is a C library, 100% dedicated to MSX. Functions dedicated to the hardware of the MSX are available in order to easily code games or tools for our machines: MSX1, MSX2, MSX2 + or MSX Turbo-R.
FUSION-C is intended to make programs that run under MSX-DOS 1 or 2, this does not prevent to transform your programs in ROM.
With FUSION-C you have more functions than under Basic, you will find functions for

  • Screen modes management from screen 0 to screen 8
  • Drawing
  • Copy of graphic area in VRAM or RAM
  • Sprites management
  • File management under MSX-DOS
  • Keyboard and joystick control
  • Management of the Memory Mapper under MSX-DOS2
  • Management of the PSG for the sound part
  • Player of music files .PT3
  • AYFX music file player for sound effects
  • etc

FUSION-C use the Cross Compiler C, SDCC (Version 3.6 preferably), compilations scripts are provided with the library.
The library is provided with all the source codes, so you can modify it and change it to your needs.

For simplicity I recommend a suitable tools-chain, compatible for Mac OS / Windows / Linux. This tools-chain consists of SDCC 3.6, the Hex2Bin module that converts the code from SDCC into a code usable under MSX-DOS, the code editor Sublime Text, and openMSX emulator.
Once the tools-chain is configured, a simple press of CTRL + B in Sublime Text starts the compilation of your code and its execution in openMSX.

The configuration of the Tools-chain, is explained in a 280 pages 's Paper book "Fusion-c Complete journey" available on Amazon for 12.99 Euros.
This book in English, supplements the documentation provided with the library by essential information about the MSX, its environment, the configuration of the tool-chain, and for beginners all the information to start coding in C, as well as a comparison of MSX Basic VS Fusion-C instructions.
Buy the book! it will be a kind of reward for the work done!

Fusion C is available for free at: www.repro-factory.com
in the FUSION-C section.

You can leave here, your comments, suggestions, problems & bugs encountered ...

Have a good coding day !

Media browser (5)

  • FUSION-C the C library for MSX (SDCC)
  • FUSION-C the C library for MSX (SDCC)
  • FUSION-C the C library for MSX (SDCC)
  • FUSION-C the C library for MSX (SDCC)
  • FUSION-C the C library for MSX (SDCC)

Reacties (57)

Van gdx

Prophet (2927)

afbeelding van gdx

15-01-2019, 09:42

Good job Eric! I'm impressed.

Van Grauw

Ascended (8318)

afbeelding van Grauw

15-01-2019, 09:56

Sounds like a great library for MSX C programmers, and also it's interesting that you combine it with a book! Seems really useful for starting C programmers especially! A lot of effort must've gone into this.

Van alexito

Hero (522)

afbeelding van alexito

15-01-2019, 10:02

I bought mine from Amazon with Free Shipping.

Sound very interesting because I never really programming in C ever.

Great job Eric.

Wink

Van fr3nd

Expert (87)

afbeelding van fr3nd

15-01-2019, 10:18

It looks promising. Will the source code be released? Is it possible to collaborate to the project in GitHub?

Van Grauw

Ascended (8318)

afbeelding van Grauw

15-01-2019, 10:26

@fr3nd "Fusion C is available for free at: www.repro-factory.com in the FUSION-C section."

Did you miss that part? It was a bit hidden in a little sentence at the bottom :).

Van Pencioner

Paladin (913)

afbeelding van Pencioner

15-01-2019, 10:26

Great, thanks Eric!

Van ericb59

Paladin (855)

afbeelding van ericb59

15-01-2019, 11:13

Fusion-c library is provided with all source code (C and ASM source codes are include), also include a script to compile the library with new functions, or if you make changes in functions's sources code.
You can collaborate of course. If you have idea, new functions, bugs, let me know. All your ideas and new functions can be included in further release ... Share you work Big smile

Van fr3nd

Expert (87)

afbeelding van fr3nd

15-01-2019, 12:11

Yes, I saw the link and I went there, but I got confused when I had to go trough a checkout and registering process to download it... I guess I was expecting something more "developer-friendly" to make collaboration easier for everyone...

But please, don't get me wrong... I think this is a really interesting project that can make much easier to develop using modern tools, I just would have liked it to be in GitHub (or Bitbucket) so it's more available to everyone.

Van ericb59

Paladin (855)

afbeelding van ericb59

15-01-2019, 14:07

@fr3nd : Yes, GitHub is great and I'm using it also. I've chosen to publish FUSION-C via Repro-factory, to keep an eye on its distribution, i'm just curious to know how many people will download it.
Anyway in the futur the library will be available on GitHub too...

Van fr3nd

Expert (87)

afbeelding van fr3nd

15-01-2019, 15:12

ericb59 wrote:

Anyway in the futur the library will be available on GitHub too...

I'm glad to hear that! kudos for the project! I can't wait to test it.

Van Danjovic

Expert (67)

afbeelding van Danjovic

15-01-2019, 15:14

Cool! Gotta try it out on Linux!

Van wimpie3

Master (254)

afbeelding van wimpie3

15-01-2019, 16:11

"this does not prevent to transform your programs in ROM"

How do you guys convert an MSX DOS program to a ROM version?

Van ericb59

Paladin (855)

afbeelding van ericb59

15-01-2019, 16:19

@wimple3 : with disk2rom utility (included in tools folders). Ok this is not suitable for 32K or 64K rom size but in most cases you can make a rom version of any floppy disk, and put it in a 512K or 1024K Cartridge.

Van Victor

Champion (468)

afbeelding van Victor

15-01-2019, 18:27

Congratulations Eric and Fernando...

Thanks for this grat work!

Van wimpie3

Master (254)

afbeelding van wimpie3

15-01-2019, 18:52

OK, so this basically means the program cannot be used to make games for the MSDEV competition.

Van ToriHino

Champion (348)

afbeelding van ToriHino

15-01-2019, 19:39

wimpie3 wrote:

OK, so this basically means the program cannot be used to make games for the MSDEV competition.

You can always submit for the MSX Freestyle category, as the rules state:
There’s no limit at all. Feel free to use whatever you want (graphic expansions, sound extensions, add-ons, later machines than MSX1, etc.)

Van Wolverine_nl

Paladin (1022)

afbeelding van Wolverine_nl

15-01-2019, 20:53

There is a guide online how to create a rom file from SDCC, several, here is one.
But Fusion-C probably has a few libraries using things specifically for DOS 1/2, also probably some CALLSLOT resolves. These need to be altered for a ROM project of course.

I think this is great, thanks Eric! :)

Van Josb

Master (196)

afbeelding van Josb

15-01-2019, 21:28

Thanks, I'm stunned by your great job.

Van rvanzon

Supporter (15)

afbeelding van rvanzon

15-01-2019, 22:15

Great work Eric and Fernando!
Thanks! Smile

Van wimpie3

Master (254)

afbeelding van wimpie3

16-01-2019, 06:50

Is it true what Wolverine says?

Van La Gaseta Msx

Supporter (13)

afbeelding van La Gaseta Msx

18-01-2019, 14:12

>>¿How do you guys convert an MSX DOS program to a ROM version?

>> with disk2rom utility (included in tools folders). Ok this is not suitable for 32K or 64K rom size but in most cases you >>can make a rom version of any floppy disk, and put it in a 512K or 1024K Cartridge.

As far as my understanding arrives, you can't.
As MSX-DOS is in a ROM any you are trying to executing another ROM.
Both occupuies the same logic space. Thus, it is not possible.

SDCC with tools can produce a .COM file
But a COM file can not be executed in a ROM.

Van ericb59

Paladin (855)

afbeelding van ericb59

18-01-2019, 16:13

La Gaseta Msx wrote:

As far as my understanding arrives, you can't.
As MSX-DOS is in a ROM any you are trying to executing another ROM.
Both occupuies the same logic space. Thus, it is not possible.

SDCC with tools can produce a .COM file
But a COM file can not be executed in a ROM.

Just download and try Brick Breaker demo
http://msx.ebsoft.fr/bbreaker/

as you see this is Game Demo made with FUSION-C. You have the DISK version, and the ROM Version
Rom version was made with DISK2ROM utility.

Van Grauw

Ascended (8318)

afbeelding van Grauw

18-01-2019, 19:00

La Gaseta Msx wrote:

As far as my understanding arrives, you can't.
As MSX-DOS is in a ROM any you are trying to executing another ROM.
Both occupuies the same logic space. Thus, it is not possible.

SDCC with tools can produce a .COM file
But a COM file can not be executed in a ROM.

You can, it works very well.

How it works is the first 16K of the ROM is a diskROM, one which interfaces with the ROM mapper instead of a disk controller. The remainder of the ROM then contains a disk image, a ROM disk very similar to how a RAM disk works. The program is loaded in the computer's RAM memory exactly like a DOS game.

Downside is that it requires a 64K MSX, and that data needs to be loaded rather than accessing ROM banks directly. Upside is that you have the DOS environment with the full 64K of TPA RAM space available, rather than the first 32K to 48K occupied by ROM (BIOS + ROM data).

The large TPA is useful for any program, but especially for C programs I think. And it's easy to install a custom ISR and to use self-modifying or generated code, and on turboR it will run in fast internal memory. Lastly you can program for one environment and release both a downloadable disk and cartridge ROM version with little extra effort.

Van gdx

Prophet (2927)

afbeelding van gdx

19-01-2019, 01:17

wimpie3 wrote:

Is it true what Wolverine says?

Yes because Ericb59 chose the simplest method for developers. Maybe, with next version, we will be able to choose the execution environment of the program during compilation. There are several possibilities on MSX (MSX-DOS command, Disk that boot on sector 0, Binary file under Basic, then ROM 16k, 32k, 48k/64k and megaroms, raw file).

I hope that Fision-C will become so complete someday. I think this will depend on the project participants. For the moment, I imagine that it is not even optimized but it is already a good tool.

Van ToriHino

Champion (348)

afbeelding van ToriHino

19-01-2019, 13:25

I received the book today, looks great!

Van sinus

Expert (78)

afbeelding van sinus

19-01-2019, 19:20

What I've seen so far is really well done and rational, it breaks with the austerity and complexity of previous options to get to C language on MSX. Of course I am willing to support your efforts, I've bought the book and will try to contribute somehow some day Tongue
I personnaly stood among those who had prefered relying on a proper C language solution instead of developping in a specific Z80 or MSX related language (ASM or compiled BASIC however good they are). For sure I much welcome the energy involved in Fusion-C, authors gathering others' contributions as a shared tools pool. I hope this package with help 'new' guy to join the force and unleash their skills to create even more quality software: a virtuous circle Wink
Thanks,
Sinus

Van ericb59

Paladin (855)

afbeelding van ericb59

19-01-2019, 19:35

Thanks
I also hope the developers will use FUSION-C, and the Library will evolve with the needs of the coders. Do not forget to share your work, so that everyone can enjoy, and thus make a futur version 2.0
Wink

Van alexito

Hero (522)

afbeelding van alexito

20-01-2019, 17:09

I received mine too. Look awesome. Thanks Eric.

Van karloch

Prophet (2058)

afbeelding van karloch

20-01-2019, 23:57

I always wanted a good set of libraries and extensive documentation for developing C in MSX. I already ordered the book Smile Combining FUSION-C with ASMLIB I think many interesting things can be achieved!

Van hbarcellos

Hero (561)

afbeelding van hbarcellos

21-01-2019, 03:25

If it's coming from Eric = instant buy for me.
Congratulations! Open Source, Amazingly Useful stuff, optional purchase for a useful and collective item (Book).
All the Best guys.

Van wimpie3

Master (254)

afbeelding van wimpie3

21-01-2019, 17:08

Got the book yesterday and I'm a bit disappointed. This is basically a reference guide, not a programmer's manual. Perhaps I was expecting too much. Lots of English mistakes too.

Van ericb59

Paladin (855)

afbeelding van ericb59

22-01-2019, 12:26

@wimpie : Yes there are English mistakes. I done it with my very bad knowledge of Shakespeare's spoken language ! You can point to me the mistakes and I will correct them.
It's not a programmer's guide, my goal was not to make a C learning Book, there are many books, or websites about that. But, there is a complete C memento that beginners can read to learn C. In any case you must know at least the basics of programming.

@hbarcellos : thank you for your support :-)

Van wimpie3

Master (254)

afbeelding van wimpie3

22-01-2019, 12:50

@ericb59 What I expected (and what I would have liked personnaly) is a bit more guidance on how to make sprites move, how to create tiles, basically how to create software on the MSX. The book is now only a reference for the libraries (which is good) and partly an introduction in C (which is also good). However, there is not much material that glues both together. Most examples in the second part are limited to the standard SCREEN 0. Which is not bad, you have to start at the beginning. But begin the book with a library reference talking about screen modes, sprites, sound, followed by a C introduction talking about pointers, variables, functions... without a connection between both sections. How to create sprites? Tiles? Music? This means there is still a lot left to explore and learn for people not used to work with the MSX. The book is IMHO probably too easy for someone who knows the MSX, but too difficult for beginners.

Van wimpie3

Master (254)

afbeelding van wimpie3

22-01-2019, 12:51

(arghhh... why can't you correct spelling mistakes here on this forum?)

Van ericb59

Paladin (855)

afbeelding van ericb59

22-01-2019, 13:19

wimpie3 wrote:

(arghhh... why can't you correct spelling mistakes here on this forum?)

I do not understand what you 're meaning

Making sprites with Fusion-c is explained in the Book.
An you're right, this is not a guide for people who never tried to code something. This was not my purpose.

Van DarkNekros

Supporter (2)

afbeelding van DarkNekros

23-01-2019, 23:33

Thanks Eric for writing a great book (a little hard to read some times (typos, incomprehensible paragraphs, etc), but with a good content).
The first thing I thought about it was: " Shocked! It's a very huge book!!", but finally it comes handy when you have to see the screenshots or read the code. I've almost finished it and now it's time to write down some code!!

Van Caetano

Supporter (1)

afbeelding van Caetano

24-01-2019, 15:19

Would be nice to have a digital version of the book, take long time to ship to Brazil Cool

Van alexito

Hero (522)

afbeelding van alexito

25-01-2019, 00:22

I have already installed the Fusion C Toolchain + SDCC + SublimeText on my Windows Vista 64 (Athlon X2 CPU 3.2Ghz)
Compiled Successfully the "HELLO WORLD" and "HARDWARE SCROLL" C Programs.

I just follow the instructions in the book everything works good for me at the moment.

Thanks Eric.

Van ericb59

Paladin (855)

afbeelding van ericb59

25-01-2019, 15:46

alexito wrote:

I have already installed the Fusion C Toolchain + SDCC + SublimeText on my Windows Vista 64 (Athlon X2 CPU 3.2Ghz)
Compiled Successfully the "HELLO WORLD" and "HARDWARE SCROLL" C Programs.

I just follow the instructions in the book everything works good for me at the moment.

Thanks Eric.

I'm really happy to read such answer Wink

Van ToriHino

Champion (348)

afbeelding van ToriHino

26-01-2019, 01:12

Setting up the tool chain indeed worked well by following the steps in the book. Already made some steps on the first project Smile

Van wilsonpilon

Champion (273)

afbeelding van wilsonpilon

28-01-2019, 15:47

Hi...

I just received my book. I'm already reading and configuring the system. good job!

Van chouimat

Supporter (2)

afbeelding van chouimat

05-02-2019, 18:44

Hi,
I just received the book, looks good

Van Fideton

Supporter (1)

afbeelding van Fideton

20-02-2019, 22:08

I have just received my book too. Great work!

Van SvaboMSX

Supporter (12)

afbeelding van SvaboMSX

02-05-2019, 19:44

Mine arrived today !
looking foward for some experiments and learnings!
Thank you for your work!

Van SvaboMSX

Supporter (12)

afbeelding van SvaboMSX

03-05-2019, 01:07

Somehow I got it running on my side.
After successful compilation always a new instance of openmsx ist started.

So I modified "compil.bat" that openmsx is only started once. (it is faster if rapidly change source code and compile again for testing

I found here:https://stackoverflow.com/questions/162291/how-to-check-if-a-process-is-running-via-a-batch-script a dos snippet

and modified "compil.bat" at the lower section to this:

:Emulator
SETLOCAL EnableExtensions
set EXE=openmsx.exe
FOR /F %%x IN ('tasklist /NH /FI "IMAGENAME eq %EXE%"') DO IF %%x == %EXE% goto FOUND
echo Not running
goto FIN
:FOUND
echo Running
goto end
:FIN
openMSX\openmsx.exe -machine Philips_NMS_8255 -ext msxdos2 -diska dsk\
:end

Van SvaboMSX

Supporter (12)

afbeelding van SvaboMSX

03-05-2019, 01:50

hey... it's me again...

I have problem to compile, when I print using "Print" and then declare a variable.
Without Printing before declaring a variable the routine works.
Any guidance?

input:

//
// Fusion-C
// My First Program in C
//

#include "fusion-c/header/msx_fusion.h"
#include 

void main(void) 
{
	PrintNumber(5);  // <<--- when I leave this out, then it is compiling. (?)
  	int dk_v = 5;
  	while (dk_v>0){
  		PrintNumber(dk_v);
  	dk_v--;
  	}
  	 Print ("\nhal\n");

}
 

output:

-------- Compilation of : 
test
.
test.c:12: syntax error: token -> 'int' ; column 6
test.c:13: error 20: Undefined identifier 'dk_v'
test.c:14: error 20: Undefined identifier 'dk_v'
test.c:15: error 20: Undefined identifier 'dk_v'
Done.
Running
[Finished in 0.2s]

Van ToriHino

Champion (348)

afbeelding van ToriHino

03-05-2019, 07:31

It is only allowed to do variable declarations at the beginning of scope block or function, so use something like:

void main(void) 
{
        int dk_V;

	PrintNumber(5); 
  	dk_v = 5;

And even better, as a good practice always initialize your variables with a value (be it f.e. either 0 or in your case 5);

Van SvaboMSX

Supporter (12)

afbeelding van SvaboMSX

03-05-2019, 08:44

excellent. It is working as you said.
Thank you.

Van ericb59

Paladin (855)

afbeelding van ericb59

02-06-2019, 08:50

After more than 220 downloaded Package since 5 months, the world wide's MSX community proved its interest in a complete easy language package usable on recent computers to program our good old MSX !

The new version 1.1 of FUSION-C is available.[/b]

Now more stability, less memory used in compiled programs, a lot BUGS fixed, and new features available.
Some functions have been fully reprogrammed to consume less memory and be faster.
The new functions now allow:
- Manage an MSX mouse
- Have a real time timer variable
- Decompress RLEWB data (Compressor include)
- Read and write data directly on disk's sectors
- Play Samples via a Covox module
- Manage an automatic interruption
- the new crt0 now initialize global variables.
and more...

FUSION-C 1.1 is always free, downloadable from www.repro-factory.com
The book FUSION-C Complete Journey has been updated and corrected, is still available on Amazon:
https://www.amazon.com/FUSION-C-MSX-Library-complete-journey/dp/1730828612/ref=sr_1_3

Code, play, publish!

Eric.

Van ToriHino

Champion (348)

afbeelding van ToriHino

02-06-2019, 18:53

Eugeny just released code for TCP/IP UNAPI for Fusion-C on the GR8NET (or any UNAPI compatible device), which can be found here. See the GR8NET manual for more details

Van st1ckman67

Supporter (1)

afbeelding van st1ckman67

16-06-2019, 19:14

Ok, I've just got the new updated 1.1 book, downloaded and installed everything as per the book instructions.
Everything compiles (test.c) without issue in Sublime and the emulator kicks up.
I then get to the a:\ prompt and I type test and hit enter only to be presented with "ooooooooooooooo" instead of "Hello MSX World".
Have I not done something right, I've also tried compiling the console.c example and it just prints junk to the screen but works perfectly.

Any help would be appreciated.

Van sergarbes

Supporter (14)

afbeelding van sergarbes

21-06-2019, 10:55

I have followed all the steps of the book with an HB-F700P on a macOS Mojave.

Everything compiles correctly. But when executing test.com it prints junk with the same length of the text you want to print.

I have tried the other functions of the msx_fusion.h library as PrintNumber and the same thing is happening.

I have also tried with stdio.h and printf and printed correctly.

What am I doing wrong with the msx_fusion.h library?

Thanks for your help and happy msx coding!

Van sergarbes

Supporter (14)

afbeelding van sergarbes

21-06-2019, 20:10

This is the code

//
// Fusion-C
// My First Program in C
//
//#include
#include "fusion-c/header/msx_fusion.h"

void main(void)
{
//printf("Hello world!\n");
Print("Hello world!");
}

And this is the result

Screenshot

Van fregarni

Supporter (5)

afbeelding van fregarni

02-07-2019, 13:41

Hello, I have the same problem with new version 1.1 of Fusion-C Library when I compile test.c file (shown "ooooooooooooooo" instead of "Hello MSX World"). I've tried to compile fusion.lib from sources and I have the same result. Any solution founded?

Thanks.

Van ToriHino

Champion (348)

afbeelding van ToriHino

02-07-2019, 20:50

There is a separate thread for issues related to FUSION-C, so it's better to post your question over there

Van sergarbes

Supporter (14)

afbeelding van sergarbes

04-07-2019, 17:48

ToriHino wrote:

There is a separate thread for issues related to FUSION-C, so it's better to post your question over there

Done. Thank you for the info.

Van ericb59

Paladin (855)

afbeelding van ericb59

14-09-2019, 11:00

The new version of FUSION_C 1.2 is available.

What's up...
Fixes, optimizations, and new features, including MSX2 VDP features, Support of the V9990 and GR8NET TCPIP

- CheckBreak: Check Break sequence in MSX-DOS console

- PutCharHex: Pint Hex conversion of a char on console

- PrintHex: Print Hex conversion of an integer on console

- HMMM: Vram to Vram

- LMMC: Ram to Vram Fast Copy Function

- YMMM: Vram to Vram Fast Copy to Y Position

- HMMV: High speed draw filled rectangle

- LMMV: High speed filled rectangle with operator

- MouseReadTo: Fast Read mouse state and buttons to variable structure

- Itoa: Integer to Char conversion

- StrReverse: Reverse a string

- BoxFill: Fast Draw of a box on screen (easy version of HMMV / LMMV)

- BoxLine: Fast Draw of an empty box on screen

Added support for the V9990 by porting the TeamBomba's GFX9K graphics library to SDCC (Thanks to Sylvain). (beta, no manual, but a .h file to read!)

Added TCP TCP Support for GR8NET Cartridge (Thanks to Eugeny) (beta. No manual but a .h to read!)

The library is still free.
To download this version, 2 possibilities:
on the Repro-Factory Site: http://www.ebsoft.fr/shop/es/19-fusion-c
or on GitHub: https://github.com/ericb59

Be happy and code for MSX !
See you