From 3ec08e34c4350ed05cb09baf974f0aa5b2f02772 Mon Sep 17 00:00:00 2001 From: Neil McPhail Date: Thu, 26 Jun 2025 20:20:43 +0000 Subject: [PATCH] Make a wonky French flag --- .devcontainer/Dockerfile | 48 +++++++++++++++++++++++++-------- .devcontainer/devcontainer.json | 2 +- Makefile | 9 +++++++ README.md | 37 +++++++++++++++++++++++++ main.asm | 47 ++++++++++++++++++++++++++++++++ 5 files changed, 131 insertions(+), 12 deletions(-) create mode 100644 Makefile create mode 100644 README.md create mode 100644 main.asm diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 375e7d6..2d4e600 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,25 +3,47 @@ FROM ubuntu:24.04 AS build RUN apt-get update \ && apt-get install -y --no-install-recommends \ + autoconf \ + automake \ build-essential \ + fpc \ make \ + python3-pip \ + unzip \ && rm -rf /var/lib/apt/lists/* ADD https://github.com/z00m128/sjasmplus.git#v1.21.0 /sjasmplus -RUN cd /sjasmplus && make && make install +RUN cd /sjasmplus && make -j8 && make install ADD https://boarstone.mcphail.uk/mcphail/spectrum_remload.git /ttttt RUN cd /ttttt && make ttttt ADD https://github.com/einar-saukas/ZX0.git /zx0 RUN cd /zx0/src/ \ && gcc -O2 -o zx0 zx0.c optimize.c compress.c memory.c \ && gcc -O2 -o dzx0 dzx0.c -ADD https://www.boriel.com/files/zxb/zxbasic-1.18.1-linux64.tar.gz . +ADD https://www.boriel.com/files/zxb/zxbasic-1.18.3-linux64.tar.gz . RUN tar xf zxbasic* +ADD https://github.com/Mastodon-/inpaws.git /inpaws +RUN cd /inpaws/ \ + && make -j8 +RUN python3 -m pip install --break-system-packages skoolkit +ADD https://github.com/gasman/hdfmonkey.git /hdfmonkey +RUN cd /hdfmonkey/ \ + && autoheader \ + && aclocal \ + && autoconf \ + && automake -a \ + && ./configure \ + && make -j16 \ + && make install +ADD https://github.com/pleumann/pasta80.git#v0.96 /opt/pasta80 +RUN cd /opt/pasta80 \ + && fpc pasta -FROM build AS z88dk +FROM ubuntu:24.04 AS z88dk RUN apt-get update \ && apt-get install -y --no-install-recommends \ bison \ + build-essential \ ca-certificates \ ccache \ cpanminus \ @@ -44,6 +66,7 @@ RUN apt-get update \ libxml2-dev \ libyaml-perl \ m4 \ + make \ perl \ pkg-config \ ragel \ @@ -54,11 +77,11 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* ENV Z88DK_PATH="/opt/z88dk" RUN cpanm -l $HOME/perl5 --no-wget local::lib Template::Plugin::YAML \ - && git clone --depth 1 --recursive https://github.com/z88dk/z88dk.git ${Z88DK_PATH} \ + && git clone --depth 1 --branch v2.4 --recursive https://github.com/z88dk/z88dk.git ${Z88DK_PATH} \ && cd ${Z88DK_PATH} \ && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" \ && chmod 777 build.sh \ - && BUILD_SDCC=1 BUILD_SDCC_HTTP=1 ./build.sh \ + && BUILD_SDCC=1 BUILD_SDCC_HTTP=1 MAKE_CONCURRENCY=-j8 ./build.sh \ && make install-clean bins-clean FROM ubuntu:24.04 @@ -67,6 +90,7 @@ RUN apt-get update \ ca-certificates \ fuse-emulator-utils \ git \ + m4 \ make \ openssh-client \ pasmo \ @@ -83,11 +107,13 @@ COPY --from=build /zxbasic/zxbasm.py /opt/zxbasic/zxbasm COPY --from=build /zxbasic/zxbc.py /opt/zxbasic/zxbc COPY --from=build /zxbasic/zxbpp.py /opt/zxbasic/zxbpp COPY --from=build /zxbasic/src /opt/zxbasic/src -COPY --from=z88dk /opt/z88dk/bin /opt/z88dk/bin -COPY --from=z88dk /opt/z88dk/lib /opt/z88dk/lib -COPY --from=z88dk /opt/z88dk/include /opt/z88dk/include -ENV PATH="${PATH}:/opt/z88dk/bin:/opt/zxbasic" +COPY --from=build /zxbasic/tools /opt/zxbasic/tools +COPY --from=build /inpaws/inpaws /bin/inpaws +COPY --from=build /usr/local/bin/ /usr/local/bin/ +COPY --from=build /usr/local/lib/python3.12/dist-packages/skoolkit/ /usr/local/lib/python3.12/dist-packages/skoolkit/ +COPY --from=build /usr/local/bin/hdfmonkey /bin/hdfmonkey +COPY --from=build /opt/pasta80 /opt/pasta80 +COPY --from=z88dk /opt/z88dk/ /opt/z88dk/ +ENV PATH="${PATH}:/opt/z88dk/bin:/opt/zxbasic:/opt/zxbasic/tools:/opt/pasta80" ENV ZCCCFG="/opt/z88dk/lib/config" USER ubuntu -RUN echo "PATH=$PATH:/opt/z88dk/bin:/opt/zxbasic" >> ~/.profile -RUN echo "export ZCCCFG=/opt/z88dk/lib/config/" >> ~/.profile \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index be348c2..9600cc9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,7 +2,7 @@ "name": "ZX Spectrum dev tools", //"build": { "dockerfile": "Dockerfile" }, // The Dockerfile takes an age to build due to z88dk, so pull from prebuilt: - "image": "boarstone.mcphail.uk/mcphail/speccydev:stable", + "image": "boarstone.mcphail.uk/mcphail/speccydev:v3.0", "remoteUser": "ubuntu", "runArgs": [ "--network=host" diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3b04df8 --- /dev/null +++ b/Makefile @@ -0,0 +1,9 @@ +myprog.sna myprog.sld: main.asm + sjasmplus --sld=myprog.sld --fullpath main.asm + +clean: + rm -rf *.sna + rm -rf *.sld + rm -rf .tmp/ + +.PHONY: clean \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..426a409 --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ +# Wonky French Flag + +This is an example ZX Spectrum program which produces a wonky French flag. + +## Usage + +- Clone this git repository +- Change into the directory +- Run `code .` to bring up VSCode +- Agree to "Reopen in container" +- Wait for the devcontainer to download and initialise +- Build the project with `make` +- Open the `myprog.sna` file in your favourite Spectrum emulator +- Recoil at flag wonkiness +- Open `main.asm` in the VSCode editor and have a quick read +- Select "Run and Debug" from the bar on the far left +- In the drop down bar at the top, select "Simulator - ZX48K Spectrum" +- Press the "Start Debugging" green arrow to the left of the dropdown list +- Select the "Continue" arrow from the wee icon menu which has appeared at the top of the screen +- Recoil again at the wonky flag +- Stop debugging by pressing the square at the far right of the wee icon menu +- Go back to the `main.asm` file +- Left click on the space to the left of the line number at line 25 +- A little red breakpoint blob should have appeared. You can toggle this by clicking on it +- Start debugging again +- Press "Continue" arrow as before +- The debugger will stop the program running at the breakpoint +- Keep pressing the "Step into" downwards arrow on the wee icon bar +- Note what is happening to the registers on the left and the screen on the right +- Watch the red stripe getting painted +- Have a moment of revelation about how you're going to fix this +- Stop the debugger +- Edit `main.asm` to fix the bug +- Remember to save the file and run `make` again to rebuild the program +- Remove the breakpoint on line 25 +- Run in the debugger again +- Marvel at the lovely flag \ No newline at end of file diff --git a/main.asm b/main.asm new file mode 100644 index 0000000..73e9194 --- /dev/null +++ b/main.asm @@ -0,0 +1,47 @@ +code_start_addr EQU #8000 + ORG code_start_addr + +ink_blue EQU 1 +paper_blue EQU 8 +ink_white EQU 7 +paper_white EQU 56 +ink_red EQU 2 +paper_red EQU 16 +bright EQU 64 +attribute_start EQU #5800 +stripe_width EQU 11 +stripe_height EQU 24 +screen_width EQU 32 + + ; blue stripe first + ld hl, attribute_start ; top left corner + ld a, ink_blue | paper_blue | bright + call make_stripe + ; white + ld hl, attribute_start + stripe_width + ld a, ink_white | paper_white | bright + call make_stripe + ; red + ld hl, attribute_start + stripe_width * 2 + ld a, ink_red | paper_red | bright + call make_stripe +eternal_pause: + jr eternal_pause + +make_stripe: + ld c, stripe_height +vertical_loop: + ld b, stripe_width +horizontal_loop: + ld (hl), a + inc hl + djnz horizontal_loop + ld de, screen_width - stripe_width + add hl, de + dec c + jr nz, vertical_loop + ret + + DEVICE ZXSPECTRUM48 + SLDOPT COMMENT WPMEM, LOGPOINT, ASSERTION + SAVESNA "myprog.sna", code_start_addr \ No newline at end of file