ubox MSX lib

Page 1/4
| 2 | 3 | 4

By reidrac

Expert (98)

reidrac's picture

30-12-2020, 20:49

Hi,

After postponing it for too long, I finally completed all the steps to make available as Open Source some libraries that I wrote when developing Night Knight and Uchusen Gamma.

It is basically is a set of libraries and tools to make MSX games using the C programming language, using SDCC.

I know that there are other projects that provide something similar (even bigger), like Fusion-C; but it happened that the libraries almost appeared naturally when making the games, so I thought it would be nice to share the code hoping that it would be useful.

Unfortunately there's a lot of work if you want to do things properly: write documentation, clean up things to make them easier to use, make an example game; and after a good start last Christmas, it got put on hold because other projects.

I didn't intend to cover all or make the perfect libraries; they are mostly good ;) AND easy to use (I hope) thanks to a narrow scope that I guess it won't be for everybody!

Anyway, I don't want to put much more time on this, so support will be on "best effort" basis. I used the opportunity to improve things and I'm quite pleased with the project, so I will use it to make more MSX games!

The project page with the docs is: https://www.usebox.net/jjm/ubox-msx-lib/

The GitHub repo: https://github.com/reidrac/ubox-msx-lib

Shameless plug: my kofi page :D

Enjoy!

Login or register to post comments

By tfh

Prophet (2999)

tfh's picture

30-12-2020, 21:23

Hi Juan,

Thank you for your contributions to the MSX-Scene. We're also looking forward for your future MSX Games Smile I really like Night Knight & Uchusen Gamma!

By geijoenr

Champion (275)

geijoenr's picture

30-12-2020, 21:32

cool, I see you added Arkos Tracker support.

I was struggling a little bit with the way they suggest to convert the rasm sources to any format, the decompiler doesn't seem to work well when translating to SDCC. I see you just "cut the gordian knot" by compiling it using rasm.

By reidrac

Expert (98)

reidrac's picture

30-12-2020, 21:37

@tfh: thanks!

@geijoenr: there's no other way if you want to customise the player according to the songs/effects of the project. I followed the official docs and it works; with some minor caveats (like rasm making all the exportable symbols uppercase!).

Also I used AKM in ROM mode, whilst my experience so far was with AKW in RAM (avoiding using Disark!); so integrating AKM has been very interesting. At the end, all ROM and it uses only 222 bytes of RAM!

Considering how good it is the player, that the tracker is multi-platform (I use Linux exclusively, so I don't have many options Big smile), I'm thankful!

At the end it is quite seamless; take a look at the docs and the example game. Even if you don't use the libs, it may help you on that part.

By reidrac

Expert (98)

reidrac's picture

31-12-2020, 10:24

Updated the lib to 1.0.1; I won't be announcing here releases (if you use GH, you can subscribe to those using the "Watch" button), but it was an omission in the README re: Disark requirement that made harder to compile the example game.

Cheers!

By santiontanon

Paragon (1519)

santiontanon's picture

31-12-2020, 14:47

I know I'm not the target audience, but I was looking into the code just out of curiosity. Looks very interesting! I hope lots of people use it! I never used the Arkos tracker, but I've been curious about it, I might take this as an example to check it out Smile

By ericb59

Paragon (1048)

ericb59's picture

02-01-2021, 10:42

Great ! Thank you for the Share Juan.

By ~mk~

Champion (303)

~mk~'s picture

03-01-2021, 04:47

Hi reidrac,

Thanks for sharing your code, I will definitely learn a lot from it.
I am struggling a bit to compile the example game under Windows environment.
Disclaimer: It is the first time I am using SDCC. Shocked!

No problem compiling the libraries (mplayer.lib, spman.lib, ubox.lib) and for the game I already compiled the "data" part successfully. I can see files enemy.h, map.h, player.h and tiles.h were generated and the contents make sense, with all graphics and data converted from the png images to hex code (nice work on the python tools, btw).

But I am having trouble with the "src" part.
First of all, I renamed aux.c and aux.h to _aux.c and _aux.h respectively, because it is not possible to create a file with the name aux.* (no matter which extension) under Windows environment. I also changed the #includes that were reffering to them. I think I took care of that and it should work.

Then, I had trouble with the command that generates Makefile.deps, but I think I understood what was trying to write and generated it by hand. It is quite possible I made a mistake here. If you can, please let me know if the contents of my Makefile.deps are correct, please:

../build/data.rel: data.c ../generated/tiles.h ../generated/player.h ../generated/enemy.h ../generated/map.h
../build/game.rel: game.c ../../include/ubox.h ../../include/spman.h ../../include/ubox.h ../../include/mplayer.h _aux.h main.h game.h ../generated/map.h ../generated/player.h ../generated/enemy.h
../build/main.rel: main.c ../../include/ubox.h ../../include/mplayer.h _aux.h game.h main.h ../generated/tiles.h
../build/_aux.rel: _aux.c ../../include/ubox.h _aux.h

So, I went on and tried "make src" but it fails while compiling main.c:

sdcc -mz80 --Werror -I../../include -I../generated --fsigned-char --std-sdcc99 --opt-code-speed -L../../lib -L. --no-std-crt0 --fomit-frame-pointer -c main.c -o ../build/main.rel
main.c:97: error 78: incompatible types
from type 'const-unsigned-char [32] [110] code'
  to type 'unsigned-char generic* fixed'
main.c:99: error 20: Undefined identifier 'tiles_colors'
main.c:99: error 20: Undefined identifier 'tiles_colors'
main.c:99: error 154: converting integral to pointer without a cast
from type 'int fixed'
  to type 'unsigned-char generic* fixed'
make: *** [../build/main.rel] Error 1

Anyway, I will keep working on it. I want to let you know so you can attempt to compile under Windows yourself if you are interested. That will definitely help you improve the code and the scripts so they are more compatible.

I am using:
SDCC 3.9.0 (windows 32 bit)
Win-builds 1.5.0 for GCC compiler and libraries
GNU utilities for Win32 - http://unxutils.sourceforge.net/

By reidrac

Expert (98)

reidrac's picture

03-01-2021, 10:44

First of all, I don't have Windows to test; but your report is good and I can make some changes to make it easier to work in Windows (e.g. the aux.* :facepalmSmile.

The Makefile.deps is to tell make your dependencies; and you can use SDCC to do it kind of automatically *per file*, so I use find and sed to generate exactly what it is needed. That part should be dynamic, otherwise if you change your code as you make your game, it will be wrong. I'll make a python tool to make this compatible with windows.

"make src"; do you mean "make game" from the top directory? The error suggests SDCC is failing to find tiles_colors, so that could be a problem with that include not being found or perhaps having something that works different in windows?

I've updated the repo; if you checkout master, it should have some fixes already (like the aux rename).

Thanks for the report!

By reidrac

Expert (98)

reidrac's picture

03-01-2021, 11:54

I've pushed some changes with a new tool to replace the shell commands to generate the dependencies.

Can you get the code from master and run "make clean" "make game"? And let's see how far we get now!

EDIT: I also thing your last issue could be because something failed generating the include files and unfortunately in those cases you need to run "make clean" and "make game" again. Crossing fingers, I think it will build after you get the code from master!

When I have some time I'll see to setup GitHub actions so the code builds in Linux, Windows and (eventually) on Mac; so I can provide with a "how to" for those systems that is less obvious how to setup things AND I know the code builds in all supported platforms.

By ~mk~

Champion (303)

~mk~'s picture

04-01-2021, 01:51

Awesome, I will try again as soon as possible, next weekend probably.
Sorry, the command wasn't "make src". Because of the errors I was getting, I decided to build the different parts separately, so by "make src" I meant, all previous steps were succesful and within the game/src folder, simply "make".
I will let you know how it goes next time, thank you!

Page 1/4
| 2 | 3 | 4