added gif recorder

This commit is contained in:
Steven Hugg 2017-05-20 15:13:23 -04:00
parent 867bab7978
commit ec9a3136ac
6 changed files with 139 additions and 16 deletions

3
.gitmodules vendored
View File

@ -16,3 +16,6 @@
[submodule "FileSaver.js"]
path = FileSaver.js
url = https://github.com/eligrey/FileSaver.js
[submodule "gif.js"]
path = gif.js
url = https://github.com/jnordberg/gif.js

1
gif.js Submodule

@ -0,0 +1 @@
Subproject commit 55bdbfea897753787fd2f4efc62f144371351522

View File

@ -37,28 +37,27 @@ body {
<li><a class="dropdown-item" href="#" id="item_share_file">Share File as GitHub Gist...</a></li>
<li><a class="dropdown-item" href="#" id="item_reset_file">Revert to Original...</a></li>
<li><a class="dropdown-item" href="#" id="item_download_rom">Download ROM Image...</a></li>
<!--
<li><a class="dropdown-item" href="#" id="item_record_video">Record Video...</a></li>
-->
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Platform</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="?platform=vcs" id="item_platform_vcs">Atari VCS</a></li>
<!--<li><a class="dropdown-item" href="?platform=apple2" id="item_platform_apple2">Apple ][</a></li>-->
<li><a class="dropdown-item" href="?platform=vicdual" id="item_platform_vicdual">VIC Dual</a></li>
<li><a class="dropdown-item" href="?platform=mw8080bw" id="item_platform_mw8080bw">Midway 8080</a></li>
<li><a class="dropdown-item" href="?platform=galaxian-scramble" id="item_platform_galaxian_scramble">Galaxian/Scramble Hardware</a></li>
<li><a class="dropdown-item" href="?platform=vector-z80color" id="item_platform_vector_z80color">Atari Color Vector (Z80)</a></li>
<li><a class="dropdown-item" href="?platform=williams-z80" id="item_platform_williams_z80">Williams (Z80)</a></li>
<li><a class="dropdown-item" href="?platform=sound_williams-z80" id="item_platform_sound_williams_z80">Williams Sound (Z80)</a></li>
</ul>
</li>
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Debug</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="#" id="item_debug_expr">Break Expression...</a></li>
</ul>
</li>
</li>
<hr>
<li class="dropdown dropdown-submenu">
<a tabindex="-1" href="#">Platform</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="?platform=vcs" id="item_platform_vcs">Atari VCS</a></li>
<!--<li><a class="dropdown-item" href="?platform=apple2" id="item_platform_apple2">Apple ][</a></li>-->
<li><a class="dropdown-item" href="?platform=vicdual" id="item_platform_vicdual">VIC Dual</a></li>
<li><a class="dropdown-item" href="?platform=mw8080bw" id="item_platform_mw8080bw">Midway 8080</a></li>
<li><a class="dropdown-item" href="?platform=galaxian-scramble" id="item_platform_galaxian_scramble">Galaxian/Scramble Hardware</a></li>
<li><a class="dropdown-item" href="?platform=vector-z80color" id="item_platform_vector_z80color">Atari Color Vector (Z80)</a></li>
<li><a class="dropdown-item" href="?platform=williams-z80" id="item_platform_williams_z80">Williams (Z80)</a></li>
<li><a class="dropdown-item" href="?platform=sound_williams-z80" id="item_platform_sound_williams_z80">Williams Sound (Z80)</a></li>
</ul>
</li>
</ul>
</span>
<select id="preset_select" name="">
@ -126,6 +125,22 @@ body {
<iframe id="pixeditframe" src="pixels.html">
</iframe>
</div>
<div id="videoPreviewModal" class="modal fade">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Video Preview - Right-click to save</h3>
</div>
<div class="modal-body">
<img id="videoPreviewImage">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<script src="jquery/jquery-2.2.3.min.js"></script>
@ -165,6 +180,7 @@ body {
-->
<script src="FileSaver.js/FileSaver.min.js"></script>
<script src="octokat.js/dist/octokat.js"></script>
<script src="gif.js/dist/gif.js"></script>
<script src="src/vlist.js"></script>
<script src="src/emu.js"></script>

65
presets/nes/conio.c Normal file
View File

@ -0,0 +1,65 @@
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <joystick.h>
static const char Text [] = "Hello world!";
int main (void)
{
unsigned char XSize, YSize;
/* Set screen colors */
(void) textcolor (COLOR_WHITE);
(void) bordercolor (COLOR_BLACK);
(void) bgcolor (COLOR_BLACK);
/* Clear the screen, put cursor in upper left corner */
clrscr ();
/* Ask for the screen size */
screensize (&XSize, &YSize);
/* Draw a border around the screen */
/* Top line */
cputc (CH_ULCORNER);
chline (XSize - 2);
cputc (CH_URCORNER);
/* Vertical line, left side */
cvlinexy (0, 1, YSize - 2);
/* Bottom line */
cputc (CH_LLCORNER);
chline (XSize - 2);
cputc (CH_LRCORNER);
/* Vertical line, right side */
cvlinexy (XSize - 1, 1, YSize - 2);
/* Write the greeting in the mid of the screen */
gotoxy ((XSize - strlen (Text)) / 2, YSize / 2);
cprintf ("%s", Text);
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
/* Wait for the user to press a button */
joy_install (joy_static_stddrv);
while (!joy_read (JOY_1)) ;
joy_uninstall ();
#else
/* Wait for the user to press a key */
cgetc ();
#endif
/* Clear the screen again */
clrscr ();
/* Done */
return EXIT_SUCCESS;
}

View File

@ -4,6 +4,8 @@
var PLATFORMS = {};
var frameUpdateFunction = null;
function noise() {
return (Math.random() * 256) & 0xff;
}
@ -73,6 +75,7 @@ var RasterVideo = function(mainElement, width, height, options) {
ctx.putImageData(imageData, sx, sy, dx, dy, width, height);
else
ctx.putImageData(imageData, 0, 0);
if (frameUpdateFunction) frameUpdateFunction(canvas);
}
/*
@ -155,6 +158,7 @@ var VectorVideo = function(mainElement, width, height) {
ctx.fillRect(0, 0, width, height);
ctx.globalAlpha = 1.0;
ctx.globalCompositeOperation = 'lighter';
if (frameUpdateFunction) frameUpdateFunction(canvas);
}
var COLORS = [

View File

@ -1068,6 +1068,39 @@ function openBitmapEditorAtCursor() {
}
}
function _recordVideo() {
var gif = new GIF({
workerScript: 'gif.js/dist/gif.worker.js',
workers: 4,
quality: 10
});
var canvas = $("#emulator").find("canvas")[0];
if (!canvas) {
alert("Could not find canvas element to record video!");
return;
}
var img = $('#videoPreviewImage');
//img.attr('src', 'https://articulate-heroes.s3.amazonaws.com/uploads/rte/kgrtehja_DancingBannana.gif');
gif.on('finished', function(blob) {
img.attr('src', URL.createObjectURL(blob));
$("#videoPreviewModal").modal('show');
});
var intervalMsec = 17;
var maxFrames = 500;
var nframes = 0;
console.log("Recording video", canvas);
var f = function() {
if (nframes++ > maxFrames) {
console.log("Rendering video");
gif.render();
} else {
gif.addFrame(canvas, {delay: intervalMsec});
setTimeout(f, intervalMsec);
}
};
f();
}
function setupDebugControls(){
$("#dbg_reset").click(resetAndDebug);
$("#dbg_pause").click(pause);
@ -1096,6 +1129,7 @@ function setupDebugControls(){
$("#item_reset_file").click(_resetPreset);
$("#item_debug_expr").click(_breakExpression);
$("#item_download_rom").click(_downloadROMImage);
$("#item_record_video").click(_recordVideo);
updateDebugWindows();
}