Skip to content

Commit

Permalink
tune->tracklen is working now.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfiredrill committed Aug 20, 2009
1 parent bc118bc commit caf4c60
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
10 changes: 5 additions & 5 deletions actions.c
Expand Up @@ -75,10 +75,10 @@ void act_mvdown(void){
}
break;
case 1:
if(tracky < tracklen - 1){
if(tracky < tune->tracklen - 1){
tracky++;
}else{
tracky = tracklen - 1;
tracky = tune->tracklen - 1;
}
break;
case 2:
Expand Down Expand Up @@ -125,10 +125,10 @@ void act_bigmvdown(void){
}
break;
case 1:
if(tracky < tracklen - 8){
if(tracky < tune->tracklen - 8){
tracky += 8;
}else{
tracky = tracklen - 1;
tracky = tune->tracklen - 1;
}
break;
case 2:
Expand All @@ -143,7 +143,7 @@ void act_mvbottom(void){
songy = tune->songlen - 1;
break;
case 1:
tracky = tracklen - 1;
tracky = tune->tracklen - 1;
break;
case 2:
instry = instrument[currinstr].length - 1;
Expand Down
8 changes: 4 additions & 4 deletions gui.c
Expand Up @@ -540,7 +540,7 @@ void drawtracked(int x, int y, int height){
if(tracky < trackoffs) trackoffs = tracky;
if(tracky >= trackoffs + height) trackoffs = tracky - height + 1;

for(i = 0; i < tracklen; i++){
for(i = 0; i < tune->tracklen; i++){
if(i >= trackoffs && i - trackoffs < height){
move(y + i - trackoffs, x + 0);
if(i == tracky) attrset(A_BOLD);
Expand All @@ -550,9 +550,9 @@ void drawtracked(int x, int y, int height){

if(i == 0){ addch(ACS_LLCORNER); }
else if(i == 1){ addch(ACS_ULCORNER); }
else if(i == tracklen-1){ addch(ACS_LLCORNER); }
else if(i == tune->tracklen-1){ addch(ACS_LLCORNER); }
else if(i%4 == 0){ addch(ACS_LTEE); }
else if(i < tracklen-1){ addch(ACS_VLINE); }
else if(i < tune->tracklen-1){ addch(ACS_VLINE); }
addch(' ');

// should this line be highlighted?
Expand Down Expand Up @@ -586,7 +586,7 @@ void drawtracked(int x, int y, int height){
}
addstr(buf);
}
if(playtrack && ((i + 1) % tracklen) == tune->trackpos){
if(playtrack && ((i + 1) % tune->tracklen) == tune->trackpos){
attrset(A_STANDOUT);
addch('*');
}
Expand Down
5 changes: 3 additions & 2 deletions lft.c
Expand Up @@ -424,7 +424,7 @@ void lft_savefile(char *fname){
fprintf(f, "#%s\n", comment);
fprintf(f, "\n");
fprintf(f, "tempo: %d\n", callbacktime);
for(i = 0; i < songlen; i++){
for(i = 0; i < tune->songlen; i++){
fprintf(f, "songline %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
i,
song[i].track[0],
Expand All @@ -438,7 +438,7 @@ void lft_savefile(char *fname){
}
fprintf(f, "\n");
for(i = 1; i < 256; i++){
for(j = 0; j < tracklen; j++){
for(j = 0; j < tune->tracklen; j++){
struct trackline *tl = &track[i].line[j];

if(tl->note || tl->instr || tl->cmd[0] || tl->cmd[1]){
Expand Down Expand Up @@ -509,6 +509,7 @@ pineapple_tune *lft_loadfile(char *fname){
rewind(f);

t->songlen = 1;
t->tracklen = TRACKLEN;
while(!feof(f) && fgets(buf, sizeof(buf), f)){
if(1 == sscanf(buf, "#%1024c", &comment)){
}
Expand Down
5 changes: 3 additions & 2 deletions main.c
Expand Up @@ -32,7 +32,8 @@ pineapple_tune *importHvl(struct hvl_tune *ht) {

tune->songlen = ht->ht_PositionNr;
printf("songlen: %i\n", tune->songlen);


tune->tracklen = ht->ht_TrackLength;

return tune;
}
Expand Down Expand Up @@ -85,6 +86,6 @@ int main(int argc, char **argv){

SDL_Quit();
}

free(tune);
return 0;
}
20 changes: 10 additions & 10 deletions modes.c
Expand Up @@ -25,7 +25,7 @@ int nextfreetrack(){
int skiptherest = 0;

for(int i = 1; i <= 0xff; i++){
for(int j = 0; j < tracklen; j++){
for(int j = 0; j < tune->tracklen; j++){
if(track[i].line[j].note) skiptherest = 1;
for(int k = 0; k < 2; k++){
if(track[i].line[j].cmd[k]) skiptherest = 1;
Expand All @@ -39,7 +39,7 @@ int nextfreetrack(){
}

// this track is free, so return the index
if(j == tracklen-1) return i;
if(j == (tune->tracklen)-1) return i;
}
}

Expand Down Expand Up @@ -337,7 +337,7 @@ void normalmode(int c){
}
break;
case 1:
if(tracky<=tracklen-2){
if(tracky<=(tune->tracklen)-2){
if(tracky==trackoffs)
tracky++;
trackoffs++;
Expand Down Expand Up @@ -377,8 +377,8 @@ void normalmode(int c){
: ((getmaxy(stdscr)-6)/2) + songoffs;
break;
case 1:
tracky = (tracklen <= getmaxy(stdscr)-2)?
tracklen/2
tracky = (tune->tracklen <= getmaxy(stdscr)-2)?
tune->tracklen/2
: ((getmaxy(stdscr)-6)/2) + trackoffs;
break;
case 2:
Expand All @@ -396,8 +396,8 @@ void normalmode(int c){
: getmaxy(stdscr)-3+songoffs;
break;
case 1:
tracky = (tracklen <= getmaxy(stdscr)-2)?
tracklen-1
tracky = (tune->tracklen <= getmaxy(stdscr)-2)?
tune->tracklen-1
: getmaxy(stdscr)-3+trackoffs;
break;
case 2:
Expand Down Expand Up @@ -492,8 +492,8 @@ void normalmode(int c){
}else if(currtab == 1){
for(int i = 0; i < tcliplen; i++){
memcpy(&track[currtrack].line[tracky], &tclip[i], sizeof(struct trackline));
if(tracky < tracklen-step) tracky += step;
else tracky = tracklen-1;
if(tracky < (tune->tracklen)-step) tracky += step;
else tracky = (tune->tracklen)-1;
}
}else if(currtab == 2){
if(instrument[currinstr].length < 256){
Expand Down Expand Up @@ -1057,7 +1057,7 @@ void insertmode(void){
_insertc(c);
if(currtab == 1){
tracky+=step;
tracky %= tracklen;
tracky %= (tune->tracklen);
}else if(currtab == 2){
//if(instry < instrument[currinstr].length-1) instry++;
if(instrx < 2) instrx++;
Expand Down
5 changes: 3 additions & 2 deletions pineapple.h
Expand Up @@ -79,7 +79,7 @@ struct instrument instrument[256], iclip[256];
struct track track[256], tclip[256];
struct songline song[256];

int songlen;
//int songlen;
int tracklen;

void initchip(void);
Expand Down Expand Up @@ -187,8 +187,9 @@ typedef struct _pineapple_tune {
struct track trk[256]; //struct hvl_step ht_Tracks[256][64]
struct songline sng[256]; //struct hvl_position *ht_Positions
int songlen; //ht_PositionNr
int trackpos;
int songpos; //ht_PosNr
int trackpos;
int tracklen; //ht_TrackLength
int instrx, instry, instroffs;
int songx, songy, songoffs;
int trackx, tracky, trackoffs;
Expand Down

0 comments on commit caf4c60

Please sign in to comment.