comparison ppl.c @ 99:7a59611f9d4f

Various minor improvements in PPL.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Oct 2012 20:26:08 +0300
parents 5cefa59baa9d
children 1d7dc7c8745c
comparison
equal deleted inserted replaced
98:82b825bb08b0 99:7a59611f9d4f
173 { 173 {
174 dmError("Can't SDL_SetVideoMode(): %s\n", SDL_GetError()); 174 dmError("Can't SDL_SetVideoMode(): %s\n", SDL_GetError());
175 return FALSE; 175 return FALSE;
176 } 176 }
177 177
178 col.inboxBg = dmCol(0.7, 0.55, 0.1); 178 col.inboxBg = dmCol(0.6, 0.5, 0.2);
179 col.boxBg = dmCol(0.8, 0.65, 0.15); 179 col.boxBg = dmCol(0.7, 0.6, 0.3);
180 col.box1 = dmCol(0.95, 0.95, 0.8); 180 col.box1 = dmCol(1.0, 0.9, 0.6);
181 col.box2 = dmCol(0.3, 0.3, 0.15); 181 col.box2 = dmCol(0.3, 0.3, 0.15);
182 col.viewDiv = dmCol(0,0,0); 182 col.viewDiv = dmCol(0,0,0);
183 col.activeRow = dmCol(150,80,0); 183 col.activeRow = dmCol(0.5,0.4,0.1);
184 184
185 return TRUE; 185 return TRUE;
186 } 186 }
187 187
188 188
267 if (n->param != jsetNotSet) 267 if (n->param != jsetNotSet)
268 sprintf(ptr, "%.2x", n->param); 268 sprintf(ptr, "%.2x", n->param);
269 else 269 else
270 sprintf(ptr, ".."); 270 sprintf(ptr, "..");
271 271
272 dmDrawBMTextConst(screen, font, DMD_SATURATE, xc, yc, text); 272 dmDrawBMTextConst(screen, font, DMD_TRANSPARENT, xc, yc, text);
273 } 273 }
274 274
275 275
276 void dmDisplayPattern(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSPattern *pat, int row, int choffs) 276 void dmDisplayPattern(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSPattern *pat, int row, int choffs)
277 { 277 {
278 int cwidth = (font->width * 10 + 3 * 4 + 5), 278 int cwidth = (font->width * 10 + 3 * 4 + 5),
279 lwidth = 6 + font->width * 3, 279 lwidth = 6 + font->width * 3,
280 qwidth = ((x1 - x0 - lwidth) / cwidth), 280 qwidth = ((x1 - x0 - lwidth) / cwidth),
281 qheight = ((y1 - y0 - 4) / (font->height + 1)), 281 qheight = ((y1 - y0 - 4) / (font->height + 1)),
282 nrow, nchannel, 282 nrow, nchannel, yc,
283 midrow = qheight / 2; 283 midrow = qheight / 2;
284 284
285 dmDrawBox3D(screen, x0 + lwidth, y0, x1, y1, 285 dmDrawBox3D(screen, x0 + lwidth, y0, x1, y1,
286 col.inboxBg, col.box2, col.box1); 286 col.inboxBg, col.box2, col.box1);
287 287
288 yc = y0 + 2 + (font->height + 1) * midrow;
289 dmFillRect(screen, x0 + lwidth + 1, yc - 1, x1 - 1, yc + font->height, col.activeRow);
290
288 for (nchannel = 1; nchannel < qwidth; nchannel++) 291 for (nchannel = 1; nchannel < qwidth; nchannel++)
289 { 292 {
290 dmDrawVLine(screen, y0 + 1, y1 - 1, x0 + lwidth + 1 + nchannel * cwidth, col.viewDiv); 293 dmDrawVLine(screen, y0 + 1, y1 - 1, x0 + lwidth + 1 + nchannel * cwidth, col.viewDiv);
291 } 294 }
292 295
293
294 for (nrow = 0; nrow < qheight; nrow++) 296 for (nrow = 0; nrow < qheight; nrow++)
295 { 297 {
296 int yc = y0 + 2 + (font->height + 1) * nrow; 298 int crow = nrow - midrow + row;
299 yc = y0 + 2 + (font->height + 1) * nrow;
297 300
298 dmDrawBMText(screen, font, DMD_SATURATE, x0, yc, "%03d", nrow); 301 if (crow >= 0 && crow < pat->nrows)
299
300 if (nrow == row)
301 { 302 {
302 dmFillRect(screen, x0 + lwidth + 1, yc - 1, x1 - 1, yc + font->height, col.activeRow); 303 dmDrawBMText(screen, font, DMD_TRANSPARENT, x0, yc, "%03d", crow);
303 } 304
304 305 for (nchannel = 0; nchannel < qwidth; nchannel++)
305 for (nchannel = 0; nchannel < qwidth; nchannel++) 306 {
306 { 307 if (choffs + nchannel >= pat->nchannels)
307 if (choffs + nchannel >= pat->nchannels) 308 break;
308 break; 309
309 310 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc,
310 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc, 311 pat->data + (pat->nchannels * crow) + choffs + nchannel);
311 pat->data + (pat->nchannels * nrow) + choffs + nchannel); 312 }
312 } 313 }
313 } 314 }
314 } 315 }
315 316
316 317
405 dmError("Could not convert module for playing, %d: %s\n", 406 dmError("Could not convert module for playing, %d: %s\n",
406 result, dmErrorStr(result)); 407 result, dmErrorStr(result));
407 goto error_exit; 408 goto error_exit;
408 } 409 }
409 410
411 #if 0
410 if ((file = dmf_create_stdio(optFontFilename, "rb")) == NULL) 412 if ((file = dmf_create_stdio(optFontFilename, "rb")) == NULL)
411 { 413 {
412 dmError("Error opening font file '%s', %d: %s\n", 414 dmError("Error opening font file '%s', %d: %s\n",
413 optFontFilename, errno, strerror(errno)); 415 optFontFilename, errno, strerror(errno));
414 goto error_exit; 416 goto error_exit;
418 if (fontbmap == NULL) 420 if (fontbmap == NULL)
419 { 421 {
420 dmError("Could not load image file '%s'.\n", optFontFilename); 422 dmError("Could not load image file '%s'.\n", optFontFilename);
421 goto error_exit; 423 goto error_exit;
422 } 424 }
423 425
424 if ((result = dmCreateBitmapFontFromImage(fontbmap, 8, 8, &font)) != DMERR_OK) 426 if ((result = dmCreateBitmapFontFromImage(fontbmap, 8, 8, &font)) != DMERR_OK)
425 { 427 {
426 dmError("Could not create a font from image, %d: %s\n", 428 dmError("Could not create a font from image, %d: %s\n",
427 result, dmErrorStr(result)); 429 result, dmErrorStr(result));
428 goto error_exit; 430 goto error_exit;
429 } 431 }
430 SDL_FreeSurface(fontbmap); 432 SDL_FreeSurface(fontbmap);
431 433 #else
434 if ((file = dmf_create_stdio("fnsmall.fnt", "rb")) == NULL)
435 {
436 dmError("Error opening font file '%s', %d: %s\n",
437 optFontFilename, errno, strerror(errno));
438 goto error_exit;
439 }
440 result = dmLoadBitmapFont(file, &font);
441 dmf_close(file);
442 if (result != DMERR_OK)
443 {
444 dmError("Could not load font from file, %d: %s\n",
445 result, dmErrorStr(result));
446 goto error_exit;
447 }
448 #endif
432 449
433 // Initialize SDL components 450 // Initialize SDL components
434 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0) 451 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0)
435 { 452 {
436 dmError("Could not initialize SDL: %s\n", SDL_GetError()); 453 dmError("Could not initialize SDL: %s\n", SDL_GetError());
541 } 558 }
542 559
543 dmDrawBox3D(engine.screen, 0, 0, engine.screen->w - 1, engine.screen->h - 1, 560 dmDrawBox3D(engine.screen, 0, 0, engine.screen->w - 1, engine.screen->h - 1,
544 col.boxBg, col.box1, col.box2); 561 col.boxBg, col.box1, col.box2);
545 562
546 dmDrawBMText(engine.screen, font, DMD_SATURATE, 5, 5, "%s v%s by ccr/TNSP - (c) Copyright 2012 TNSP", dmProgDesc, dmProgVersion); 563 dmDrawBMText(engine.screen, font, DMD_TRANSPARENT, 5, 5, "%s v%s by ccr/TNSP - (c) Copyright 2012 TNSP", dmProgDesc, dmProgVersion);
547 564
548 565
549 JSS_LOCK(dev); 566 JSS_LOCK(dev);
550 JSS_LOCK(plr); 567 JSS_LOCK(plr);
551 568
552 dmDrawBMText(engine.screen, font, DMD_SATURATE, 5, 5 + 9, 569 dmDrawBMText(engine.screen, font, DMD_TRANSPARENT, 5, 5 + 12,
553 "Tempo %3d | Speed: %3d | Row: %3d | Order: %d", 570 "Tempo: %3d | Speed: %3d | Row: %3d | Order: %d",
554 plr->tempo, plr->speed, plr->row, plr->order 571 plr->tempo, plr->speed, plr->row, plr->order
555 ); 572 );
556 573
557 dmDisplayPattern(engine.screen, 5, 30, engine.screen->w - 6, engine.screen->h - 10, 574 dmDisplayPattern(engine.screen, 5, 30, engine.screen->w - 6, engine.screen->h - 10,
558 plr->pattern, plr->row, 0); 575 plr->pattern, plr->row, 0);