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.
C analog-photographycamera-firmwarecanoncanon-5d-mark-ivcanon-5dmark2canon-6dcanon-eoscr2darkroomeos-mfilm-emulationfilm-lookfilm-photographyfilm-simulationfujifilm-recipeskodak-portralutmagic-lanternphotographyraw
The film OS as a module: ~180 KB less at boot, five more cameras fit
Claude23c54733c410
diff --git a/.github/workflows/camera.yml b/.github/workflows/camera.ymlindex 47e044f..aa5304e 100644--- a/.github/workflows/camera.yml+++ b/.github/workflows/camera.yml@@ -28,12 +28,14 @@ jobs:strategy:fail-fast: falsematrix:- platform: [EOSM.202, 650D.104, 700D.115, 6D.116, 5D3.113, 5D3.123, 60D.111, 500D.111, 50D.109, 5D2.212] # from ml-dev/cameras.txt+ platform: [EOSM.202, 100D.101, 650D.104, 700D.115, 6D.116, 70D.112, 5D3.113, 5D3.123, 550D.109, 600D.102, 60D.111, 1100D.105, 500D.111, 50D.109, 5D2.212] # from ml-dev/cameras.txtruns-on: ubuntu-24.04name: camera ${{ matrix.platform }}env:# built and released without the in-camera darkroom: the full build doesn't fit at boot (cameras.txt)NODARK: "650D.104 700D.115"+ # built with the film OS as a module (ML/modules/filmos.mo), loaded after boot (cameras.txt ":module")+ MODULE: "100D.101 70D.112 550D.109 600D.102 1100D.105"steps:- uses: actions/checkout@v4- uses: actions/setup-python@v5@@ -50,12 +52,17 @@ jobs:- name: Buildrun: |p=${{ matrix.platform }}- case " $NODARK " in *" $p "*) bash ml-dev/build_fork.sh $p --no-darkroom ;; *) bash ml-dev/build_fork.sh $p ;; esac+ f=""+ case " $NODARK " in *" $p "*) f="$f --no-darkroom" ;; esac+ case " $MODULE " in *" $p "*) f="$f --module" ;; esac+ bash ml-dev/build_fork.sh $p $f- name: Ziprun: |p=${{ matrix.platform }}- if [ "$p" = EOSM.202 ]; then d=ml-dev/out/fork; else d=ml-dev/out/fork-$p; fi- case " $NODARK " in *" $p "*) d=ml-dev/out/fork-$p-nodark ;; esac+ s=""+ case " $NODARK " in *" $p "*) s="$s-nodark" ;; esac+ case " $MODULE " in *" $p "*) s="$s-module" ;; esac+ if [ "$p" = EOSM.202 ] && [ -z "$s" ]; then d=ml-dev/out/fork; else d=ml-dev/out/fork-$p$s; ficp ml-dev/CAMERA-README.txt "$d/M-FILM-README.txt"# the licence and the notices travel with the binaries (GPL-2.0 section 1; the MIT notice of# Film-Luts, whose LUTs the colour tables and samples in ML/ are made from)@@ -75,9 +82,17 @@ jobs:strategy:fail-fast: falsematrix:- platform: [6D.116] # built --no-darkroom+ # the 6D without the darkroom; and the film OS as a module (--module) on cameras released with+ # it built in, so a tester can try the module where the built-in one is known to start+ include:+ - { platform: 6D.116, flags: --no-darkroom, suffix: -nodark }+ - { platform: EOSM.202, flags: --module, suffix: -module }+ - { platform: 6D.116, flags: --module, suffix: -module }+ - { platform: 650D.104, flags: --module, suffix: -module }+ - { platform: 700D.115, flags: --module, suffix: -module }+ - { platform: 5D2.212, flags: --module, suffix: -module }runs-on: ubuntu-24.04- name: camera ${{ matrix.platform }} (no darkroom, for testing)+ name: camera ${{ matrix.platform }}${{ matrix.suffix }} (for testing)steps:- uses: actions/checkout@v4- uses: actions/setup-python@v5@@ -92,22 +107,22 @@ jobs:git -C "$HOME/ml/magiclantern_simplified" checkout -q ed3e7c0dfacfdeaf3349dee73edf9e3621217462arm-none-eabi-gcc --version | head -1- name: Build- run: bash ml-dev/build_fork.sh ${{ matrix.platform }} --no-darkroom+ run: bash ml-dev/build_fork.sh ${{ matrix.platform }} ${{ matrix.flags }}- name: Ziprun: |p=${{ matrix.platform }}- d=ml-dev/out/fork-$p-nodark+ d=ml-dev/out/fork-$p${{ matrix.suffix }}cp ml-dev/CAMERA-README.txt "$d/M-FILM-README.txt"# the licence and the notices travel with the binaries (GPL-2.0 section 1; the MIT notice of# Film-Luts, whose LUTs the colour tables and samples in ML/ are made from)cp LICENSE "$d/LICENSE.txt"cp THIRD_PARTY.md "$d/THIRD_PARTY.txt"- (cd "$d" && zip -qr "$GITHUB_WORKSPACE/M-Film-camera-$p-nodark.zip" .)- ls -la M-Film-camera-$p-nodark.zip+ (cd "$d" && zip -qr "$GITHUB_WORKSPACE/M-Film-camera-$p${{ matrix.suffix }}.zip" .)+ ls -la M-Film-camera-$p${{ matrix.suffix }}.zip- uses: actions/upload-artifact@v4with:- name: test-M-Film-camera-${{ matrix.platform }}-nodark- path: M-Film-camera-${{ matrix.platform }}-nodark.zip+ name: test-M-Film-camera-${{ matrix.platform }}${{ matrix.suffix }}+ path: M-Film-camera-${{ matrix.platform }}${{ matrix.suffix }}.zipif-no-files-found: errorrelease:diff --git a/PORTING.md b/PORTING.mdindex 067c527..61b816c 100644--- a/PORTING.md+++ b/PORTING.md@@ -66,6 +66,10 @@ all in `ml-dev/fork/apply_fork.py` (applied to a `magiclantern_simplified` check4. `platform/EOSM.202/features.h`: `#define FEATURE_FILMROLL`.5. `platform/EOSM.202/Makefile`: our objects (`filmroll.o fos_*.o`).6. `modules/Makefile`: lua left out (didn't build with the toolchain used).+7. `--module` only: autoexec.bin gets `filmhook.c` (the three hooks above, forwarded to the module by+ `MODULE_FUNCTION`) instead of the film OS, which is built from the same sources as+ `ML/modules/filmos.mo` (`fork/module/Makefile`, `fork/src/filmos_mod.h`). ~180 KB less at boot:+ see "The film OS as a module" in `ml-dev/MEMORY.md`.4 to 6 are per camera: `apply_fork.py SRC <platform> ...` does them for any platform, and`build_fork.sh <platform>` builds one (`ml-dev/out/fork-<platform>/`). What is already done for thediff --git a/README.md b/README.mdindex c541003..bca0ca4 100644--- a/README.md+++ b/README.md@@ -14,7 +14,7 @@ The camera side is free and open, for everyone.[](https://buy.stripe.com/7sY14p8d93QE5Ny5M58so02)[](LICENSE)-[](#cameras)+[](#cameras)[](FILMS.md)**English** · [ภาษาไทย](README.th.md) · [Films](#72-films) · [Cameras](#cameras) · [Darkrooms](#develop-on-your-computer-darkrooms) · [Take it further](PORTING.md)@@ -151,17 +151,17 @@ still wrong. If you have one marked *needs a tester*, you can help: [TESTING.md]| Camera | Canon firmware | Status | Notes | Card files ||---|---|---|---|---|| Canon EOS M | 2.0.2 | ✅ **Works** | | `M-Film-camera-EOSM.202.zip` |-| Canon EOS 100D / Rebel SL1 / Kiss X7 | 1.0.1 | 🔧 Too big for its boot memory: being fixed | | |+| Canon EOS 100D / Rebel SL1 / Kiss X7 | 1.0.1 | 🧪 Builds, needs a tester | New: the film OS now loads as a module after start-up, so the build fits its boot memory (562,944 of 605,952 bytes). Needs a first tester. | `M-Film-camera-100D.101.zip` || Canon EOS 650D / Rebel T4i / Kiss X6i | 1.0.4 | ⚠️ Without the in-camera darkroom (develop with Darkrooms) | The full build gives a black screen ([#34](../../issues/34)); a tester's 650D starts without the darkroom. Released that way since 0.1.3: develop on a computer. | `M-Film-camera-650D.104.zip` || Canon EOS 700D / Rebel T5i / Kiss X7i | 1.1.5 | ⚠️ Without the in-camera darkroom (develop with Darkrooms) | The full build gives a black screen ([#19](../../issues/19)). Released without the darkroom since 0.1.3, as for the 650D: waiting for a tester. | `M-Film-camera-700D.115.zip` || Canon EOS 6D | 1.1.6 | ✅ **Works** | Works since 0.1.2 ([#17](../../issues/17), [#22](../../issues/22)). | `M-Film-camera-6D.116.zip` |-| Canon EOS 70D | 1.1.2 | 🔧 Too big for its boot memory: being fixed | | |+| Canon EOS 70D | 1.1.2 | 🧪 Builds, needs a tester | New: the film OS now loads as a module after start-up, so the build fits its boot memory (511,744 of 605,952 bytes). Needs a first tester. | `M-Film-camera-70D.112.zip` || Canon EOS 5D Mark III (firmware 1.1.3) | 1.1.3 | ⚠️ Tried, known problem | Starts and shoots; the in-camera darkroom couldn't find the RAWs ([#31](../../issues/31)): fixed in 0.1.3. | `M-Film-camera-5D3.113.zip` || Canon EOS 5D Mark III (firmware 1.2.3) | 1.2.3 | ⚠️ Tried, known problem | Starts and shoots; the in-camera darkroom couldn't find the RAWs ([#16](../../issues/16), [#37](../../issues/37)): fixed in 0.1.3. | `M-Film-camera-5D3.123.zip` |-| Canon EOS 550D / Rebel T2i / Kiss X4 | 1.0.9 | 🔧 Too big for its boot memory: being fixed | | |-| Canon EOS 600D / Rebel T3i / Kiss X5 | 1.0.2 | 🔧 Too big for its boot memory: being fixed | | |+| Canon EOS 550D / Rebel T2i / Kiss X4 | 1.0.9 | 🧪 Builds, needs a tester | New: the film OS now loads as a module after start-up, so the build fits its boot memory (572,672 of 589,568 bytes). Needs a first tester. | `M-Film-camera-550D.109.zip` |+| Canon EOS 600D / Rebel T3i / Kiss X5 | 1.0.2 | 🧪 Builds, needs a tester | New: the film OS now loads as a module after start-up, so the build fits its boot memory (537,856 of 589,824 bytes). Needs a first tester. | `M-Film-camera-600D.102.zip` || Canon EOS 60D | 1.1.1 | ⚠️ Tried, known problem | Starts, shoots and develops; the prints came out magenta ([#25](../../issues/25)): fixed in 0.1.3. | `M-Film-camera-60D.111.zip` |-| Canon EOS 1100D / Rebel T3 / Kiss X50 | 1.0.5 | 🔧 Too big for its boot memory: being fixed | | |+| Canon EOS 1100D / Rebel T3 / Kiss X50 | 1.0.5 | 🧪 Builds, needs a tester | New: the film OS now loads as a module after start-up, so the build fits its boot memory (493,056 of 524,032 bytes). Needs a first tester. | `M-Film-camera-1100D.105.zip` || Canon EOS 500D / Rebel T1i / Kiss X3 | 1.1.1 | 🧪 Builds, needs a tester | | `M-Film-camera-500D.111.zip` || Canon EOS 50D | 1.0.9 | 🧪 Builds, needs a tester | | `M-Film-camera-50D.109.zip` || Canon EOS 5D Mark II | 2.1.2 | ⚠️ Tried, known problem | Most hang at power on: the build is too big at start-up ([#18](../../issues/18)). 0.1.3 has a smaller one (some Magic Lantern features left out, the darkroom kept) and fixes the pink prints: waiting for testers. | `M-Film-camera-5D2.212.zip` |diff --git a/README.th.md b/README.th.mdindex 43751e0..eacb0ab 100644--- a/README.th.md+++ b/README.th.md@@ -14,7 +14,7 @@[](https://buy.stripe.com/7sY14p8d93QE5Ny5M58so02)[](LICENSE)-[](#กล้องที่รองรับ)+[](#กล้องที่รองรับ)[](FILMS.md)[English](README.md) · **ภาษาไทย** · [ฟิล์ม](#ฟิล์ม-72-แบบ) · [กล้องที่รองรับ](#กล้องที่รองรับ) · [Darkrooms](#ล้างบนคอม-darkrooms) · [คู่มือในกล้อง](docs/MANUAL.th.md) · [ทำต่อยอด](PORTING.md)@@ -151,17 +151,17 @@ M-Film ทำบน EOS M และใช้ได้จริงบนรุ่| กล้อง | เฟิร์มแวร์ Canon | สถานะ | หมายเหตุ | ไฟล์ลงการ์ด ||---|---|---|---|---|| Canon EOS M | 2.0.2 | ✅ **ใช้ได้** | | `M-Film-camera-EOSM.202.zip` |-| Canon EOS 100D / Rebel SL1 / Kiss X7 | 1.0.1 | 🔧 ใหญ่เกินหน่วยความจำตอนบูต: กำลังแก้ | | |+| Canon EOS 100D / Rebel SL1 / Kiss X7 | 1.0.1 | 🧪 build ได้แล้ว รอคนทดสอบ | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (562,944 จาก 605,952 ไบต์) รอคนลองเป็นคนแรก | `M-Film-camera-100D.101.zip` || Canon EOS 650D / Rebel T4i / Kiss X6i | 1.0.4 | ⚠️ ไม่มีห้องมืดในกล้อง (ล้างด้วย Darkrooms) | build เต็มจอดำ ([#34](../../issues/34)) ผู้ทดสอบลองแบบไม่มีห้องมืดแล้วเปิดได้ ตั้งแต่ 0.1.3 ออกแบบนั้น ล้างบนคอม | `M-Film-camera-650D.104.zip` || Canon EOS 700D / Rebel T5i / Kiss X7i | 1.1.5 | ⚠️ ไม่มีห้องมืดในกล้อง (ล้างด้วย Darkrooms) | build เต็มจอดำ ([#19](../../issues/19)) ตั้งแต่ 0.1.3 ออกแบบไม่มีห้องมืด เหมือน 650D รอคนลอง | `M-Film-camera-700D.115.zip` || Canon EOS 6D | 1.1.6 | ✅ **ใช้ได้** | ใช้ได้ตั้งแต่ 0.1.2 ([#17](../../issues/17), [#22](../../issues/22)) | `M-Film-camera-6D.116.zip` |-| Canon EOS 70D | 1.1.2 | 🔧 ใหญ่เกินหน่วยความจำตอนบูต: กำลังแก้ | | |+| Canon EOS 70D | 1.1.2 | 🧪 build ได้แล้ว รอคนทดสอบ | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (511,744 จาก 605,952 ไบต์) รอคนลองเป็นคนแรก | `M-Film-camera-70D.112.zip` || Canon EOS 5D Mark III (firmware 1.1.3) | 1.1.3 | ⚠️ ลองแล้ว ยังมีปัญหา | เปิดและถ่ายได้ ห้องมืดในกล้องหาไฟล์ RAW ไม่เจอ ([#31](../../issues/31)) แก้แล้วใน 0.1.3 | `M-Film-camera-5D3.113.zip` || Canon EOS 5D Mark III (firmware 1.2.3) | 1.2.3 | ⚠️ ลองแล้ว ยังมีปัญหา | เปิดและถ่ายได้ ห้องมืดในกล้องหาไฟล์ RAW ไม่เจอ ([#16](../../issues/16), [#37](../../issues/37)) แก้แล้วใน 0.1.3 | `M-Film-camera-5D3.123.zip` |-| Canon EOS 550D / Rebel T2i / Kiss X4 | 1.0.9 | 🔧 ใหญ่เกินหน่วยความจำตอนบูต: กำลังแก้ | | |-| Canon EOS 600D / Rebel T3i / Kiss X5 | 1.0.2 | 🔧 ใหญ่เกินหน่วยความจำตอนบูต: กำลังแก้ | | |+| Canon EOS 550D / Rebel T2i / Kiss X4 | 1.0.9 | 🧪 build ได้แล้ว รอคนทดสอบ | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (572,672 จาก 589,568 ไบต์) รอคนลองเป็นคนแรก | `M-Film-camera-550D.109.zip` |+| Canon EOS 600D / Rebel T3i / Kiss X5 | 1.0.2 | 🧪 build ได้แล้ว รอคนทดสอบ | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (537,856 จาก 589,824 ไบต์) รอคนลองเป็นคนแรก | `M-Film-camera-600D.102.zip` || Canon EOS 60D | 1.1.1 | ⚠️ ลองแล้ว ยังมีปัญหา | เปิด ถ่าย และล้างได้ รูปออกสีม่วงอมชมพู ([#25](../../issues/25)) แก้แล้วใน 0.1.3 | `M-Film-camera-60D.111.zip` |-| Canon EOS 1100D / Rebel T3 / Kiss X50 | 1.0.5 | 🔧 ใหญ่เกินหน่วยความจำตอนบูต: กำลังแก้ | | |+| Canon EOS 1100D / Rebel T3 / Kiss X50 | 1.0.5 | 🧪 build ได้แล้ว รอคนทดสอบ | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (493,056 จาก 524,032 ไบต์) รอคนลองเป็นคนแรก | `M-Film-camera-1100D.105.zip` || Canon EOS 500D / Rebel T1i / Kiss X3 | 1.1.1 | 🧪 build ได้แล้ว รอคนทดสอบ | | `M-Film-camera-500D.111.zip` || Canon EOS 50D | 1.0.9 | 🧪 build ได้แล้ว รอคนทดสอบ | | `M-Film-camera-50D.109.zip` || Canon EOS 5D Mark II | 2.1.2 | ⚠️ ลองแล้ว ยังมีปัญหา | ส่วนใหญ่ค้างตอนเปิด เพราะ build ใหญ่เกินหน่วยความจำตอนบูต ([#18](../../issues/18)) 0.1.3 มี build ที่เล็กลง (ตัดบางฟีเจอร์ของ Magic Lantern ออก แต่ห้องมืดยังอยู่) และแก้รูปสีชมพู รอคนลอง | `M-Film-camera-5D2.212.zip` |diff --git a/TESTING.md b/TESTING.mdindex 6a68978..7f93898 100644--- a/TESTING.md+++ b/TESTING.md@@ -20,12 +20,17 @@ From the [latest release](../../releases/latest) (or the newest run under *Actio| Camera | Canon firmware it needs | File ||---|---|---|| Canon EOS M | 2.0.2 | `M-Film-camera-EOSM.202.zip` |+| Canon EOS 100D / Rebel SL1 / Kiss X7 | 1.0.1 | `M-Film-camera-100D.101.zip` || Canon EOS 650D / Rebel T4i / Kiss X6i | 1.0.4 | `M-Film-camera-650D.104.zip` || Canon EOS 700D / Rebel T5i / Kiss X7i | 1.1.5 | `M-Film-camera-700D.115.zip` || Canon EOS 6D | 1.1.6 | `M-Film-camera-6D.116.zip` |+| Canon EOS 70D | 1.1.2 | `M-Film-camera-70D.112.zip` || Canon EOS 5D Mark III (firmware 1.1.3) | 1.1.3 | `M-Film-camera-5D3.113.zip` || Canon EOS 5D Mark III (firmware 1.2.3) | 1.2.3 | `M-Film-camera-5D3.123.zip` |+| Canon EOS 550D / Rebel T2i / Kiss X4 | 1.0.9 | `M-Film-camera-550D.109.zip` |+| Canon EOS 600D / Rebel T3i / Kiss X5 | 1.0.2 | `M-Film-camera-600D.102.zip` || Canon EOS 60D | 1.1.1 | `M-Film-camera-60D.111.zip` |+| Canon EOS 1100D / Rebel T3 / Kiss X50 | 1.0.5 | `M-Film-camera-1100D.105.zip` || Canon EOS 500D / Rebel T1i / Kiss X3 | 1.1.1 | `M-Film-camera-500D.111.zip` || Canon EOS 50D | 1.0.9 | `M-Film-camera-50D.109.zip` || Canon EOS 5D Mark II | 2.1.2 | `M-Film-camera-5D2.212.zip` |diff --git a/ml-dev/CAMERA-README.txt b/ml-dev/CAMERA-README.txtindex dd8da40..26d271a 100644--- a/ml-dev/CAMERA-README.txt+++ b/ml-dev/CAMERA-README.txt@@ -26,6 +26,9 @@ Update to a new versionIf the camera doesn't start (black screen, card light stays on): take the battery out, take thecard out, and the camera starts normally without it. Tell us (see TESTING.md).+If Magic Lantern's own menu shows instead of the film shelf: on some cameras the film OS is a+module (ML/modules/filmos.mo), and it didn't load. Its line in the Modules tab says why. Tell us.+Remove: format the card in the camera, or delete autoexec.bin and ML/.Logs for a bug report: ML/FILMROLL.LOG on the card.diff --git a/ml-dev/MEMORY.md b/ml-dev/MEMORY.mdindex 8a27268..03565f6 100644--- a/ml-dev/MEMORY.md+++ b/ml-dev/MEMORY.md@@ -66,7 +66,55 @@ The same cut doesn't build on the 650D (ML there needs FPS_OVERRIDE, FPS_RAMPINGthree, a lean 650D with the darkroom takes 718,336 bytes: under the EOS M's 727,072, but above the 689,664 knownto start on a 650D. Worth a tester's try before it replaces the no-darkroom release.-## What would fix the fixed ones+## The film OS as a module (`build_fork.sh --module`)++The film OS is about 180 KB of code and data. Built in, all of it is part of `autoexec.bin` and comes out+of the memory the camera gives Magic Lantern at power on. As a module it isn't: autoexec.bin keeps Magic+Lantern and three hooks (`fork/src/filmhook.c`), and the film OS is `ML/modules/filmos.mo`, which Magic+Lantern's module loader puts into Canon's memory after boot (about 216 KB there: 185 KB of code, 35 KB+of data). The film OS itself doesn't change: the same sources, built for one camera+(`fork/module/Makefile`), with the same libm and libgcc as autoexec.bin, so it develops the same prints.++Boot size with `--module`, full film OS with the darkroom (2026-11, gcc 13.2):++| Camera | Built in (the survey above) | As a module | Limit | |+|---|---|---|---|---|+| EOS M | 720,416 | 536,864 | 727,072 | |+| 650D | 743,680 | 564,992 | 689,664 (no darkroom starts) | the darkroom back, under what starts |+| 700D | 743,936 | 565,248 | unknown | as the 650D |+| 6D | 740,864 | 562,176 | 868,096 | |+| 5D Mark III 1.1.3 / 1.2.3 | 737,536 / 733,440 | 558,592 / 554,496 | unknown | |+| 60D | 740,096 | 561,152 | unknown | |+| 500D | 734,208 | 555,264 | unknown | |+| 50D | 716,032 | 537,344 | unknown | |+| 5D Mark II (lean) | 706,048 | 520,192 | 705,792 starts | under what starts |+| 100D | 741,888 | 562,944 | 605,952 | ✅ fits |+| 70D | 690,432 | 511,744 | 605,952 | ✅ fits |+| 550D | 751,616 | 572,672 | 589,568 | ✅ fits (16 KB to spare) |+| 600D | 716,800 | 537,856 | 589,824 | ✅ fits |+| 1100D | 672,000 | 493,056 | 524,032 | ✅ fits |++The five fixed-reservation cameras are built this way (`testing:module` in `cameras.txt`), with nothing+of Magic Lantern left out. The others keep the built-in film OS for their releases; CI also builds the+module for the EOS M, 6D, 650D, 700D and 5D Mark II as `test-…-module` artifacts, so a tester can try it+where the built-in one is known to start.++What only a camera can tell:+- **Canon's memory after boot.** The module and the loader's work while linking it (it reads the file and+ links it with TCC) come out of Canon's own memory, which Canon also uses. The one figure known so far: the+ 6D had 2,192 KB free with stock Magic Lantern (below). Where there isn't enough, the module fails to load.+- **If the module doesn't load**, the camera starts with Magic Lantern alone: the hooks answer as if there+ were no film OS, so MENU opens Magic Lantern's own menu (Modules tab: why it didn't load). After a crash+ while loading modules, Magic Lantern skips them at the next start and says so.+- **Settings.** The module keeps them in `ML/SETTINGS/filmos.cfg`. The first time it starts it takes the+ `filmroll.*` ones from `magiclantern.cfg`, so a camera moving from the built-in film OS keeps its roll.++How the module is checked when it's built (`build_fork.sh`): every name it needs must be exported by that+camera's autoexec.bin (`*.sym`), it must not define a name autoexec.bin has (only its entry points stay+global), and nothing in it calls into autoexec.bin with a short branch (libm's `__errno` goes to the+module's own `fos_errno`), so it works wherever the loader puts it.++## What would fix the fixed ones (built in)The same as the 6D: give Magic Lantern a bigger slice of the pool at boot, and check that Canon keeps enough.- **70D:** its pool starts and ends where the 6D's does (`0x44C000`–`0xD3C000`), so the 6D's `0x520000` (848K)diff --git a/ml-dev/build_fork.sh b/ml-dev/build_fork.shindex 34cd128..0bf8cb7 100644--- a/ml-dev/build_fork.sh+++ b/ml-dev/build_fork.sh@@ -7,6 +7,10 @@# build_fork.sh 6D.116 --no-darkroom# without the in-camera darkroom (~60 KB less at boot, for cameras# that can't spare it) -> ml-dev/out/fork-6D.116-nodark/+# build_fork.sh 1100D.105 --module+# the film OS as a module (ML/modules/filmos.mo, loaded after boot):+# autoexec.bin keeps only Magic Lantern and three hooks, ~190 KB less+# at boot -> ml-dev/out/fork-1100D.105-module/ (both flags can go together)## The cameras are the folders under platform/ in magiclantern_simplified; the# ones M-Film knows are listed in CAMERAS (ml-dev/cameras.txt).@@ -16,17 +20,25 @@ HERE="$(cd "$(dirname "$0")" && pwd)"SRC="${ML_SRC:-$HOME/ml/magiclantern_simplified}"PLAT="${1:-EOSM.202}"NODARK=""-[ "${2:-}" = "--no-darkroom" ] && NODARK="--no-darkroom"-if [ "$PLAT" = "EOSM.202" ] && [ -z "$NODARK" ]; then OUT="$HERE/out/fork"; else OUT="$HERE/out/fork-$PLAT${NODARK:+-nodark}"; fi-LOG="${LOG:-$HOME/ml/build_fork_$PLAT${NODARK:+-nodark}.log}"+MODULE=""+for a in "${@:2}"; do+ case "$a" in+ --no-darkroom) NODARK="--no-darkroom" ;;+ --module) MODULE="--module" ;;+ *) echo "unknown option $a"; exit 1 ;;+ esac+done+TAG="${NODARK:+-nodark}${MODULE:+-module}"+if [ "$PLAT" = "EOSM.202" ] && [ -z "$TAG" ]; then OUT="$HERE/out/fork"; else OUT="$HERE/out/fork-$PLAT$TAG"; fi+LOG="${LOG:-$HOME/ml/build_fork_$PLAT$TAG.log}"-cp "$HERE"/fork/src/filmroll.{c,h} "$HERE"/filmos/fos*.{c,h} "$SRC/src/"-sed -i 's/\r$//' "$SRC"/src/filmroll.{c,h} "$SRC"/src/fos*.{c,h}+cp "$HERE"/fork/src/filmroll.{c,h} "$HERE"/fork/src/filmhook.c "$HERE"/filmos/fos*.{c,h} "$SRC/src/"+sed -i 's/\r$//' "$SRC"/src/filmroll.{c,h} "$SRC"/src/filmhook.c "$SRC"/src/fos*.{c,h}# M-Film's version, one for the camera and the program (VERSION at the top of the repository)VERSION=$(tr -d ' \r\n' < "$HERE/../VERSION")printf '#define MFILM_VERSION "%s"\n' "$VERSION" > "$SRC/src/fos_version.h"echo "M-Film $VERSION"-python3 "$HERE/fork/apply_fork.py" "$SRC" "$PLAT" $NODARK+python3 "$HERE/fork/apply_fork.py" "$SRC" "$PLAT" $NODARK $MODULEcd "$SRC/platform/$PLAT"make clean >/dev/null@@ -58,11 +70,48 @@ if [ -n "$LIMIT" ] && [ "$LIMIT" != "-" ]; thenelseecho "ML takes $USED bytes at boot (no limit known for $PLAT yet: if the camera hangs at power on, it is too big)"fi-mkdir -p "$HERE/out" && echo "$USED" > "$HERE/out/.size-$PLAT${NODARK:+-nodark}"+mkdir -p "$HERE/out" && echo "$USED" > "$HERE/out/.size-$PLAT$TAG"rm -rf "$OUT" && mkdir -p "$OUT"(cd "$OUT" && unzip -q "$SRC/platform/$PLAT/$ZIP")+if [ -n "$MODULE" ]; then+ # the film OS as ML/modules/filmos.mo, built for this camera only (fork/module/Makefile)+ MOD="$SRC/modules/filmos"+ rm -rf "$MOD" && mkdir -p "$MOD"+ cp "$HERE"/fork/module/{Makefile,README.rst} "$HERE"/fork/src/filmroll.{c,h} "$HERE"/fork/src/filmos_mod.h \+ "$HERE"/filmos/fos*.{c,h} "$SRC"/src/fos_version.h "$MOD/"+ sed -i 's/\r$//' "$MOD"/*.c "$MOD"/*.h+ OBJS="filmroll.o fos_gfx.o fos_film.o fos_ui.o fos_shelf.o fos_pages.o fos_hud.o fos_print.o"+ if [ -n "$NODARK" ]; then OBJS="$OBJS fos_nodark.o"; else OBJS="$OBJS fos_dark.o fos_dev.o fos_lab.o fos_looks.o fos_jpeg.o"; fi+ make -C "$MOD" FILMOS_PLATFORM="$PLAT" FILMOS_OBJS="$OBJS" FATAL_WARNINGS=y >> "$LOG" 2>&1 || { tail -40 "$LOG"; echo "the film OS module didn't build, see $LOG"; exit 1; }+ # Only the module's entry points stay global: the loader refuses a module that defines a name+ # autoexec.bin already has (libgcc's helpers, pulled in with __powisf2).+ arm-none-eabi-objcopy --wildcard --keep-global-symbol='__module_*' \+ --keep-global-symbol=filmos_key_used --keep-global-symbol=filmos_menu_open \+ --keep-global-symbol=filmos_overlays "$MOD/build/filmos.mo"+ arm-none-eabi-readelf -sW "$MOD/build/filmos.mo" | awk '$5 == "GLOBAL" && $7 == "UND" {print $8}' | sort -u > "$MOD/build/filmos.dep"+ # every symbol the module needs must be in this camera's autoexec.bin, or the loader refuses it+ # the symbol file the camera's module loader reads (5D2_212.sym, t3_105.sym on the 1100D ...)+ SYM="$OUT/ML/modules/$(cd "$SRC/platform/$PLAT/build" && ls *.sym | grep -v '^magiclantern.sym$' | head -1)"+ [ -f "$SYM" ] || { echo "no symbol file for $PLAT in the card files"; exit 1; }+ MISSING=$(comm -23 <(sort -u "$MOD/build/filmos.dep") <(awk '{print $2}' "$SYM" | sort -u))+ if [ -n "$MISSING" ]; then+ echo "the film OS module needs symbols this camera's Magic Lantern doesn't export:"; echo "$MISSING"+ exit 1+ fi+ CLASH=$(comm -12 <(arm-none-eabi-readelf -sW "$MOD/build/filmos.mo" | awk '$5 == "GLOBAL" && $7 != "UND" {print $8}' | sort -u) <(awk '{print $2}' "$SYM" | sort -u))+ if [ -n "$CLASH" ]; then+ echo "the film OS module defines names autoexec.bin already has:"; echo "$CLASH"+ exit 1+ fi+ # next to ML's own modules, in the zip's spelling (the card doesn't care, a computer unzipping it does)+ mkdir -p "$OUT/ML/modules" "$OUT/ML/SETTINGS"+ cp "$MOD/build/filmos.mo" "$OUT/ML/modules/filmos.mo"+ : > "$OUT/ML/SETTINGS/filmos.en" # enabled: ML's menu, where modules are switched on, is the film OS's+ echo "film OS module: $(stat -c %s "$OUT/ML/modules/filmos.mo") bytes, loaded after boot"+fi+# the film OS fonts, loaded from the card after bootgcc -O2 -I"$HERE/filmos" -o "$HOME/ml/fontblob" "$HERE/filmos/tools/fontblob.c"mkdir -p "$OUT/ML/data"@@ -106,5 +155,5 @@ echo "== card files in $OUT =="(cd "$OUT" && find . -maxdepth 3 | sort | head -60)# keep the fork's source changes next to the project-(cd "$SRC" && git add -A src/filmroll.c src/filmroll.h src/fos*.c $(ls src/fos*.h | grep -v fos_version.h) && git diff ed3e7c0df -- src platform > "$HERE/fork/film-mode.patch")+(cd "$SRC" && git add -A src/filmroll.c src/filmroll.h src/filmhook.c src/fos*.c $(ls src/fos*.h | grep -v fos_version.h) && git diff ed3e7c0df -- src platform > "$HERE/fork/film-mode.patch")echo "patch: $HERE/fork/film-mode.patch"diff --git a/ml-dev/cameras.txt b/ml-dev/cameras.txtindex f87af52..5bee92c 100644--- a/ml-dev/cameras.txt+++ b/ml-dev/cameras.txt@@ -11,21 +11,24 @@# would stop at power on (3 long, 3 short blinks), so it isn't built or released# until that reservation is raised for it, as for the 6D (MEMORY.md)# no not for now: Magic Lantern itself is experimental there (DIGIC 6 and later)+# :module after the status (e.g. testing:module): built with the film OS as a module+# (build_fork.sh --module): ML/modules/filmos.mo, loaded after boot, so autoexec.bin keeps+# only Magic Lantern and three hooks, ~180 KB less at boot (MEMORY.md)# boot-limit: the largest autoexec.bin (bytes at boot) known to start on it, - if not known yet# (6D: what the fork reserves for ML at boot, see the 6D edit in fork/apply_fork.py;# 100D, 70D, 550D, 600D, 1100D: the fixed reservation of Magic Lantern's boot code, MEMORY.md)EOSM.202 working 727072 Canon EOS M-100D.101 memory 605952 Canon EOS 100D / Rebel SL1 / Kiss X7+100D.101 testing:module 605952 Canon EOS 100D / Rebel SL1 / Kiss X7 | New: the film OS now loads as a module after start-up, so the build fits its boot memory (562,944 of 605,952 bytes). Needs a first tester. | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (562,944 จาก 605,952 ไบต์) รอคนลองเป็นคนแรก650D.104 nodark 689664 Canon EOS 650D / Rebel T4i / Kiss X6i | The full build gives a black screen (#34); a tester's 650D starts without the darkroom. Released that way since 0.1.3: develop on a computer. | build เต็มจอดำ (#34) ผู้ทดสอบลองแบบไม่มีห้องมืดแล้วเปิดได้ ตั้งแต่ 0.1.3 ออกแบบนั้น ล้างบนคอม700D.115 nodark - Canon EOS 700D / Rebel T5i / Kiss X7i | The full build gives a black screen (#19). Released without the darkroom since 0.1.3, as for the 650D: waiting for a tester. | build เต็มจอดำ (#19) ตั้งแต่ 0.1.3 ออกแบบไม่มีห้องมืด เหมือน 650D รอคนลอง6D.116 working 868096 Canon EOS 6D | Works since 0.1.2 (#17, #22). | ใช้ได้ตั้งแต่ 0.1.2 (#17, #22)-70D.112 memory 605952 Canon EOS 70D+70D.112 testing:module 605952 Canon EOS 70D | New: the film OS now loads as a module after start-up, so the build fits its boot memory (511,744 of 605,952 bytes). Needs a first tester. | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (511,744 จาก 605,952 ไบต์) รอคนลองเป็นคนแรก5D3.113 issues - Canon EOS 5D Mark III (firmware 1.1.3) | Starts and shoots; the in-camera darkroom couldn't find the RAWs (#31): fixed in 0.1.3. | เปิดและถ่ายได้ ห้องมืดในกล้องหาไฟล์ RAW ไม่เจอ (#31) แก้แล้วใน 0.1.35D3.123 issues - Canon EOS 5D Mark III (firmware 1.2.3) | Starts and shoots; the in-camera darkroom couldn't find the RAWs (#16, #37): fixed in 0.1.3. | เปิดและถ่ายได้ ห้องมืดในกล้องหาไฟล์ RAW ไม่เจอ (#16, #37) แก้แล้วใน 0.1.3-550D.109 memory 589568 Canon EOS 550D / Rebel T2i / Kiss X4-600D.102 memory 589824 Canon EOS 600D / Rebel T3i / Kiss X5+550D.109 testing:module 589568 Canon EOS 550D / Rebel T2i / Kiss X4 | New: the film OS now loads as a module after start-up, so the build fits its boot memory (572,672 of 589,568 bytes). Needs a first tester. | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (572,672 จาก 589,568 ไบต์) รอคนลองเป็นคนแรก+600D.102 testing:module 589824 Canon EOS 600D / Rebel T3i / Kiss X5 | New: the film OS now loads as a module after start-up, so the build fits its boot memory (537,856 of 589,824 bytes). Needs a first tester. | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (537,856 จาก 589,824 ไบต์) รอคนลองเป็นคนแรก60D.111 issues - Canon EOS 60D | Starts, shoots and develops; the prints came out magenta (#25): fixed in 0.1.3. | เปิด ถ่าย และล้างได้ รูปออกสีม่วงอมชมพู (#25) แก้แล้วใน 0.1.3-1100D.105 memory 524032 Canon EOS 1100D / Rebel T3 / Kiss X50+1100D.105 testing:module 524032 Canon EOS 1100D / Rebel T3 / Kiss X50 | New: the film OS now loads as a module after start-up, so the build fits its boot memory (493,056 of 524,032 bytes). Needs a first tester. | ใหม่: film OS โหลดเป็นโมดูลหลังเปิดกล้อง build จึงพอดีหน่วยความจำตอนบูตแล้ว (493,056 จาก 524,032 ไบต์) รอคนลองเป็นคนแรก500D.111 testing - Canon EOS 500D / Rebel T1i / Kiss X350D.109 testing - Canon EOS 50D5D2.212 issues - Canon EOS 5D Mark II | Most hang at power on: the build is too big at start-up (#18). 0.1.3 has a smaller one (some Magic Lantern features left out, the darkroom kept) and fixes the pink prints: waiting for testers. | ส่วนใหญ่ค้างตอนเปิด เพราะ build ใหญ่เกินหน่วยความจำตอนบูต (#18) 0.1.3 มี build ที่เล็กลง (ตัดบางฟีเจอร์ของ Magic Lantern ออก แต่ห้องมืดยังอยู่) และแก้รูปสีชมพู รอคนลองdiff --git a/ml-dev/fork/apply_fork.py b/ml-dev/fork/apply_fork.pyindex a3d9f74..0eb42d5 100644--- a/ml-dev/fork/apply_fork.py+++ b/ml-dev/fork/apply_fork.py@@ -17,6 +17,9 @@ from pathlib import Pathroot = Path(sys.argv[1])# --no-darkroom: the film OS without its in-camera darkroom (fos_nodark.c in its place), ~60 KB less at bootNO_DARKROOM = "--no-darkroom" in sys.argv[2:]+# --module: the film OS is a module (ML/modules/filmos.mo, built by build_fork.sh) loaded after boot;+# autoexec.bin keeps only the three hooks (filmhook.c), ~190 KB less at boot+MODULE = "--module" in sys.argv[2:]PLATFORMS = [a for a in sys.argv[2:] if not a.startswith("--")] or ["EOSM.202"]@@ -63,9 +66,14 @@ edit("src/zebra.c",edit("src/menu.c","static void menu_open() \n{ \n if (menu_shown)\n return;\n","static void menu_open() \n{ \n#ifdef FEATURE_FILMROLL\n"+ "#ifdef FEATURE_FILMOS_MODULE\n"+ " if (filmroll_menu_requested()) /* 0: the module isn't loaded, ML's menu opens */\n"+ " return;\n"+ "#else\n"" filmroll_menu_requested();\n"" return;\n""#endif\n"+ "#endif\n"" if (menu_shown)\n return;\n","filmroll_menu_requested")edit("src/menu.c",@@ -105,6 +113,14 @@ LEAN_FEATURES = ["ZEBRA", "ZEBRA_FAST", "FOCUS_PEAK", "GHOST_IMAGE", "SPOTMETER""GRADUAL_EXPOSURE", "TRAP_FOCUS", "FOLLOW_FOCUS", "RACK_FOCUS", "AUDIO_METERS", "HDR_BRACKETING"]+def film_os_objects():+ """The film OS's objects in autoexec.bin. (build_fork.sh --module builds the same list into filmos.mo.)"""+ objs = ["filmroll", "fos_gfx", "fos_film", "fos_ui", "fos_shelf", "fos_pages", "fos_hud", "fos_print"]+ objs += ["fos_nodark"] if NO_DARKROOM else ["fos_dark", "fos_dev", "fos_lab", "fos_looks", "fos_jpeg"]+ return objs+++def platform(name):"""FEATURE_FILMROLL, our objects, and no lua, for one camera."""# build it in@@ -117,6 +133,16 @@ def platform(name):# Cameras whose build is too big at boot: Magic Lantern features M-Film doesn't use, left out# (Enzo-Reveillon's list on his 5D Mark II, #18). VECTORSCOPE, MAGIC_ZOOM, RAW_HISTOGRAM and# INTERVALOMETER stay: ML doesn't build without them.+ # --module: the film OS is filmos.mo; the core's hooks may find it missing (filmhook.c)+ p = root / f"platform/{name}/features.h"+ text = p.read_text()+ mark = "\n/* film-mode fork: the film OS is a module (build_fork.sh --module) */\n#define FEATURE_FILMOS_MODULE\n"+ if MODULE and mark not in text:+ p.write_text(text.rstrip("\n") + "\n" + mark)+ print(f" platform/{name}/features.h: film OS as a module")+ elif not MODULE and mark in text:+ p.write_text(text.replace(mark, ""))+ print(f" platform/{name}/features.h: film OS built in")if name in LEAN:p = root / f"platform/{name}/features.h"if "film-mode fork: lean" not in p.read_text():@@ -126,8 +152,9 @@ def platform(name):# our objects. Rewritten every time (older versions of this fork# listed only filmroll.o), so the list always matches the sources.# (no fos_font: the fonts go on the card as ML/DATA/FOSFONT.BIN, see fos_gfx.h)- FOS_OBJS = ["filmroll", "fos_gfx", "fos_film", "fos_ui", "fos_shelf", "fos_pages", "fos_hud", "fos_print"]- FOS_OBJS += ["fos_nodark"] if NO_DARKROOM else ["fos_dark", "fos_dev", "fos_lab", "fos_looks", "fos_jpeg"]+ FOS_OBJS = film_os_objects()+ if MODULE:+ FOS_OBJS = ["filmhook"] # the film OS itself is the module (build_fork.sh)p = root / f"platform/{name}/Makefile"lines = p.read_text().split("\n")out, skip = [], False@@ -135,7 +162,7 @@ def platform(name):if skip:skip = line.rstrip().endswith("\\")continue- if line.startswith("ML_SRC_EXTRA_OBJS +=") and ("filmroll" in line or "fos_" in line):+ if line.startswith("ML_SRC_EXTRA_OBJS +=") and ("filmroll" in line or "fos_" in line or "filmhook" in line):skip = line.rstrip().endswith("\\")continueout.append(line)diff --git a/ml-dev/fork/film-mode.patch b/ml-dev/fork/film-mode.patchindex 582b88b..de5ffde 100644--- a/ml-dev/fork/film-mode.patch+++ b/ml-dev/fork/film-mode.patch@@ -1,26 +1,29 @@diff --git a/platform/100D.101/Makefile b/platform/100D.101/Makefile-index 05832de0d..9e706a32e 100644+index 05832de0d..6aeb6422b 100644--- a/platform/100D.101/Makefile+++ b/platform/100D.101/Makefile@@ -15,6 +15,7 @@ PLATFORM_ARCH = armv5teRESTARTSTART = 0x44C100ML_BOOT_OBJ = boot-d45-am.oML_SRC_EXTRA_OBJS = $(BUILD_DIR)/reloc.o-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.o++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmhook.oinclude ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_completediff --git a/platform/100D.101/features.h b/platform/100D.101/features.h-index 18fa340fe..0a9fb2e00 100644+index 18fa340fe..cb0f612f5 100644--- a/platform/100D.101/features.h+++ b/platform/100D.101/features.h-@@ -12,3 +12,6 @@+@@ -12,3 +12,9 @@/* Not working */#undef FEATURE_TRAP_FOCUS#undef FEATURE_MAGIC_ZOOM_FULL_SCREEN // https://bitbucket.org/hudson/magic-lantern/issues/2842++/* film camera mode (src/filmroll.c) */+#define FEATURE_FILMROLL++++/* film-mode fork: the film OS is a module (build_fork.sh --module) */++#define FEATURE_FILMOS_MODULEdiff --git a/platform/100D.101/modules.included b/platform/100D.101/modules.includedindex 8428d3c4b..a3be71e80 100644--- a/platform/100D.101/modules.included@@ -34,28 +37,31 @@ index 8428d3c4b..a3be71e80 100644mlv_playmlv_snddiff --git a/platform/1100D.105/Makefile b/platform/1100D.105/Makefile-index 474a5bd7b..b28492c1b 100644+index 474a5bd7b..8063406cb 100644--- a/platform/1100D.105/Makefile+++ b/platform/1100D.105/Makefile@@ -21,6 +21,7 @@ RESTARTSTART = 0xC80100ML_BOOT_OBJ = boot-d45-am.oFIRMWARE_ID_1100D = 0x80000288-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.o++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmhook.oinclude ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_completediff --git a/platform/1100D.105/features.h b/platform/1100D.105/features.h-index 81cc3db68..21ccd11c0 100644+index 81cc3db68..0c2e07e6b 100644--- a/platform/1100D.105/features.h+++ b/platform/1100D.105/features.h-@@ -32,3 +32,6 @@+@@ -32,3 +32,9 @@#undef FEATURE_FLEXINFO#undef FEATURE_SHOW_FREE_MEMORY#undef CONFIG_TSKMON++/* film camera mode (src/filmroll.c) */+#define FEATURE_FILMROLL++++/* film-mode fork: the film OS is a module (build_fork.sh --module) */++#define FEATURE_FILMOS_MODULEdiff --git a/platform/1100D.105/modules.included b/platform/1100D.105/modules.includedindex 70260051d..eb4ce352c 100644--- a/platform/1100D.105/modules.included@@ -138,28 +144,31 @@ index 9412f9301..6c9da4f53 100644mlv_playpic_viewdiff --git a/platform/550D.109/Makefile b/platform/550D.109/Makefile-index d7b8d6f03..47d22dfd0 100644+index d7b8d6f03..b7479c3a7 100644--- a/platform/550D.109/Makefile+++ b/platform/550D.109/Makefile@@ -22,6 +22,7 @@ ML_BOOT_OBJ = boot-d45-am.oML_PICSTYLE_AUTO = nCONFIG_LVAPP_HACK_RELOC = y-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.o++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmhook.oinclude ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_completediff --git a/platform/550D.109/features.h b/platform/550D.109/features.h-index fd2485377..104598425 100644+index fd2485377..bfd9a86c8 100644--- a/platform/550D.109/features.h+++ b/platform/550D.109/features.h-@@ -12,3 +12,6 @@+@@ -12,3 +12,9 @@#undef FEATURE_LV_BUTTON_RATE_UPDOWN // Canon uses up/down in play mode#undef FEATURE_BULB_TIMER_SHOW_PREVIOUS_PIC // screen remains black++/* film camera mode (src/filmroll.c) */+#define FEATURE_FILMROLL++++/* film-mode fork: the film OS is a module (build_fork.sh --module) */++#define FEATURE_FILMOS_MODULEdiff --git a/platform/550D.109/modules.included b/platform/550D.109/modules.includedindex edc1dfbba..b8ec816ba 100644--- a/platform/550D.109/modules.included@@ -299,28 +308,31 @@ index eddc7617e..6bfdee970 100644mlv_playmlv_snddiff --git a/platform/600D.102/Makefile b/platform/600D.102/Makefile-index 1cd54b6a0..e1b6731bc 100644+index 1cd54b6a0..6ef27076f 100644--- a/platform/600D.102/Makefile+++ b/platform/600D.102/Makefile@@ -19,6 +19,7 @@ ML_BOOT_OBJ = boot-d45-ch.oML_AUDIO_OBJ = audio-lapis.oCONFIG_LVAPP_HACK_RELOC = y-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.o++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmhook.oinclude ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_completediff --git a/platform/600D.102/features.h b/platform/600D.102/features.h-index 7e3229a7b..ec518efec 100644+index 7e3229a7b..16a0a2ca4 100644--- a/platform/600D.102/features.h+++ b/platform/600D.102/features.h-@@ -17,3 +17,6 @@+@@ -17,3 +17,9 @@#undef FEATURE_SHOW_EDMAC_INFO#undef CONFIG_TSKMON++/* film camera mode (src/filmroll.c) */+#define FEATURE_FILMROLL++++/* film-mode fork: the film OS is a module (build_fork.sh --module) */++#define FEATURE_FILMOS_MODULEdiff --git a/platform/600D.102/modules.included b/platform/600D.102/modules.includedindex edc1dfbba..b8ec816ba 100644--- a/platform/600D.102/modules.included@@ -369,14 +381,14 @@ index edc1dfbba..b8ec816ba 100644mlv_playmlv_snddiff --git a/platform/650D.104/Makefile b/platform/650D.104/Makefile-index 9e9650596..6ef6f2852 100644+index 9e9650596..452e67a8d 100644--- a/platform/650D.104/Makefile+++ b/platform/650D.104/Makefile@@ -14,6 +14,7 @@ PLATFORM_ARCH = armv5te# RESTARTSTART is selected to be just above the end of the bss#RESTARTSTART = 0x7E100-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_dark.o $(BUILD_DIR)/fos_dev.o $(BUILD_DIR)/fos_lab.o $(BUILD_DIR)/fos_looks.o $(BUILD_DIR)/fos_jpeg.o++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.oinclude ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_complete@@ -439,14 +451,14 @@ index eddc7617e..6bfdee970 100644mlv_playmlv_snddiff --git a/platform/700D.115/Makefile b/platform/700D.115/Makefile-index af9eb604f..373803523 100644+index af9eb604f..0db8c8efa 100644--- a/platform/700D.115/Makefile+++ b/platform/700D.115/Makefile@@ -15,6 +15,7 @@ PLATFORM_ARCH = armv5te#MAIN_FIRMWARE_ADDR = 0xFF0C0000RESTARTSTART = 0x7EC00-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_dark.o $(BUILD_DIR)/fos_dev.o $(BUILD_DIR)/fos_lab.o $(BUILD_DIR)/fos_looks.o $(BUILD_DIR)/fos_jpeg.o++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.oinclude ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_complete@@ -474,67 +486,35 @@ index 8428d3c4b..a3be71e80 100644mlv_playmlv_snddiff --git a/platform/70D.112/Makefile b/platform/70D.112/Makefile-index 508e2c952..46950f467 100644+index 508e2c952..e2ec59b3e 100644--- a/platform/70D.112/Makefile+++ b/platform/70D.112/Makefile@@ -20,6 +20,7 @@ ML_BITRATE_OBJ = bitrate-5d3.o# default 0x44C000 - 0xD3C000, patched to 0x4E0000 - 0xD3C000 (592K for us).RESTARTSTART = 0x44C100ML_BOOT_OBJ = boot-d45-am.o-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_nodark.o++ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmhook.oinclude ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_completediff --git a/platform/70D.112/features.h b/platform/70D.112/features.h-index 5095eea7d..7db47a65b 100644+index 5095eea7d..e3daf04a3 100644--- a/platform/70D.112/features.h+++ b/platform/70D.112/features.h-@@ -33,3 +33,6 @@+@@ -33,3 +33,9 @@/* Audio Features */#define FEATURE_AUDIO_METERS#define FEATURE_AUDIO_REMOTE_SHOT++/* film camera mode (src/filmroll.c) */+#define FEATURE_FILMROLL++++/* film-mode fork: the film OS is a module (build_fork.sh --module) */++#define FEATURE_FILMOS_MODULEdiff --git a/platform/70D.112/modules.included b/platform/70D.112/modules.includedindex eddc7617e..6bfdee970 100644--- a/platform/70D.112/modules.included+++ b/platform/70D.112/modules.included-@@ -11,7 +11,6 @@ edmac- ettr- file_man- img_name--lua- mlv_lite- mlv_play- mlv_snd-diff --git a/platform/7D.203/Makefile b/platform/7D.203/Makefile-index 01a525ba4..eb4f9e8e0 100644---- a/platform/7D.203/Makefile-+++ b/platform/7D.203/Makefile-@@ -1,6 +1,7 @@- #Makefile for 7D-- MODEL=7D-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_dark.o $(BUILD_DIR)/fos_dev.o $(BUILD_DIR)/fos_lab.o $(BUILD_DIR)/fos_looks.o $(BUILD_DIR)/fos_jpeg.o-- include ../Makefile--diff --git a/platform/7D.203/features.h b/platform/7D.203/features.h-index 2b37c0834..01b8ecc0b 100644---- a/platform/7D.203/features.h-+++ b/platform/7D.203/features.h-@@ -19,3 +19,6 @@- #define FEATURE_AUDIO_REMOTE_SHOT-- #undef FEATURE_VIGNETTING_CORRECTION // requires master code-+-+/* film camera mode (src/filmroll.c) */-+#define FEATURE_FILMROLL-diff --git a/platform/7D.203/modules.included b/platform/7D.203/modules.included-index eddc7617e..6bfdee970 100644---- a/platform/7D.203/modules.included-+++ b/platform/7D.203/modules.included@@ -11,7 +11,6 @@ edmacettrfile_man@@ -544,15 +524,15 @@ index eddc7617e..6bfdee970 100644mlv_playmlv_snddiff --git a/platform/EOSM.202/Makefile b/platform/EOSM.202/Makefile-index 7e11d12a2..cc4932423 100644+index 7e11d12a2..be468805c 100644--- a/platform/EOSM.202/Makefile+++ b/platform/EOSM.202/Makefile-@@ -19,5 +19,7 @@ RESTARTSTART = 0x9E1E0+@@ -18,6 +18,7 @@ PLATFORM_ARCH = armv5te+ RESTARTSTART = 0x9E1E0ML_AF_PATTERNS_OBJ = n-+ML_SRC_EXTRA_OBJS += $(BUILD_DIR)/filmroll.o $(BUILD_DIR)/fos_gfx.o $(BUILD_DIR)/fos_film.o $(BUILD_DIR)/fos_ui.o $(BUILD_DIR)/fos_shelf.o $(BUILD_DIR)/fos_pages.o $(BUILD_DIR)/fos_hud.o $(BUILD_DIR)/fos_print.o $(BUILD_DIR)/fos_dark.o $(BUILD_DIR)/fos_dev.o $(BUILD_DIR)/fos_lab.o $(BUILD_DIR)/fos_looks.o $(BUILD_DIR)/fos_jpeg.o-++include ../Makefile.DEFAULT_GOAL := $(BUILD_DIR)/cam_completediff --git a/platform/EOSM.202/features.h b/platform/EOSM.202/features.h@@ -595,12 +575,51 @@ index 2201e76c7..01865665a 100755/* R0: 0x44C000 (start address, easier to patch, change to 0x4E0000 => reserve 592K for ML) *//* R1: 0xD3C000 [6D, 70D] / 0xC3C000 [100D] (end address, unchanged) */addr_AllocMem_end[1] = MOV_R0_0x4E0000_INSTR;+diff --git a/src/filmhook.c b/src/filmhook.c+new file mode 100644+index 000000000..3c74011d1+--- /dev/null++++ b/src/filmhook.c+@@ -0,0 +1,33 @@++/* The film OS as a module (build_fork.sh --module): all that stays in++ * autoexec.bin. The film OS itself (filmroll.c, fos_*.c) is ML/modules/filmos.mo,++ * loaded after boot into Canon's memory, so it doesn't count against what the++ * camera can spare at power on (MEMORY.md).++ *++ * These are the three calls ML's core makes into the film OS. Each goes to++ * the module once it is loaded; without it (missing, failed to load, or ML++ * skipped loading modules after a crash) they answer as if there were no++ * film OS, so the camera still has Magic Lantern's own menu. */++++#include <dryos.h>++#include <module.h>++#include "filmroll.h"++++/* defined in the module (filmroll.c); 0 until it is loaded */++static int (*filmos_key_used)(struct event *event) = MODULE_FUNCTION(filmos_key_used);++static int (*filmos_menu_open)(void) = MODULE_FUNCTION(filmos_menu_open);++static int (*filmos_overlays)(void) = MODULE_FUNCTION(filmos_overlays);++++int handle_filmroll_keys(struct event *event)++{++ return filmos_key_used(event) ? 0 : 1;++}++++int filmroll_menu_requested()++{++ return filmos_menu_open();++}++++int filmroll_overlays_active()++{++ return filmos_overlays();++}diff --git a/src/filmroll.c b/src/filmroll.cnew file mode 100644-index 000000000..642db0176+index 000000000..7812c702a--- /dev/null+++ b/src/filmroll.c-@@ -0,0 +1,1469 @@+@@ -0,0 +1,1498 @@+/* filmroll: a Canon camera as a film camera (built into this ML fork).+ * Made on the EOS M; 100D, 650D, 700D and others build from the same code.+ *@@ -629,6 +648,15 @@ index 000000000..642db0176+ * logged even in burst mode.+ */+++#ifdef MODULE++/* ML/modules/filmos.mo is built for one camera (fork/module/Makefile), so it++ * takes that camera's definitions, as autoexec.bin does */++#include "internals.h"++#include "internals-common.h"++#include "features.h"++#include "consts.h"++#include "gui.h" /* ahead of dryos.h's gui-common.h, as in autoexec.bin */++#endif+#include <dryos.h>+#include <module.h>+#include <property.h>@@ -647,6 +675,13 @@ index 000000000..642db0176+#include <tasks.h>+#include <mem.h>+#include <powersave.h>++#ifdef MODULE++/* built as ML/modules/filmos.mo (build_fork.sh --module): the core keeps++ * these three names for its shim (filmhook.c), the module's own go by others */++#define handle_filmroll_keys fr_handle_keys++#define filmroll_menu_requested fr_menu_requested++#define filmroll_overlays_active fr_overlays_active++#endif+#include "filmroll.h"+#include "fos.h"+#include "fos_dev.h"@@ -1928,11 +1963,20 @@ index 000000000..642db0176++/* ---------------------------------------------------------------- the ML menu, replaced */+++#ifdef MODULE++int filmroll_menu_requested()++{++ if (shooting_screen())++ open_ui(FOS_OPEN_HOME);++ return 1;++}++#else+void filmroll_menu_requested()+{+ if (shooting_screen())+ open_ui(FOS_OPEN_HOME);+}++#endif++static void filmroll_init()+{@@ -2068,14 +2112,18 @@ index 000000000..642db0176+ }+}+++#ifndef MODULE+INIT_FUNC("filmroll", filmroll_init);+TASK_CREATE("film_main", filmroll_task, 0, 0x1e, 0x2000);++#else++#include "filmos_mod.h"++#endifdiff --git a/src/filmroll.h b/src/filmroll.hnew file mode 100644-index 000000000..f43cb73ad+index 000000000..c465a6cd1--- /dev/null+++ b/src/filmroll.h-@@ -0,0 +1,16 @@+@@ -0,0 +1,22 @@+#ifndef _filmroll_h_+#define _filmroll_h_+@@ -2084,8 +2132,14 @@ index 000000000..f43cb73ad+/* button hook, called from handle_common_events_by_feature; 0 = handled */+int handle_filmroll_keys(struct event *event);+-+/* called instead of opening the Magic Lantern menu (menu.c) */++/* called instead of opening the Magic Lantern menu (menu.c). With the film OS++ * as a module (FEATURE_FILMOS_MODULE): 1 = it took it, 0 = open ML's menu as++ * usual (the module isn't loaded) */++#if defined(FEATURE_FILMOS_MODULE) || defined(MODULE)++int filmroll_menu_requested();++#else+void filmroll_menu_requested();++#endif++/* ML's own LiveView overlays stay out of the way of the film OS and the+ * viewfinder HUD (always, in this fork) */@@ -17110,7 +17164,7 @@ index 992e8f692..13f631291 100644if (handle_flexinfo_keys(event) == 0) return 0;diff --git a/src/menu.c b/src/menu.c-index a83f43e1b..57405de9d 100755+index a83f43e1b..a139f9128 100755--- a/src/menu.c+++ b/src/menu.c@@ -39,6 +39,7 @@@@ -17121,13 +17175,18 @@ index a83f43e1b..57405de9d 100755#define CONFIG_MENU_ICONS//~ #define CONFIG_MENU_DIM_HACKS-@@ -5648,6 +5649,10 @@ static void close_canon_menu()+@@ -5648,6 +5649,15 @@ static void close_canon_menu()static void menu_open(){+#ifdef FEATURE_FILMROLL++#ifdef FEATURE_FILMOS_MODULE++ if (filmroll_menu_requested()) /* 0: the module isn't loaded, ML's menu opens */++ return;++#else+ filmroll_menu_requested();+ return;++#endif+#endifif (menu_shown)return;diff --git a/ml-dev/fork/module/Makefile b/ml-dev/fork/module/Makefilenew file mode 100644index 0000000..29dff31--- /dev/null+++ b/ml-dev/fork/module/Makefile@@ -0,0 +1,24 @@+# The film OS as a Magic Lantern module (build_fork.sh --module copies this to+# modules/filmos/ with the sources). Built per camera: the film OS reads the+# camera's buttons and sensor by CONFIG_<camera>, so build_fork.sh passes+# FILMOS_PLATFORM (e.g. 5D2.212) and the module is only for that camera.+MODULE_NAME = filmos+MODULE_OBJS = $(addprefix $(BUILD_DIR)/,$(FILMOS_OBJS))+# the maths the darkroom uses (exp2f, powf's helpers) come from the same libm and libgcc that+# autoexec.bin is linked with, so the module develops exactly as the built-in darkroom does+# (libm's own calls to __errno go to the module's fos_errno instead: libm isn't built with+# -mlong-calls, and the module may load too far from autoexec.bin for a plain BL to reach it)+MODULE_OBJS += $(BUILD_DIR)/fos-libm.a $(TOP_DIR)/platform/$(FILMOS_PLATFORM)/build/gcc-libgcc.a+TOP_DIR = ../..++FILMOS_MODEL = $(firstword $(subst ., ,$(FILMOS_PLATFORM)))+FILMOS_FW = $(lastword $(subst ., ,$(FILMOS_PLATFORM)))+MODULE_CFLAGS += -I$(TOP_DIR)/platform/$(FILMOS_PLATFORM) -I$(TOP_DIR)/platform/$(FILMOS_PLATFORM)/include \+ -DCONFIG_$(FILMOS_MODEL)=1 -DCONFIG_$(FILMOS_MODEL)_$(FILMOS_FW)=1 -DCONFIG_FW_VERSION=$(FILMOS_FW)++include $(TOP_DIR)/modules/Makefile+.DEFAULT_GOAL := $(BUILD_DIR)/module_complete++# (after the include: BUILD_DIR comes from it)+$(BUILD_DIR)/fos-libm.a: $(TOP_DIR)/platform/$(FILMOS_PLATFORM)/build/newlib-libm.a | $(BUILD_DIR)+ $(OBJCOPY) --redefine-sym __errno=fos_errno $< $@diff --git a/ml-dev/fork/module/README.rst b/ml-dev/fork/module/README.rstnew file mode 100644index 0000000..a812f48--- /dev/null+++ b/ml-dev/fork/module/README.rst@@ -0,0 +1,10 @@+Film OS+=======++M-Film's film camera: the film shelf, the roll, the viewfinder HUD and the+in-camera darkroom, as a module loaded after boot (build_fork.sh --module).+Built for one camera; use the one in that camera's M-Film zip.++:Author: hengz+:License: GPL+:Summary: M-Film's film OS, loaded after bootdiff --git a/ml-dev/fork/src/filmhook.c b/ml-dev/fork/src/filmhook.cnew file mode 100644index 0000000..3c74011--- /dev/null+++ b/ml-dev/fork/src/filmhook.c@@ -0,0 +1,33 @@+/* The film OS as a module (build_fork.sh --module): all that stays in+ * autoexec.bin. The film OS itself (filmroll.c, fos_*.c) is ML/modules/filmos.mo,+ * loaded after boot into Canon's memory, so it doesn't count against what the+ * camera can spare at power on (MEMORY.md).+ *+ * These are the three calls ML's core makes into the film OS. Each goes to+ * the module once it is loaded; without it (missing, failed to load, or ML+ * skipped loading modules after a crash) they answer as if there were no+ * film OS, so the camera still has Magic Lantern's own menu. */++#include <dryos.h>+#include <module.h>+#include "filmroll.h"++/* defined in the module (filmroll.c); 0 until it is loaded */+static int (*filmos_key_used)(struct event *event) = MODULE_FUNCTION(filmos_key_used);+static int (*filmos_menu_open)(void) = MODULE_FUNCTION(filmos_menu_open);+static int (*filmos_overlays)(void) = MODULE_FUNCTION(filmos_overlays);++int handle_filmroll_keys(struct event *event)+{+ return filmos_key_used(event) ? 0 : 1;+}++int filmroll_menu_requested()+{+ return filmos_menu_open();+}++int filmroll_overlays_active()+{+ return filmos_overlays();+}diff --git a/ml-dev/fork/src/filmos_mod.h b/ml-dev/fork/src/filmos_mod.hnew file mode 100644index 0000000..fc21811--- /dev/null+++ b/ml-dev/fork/src/filmos_mod.h@@ -0,0 +1,121 @@+/* The film OS as a module: the end of filmroll.c when it is built as+ * ML/modules/filmos.mo (build_fork.sh --module), in place of its INIT_FUNC+ * and TASK_CREATE. Included there so it sees filmroll.c's statics. */+++/* The settings, saved in ML/SETTINGS/filmos.cfg by the module loader (same+ * names as before: filmroll.roll, filmroll.shot, ...). */+MODULE_CONFIGS_START()+ MODULE_CONFIG(film_sel)+ MODULE_CONFIG(exp_sel)+ MODULE_CONFIG(hud_enabled)+ MODULE_CONFIG(focus_screen)+ MODULE_CONFIG(leds_on_half)+ MODULE_CONFIG(wind_mode)+ MODULE_CONFIG(play_lock)+ MODULE_CONFIG(startup_picker)+ MODULE_CONFIG(boot_anim)+ MODULE_CONFIG(debug_log)+ MODULE_CONFIG(film_mode)+ MODULE_CONFIG(lens_widest)+ MODULE_CONFIG(manual_fstop)+ MODULE_CONFIG(aperture_keys)+ MODULE_CONFIG(scr_std)+ MODULE_CONFIG(scr_sat)+ MODULE_CONFIG(scr_warm)+ MODULE_CONFIG(scr_bright)+ MODULE_CONFIG(roll_loaded)+ MODULE_CONFIG(roll_number)+ MODULE_CONFIG(roll_film)+ MODULE_CONFIG(roll_exposures)+ MODULE_CONFIG(frames_shot)+ MODULE_CONFIG(last_file_number)+ MODULE_CONFIG(roll_folder)+ MODULE_CONFIG(need_wind)+MODULE_CONFIGS_END()++/* A camera that ran the built-in film OS kept these settings in Magic+ * Lantern's own magiclantern.cfg. The first time the module starts (no+ * FILMOS.CFG yet) it takes them from there, so a roll in the camera carries+ * on where it was. */+static void config_from_core()+{+ char path[64];+ snprintf(path, sizeof(path), "%sfilmos.cfg", get_config_dir());+ if ((int) FIO_GetFileSize_direct(path) >= 0)+ return;+ snprintf(path, sizeof(path), "%smagiclantern.cfg", get_config_dir());+ int size = 0;+ char *buf = (char *) read_entire_file(path, &size);+ if (!buf)+ return;+ int taken = 0;+ for (char *line = buf; line < buf + size; )+ {+ char *end = line;+ while (end < buf + size && *end != '\n' && *end != '\r') end++;+ char save = (end < buf + size) ? *end : 0;+ if (end < buf + size) *end = 0;+ if (strncmp(line, "filmroll.", 9) == 0)+ {+ for (module_config_t *c = __module_config_filmos; c->name; c++)+ {+ int n = strlen(c->ref->name);+ if (strncmp(line, c->ref->name, n) == 0 && (line[n] == ' ' || line[n] == '='))+ {+ char *v = line + n;+ while (*v == ' ' || *v == '=') v++;+ *(c->ref->value) = atoi(v);+ taken++;+ break;+ }+ }+ }+ if (end < buf + size) *end = save;+ line = end + 1;+ }+ fio_free(buf);+ dbg("init: %d settings taken from magiclantern.cfg (first start as a module)", taken);+}++/* errno for the maths library linked into the module (fork/module/Makefile) */+int *fos_errno(void)+{+ static int e;+ return &e;+}++static unsigned int filmos_init()+{+ config_from_core();+ filmroll_init();+ task_create("film_main", 0x1e, 0x2000, filmroll_task, 0);+ return 0;+}++static unsigned int filmos_deinit()+{+ return 0;+}++/* What the core's shim (filmhook.c) calls. Not static: the module loader+ * hands these to the core by name once the module is loaded. */+int filmos_key_used(struct event *event)+{+ return handle_filmroll_keys(event) == 0;+}++int filmos_menu_open()+{+ return filmroll_menu_requested();+}++int filmos_overlays()+{+ return filmroll_overlays_active();+}++MODULE_INFO_START()+ MODULE_INIT(filmos_init)+ MODULE_DEINIT(filmos_deinit)+MODULE_INFO_END()diff --git a/ml-dev/fork/src/filmroll.c b/ml-dev/fork/src/filmroll.cindex 642db01..7812c70 100644--- a/ml-dev/fork/src/filmroll.c+++ b/ml-dev/fork/src/filmroll.c@@ -26,6 +26,15 @@* logged even in burst mode.*/+#ifdef MODULE+/* ML/modules/filmos.mo is built for one camera (fork/module/Makefile), so it+ * takes that camera's definitions, as autoexec.bin does */+#include "internals.h"+#include "internals-common.h"+#include "features.h"+#include "consts.h"+#include "gui.h" /* ahead of dryos.h's gui-common.h, as in autoexec.bin */+#endif#include <dryos.h>#include <module.h>#include <property.h>@@ -44,6 +53,13 @@#include <tasks.h>#include <mem.h>#include <powersave.h>+#ifdef MODULE+/* built as ML/modules/filmos.mo (build_fork.sh --module): the core keeps+ * these three names for its shim (filmhook.c), the module's own go by others */+#define handle_filmroll_keys fr_handle_keys+#define filmroll_menu_requested fr_menu_requested+#define filmroll_overlays_active fr_overlays_active+#endif#include "filmroll.h"#include "fos.h"#include "fos_dev.h"@@ -1325,11 +1341,20 @@ int handle_filmroll_keys(struct event *event)/* ---------------------------------------------------------------- the ML menu, replaced */+#ifdef MODULE+int filmroll_menu_requested()+{+ if (shooting_screen())+ open_ui(FOS_OPEN_HOME);+ return 1;+}+#elsevoid filmroll_menu_requested(){if (shooting_screen())open_ui(FOS_OPEN_HOME);}+#endifstatic void filmroll_init(){@@ -1465,5 +1490,9 @@ static void filmroll_task()}}+#ifndef MODULEINIT_FUNC("filmroll", filmroll_init);TASK_CREATE("film_main", filmroll_task, 0, 0x1e, 0x2000);+#else+#include "filmos_mod.h"+#endifdiff --git a/ml-dev/fork/src/filmroll.h b/ml-dev/fork/src/filmroll.hindex f43cb73..c465a6c 100644--- a/ml-dev/fork/src/filmroll.h+++ b/ml-dev/fork/src/filmroll.h@@ -6,8 +6,14 @@ struct event;/* button hook, called from handle_common_events_by_feature; 0 = handled */int handle_filmroll_keys(struct event *event);-/* called instead of opening the Magic Lantern menu (menu.c) */+/* called instead of opening the Magic Lantern menu (menu.c). With the film OS+ * as a module (FEATURE_FILMOS_MODULE): 1 = it took it, 0 = open ML's menu as+ * usual (the module isn't loaded) */+#if defined(FEATURE_FILMOS_MODULE) || defined(MODULE)+int filmroll_menu_requested();+#elsevoid filmroll_menu_requested();+#endif/* ML's own LiveView overlays stay out of the way of the film OS and the* viewfinder HUD (always, in this fork) */diff --git a/ml-dev/tools/cameras.py b/ml-dev/tools/cameras.pyindex 0195c2d..9ba9cf0 100644--- a/ml-dev/tools/cameras.py+++ b/ml-dev/tools/cameras.py@@ -1,5 +1,6 @@"""ml-dev/cameras.txt -> the camera tables in README.md, README.th.md and TESTING.md, and the-cameras CI builds (.github/workflows/camera.yml, and which of them without the darkroom). Run after changing cameras.txt:+cameras CI builds (.github/workflows/camera.yml, and which of them without the darkroom or with the+film OS as a module). Run after changing cameras.txt:python3 ml-dev/tools/cameras.py"""@@ -39,9 +40,11 @@ def cameras():if not line.strip() or line.startswith("#"):continueplat, status, limit, rest = line.split(None, 3)+ # "testing:module": the film OS is built as a module for it (build_fork.sh --module)+ status, _, build = status.partition(":")name, note, note_th = (rest.split(" | ") + ["", ""])[:3]fw = plat.split(".")[1]- out.append({"plat": plat, "status": status, "limit": limit, "name": name.strip(),+ out.append({"plat": plat, "status": status, "module": build == "module", "limit": limit, "name": name.strip(),"note": note.strip(), "note_th": note_th.strip() or note.strip(),"fw": ".".join(fw) if fw.isdigit() else fw})return out@@ -107,6 +110,8 @@ def main():lambda m: m.group(1) + "[" + ", ".join(c["plat"] for c in built) + "] # from ml-dev/cameras.txt", text, count=1)text = re.sub(r"( NODARK: \")[^\"]*(\")",lambda m: m.group(1) + " ".join(c["plat"] for c in cams if c["status"] == "nodark") + m.group(2), text, count=1)+ text = re.sub(r"( MODULE: \")[^\"]*(\")",+ lambda m: m.group(1) + " ".join(c["plat"] for c in built if c["module"]) + m.group(2), text, count=1)wf.write_text(text, encoding="utf-8")print(f"{len(cams)} cameras: {sum(c['status'] == 'working' for c in cams)} working, {sum(c['status'] == 'issues' for c in cams)} with a problem, "f"{sum(c['status'] == 'testing' for c in cams)} testing, {sum(c['status'] == 'nodark' for c in cams)} without the darkroom, {sum(c['status'] == 'memory' for c in cams)} too big at boot")