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.

A top plate for DSLRs shooting through the viewfinder (roadmap 4)

Claude29475d6605c0
diff --git a/docs/MANUAL.th.md b/docs/MANUAL.th.md
index 415a969..c49bb81 100644
--- a/docs/MANUAL.th.md
+++ b/docs/MANUAL.th.md
@@ -59,6 +59,9 @@ System > Support M·FILM แสดง QR code ของลิงก์โดเ
(ปิดได้ที่ System > PLAY shows prints only) ตั้งในเมนู Canon เองครั้งเดียว: Image quality = RAW
และ Image review = Off (ถ้ายังไม่ได้ตั้ง กล้องจะขึ้นข้อความเตือนตอนโหลดม้วน; ML ไม่เปลี่ยนค่าพวกนี้เอง
เพราะการเขียนค่า quality ของ Canon โดยตรงเสี่ยงทำให้เฟิร์มแวร์รวน)
+- **กล้อง DSLR ตอนถ่ายผ่านช่องมอง** (ไม่ได้เปิด LiveView): จอหลังแสดง "ฝาบนกล้องฟิล์ม" แทนหน้าข้อมูลของ Canon
+ ชัตเตอร์, ค่า f และนับรูปเป็นตัวเลข LED สีแดง, เข็มวัดแสงตอนกดชัตเตอร์ครึ่งเดียว, ฟิล์มกับ ISO
+ ปิดได้พร้อม HUD (Viewfinder > Viewfinder HUD) ไม่มีใน EOS M
- **โหมดฟิล์ม** (System > Film mode): **Basic** (ค่าเริ่มต้น) ไม่ต้องกรอฟิล์ม ถ่ายครบม้วนแล้วส่งเข้าห้องมืดได้เลย
ม้วนที่ถ่ายครบแต่ยังอยู่ในกล้องก็ล้างได้ จะจบกลางม้วนใช้ Finish roll ที่หน้า Roll
**Realistic** ต้องกรอฟิล์มกลับก่อนถึงจะล้างได้ เหมือนกล้องฟิล์มจริง ใน log ของม้วนเหมือนกันทั้งสองโหมด
diff --git a/docs/ROADMAP.th.md b/docs/ROADMAP.th.md
index 960602f..2bd30ba 100644
--- a/docs/ROADMAP.th.md
+++ b/docs/ROADMAP.th.md
@@ -20,7 +20,7 @@
- ใน log ของม้วน (`ROLL_nnn.TXT`) Basic เขียนบรรทัดจบม้วนให้เอง Darkrooms บนคอมจึงอ่านได้เหมือนเดิม
- แก้ที่ `filmroll.c` (จบม้วน), `fos_pages.c` (หน้า Roll, ตั้งค่า), `fos_dark.c` (ม้วนที่จบแล้วล้างได้)
-## 4. หน้าจอถ่ายรูปสำหรับ DSLR (ไม่มี LiveView)
+## 4. หน้าจอถ่ายรูปสำหรับ DSLR (ไม่มี LiveView) ✅ (รอคนทดสอบบน DSLR)
- DSLR ถ่ายผ่านช่องมอง จอหลังไม่ได้เป็น LiveView: วาดหน้าแบบ "ฝาบนของกล้องฟิล์ม" แทน
ชัตเตอร์, ค่า f, ISO ของฟิล์ม, ฟิล์มที่ใส่, นับรูปที่เหลือ
- แทนหน้าข้อมูลของ Canon (กด INFO) และหายไปเองเมื่อเอาตาแนบช่องมอง (เซนเซอร์ดับจอ)
diff --git a/ml-dev/filmos/fos.h b/ml-dev/filmos/fos.h
index 87b9088..89552b2 100644
--- a/ml-dev/filmos/fos.h
+++ b/ml-dev/filmos/fos.h
@@ -199,6 +199,7 @@ struct fos_hud
int frame, exposures, finished, need_wind;
int focus_screen;
const char *film;
+ int iso; /* the film's speed (the top plate shows it) */
};
struct fos_hud_palette
@@ -209,6 +210,9 @@ struct fos_hud_palette
void fos_hud_draw(uint8_t *vram, int pitch, const struct fos_hud *h, const struct fos_hud_palette *p);
void fos_hud_clear(uint8_t *vram, int pitch, const struct fos_hud_palette *p);
+/* the top plate: a DSLR's back screen while you shoot through the viewfinder */
+void fos_hud_plate(uint8_t *vram, int pitch, const struct fos_hud *h, const struct fos_hud_palette *p);
+void fos_hud_plate_clear(uint8_t *vram, int pitch, const struct fos_hud_palette *p);
/* ---------------------------------------------------------------- the UI */
diff --git a/ml-dev/filmos/fos_hud.c b/ml-dev/filmos/fos_hud.c
index 5365348..315a92e 100644
--- a/ml-dev/filmos/fos_hud.c
+++ b/ml-dev/filmos/fos_hud.c
@@ -77,10 +77,13 @@ static int seg_bits(int ch)
return 0;
}
-#define DIG_W 15
-#define DIG_H 26
-#define SEG_T 3
-#define DIG_GAP 6
+/* the digits' size: the HUD's, or the top plate's bigger ones (seg_size) */
+static int DIG_W = 15, DIG_H = 26, SEG_T = 3, DIG_GAP = 6;
+
+static void seg_size(int w, int h, int t, int gap)
+{
+ DIG_W = w; DIG_H = h; SEG_T = t; DIG_GAP = gap;
+}
/* one slanted digit; off segments are drawn faintly, like the unlit LEDs
* you can just see behind a real viewfinder mask */
@@ -89,7 +92,7 @@ static void seg_digit(int x, int y, int bits, uint8_t on, uint8_t off)
int half = DIG_H / 2;
for (int r = 0; r < DIG_H; r++)
{
- int slant = (DIG_H - 1 - r) * 3 / DIG_H; /* leans right like the real ones */
+ int slant = (DIG_H - 1 - r) * (DIG_H * 3 / 26) / DIG_H; /* leans right like the real ones */
int yy = y + r;
/* horizontals: a at the top, g in the middle, d at the bottom */
int hseg = -1;
@@ -99,7 +102,7 @@ static void seg_digit(int x, int y, int bits, uint8_t on, uint8_t off)
if (hseg >= 0)
{
/* chamfered ends: shorter where the segment meets the verticals */
- int inset = hseg == 6 ? 2 : (r == 0 || r == DIG_H - 1) ? 2 : 1;
+ int inset = (hseg == 6 ? 2 : (r == 0 || r == DIG_H - 1) ? 2 : 1) * SEG_T / 3;
fill(x + slant + inset + 1, yy, DIG_W - 2 * inset - 2, 1, (bits >> hseg) & 1 ? on : off);
}
/* verticals: f and b above the middle, e and c below */
@@ -129,9 +132,9 @@ static int seg_text(int x, int y, const char *s, int lit)
}
if (*s == '"')
{
- fill(x - 2, y, 2, 6, on);
- fill(x + 2, y, 2, 6, on);
- x += 8;
+ fill(x - 2, y, SEG_T * 2 / 3, DIG_H / 4, on);
+ fill(x + SEG_T * 2 / 3, y, SEG_T * 2 / 3, DIG_H / 4, on);
+ x += DIG_H / 3;
continue;
}
seg_digit(x, y, seg_bits(*s), on, off);
@@ -260,3 +263,109 @@ void fos_hud_clear(uint8_t *vram, int pitch, const struct fos_hud_palette *p)
fill(0, VIEW_H, W, BAR_H, p->clear);
fill(VIEW_W / 2 - 64, VIEW_H / 2 - 64, 129, 129, p->clear);
}
+
+/* ---------------------------------------------------------------- the top plate */
+
+/* not on the EOS M: it has no viewfinder to shoot through, and its boot
+ * memory is short (MEMORY.md) */
+#ifndef CONFIG_EOSM
+
+/* What a DSLR shows when you shoot through the viewfinder and the screen
+ * on the back is Canon's settings display: a film camera's top plate in
+ * its place, lit like the HUD's LEDs. Shutter, aperture and the frame
+ * counter in big red digits, the meter's needle on a scale of stops, the
+ * film and its speed. */
+void fos_hud_plate(uint8_t *vram, int pitch, const struct fos_hud *h, const struct fos_hud_palette *p)
+{
+ vr = vram; vp = pitch; pal = p;
+ char b[24];
+ fill(0, 0, W, H, p->black);
+
+ /* the maker's plate: name, and the film loaded */
+ text_gray(&fos_font_sm, 28, 40, "M" "\x80" "FILM", 46, 40);
+ if (h->film)
+ {
+ int w = fos_text_w(&fos_font_lg, h->film, 0);
+ text_gray(&fos_font_lg, W - 28 - w, 46, h->film, 100, 0);
+ }
+ if (h->iso)
+ {
+ snprintf(b, sizeof(b), "ISO %d", h->iso);
+ int w = fos_text_w(&fos_font_sm, b, 24);
+ text_gray(&fos_font_sm, W - 28 - w, 74, b, 55, 24);
+ }
+ fill(28, 92, W - 56, 1, p->gray[18]);
+
+ /* three windows: shutter, aperture, frames */
+ static const char *const names[3] = { "SHUTTER", "APERTURE", "FRAME" };
+ const int col[3] = { 28, 268, 488 };
+ for (int i = 0; i < 3; i++)
+ text_gray(&fos_font_xs, col[i], 132, names[i], 40, 48);
+ seg_size(36, 64, 7, 12);
+ int ty = 150;
+ seg_text(col[0], ty, h->shutter, h->lit);
+ fos_format_fstop(b, sizeof(b), h->fstop);
+ int w = seg_text(col[1] + 22, ty, b, h->lit);
+ text_gray(&fos_font_md, col[1], ty + 62, "f", h->lit ? 70 : 30, 0);
+ (void) w;
+ if (h->finished)
+ seg_text(col[2], ty, h->blink ? "End" : " ", 1);
+ else
+ {
+ snprintf(b, sizeof(b), "%d", h->frame);
+ int fw = seg_text(col[2], ty, b, 1);
+ snprintf(b, sizeof(b), "/%d", h->exposures);
+ text_gray(&fos_font_md, col[2] + fw + 4, ty + 62, b, 55, 0);
+ }
+ seg_size(15, 26, 3, 6);
+
+ /* the meter: -2 .. +2 stops in thirds, the needle where the light is */
+ int my = 286, mx0 = 120, mx1 = W - 120, mc = (mx0 + mx1) / 2, step = (mx1 - mx0) / 12;
+ fill(mx0, my, mx1 - mx0, 1, p->gray[30]);
+ for (int t = -6; t <= 6; t++)
+ {
+ int x = mc + t * step, big = t % 3 == 0;
+ fill(x, my - (big ? 10 : 5), t == 0 ? 3 : 1, big ? 20 : 10, p->gray[t == 0 ? 70 : big ? 45 : 25]);
+ if (big && t)
+ {
+ snprintf(b, sizeof(b), "%+d", t / 3);
+ int tw = fos_text_w(&fos_font_xs, b, 0);
+ text_gray(&fos_font_xs, x - tw / 2, my + 30, b, 40, 0);
+ }
+ }
+ text_gray(&fos_font_xs, mx0 - 70, my + 5, "UNDER", 30, 24);
+ text_gray(&fos_font_xs, mx1 + 16, my + 5, "OVER", 30, 24);
+ if (h->lit && h->meter)
+ {
+ int thirds = h->fstop - h->want; /* + : more light than the aperture set wants */
+ int out = thirds > 6 || thirds < -6;
+ thirds = thirds > 6 ? 6 : thirds < -6 ? -6 : thirds;
+ if (!out || h->blink)
+ {
+ int x = mc + thirds * step;
+ for (int r = 0; r < 14; r++)
+ fill(x - (14 - r) / 2, my - 26 + r, 14 - r + 1, 1, p->red);
+ }
+ }
+
+ /* the frames left, like the marks on a film counter */
+ int n = h->exposures > 0 ? h->exposures : 36, done = h->finished ? n : h->frame - 1;
+ int fx = 28, fw = (W - 56) / n;
+ for (int i = 0; i < n; i++)
+ fill(fx + i * fw, 364, fw - 3 > 1 ? fw - 3 : 1, 10, i < done ? p->gray[60] : i == done ? p->red : p->gray[14]);
+ if (h->need_wind)
+ text_led(&fos_font_mdb, 28, 420, "WIND ON", h->blink, 24);
+
+ /* the way back to the film OS */
+ const char *hint = "TRASH Home PLAY Prints";
+ int hw = fos_text_w(&fos_font_xs, hint, 24);
+ text_gray(&fos_font_xs, W - 28 - hw, H - 22, hint, 36, 24);
+}
+
+/* the plate off: Canon's screen shows again */
+void fos_hud_plate_clear(uint8_t *vram, int pitch, const struct fos_hud_palette *p)
+{
+ vr = vram; vp = pitch; pal = p;
+ fill(0, 0, W, H, p->clear);
+}
+#endif
diff --git a/ml-dev/filmos/fos_pages.c b/ml-dev/filmos/fos_pages.c
index 0282106..e5b45de 100644
--- a/ml-dev/filmos/fos_pages.c
+++ b/ml-dev/filmos/fos_pages.c
@@ -306,7 +306,7 @@ static const char *const mode_choices[] = { "Basic", "Realistic" };
static const struct item finder_items[] =
{
- { "Viewfinder HUD", IT_TOGGLE, FS_HUD, 0, 0, "SLR-style meter needle and LED readout over LiveView." },
+ { "Viewfinder HUD", IT_TOGGLE, FS_HUD, 0, 0, "Meter and LEDs over LiveView; on a DSLR, a top plate on the back screen too." },
{ "LEDs on half-press", IT_TOGGLE, FS_LEDS, 0, 0, "Like a real SLR: the readout lights only while metering." },
{ "Focusing screen", IT_TOGGLE, FS_FOCUS, 0, 0, "A split-image circle and microprism collar (decoration only)." },
{ "Wind lever", IT_CHOICE, FS_WIND, wind_choices, 3, "After each frame press SET to wind on. Locking is experimental." },
diff --git a/ml-dev/filmos/preview/plate.png b/ml-dev/filmos/preview/plate.png
new file mode 100644
index 0000000..306e9a5
Binary files /dev/null and b/ml-dev/filmos/preview/plate.png differ
diff --git a/ml-dev/filmos/sim/hudtest.c b/ml-dev/filmos/sim/hudtest.c
index a824d96..e5738f8 100644
--- a/ml-dev/filmos/sim/hudtest.c
+++ b/ml-dev/filmos/sim/hudtest.c
@@ -1,7 +1,8 @@
/* hudtest: the viewfinder HUD over a made-up LiveView picture, with a
* stand-in for Canon's palette (white 1, black 2, red 8, dark red 12,
* greys 38..79)
- * hudtest [1|0|e] [liveview.ppm] the picture: a 720 x 480 binary PPM */
+ * hudtest [1|0|e|p] [liveview.ppm] the picture: a 720 x 480 binary PPM;
+ * p: the top plate a DSLR shows instead when you shoot through the viewfinder */
#include <stdio.h>
#include <stdlib.h>
@@ -22,9 +23,11 @@ int main(int argc, char **argv)
struct fos_hud h = { 1, 1, 1, 13, 6, 15, "125", 12, 36, 0, 1, 1, "PORTRA 400" };
if (argc > 1 && argv[1][0] == '0') { h.lit = 0; h.need_wind = 1; }
if (argc > 1 && argv[1][0] == 'e') { h.finished = 1; strcpy(h.shutter, "0.5\""); h.want = 30; }
+ h.iso = 400;
fos_gfx_init();
sim_fonts();
- fos_hud_draw(ov, 960, &h, &p);
+ if (argc > 1 && argv[1][0] == 'p') { h.want = h.fstop - 2; fos_hud_plate(ov, 960, &h, &p); }
+ else fos_hud_draw(ov, 960, &h, &p);
static uint8_t lv[480 * 720 * 3];
int have_lv = 0;
diff --git a/ml-dev/filmos/sim/previews.sh b/ml-dev/filmos/sim/previews.sh
index b5b789a..cdea77e 100755
--- a/ml-dev/filmos/sim/previews.sh
+++ b/ml-dev/filmos/sim/previews.sh
@@ -36,6 +36,8 @@ run prints; still prints 1300 prints-sheet; still prints 3500 prints-frame
# the HUD over a made-up LiveView picture
gcc -O2 -std=gnu99 -o out/hudtest hudtest.c fonts.c ../fos_gfx.c ../fos_film.c ../fos_hud.c -lm
./out/hudtest 1 ${LIVEVIEW:-} && python3 -c "from PIL import Image; Image.open('out/hud.ppm').save('$OUT/hud.png')"
+# and the top plate a DSLR shows instead, shooting through the viewfinder
+./out/hudtest p && python3 -c "from PIL import Image; Image.open('out/hud.ppm').save('$OUT/plate.png')"
# browsing the shelf, half size
run browse
diff --git a/ml-dev/fork/src/filmroll.c b/ml-dev/fork/src/filmroll.c
index 77741e1..f9ad8b8 100644
--- a/ml-dev/fork/src/filmroll.c
+++ b/ml-dev/fork/src/filmroll.c
@@ -976,6 +976,14 @@ static int hud_visible()
return hud_enabled && roll_loaded && lv && display_idle() && !is_movie_mode() && !ui_running;
}
+/* a DSLR shooting through the viewfinder: the back screen shows Canon's
+ * settings display, and the top plate (fos_hud_plate) goes over it */
+static int plate_visible()
+{
+ return !FOS_LV_ONLY && hud_enabled && roll_loaded && !lv && display_is_on() && display_idle()
+ && !is_movie_mode() && !ui_running;
+}
+
/* Magic Lantern's own LiveView overlays never draw: the film OS (or
* Canon's clean screen) is all you see */
int filmroll_overlays_active()
@@ -1013,7 +1021,7 @@ static void shutter_led(char *buf, int size)
buf[n] = 0;
}
-static void hud_draw(int lit, int blink)
+static void hud_draw(int lit, int blink, int plate)
{
struct fos_hud h;
memset(&h, 0, sizeof(h));
@@ -1034,9 +1042,13 @@ static void hud_draw(int lit, int blink)
h.need_wind = need_wind;
h.focus_screen = focus_screen;
h.film = fos_films[COERCE(roll_film, 0, fos_nfilms - 1)].name;
+ h.iso = fos_films[COERCE(roll_film, 0, fos_nfilms - 1)].box_iso;
uint8_t *vram = bmp_vram();
- if (vram)
- fos_hud_draw(vram, BMPPITCH, &h, &hud_pal);
+#if !FOS_LV_ONLY
+ if (vram && plate) fos_hud_plate(vram, BMPPITCH, &h, &hud_pal);
+ else
+#endif
+ if (vram) fos_hud_draw(vram, BMPPITCH, &h, &hud_pal);
}
static void hud_clear()
@@ -1053,16 +1065,29 @@ static void hud_step()
static int last_draw = 0;
static int drawn = 0;
static int was_visible = -1;
+ static int plate_drawn = 0;
- int visible = hud_visible();
- if (visible != was_visible)
+ int plate = plate_visible();
+ int visible = hud_visible() || plate;
+ if (visible * 2 + plate != was_visible)
{
- dbg("hud: visible %d (enabled %d roll %d lv %d movie %d ui %d)",
- visible, hud_enabled, roll_loaded, lv, is_movie_mode(), ui_running);
- was_visible = visible;
+ dbg("hud: visible %d plate %d (enabled %d roll %d lv %d movie %d ui %d)",
+ visible, plate, hud_enabled, roll_loaded, lv, is_movie_mode(), ui_running);
+ was_visible = visible * 2 + plate;
}
hud_showing = visible;
+ /* the plate off (LiveView on, or a Canon menu over it): hand the screen back */
+ if (plate_drawn && !plate)
+ {
+#if !FOS_LV_ONLY
+ uint8_t *vram = bmp_vram();
+ if (vram && display_idle() && !ui_running) fos_hud_plate_clear(vram, BMPPITCH, &hud_pal);
+#endif
+ plate_drawn = 0;
+ last_sig = -1;
+ }
+
if (!visible)
{
/* HUD switched off or roll rewound: wipe it once we're back on the LiveView screen */
@@ -1090,7 +1115,8 @@ static void hud_step()
hud_dirty = 0;
last_sig = sig;
last_draw = now;
- hud_draw(lit, blink);
+ hud_draw(lit, blink, plate);
+ plate_drawn = plate;
}
}