unsigned int mouse_bmask;
static unsigned long nframes;
-static const char *start_scr_name = "tunnel";
+static const char *start_scr_name;
int demo_init(int argc, char **argv)
{
+ struct screen *scr;
+
if(argv[1]) {
start_scr_name = argv[1];
}
if(scr_init() == -1) {
return -1;
}
- if(scr_change(scr_lookup(start_scr_name), 4000) == -1) {
- fprintf(stderr, "screen %s not found\n", start_scr_name);
+ if(start_scr_name) {
+ scr = scr_lookup(start_scr_name);
+ } else {
+ scr = scr_screen(0);
+ }
+
+ if(!scr || scr_change(scr, 4000) == -1) {
+ fprintf(stderr, "screen %s not found\n", start_scr_name ? start_scr_name : "0");
return -1;
}
break;
default:
+ if(key >= '1' && key <= '1' + scr_num_screens()) {
+ int idx = key - '1';
+ printf("change screen %d\n", idx);
+ scr_change(scr_screen(idx), 4000);
+ }
break;
}
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "screen.h"
#include "demo.h"
#define NUM_SCR 32
static struct screen *scr[NUM_SCR];
+static int num_screens;
static struct screen *cur, *prev, *next;
static long trans_start, trans_dur;
if(!(scr[idx++] = fract_screen())) {
return -1;
}
+ num_screens = idx;
- for(i=0; i<NUM_SCR; i++) {
- if(scr[i] && scr[i]->init() == -1) {
+ assert(num_screens <= NUM_SCR);
+
+ for(i=0; i<num_screens; i++) {
+ if(scr[i]->init() == -1) {
return -1;
}
}
void scr_shutdown(void)
{
int i;
- for(i=0; i<NUM_SCR; i++) {
- if(!scr[i]) break;
+ for(i=0; i<num_screens; i++) {
scr[i]->shutdown();
}
}
struct screen *scr_lookup(const char *name)
{
int i;
- for(i=0; i<NUM_SCR; i++) {
- if(!scr[i]) break;
+ for(i=0; i<num_screens; i++) {
if(strcmp(scr[i]->name, name) == 0) {
return scr[i];
}
return 0;
}
+struct screen *scr_screen(int idx)
+{
+ return scr[idx];
+}
+
+int scr_num_screens(void)
+{
+ return num_screens;
+}
+
int scr_change(struct screen *s, long trans_time)
{
if(!s) return -1;
void scr_draw(void);
struct screen *scr_lookup(const char *name);
+struct screen *scr_screen(int idx);
+int scr_num_screens(void);
int scr_change(struct screen *s, long trans_time);
#endif /* SCREEN_H_ */
for(i=0; i<NUM_WORK_ITEMS; i++) {
int starty = i * num_lines;
+ int resty = starty + draw_lines;
+ int rest_lines = num_lines - draw_lines;
draw_tunnel_range((unsigned short*)fb_pixels, xoffs, yoffs, starty, draw_lines, time_msec);
+ if(rest_lines) {
+ memset((unsigned short*)fb_pixels + resty * fb_width, 0, rest_lines * fb_width * 2);
+ }
}
}