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

Commit

Permalink
This git repo was stuck on 0.9 and not 0.92, I've updated it after 6 …
Browse files Browse the repository at this point in the history
…years of neglect and not even knowing it was different
  • Loading branch information
Babkock committed Nov 14, 2018
1 parent 3848a55 commit 3f5e431
Show file tree
Hide file tree
Showing 18 changed files with 201 additions and 181 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ToneMatrix changelog:

0.92:
- Fixed some things in the code

0.9:
- Added save song and load song functions
- Changed from 12 grids to 16 grids
Expand Down
Binary file added src/EBOOT.PBP
Binary file not shown.
4 changes: 2 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TARGET = tm
OBJS = main.o draw.o file.o menu.o misc.o sound.o
OBJS = draw.o file.o grid.o main.o menu.o misc.o rhythm.o sound.o

CFLAGS = -G4 -Wall -O2
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
Expand All @@ -10,7 +10,7 @@ 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_TITLE = ToneMatrix 0.93
PSP_EBOOT_ICON = ICON0.PNG

PSPSDK=$(shell psp-config --pspsdk-path)
Expand Down
Binary file added src/PARAM.SFO
Binary file not shown.
70 changes: 27 additions & 43 deletions src/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,40 @@
* Copyright (c) 2012 Tanner Babcock */
#include <oslib/oslib.h>
#include "main.h"
#include "draw.h"

int tmGetColor(char gridval, int x, int y) {
int c = 0;
if (tmMuteEmpty(mute) || solo == 0) {
switch (gridval) {
case OFF: case CURSOFF: c = (x == col) ? HOFF : OFFC; break;
case ON: case CURSON: c = (x == col) ? HON : ONC; break;
}
}
if (mute[y-1] && solo == 0) {
switch (gridval) {
case OFF: case CURSOFF: c = (x == col) ? MHOFF : MOFF; break;
case ON: case CURSON: c = (x == col) ? MHON : MON; break;
}
}
if (solo == y && tmMuteEmpty(mute)) {
switch (gridval) {
case OFF: case CURSOFF: c = (x == col) ? SHOFF : SOFF; break;
case ON: case CURSON: c = (x == col) ? SHON : SON; break;
}
}
return c;
}

// 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);
}
}
oslDrawFillRect(x1form, y1form, x2form, y2form, tmGetColor(data[current].grid[x-1][y-1], x, y));
if (data[current].grid[x-1][y-1] == CURSON || data[current].grid[x-1][y-1] == CURSOFF)
oslDrawImageXY(select, x1form, y1form);
}
}
return;
Expand Down
24 changes: 24 additions & 0 deletions src/draw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* ToneMatrix - draw.h
* Copyright (c) 2011-2012 Tanner Babcock */
#ifndef DRAW_H
#define DRAW_H

#define OFFC RGBA(30,30,30,255) // off
#define ONC RGBA(199,199,199,255) // on
#define HOFF RGBA(50,50,50,255) // lit up and off
#define HON RGBA(220,220,220,255) // lit up and on
#define MOFF RGBA(40,0,0,255) // off, row muted
#define MON RGBA(199,0,0,255) // on, row muted
#define MHOFF RGBA(60,0,0,255) // lit up and off, row muted
#define MHON RGBA(220,0,0,255) // lit up and on, row muted
#define SOFF RGBA(0,7,40,255) // off, row soloed
#define SON RGBA(0,8,199,255) // on, row soloed
#define SHOFF RGBA(0,7,60,255) // lit up and off, row soloed
#define SHON RGBA(0,8,220,255) // lit up and on, row soloed

#define x1form ((x*30)-29)
#define y1form ((15+(y*30))-29)
#define x2form ((x*30)-1)
#define y2form ((15+(y*30))-1)

#endif
8 changes: 4 additions & 4 deletions src/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ void tmFileDialog(bool save) {
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[]

/* 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);
Expand Down
40 changes: 40 additions & 0 deletions src/grid.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* ToneMatrix - grid.c
* Copyright (c) 2011-2012 Tanner Babcock */
#include <oslib/oslib.h>
#include <stdlib.h>
#include "main.h"

void tmClear(tmGrid *g) {
int y, z;
for (y = 0; y < MAX_X; y++) {
for (z = 0; z < MAX_Y; z++)
g->grid[y][z] = OFF;
}
g->grid[0][0] = CURSOFF;
return;
}

bool tmIsGridEmpty(tmGrid *g) {
int x, y;
for (x = 0; x < MAX_Y; x++) {
for (y = 0; y < MAX_X; y++) {
if (g->grid[x][y] != OFF && g->grid[x][y] != CURSOFF)
return FALSE;
}
}
return TRUE;
}

void tmSwitchGrid(int *a, int *b) {
// call from tmMainloop with tmSwitchGrid(&x, &y)
int x, y;
for (x = 0; x < MAX_X; x++) {
for (y = 0; y < MAX_Y; y++) {
if (data[current].grid[x][y] == CURSON)
data[current].grid[x][y] = ON;
if (data[current].grid[x][y] == CURSOFF)
data[current].grid[x][y] = OFF;
}
}
return;
}
13 changes: 7 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
#include <pspkernel.h>
#include <psputils.h>
#include "main.h"
#include "menu.h"
#define c data[current]
PSP_MODULE_INFO("ToneMatrix", 0, 1, 1);
PSP_MAIN_THREAD_ATTR(THREAD_ATTR_USER | THREAD_ATTR_VFPU);
PSP_HEAP_SIZE_KB(-2048);
PSP_HEAP_SIZE_KB(2048);

void tmMainLoop(void) {
int x = 0, y = 0, q, m;
int tmpcurrent = current;
clock_t start, cu, d;
clock_t start, cu;
start = sceKernelLibcClock();
oslClearScreen(RGBA(0, 0, 0, 255));
tmStart();
Expand Down Expand Up @@ -78,7 +79,7 @@ void tmMainLoop(void) {
else if (c.grid[x-1][y] == OFF)
c.grid[x-1][y] = CURSOFF;
x--;
}
}
}
if (osl_keys->pressed.right) {
if (x < (MAX_X-1)) {
Expand Down Expand Up @@ -121,7 +122,7 @@ void tmMainLoop(void) {
solo = 0;
mute[y] = (mute[y]) ? FALSE : TRUE;
}

if (osl_keys->pressed.R) {
if (current < 11)
current++;
Expand All @@ -142,12 +143,12 @@ void tmMainLoop(void) {
tmHelp();
break;
case CLEARM:
data[current] = tmClear();
tmClear(&data[current]);
break;
case CLEARALLM:
if (tmClearAllWarning()) {
for (q = 0; q < MAX_GRIDS; q++)
data[q] = tmClear();
tmClear(&data[q]);
current = 0;
x = 0, y = 0;
}
Expand Down
99 changes: 39 additions & 60 deletions src/main.h
Original file line number Diff line number Diff line change
@@ -1,61 +1,26 @@
/* ToneMatrix - main.h
* Copyright (c) 2012 Tanner Babcock */
* Copyright (c) 2011-2012 Tanner Babcock */
#ifndef MAIN_H
#define MAIN_H

#include <oslib/oslib.h>
#include <pspmodulemgr.h>

#define VERSION "0.9"
#define VERSION "0.93"
#define bool char
#define tmQuit() oslEndGfx(); oslQuit()
#define tmAbort(err) \
int s; \
oslClearScreen(RGBA(0, 0, 0, 255)); \
for (s = 0; s < 4; s++) { \
oslStartDrawing(); \
oslReadKeys(); \
oslDrawString(10, 10, err); \
oslEndDrawing(); \
oslSyncFrame(); \
} \
oslStartDrawing(); \
oslReadKeys(); \
oslDrawString(10, 10, err); \
oslEndDrawing(); \
oslSyncFrame();\
sceKernelDelayThread(2000000); \
tmQuit()

#define OFFC RGBA(30,30,30,255) // off
#define ONC RGBA(199,199,199,255) // on
#define HOFF RGBA(50,50,50,255) // lit up and off
#define HON RGBA(220,220,220,255) // lit up and on
#define MOFF RGBA(40,0,0,255) // off, row muted
#define MON RGBA(199,0,0,255) // on, row muted
#define MHOFF RGBA(60,0,0,255) // lit up and off, row muted
#define MHON RGBA(220,0,0,255) // lit up and on, row muted
#define SOFF RGBA(0,7,40,255) // off, row soloed
#define SON RGBA(0,8,199,255) // on, row soloed
#define SHOFF RGBA(0,7,60,255) // lit up and off, row soloed
#define SHON RGBA(0,8,220,255) // lit up and on, row soloed

#define x1form ((x*30)-29)
#define y1form ((15+(y*30))-29)
#define x2form ((x*30)-1)
#define y2form ((15+(y*30))-1)

enum { FALSE, TRUE };
enum { OFF, ON, CURSOFF, CURSON };
enum {
SAVEM, // Save song
LOADM, // Load song
HELPM, // Help me
LOOPM, // Loop all: on
TEMPOM, // Tempo: 120 BPM
GRIDM, // Grid: 0
BREAK, //
CUTM, // Cut grid
COPYM, // Copy grid
PASTEM, // Paste grid
CLEARM, // Clear current grid
CLEARALLM // Clear all grids
};
enum {
MAX_MENU_ITEMS = 12,
MAX_GRIDS = 16,
Expand All @@ -67,7 +32,7 @@ enum {
};

typedef struct {
char grid[16][8];
char grid[MAX_X][MAX_Y];
} tmGrid;

int bpm;
Expand All @@ -82,29 +47,43 @@ SceUID soundloop;
OSL_SOUND *sound[MAX_Y];
OSL_IMAGE *select;

void tmInit(void);
void tmDebug(int x, int y, const char *str);
void tmSoundLoop(void);
void tmMainLoop(void);
// draw.c
int tmGetColor(char gridval, int x, int y);
void tmDrawGrid(void);

// file.c
void tmFileDialog(bool save);
bool tmDoesFileExist(const char *path);
void tmRead(int slot);
void tmWrite(int slot);

// grid.c
void tmClear(tmGrid *g);
bool tmIsGridEmpty(tmGrid *g);
void tmSwitchGrid(int *a, int *b);

// main.c
void tmMainLoop(void);

// menu.c
unsigned char tmMenu(void);
void tmHelp(void);
bool tmClearAllWarning(void);
bool tmOverwriteWarning(int slot);
bool tmDeleteWarning(int slot);

// misc.c
void tmInit(void);
void tmDebug(int x, int y, const char *str);
void setUpVirtualFileMenu(void);
unsigned char tmMenu(void);
tmGrid tmClear(void);

// rhythm.c
double tmTempo(int b);
int tmBPM(double t);
void tmMuteCheck(void);
bool tmMuteEmpty(bool m[8]);
bool tmIsGridEmpty(tmGrid g);
void tmSwitchGrid(int a, int b);
bool tmClearAllWarning(void);
void tmFileDialog(bool save);
bool tmOverwriteWarning(int slot);
bool tmDeleteWarning(int slot);
bool tmDoesFileExist(const char *path);
const char * tmOSK(const char *name);
void tmRead(int slot);
void tmWrite(int slot);

// sound.c
void tmSoundLoop(void);
void tmStop(void);
void tmStart(void);

Expand Down
Loading

0 comments on commit 3f5e431

Please sign in to comment.