Skip to content

Commit

Permalink
Merge pull request #59 from jcobol/jcobol_makefiles
Browse files Browse the repository at this point in the history
Looks good, let me know if you need anything else. Still haven't messed with Docker yet, but it's on my TODO list.
  • Loading branch information
Pinacolada64 committed Jun 22, 2022
2 parents 9be9f59 + 2deb749 commit 115201c
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 26 deletions.
2 changes: 2 additions & 0 deletions v2/asm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build.lst
build.sym
23 changes: 10 additions & 13 deletions v2/asm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

WINE = wine
C1541 = c1541
C64LIST4BETAA = $(WINE) c64list4_00-beta-a.exe # needed for .bin generation/inclusion
C64LIST4BETAC = $(WINE) c64list4_00-beta-c.exe # latest version
C64LIST = $(WINE) /bin/C64List.exe # needed for .bin generation/inclusion
DISKIMAGE = test-ml20.d64
C64_FILENAME = "ml 2.0"
# c64list: petscii translation results in "ml 2.0", but it can't output both .prg and to .d64 in a single command line
Expand All @@ -23,8 +22,8 @@ all: ml20.prg
# @rm $@.in

# (foreach variable,list,text)
# $(foreach O,$(basename $(OBJECTS)),$(echo "wine $(C64LIST4BETAC) @$@.asm -prg" $O))
# echo wine $(C64LIST4BETAC) @$@ -prg
# $(foreach O,$(basename $(OBJECTS)),$(echo "wine $(C64LIST) @$@.asm -prg" $O))
# echo wine $(C64LIST) @$@ -prg
# @rm $@.in

# *.lbl files are being kept as BASIC programs.
Expand All @@ -37,28 +36,26 @@ PREREQS = wedge.bin editor.bin garbage-collect.bin ecs.bin struct.bin \
swap1.bin swap2.bin swap3.bin

%.bin: %.asm
# this must stay beta a for now; this version outputs and includes .bin files
$(C64LIST4BETAA) $< -bin:$@
$(C64LIST) $< -bin:$@

# 2) call build.asm, include *.asm files not listed in $(PREREQS)
ml20.prg: $(PREREQS) build.asm
# need beta a since it embeds .bin files
$(C64LIST4BETAA) build.asm -verbose -prg:ml20.prg
$(C64LIST) build.asm -verbose -prg:ml20.prg
# output symbols
$(C64LIST4BETAA) build.asm -sym
$(C64LIST) build.asm -sym
# TODO: make one-byte zp symbols ($61) two bytes ($0061) for purposes of sorting and ease of diff'ing

# sort symbols
$(shell sort build.sym -t $ --key 2)
# output disassembly
$(C64LIST4BETAA) build.asm -lst
$(C64LIST) build.asm -lst
# write ml 2.0 to disk
$(C1541) $(DISKIMAGE) -write $@ $(C64_FILENAME) -dir

# $(DISKIMAGE): ml20.prg
# $(C1541) -format "test,rs" d64 $(DISKIMAGE)
# # import ml20.prg into $(DISKIMAGE) as "ml 2.0"
# $(C64LIST4BETAC) $< -d64:$@::$(C64_FILENAME)
# $(C64LIST) $< -d64:$@::$(C64_FILENAME)
# # show contents
# $(C1541) $(DISKIMAGE) -dir

Expand Down Expand Up @@ -100,7 +97,7 @@ ml20.prg: $(PREREQS) build.asm
# $(C1541) $(OUTPUT_PATH)/$(OUTPUT_DISK) -del ml.$(basename $@) -write $(OUTPUT_PATH)/$(basename $@).prg ml.$(basename $@)

# Include build date of module
# C64LIST4BETAC does this with build revision tracking
# C64LIST does this with build revision tracking
# Example usage: bd$={usedef:__BuildDate}:bt$={usedef:__BuildTime}

# The "make disk" target will add all the *.prg files to a .d81 at once
Expand All @@ -120,7 +117,7 @@ ml20.prg: $(PREREQS) build.asm

clean:
# "-" prefix allows 'clean' to continue despite possible missing files
-rm *.bin *.prg *.lst $(DISKIMAGE)
-rm -f build.sym *.bin *.prg *.lst $(DISKIMAGE)
$(C1541) -format "test,rs" d64 $(DISKIMAGE)

# FIXME: not sure this really works
Expand Down
12 changes: 11 additions & 1 deletion v2/asm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,14 @@ Vice can also load label files created by the Acme assembler. Their syntax is e.
`labelname = $1234 ; Maybe a comment`. A dot will be added automatically
to label names assigned in this way to fit to the Vice label syntax.

Pipe the `.sym` file generated by `wine casm.exe <file.lbl> -sym | dos2unix` to fix line endings for Linux VICE.
To change Windows' CR/LF line endings to Linux's LF line endings: `wine c64list.exe <file.asm> -sym | dos2unix`

## Docker-based build

The `./v2/asm` directory can be built inside a Docker container to ease environment setup.

Prerequisites:
* Ensure you have Docker installed on your system.
* Ensure your user account is part of the `docker` group. Sample command: `sudo usermod -G docker -a $(whoami)`

Execute `./build.sh` to execute the build. Once the build completes, note the `*.bin` files in the current directory.
16 changes: 8 additions & 8 deletions v2/asm/build.asm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ orig $6c00

; wedge: load addr $0c00, reloc $0c00
{info:embedding wedge.bin}
embed wedge.bin
embed "wedge.bin"
; orig: the individual .bin file's load address
; embed: where in RAM the .bin file gets put
; reloc: where in RAM the module gets relocated to after "ml 2.0" loads
Expand All @@ -28,44 +28,44 @@ orig $6c00
{info:Aligning to $7000.}
orig $7000
{info:embedding editor.bin}
embed editor.bin
embed "editor.bin"

{info:Aligning to $8000.}
orig $8000

; orig $c000, embed $8000, reloc $e000: garbage collect
{info:embedding garbage-collect.bin}
embed garbage-collect.bin
embed "garbage-collect.bin"

{info:Aligning to $8400.}
orig $8400
; orig $c000, embed $8400, reloc $e400: e.c.s. checker
{info:embedding ecs.bin}
embed ecs.bin
embed "ecs.bin"

{info:Aligning to $8e00.}
orig $8e00
; orig $c000, embed $8e00, reloc $ee00: struct
{info:embedding struct.bin}
embed struct.bin
embed "struct.bin"

{info:Aligning to $9400.}
orig $9400
; orig $c000, embed $9400, reloc $f400: swap1
{info:embedding swap1.bin}
embed swap1.bin
embed "swap1.bin"

{info:Aligning to $9800.}
orig $9800
; orig $c000, embed $9800, reloc $f800: swap2
{info:embedding swap2.bin}
embed swap2.bin
embed "swap2.bin"

{info:Aligning to $9c00.}
orig $9c00
; orig $c000, embed $9c00, reloc $fc00: swap3
{info:embedding swap3.bin}
embed swap3.bin
embed "swap3.bin"

{info:Aligning to $a000.}
orig $a000
Expand Down
15 changes: 15 additions & 0 deletions v2/asm/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Ensure Docker is available
if ! docker info &>/dev/null; then
echo "ERROR: Please ensure you have Docker installed and that your shell user is part of the 'docker' group" 1>&2
exit 1
fi

# Build Docker image
# Will use cached copy if already built
(cd ../docker && ./build.sh)

# Execute build inside Docker container

docker run -it --rm -v $(pwd):/asm imagebbs_docker:latest bash -c "cd /asm && make clean all"
9 changes: 7 additions & 2 deletions v2/asm/equates-2_0.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
; Image BBS v2.0 equates
;

;
; printable characters
;

comma = $2c
; [1.2]: labels/memory address is the same as 1.2
; [?] : not certain of purpose of routine
; ($xx): Indirect addressing: $xx *256+ ($xx+1)
Expand Down Expand Up @@ -345,8 +351,7 @@
frmevl = $ad9e ; evaluate string/math expressions
eval1 = $ae8d
parchk = $aef1 ; parentheses check: '('
comma = $aefd ; check next character is comma, ...
chkcom = $aefd ; ...return "?syntax error" if not
chkcom = $aefd ; check if next character is comma, return "?syntax error" if not
synerr = $af08 ; emit "?syntax error"

ptrget1 = $b0e7 ; set up descriptor stored in ($45) [varname],
Expand Down
2 changes: 1 addition & 1 deletion v2/asm/irqhn.asm
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ dispd3:
jsr dispdt
lda d1str+6
jsr dispdt
lda #','
lda #comma
jsr dispdt
lda #' '
jsr dispdt
Expand Down
2 changes: 1 addition & 1 deletion v2/asm/swap3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ movie1:
pha
jsr clrchn
ldx movdly
ldy#0
ldy #0
dl1:
dey
bne dl1
Expand Down
38 changes: 38 additions & 0 deletions v2/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM ubuntu:latest

RUN apt-get update \
&& apt install -y --no-install-recommends \
apt-transport-https \
bison \
build-essential \
ca-certificates \
flex \
git \
gnupg \
gpg-agent \
libreadline-dev \
libxaw7-dev \
unzip \
wget

# Adapted from https://github.com/scottyhardy/docker-wine/blob/master/Dockerfile
# Install wine
ARG WINE_BRANCH="stable"
ARG C64LIST_VER="4.04"
RUN wget -nv -O- https://dl.winehq.org/wine-builds/winehq.key | APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - \
&& echo "deb https://dl.winehq.org/wine-builds/ubuntu/ $(grep VERSION_CODENAME= /etc/os-release | cut -d= -f2) main" >> /etc/apt/sources.list \
&& dpkg --add-architecture i386 \
&& DEBIAN_FRONTEND="noninteractive" apt-get install -y --install-recommends wine-${WINE_BRANCH}

RUN apt install -y libwine --install-recommends \
&& apt update \
&& apt install -y wine32 --no-install-recommends


# Configure locale for unicode
#RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8

COPY files/C64List${C64LIST_VER}/Win32/C64List.exe /bin/C64List.exe

RUN apt install -y vice
3 changes: 3 additions & 0 deletions v2/docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

docker build -t imagebbs_docker .
Binary file added v2/docker/files/C64List4.04/Win32/C64List.exe
Binary file not shown.
Binary file added v2/docker/files/C64List4.04/Win64/C64List.exe
Binary file not shown.
5 changes: 5 additions & 0 deletions v2/docker/files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# C64List

The C64List binaries and .docx files were downloaded from (here)[http://commodoreserver.com/BlogEntryView.asp?EID=8AA5A8C601114E8C8FEEC094A758FABA]
and are included in this Git repository for simplicity.

0 comments on commit 115201c

Please sign in to comment.