Monday, December 16, 2019

MSX Dev 2020 Blog 1

One reason for this post is the cool build pipeline I have going. I'm on Ubuntu, and I wrote a nice little one-click compile-and-run bash script that will do the following:

-Compile assets in .z80 format to .bin
-Compress .bin to .rle
-Move .rle to their asset folders and delete the .bin artifacts
-Compiles the ROM (using tniasm)
-Analyzes the label definitions to calculate remaining byte space AND automatically adds breakpoints to an openMSX config file
-Launches OpenMSX w/ the proper configs

I've pasted it at the bottom of this post.

BEHOLD, IRIDESCENT:



IRIDESCENT is a two-player, pseudo-random cyberpunk hack-and-slash. Imagine Gauntlet or Smash TV crossed with Shadowrun.

Progress shown above:
-Room data is decompressed on load, enemies are populated in RAM simultaneously.
-Support for 25 enemies at once
-Enemies animate and collide with the player and projectiles, player collides w/ 2px accuracy on walls/enemies
-Video buffering - 1/3 of the screen tiles from RAM buffer are drawn to the VDP per frame, easily allotting for 60 fps sprite action with no play impact
-PSG-only MuSICA playback

The white is video blank code. By only doing 1/3 of the screen tiles at once, this easily keeps update time within blank interval.

Green is per-frame CPU code. After optimizations today, it's been cut down to allot for PLENTY of more calculations!

compile-and-run.sh:
#!/bin/bash

check_success(){
    if [ $? -eq 0 ]; then 
        :
    else 
        cat errors.log
        echo 
        echo Compile script failed. Terminating.
        exit 1
    fi 
}

echo Compiling assets...
za=$(wine tniasm ./screens/screen1.z80 ./screen1.bin)
check_success
...

echo Compressing assets...
za=$(python3 ./rlenc.py screen1.bin)
check_success
...

# move compressed data to folders and remove artifacts
mv screen1.rle ./screens/
rm screen1.bin
...
echo Done. Compiling ROM...

calc_block_size () {
    # $1 = label to find, end of used-up memory
    # $2 = start of block (byte no.)
    # $3 = full size of block in b
    te="$(grep -i $1 tniasm.sym)"
    a="$te"
    b=${a#*:}
    c=${b%;*}
    te2="$(echo "$c" | tr -dc '0-9','A-F')"
    d="$te2"
    t3="$(echo "obase=10; ibase=16; $d" | bc)"
    e="$t3"
    f="$(($e-$2))"
    g="$(($3-$f))"

}

# compile rom, catch errors
w=$(wine ./tniasm.exe gamerom.z80 irides.rom 2> errors.log)
check_success

echo Success. 

find_debug_points(){
    db=($(grep -i breakpoint tniasm.sym))
    for i in ${db[@]}; do 
        vv=${i#*:}
        vb=${vv%;*}
        vc=$(echo "$vb" | tr -dc '0-9','A-F')
        vd="$vc"
        if [ ${#vd} == 5 ]; then
            echo debug set_bp 0x$vd >> m1.txt
            echo Breakpoint found @ \$$vd
        fi
    done 
}

echo plug joyporta keyjoystick1 > m1.txt

find_debug_points

calc_block_size PlayerCompressed_end 16384 16384
echo "$g bytes remaining in data block (\$04000-\$$d)"
calc_block_size EndMainCode 32768 9655
echo "$g bytes remaining in code block A (\$08000-\$$d)"
calc_block_size EndBlockTwo 42423 6729
echo "$g bytes remaining in code block B (\$0a5b7-\$$d)"
calc_block_size EndRAM 49152 3583
echo "$g bytes remaining for RAM (\$0c000-\$$d)"

echo Launching OpenMSX...

sudo /opt/openMSX/bin/openmsx -machine Sony_HB-10 -cart ./irides.rom -script m1.txt


The output looks like this:



No comments:

Post a Comment