Make a wonky French flag

This commit is contained in:
2025-06-26 20:20:43 +00:00
parent 9d96bc0e06
commit 3ec08e34c4
5 changed files with 131 additions and 12 deletions

View File

@@ -3,25 +3,47 @@
FROM ubuntu:24.04 AS build FROM ubuntu:24.04 AS build
RUN apt-get update \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \ build-essential \
fpc \
make \ make \
python3-pip \
unzip \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ADD https://github.com/z00m128/sjasmplus.git#v1.21.0 /sjasmplus 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 ADD https://boarstone.mcphail.uk/mcphail/spectrum_remload.git /ttttt
RUN cd /ttttt && make ttttt RUN cd /ttttt && make ttttt
ADD https://github.com/einar-saukas/ZX0.git /zx0 ADD https://github.com/einar-saukas/ZX0.git /zx0
RUN cd /zx0/src/ \ RUN cd /zx0/src/ \
&& gcc -O2 -o zx0 zx0.c optimize.c compress.c memory.c \ && gcc -O2 -o zx0 zx0.c optimize.c compress.c memory.c \
&& gcc -O2 -o dzx0 dzx0.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* 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 \ RUN apt-get update \
&& apt-get install -y --no-install-recommends \ && apt-get install -y --no-install-recommends \
bison \ bison \
build-essential \
ca-certificates \ ca-certificates \
ccache \ ccache \
cpanminus \ cpanminus \
@@ -44,6 +66,7 @@ RUN apt-get update \
libxml2-dev \ libxml2-dev \
libyaml-perl \ libyaml-perl \
m4 \ m4 \
make \
perl \ perl \
pkg-config \ pkg-config \
ragel \ ragel \
@@ -54,11 +77,11 @@ RUN apt-get update \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV Z88DK_PATH="/opt/z88dk" ENV Z88DK_PATH="/opt/z88dk"
RUN cpanm -l $HOME/perl5 --no-wget local::lib Template::Plugin::YAML \ 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} \ && cd ${Z88DK_PATH} \
&& eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" \ && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" \
&& chmod 777 build.sh \ && 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 && make install-clean bins-clean
FROM ubuntu:24.04 FROM ubuntu:24.04
@@ -67,6 +90,7 @@ RUN apt-get update \
ca-certificates \ ca-certificates \
fuse-emulator-utils \ fuse-emulator-utils \
git \ git \
m4 \
make \ make \
openssh-client \ openssh-client \
pasmo \ 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/zxbc.py /opt/zxbasic/zxbc
COPY --from=build /zxbasic/zxbpp.py /opt/zxbasic/zxbpp COPY --from=build /zxbasic/zxbpp.py /opt/zxbasic/zxbpp
COPY --from=build /zxbasic/src /opt/zxbasic/src COPY --from=build /zxbasic/src /opt/zxbasic/src
COPY --from=z88dk /opt/z88dk/bin /opt/z88dk/bin COPY --from=build /zxbasic/tools /opt/zxbasic/tools
COPY --from=z88dk /opt/z88dk/lib /opt/z88dk/lib COPY --from=build /inpaws/inpaws /bin/inpaws
COPY --from=z88dk /opt/z88dk/include /opt/z88dk/include COPY --from=build /usr/local/bin/ /usr/local/bin/
ENV PATH="${PATH}:/opt/z88dk/bin:/opt/zxbasic" 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" ENV ZCCCFG="/opt/z88dk/lib/config"
USER ubuntu USER ubuntu
RUN echo "PATH=$PATH:/opt/z88dk/bin:/opt/zxbasic" >> ~/.profile
RUN echo "export ZCCCFG=/opt/z88dk/lib/config/" >> ~/.profile

View File

@@ -2,7 +2,7 @@
"name": "ZX Spectrum dev tools", "name": "ZX Spectrum dev tools",
//"build": { "dockerfile": "Dockerfile" }, //"build": { "dockerfile": "Dockerfile" },
// The Dockerfile takes an age to build due to z88dk, so pull from prebuilt: // 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", "remoteUser": "ubuntu",
"runArgs": [ "runArgs": [
"--network=host" "--network=host"

9
Makefile Normal file
View File

@@ -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

37
README.md Normal file
View File

@@ -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

47
main.asm Normal file
View File

@@ -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