-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e9a84bf
Showing
107 changed files
with
32,372 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
*.swp | ||
*.o | ||
*.a | ||
*~ | ||
*.bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (C) 2015 by Juan J. Martinez <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
all: | ||
make -C video | ||
make -C input | ||
make -C memory | ||
make -C vm | ||
make -C storage | ||
make -C dasm | ||
make -C init | ||
make -C docs | ||
|
||
cc65: | ||
make -C cc65 | ||
|
||
upload: all | ||
make -C init upload | ||
|
||
clean: | ||
make -s -C video clean | ||
make -s -C input clean | ||
make -s -C memory clean | ||
make -s -C vm clean | ||
make -s -C storage clean | ||
make -s -C storage/tools clean | ||
make -s -C dasm clean | ||
make -s -C dasm/tools clean | ||
make -s -C init clean | ||
make -s -C docs clean | ||
make -s -C cc65 clean | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
DAN64, an AVR based 8-bit microcomputer | ||
======================================= | ||
|
||
This is my personal attempt to build a 8-bit microcomputer based on | ||
the popular ATmega328 microcontroller (MCU) as an excuse to learn some | ||
electronics. Check `docs/` directory for further information. | ||
|
||
The microcomputer can be assembled and run in a breadboard with an | ||
Arduino Uno board. | ||
|
||
General features: | ||
|
||
- Composite video black and white output, 256 x 192 resolution, 32 x 24 | ||
characters (8 x 8 pixels font, code page 437 character set). | ||
- PS/2 keyboard support. | ||
- 6502 virtual machine with system call interface to native code | ||
services. | ||
- Linear 64KB memory access from the virtual machine (256 bytes page zero, | ||
256 bytes hardware stack, 6144 bytes of video RAM and 58880 bytes for | ||
user programs). | ||
- External storage support via audio in/out. | ||
- Integrated 6502 assembler and disassembler. | ||
- Basic shell supporting peek, poke, load, run, etc. | ||
|
||
Project page: http://www.usebox.net/jjm/dan64/ | ||
|
||
General directory structure | ||
--------------------------- | ||
|
||
- `docs/`: documentation of the project. | ||
- `schematics/`: KiCad schematics and PCB design. | ||
- source code: | ||
- `include/`: general include files. | ||
- `init/`: main entry point for the firmware, including the implementation | ||
of the syscalls. | ||
- `video/`: composite video generation. | ||
- `input/`: PS/2 keyboard support. | ||
- `memory/`: memory functions. | ||
- `vm/`: 6502 virtual machine. | ||
- `test/`: virtual machine test suite. | ||
- `storage/`: storage using audio in/out. | ||
- `tools/`: wav audio file encoder. | ||
- `dasm/`: DAN64 assembler/disassembler. | ||
- `tools/`: standalone version. | ||
- `tools/`: some misc auxiliary tools (eg, font bitmap generation). | ||
- `cc65/`: CC65 runtime for cross-compiling C programs. | ||
- `examples/`: several user program examples in ca65 assembler and C. | ||
- `images/`: logos, pictures, screenshots, etc. | ||
|
||
|
||
Build instructions | ||
------------------ | ||
|
||
Install GCC AVR compiler and toolchain, and run `make` in the top level | ||
directory. | ||
|
||
If `avrdude` is installed and you want to deploy to an Arduino Uno board | ||
you can try `make upload`, although some tweaking may be requited. | ||
|
||
The examples and the CC65 runtime require the | ||
[CC65 compiler](https://github.com/cc65/cc65). If the binaries are in | ||
your path, just use `make`. | ||
|
||
The user programs can be encoded into audio using the `encode` tool in the | ||
storage module (requires POSIX `getopt` and `libsndfile`). | ||
|
||
|
||
Notes | ||
----- | ||
|
||
Video: | ||
|
||
- timing is set for PAL. | ||
- output is de-interlaced. | ||
- it may require set TV's AFC (Automatic Frequency Control) to "mode2" | ||
(usually for VCRs or Camcorders). | ||
|
||
Input: | ||
|
||
- supported UK PS/2 keyboard layout only, but is easy to adapt to other layouts. | ||
|
||
Storage: | ||
|
||
- audio in requires quite high volume, start with a 90% and adjust. | ||
|
||
|
||
Author and licensing | ||
-------------------- | ||
|
||
Juan J. Martinez <[email protected]> | ||
|
||
This software is free software (see LICENSE file for details), unless | ||
explicitly stated otherwise. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#PRG = main | ||
#OBJ = main.o | ||
|
||
#MCU_TARGET = at90s2313 | ||
#MCU_TARGET = at90s2333 | ||
#MCU_TARGET = at90s4414 | ||
#MCU_TARGET = at90s4433 | ||
#MCU_TARGET = at90s4434 | ||
#MCU_TARGET = at90s8515 | ||
#MCU_TARGET = at90s8535 | ||
#MCU_TARGET = atmega128 | ||
#MCU_TARGET = atmega1280 | ||
#MCU_TARGET = atmega1281 | ||
#MCU_TARGET = atmega1284p | ||
#MCU_TARGET = atmega16 | ||
#MCU_TARGET = atmega163 | ||
#MCU_TARGET = atmega164p | ||
#MCU_TARGET = atmega165 | ||
#MCU_TARGET = atmega165p | ||
#MCU_TARGET = atmega168 | ||
#MCU_TARGET = atmega169 | ||
#MCU_TARGET = atmega169p | ||
#MCU_TARGET = atmega2560 | ||
#MCU_TARGET = atmega2561 | ||
#MCU_TARGET = atmega32 | ||
#MCU_TARGET = atmega324p | ||
#MCU_TARGET = atmega325 | ||
#MCU_TARGET = atmega3250 | ||
#MCU_TARGET = atmega329 | ||
#MCU_TARGET = atmega3290 | ||
#MCU_TARGET = atmega48 | ||
#MCU_TARGET = atmega64 | ||
#MCU_TARGET = atmega640 | ||
#MCU_TARGET = atmega644 | ||
#MCU_TARGET = atmega644p | ||
#MCU_TARGET = atmega645 | ||
#MCU_TARGET = atmega6450 | ||
#MCU_TARGET = atmega649 | ||
#MCU_TARGET = atmega6490 | ||
#MCU_TARGET = atmega8 | ||
#MCU_TARGET = atmega8515 | ||
#MCU_TARGET = atmega8535 | ||
#MCU_TARGET = atmega88 | ||
#MCU_TARGET = attiny2313 | ||
#MCU_TARGET = attiny24 | ||
#MCU_TARGET = attiny25 | ||
#MCU_TARGET = attiny26 | ||
#MCU_TARGET = attiny261 | ||
#MCU_TARGET = attiny44 | ||
#MCU_TARGET = attiny45 | ||
#MCU_TARGET = attiny461 | ||
#MCU_TARGET = attiny84 | ||
#MCU_TARGET = attiny85 | ||
#MCU_TARGET = attiny861 | ||
|
||
#OPTIMIZE = -O2 | ||
|
||
#DEFS = | ||
#LIBS = | ||
|
||
#PORT = /dev/ttyUSB0 | ||
#PROGRAMMER = "<undefined>" | ||
|
||
# You should not have to change anything below here. | ||
|
||
CC = avr-gcc | ||
|
||
# Override is only needed by avr-lib build system. | ||
|
||
override CFLAGS = -std=gnu99 -g -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS) | ||
override LDFLAGS = -Wl,-Map,$(PRG).map | ||
|
||
OBJCOPY = avr-objcopy | ||
OBJDUMP = avr-objdump | ||
|
||
all: $(PRG).elf lst text eeprom | ||
|
||
$(PRG).elf: $(OBJ) | ||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS) | ||
avr-size -C --mcu=$(MCU_TARGET) $(PRG).elf | ||
|
||
upload: all | ||
avrdude -v -p$(MCU_TARGET) -c$(PROGRAMMER) -P$(PORT) -b115200 -D -Uflash:w:$(PRG).hex:i | ||
|
||
clean: | ||
rm -rf *.o $(PRG).elf *.eps *.png *.pdf *.bak | ||
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES) | ||
|
||
lst: $(PRG).lst | ||
|
||
%.lst: %.elf | ||
$(OBJDUMP) -h -S $< > $@ | ||
|
||
# Rules for building the .text rom images | ||
|
||
text: hex bin srec | ||
|
||
hex: $(PRG).hex | ||
bin: $(PRG).bin | ||
srec: $(PRG).srec | ||
|
||
%.hex: %.elf | ||
$(OBJCOPY) -j .text -j .data -O ihex $< $@ | ||
|
||
%.srec: %.elf | ||
$(OBJCOPY) -j .text -j .data -O srec $< $@ | ||
|
||
%.bin: %.elf | ||
$(OBJCOPY) -j .text -j .data -O binary $< $@ | ||
|
||
# Rules for building the .eeprom rom images | ||
|
||
eeprom: ehex ebin esrec | ||
|
||
ehex: $(PRG)_eeprom.hex | ||
ebin: $(PRG)_eeprom.bin | ||
esrec: $(PRG)_eeprom.srec | ||
|
||
%_eeprom.hex: %.elf | ||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ \ | ||
|| { echo empty $@ not generated; exit 0; } | ||
|
||
%_eeprom.srec: %.elf | ||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O srec $< $@ \ | ||
|| { echo empty $@ not generated; exit 0; } | ||
|
||
%_eeprom.bin: %.elf | ||
$(OBJCOPY) -j .eeprom --change-section-lma .eeprom=0 -O binary $< $@ \ | ||
|| { echo empty $@ not generated; exit 0; } | ||
|
||
# Every thing below here is used by avr-libc's build system and can be ignored | ||
# by the casual user. | ||
|
||
FIG2DEV = fig2dev | ||
EXTRA_CLEAN_FILES = *.hex *.bin *.srec | ||
|
||
dox: eps png pdf | ||
|
||
eps: $(PRG).eps | ||
png: $(PRG).png | ||
pdf: $(PRG).pdf | ||
|
||
%.eps: %.fig | ||
$(FIG2DEV) -L eps $< $@ | ||
|
||
%.pdf: %.fig | ||
$(FIG2DEV) -L pdf $< $@ | ||
|
||
%.png: %.fig | ||
$(FIG2DEV) -L png $< $@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
all: | ||
make -C lib | ||
|
||
clean: | ||
make -C lib clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Library and helpers to write programs in C using CC65. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BINS=hello.bin hello_name.bin loads.bin \ | ||
hello.c.bin map.c.bin ball.c.bin vidmem.c.bin \ | ||
hello_printf.c.bin \ | ||
adventure.c.bin yum.c.bin \ | ||
mandelbrot.c.bin | ||
|
||
all: $(BINS) | ||
|
||
wav: $(BINS:.bin=.wav) | ||
|
||
%.wav: %.bin ../../storage/tools/encode | ||
../../storage/tools/encode $< -o $@ | ||
|
||
../storage/tools/encode: | ||
make -C ../../storage/tools | ||
|
||
%.c.s: %.c | ||
cc65 -t none -Or -O2 -I ../include $< -o $@ | ||
|
||
%.o: %.s | ||
ca65 $< -o $@ | ||
|
||
%.bin: %.o | ||
ld65 -C ../../d64.cfg -L ../lib $< -o $@ --lib d64.lib | ||
|
||
clean: | ||
rm -f *.o *.bin *.c.s *.wav | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
This directory contains some simple examples of 6502 programs | ||
to be run in DAN64. | ||
|
||
CC65 compiler is required to be in the path. | ||
|
||
Targets: | ||
|
||
- build all binaries: `make` | ||
- encode wave files: `make wav` | ||
|
||
Binaries generated form assembler end in `.bin`. | ||
Binaries generated from C end in `.c.bin`. | ||
|
Oops, something went wrong.