Skip to content

M-Film: film simulation for Canon EOS cameras with Magic Lantern. 72 film stocks (Portra, Velvia, Tri-X, CineStill…), a film-camera interface and an in-camera darkroom that develops your RAWs. 5D Mark III, 6D, 600D, 650D, 700D, EOS M and more.

EOS M: the overdraw, exposure simulation and Delete roll changes fit its boot memory together

Claude6a171f20a052
diff --git a/ml-dev/filmos/fos_dev.c b/ml-dev/filmos/fos_dev.c
index fd6efba..594c75b 100644
--- a/ml-dev/filmos/fos_dev.c
+++ b/ml-dev/filmos/fos_dev.c
@@ -1450,8 +1450,8 @@ static __attribute__((noinline)) int nearest(struct fos_dev *d, int cell)
static int write_print(const char *path, int film, int frame, const char *when, const char *fstop,
const uint8_t pal[][3], int npal, const uint8_t *px, const uint8_t *thumb, int x0, int w)
{
- static uint8_t h[FOS_BMP_PIXELS];
- memset(h, 0, sizeof(h));
+ uint8_t *h = fos_bmp_head;
+ memset(h, 0, FOS_BMP_PIXELS);
h[0] = 'B'; h[1] = 'M';
put32(h + 2, FOS_BMP_SIZE);
put32(h + 10, FOS_BMP_PIXELS);
diff --git a/ml-dev/filmos/fos_dev.h b/ml-dev/filmos/fos_dev.h
index 943710b..fca6ab8 100644
--- a/ml-dev/filmos/fos_dev.h
+++ b/ml-dev/filmos/fos_dev.h
@@ -81,6 +81,11 @@ extern const uint8_t fos_fixed_rgb[FOS_FIXED_N][3];
#define FOS_BMP_SIZE (FOS_BMP_THUMB + FOS_THUMB_SIZE)
/* in fos_print.c, which every build has (the shelf's samples are prints too) */
+/* a print's headers while it is read or written: one for the readers here and
+ * the darkroom's writer, which never use it at the same time (all on the film
+ * OS's task, each done with it before it returns), so the boot memory holds
+ * it once and not three times */
+extern uint8_t fos_bmp_head[FOS_BMP_PIXELS];
int fos_print_load(const char *path, struct fos_print *p); /* allocates p->px; 0 on failure */
void fos_print_free(struct fos_print *p);
int fos_print_thumb(const char *path, uint8_t *thumb); /* FOS_THUMB_W x FOS_THUMB_H RGB */
diff --git a/ml-dev/filmos/fos_print.c b/ml-dev/filmos/fos_print.c
index 38c5d50..7e184c9 100644
--- a/ml-dev/filmos/fos_print.c
+++ b/ml-dev/filmos/fos_print.c
@@ -8,6 +8,8 @@
#include "fos_dev.h"
#include <string.h>
+uint8_t fos_bmp_head[FOS_BMP_PIXELS];
+
static int u16le(const uint8_t *p) { return p[0] | p[1] << 8; }
static unsigned u32le(const uint8_t *p) { return p[0] | p[1] << 8 | p[2] << 16 | (unsigned) p[3] << 24; }
@@ -21,7 +23,7 @@ int fos_print_thumb(const char *path, uint8_t *thumb)
{
void *f = fos_port_open(path, 0);
if (!f) return 0;
- static uint8_t h[FOS_BMP_PIXELS];
+ uint8_t *h = fos_bmp_head;
int ok = fos_port_read(f, h, FOS_BMP_PIXELS) == FOS_BMP_PIXELS && is_print(h)
&& fos_port_seek(f, FOS_BMP_THUMB) >= 0 && fos_port_read(f, thumb, FOS_THUMB_SIZE) == FOS_THUMB_SIZE;
fos_port_close(f);
@@ -33,7 +35,7 @@ int fos_print_load(const char *path, struct fos_print *p)
memset(p, 0, sizeof(*p));
void *f = fos_port_open(path, 0);
if (!f) return 0;
- static uint8_t h[FOS_BMP_PIXELS];
+ uint8_t *h = fos_bmp_head;
int ok = fos_port_read(f, h, FOS_BMP_PIXELS) == FOS_BMP_PIXELS && is_print(h);
if (ok)
{