Skip to content

Commit e9a84bf

Browse files
committed
Initial import
0 parents  commit e9a84bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+32372
-0
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.swp
2+
*.o
3+
*.a
4+
*~
5+
*.bin

LICENSE

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (C) 2015 by Juan J. Martinez <[email protected]>
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
all:
2+
make -C video
3+
make -C input
4+
make -C memory
5+
make -C vm
6+
make -C storage
7+
make -C dasm
8+
make -C init
9+
make -C docs
10+
11+
cc65:
12+
make -C cc65
13+
14+
upload: all
15+
make -C init upload
16+
17+
clean:
18+
make -s -C video clean
19+
make -s -C input clean
20+
make -s -C memory clean
21+
make -s -C vm clean
22+
make -s -C storage clean
23+
make -s -C storage/tools clean
24+
make -s -C dasm clean
25+
make -s -C dasm/tools clean
26+
make -s -C init clean
27+
make -s -C docs clean
28+
make -s -C cc65 clean
29+

README.markdown

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
DAN64, an AVR based 8-bit microcomputer
2+
=======================================
3+
4+
This is my personal attempt to build a 8-bit microcomputer based on
5+
the popular ATmega328 microcontroller (MCU) as an excuse to learn some
6+
electronics. Check `docs/` directory for further information.
7+
8+
The microcomputer can be assembled and run in a breadboard with an
9+
Arduino Uno board.
10+
11+
General features:
12+
13+
- Composite video black and white output, 256 x 192 resolution, 32 x 24
14+
characters (8 x 8 pixels font, code page 437 character set).
15+
- PS/2 keyboard support.
16+
- 6502 virtual machine with system call interface to native code
17+
services.
18+
- Linear 64KB memory access from the virtual machine (256 bytes page zero,
19+
256 bytes hardware stack, 6144 bytes of video RAM and 58880 bytes for
20+
user programs).
21+
- External storage support via audio in/out.
22+
- Integrated 6502 assembler and disassembler.
23+
- Basic shell supporting peek, poke, load, run, etc.
24+
25+
Project page: http://www.usebox.net/jjm/dan64/
26+
27+
General directory structure
28+
---------------------------
29+
30+
- `docs/`: documentation of the project.
31+
- `schematics/`: KiCad schematics and PCB design.
32+
- source code:
33+
- `include/`: general include files.
34+
- `init/`: main entry point for the firmware, including the implementation
35+
of the syscalls.
36+
- `video/`: composite video generation.
37+
- `input/`: PS/2 keyboard support.
38+
- `memory/`: memory functions.
39+
- `vm/`: 6502 virtual machine.
40+
- `test/`: virtual machine test suite.
41+
- `storage/`: storage using audio in/out.
42+
- `tools/`: wav audio file encoder.
43+
- `dasm/`: DAN64 assembler/disassembler.
44+
- `tools/`: standalone version.
45+
- `tools/`: some misc auxiliary tools (eg, font bitmap generation).
46+
- `cc65/`: CC65 runtime for cross-compiling C programs.
47+
- `examples/`: several user program examples in ca65 assembler and C.
48+
- `images/`: logos, pictures, screenshots, etc.
49+
50+
51+
Build instructions
52+
------------------
53+
54+
Install GCC AVR compiler and toolchain, and run `make` in the top level
55+
directory.
56+
57+
If `avrdude` is installed and you want to deploy to an Arduino Uno board
58+
you can try `make upload`, although some tweaking may be requited.
59+
60+
The examples and the CC65 runtime require the
61+
[CC65 compiler](https://github.com/cc65/cc65). If the binaries are in
62+
your path, just use `make`.
63+
64+
The user programs can be encoded into audio using the `encode` tool in the
65+
storage module (requires POSIX `getopt` and `libsndfile`).
66+
67+
68+
Notes
69+
-----
70+
71+
Video:
72+
73+
- timing is set for PAL.
74+
- output is de-interlaced.
75+
- it may require set TV's AFC (Automatic Frequency Control) to "mode2"
76+
(usually for VCRs or Camcorders).
77+
78+
Input:
79+
80+
- supported UK PS/2 keyboard layout only, but is easy to adapt to other layouts.
81+
82+
Storage:
83+
84+
- audio in requires quite high volume, start with a 90% and adjust.
85+
86+
87+
Author and licensing
88+
--------------------
89+
90+
Juan J. Martinez <[email protected]>
91+
92+
This software is free software (see LICENSE file for details), unless
93+
explicitly stated otherwise.
94+

avr.mk

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
#PRG = main
2+
#OBJ = main.o
3+
4+
#MCU_TARGET = at90s2313
5+
#MCU_TARGET = at90s2333
6+
#MCU_TARGET = at90s4414
7+
#MCU_TARGET = at90s4433
8+
#MCU_TARGET = at90s4434
9+
#MCU_TARGET = at90s8515
10+
#MCU_TARGET = at90s8535
11+
#MCU_TARGET = atmega128
12+
#MCU_TARGET = atmega1280
13+
#MCU_TARGET = atmega1281
14+
#MCU_TARGET = atmega1284p
15+
#MCU_TARGET = atmega16
16+
#MCU_TARGET = atmega163
17+
#MCU_TARGET = atmega164p
18+
#MCU_TARGET = atmega165
19+
#MCU_TARGET = atmega165p
20+
#MCU_TARGET = atmega168
21+
#MCU_TARGET = atmega169
22+
#MCU_TARGET = atmega169p
23+
#MCU_TARGET = atmega2560
24+
#MCU_TARGET = atmega2561
25+
#MCU_TARGET = atmega32
26+
#MCU_TARGET = atmega324p
27+
#MCU_TARGET = atmega325
28+
#MCU_TARGET = atmega3250
29+
#MCU_TARGET = atmega329
30+
#MCU_TARGET = atmega3290
31+
#MCU_TARGET = atmega48
32+
#MCU_TARGET = atmega64
33+
#MCU_TARGET = atmega640
34+
#MCU_TARGET = atmega644
35+
#MCU_TARGET = atmega644p
36+
#MCU_TARGET = atmega645
37+
#MCU_TARGET = atmega6450
38+
#MCU_TARGET = atmega649
39+
#MCU_TARGET = atmega6490
40+
#MCU_TARGET = atmega8
41+
#MCU_TARGET = atmega8515
42+
#MCU_TARGET = atmega8535
43+
#MCU_TARGET = atmega88
44+
#MCU_TARGET = attiny2313
45+
#MCU_TARGET = attiny24
46+
#MCU_TARGET = attiny25
47+
#MCU_TARGET = attiny26
48+
#MCU_TARGET = attiny261
49+
#MCU_TARGET = attiny44
50+
#MCU_TARGET = attiny45
51+
#MCU_TARGET = attiny461
52+
#MCU_TARGET = attiny84
53+
#MCU_TARGET = attiny85
54+
#MCU_TARGET = attiny861
55+
56+
#OPTIMIZE = -O2
57+
58+
#DEFS =
59+
#LIBS =
60+
61+
#PORT = /dev/ttyUSB0
62+
#PROGRAMMER = "<undefined>"
63+
64+
# You should not have to change anything below here.
65+
66+
CC = avr-gcc
67+
68+
# Override is only needed by avr-lib build system.
69+
70+
override CFLAGS = -std=gnu99 -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
71+
override LDFLAGS = -Wl,-Map,$(PRG).map
72+
73+
OBJCOPY = avr-objcopy
74+
OBJDUMP = avr-objdump
75+
76+
all: $(PRG).elf lst text eeprom
77+
78+
$(PRG).elf: $(OBJ)
79+
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
80+
avr-size -C --mcu=$(MCU_TARGET) $(PRG).elf
81+
82+
upload: all
83+
avrdude -v -p$(MCU_TARGET) -c$(PROGRAMMER) -P$(PORT) -b115200 -D -Uflash:w:$(PRG).hex:i
84+
85+
clean:
86+
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak
87+
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
88+
89+
lst: $(PRG).lst
90+
91+
%.lst: %.elf
92+
$(OBJDUMP) -h -S $< > $@
93+
94+
# Rules for building the .text rom images
95+
96+
text: hex bin srec
97+
98+
hex: $(PRG).hex
99+
bin: $(PRG).bin
100+
srec: $(PRG).srec
101+
102+
%.hex: %.elf
103+
$(OBJCOPY) -j .text -j .data -O ihex $< $@
104+
105+
%.srec: %.elf
106+
$(OBJCOPY) -j .text -j .data -O srec $< $@
107+
108+
%.bin: %.elf
109+
$(OBJCOPY) -j .text -j .data -O binary $< $@
110+
111+
# Rules for building the .eeprom rom images
112+
113+
eeprom: ehex ebin esrec
114+
115+
ehex: $(PRG)_eeprom.hex
116+
ebin: $(PRG)_eeprom.bin
117+
esrec: $(PRG)_eeprom.srec
118+
119+
%_eeprom.hex: %.elf
120+
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \
121+
|| { echo empty $@ not generated; exit 0; }
122+
123+
%_eeprom.srec: %.elf
124+
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \
125+
|| { echo empty $@ not generated; exit 0; }
126+
127+
%_eeprom.bin: %.elf
128+
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \
129+
|| { echo empty $@ not generated; exit 0; }
130+
131+
# Every thing below here is used by avr-libc's build system and can be ignored
132+
# by the casual user.
133+
134+
FIG2DEV = fig2dev
135+
EXTRA_CLEAN_FILES = *.hex *.bin *.srec
136+
137+
dox: eps png pdf
138+
139+
eps: $(PRG).eps
140+
png: $(PRG).png
141+
pdf: $(PRG).pdf
142+
143+
%.eps: %.fig
144+
$(FIG2DEV) -L eps $< $@
145+
146+
%.pdf: %.fig
147+
$(FIG2DEV) -L pdf $< $@
148+
149+
%.png: %.fig
150+
$(FIG2DEV) -L png $< $@
151+

cc65/Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
all:
2+
make -C lib
3+
4+
clean:
5+
make -C lib clean

cc65/README.markdown

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Library and helpers to write programs in C using CC65.
2+

cc65/examples/Makefile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BINS=hello.bin hello_name.bin loads.bin \
2+
hello.c.bin map.c.bin ball.c.bin vidmem.c.bin \
3+
hello_printf.c.bin \
4+
adventure.c.bin yum.c.bin \
5+
mandelbrot.c.bin
6+
7+
all: $(BINS)
8+
9+
wav: $(BINS:.bin=.wav)
10+
11+
%.wav: %.bin ../../storage/tools/encode
12+
../../storage/tools/encode $< -o $@
13+
14+
../storage/tools/encode:
15+
make -C ../../storage/tools
16+
17+
%.c.s: %.c
18+
cc65 -t none -Or -O2 -I ../include $< -o $@
19+
20+
%.o: %.s
21+
ca65 $< -o $@
22+
23+
%.bin: %.o
24+
ld65 -C ../../d64.cfg -L ../lib $< -o $@ --lib d64.lib
25+
26+
clean:
27+
rm -f *.o *.bin *.c.s *.wav
28+

cc65/examples/README.markdown

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
This directory contains some simple examples of 6502 programs
2+
to be run in DAN64.
3+
4+
CC65 compiler is required to be in the path.
5+
6+
Targets:
7+
8+
- build all binaries: `make`
9+
- encode wave files: `make wav`
10+
11+
Binaries generated form assembler end in `.bin`.
12+
Binaries generated from C end in `.c.bin`.
13+

0 commit comments

Comments
 (0)