0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

stack machineを愛でる。

Last updated at Posted at 2021-06-12

#概要

stack machineが、好きだ。
余り、実装を知らない。flashと.netくらいしか。(mindもあった。)
flashは、終了したが、ruffleがあるらしい。
動的に、swfを生成して、ruffleに、食わせてみた。

#サンプルコード



function _arrayBufferToBase64(buffer) {
	var binary = '';
	var bytes = new Uint8Array(buffer);
	var len = bytes.byteLength;
	for (var i = 0; i < len; i++) 
	{
		binary += String.fromCharCode(bytes[i]);
	}
	return window.btoa(binary);
}
swf21 = [
	0x46, 0x57, 0x53, 0x04, 0xB0, 0x00, 0x00, 0x00, 0x68, 0x00, 0x10, 0x40, 0x00, 0x04, 0x10, 0x00,
	0x00, 0x0C, 0x01, 0x00, 0x43, 0x02, 0x33, 0x33, 0x33, 0x3F, 0x03, 0x79, 0x00, 0x00, 0x00, 
	0x96, 0x03, 0x00, 0x00, 0x69, 0x00, 0x96, 0x03, 0x00, 0x00, 0x30, 0x00, 0x1d, 0x96, 0x03, 0x00,
	0x00, 0x78, 0x00, 0x96, 0x03, 0x00, 0x00, 0x69, 0x00, 0x96, 0x03, 0x00, 0x00, 0x69, 0x00, 0x1c,
	0x96, 0x03, 0x00, 0x00, 0x31, 0x00, 0x0a, 0x1d, 0x96, 0x04, 0x00, 0x00, 0x32, 0x39, 0x00, 0x96,
	0x03, 0x00, 0x00, 0x69, 0x00, 0x1c, 0x0f, 0x12, 0x9d, 0x02, 0x00, 0xd6, 0xff, 0x96, 0x03, 0x00,
	0x00, 0x69, 0x00, 0x1c, 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
	0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x09, 0x01, 0x00, 0x60, 0x0A, 0x3F, 0xC0,
	0x0A, 0x3F, 0xC0, 0x60, 0x08, 0x78, 0x00, 0x05, 0x01, 0x01, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00
];
function tob(url) {
	var bin = atob(url);
	var buffer = new Uint8Array(bin.length);
	for (var i = 0; i < bin.length; i++)
	{
  		buffer[i] = bin.charCodeAt(i);
	}
	var blob = new Blob([buffer.buffer], {
		type : 'application/x-shockwave-flash'
	});
	var blob_url = window.URL.createObjectURL(blob);
	return blob_url;
}
var b = _arrayBufferToBase64(swf21);
var l = '" type="application/x-shockwave-flash" width="300" height="300"></embed>';
var swf = '<embed src ="' + tob(b) + l;
document.write(swf);


#成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?