projects
/
dosdemo
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
test test
[dosdemo]
/
src
/
screen.c
diff --git
a/src/screen.c
b/src/screen.c
index
a949fc4
..
2387d52
100644
(file)
--- a/
src/screen.c
+++ b/
src/screen.c
@@
-1,6
+1,7
@@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "screen.h"
#include "demo.h"
#include "screen.h"
#include "demo.h"
@@
-9,6
+10,7
@@
struct screen *fract_screen(void);
#define NUM_SCR 32
static struct screen *scr[NUM_SCR];
#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;
static struct screen *cur, *prev, *next;
static long trans_start, trans_dur;
@@
-23,9
+25,12
@@
int scr_init(void)
if(!(scr[idx++] = fract_screen())) {
return -1;
}
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;
}
}
return -1;
}
}
@@
-35,8
+40,7
@@
int scr_init(void)
void scr_shutdown(void)
{
int i;
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();
}
}
scr[i]->shutdown();
}
}
@@
-64,8
+68,7
@@
void scr_draw(void)
struct screen *scr_lookup(const char *name)
{
int i;
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];
}
if(strcmp(scr[i]->name, name) == 0) {
return scr[i];
}
@@
-73,6
+76,16
@@
struct screen *scr_lookup(const char *name)
return 0;
}
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;
int scr_change(struct screen *s, long trans_time)
{
if(!s) return -1;