projects
/
xscreensaver
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
From http://www.jwz.org/xscreensaver/xscreensaver-5.35.tar.gz
[xscreensaver]
/
hacks
/
m6502.c
diff --git
a/hacks/m6502.c
b/hacks/m6502.c
index 8361fbd0dca03d0093379ab6369a791126875112..4f90a6a10acf8b1f396556c372c6e3e4cd2ac005 100644
(file)
--- a/
hacks/m6502.c
+++ b/
hacks/m6502.c
@@
-12,7
+12,7
@@
* Created: 07-May-2007
*/
* Created: 07-May-2007
*/
-#include <
stdint.h>
+#include <
inttypes.h>
#include <string.h>
#include "screenhack.h"
#include "analogtv.h"
#include <string.h>
#include "screenhack.h"
#include "analogtv.h"
@@
-23,11
+23,16
@@
ISO C89 compilers are required to support" when includng
the following data file... */
# endif
ISO C89 compilers are required to support" when includng
the following data file... */
# endif
-const char * const demo_files[] = {
+
static
const char * const demo_files[] = {
# include "m6502.h"
};
# include "m6502.h"
};
+#ifndef HAVE_MOBILE
+# define READ_FILES
+#endif
+
+
/* We want to paint on a 32 by 32 grid of pixels. We will needed to
divided the screen up into chuncks */
enum {
/* We want to paint on a 32 by 32 grid of pixels. We will needed to
divided the screen up into chuncks */
enum {
@@
-55,6
+60,7
@@
struct state {
int which;/* the program to run*/
int demos;/* number of demos included */
struct timeval start_time;
int which;/* the program to run*/
int demos;/* number of demos included */
struct timeval start_time;
+ int reset_p;
};
static void
};
static void
@@
-74,7
+80,7
@@
start_rand_bin_prog(machine_6502 *machine, struct state *st){
while(n == st->which)
n = random() % st->demos;
st->which = n;
while(n == st->which)
n = random() % st->demos;
st->which = n;
- start_eval_string(machine, demo_files[st->which], plot6502, st);
+
m6502_
start_eval_string(machine, demo_files[st->which], plot6502, st);
}
\f
}
\f
@@
-114,7
+120,6
@@
m6502_init (Display *dpy, Window window)
{
struct state *st = (struct state *) calloc (1, sizeof(*st));
unsigned int x, y;
{
struct state *st = (struct state *) calloc (1, sizeof(*st));
unsigned int x, y;
- char *s = get_string_resource (dpy, "file", "File");
int n = get_integer_resource(dpy, "displaytime", "Displaytime");
int dh;
st->demos = countof(demo_files);
int n = get_integer_resource(dpy, "displaytime", "Displaytime");
int dh;
st->demos = countof(demo_files);
@@
-125,7
+130,7
@@
m6502_init (Display *dpy, Window window)
st->tv=analogtv_allocate(st->dpy, st->window);
analogtv_set_defaults(st->tv, "");
st->tv=analogtv_allocate(st->dpy, st->window);
analogtv_set_defaults(st->tv, "");
- st->machine =
build6502
();
+ st->machine =
m6502_build
();
st->inp=analogtv_input_allocate();
analogtv_setup_sync(st->inp, 1, 0);
st->inp=analogtv_input_allocate();
analogtv_setup_sync(st->inp, 1, 0);
@@
-141,10
+146,15
@@
m6502_init (Display *dpy, Window window)
init_time(st);
init_time(st);
- if (strlen(s) > 0)
- start_eval_file(st->machine,s, plot6502, st);
+ {
+#ifdef READ_FILES
+ char *s = get_string_resource (dpy, "file", "File");
+ if (strlen(s) > 0)
+ m6502_start_eval_file(st->machine,s, plot6502, st);
else
else
+#endif
start_rand_bin_prog(st->machine,st);
start_rand_bin_prog(st->machine,st);
+ }
analogtv_lcp_to_ntsc(ANALOGTV_BLACK_LEVEL, 0.0, 0.0, st->field_ntsc);
analogtv_lcp_to_ntsc(ANALOGTV_BLACK_LEVEL, 0.0, 0.0, st->field_ntsc);
@@
-213,20
+223,20
@@
m6502_draw (Display *dpy, Window window, void *closure)
struct state *st = (struct state *) closure;
unsigned int x = 0, y = 0;
double te;
struct state *st = (struct state *) closure;
unsigned int x = 0, y = 0;
double te;
+ const analogtv_reception *reception = &st->reception;
- next_eval(st->machine,500);
+
m6502_
next_eval(st->machine,500);
for (x = 0; x < 32; x++)
for (y = 0; y < 32; y++)
paint_pixel(st,x,y,st->pixels[x][y]);
for (x = 0; x < 32; x++)
for (y = 0; y < 32; y++)
paint_pixel(st,x,y,st->pixels[x][y]);
- analogtv_init_signal(st->tv, 0.04);
analogtv_reception_update(&st->reception);
analogtv_reception_update(&st->reception);
- analogtv_add_signal(st->tv, &st->reception);
- analogtv_draw(st->tv);
+ analogtv_draw(st->tv, 0.04, &reception, 1);
te = get_time(st);
te = get_time(st);
- if (te > st->dt){ /* do something more interesting here XXX */
+ if (st->reset_p || te > st->dt){ /* do something more interesting here XXX */
+ st->reset_p = 0;
for(x = 0; x < 32; x++)
for(y = 0; y < 32; y++)
st->pixels[x][y] = 0;
for(x = 0; x < 32; x++)
for(y = 0; y < 32; y++)
st->pixels[x][y] = 0;
@@
-234,7
+244,11
@@
m6502_draw (Display *dpy, Window window, void *closure)
start_rand_bin_prog(st->machine,st);
}
start_rand_bin_prog(st->machine,st);
}
- return 10000;
+#ifdef HAVE_MOBILE
+ return 0;
+#else
+ return 5000;
+#endif
}
}
@@
-267,6
+281,12
@@
m6502_reshape (Display *dpy, Window window, void *closure,
static Bool
m6502_event (Display *dpy, Window window, void *closure, XEvent *event)
{
static Bool
m6502_event (Display *dpy, Window window, void *closure, XEvent *event)
{
+ struct state *st = (struct state *) closure;
+ if (screenhack_event_helper (dpy, window, event))
+ {
+ st->reset_p = 1;
+ return True;
+ }
return False;
}
return False;
}