Skip to content

Instantly share code, notes, and snippets.

View suzukiplan's full-sized avatar
🏠
Working from home

Yoji Suzuki suzukiplan

🏠
Working from home
View GitHub Profile
@suzukiplan
suzukiplan / gist:2ca084a578a2d0eba28b
Created May 13, 2015 01:39
double精度の波形出力(sin, square, pulse)
/* description: 波形情報をメモリではなく全て演算ベースにする新音源用のメモ */
/* とりあえず、サイン波、矩形波、ノコギリ波のみ */
/* ノイズ発生装置は後回し */
#include <math.h>
#define PI 3.1415926535897932
#define PI2 6.2831853071795864
double calcwav_sin(double r)
{
return sin(r);
@suzukiplan
suzukiplan / piano.c
Last active August 29, 2015 14:21
88鍵ピアノの音階周波数とサンプリング周波数1Hzあたりのラジアン増分を求めて表示
/* 88鍵ピアノの音階周波数 & サンプリング周波数1Hzあたりのラジアン増分を求めて表示 */
#include <stdio.h>
#define S 44100.00
#define B 1.0594631
#define PI 3.1415926535897932
#define PI2 6.2831853071795864
int main(int argc,char* argv[])
{
@suzukiplan
suzukiplan / artbl.c
Created May 14, 2015 01:06
音程ごとのラジアン増分値を格納したテーブル
double ARTBL[88] = {
0.0039180860759056
,0.0041510676200458
,0.0043979029690434
,0.0046594159130819
,0.0049364792274631
,0.0052300175854136
,0.0055410106440968
,0.0058704963141278
,0.0062195742235045
@suzukiplan
suzukiplan / playsample.sh
Last active January 31, 2016 00:11
play touhou BGM mml files on VGS in Mac / Linux
#!/bin/sh
# VGSのセットアップ
cd ~/
git clone https://github.com/suzukiplan/vgs2.git vgs2
cd vgs2/bin_src
make
export VGS2_HOME=~/vgs2
export PATH=$PATH:$VGS2_HOME/bin
# 次回起動時に環境変数の設定を省略するための手順
@suzukiplan
suzukiplan / gethwnd.c
Created July 3, 2015 11:05
get console hwnd
#include <Windows.h>
#include <stdio.h>
HWND GetConsoleHwnd(void)
{
#define MY_BUFSIZE 1024
HWND hwndFound;
char pszNewWindowTitle[MY_BUFSIZE];
char pszOldWindowTitle[MY_BUFSIZE];
GetConsoleTitle(pszOldWindowTitle, MY_BUFSIZE);
@suzukiplan
suzukiplan / nestone.c
Created July 17, 2015 04:59
ファミコンの音程($4002-$4003)に設定する値を算出する
/* ファミコンの音程 ($4002-$4003 に設定すべき値) */
#include <stdio.h>
#define S 44100.00
#define B 1.0594631
#define PI 3.1415926535897932
#define PI2 6.2831853071795864
#define CPU 1790000
@suzukiplan
suzukiplan / vgs-spu-example.c
Created February 13, 2016 14:39
Example of the VGS-SPU
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include <stdio.h>
#include "vgsspu.h"
#ifdef _WIN32
static void usleep(int usec)
@suzukiplan
suzukiplan / gist:a7729b7a7dca3ee30824590ef192bc2b
Created August 27, 2016 16:07
git で commitした回数, 追加した行数, 削除した行数 を 表示するシェル
#!/bin/sh
echo commits: `git log --since=1971-01-01 --until=2035-12-31 --oneline --no-merges | wc -l`
echo added: `git log --since=1971-01-01 --until=2035-12-31 --oneline --numstat --no-merges --pretty=format:"" | cut -f1 | awk 'BEGIN {sum=0} {sum+=$1} END {print sum}'`
echo deleted: `git log --since=1971-01-01 --until=2035-12-31 --oneline --numstat --no-merges --pretty=format:"" | cut -f2 | awk 'BEGIN {sum=0} {sum+=$1} END {print sum}'`
@suzukiplan
suzukiplan / callback_on_c.c
Created August 30, 2018 06:11
Callback example for C
#include <stdio.h>
void functionWithCallback(void(*callback)(int, int)) {
callback(1234, 5678);
}
void callback(int a, int b) {
printf("a=%d, b=%d\n", a, b);
}
$ bin/vgsrun examples/hello/hello.rom
$8000: LDA #$00 (a=$00, x=$00, y=$00, s=$00, p=$02)
$8002: STA $5404 (a=$00, x=$00, y=$00, s=$00, p=$02)
$8005: LDX #$00 (a=$00, x=$00, y=$00, s=$00, p=$02)
$8007: LDA $8018, X (a=$48, x=$00, y=$00, s=$00, p=$00)
$800A: STA $63C7, X (a=$48, x=$00, y=$00, s=$00, p=$00)
$800D: INX (a=$48, x=$01, y=$00, s=$00, p=$00)
$800E: CPX #$12 (a=$48, x=$01, y=$00, s=$00, p=$80)
$8010: BNE $F5 (a=$48, x=$01, y=$00, s=$00, p=$80)
$8007: LDA $8018, X (a=$65, x=$01, y=$00, s=$00, p=$00)