Coder Social home page Coder Social logo

aoineko-fr / msxgl Goto Github PK

View Code? Open in Web Editor NEW
113.0 15.0 9.0 192.65 MB

The MSX Game Library in C language

Batchfile 0.20% C 87.25% Assembly 6.27% C++ 1.30% POV-Ray SDL 0.06% JavaScript 1.14% HTML 3.56% CSS 0.01% BASIC 0.01% Shell 0.04% Python 0.05% Makefile 0.01% Tcl 0.12%
msx c game-engine tms9918 z80 msxgl v9938 v9958 v9990

msxgl's Introduction

MSXgl is a Game Library wrote in C and targeting MSX computers.

The purpose of this library is to provide C programmers with the whole set of functionalities to make a game with high performance. Even though a C program can never be as efficient as a program written entirely in assembler, the goal is to try to get as close as possible.

To achieve this goal, the library is dynamically compiled to allow the user to configure the functionalities to best suit his needs. Also, the most expensive features are written in assembler.

The other goal was to create a library that is totally independent of the BIOS. This makes it much easier to use the 16K of page 0. The library also provides interrupt handling code to create ROMs that always remain on page 0.

Many sample programs are available to demonstrate the different features of the library.

The MSXgl Build Tool allows you to create a final program for a large number of formats with just 1 click:

  • Plain ROM from 8K to 64K (interrupt handler can be installed in page 0),
  • Mapped ROM from 64K to 4096K (ASCII-8, ASCII-16, Konami and Konami SCC mappers),
  • MSX-DOS 1 or 2 binary program,
  • BASIC binary program.

The library supports the following devices:

  • VDP (TMS9918, V9938 and V9958) and V9990,
  • PSG (AY-3-8910), MSX-Music, MSX-Audio, Konami SCC,
  • Keyboard, Joystick, Mouse and Ninja Tap (4 joysticks adaptator),
  • ROM mapper, slot manager, and Real Time Clock (RP-5C01).

Here are also the supported audio formats:

  • Arkos Tracker 2 (AKG, AKY and AKM)
  • Trilo Tracker SCC
  • Vortex Tracker II (PT3)
  • WYZ Tracker (WYZ)
  • ayFX
  • VGM (for all supported audio chip)
  • lVGM (a light-VGM format for PSG)
  • PCM-Encoder (aka. Crystal clean PCM 8bit samples on the poor PSG)

Many thanks to the members of the MSX Resource Center and MSX Village who have been very helpful. The library is distributed under the Creative Commons BY-SA license. Tools or sources from other authors may use another free license.

Documentation:

If you have any question, feel free to join the MSXgl Discord server.

msxgl's People

Contributors

abekermsx avatar aoineko-fr avatar dgchrt avatar pvmm avatar rvanzon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msxgl's Issues

VDP_SetMode should not touch the frequency setting

When I do VDP_SetMode(VDP_MODE_SCREEN5); the VDP frequency is set to 50Hz, even if it was set to 60Hz before.
This is undesirable behavior. The VDP frequency should not be touched.

Reproduction scenario:
Program snippet:

#include "msxgl.h"
#include "vdp.h"

void main()
{
    VDP_SetMode(VDP_MODE_SCREEN5);
    while (true) {
        // no need to do anything
    }
}

Start with e.g. CBIOS MSX2+ (which runs at 60Hz normally)

After the screen has been set, you can see in the openMSX / menu / advanced / toys and utilities / info panel that the frequency has been changed to 50Hz.

VDP_Poke_16K problem

VDP_Poke_16K sometimes writes to the wrong memory address in VRAM. It's rare, but it happens. I am using the 128K version as a workaround for now. Can provide example code if needed.

Sample images

Maybe these sample images could be in a docs folder (or you can ignore this issue and just reference them from here since https://msxvillage.fr/ doesn't allow linking from outside, but github allows it). ๐Ÿ˜‰

image
image
image

Dirty screen with s_text sample in DOS2 mode

image

Step to reproduce:

  • cd projects/samples/
  • add Target = "DOS2" to s_text.js
  • ./build.sh s_text
  • open the emulator using emul/dos2/ as diska (e.g. openmsx -machine Philips_NMS_8250 -ext msxdos2 -diska emul/dos2/)

Using up and down arrows, the other fonts seem to be ok.

Skipping already compiled files

Hi,

I admire your great DOS batch file skills (seriously), but I managed to make an improvement, that makes SDCC skip files for which the compiled output is newer than the source file. This makes compiles instantaneous if only small changes were made, which helps me drink less coffee. Here is the relevant snippet:

rem ***************************************************************************
rem * COMPILE C SOURCE                                                        *
rem ***************************************************************************
if /I %FileExt%==.c (

	rem Find out if the source file changed:
	copy %File% %OutDir% /Y >NUL
	cd %OutDir%
	for /F %%i in ('dir /B /O:D %FileName%.c %FileName%.sym') do set Newest=%%i
	cd ..

	if /I !Newest! NEQ %FileName%.c ( 

		echo Skipping !FileName!.c: up-to-date.
		goto :SkipThisFile
	)

	set AddOpt=%CompileOpt%
	if /I %Optim%==Speed (set AddOpt=!AddOpt! --opt-code-speed)
	if /I %Optim%==Size (set AddOpt=!AddOpt! --opt-code-size)

	set SDCCParam=-c -mz80 --vc -DTARGET=TARGET_%Target% -DMSX_VERSION=MSX_%Machine% -I%ProjDir% -I%LibDir%\src -I%LibDir%\content !AddOpt! %File% -o %OutDir%\

	echo %BLUE%Compiling %1 using SDCC C compiler...%RESET%
	
	echo SDCC !SDCCParam!
	%Compiler% !SDCCParam!

        if errorlevel 1 ( goto :Error )

)

:SkipThisFile

Information from stackoverflow was used:
https://stackoverflow.com/questions/1687014/how-do-i-compare-timestamps-of-files-in-a-batch-script
https://stackoverflow.com/questions/14686330/how-do-i-make-a-windows-batch-script-completely-silent
because I don't know much about batch files. ;)

Greets,
Jacco.

Bug in memory.c

There is a bug in:
void* Mem_DynamicAlloc(u16 size)
The bug is here:
struct MemChunkHeader* newChunk = (struct MemChunkHeader*)(chunk + needSize); // New free sub-chunk
chunk has to be converted to u16 or you allocate 4 times more bytes. This is the fix

struct SptChunkHeader* newChunk = (struct SptChunkHeader*)(((u16)chunk) + needSize); // New free sub-chunk

Cos and Sin tables are unsigned

Cos and sin tables should be signed, this is causing the s_clock.c example to fail with SDCC 4.4
If you need to keep trigonometric tables unsigned you need to cast then to signed each time you use them
In attach the s_clock.c fixed without changing the trigonometric tables

s_clock.c.txt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.