Code Monkey home page Code Monkey logo

libyaul's Introduction

Yet Another Useless [Saturn] Library

About

Yaul is an open source development kit for the SEGA Saturn. The SDK as a whole aims to minimize the painful experience that is developing for the Saturn by providing lightweight abstractions between your program and the hardware.

Documentation

Visit yaul.org.

Installation

Windows

MSYS2

If you already have MSYS2 installed, follow the directions below to setup access to the package repository. If not, download and install MSYS2 here first, then continue to follow the instructions below.

  1. From the Start menu, open MSYS MinGW 64-bit.

  2. Open /etc/pacman.conf and at the end of the file, add the following:

    [yaul-mingw-w64]
    SigLevel = Optional TrustAll
    Server = http://packages.yaul.org/mingw-w64/x86_64
    
  3. Go back to the shell and sync and refresh the databases.

    pacman -Syy
    
  4. Install everything.

    pacman -S \
      yaul-tool-chain-git \
      yaul \
      yaul-emulator-yabause \
      yaul-emulator-mednafen \
      yaul-examples-git
    
  5. Once all the packages have been installed, close the existing shell and start a new one.

  6. Test your environment by building an example.

Linux

Arch

Follow the directions below to setup access to the Arch Linux package repository, or build the packages yourself.

  1. As root, open /etc/pacman.conf and at the end of the file, add the following:

    [yaul-linux]
    SigLevel = Optional TrustAll
    Server = http://packages.yaul.org/linux/x86_64
    
  2. Sync and refresh the databases.

    pacman -Syy
    
  3. Install everything. Keep in mind that yaul-emulator-kronos is only available on Linux. For MinGW-w64, install yaul-emulator-yabause instead.

    pacman -S \
      yaul-tool-chain-git \
      yaul \
      yaul-emulator-mednafen \
      yaul-emulator-kronos \
      yaul-examples-git
    
  4. Once all the packages have been installed, close the existing shell and start a new one.

  5. Test your environment by building an example.

Debian based

There are currently no .deb packages available. You will need to build Yaul.

MacOS X

There are currently no packages available. You will need to build Yaul.

Docker

A Dockerfile file is available.

Building tool-chain from source

Follow the instructions found in the build-scripts/ directory. Please note that you still need to build Yaul.

Setting and building Yaul manually

Cloning the repository
  1. Clone the respository

    git clone "https://github.com/ijacquez/libyaul.git"
    
  2. Initialize the submodules

    git submodule init
    
  3. Update the registered submodules

    git submodule update
    

Setting up the environment file
  1. If the tool-chain package was installed, copy the template $TOOL_CHAIN_PREFIX/sh2eb-elf/yaul.env.in to your home directory as .yaul.env. This is your environment file.

    Otherwise, copy yaul.env.in from the root of this repository to your home directory as .yaul.env.

  2. Read the environment file .yaul.env into your current shell.

    source $HOME/.yaul.env
    
  3. Reading the environment file needs to be done every time a new shell is opened. To avoid having to do this every time, add the line below to your shell's startup file.

    echo 'source $HOME/.yaul.env' >> $HOME/.bash_profile
    

    If .bash_profile is not used, use .profile instead. This is dependent on your set up.

Configuring the environment file

Open $HOME/.yaul.env in a text editor and change the following to define your environment:

  1. Set the absolute path to the tool-chain in YAUL_INSTALL_ROOT.
  2. If necessary, set YAUL_PROG_SH_PREFIX and YAUL_ARCH_SH_PREFIX.
  3. Set the absolute path to where the libyaul source tree is located in YAUL_BUILD_ROOT.

Setting the wrong values may result in compilation errors.

Building
  1. Build and install the supported libraries.

    SILENT=1 make install-debug
    

    If any given library in Yaul is being debugged, use the install-debug target instead. Either release or debug can currently be installed at one time. It's possible to switch between the two in the same installation.

    To find more about other targets, call make list-targets.

  2. Build and install the tools.

    SILENT=1 make install-tools
    
  3. Test your environment by building an example.

Building and running an example

  1. If you've built Yaul manually, check out any example in the examples submodule. Otherwise, go to /opt/yaul-examples/.

  2. Copy the vdp1-zoom-sprite directory to your home directory

    cp -r /opt/yaul-examples/vdp1-zoom-sprite $HOME/
    
  3. Build vdp1-sprite

    cd $HOME/vdp1-zoom-sprite
    SILENT=1 make clean
    SILENT=1 make
    
  4. Use Mednafen to test the example.

    mednafen vdp1-zoom-sprite.cue
    

    If Mednafen is unable to find the Sega Saturn BIOS image, please confirm that,

    1. The file is named mpr-17933.bin and that it exists relative to the firmware directory under the Mednafen base directory.

    2. The calculated MD5 hash of the file is 3240872c70984b6cbfda1586cab68dbe.

  5. Success! ๐ŸŽ‰

Contact

You can find me (@mrkotfw) on Discord.

libyaul's People

Contributors

chuidc avatar hitomi2500 avatar ijacquez avatar mistydemeo avatar razor85 avatar robertoduarte avatar tiagosr 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

libyaul's Issues

Add Mac OS X to CI

Testing needs to be for Mac OS X.

Modifications need to be done to .travis.yml and the tool chain needs to be built as well.

Digital Pad "pressed" button behavior

when using something like :
joyA = g_digital.pressed.button.a;

the result is that it is always true even if the button is not released (like "held") or like autofire :)

USB Cart no longer supported?

While compiling the library, I had the option for the USB cart set, but it built yaul.h with the following

#if HAVE_DEV_CARTRIDGE != 0
#error "Invalid HAVE_DEV_CARTRIDGE value"
#endif

Cart includes

Looking at the current yaul.h, shouldn't the section for CS0 be more like this?

/* CS0 */
#if HAVE_DEV_CART == 1
#include <scu/bus/a/cs0/usb-cartridge/usb-cartridge.h>
#elif HAVE_DEV_CART == 2
#include <scu/bus/a/cs0/arp/arp.h>
#else
#include <scu/bus/a/cs0/dram-cartridge/dram-cartridge.h>
#endif

Wrong masks in vdp2_scrn_ls_set.c

the masks are wrong:

 case SCRN_NBG0:
                vdp2_state.buffered_regs.scrctl &= 0xFFF9;
                ...
        case SCRN_NBG1:
                vdp2_state.buffered_regs.scrctl &= 0xF9FD;
                ...
                break;

for NBG0 should be: vdp2_state.buffered_regs.scrctl &= 0x3F01; to mask only NBG0 linescroll features
for NBG1 should be: vdp2_state.buffered_regs.scrctl &= 0x013F; to mask only NBG1 linescroll features

Examples don't match library

While I was able to compile the toolchain and libs, the examples seem to not match in areas. For example, dark_blue.c line 87 is
vdp2_scrn_back_screen_color_set(VRAM_ADDR_4MBIT(2, 0x01FFFE), 0x9C00);

which gives an error for not being a color_rgb555_t value. So I changed it to
vdp2_scrn_back_screen_color_set(VRAM_ADDR_4MBIT(2, 0x01FFFE), COLOR_RGB555(0, 0, 7));
which compiles fine. Worse, the next error is in object_world.c line 258, which is
vdp2_scrn_scv_x_set(SCRN_NBG1, THIS_PRIVATE_DATA(object_world, move), 0);
which apparently no longer exists. I couldn't find anything remotely similar in the vdp2 scrn library. There are some errors with defines right after that which are gone, too.

object_world.c:270:25: error: implicit declaration of function 'VDP2_PN_CONFIG_2_CHARACTER_NUMBER' [-Werror=implicit-function-declaration] object_world.c:271:29: error: implicit declaration of function 'VDP2_PN_CONFIG_1_PALETTE_NUMBER' [-Werror=implicit-function-declaration] object_world.c:300:25: error: implicit declaration of function 'VDP2_PN_CONFIG_1_CHARACTER_NUMBER' [-Werror=implicit-function-declaration]

None of those constants exist that I can find. I suspect that the vdp2 scrn library changed, but the updates you made to the examples didn't get committed.

Compiler build system upgrade.

I wish to improve your compiler build system because I would like to make libyaul into the centerpiece of a Saturn SDK. I made the build system for a Dreamcast SDK and wish to similarly update your system.

The end result would be an SDK that can easily be built without needing to read any instructions about how to do it while leaving powerful options for those who do.

Expand .travis.yml

There should be multiple builds and tests for each library as well as each type (release, release-internal, and debug).

Add dependency to readme

When building libyaul, the readme for building the compiler has all the dependencies it needs, but when you get to libyaul tools, you're missing one thing - libftdi-dev. You might wish to add that to the main readme before "make tools" as it will fail if libftdi-dev hasn't been installed.

Cosmetic issue with build-script

I was rebuilding the latest from scratch and noticed this line
Set INSTALL_ROOT variable (in ../yaul.env) to '/opt/toolchains/Saturn/sh-elf'

That's wrong - INSTALL_ROOT shouldn't have '/sh-elf' on the end or it will fail to build the library. It's not a big deal since the yaul.env.in makes no mention of that, but the message should be consistent to avoid confusion.

Prevent re-installing header files

The following targets

install
install-debug
install-release
install-release-internal
install-tools
libbcl-install-debug
libbcl-install-release
libbcl-install-release-internal
libtga-install-debug
libtga-install-release
libtga-install-release-internal
libyaul-install-debug
libyaul-install-release
libyaul-install-release-internal

Need to only install files when they are modified. This is very slow.

Add zooming functions

/*
 * The coord increment should be a value smaller then 1 to zoon in 
 * and larger than 1 to zoom out
 * no zoom means equal to 1 
 * 
 * Only NBG0 and NBG1 can be zoomed
 * can be changed during horizontal retrace
 * max zoom out is set to 1/4 means value = 4
 * max zoom out is constrainted by bitmap color depth: 1/4 in 16 colors mode, 1/2 in 16/256 colors mode
 */
void vdp2_scrn_zm_x_set(uint8_t scrn, uint16_t in, uint16_t dn)
{
#define ZMXIN0          0x0078
#define ZMXDN0          0x007A
#define ZMXIN1          0x0088
#define ZMXDN1          0x008A
        /*  integer part rounded to 3 bits*/
        in &= 0x07; 

        switch (scrn) {
        case SCRN_NBG0:
                /*  frac part rounded to 8 bits, shifted left by 8 */
                dn &= 0xFF; // 
                dn <<= 8;

                /* Write to memory */
                MEMORY_WRITE(16, VDP2(ZMXIN0), in);
                MEMORY_WRITE(16, VDP2(ZMXN0D), dn);
                break;
        case SCRN_NBG1:
                dn &= 0xFF;
                dn <<= 8;

                /* Write to memory */
                MEMORY_WRITE(16, VDP2(ZMXIN1), in);
                MEMORY_WRITE(16, VDP2(ZMXDN1), dn);
                break;
        default:
                return;
        }
}

void vdp2_scrn_zm_y_set(uint8_t scrn, uint16_t in, uint16_t dn)
{
#define ZMYIN0          0x007C
#define ZMYDN0          0x007E
#define ZMYIN1          0x008C
#define ZMYDN1          0x008E
        /*  integer part rounded to 3 bits*/
        in &= 0x07; 

        switch (scrn) {
        case SCRN_NBG0:
                /*  frac part rounded to 8 bits, shifted left by 8 */
                dn &= 0xFF; // 
                dn <<= 8;

                /* Write to memory */
                MEMORY_WRITE(16, VDP2(ZMYIN0), in);
                MEMORY_WRITE(16, VDP2(ZMYDN0), dn);
                break;
        case SCRN_NBG1:
                dn &= 0xFF;
                dn <<= 8;

                /* Write to memory */
                MEMORY_WRITE(16, VDP2(ZMYIN1), in);
                MEMORY_WRITE(16, VDP2(ZMYDN1), dn);
                break;
        default:
                return;
        }
}

[Compilation] vdp2_scrn_cell_format_set.c broken

scu/bus/b/vdp2/vdp2_scrn_cell_format_set.c: In function 'vdp2_scrn_cell_format_set':
scu/bus/b/vdp2/vdp2_scrn_cell_format_set.c:102:9: warning: implicit declaration of function 'VRAM_ADDR_4MBIT' [-Wimplicit-function-declaration]
scu/bus/b/vdp2/vdp2_scrn_cell_format_set.c:108:9: warning: implicit declaration of function 'VRAM_BANK_4MBIT' [-Wimplicit-function-declaration]
scu/bus/b/vdp2/vdp2_scrn_cell_format_set.c:348:25: warning: 'plane_n' may be used uninitialized in this function [-Wuninitialized]
scu/bus/b/vdp2/vdp2_scrn_cell_format_set.c:384:17: warning: 'pncnx' may be used uninitialized in this function [-Wmaybe-uninitialized]
scu/bus/b/vdp2/vdp2_scrn_cell_format_set.c:176:31: warning: 'sc_number' may be used uninitialized in this function [-Wmaybe-uninitialized]
scu/bus/b/vdp2/vdp2_scrn_cell_format_set.c:159:31: warning: 'sp_number' may be used uninitialized in this function [-Wmaybe-uninitialized]

then when compiling my stuff

vdp2_scrn_cell_format_set.c:(.text+0xec): undefined reference to `VRAM_ADDR_4MBIT'
vdp2_scrn_cell_format_set.c:(.text+0xf4): undefined reference to `VRAM_BANK_4MBIT'

Manage scu_dma_cpu_level_sanitize errors

Currently if something bad is detected in the sanitizer, it does nothing that can tell the caller something went wrong :

if ((scu_dma_cpu_level_sanitize(cfg, mode)) < 0)
                return;

For example if the indirect table is empty or not well aligned or whatever, it just exit. So would be better to add assert or a return code in

void
scu_dma_cpu_level_set(enum dma_level lvl, enum dma_mode mode, struct dma_level_cfg *cfg)

Then would it be possible to extract scu_dma_cpu_level_sanitize as a public function, as the goal of a DMA transfer is to be fast, I could sanitize my DMA transfer configuration at init, and then start the transfer later with little overhead ?

[Compilation] GDB patch broked the compilation

build/libyaul/release/common/gdb/sh2-704x.o
common/gdb/sh2-704x.c:16:30: error:  ':' without preceding '?'
common/gdb/sh2-704x.c: In function 'device_init':
common/gdb/sh2-704x.c:554:30: error:  ':' without preceding '?'
common/gdb/sh2-704x.c: In function 'device_read':
common/gdb/sh2-704x.c:564:30: error:  ':' without preceding '?'
common/gdb/sh2-704x.c: In function 'device_write':
common/gdb/sh2-704x.c:574:30: error:  ':' without preceding '?'
make[1]: *** [/home/shazz/libyaul/build/libyaul/release/common/gdb/sh2-704x.o] Error 1
make[1]: Leaving directory `/home/shazz/libyaul/libyaul'

remove ":" at the end of the elif

CMakeLists.txt file missing in libfixmath

CMake Error in CMakeLists.txt:
The source directory

.../libyaul-master/libfixmath

does not contain a CMakeLists.txt file.

-- Configuring incomplete, errors occurred!

[Compliation] missing header files

toolchains/sh-elf/sh-elf/include/yaul/yaul.h:21:35: fatal error: scu/bus/a/cs0/arp/arp.h: No such file or directory

to be removed from yaul.h

Bug in scu_dma_cpu_level_start.c

In fact this register should be written to enable the SCU DMA (bit 8) but bit 0 ONLY is the trigger is not DMA_MODE_START_FACTOR_ENABLE (so a manual trigger) else it will disable the other triggers.

I propose:

void
scu_dma_cpu_level_enable(enum dma_level level)
{

        switch (level) {
        case DMA_LEVEL_0:
                MEMORY_WRITE(32, SCU(D0EN), 0x00000100);
                return;
        case DMA_LEVEL_1:
                MEMORY_WRITE(32, SCU(D1EN), 0x00000100);
                return;
        case DMA_LEVEL_2:
                MEMORY_WRITE(32, SCU(D2EN), 0x00000100);
        default:
                return;
        }
}

void
scu_dma_cpu_level_set_starting_factor_bit(enum dma_level level)
{
        switch (level) {
        case DMA_LEVEL_0:
         uint32_t reg = MEMORY_READ(32, SCU(D0EN));
                MEMORY_WRITE(32, SCU(D0EN), reg | 0x1);
                return;
        case DMA_LEVEL_1:
            uint32_t reg = MEMORY_READ(32, SCU(D1EN));
                MEMORY_WRITE(32, SCU(D1EN), reg | 0x1);
                return;
        case DMA_LEVEL_2:
            uint32_t reg = MEMORY_READ(32, SCU(D2EN));
                MEMORY_WRITE(32, SCU(D2EN), reg | 0x1);
        default:
                return;
        }
}

Refactor dma_level_cfg structure

Initializing the Indirect mode union is quite difficult, may be easier to define the indirect buffer structure as a typedef struct like :

typedef struct __packed
{
   size_t len;
   void *dst;
   const void *src;
} __packed dma_tbl_type;

then

struct dma_level_cfg {
        union {
               struct {
                        void *dst;
                        const void *src;
                        size_t len;
                } direct;

                struct {
                        dma_tbl_type*tbl;
                        uint32_t nelems;
                } indirect;
        } mode;

        uint32_t add;
        enum dma_mode_strt_factor_type starting_factor;
        enum dma_mode_update_type update;
};

Add missing CPU registers to map.h

In file libyaul/libyaul/scu/bus/cpu/cpu/map.h

All first registers are missing such as:

define TCR 0x0E16

define FRC_H 0x0E12

define FRC_L 0x0E13

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.