diff --git a/onefile/data/shisen/sounds/01-ayb.ogg b/onefile/data/shisen/sounds/01-ayb.ogg new file mode 100644 index 0000000..dbb3c14 Binary files /dev/null and b/onefile/data/shisen/sounds/01-ayb.ogg differ diff --git a/onefile/data/shisen/sounds/02-ben.ogg b/onefile/data/shisen/sounds/02-ben.ogg new file mode 100644 index 0000000..430cf6b Binary files /dev/null and b/onefile/data/shisen/sounds/02-ben.ogg differ diff --git a/onefile/data/shisen/sounds/03-gim.ogg b/onefile/data/shisen/sounds/03-gim.ogg new file mode 100644 index 0000000..a5d1017 Binary files /dev/null and b/onefile/data/shisen/sounds/03-gim.ogg differ diff --git a/onefile/data/shisen/sounds/04-da.ogg b/onefile/data/shisen/sounds/04-da.ogg new file mode 100644 index 0000000..9375b0e Binary files /dev/null and b/onefile/data/shisen/sounds/04-da.ogg differ diff --git a/onefile/data/shisen/sounds/05-yec.ogg b/onefile/data/shisen/sounds/05-yec.ogg new file mode 100644 index 0000000..70b10bc Binary files /dev/null and b/onefile/data/shisen/sounds/05-yec.ogg differ diff --git a/onefile/data/shisen/sounds/06-za.ogg b/onefile/data/shisen/sounds/06-za.ogg new file mode 100644 index 0000000..5324120 Binary files /dev/null and b/onefile/data/shisen/sounds/06-za.ogg differ diff --git a/onefile/data/shisen/sounds/07-e.ogg b/onefile/data/shisen/sounds/07-e.ogg new file mode 100644 index 0000000..0b2a137 Binary files /dev/null and b/onefile/data/shisen/sounds/07-e.ogg differ diff --git a/onefile/data/shisen/sounds/08-et.ogg b/onefile/data/shisen/sounds/08-et.ogg new file mode 100644 index 0000000..814e7c4 Binary files /dev/null and b/onefile/data/shisen/sounds/08-et.ogg differ diff --git a/onefile/data/shisen/sounds/09-to.ogg b/onefile/data/shisen/sounds/09-to.ogg new file mode 100644 index 0000000..2062fa6 Binary files /dev/null and b/onefile/data/shisen/sounds/09-to.ogg differ diff --git a/onefile/data/shisen/sounds/10-ze.ogg b/onefile/data/shisen/sounds/10-ze.ogg new file mode 100644 index 0000000..d81a53c Binary files /dev/null and b/onefile/data/shisen/sounds/10-ze.ogg differ diff --git a/onefile/data/shisen/sounds/11-ini.ogg b/onefile/data/shisen/sounds/11-ini.ogg new file mode 100644 index 0000000..e66026d Binary files /dev/null and b/onefile/data/shisen/sounds/11-ini.ogg differ diff --git a/onefile/data/shisen/sounds/12-lyun.ogg b/onefile/data/shisen/sounds/12-lyun.ogg new file mode 100644 index 0000000..70b82f3 Binary files /dev/null and b/onefile/data/shisen/sounds/12-lyun.ogg differ diff --git a/onefile/data/shisen/sounds/13-xe.ogg b/onefile/data/shisen/sounds/13-xe.ogg new file mode 100644 index 0000000..1c66119 Binary files /dev/null and b/onefile/data/shisen/sounds/13-xe.ogg differ diff --git a/onefile/data/shisen/sounds/14-ca.ogg b/onefile/data/shisen/sounds/14-ca.ogg new file mode 100644 index 0000000..730894d Binary files /dev/null and b/onefile/data/shisen/sounds/14-ca.ogg differ diff --git a/onefile/data/shisen/sounds/15-ken.ogg b/onefile/data/shisen/sounds/15-ken.ogg new file mode 100644 index 0000000..7f237d3 Binary files /dev/null and b/onefile/data/shisen/sounds/15-ken.ogg differ diff --git a/onefile/data/shisen/sounds/16-ho.ogg b/onefile/data/shisen/sounds/16-ho.ogg new file mode 100644 index 0000000..ea9e234 Binary files /dev/null and b/onefile/data/shisen/sounds/16-ho.ogg differ diff --git a/onefile/data/shisen/sounds/17-ja.ogg b/onefile/data/shisen/sounds/17-ja.ogg new file mode 100644 index 0000000..53aa6c3 Binary files /dev/null and b/onefile/data/shisen/sounds/17-ja.ogg differ diff --git a/onefile/data/shisen/sounds/18-gat.ogg b/onefile/data/shisen/sounds/18-gat.ogg new file mode 100644 index 0000000..1dea421 Binary files /dev/null and b/onefile/data/shisen/sounds/18-gat.ogg differ diff --git a/onefile/data/shisen/sounds/19-ce.ogg b/onefile/data/shisen/sounds/19-ce.ogg new file mode 100644 index 0000000..473553e Binary files /dev/null and b/onefile/data/shisen/sounds/19-ce.ogg differ diff --git a/onefile/data/shisen/sounds/20-men.ogg b/onefile/data/shisen/sounds/20-men.ogg new file mode 100644 index 0000000..d2b0b06 Binary files /dev/null and b/onefile/data/shisen/sounds/20-men.ogg differ diff --git a/onefile/data/shisen/sounds/21-hi.ogg b/onefile/data/shisen/sounds/21-hi.ogg new file mode 100644 index 0000000..e5349dc Binary files /dev/null and b/onefile/data/shisen/sounds/21-hi.ogg differ diff --git a/onefile/data/shisen/sounds/22-nu.ogg b/onefile/data/shisen/sounds/22-nu.ogg new file mode 100644 index 0000000..25eedcd Binary files /dev/null and b/onefile/data/shisen/sounds/22-nu.ogg differ diff --git a/onefile/data/shisen/sounds/23-sa.ogg b/onefile/data/shisen/sounds/23-sa.ogg new file mode 100644 index 0000000..a94fc67 Binary files /dev/null and b/onefile/data/shisen/sounds/23-sa.ogg differ diff --git a/onefile/data/shisen/sounds/24-vo.ogg b/onefile/data/shisen/sounds/24-vo.ogg new file mode 100644 index 0000000..baf987f Binary files /dev/null and b/onefile/data/shisen/sounds/24-vo.ogg differ diff --git a/onefile/data/shisen/sounds/25-cha.ogg b/onefile/data/shisen/sounds/25-cha.ogg new file mode 100644 index 0000000..4d81904 Binary files /dev/null and b/onefile/data/shisen/sounds/25-cha.ogg differ diff --git a/onefile/data/shisen/sounds/26-pe.ogg b/onefile/data/shisen/sounds/26-pe.ogg new file mode 100644 index 0000000..d716d66 Binary files /dev/null and b/onefile/data/shisen/sounds/26-pe.ogg differ diff --git a/onefile/data/shisen/sounds/27-je.ogg b/onefile/data/shisen/sounds/27-je.ogg new file mode 100644 index 0000000..f76fb8b Binary files /dev/null and b/onefile/data/shisen/sounds/27-je.ogg differ diff --git a/onefile/data/shisen/sounds/28-ra.ogg b/onefile/data/shisen/sounds/28-ra.ogg new file mode 100644 index 0000000..9c5adb8 Binary files /dev/null and b/onefile/data/shisen/sounds/28-ra.ogg differ diff --git a/onefile/data/shisen/sounds/29-se.ogg b/onefile/data/shisen/sounds/29-se.ogg new file mode 100644 index 0000000..3ddd48a Binary files /dev/null and b/onefile/data/shisen/sounds/29-se.ogg differ diff --git a/onefile/data/shisen/sounds/30-vew.ogg b/onefile/data/shisen/sounds/30-vew.ogg new file mode 100644 index 0000000..7b0086e Binary files /dev/null and b/onefile/data/shisen/sounds/30-vew.ogg differ diff --git a/onefile/data/shisen/sounds/31-tiwn.ogg b/onefile/data/shisen/sounds/31-tiwn.ogg new file mode 100644 index 0000000..972b9ec Binary files /dev/null and b/onefile/data/shisen/sounds/31-tiwn.ogg differ diff --git a/onefile/data/shisen/sounds/32-re.ogg b/onefile/data/shisen/sounds/32-re.ogg new file mode 100644 index 0000000..a0e5685 Binary files /dev/null and b/onefile/data/shisen/sounds/32-re.ogg differ diff --git a/onefile/data/shisen/sounds/33-co.ogg b/onefile/data/shisen/sounds/33-co.ogg new file mode 100644 index 0000000..3c6eadb Binary files /dev/null and b/onefile/data/shisen/sounds/33-co.ogg differ diff --git a/onefile/data/shisen/sounds/34-u.ogg b/onefile/data/shisen/sounds/34-u.ogg new file mode 100644 index 0000000..6b40648 Binary files /dev/null and b/onefile/data/shisen/sounds/34-u.ogg differ diff --git a/onefile/data/shisen/sounds/35-pyur.ogg b/onefile/data/shisen/sounds/35-pyur.ogg new file mode 100644 index 0000000..e5b99b0 Binary files /dev/null and b/onefile/data/shisen/sounds/35-pyur.ogg differ diff --git a/onefile/data/shisen/sounds/36-ke.ogg b/onefile/data/shisen/sounds/36-ke.ogg new file mode 100644 index 0000000..818b40a Binary files /dev/null and b/onefile/data/shisen/sounds/36-ke.ogg differ diff --git a/onefile/data/shisen/sounds/37-o.ogg b/onefile/data/shisen/sounds/37-o.ogg new file mode 100644 index 0000000..ebfc198 Binary files /dev/null and b/onefile/data/shisen/sounds/37-o.ogg differ diff --git a/onefile/data/shisen/sounds/38-fe.ogg b/onefile/data/shisen/sounds/38-fe.ogg new file mode 100644 index 0000000..6d7ca77 Binary files /dev/null and b/onefile/data/shisen/sounds/38-fe.ogg differ diff --git a/onefile/data/shisen/sounds/39-yew.ogg b/onefile/data/shisen/sounds/39-yew.ogg new file mode 100644 index 0000000..87a5807 Binary files /dev/null and b/onefile/data/shisen/sounds/39-yew.ogg differ diff --git a/onefile/shisen.c b/onefile/shisen.c index f0c1d0c..a784f44 100644 --- a/onefile/shisen.c +++ b/onefile/shisen.c @@ -11,6 +11,7 @@ #define ROWS 9 #define ACTIVELETTERS 20 #define MAXLETTERS 256 +#define MAXSOUNDS 16 #define RMTIME 1.0 #define EXTIME 2.0 @@ -20,6 +21,8 @@ typedef struct { Animation glyphs[4]; int glyphsCount; + Sound sounds[MAXSOUNDS]; + int soundsCount; Animation g[4]; } Letter; @@ -56,6 +59,7 @@ int glyphsMask = 0; int mode; double exitTm; + void clearBoard() { exitTm = 0; mode = 0; @@ -65,8 +69,17 @@ void clearBoard() { selected = (Pos){ -1, -1 }; } + +void clearSounds() { + for(int i = 0; i < lettersCount; ++i) + for(int j = 0; j < letters[i].soundsCount; ++i) + soundDestroy(letters[i].sounds[j]); +} + + void clearLetters() { clearBoard(); + clearSounds(); for(int i = 0; i < lettersCount; ++i) for(int j = 0; j < letters[i].glyphsCount; ++j) animationDestroy(letters[i].glyphs[j]); @@ -76,6 +89,7 @@ void clearLetters() { cellWidth = cellHeight = 1; } + int loadLetters(const char *filename, int rows, int cols) { clearLetters(); @@ -121,6 +135,21 @@ int loadLetters(const char *filename, int rows, int cols) { } +void loadSounds(const char *path) { + Directory dir = openDirectoryEx(path, "", ".ogg", FALSE, TRUE, FALSE); + if (!dir) return; + for(int i = 0; i < directoryGetCount(dir); ++i) { + int index = atoi(directoryGet(dir, i)); + if (index <= 0 || index > lettersCount) continue; + Letter *l = &letters[index-1]; + if (l->soundsCount >= MAXSOUNDS) continue; + l->sounds[l->soundsCount] = createSound(directoryGetFull(dir, i)); + if (l->sounds[l->soundsCount]) ++l->soundsCount; + } + closeDirectory(dir); +} + + void shuffleLetters(int glyps) { for(int i = 0; i < lettersCount; ++i) { int j = randomNumber(i, lettersCount - 1); @@ -151,6 +180,17 @@ void shuffleLetters(int glyps) { } +void simpleBoard() { + clearBoard(); + for(int i = 0; i < COUNT; ++i) { + Letter *l = &letters[i%lettersCount]; + board[i/COLS][i%COLS].l = l; + board[i/COLS][i%COLS].g = l->glyphs[1]; + } + mode = 1; +} + + void generateBoard(int glyphsMask, int maxLetters) { if (maxLetters < 1) maxLetters = 1; @@ -286,6 +326,8 @@ void init() { windowStop(); return; } + loadSounds("data/shisen/sounds"); + //simpleBoard(); } @@ -380,6 +422,10 @@ void draw() { clearBoard(); if (mouseWentDown("left")) { + Letter *l = get(hover); + if (l && l->soundsCount) + soundPlay( l->sounds[ randomNumber(0, l->soundsCount-1) ], FALSE ); + Track t = findTrack(selected, hover); if (t.len) { t.tm = 1; @@ -395,7 +441,7 @@ void draw() { else if ( !(hover.r < 0 && hover.c < 0) // ignore hint or exit pressing && !(hover.r >= ROWS && hover.c >= COLS) ) - selected = hover; + selected = hover; } Letter *hl = mouseDown("right") ? get(hover) : NULL;