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.

Darkroom: Delete roll, its prints only or the whole roll, for a roll out of the camera (#65)

Claude8f1f6475b255
diff --git a/.github/workflows/camera.yml b/.github/workflows/camera.yml
index 9086c5a..b0675f5 100644
--- a/.github/workflows/camera.yml
+++ b/.github/workflows/camera.yml
@@ -26,7 +26,8 @@ permissions:
jobs:
# the darkroom on the PC simulator, on a card of rolls it has to find or explain: shot as JPEG,
- # Adobe RGB with a file deleted, across the IMG_9999 wrap (ml-dev/filmos/sim/cardtest.sh)
+ # Adobe RGB with a file deleted, across the IMG_9999 wrap; then Delete roll on them, and a card
+ # that can't take long folder names (ml-dev/filmos/sim/cardtest.sh)
darkroom:
runs-on: ubuntu-24.04
name: darkroom (simulator)
diff --git a/TESTING.md b/TESTING.md
index ec54d56..ed40a48 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -72,6 +72,8 @@ Go through these and note what happens (a photo of the screen helps a lot):
- [ ] With a manual (adapted) lens, turn off *Viewfinder → Exposure simulation*. Is LiveView bright enough
to focus? Does the HUD's meter needle still move when you half-press?
- [ ] Rewind the roll and **develop it in the camera** (Darkroom). Do prints come out? How long per frame?
+- [ ] In the Darkroom, **◀** on a developed roll: *Delete roll* → *Prints only* → *Delete*. On a computer:
+ are its JPEG folder in `DCIM` and `ML/DARKROOM/Rnnn` gone, with no empty folder left?
- [ ] Open the card in **Darkrooms** on a computer: are the rolls and films there?
Then [open an issue](../../issues/new/choose) with: your camera and firmware, what worked, what didn't,
diff --git a/docs/MANUAL.th.md b/docs/MANUAL.th.md
index afa90ca..0fbb11b 100644
--- a/docs/MANUAL.th.md
+++ b/docs/MANUAL.th.md
@@ -49,7 +49,7 @@ System > Support M·FILM แสดง QR code ของลิงก์โดเ
| | |
|---|---|
| ![](../ml-dev/filmos/preview/end-of-roll.png) | ![](../ml-dev/filmos/preview/darkroom.png) |
-| **ถ่ายครบม้วน** กล้องถามเอง: ล้างเลย (SET) หรือใส่ม้วนใหม่ก่อน (INFO) | **Darkroom** ม้วนที่ยังไม่ล้าง / ล้างแล้ว / ยังอยู่ในกล้อง เลือกบางม้วน (SET) หรือล้างทั้งหมด (INFO) |
+| **ถ่ายครบม้วน** กล้องถามเอง: ล้างเลย (SET) หรือใส่ม้วนใหม่ก่อน (INFO) | **Darkroom** ม้วนที่ยังไม่ล้าง / ล้างแล้ว / ยังอยู่ในกล้อง เลือกบางม้วน (SET) ล้างทั้งหมด (INFO) หรือลบม้วน (◀) |
| ![](../ml-dev/filmos/preview/developing.png) | ![](../ml-dev/filmos/preview/developing-line.png) |
| **กำลังล้าง** ใต้ไฟแดง: ภาพแฝงค่อยๆ ขึ้นบนกระดาษในถาดน้ำยาตามที่ CPU อ่าน RAW ได้ แล้วภาพเข้มขึ้นจนเต็ม | ภาพที่เสร็จแล้วถูกยกขึ้นไปตากบนราว นาฬิกาจับเวลาห้องมืดเดินรอบละรูป จุดรอบหน้าปัดคือรูปทั้งม้วน |
| ![](../ml-dev/filmos/preview/prints-sheet.png) | ![](../ml-dev/filmos/preview/prints-frame.png) |
@@ -98,6 +98,14 @@ System > Support M·FILM แสดง QR code ของลิงก์โดเ
ล้างอีกครั้งจะทำเฉพาะรูปที่ยังไม่มี JPEG
- สำหรับดูในกล้องยังมี `ML/DARKROOM/R<ม้วน>/F<รูป>.BMP` (240 สี) และ `SHEET.BMP` (contact sheet)
ม้วนถือว่าล้างแล้วเมื่อมี `SHEET.BMP` ไฟล์ CR2 เดิมยังอยู่ครบ เอาไปล้างละเอียดเต็มขนาดด้วย Darkrooms บนคอมได้เหมือนเดิม
+- **ลบม้วน** (◀ ที่หน้า Darkroom) ได้เฉพาะม้วนที่ไม่ได้อยู่ในกล้อง จะล้างแล้วหรือยังก็ได้ เลือกแล้วกล้องถามยืนยันอีกครั้งเสมอ
+ - **Prints only** (SET): ลบภาพที่ล้างแล้ว คือโฟลเดอร์ JPEG ของม้วนใน DCIM และ `ML/DARKROOM/R<ม้วน>/`
+ RAW กับ log ของม้วนยังอยู่ ม้วนกลับเป็น TO DEVELOP ล้างใหม่ได้ (ในกล้องหรือ Darkrooms)
+ - **Whole roll** (INFO): ลบภาพเหล่านั้น รูปทุกรูปที่ log ของม้วน (`ROLL_nnn.TXT`) ระบุ แล้วลบ log เป็นอย่างสุดท้าย
+ หาไฟล์แบบเดียวกับตอนล้าง: ชื่อที่กล้องตั้งจริง (`_MG_` ใน Adobe RGB, prefix ที่ตั้งเอง), JPG ถ้าถ่ายเป็น JPEG,
+ และทุกโฟลเดอร์ใน DCIM ที่ม้วนข้ามไปหลัง IMG_9999 ม้วนที่ไม่มีภาพเลยจะข้ามไปถามยืนยันลบทั้งม้วนเลย
+ - ไม่ลบไฟล์ที่ log ไม่ได้ระบุ (เช่น JPEG ที่กล้องเขียนคู่กับ RAW ตอนตั้ง RAW+JPEG ยังอยู่) และไม่ลบม้วนที่อยู่ในกล้อง
+ - ลบไม่ได้ครบ กล้องจะบอกจำนวนที่เหลือ รายละเอียดอยู่ใน log บรรทัด `lab: ...` (เปิด Debug log ไว้)
### สีบนจอ
สีของ Film OS ส่งไปที่จอแบบเดียวกับที่ Canon แปลงสีของตัวเอง (BT.601 Y'CbCr, ขาวที่ระดับ 235)
@@ -126,6 +134,7 @@ Brightness (โทนกลาง) และ Conversion (Canon / Rec.709 แบ
| Home | ▲ ▼ / หมุนวงล้อ, SET | เลือก, เปิด (PLAY = Prints) |
| Darkroom | SET | ทำเครื่องหมายม้วนที่จะล้าง / เปิด Prints ของม้วนที่ล้างแล้ว |
| | INFO | ล้างม้วนที่เลือก (ไม่ได้เลือก = ล้างทั้งหมด) |
+| | ◀ | ลบม้วน (ไม่ใช่ม้วนในกล้อง): Prints only (SET) หรือ Whole roll (INFO) แล้วยืนยัน (SET) / MENU ยกเลิก |
| กำลังล้าง | MENU | หยุด (รูปที่เสร็จแล้วยังอยู่) |
| Prints | ◀ ▶ ▲ ▼, SET | เลือกรูปใน contact sheet, เปิดเต็มจอ |
| | หมุนวงล้อ | ม้วนอื่น (ใน contact sheet) / รูปถัดไป (เต็มจอ) |
diff --git a/ml-dev/filmos/fos_dark.c b/ml-dev/filmos/fos_dark.c
index 8e44744..22ac49c 100644
--- a/ml-dev/filmos/fos_dark.c
+++ b/ml-dev/filmos/fos_dark.c
@@ -101,6 +101,14 @@ static int dk_sel;
static struct spring dk_hl, dk_scroll;
static int dk_hints_for = -1; /* the hints show what SET does on this row */
+/* Delete roll (LEFT, a roll out of the camera): which part, then sure? The
+ * files go once the sheet is down, under a toast saying so. */
+enum { DEL_NONE, DEL_WHICH, DEL_PRINTS, DEL_WHOLE };
+static int dk_ask, dk_said; /* the sheet up; what it said, while it goes down */
+static int dk_doing; /* DEL_PRINTS or DEL_WHOLE: confirmed */
+static struct spring dk_sheet;
+static int dk_sheet_drawn;
+
#define DK_X 24
#define DK_W 672
#define DK_Y 124
@@ -155,11 +163,12 @@ static void dark_hints()
char dev[32];
if (nm) snprintf(dev, sizeof(dev), "Develop %d", nm);
else snprintf(dev, sizeof(dev), "Develop all");
- struct hint h[4];
+ struct hint h[5];
int n = 0;
if (r && is_waiting(r)) h[n++] = (struct hint) { "SET", marked[dk_sel] ? "Unmark" : "Mark" };
else if (r && has_prints(r)) h[n++] = (struct hint) { "SET", "Prints" };
if (count_waiting(0)) h[n++] = (struct hint) { "INFO", dev };
+ if (r && !r->in_camera) h[n++] = (struct hint) { "<", "Delete" };
h[n++] = (struct hint) { "PLAY", "Prints" };
h[n++] = (struct hint) { "MENU", "Back" };
ui_bg_restore(0, HINTS_Y, FOS_W, FOS_H - HINTS_Y);
@@ -186,6 +195,9 @@ void dark_enter(int arg)
dk_scroll.x = (float) fos_clamp(dk_sel - DK_ROWS / 2, 0, nrolls > DK_ROWS ? nrolls - DK_ROWS : 0);
dk_scroll.v = 0;
dk_hints_for = -1;
+ dk_ask = dk_doing = 0;
+ dk_sheet.x = dk_sheet.v = 0;
+ dk_sheet_drawn = 0;
dark_bake();
}
@@ -214,6 +226,21 @@ void dark_key(int k)
return;
}
const struct fos_lab_roll *r = nrolls ? &rolls[dk_sel] : 0;
+ if (dk_doing) return;
+ if (dk_ask)
+ {
+ /* Delete roll: SET prints only (or, asked to be sure, yes), INFO the whole roll */
+ if (k == FK_MENU) dk_ask = DEL_NONE;
+ else if (dk_ask == DEL_WHICH && (k == FK_SET || k == FK_INFO)) dk_ask = k == FK_SET ? DEL_PRINTS : DEL_WHOLE;
+ else if (dk_ask != DEL_WHICH && k == FK_SET)
+ {
+ dk_doing = dk_ask;
+ dk_ask = DEL_NONE;
+ ui_toast("Deleting" T_ELLIPSIS);
+ }
+ ui_damage_all();
+ return;
+ }
switch (k)
{
case FK_UP: case FK_WHEEL_L:
@@ -222,11 +249,13 @@ void dark_key(int k)
case FK_DOWN: case FK_WHEEL_R:
if (dk_sel < nrolls - 1) dk_sel++;
break;
- case FK_SET: case FK_RIGHT:
+ case FK_SET: case FK_RIGHT: case FK_LEFT:
if (!r) break;
- if (r->in_camera && !finished_in_camera(r))
+ /* LEFT: Delete roll, never the one in the camera */
+ if (r->in_camera && (k == FK_LEFT || !finished_in_camera(r)))
ui_toast(ui_realistic() ? "Still in the camera " T_MDASH " rewind it first"
: "Still in the camera " T_MDASH " finish it on the Roll page first");
+ else if (k == FK_LEFT) dk_ask = has_prints(r) || r->jpegs ? DEL_WHICH : DEL_WHOLE; /* no prints: no choice */
else if (is_waiting(r) && k == FK_SET) marked[dk_sel] ^= 1;
else if (has_prints(r)) ui_go(SCR_PRINTS, r->number, GO_FADE);
break;
@@ -247,6 +276,19 @@ void dark_key(int k)
ui_damage(DK_Y - 4, FOS_H);
}
+/* the confirmed Delete roll, with the sheet down and the toast up */
+static void dark_delete()
+{
+ int left = fos_lab_delete(rolls[dk_sel].number, dk_doing == DEL_WHOLE, dm->frames);
+ dk_doing = DEL_NONE;
+ ui_toast(left ? "Not all of it could be deleted" : "Deleted");
+ rescan();
+ memset(marked, 0, sizeof(marked));
+ if (dk_sel >= nrolls) dk_sel = nrolls > 0 ? nrolls - 1 : 0;
+ dark_bake();
+ ui_clobbered = 1;
+}
+
int dark_update(int dt)
{
int moving = 0;
@@ -254,6 +296,8 @@ int dark_update(int dt)
moving |= spring_step(&dk_hl, (float) dk_sel, dt, 3.4f, 0.82f);
moving |= spring_step(&dk_scroll, top, dt, 2.6f, 0.9f);
if (moving) ui_damage(DK_Y - 4, DK_Y + DK_ROWS * DK_ROW + 4);
+ if (dm && spring_step(&dk_sheet, dk_ask ? 1 : 0, dt, 3.0f, 0.95f)) { moving = 1; ui_damage_all(); }
+ if (dk_doing && dk_sheet.x <= 0.002f) dark_delete();
return moving;
}
@@ -289,15 +333,31 @@ static void dark_row(int i, int y)
fos_text_r(cv, &fos_font_xs, DK_X + DK_W - 24, y + 36, b, c, OPAQUE, 48);
}
+/* the Delete roll sheet */
+static void dark_sheet()
+{
+ if (dk_ask) dk_said = dk_ask;
+ const struct fos_lab_roll *r = &rolls[dk_sel];
+ char t[48], b[80];
+ int which = dk_said == DEL_WHICH, prints = dk_said == DEL_PRINTS;
+ snprintf(t, sizeof(t), which ? "Delete roll %03d?" : prints ? "Delete its prints?" : "Delete all of roll %03d?", r->number);
+ snprintf(b, sizeof(b), "Its %d frame%s, prints and log. They can't come back.", r->shot, r->shot == 1 ? "" : "s");
+ /* which part: SET, INFO; then sure? SET */
+ ui_sheet3(dk_sheet.x, t, which ? "Prints only keeps the RAW files and the log." : prints ? "Its JPEGs in DCIM go too." : b,
+ which ? "Prints only" : "Delete", which ? "Whole roll" : 0, which ? "Cancel" : "Keep");
+}
+
void dark_draw()
{
- if (ui_clobbered)
+ int sheet = dk_sheet.x > 0.002f;
+ if (ui_clobbered || sheet || dk_sheet_drawn)
{
ui_clobbered = 0;
ui_bg_restore(0, 0, FOS_W, FOS_H);
ui_damage_all();
dk_hints_for = -1;
}
+ dk_sheet_drawn = sheet;
if (!dm)
{
fos_text_c(cv, &fos_font_md, 360, DK_Y + 120, "Not enough memory for the darkroom.", C_TEXT3, OPAQUE, 0);
@@ -326,6 +386,7 @@ void dark_draw()
if (top > 0.05f) fos_tri(cv, DK_X + DK_W - 14, DK_Y - 8, 8, 3, C_TEXT3, OPAQUE);
if (top < nrolls - DK_ROWS - 0.05f) fos_tri(cv, DK_X + DK_W - 14, DK_Y + DK_ROWS * DK_ROW + 6, 8, 1, C_TEXT3, OPAQUE);
ui_damage(y0, y1 + 8);
+ if (dk_sheet_drawn) dark_sheet();
}
/* ================================================================ developing */
diff --git a/ml-dev/filmos/fos_dev.h b/ml-dev/filmos/fos_dev.h
index e1c9b0b..943710b 100644
--- a/ml-dev/filmos/fos_dev.h
+++ b/ml-dev/filmos/fos_dev.h
@@ -165,5 +165,10 @@ void fos_lab_cache_dir(char *buf, int size); /* where
* (month, month number, day of its first frame; when: "2026-09-06 10:15")
* or SEP0906 where the card takes no long names. 0 = ok */
int fos_lab_dcim_dir(char *buf, int size, int roll, int film, const char *when);
+/* delete a roll that isn't in the camera: its prints (in the darkroom and
+ * its folder in DCIM), and with whole also the frames its logs list and
+ * the logs. frames: room for FOS_MAX_FRAMES to work in. Returns how many
+ * files or folders couldn't be removed; -1 for the roll in the camera */
+int fos_lab_delete(int roll, int whole, struct fos_lab_frame *frames);
#endif
diff --git a/ml-dev/filmos/fos_lab.c b/ml-dev/filmos/fos_lab.c
index 8c275a0..fe946c7 100644
--- a/ml-dev/filmos/fos_lab.c
+++ b/ml-dev/filmos/fos_lab.c
@@ -4,7 +4,8 @@
* camera frame by frame (a roll that ran into a new DCIM folder has a log
* in each). Its prints are kept in ML/DARKROOM/Rnnn/, Fnn.BMP for frame nn
* and SHEET.BMP for the contact sheet; a roll is developed when they are
- * all there.
+ * all there. A roll out of the camera can be deleted here too: its prints,
+ * or with them the frames its logs list and the logs.
*/
#include "fos.h"
@@ -297,9 +298,13 @@ static int print_entry(void *ctx, const char *name, int is_dir)
return 1;
}
+/* paths found for a roll, to act on once their folders have been read */
+struct found { int roll, n; char paths[8][64]; };
+
/* our folders in DCIM (not Canon's "100CANON"): which roll each holds, by
- * its tag file, and how many JPEGs */
-struct jpeg_scan { struct fos_lab_roll *rolls; int n; int roll, count; };
+ * its tag file, and how many JPEGs; with found, the paths of those that
+ * hold its roll */
+struct jpeg_scan { struct fos_lab_roll *rolls; int n; int roll, count; struct found *found; };
static int jpeg_file(void *ctx, const char *name, int is_dir)
{
@@ -322,6 +327,8 @@ static int jpeg_folder(void *ctx, const char *name, int is_dir)
fos_port_list(dir, jpeg_file, s);
for (int i = 0; i < s->n; i++)
if (s->rolls[i].number == s->roll) s->rolls[i].jpegs += s->count;
+ struct found *f = s->found;
+ if (f && s->roll == f->roll && f->n < 8 && strlen(dir) < sizeof(f->paths[0])) strcpy(f->paths[f->n++], dir);
return 1;
}
@@ -341,7 +348,7 @@ int fos_lab_scan(struct fos_lab_roll *rolls, int max)
}
char dcim[64];
snprintf(dcim, sizeof(dcim), "%sDCIM", fos_port_card());
- struct jpeg_scan js = { rolls, s.n, -1, 0 };
+ struct jpeg_scan js = { rolls, s.n, -1, 0, 0 };
fos_port_list(dcim, jpeg_folder, &js);
/* newest first */
for (int i = 1; i < s.n; i++)
@@ -463,3 +470,81 @@ int fos_lab_frames(int roll, struct fos_lab_frame *frames, int max)
}
return n;
}
+
+/* ---------------------------------------------------------------- deleting a roll */
+
+/* A folder of ours: the roll's prints (ML/DARKROOM/Rnnn: Fnn.BMP, SHEET.BMP),
+ * or its folder in DCIM (IMG_0102.JPG and the tag, ROLL012.TXT). Those files
+ * go, and the folder once nothing else is in it: one with anything left is
+ * never removed. The names are taken first and removed after, not while the
+ * folder is read. How many couldn't be removed. */
+#define SWEEP_MAX (FOS_MAX_FRAMES + 2)
+struct sweep { int n; char names[SWEEP_MAX][13]; };
+
+static int sweep_entry(void *ctx, const char *name, int is_dir)
+{
+ struct sweep *s = ctx;
+ int len = (int) strlen(name);
+ if (!is_dir && len >= 5 && len <= 12 && s->n < SWEEP_MAX
+ && (!strcmp(name + len - 4, ".BMP") || !strcmp(name + len - 4, ".JPG") || !strncmp(name, "ROLL", 4)))
+ memcpy(s->names[s->n++], name, len + 1);
+ return 1;
+}
+
+static int sweep(const char *dir)
+{
+ struct sweep s;
+ s.n = 0;
+ fos_port_list(dir, sweep_entry, &s);
+ char path[160];
+ int failed = 0;
+ for (int i = 0; i < s.n; i++)
+ {
+ snprintf(path, sizeof(path), "%s/%s", dir, s.names[i]);
+ failed += remove_logged(path);
+ }
+ int left = fos_port_list(dir, first_only, 0); /* < 0: there was none */
+ return failed + (left ? left > 0 : remove_logged(dir));
+}
+
+/* the roll's logs, one in each DCIM folder it ran into */
+static void logs_log(void *ctx, const char *folder, const char *name, int number)
+{
+ struct found *f = ctx;
+ if (number == f->roll && f->n < 8) snprintf(f->paths[f->n++], sizeof(f->paths[0]), "%sDCIM/%s/%s", fos_port_card(), folder, name);
+}
+
+int fos_lab_delete(int roll, int whole, struct fos_lab_frame *frames)
+{
+ struct fos_roll cam;
+ fos_port_roll(&cam);
+ if (cam.loaded && cam.number == roll) return -1; /* never the one in the camera */
+ /* its prints: the darkroom's, and its folder in DCIM */
+ struct found f;
+ f.roll = roll;
+ f.n = 1;
+ snprintf(f.paths[0], sizeof(f.paths[0]), "%sML/DARKROOM/R%03d", fos_port_card(), roll);
+ struct jpeg_scan js = { 0, 0, -1, 0, &f };
+ char dcim[64];
+ snprintf(dcim, sizeof(dcim), "%sDCIM", fos_port_card());
+ fos_port_list(dcim, jpeg_folder, &js);
+ int failed = 0;
+ for (int i = 0; i < f.n; i++) failed += sweep(f.paths[i]);
+ if (whole)
+ {
+ /* its frames, only those its logs list, by the names the darkroom
+ * finds them by (Canon's _MG_ in Adobe RGB, a JPEG where it was
+ * shot as one, each in its folder across IMG_9999); then the logs,
+ * last, so a roll that couldn't all go is still there to delete */
+ int n = fos_lab_frames(roll, frames, FOS_MAX_FRAMES);
+ for (int i = 0; i < n; i++)
+ if (!frames[i].missing || frames[i].jpeg) failed += remove_logged(frames[i].cr2);
+ f.n = 0;
+ each_log(logs_log, &f);
+ for (int i = 0; i < f.n; i++) failed += remove_logged(f.paths[i]);
+ }
+ char msg[64];
+ snprintf(msg, sizeof(msg), "lab: roll %03d: deleted %s, %d left", roll, whole ? "all" : "prints", failed);
+ fos_port_log(msg);
+ return failed;
+}
diff --git a/ml-dev/filmos/fos_ui.c b/ml-dev/filmos/fos_ui.c
index 1301a02..6aaf49c 100644
--- a/ml-dev/filmos/fos_ui.c
+++ b/ml-dev/filmos/fos_ui.c
@@ -226,15 +226,15 @@ void ui_status_bar(const char *title)
int ui_keycap(int x, int base, const char *key)
{
- /* arrows are drawn, words are written */
+ /* arrows are drawn ("<>", "^v", or "<" alone), words are written */
int w;
- if (!strcmp(key, "<>") || !strcmp(key, "^v"))
+ if (key[0] == '<' || key[0] == '^')
{
- w = 34;
+ w = key[1] ? 34 : 22;
fos_rrect_line(cv, x, base - 15, w, 20, 6, 1, FC(RAMP_GRAY, 90), OPAQUE);
int vert = key[0] == '^';
fos_tri(cv, x + 11, base - 5, 7, vert ? 3 : 2, C_TEXT2, OPAQUE);
- fos_tri(cv, x + 23, base - 5, 7, vert ? 1 : 0, C_TEXT2, OPAQUE);
+ if (key[1]) fos_tri(cv, x + 23, base - 5, 7, vert ? 1 : 0, C_TEXT2, OPAQUE);
return w;
}
w = fos_text_w(&fos_font_xs, key, 16) + 14;
@@ -245,7 +245,7 @@ int ui_keycap(int x, int base, const char *key)
static int keycap_w(const char *key)
{
- return !strcmp(key, "<>") || !strcmp(key, "^v") ? 34 : fos_text_w(&fos_font_xs, key, 16) + 14;
+ return key[0] == '<' || key[0] == '^' ? (key[1] ? 34 : 22) : fos_text_w(&fos_font_xs, key, 16) + 14;
}
void ui_hints(const struct hint *h, int n)
diff --git a/ml-dev/filmos/preview/darkroom.png b/ml-dev/filmos/preview/darkroom.png
index ef529ba..bb5fc28 100644
Binary files a/ml-dev/filmos/preview/darkroom.png and b/ml-dev/filmos/preview/darkroom.png differ
diff --git a/ml-dev/filmos/sim/cardtest.sh b/ml-dev/filmos/sim/cardtest.sh
index b127fc1..bf5efe7 100755
--- a/ml-dev/filmos/sim/cardtest.sh
+++ b/ml-dev/filmos/sim/cardtest.sh
@@ -1,7 +1,8 @@
#!/usr/bin/env bash
# The darkroom on a card of problem rolls (mkcard.sh --problems): it develops
-# what it can, and says why it can't the rest; a card that can't take long
-# folder names keeps no empty ones (#65). Fails if a line is missing.
+# what it can, and says why it can't the rest; Delete roll takes exactly
+# what it says; a card that can't take long folder names keeps no empty
+# ones (#65). Fails if a line is missing or a file is wrong.
# make && ./cardtest.sh
set -euo pipefail
cd "$(dirname "$0")"
@@ -32,6 +33,53 @@ expect "9999 wrap: all four RAWs" "roll 008 (gold200): 4 frames, 4 RAW
reject "9999 wrap: nothing missing" "roll 008 frame [0-9]+: (no RAW|shot as JPEG)"
for f in 1 2 3 4; do expect "9999 wrap: frame $f developed" "roll 008 frame $f developed"; done
+# Delete roll, on the card just developed: the files that go are exactly
+# the ones listed, and nothing else changes
+listing() { (cd "$1" && find . | grep -v '/LOOK[0-9]*\.LUT$' | sort); }
+deletes() { # deletes <what> <scene> <path that goes>...
+ local what=$1 scene=$2; shift 2
+ listing out/cardp > out/del-before.txt
+ FOS_CARD=out/cardp/ ./out/sim "scenes/$scene.txt" - >> "$log" 2>&1
+ listing out/cardp > out/del-after.txt
+ printf '%s\n' "$@" | sed '/^$/d' | sort > out/del-want.txt
+ comm -23 out/del-before.txt out/del-after.txt > out/del-gone.txt
+ comm -13 out/del-before.txt out/del-after.txt > out/del-new.txt
+ if cmp -s out/del-want.txt out/del-gone.txt && [ ! -s out/del-new.txt ]; then echo "ok $what"
+ else
+ echo "FAIL $what"; fail=1
+ diff out/del-want.txt out/del-gone.txt | sed 's/^</ should have gone:/; s/^>/ shouldn'"'"'t have gone:/' | grep '^ ' || true
+ sed 's/^/ new: /' out/del-new.txt
+ fi
+}
+# asked, then not confirmed: nothing goes
+deletes "Delete roll: not confirmed" delete_cancel ""
+# prints only (007, Adobe RGB, frame 2 deleted): its JPEG folder and the darkroom's prints
+deletes "Delete roll: prints only" delete_prints \
+ "./DCIM/Oct1002 Ektar100" "./DCIM/Oct1002 Ektar100/ROLL007.TXT" "./DCIM/Oct1002 Ektar100/_MG_0505.JPG" \
+ "./DCIM/Oct1002 Ektar100/_MG_0507.JPG" "./DCIM/Oct1002 Ektar100/_MG_0508.JPG" \
+ ./ML/DARKROOM/R007 ./ML/DARKROOM/R007/F01.BMP ./ML/DARKROOM/R007/F03.BMP ./ML/DARKROOM/R007/F04.BMP \
+ ./ML/DARKROOM/R007/SHEET.BMP
+expect "Delete roll: prints only, logged" "lab: roll 007: deleted prints, 0 left"
+# the whole roll (008, across IMG_9999): its RAWs and logs in both DCIM folders, and its prints
+deletes "Delete roll: whole roll across IMG_9999" delete_whole \
+ ./DCIM/100CANON/IMG_9998.CR2 ./DCIM/100CANON/IMG_9999.CR2 ./DCIM/100CANON/ROLL_008.TXT \
+ ./DCIM/101CANON/IMG_0001.CR2 ./DCIM/101CANON/IMG_0002.CR2 ./DCIM/101CANON/ROLL_008.TXT \
+ "./DCIM/Oct1003 Gold200" "./DCIM/Oct1003 Gold200/IMG_0001.JPG" "./DCIM/Oct1003 Gold200/IMG_0002.JPG" \
+ "./DCIM/Oct1003 Gold200/IMG_9998.JPG" "./DCIM/Oct1003 Gold200/IMG_9999.JPG" "./DCIM/Oct1003 Gold200/ROLL008.TXT" \
+ ./ML/DARKROOM/R008 ./ML/DARKROOM/R008/F01.BMP ./ML/DARKROOM/R008/F02.BMP ./ML/DARKROOM/R008/F03.BMP \
+ ./ML/DARKROOM/R008/F04.BMP ./ML/DARKROOM/R008/SHEET.BMP
+# the roll in the camera (006 here): nothing goes
+deletes "Delete roll: never the roll in the camera" delete_loaded ""
+# the whole roll (007) once its prints are gone: straight to "sure?"; Canon's _MG_ names
+deletes "Delete roll: whole roll in Adobe RGB" delete_whole \
+ ./DCIM/100CANON/_MG_0505.CR2 ./DCIM/100CANON/_MG_0507.CR2 ./DCIM/100CANON/_MG_0508.CR2 ./DCIM/100CANON/ROLL_007.TXT
+# the whole roll shot as JPEG (006): Canon's JPEGs are its frames
+deletes "Delete roll: whole roll shot as JPEG" delete_whole \
+ ./DCIM/100CANON/IMG_0501.JPG ./DCIM/100CANON/IMG_0502.JPG ./DCIM/100CANON/IMG_0503.JPG \
+ ./DCIM/100CANON/IMG_0504.JPG ./DCIM/100CANON/ROLL_006.TXT \
+ "./DCIM/Oct1001 Portra400" "./DCIM/Oct1001 Portra400/ROLL006.TXT" ./ML/DARKROOM/R006 ./ML/DARKROOM/R006/SHEET.BMP
+reject "Delete roll: nothing it couldn't" "lab: can't remove|isn't empty"
+
# A card that makes a long-named folder but can't write into it (a 550D's
# exFAT card, #65): the prints go in SEP0906-style folders, and no empty
# long-named one is left, however often the rolls are developed (6 and 7
diff --git a/ml-dev/filmos/sim/mkcard.sh b/ml-dev/filmos/sim/mkcard.sh
index 5302da3..f982c39 100755
--- a/ml-dev/filmos/sim/mkcard.sh
+++ b/ml-dev/filmos/sim/mkcard.sh
@@ -7,8 +7,8 @@
# CARD=out/cardp ./mkcard.sh --problems
# instead, the rolls the darkroom has to find or explain (cardtest.sh):
# shot as JPEG, Adobe RGB with a file deleted, across the IMG_9999 wrap;
-# cardtest.sh also develops them on a card that takes no long folder
-# names (FOS_LONG_DIRS_EMPTY, FOS_NO_RMDIR: port_files.c)
+# cardtest.sh then deletes them (Delete roll), and develops them on a card
+# that takes no long folder names (FOS_LONG_DIRS_EMPTY, FOS_NO_RMDIR: port_files.c)
set -euo pipefail
cd "$(dirname "$0")"
mkdir -p out
diff --git a/ml-dev/filmos/sim/scenes/delete_cancel.txt b/ml-dev/filmos/sim/scenes/delete_cancel.txt
new file mode 100644
index 0000000..a8bb01b
--- /dev/null
+++ b/ml-dev/filmos/sim/scenes/delete_cancel.txt
@@ -0,0 +1,10 @@
+# Delete roll (cardtest.sh): asked, then not confirmed (MENU), for each kind: nothing goes
+noroll
+open darkroom
+1500 left
+2300 info
+3100 menu
+3900 left
+4700 set
+5500 menu
+6500 end
diff --git a/ml-dev/filmos/sim/scenes/delete_loaded.txt b/ml-dev/filmos/sim/scenes/delete_loaded.txt
new file mode 100644
index 0000000..d9e7f04
--- /dev/null
+++ b/ml-dev/filmos/sim/scenes/delete_loaded.txt
@@ -0,0 +1,7 @@
+# Delete roll (cardtest.sh): roll 006 is in the camera and can't be deleted
+roll 0 4 12 6
+open darkroom
+1500 down
+1900 left
+2700 set
+3500 end
diff --git a/ml-dev/filmos/sim/scenes/delete_prints.txt b/ml-dev/filmos/sim/scenes/delete_prints.txt
new file mode 100644
index 0000000..615d10a
--- /dev/null
+++ b/ml-dev/filmos/sim/scenes/delete_prints.txt
@@ -0,0 +1,8 @@
+# Delete roll (cardtest.sh, on the problem card once developed): the prints of
+# the newest roll waiting (007), keeping its RAWs and log
+noroll
+open darkroom
+1500 left
+2300 set
+3100 set
+6000 end
diff --git a/ml-dev/filmos/sim/scenes/delete_whole.txt b/ml-dev/filmos/sim/scenes/delete_whole.txt
new file mode 100644
index 0000000..9487a87
--- /dev/null
+++ b/ml-dev/filmos/sim/scenes/delete_whole.txt
@@ -0,0 +1,9 @@
+# Delete roll (cardtest.sh): all of the roll above the newest waiting (the
+# top one if none is above): SET would be prints only, INFO is the whole roll
+noroll
+open darkroom
+1500 up
+1900 left
+2700 info
+3500 set
+6000 end
diff --git a/ml-dev/filmos/sim/sim.c b/ml-dev/filmos/sim/sim.c
index 4314f40..1073496 100644
--- a/ml-dev/filmos/sim/sim.c
+++ b/ml-dev/filmos/sim/sim.c
@@ -242,11 +242,14 @@ int main(int argc, char **argv)
while (fgets(line, sizeof(line), f))
{
char a[64], b[64];
- int t, n1, n2, n3;
+ int t, n1, n2, n3, n4;
if (line[0] == '#' || line[0] == '\n') continue;
- if (sscanf(line, "roll %d %d %d", &n1, &n2, &n3) == 3)
+ /* roll <film> <shot> <exposures> [<number>]: the roll in the camera */
+ int nr = sscanf(line, "roll %d %d %d %d", &n1, &n2, &n3, &n4);
+ if (nr >= 3)
{
roll.loaded = 1; roll.film = n1; roll.shot = n2; roll.exposures = n3;
+ if (nr == 4) roll.number = n4;
continue;
}
if (!strncmp(line, "noroll", 6)) { roll.loaded = 0; continue; }