-
Notifications
You must be signed in to change notification settings - Fork 0
segaconsoles
ArcadeTV edited this page May 22, 2021
·
3 revisions
Pixel art Sega consoles by BLUEamnesiac
In this example I show how to use a big plane map (64x64 tiles) and how to set vdp registers so that plane B's map will not interfer with hscroll memory in vram. The background is moved by a set of data that is generated from a sine easing function which moves plane B's HSCROLL and VSCROLL with an offset of 90 degrees so the movement is circular.
This is my PHP function that I wrote to create the data. It can be easily adopted for other easing data.
<pre>
<?php
// t: current time
// b: start value
// c: change in value
// d: duration
//
// t and d can be frames and/or (milli)seconds
function easeOutQuad($t, $b, $c, $d) {
$t /= $d;
return ($c*-1) * $t * ($t-2) + $b;
};
function easeInQuad($t, $b, $c, $d) {
$t /= $d;
return $c*$t*$t + $b;
};
function easeInSine($t, $b, $c, $d) {
return ($c*-1) * cos($t/$d * (pi()/2)) + $c + $b;
};
function easeInOutSine($t, $b, $c, $d) {
$c = -1 * abs($c);
return $c/2 * (cos(pi()*$t/$d) - 1) + $b;
};
$seconds = 15; // Enter time in seconds
$duration = (60*$seconds); // 60fps * x = xsec
$start = 0;
$end = 1024;
$array = [];
for($frame=0; $frame <= $duration; $frame++){
$val = easeInOutSine($frame, $start, $end, $duration); // select easing function here
$array[] = $val;
}
// Change from here to whatever fits your need of formatting the data:
echo 'sine:' . "\n";
foreach($array as $val){
echo "\t".'dc.w' . "\t" . '$' . strtoupper(dechex(round($val))) . "\n";
}
$array = array_reverse($array);
foreach($array as $val){
echo "\t".'dc.w' . "\t" . '$' . strtoupper(dechex(round($val))) . "\n";
}
echo 'sineEnd:' . "\n";
?>
</pre>