Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
Done yo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Babkock committed Apr 16, 2014
1 parent 348eb63 commit cfc451e
Show file tree
Hide file tree
Showing 42 changed files with 1,034 additions and 10 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ToneMatrix changelog:

0.9:
- Added save song and load song functions
- Changed from 12 grids to 16 grids
- Removed "Quit" and "Stop playing" menu options

0.8:
- Added 12 grid sequencer
- Added loop all function
- Added cut, copy, and paste functions

0.7:
- Added mute row function
- Added solo row function

0.6:
- Fixed "trail" bug

0.5:
- Initial release
- Clear grid, tempo, and stop functions
12 changes: 6 additions & 6 deletions LICENSE → LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Expand Down Expand Up @@ -290,8 +290,8 @@ to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

{description}
Copyright (C) {year} {fullname}
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -329,11 +329,11 @@ necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

{signature of Ty Coon}, 1 April 1989
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
Public License instead of this License.
4 changes: 0 additions & 4 deletions README.md

This file was deleted.

53 changes: 53 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ToneMatrix is a 16-step drum machine. The Y (vertical) axis
represents eight different sounds, and more than one can be
played at a time. The X (horizontal) axis represents one
4/4 measure in sixteenth-notes.

Select a node on the grid with the D-pad and the X button,
and that sound will be played in time. Press O to stop/
resume playing. Press [] (square) to mute the row the cursor
is on. Press /\ (triangle) to mute every row except the
row the cursor is on. You can mute more than one row at
once.

Press START to use the menu, and use the D-pad to select a
menu item or change a value (like the tempo), and X (cross)
to confirm your choice. Press SELECT for help.

You can play up to twelve measures in a row by using the R
and L triggers, or by switching the "grid" value in the
START mneu. If "loop all" is on, then the measures will
play one after another. If it is off, it will only repeat
one measure. It is recommended that you stop playback
before editing another grid.

To install:
If you have custom firmware or a homebrew-enabled PSP,
place the "unsigned" folder into the /PSP/GAME folder on
your Memory Stick. If you have official firmware on your PSP
(or if you have a PSPgo), place the "signed" folder into the
/PSP/GAME folder on your Memory Stick.

-

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.

This program is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public
License along with this program; if not, visit
http://www.gnu.org/licenses/gpl-2.0.txt

If you want to redistribute any modifications you make to
the program, please credit yourself in the modified source
file(s) under my name as,
"Copyright (c) <year> <your name here>"

Feel free to contact me at [email protected] if you have any
questions or concerns. Thanks for playing :)
Binary file added screen1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screen2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screen3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screen4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screen5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screen6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added signed/EBOOT.PBP
Binary file not shown.
Binary file added signed/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions signed/songs/SAVED-SONGS-GO-HERE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ToneMatrix will only load songs if the file name is one of the following:

song0.tms
song1.tms
song2.tms
song3.tms
song4.tms
song5.tms
song6.tms
song7.tms
song8.tms
song9.tms

Binary file added signed/sounds/tone0.wav
Binary file not shown.
Binary file added signed/sounds/tone1.wav
Binary file not shown.
Binary file added signed/sounds/tone2.wav
Binary file not shown.
Binary file added signed/sounds/tone3.wav
Binary file not shown.
Binary file added signed/sounds/tone4.wav
Binary file not shown.
Binary file added signed/sounds/tone5.wav
Binary file not shown.
Binary file added signed/sounds/tone6.wav
Binary file not shown.
Binary file added signed/sounds/tone7.wav
Binary file not shown.
Binary file added src/ICON0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
TARGET = tm
OBJS = main.o draw.o file.o menu.o misc.o sound.o

CFLAGS = -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

BUILD_PRX = 1

LIBS = -losl -lc -ljpeg -lpng -lz -lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspgum -lpsphprm -lpspaudiolib -lpspaudio -lm

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = ToneMatrix 0.9
PSP_EBOOT_ICON = ICON0.PNG

PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
58 changes: 58 additions & 0 deletions src/draw.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* ToneMatrix - draw.c
* Copyright (c) 2012 Tanner Babcock */
#include <oslib/oslib.h>
#include "main.h"

// GOLD
void tmDrawGrid(void) {
int x, y;
oslDrawFillRect(0, 15, 480, 255, RGBA(0, 0, 0, 255));
for (x = 1; x < (MAX_X+1); x++) {
for (y = 1; y < (MAX_Y+1); y++) {
if (tmMuteEmpty(mute) || solo == 0) {
if (data[current].grid[x-1][y-1] == OFF)
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? HOFF : OFFC);
else if (data[current].grid[x-1][y-1] == ON)
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? HON : ONC);
else if (data[current].grid[x-1][y-1] == CURSOFF) {
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? HOFF : OFFC);
oslDrawImageXY(select, x1form, y1form);
}
else if (data[current].grid[x-1][y-1] == CURSON) {
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? HON : ONC);
oslDrawImageXY(select, x1form, y1form);
}
}
if (mute[y-1] && solo == 0) {
if (data[current].grid[x-1][y-1] == OFF)
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? MHOFF : MOFF);
else if (data[current].grid[x-1][y-1] == ON)
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? MHON : MON);
else if (data[current].grid[x-1][y-1] == CURSOFF) {
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? MHOFF : MOFF);
oslDrawImageXY(select, x1form, y1form);
}
else if (data[current].grid[x-1][y-1] == CURSON) {
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? MHON : MON);
oslDrawImageXY(select, x1form, y1form);
}
}

if (solo == y && tmMuteEmpty(mute)) {
if (data[current].grid[x-1][y-1] == OFF)
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? SHOFF : SOFF);
else if (data[current].grid[x-1][y-1] == ON)
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? SHON : SON);
else if (data[current].grid[x-1][y-1] == CURSOFF) {
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? SHOFF : SOFF);
oslDrawImageXY(select, x1form, y1form);
}
else if (data[current].grid[x-1][y-1] == CURSON) {
oslDrawFillRect(x1form, y1form, x2form, y2form, (x == col) ? SHON : SON);
oslDrawImageXY(select, x1form, y1form);
}
}
}
}
return;
}
158 changes: 158 additions & 0 deletions src/file.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/* ToneMatrix - file.c
* Copyright (c) 2012 Tanner Babcock */
#include <oslib/oslib.h>
#include <pspiofilemgr_stat.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "main.h"

void tmFileDialog(bool save) {
int x;
unsigned char option = 0;
bool empty[MAX_SAVE_SLOTS];
char strings[MAX_SAVE_SLOTS][50];
char mdate[MAX_SAVE_SLOTS][50];
char tmp[30];

SceIoStat a;
typedef struct {
int year, month, day;
int minute, hour;
} metadata;
metadata songMeta[MAX_SAVE_SLOTS];

current = 0;
for (x = 0; x < MAX_SAVE_SLOTS; x++) {
bzero(tmp, sizeof(tmp));
sprintf(tmp, "songs/song%d.tms", x);
sceIoGetstat(tmp, &a);
songMeta[x].year = a.st_mtime.year;
songMeta[x].month = a.st_mtime.month;
songMeta[x].day = a.st_mtime.day;
songMeta[x].minute = a.st_mtime.minute;
songMeta[x].hour = a.st_mtime.hour;
}
// I have to make a separate struct because accessing sm->tm_mday
// from the while (!osl_quit) fries the memory stick
// same reason why there's a bool empty[]

for (x = 0; x < MAX_SAVE_SLOTS; x++) {
bzero(tmp, sizeof(tmp));
sprintf(tmp, "songs/song%d.tms", x);
empty[x] = tmDoesFileExist(tmp);
}
while (!osl_quit) {
oslStartDrawing();
oslReadKeys();
tmDrawGrid();
oslDrawFillRect(0, 0, 480, 272, RGBA(0, 0, 0, 125));
if (save)
oslDrawString(10, 40, "Press X (cross) to save your song in the selected slot.");
else
oslDrawString(10, 40, "Press X (cross) to load a song from the selected slot.");
oslDrawString(10, 50, "Press O (circle) to cancel.");
for (x = 0; x < MAX_SAVE_SLOTS; x++) {
bzero(strings[x], sizeof(strings[x]));
bzero(tmp, sizeof(tmp));
sprintf(tmp, "song%d.tms", x);
sprintf(strings[x], "%s %s", (option == x) ? "->" : " ", (empty[x]) ? "EMPTY" : tmp);
sprintf(mdate[x], "%d/%d/%d %d:%d UTC", songMeta[x].month, songMeta[x].day, songMeta[x].year, songMeta[x].hour, songMeta[x].minute);
oslDrawString(10, (70+(x*10)), strings[x]);
if (!empty[x])
oslDrawString(200, (70+(x*10)), mdate[x]);
}
oslDrawString(10, 190, "Press /\\ (triangle) to delete the selected song slot.");
if ((osl_keys->pressed.up) && (option > 0))
option--;
if ((osl_keys->pressed.down) && (option < (MAX_SAVE_SLOTS-1)))
option++;
if (osl_keys->pressed.cross) {
if (empty[option]) {
if (save) {
tmWrite(option);
break;
}
}
else {
if (save) {
if (tmOverwriteWarning(option)) {
tmWrite(option);
break;
}
}
else {
tmRead(option);
break;
}
}
}
if (osl_keys->pressed.triangle) {
if (!empty[option]) {
if (tmDeleteWarning(option)) {
bzero(tmp, sizeof(tmp));
sprintf(tmp, "songs/song%d.tms", option);
remove(tmp);
empty[option] = TRUE;
}
}
}
if (osl_keys->pressed.circle)
break;
if (osl_keys->pressed.start)
break;
oslEndDrawing();
oslSyncFrame();
}
return;
}

bool tmDoesFileExist(const char *path) {
FILE *in = fopen(path, "r");
if (!in) {
fclose(in);
return TRUE;
}
else {
fclose(in);
return FALSE;
}
}

void tmRead(int slot) {
int x, y, z;
char f[25];
sprintf(f, "songs/song%d.tms", slot);
FILE *in = fopen(f, "r");
for (z = 0; z < MAX_GRIDS; z++) {
for (x = 0; x < MAX_X; x++) {
for (y = 0; y < MAX_Y; y++)
fscanf(in, "%c", &data[z].grid[x][y]);
fseek(in, 4, SEEK_CUR);
}
fseek(in, 5, SEEK_CUR);
}
fclose(in);
return;
}

void tmWrite(int slot) {
int x, y, z;
char f[25];
sprintf(f, "songs/song%d.tms", slot);
FILE *out = fopen(f, "r");
if (out)
remove(f);
fclose(out);
out = fopen(f, "w");
for (z = 0; z < MAX_GRIDS; z++) {
for (x = 0; x < MAX_X; x++) {
for (y = 0; y < MAX_Y; y++)
fprintf(out, "%c", data[z].grid[x][y]);
fprintf(out, "%c%c%c%c", 82, 42, 82, 22);
}
fprintf(out, "%c%c%c%c\a", 82, 42, 82, 22);
}
fclose(out);
return;
}
Loading

0 comments on commit cfc451e

Please sign in to comment.