├── fampiga ├── .gitignore ├── firmware │ ├── osdload.asm │ ├── Makefile │ ├── unhexer.py │ └── hexer.py ├── chameleon │ ├── .gitignore │ ├── fampiga.qpf │ ├── syscontrol.bsf │ ├── fampiga.sdc │ ├── bank_mapper.bsf │ ├── chameleon_docking_station.bsf │ ├── sram_bridge.bsf │ ├── TG68KdotC_Kernel.bsf │ └── chameleon_cdtv_remote.bsf ├── board │ ├── startram.qip │ ├── Cache_DataRAM.qip │ ├── palclk.qip │ ├── JBboot.qip │ ├── CacheBlockRAM.qip │ ├── palclk_v2.qip │ ├── palclk.ppf │ ├── palclk_v2.ppf │ ├── JBboot.inc │ ├── JBboot.cmp │ ├── palclk_v2.cmp │ ├── CacheBlockRAM.cmp │ ├── chameleon_phi_clock_e.vhd │ ├── chameleon_reconfigure.vhd │ ├── chameleon2_io_shiftreg.vhd │ ├── chameleon2_e.vhd │ ├── chameleon2_io_ps2iec.vhd │ ├── palclk.bsf │ ├── startram.bsf │ ├── JBboot.tdf │ └── chameleon_phi_clock_a.vhd ├── Makefile ├── chameleonv2 │ ├── fampiga_tc64v2.qpf │ └── fampiga_v2.sdc └── minimig │ └── Clock.v ├── .gitignore ├── amiga ├── dice_mini │ ├── bin │ │ ├── das │ │ ├── dc1 │ │ ├── dcc │ │ ├── dcpp │ │ ├── dlink │ │ ├── dmake │ │ └── romable │ ├── dlib │ │ ├── x.o │ │ └── roms.lib │ ├── README │ └── include │ │ ├── stddef.h │ │ ├── string.h │ │ └── stdio.h ├── s │ ├── Shell-startup │ └── Startup-sequence ├── MAKE.txt └── DMakefile ├── src ├── include │ ├── newlib.h │ ├── sys │ │ ├── string.h │ │ ├── lock.h │ │ ├── stdio.h │ │ ├── _types.h │ │ └── cdefs.h │ ├── machine │ │ ├── _types.h │ │ ├── types.h │ │ └── _default_types.h │ ├── _ansi.h │ └── string.h ├── klibc │ ├── README │ ├── strcat.c │ ├── strlen.c │ ├── strchr.c │ ├── strcpy.c │ ├── memcmp.c │ ├── sprintf.c │ ├── strncat.c │ ├── strncpy.c │ ├── strncmp.c │ ├── memcpy.c │ └── memset.c ├── swap.h ├── startup.s ├── errors.h ├── osdcpu.ld ├── fpga.h ├── swap.c ├── printf.c ├── firmware.h ├── start.asm ├── rafile.h ├── fdd.h ├── config.h ├── Makefile ├── rafile.c ├── menu.h ├── hdd.h ├── hardware.h ├── hdd_internal.h ├── memcheck.c ├── osd.h ├── main.c ├── mmc.h ├── fat.h ├── logo.h └── hardware.c ├── .gitmodules ├── README ├── doc ├── serial.txt └── toolchain.txt ├── INSTALL └── unix └── Makefile /fampiga/.gitignore: -------------------------------------------------------------------------------- 1 | *.bak 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | OSD_CA01.sys 2 | menu 3 | adf 4 | -------------------------------------------------------------------------------- /amiga/dice_mini/bin/das: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/bin/das -------------------------------------------------------------------------------- /amiga/dice_mini/bin/dc1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/bin/dc1 -------------------------------------------------------------------------------- /amiga/dice_mini/bin/dcc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/bin/dcc -------------------------------------------------------------------------------- /amiga/dice_mini/bin/dcpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/bin/dcpp -------------------------------------------------------------------------------- /amiga/dice_mini/dlib/x.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/dlib/x.o -------------------------------------------------------------------------------- /amiga/dice_mini/bin/dlink: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/bin/dlink -------------------------------------------------------------------------------- /amiga/dice_mini/bin/dmake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/bin/dmake -------------------------------------------------------------------------------- /amiga/dice_mini/bin/romable: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/bin/romable -------------------------------------------------------------------------------- /amiga/dice_mini/dlib/roms.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/amiga/dice_mini/dlib/roms.lib -------------------------------------------------------------------------------- /fampiga/firmware/osdload.asm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/robinsonb5/minimig_tc64/HEAD/fampiga/firmware/osdload.asm -------------------------------------------------------------------------------- /src/include/newlib.h: -------------------------------------------------------------------------------- 1 | /* dummy file for external tools to use. Real file is created by 2 | newlib configuration. */ 3 | -------------------------------------------------------------------------------- /src/klibc/README: -------------------------------------------------------------------------------- 1 | This code is taken from klibc. 2 | 3 | See http://git.kernel.org/pub/scm/libs/klibc/klibc.git for details. 4 | 5 | -------------------------------------------------------------------------------- /src/include/sys/string.h: -------------------------------------------------------------------------------- 1 | /* This is a dummy used as a placeholder for 2 | systems that need to have a special header file. */ 3 | -------------------------------------------------------------------------------- /fampiga/chameleon/.gitignore: -------------------------------------------------------------------------------- 1 | PLLJ_PLLSPE_INFO.txt 2 | db/ 3 | *.rpt 4 | *.done 5 | *.summary 6 | *.jdi 7 | *.smsg 8 | *.pin 9 | *.rbf 10 | *.sof 11 | incremental_db/ 12 | simulation/ 13 | 14 | -------------------------------------------------------------------------------- /amiga/s/Shell-startup: -------------------------------------------------------------------------------- 1 | ; $VER: shell-startup 38.13 (13.2.92) 2 | echo Start DCC 3 | ARM: 4 | execute make.txt 5 | Prompt "%N.%S> " 6 | Alias Clear "Echo *"*E[0;0H*E[J*" " 7 | Alias XCopy "Copy CLONE " 8 | -------------------------------------------------------------------------------- /src/klibc/strcat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strcat.c 3 | */ 4 | 5 | #include 6 | 7 | char *strcat(char *dst, const char *src) 8 | { 9 | strcpy(strchr(dst, '\0'), src); 10 | return dst; 11 | } 12 | -------------------------------------------------------------------------------- /src/swap.h: -------------------------------------------------------------------------------- 1 | #ifndef SWAP_H 2 | #define SWAP_H 3 | 4 | unsigned long SwapBBBB(unsigned long i); 5 | unsigned int SwapBB(unsigned int i); 6 | unsigned long SwapWW(unsigned long i); 7 | 8 | #endif 9 | 10 | -------------------------------------------------------------------------------- /src/klibc/strlen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strlen() 3 | */ 4 | 5 | #include 6 | 7 | size_t strlen(const char *s) 8 | { 9 | const char *ss = s; 10 | while (*ss) 11 | ss++; 12 | return ss - s; 13 | } 14 | -------------------------------------------------------------------------------- /src/include/machine/_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: _types.h,v 1.3 2007/09/07 21:16:25 jjohnstn Exp $ 3 | */ 4 | 5 | #ifndef _MACHINE__TYPES_H 6 | #define _MACHINE__TYPES_H 7 | #include 8 | #endif 9 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Minimig_Firmware"] 2 | path = Minimig_Firmware 3 | url = https://github.com/robinsonb5/Minimig_Firmware.git 4 | [submodule "TG68K.C"] 5 | path = TG68K.C 6 | url = https://github.com/TobiFlex/TG68K.C.git 7 | -------------------------------------------------------------------------------- /amiga/MAKE.txt: -------------------------------------------------------------------------------- 1 | echo "" 2 | dcc start.asm main.c FDD.c FAT.c osd.c hardware.c FPGA.c MMC.c HDD.c menu.c -o menue -rom -l rom.lib -D ROM -// 3 | echo "dcc ... ok" 4 | romable menue -o OSD_CA01.sys -DC -C 0x2000 5 | echo "romable ... ok" 6 | -------------------------------------------------------------------------------- /src/startup.s: -------------------------------------------------------------------------------- 1 | move.l #stack_top,%a7 2 | 3 | /* clear bss */ 4 | lea.l __s_bss,%a0 5 | move.l #__e_bss,%d0 6 | 1: cmp.l %d0,%a0 7 | beq.s 2f 8 | clr.b (%a0)+ 9 | bra.s 1b 10 | 2: 11 | jmp c_entry 12 | -------------------------------------------------------------------------------- /src/klibc/strchr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strchr.c 3 | */ 4 | 5 | #include 6 | 7 | char *strchr(const char *s, int c) 8 | { 9 | while (*s != (char)c) { 10 | if (!*s) 11 | return NULL; 12 | s++; 13 | } 14 | 15 | return (char *)s; 16 | } 17 | -------------------------------------------------------------------------------- /src/errors.h: -------------------------------------------------------------------------------- 1 | #define ERROR_NONE 0 2 | #define ERROR_FILE_NOT_FOUND 1 3 | #define ERROR_INVALID_DATA 2 4 | #define ERROR_UPDATE_FAILED 3 5 | 6 | extern unsigned char Error; 7 | 8 | void FatalError(unsigned long error); 9 | void ErrorMessage(char *message, unsigned char code); 10 | -------------------------------------------------------------------------------- /amiga/dice_mini/README: -------------------------------------------------------------------------------- 1 | The "dice_mini" directory contains a stripped down version of 2 | the DICE 3.16 release for Amiga available on Aminet [1]. 3 | 4 | Have a look at this archive for further information and for 5 | copyright and license information. 6 | 7 | [1] http://aminet.net/dev/c/dice-3.16.lha -------------------------------------------------------------------------------- /fampiga/board/startram.qip: -------------------------------------------------------------------------------- 1 | set_global_assignment -name IP_TOOL_NAME "RAM: 1-PORT" 2 | set_global_assignment -name IP_TOOL_VERSION "9.0" 3 | set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "startram.vhd"] 4 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "startram.bsf"] 5 | -------------------------------------------------------------------------------- /src/klibc/strcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strcpy.c 3 | * 4 | * strcpy() 5 | */ 6 | 7 | #include 8 | 9 | char *strcpy(char *dst, const char *src) 10 | { 11 | char *q = dst; 12 | const char *p = src; 13 | char ch; 14 | 15 | do { 16 | *q++ = ch = *p++; 17 | } while (ch); 18 | 19 | return dst; 20 | } 21 | -------------------------------------------------------------------------------- /fampiga/board/Cache_DataRAM.qip: -------------------------------------------------------------------------------- 1 | set_global_assignment -name IP_TOOL_NAME "RAM: 2-PORT" 2 | set_global_assignment -name IP_TOOL_VERSION "12.0" 3 | set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "Cache_DataRAM.v"] 4 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "Cache_DataRAM_bb.v"] 5 | -------------------------------------------------------------------------------- /src/klibc/memcmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memcmp.c 3 | */ 4 | 5 | #include 6 | 7 | int memcmp(const void *s1, const void *s2, size_t n) 8 | { 9 | const unsigned char *c1 = s1, *c2 = s2; 10 | int d = 0; 11 | 12 | while (n--) { 13 | d = (int)*c1++ - (int)*c2++; 14 | if (d) 15 | break; 16 | } 17 | 18 | return d; 19 | } 20 | -------------------------------------------------------------------------------- /src/klibc/sprintf.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sprintf.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | int sprintf(char *buffer, const char *format, ...) 9 | { 10 | va_list ap; 11 | int rv; 12 | 13 | va_start(ap, format); 14 | rv = vsnprintf(buffer, ~(size_t) 0, format, ap); 15 | va_end(ap); 16 | 17 | return rv; 18 | } 19 | -------------------------------------------------------------------------------- /src/klibc/strncat.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strncat.c 3 | */ 4 | 5 | #include 6 | 7 | char *strncat(char *dst, const char *src, size_t n) 8 | { 9 | char *q = strchr(dst, '\0'); 10 | const char *p = src; 11 | char ch; 12 | 13 | while (n--) { 14 | *q++ = ch = *p++; 15 | if (!ch) 16 | return dst; 17 | } 18 | *q = '\0'; 19 | 20 | return dst; 21 | } 22 | -------------------------------------------------------------------------------- /fampiga/board/palclk.qip: -------------------------------------------------------------------------------- 1 | set_global_assignment -name IP_TOOL_NAME "ALTPLL" 2 | set_global_assignment -name IP_TOOL_VERSION "12.0" 3 | set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "palclk.vhd"] 4 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "palclk.bsf"] 5 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "palclk.ppf"] 6 | -------------------------------------------------------------------------------- /fampiga/board/JBboot.qip: -------------------------------------------------------------------------------- 1 | set_global_assignment -name IP_TOOL_NAME "ROM: 1-PORT" 2 | set_global_assignment -name IP_TOOL_VERSION "9.0" 3 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "JBboot.tdf"] 4 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "JBboot.inc"] 5 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "JBboot.cmp"] 6 | -------------------------------------------------------------------------------- /fampiga/board/CacheBlockRAM.qip: -------------------------------------------------------------------------------- 1 | set_global_assignment -name IP_TOOL_NAME "RAM: 2-PORT" 2 | set_global_assignment -name IP_TOOL_VERSION "12.0" 3 | set_global_assignment -name VERILOG_FILE [file join $::quartus(qip_path) "CacheBlockRAM.v"] 4 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "CacheBlockRAM_bb.v"] 5 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "CacheBlockRAM.cmp"] 6 | -------------------------------------------------------------------------------- /src/klibc/strncpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strncpy.c 3 | */ 4 | 5 | #include 6 | 7 | char *strncpy(char *dst, const char *src, size_t n) 8 | { 9 | char *q = dst; 10 | const char *p = src; 11 | char ch; 12 | 13 | while (n) { 14 | n--; 15 | *q++ = ch = *p++; 16 | if (!ch) 17 | break; 18 | } 19 | 20 | /* The specs say strncpy() fills the entire buffer with NUL. Sigh. */ 21 | memset(q, 0, n); 22 | 23 | return dst; 24 | } 25 | -------------------------------------------------------------------------------- /src/klibc/strncmp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * strncmp.c 3 | */ 4 | 5 | #include 6 | 7 | int strncmp(const char *s1, const char *s2, size_t n) 8 | { 9 | const unsigned char *c1 = (const unsigned char *)s1; 10 | const unsigned char *c2 = (const unsigned char *)s2; 11 | unsigned char ch; 12 | int d = 0; 13 | 14 | while (n--) { 15 | d = (int)(ch = *c1++) - (int)*c2++; 16 | if (d || !ch) 17 | break; 18 | } 19 | 20 | return d; 21 | } 22 | -------------------------------------------------------------------------------- /fampiga/board/palclk_v2.qip: -------------------------------------------------------------------------------- 1 | set_global_assignment -name IP_TOOL_NAME "ALTPLL" 2 | set_global_assignment -name IP_TOOL_VERSION "18.1" 3 | set_global_assignment -name IP_GENERATED_DEVICE_FAMILY "{Cyclone 10 LP}" 4 | set_global_assignment -name VHDL_FILE [file join $::quartus(qip_path) "palclk_v2.vhd"] 5 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "palclk_v2.cmp"] 6 | set_global_assignment -name MISC_FILE [file join $::quartus(qip_path) "palclk_v2.ppf"] 7 | -------------------------------------------------------------------------------- /src/osdcpu.ld: -------------------------------------------------------------------------------- 1 | SECTIONS 2 | { 3 | . = 0x2000; 4 | .code : { 5 | BUILD/startup.o (.text) 6 | *(.text) 7 | *(.rodata) 8 | *(.rodata.*) 9 | *(.data) 10 | } 11 | .extra : { 12 | __s_bss = . ; 13 | *(.bss) 14 | __e_bss = . ; 15 | } 16 | .eh_frame : { 17 | *(.eh_frame) 18 | } 19 | heap_low = .; /* for _sbrk */ 20 | . = . + 0x1000; /* 64kB of heap memory */ 21 | heap_top = .; /* for _sbrk */ 22 | 23 | stack_top = 0x1ffe; /* for startup.s */ 24 | } 25 | -------------------------------------------------------------------------------- /amiga/dice_mini/include/stddef.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * $VER: stddef.h 1.0 (17.4.93) 4 | * 5 | * (c)Copyright 1992 Obvious Implementations Corp, All Rights Reserved 6 | */ 7 | 8 | #ifndef STDDEF_H 9 | #define STDDEF_H 10 | 11 | #ifndef NULL 12 | #define NULL ((void *)0L) 13 | #endif 14 | #ifndef offsetof 15 | #define offsetof(sname,fname) ((long)&((sname *)0)->fname) 16 | #endif 17 | typedef int ptrdiff_t; 18 | typedef unsigned int size_t; 19 | typedef char wchar_t; 20 | 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /fampiga/Makefile: -------------------------------------------------------------------------------- 1 | CHACOCMD=chacocmd 2 | SLOT=2 3 | 4 | clean: 5 | for a in rpt summary done jdi smsg pin rbf sof ; do \ 6 | find . -name "*.$$a" -exec rm {} \; ; \ 7 | done 8 | find chameleon -mindepth 1 -type d -d -exec rm -rf {} \; 9 | find chameleon -name "*.txt" -exec rm {} \; 10 | 11 | clean_bak: 12 | find . -type f -name '*.bak' -exec rm {} \; 13 | 14 | run: flash start 15 | 16 | flash: 17 | $(CHACOCMD) --flashrbf $(SLOT) chameleon/fampiga_top.rbf 18 | 19 | start: 20 | $(CHACOCMD) --start $(SLOT) 21 | -------------------------------------------------------------------------------- /src/fpga.h: -------------------------------------------------------------------------------- 1 | #ifndef FPGA_H 2 | #define FPGA_H 3 | 4 | #include "rafile.h" 5 | 6 | void ShiftFpga(unsigned char data); 7 | unsigned char ConfigureFpga(void); 8 | void SendFile(RAFile *file); 9 | void SendFileEncrypted(RAFile *file,unsigned char *key,int keysize); 10 | char BootPrint(const char *text); 11 | char PrepareBootUpload(unsigned char base, unsigned char size); 12 | void BootExit(void); 13 | void ClearMemory(unsigned long base, unsigned long size); 14 | unsigned char GetFPGAStatus(void); 15 | 16 | #endif 17 | 18 | -------------------------------------------------------------------------------- /fampiga/firmware/Makefile: -------------------------------------------------------------------------------- 1 | # *nix Makefile for Minimig bootfirmware assembly 2 | # Written by Christian Vogelgsang 3 | 4 | # ----- the following tools need to be installed ----- 5 | # vasm homepage http://sun.hasenbraten.de/vasm 6 | ASM=vasmm68k_mot 7 | ASM_OPTS= 8 | HEXER=python hexer.py 9 | 10 | .PRECIOUS: %.bin 11 | 12 | # ----- rules ----- 13 | all: hostboot.hex osdload.hex 14 | 15 | clean: 16 | rm -f hostboot.hex osdload.hex hostboot.bin osdload.bin 17 | 18 | %.hex: %.bin 19 | $(HEXER) -l 2048 $< $@ 20 | 21 | %.bin: %.asm 22 | $(ASM) $(ASM_OPTS) -Fbin -o $@ $< 23 | -------------------------------------------------------------------------------- /src/swap.c: -------------------------------------------------------------------------------- 1 | unsigned long SwapBBBB(unsigned long i) 2 | { 3 | asm volatile 4 | ( 5 | "rol.w #8,%0\n\t" 6 | "swap %0\n\t" 7 | "rol.w #8,%0\n\t" 8 | : "=r" (i) /* out */ 9 | : "r" (i) 10 | : /* no clobber */ 11 | ); 12 | return i; 13 | } 14 | 15 | unsigned int SwapBB(unsigned int i) 16 | { 17 | asm volatile 18 | ( 19 | "rol.w #8,%0\n\t" 20 | : "=r" (i) /* out */ 21 | : "r" (i) 22 | : /* no clobber */ 23 | ); 24 | return i; 25 | } 26 | 27 | unsigned long SwapWW(unsigned long i) 28 | { 29 | asm volatile 30 | ( 31 | "swap %0\n\t" 32 | : "=r" (i) /* out */ 33 | : "r" (i) 34 | : /* no clobber */ 35 | ); 36 | return i; 37 | } 38 | -------------------------------------------------------------------------------- /fampiga/board/palclk.ppf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/klibc/memcpy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memcpy.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | void *memcpy(void *dst, const void *src, size_t n) 9 | { 10 | const char *p = src; 11 | char *q = dst; 12 | #if defined(__i386__) 13 | size_t nl = n >> 2; 14 | asm volatile ("cld ; rep ; movsl ; movl %3,%0 ; rep ; movsb":"+c" (nl), 15 | "+S"(p), "+D"(q) 16 | :"r"(n & 3)); 17 | #elif defined(__x86_64__) 18 | size_t nq = n >> 3; 19 | asm volatile ("cld ; rep ; movsq ; movl %3,%%ecx ; rep ; movsb":"+c" 20 | (nq), "+S"(p), "+D"(q) 21 | :"r"((uint32_t) (n & 7))); 22 | #else 23 | while (n--) { 24 | *q++ = *p++; 25 | } 26 | #endif 27 | 28 | return dst; 29 | } 30 | -------------------------------------------------------------------------------- /src/klibc/memset.c: -------------------------------------------------------------------------------- 1 | /* 2 | * memset.c 3 | */ 4 | 5 | #include 6 | #include 7 | 8 | void *memset(void *dst, int c, size_t n) 9 | { 10 | char *q = dst; 11 | 12 | #if defined(__i386__) 13 | size_t nl = n >> 2; 14 | asm volatile ("cld ; rep ; stosl ; movl %3,%0 ; rep ; stosb" 15 | : "+c" (nl), "+D" (q) 16 | : "a" ((unsigned char)c * 0x01010101U), "r" (n & 3)); 17 | #elif defined(__x86_64__) 18 | size_t nq = n >> 3; 19 | asm volatile ("cld ; rep ; stosq ; movl %3,%%ecx ; rep ; stosb" 20 | :"+c" (nq), "+D" (q) 21 | : "a" ((unsigned char)c * 0x0101010101010101U), 22 | "r" ((uint32_t) n & 7)); 23 | #else 24 | while (n--) { 25 | *q++ = c; 26 | } 27 | #endif 28 | 29 | return dst; 30 | } 31 | -------------------------------------------------------------------------------- /fampiga/board/palclk_v2.ppf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/printf.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | char buf[256]; 5 | 6 | #define TX ((volatile char *)0xda8001) 7 | 8 | int printf(const char *fmt,...) 9 | { 10 | int i; 11 | 12 | va_list ap; 13 | va_start(ap, fmt); 14 | int num = vsnprintf(buf, 256, fmt, ap); 15 | va_end(ap); 16 | 17 | for(i=0;i='A')&&(c<='Z')) { 44 | return c + 'a' - 'A'; 45 | } else { 46 | return c; 47 | } 48 | } -------------------------------------------------------------------------------- /src/include/machine/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _MACHTYPES_H_ 2 | #define _MACHTYPES_H_ 3 | 4 | /* 5 | * The following section is RTEMS specific and is needed to more 6 | * closely match the types defined in the BSD machine/types.h. 7 | * This is needed to let the RTEMS/BSD TCP/IP stack compile. 8 | */ 9 | #if defined(__rtems__) 10 | #include 11 | #endif 12 | 13 | #define _CLOCK_T_ unsigned long /* clock() */ 14 | #define _TIME_T_ long /* time() */ 15 | #define _CLOCKID_T_ unsigned long 16 | #define _TIMER_T_ unsigned long 17 | 18 | #ifndef _HAVE_SYSTYPES 19 | typedef long int __off_t; 20 | typedef int __pid_t; 21 | #ifdef __GNUC__ 22 | __extension__ typedef long long int __loff_t; 23 | #else 24 | typedef long int __loff_t; 25 | #endif 26 | #endif 27 | 28 | #endif /* _MACHTYPES_H_ */ 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/firmware.h: -------------------------------------------------------------------------------- 1 | typedef struct 2 | { 3 | unsigned long flags; 4 | unsigned long base; 5 | unsigned long size; 6 | unsigned long crc; 7 | } romTYPE; 8 | 9 | typedef struct 10 | { 11 | unsigned char id[8]; 12 | unsigned char version[8]; 13 | romTYPE rom; 14 | unsigned long padding[119]; 15 | unsigned long crc; 16 | } UPGRADE; 17 | 18 | #define NVCONFIG 0x3FFFC 19 | #define NVCONFIG_SPIMODE 0x00000001 20 | #define SPIMODE_NORMAL 0 21 | #define SPIMODE_FAST 1 22 | 23 | #define true -1 24 | #define false 0 25 | 26 | unsigned long CalculateCRC32(unsigned long crc, unsigned char *pBuffer, unsigned long nSize); 27 | unsigned char CheckFirmware(fileTYPE *file, char *name); 28 | unsigned long WriteFirmware(fileTYPE *file); 29 | void SetSPIMode(unsigned long mode); 30 | unsigned long GetSPIMode(void); 31 | 32 | -------------------------------------------------------------------------------- /src/include/sys/lock.h: -------------------------------------------------------------------------------- 1 | #ifndef __SYS_LOCK_H__ 2 | #define __SYS_LOCK_H__ 3 | 4 | /* dummy lock routines for single-threaded aps */ 5 | 6 | typedef int _LOCK_T; 7 | typedef int _LOCK_RECURSIVE_T; 8 | 9 | #include <_ansi.h> 10 | 11 | #define __LOCK_INIT(class,lock) static int lock = 0; 12 | #define __LOCK_INIT_RECURSIVE(class,lock) static int lock = 0; 13 | #define __lock_init(lock) (_CAST_VOID 0) 14 | #define __lock_init_recursive(lock) (_CAST_VOID 0) 15 | #define __lock_close(lock) (_CAST_VOID 0) 16 | #define __lock_close_recursive(lock) (_CAST_VOID 0) 17 | #define __lock_acquire(lock) (_CAST_VOID 0) 18 | #define __lock_acquire_recursive(lock) (_CAST_VOID 0) 19 | #define __lock_try_acquire(lock) (_CAST_VOID 0) 20 | #define __lock_try_acquire_recursive(lock) (_CAST_VOID 0) 21 | #define __lock_release(lock) (_CAST_VOID 0) 22 | #define __lock_release_recursive(lock) (_CAST_VOID 0) 23 | 24 | #endif /* __SYS_LOCK_H__ */ 25 | -------------------------------------------------------------------------------- /src/include/sys/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef _NEWLIB_STDIO_H 2 | #define _NEWLIB_STDIO_H 3 | 4 | #include 5 | #include 6 | 7 | /* Internal locking macros, used to protect stdio functions. In the 8 | general case, expand to nothing. Use __SSTR flag in FILE _flags to 9 | detect if FILE is private to sprintf/sscanf class of functions; if 10 | set then do nothing as lock is not initialised. */ 11 | #if !defined(_flockfile) 12 | #ifndef __SINGLE_THREAD__ 13 | # define _flockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_acquire_recursive((fp)->_lock)) 14 | #else 15 | # define _flockfile(fp) (_CAST_VOID 0) 16 | #endif 17 | #endif 18 | 19 | #if !defined(_funlockfile) 20 | #ifndef __SINGLE_THREAD__ 21 | # define _funlockfile(fp) (((fp)->_flags & __SSTR) ? 0 : __lock_release_recursive((fp)->_lock)) 22 | #else 23 | # define _funlockfile(fp) (_CAST_VOID 0) 24 | #endif 25 | #endif 26 | 27 | #endif /* _NEWLIB_STDIO_H */ 28 | -------------------------------------------------------------------------------- /fampiga/board/JBboot.inc: -------------------------------------------------------------------------------- 1 | --Copyright (C) 1991-2009 Altera Corporation 2 | --Your use of Altera Corporation's design tools, logic functions 3 | --and other software and tools, and its AMPP partner logic 4 | --functions, and any output files from any of the foregoing 5 | --(including device programming or simulation files), and any 6 | --associated documentation or information are expressly subject 7 | --to the terms and conditions of the Altera Program License 8 | --Subscription Agreement, Altera MegaCore Function License 9 | --Agreement, or other applicable license agreement, including, 10 | --without limitation, that your use is for the sole purpose of 11 | --programming logic devices manufactured by Altera and sold by 12 | --Altera or its authorized distributors. Please refer to the 13 | --applicable agreement for further details. 14 | 15 | 16 | FUNCTION JBboot 17 | ( 18 | address[9..0], 19 | clock 20 | ) 21 | 22 | RETURNS ( 23 | q[15..0] 24 | ); 25 | -------------------------------------------------------------------------------- /amiga/DMakefile: -------------------------------------------------------------------------------- 1 | # amiga DICE dmake file for minimig code 2 | # 3 | # define assign DCC: to point to your DICE 3.15/3.16 install 4 | 5 | DBIN=DCC:bin 6 | DCCOPTS=-// -D ROM -D ACTIONREPLAY_BROKEN 7 | DCCLINK=-rom -l rom.lib 8 | ROM_ADDR=0x2000 9 | 10 | C_ASM=start.asm 11 | C_SRC=main.c fdd.c fat.c osd.c hardware.c fpga.c mmc.c hdd.c menu.c config.c rafile.c 12 | C_HDR=config.h errors.h fat.h fdd.h firmware.h fpga.h hardware.h hdd.h menu.h mmc.h osd.h charrom.h rafile.h 13 | C_ALL= $(C_ASM) $(C_SRC) 14 | ALL_SRC=$(C_ALL:*:"/src/*") 15 | ALL_HDR=$(C_HDR:*:"/src/*") 16 | 17 | REL_BIN=menu 18 | ABS_BIN=OSD_CA01.sys 19 | 20 | all: setup build 21 | 22 | setup: 23 | assign DCC: dice_mini 24 | assign DINCLUDE: DCC:include 25 | assign DLIB: DCC:dlib 26 | 27 | clean: 28 | Delete $(REL_BIN) $(ABS_BIN) 29 | 30 | build: $(ABS_BIN) 31 | 32 | $(REL_BIN): $(ALL_SRC) $(ALL_HDR) 33 | $(DBIN)/dcc $(DCCOPTS) $(ALL_SRC) -o $(REL_BIN) $(DCCLINK) 34 | 35 | $(ABS_BIN): $(REL_BIN) 36 | $(DBIN)/romable $(REL_BIN) -o $(ABS_BIN) -DC -C $(ROM_ADDR) 37 | -------------------------------------------------------------------------------- /fampiga/board/JBboot.cmp: -------------------------------------------------------------------------------- 1 | --Copyright (C) 1991-2009 Altera Corporation 2 | --Your use of Altera Corporation's design tools, logic functions 3 | --and other software and tools, and its AMPP partner logic 4 | --functions, and any output files from any of the foregoing 5 | --(including device programming or simulation files), and any 6 | --associated documentation or information are expressly subject 7 | --to the terms and conditions of the Altera Program License 8 | --Subscription Agreement, Altera MegaCore Function License 9 | --Agreement, or other applicable license agreement, including, 10 | --without limitation, that your use is for the sole purpose of 11 | --programming logic devices manufactured by Altera and sold by 12 | --Altera or its authorized distributors. Please refer to the 13 | --applicable agreement for further details. 14 | 15 | 16 | component JBboot 17 | PORT 18 | ( 19 | address : IN STD_LOGIC_VECTOR (9 DOWNTO 0); 20 | clock : IN STD_LOGIC := '1'; 21 | q : OUT STD_LOGIC_VECTOR (15 DOWNTO 0) 22 | ); 23 | end component; 24 | -------------------------------------------------------------------------------- /fampiga/firmware/unhexer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # unhexer.py 3 | # decode a word-size intel-hex file 4 | # 5 | # usage: unhexer.py 6 | 7 | from optparse import OptionParser 8 | 9 | # parse args 10 | parser = OptionParser("usage: %prog [options] ") 11 | parser.add_option('-s', "--start", dest="start", help="start address of output", action="store", type=int, default=0) 12 | parser.add_option('-l', "--length", dest="length", help="total length of output binary", action="store", type=int, default=0) 13 | (options, args) = parser.parse_args() 14 | if len(args) != 2: 15 | parser.error("incorrect number of arguments") 16 | in_hex = args[0] 17 | out_bin = args[1] 18 | 19 | # read input file 20 | data = "" 21 | f = open(in_hex,"r") 22 | for line in f: 23 | if line[0:3] == ':02': 24 | val = line[9:13] 25 | hi = int(val[0:2],16) 26 | lo = int(val[2:4],16) 27 | data += chr(hi) + chr(lo) 28 | f.close() 29 | print len(data) 30 | 31 | # write output file 32 | f = open(out_bin,"wb") 33 | f.write(data) 34 | f.close() 35 | 36 | -------------------------------------------------------------------------------- /fampiga/board/palclk_v2.cmp: -------------------------------------------------------------------------------- 1 | --Copyright (C) 2018 Intel Corporation. All rights reserved. 2 | --Your use of Intel Corporation's design tools, logic functions 3 | --and other software and tools, and its AMPP partner logic 4 | --functions, and any output files from any of the foregoing 5 | --(including device programming or simulation files), and any 6 | --associated documentation or information are expressly subject 7 | --to the terms and conditions of the Intel Program License 8 | --Subscription Agreement, the Intel Quartus Prime License Agreement, 9 | --the Intel FPGA IP License Agreement, or other applicable license 10 | --agreement, including, without limitation, that your use is for 11 | --the sole purpose of programming logic devices manufactured by 12 | --Intel and sold by Intel or its authorized distributors. Please 13 | --refer to the applicable agreement for further details. 14 | 15 | 16 | component palclk_v2 17 | PORT 18 | ( 19 | areset : IN STD_LOGIC := '0'; 20 | inclk0 : IN STD_LOGIC := '0'; 21 | c0 : OUT STD_LOGIC ; 22 | c1 : OUT STD_LOGIC ; 23 | c2 : OUT STD_LOGIC ; 24 | c3 : OUT STD_LOGIC ; 25 | locked : OUT STD_LOGIC 26 | ); 27 | end component; 28 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | TurboChameleon64 Port of Minimig 2 | -------------------------------- 3 | 4 | This repository hosts the MiniMig[1] menu controller code ported to a Motorola 5 | 68000 SoftCore by Tobias Gubener (TobiFlexx) for the TurboChameleon64[2] FPGA 6 | cartridge by Individual Computers. 7 | 8 | Build 9 | ----- 10 | 11 | You will need the DICE[3] Amiga C compiler either as a native or a cross 12 | compiler to build the menu code. 13 | 14 | See the INSTALL file for more details. 15 | 16 | Run 17 | --- 18 | 19 | You need a Chameleon cartridge to run the MiniMig menu code. Install the 20 | latest Core from [4] and set up a SD card with the provided files and a 21 | Kickstart ROM image. Finally replace the "OSD_CA01.sys" menu code with your 22 | newly build one and run the core. 23 | 24 | Contribute 25 | ---------- 26 | 27 | I'll keep updates to the menu code in this repository. If you have fixes, 28 | extension, or other contributions then drop me an email or a GitHub push 29 | request to include them here. 30 | 31 | 32 | Have Fun, 33 | Christian Vogelgsang / lallafa 34 | chris@vogelgsang.org 35 | 36 | 37 | [1] http://code.google.com/p/minimig/ 38 | [2] http://www.icomp.de/products/chameleon_e.htm 39 | [3] http://www.obviously.com/dice/ 40 | [4] http://beta.icomp.de/ -------------------------------------------------------------------------------- /fampiga/board/CacheBlockRAM.cmp: -------------------------------------------------------------------------------- 1 | --Copyright (C) 1991-2012 Altera Corporation 2 | --Your use of Altera Corporation's design tools, logic functions 3 | --and other software and tools, and its AMPP partner logic 4 | --functions, and any output files from any of the foregoing 5 | --(including device programming or simulation files), and any 6 | --associated documentation or information are expressly subject 7 | --to the terms and conditions of the Altera Program License 8 | --Subscription Agreement, Altera MegaCore Function License 9 | --Agreement, or other applicable license agreement, including, 10 | --without limitation, that your use is for the sole purpose of 11 | --programming logic devices manufactured by Altera and sold by 12 | --Altera or its authorized distributors. Please refer to the 13 | --applicable agreement for further details. 14 | 15 | 16 | component CacheBlockRAM 17 | PORT 18 | ( 19 | address_a : IN STD_LOGIC_VECTOR (8 DOWNTO 0); 20 | address_b : IN STD_LOGIC_VECTOR (8 DOWNTO 0); 21 | clock : IN STD_LOGIC := '1'; 22 | data_a : IN STD_LOGIC_VECTOR (17 DOWNTO 0); 23 | data_b : IN STD_LOGIC_VECTOR (17 DOWNTO 0); 24 | wren_a : IN STD_LOGIC := '0'; 25 | wren_b : IN STD_LOGIC := '0'; 26 | q_a : OUT STD_LOGIC_VECTOR (17 DOWNTO 0); 27 | q_b : OUT STD_LOGIC_VECTOR (17 DOWNTO 0) 28 | ); 29 | end component; 30 | -------------------------------------------------------------------------------- /src/start.asm: -------------------------------------------------------------------------------- 1 | xref _main; 2 | ; xref _s; 3 | xref _sprintf; 4 | ; xdef _SPI 5 | xdef _putch 6 | xdef _printf 7 | xdef _SwapBBBB 8 | xdef _SwapBB 9 | xdef _SwapWW 10 | RS232_base equ $DA8000 11 | SECTION ,CODE 12 | lea stack_top,a7 13 | jmp _main 14 | ;_SPI: 15 | ;; move.b 7(A7),$da8001 16 | ; move.b 7(A7),$da4001 17 | ; move.b $da4001,d0 18 | ;; move.w $da4000,d0 19 | ;; andi.l #$ff,d0 20 | ;;@spi_1: move $da4000,d0 21 | ;; bmi.s @spi_1 22 | ; rts 23 | _putch: ; Basic character output routine 24 | move.b 7(A7),$da8001 25 | rts 26 | 27 | _printf: ; Basic character output routine 28 | move.l (a7)+,rettmp 29 | pea rs_buf 30 | bsr _sprintf 31 | move.l (a7),a0 32 | move.l rettmp,(a7) 33 | _printfa 34 | move.b (a0)+,d0 35 | beq _printfe 36 | move.b d0,$da8001 37 | bra _printfa 38 | _printfe 39 | rts 40 | rettmp ds.l 1 41 | rs_buf ds.b 256 42 | 43 | _SwapBBBB 44 | move.l 4(a7),d0 45 | rol.w #8,d0 46 | swap d0 47 | rol.w #8,d0 48 | rts 49 | 50 | _SwapBB 51 | move.l 4(a7),d0 52 | rol.w #8,d0 53 | rts 54 | 55 | _SwapWW 56 | move.l 4(a7),d0 57 | swap d0 58 | rts 59 | 60 | END 61 | 62 | -------------------------------------------------------------------------------- /src/rafile.h: -------------------------------------------------------------------------------- 1 | #ifndef RAFILE_H 2 | #define RAFILE_H 3 | 4 | /* Utility functions to provide the Minimig OSD code with file access 5 | at single-byte rather than 512-byte-block granularity. 6 | Copyright (c) 2012 by Alastair M. Robinson 7 | 8 | Contributed to the Minimig project, which is free software; 9 | you can redistribute it and/or modify it under the terms of 10 | the GNU General Public License as published by the Free Software Foundation; 11 | either version 3 of the License, or (at your option) any later version. 12 | 13 | Minimig is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU General Public License for more details. 17 | 18 | You should have received a copy of the GNU General Public License 19 | along with this program. If not, see . 20 | */ 21 | 22 | #include "fat.h" 23 | 24 | typedef struct 25 | { 26 | fileTYPE file; 27 | unsigned long size; 28 | unsigned long ptr; 29 | unsigned char buffer[512]; // Each RandomAccessFile has its own sector_buffer 30 | } RAFile; 31 | 32 | int RARead(RAFile *file,unsigned char *pBuffer, unsigned long bytes); 33 | int RASeek(RAFile *file,unsigned long offset,unsigned long origin); 34 | int RAOpen(RAFile *file,const char *filename); 35 | #endif 36 | -------------------------------------------------------------------------------- /fampiga/chameleon/fampiga.qpf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- # 2 | # 3 | # Copyright (C) 1991-2009 Altera Corporation 4 | # Your use of Altera Corporation's design tools, logic functions 5 | # and other software and tools, and its AMPP partner logic 6 | # functions, and any output files from any of the foregoing 7 | # (including device programming or simulation files), and any 8 | # associated documentation or information are expressly subject 9 | # to the terms and conditions of the Altera Program License 10 | # Subscription Agreement, Altera MegaCore Function License 11 | # Agreement, or other applicable license agreement, including, 12 | # without limitation, that your use is for the sole purpose of 13 | # programming logic devices manufactured by Altera and sold by 14 | # Altera or its authorized distributors. Please refer to the 15 | # applicable agreement for further details. 16 | # 17 | # -------------------------------------------------------------------------- # 18 | # 19 | # Quartus II 20 | # Version 9.0 Build 184 04/29/2009 Service Pack 1 SJ Web Edition 21 | # Date created = 20:32:22 April 24, 2011 22 | # 23 | # -------------------------------------------------------------------------- # 24 | 25 | QUARTUS_VERSION = "9.0" 26 | DATE = "20:32:22 April 24, 2011" 27 | 28 | # Revisions 29 | 30 | PROJECT_REVISION = "fampiga_top" 31 | -------------------------------------------------------------------------------- /fampiga/chameleonv2/fampiga_tc64v2.qpf: -------------------------------------------------------------------------------- 1 | # -------------------------------------------------------------------------- # 2 | # 3 | # Copyright (C) 1991-2009 Altera Corporation 4 | # Your use of Altera Corporation's design tools, logic functions 5 | # and other software and tools, and its AMPP partner logic 6 | # functions, and any output files from any of the foregoing 7 | # (including device programming or simulation files), and any 8 | # associated documentation or information are expressly subject 9 | # to the terms and conditions of the Altera Program License 10 | # Subscription Agreement, Altera MegaCore Function License 11 | # Agreement, or other applicable license agreement, including, 12 | # without limitation, that your use is for the sole purpose of 13 | # programming logic devices manufactured by Altera and sold by 14 | # Altera or its authorized distributors. Please refer to the 15 | # applicable agreement for further details. 16 | # 17 | # -------------------------------------------------------------------------- # 18 | # 19 | # Quartus II 20 | # Version 9.0 Build 184 04/29/2009 Service Pack 1 SJ Web Edition 21 | # Date created = 20:32:22 April 24, 2011 22 | # 23 | # -------------------------------------------------------------------------- # 24 | 25 | QUARTUS_VERSION = "9.0" 26 | DATE = "20:32:22 April 24, 2011" 27 | 28 | # Revisions 29 | 30 | PROJECT_REVISION = "fampiga_tc64v2" 31 | -------------------------------------------------------------------------------- /src/fdd.h: -------------------------------------------------------------------------------- 1 | #ifndef FDD_H 2 | #define FDD_H 3 | 4 | // floppy disk interface defs 5 | #define CMD_RDTRK 0x01 6 | #define CMD_WRTRK 0x02 7 | 8 | // floppy status 9 | #define DSK_INSERTED 0x01 /*disk is inserted*/ 10 | #define DSK_WRITABLE 0x10 /*disk is writable*/ 11 | 12 | #define MAX_TRACKS (83*2) 13 | 14 | typedef struct 15 | { 16 | unsigned char status; /*status of floppy*/ 17 | unsigned char tracks; /*number of tracks*/ 18 | unsigned long cache[MAX_TRACKS]; /*cluster cache*/ 19 | unsigned long cluster_offset; /*cluster offset to handle tricky loaders*/ 20 | unsigned char sector_offset; /*sector offset to handle tricky loaders*/ 21 | unsigned char track; /*current track*/ 22 | unsigned char track_prev; /*previous track*/ 23 | char name[22]; /*floppy name*/ 24 | } adfTYPE; 25 | 26 | void SectorGapToFpga(void); 27 | void SectorHeaderToFpga(unsigned char n, unsigned char dsksynch, unsigned char dsksyncl); 28 | //unsigned short SectorToFpga(unsigned char sector, unsigned char track, unsigned char dsksynch, unsigned char dsksyncl); 29 | void ReadTrack(adfTYPE *drive); 30 | unsigned char FindSync(adfTYPE *drive); 31 | unsigned char GetHeader(unsigned char *pTrack, unsigned char *pSector); 32 | unsigned char GetData(void); 33 | void WriteTrack(adfTYPE *drive); 34 | void UpdateDriveStatus(void); 35 | void HandleFDD(unsigned char c1, unsigned char c2); 36 | 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /doc/serial.txt: -------------------------------------------------------------------------------- 1 | serial.txt - Serial Connection on the MiniMig TC64 Core 2 | ------------------------------------------------------- 3 | 4 | The core currently supports two serial ports all wired to pins on the IEC 5 | connector of the Chameleon. 6 | 7 | The protocol for both is RS 232 but the levels are _NOT_ (!!!) 8 | 9 | Both tolerate signal levels from 0V up to 5V and therefore need a serial device 10 | connected with TTL 5V levels. 11 | 12 | !!! NEVER USE AN ORDINARY RS232 SERIAL DEVICE WITH -12V TO 12V LEVELS DIRECTLY 13 | AT THE IEC CONNECTOR - YOU HAVE BEEN WARNED!!! 14 | 15 | E.g. I use a FT232 USB-to-serial break out board that provides TxD and RxD with 16 | 5V levels. 17 | 18 | 19 | 1.) Amiga Paula Serial 20 | 21 | The RS232 port available in a real Amiga (provided by custom chip Paula) is wired on this 22 | Minimig core, too. The RxD and TxD are available as IEC_CLK (Rxd) and IEC_ATN (Txd). 23 | 24 | IEC Connector: 25 | 26 | Pin 2 - GND 27 | Pin 3 - IEC_ATN = Amiga Serial TxD 28 | Pin 4 - IEC_CLK = Amiga Serial RxD 29 | 30 | The serial paramters of this port depend on the values you set up on your Amiga. 31 | 32 | 33 | 2.) Debug Serial for OSD Menu Code Diagnosis 34 | 35 | This port is a transmit (TxD) only port and provides debugging information from 36 | the 68K SoftCore running the Menu Code. Its mainly useful for menu code or core 37 | developers. 38 | 39 | IEC Connector: 40 | 41 | Pin 2 - GND 42 | Pin 5 - IEC_DATA = Debug Serial TxD 43 | 44 | The serial parameters are 115200 Baud, 8 N 1, no flow control 45 | -------------------------------------------------------------------------------- /doc/toolchain.txt: -------------------------------------------------------------------------------- 1 | A bare-metal m68k gcc toolchain 2 | ------------------------------- 3 | 4 | Inspired by: http://www.mikrocontroller.net/articles/GCC_M68k 5 | 6 | 1.) binutils 7 | 8 | wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2 9 | tar -xvf binutils-2.22.tar.bz2 10 | cd binutils-2.22 11 | mkdir m68k-obj 12 | cd m68k-obj 13 | ../configure --target=m68k-elf --prefix=/opt/m68k/ 14 | make 15 | sudo make install 16 | 17 | 2.) gcc 18 | 19 | wget ftp://ftp.gwdg.de/pub/misc/gcc/releases/gcc-4.6.2/gcc-core-4.6.2.tar.bz2 20 | tar -xvf gcc-core-4.6.2.tar.bz2 21 | cd gcc-4.6.2 22 | mkdir m68k-obj 23 | cd m68k-obj 24 | ../configure --target=m68k-elf --prefix=/opt/m68k/ --enable-languages=c --with-newlib --disable-libmudflap --disable-libssp --disable-libgomp --disable-libstdcxx-pch --disable-threads --with-gnu-as --with-gnu-ld --disable-nls --with-headers=yes --disable-checking --without-headers 25 | make -j6 26 | sudo make install 27 | 28 | 3.) newlib 29 | 30 | wget ftp://sources.redhat.com/pub/newlib/newlib-1.20.0.tar.gz 31 | tar -xvf newlib-1.20.0.tar.gz 32 | cd newlib-1.20.0 33 | mkdir m68k-obj 34 | cd m68k-obj 35 | ../configure --target=m68k-elf --prefix=/opt/m68k-newlib/ --enable-newlib-reent-small --disable-malloc-debugging --disable-newlib-multithread --disable-newlib-io-float --disable-newlib-supplied-syscalls --disable-newlib-io-c99-formats --disable-newlib-mb --disable-newlib-atexit-alloc --enable-target-optspace --disable-shared --enable-static --enable-fast-install --disable-newlib-iconv --disable-newlib-io-pos-args 36 | make -j6 37 | sudo make install 38 | 39 | 40 | -------------------------------------------------------------------------------- /fampiga/firmware/hexer.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # hexer.py 3 | # create a word-size intel-hex file 4 | # 5 | # usage: hexer.py 6 | 7 | from optparse import OptionParser 8 | 9 | # parse args 10 | parser = OptionParser("usage: %prog [options] ") 11 | parser.add_option('-s', "--start", dest="start", help="start address of output", action="store", type=int, default=0) 12 | parser.add_option('-l', "--length", dest="length", help="total length of output binary", action="store", type=int, default=0) 13 | (options, args) = parser.parse_args() 14 | if len(args) != 2: 15 | parser.error("incorrect number of arguments") 16 | in_bin = args[0] 17 | out_hex = args[1] 18 | 19 | # read input file 20 | f = open(in_bin,"rb") 21 | data = f.read() 22 | f.close() 23 | data_len = len(data) 24 | print "hexer: input has %d bytes" % data_len 25 | 26 | # pad input file 27 | if options.length > 0 and data_len < options.length: 28 | pad_len = options.length - data_len 29 | pad = "\xff" * pad_len 30 | data += pad 31 | data_len = options.length 32 | print "hexer: padded to %d bytes" % data_len 33 | 34 | # create intel hex 35 | num_words = data_len / 2 36 | pos = 0 37 | addr = options.start 38 | f = open(out_hex,"w") 39 | for i in xrange(num_words): 40 | addr_hi = addr >> 8 41 | addr_lo = addr & 0xff 42 | bytes = [ 2, addr_hi, addr_lo, 0, ord(data[pos]), ord(data[pos+1]) ] 43 | pos += 2 44 | addr += 1 45 | chk = 0 46 | for b in bytes: 47 | chk += b 48 | chk = (~chk + 1) & 0xff 49 | bytes.append(chk) 50 | line = ":" + "".join(map(lambda x : "%02X" % x, bytes)) + "\r\n" 51 | f.write(line) 52 | f.write(":00000001FF\r\n") 53 | f.close() 54 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | INSTALL 2 | 3 | Preface: 4 | 5 | The controller m68k CPU code is written in C and compiled using DICE [1]. 6 | You do not need any target specific libraries or headers (e.g. Amiga). 7 | 8 | 9 | A) On a UNIX System (Linux, Mac OS X, ...) 10 | ------------------------------------------ 11 | 12 | 1. First you need to compile and setup DICE from source as a cross-compiler on 13 | your host machine. I have written a How To on my Blog [2]. This describes the 14 | Mac setup but it will work on Linux and other *nixes, too. 15 | 16 | I use the install location /opt/dice defined in DHOME in the Makefile. 17 | If you user another location than you need to adjust this value. 18 | 19 | 2. Call the Makefile supplied in the "unix" directory: 20 | 21 | > cd unix 22 | > make 23 | 24 | This will create the "OSD_CA01.sys" menu binary ready to be installed on a SD card. 25 | 26 | 27 | B) On an Amiga System 28 | --------------------- 29 | 30 | 0. Make this code tree including "amiga" and "src" folders available on your 31 | Amiga. 32 | a.) You can create a Disk (image) and copy both directories there. 33 | b.) Copy them to a SD Card 34 | c.) Use a virtual drive with host directory in an emulator like UAE 35 | 36 | 1. This distribution already ships a mini distribution of DICE 3.16 [1]. So 37 | everything is setup to compile the code. 38 | 39 | 2. Enter the "amiga" directory and call "dmake" there from the the 40 | "dice_mini/bin" directory: 41 | 42 | cd amiga 43 | dice_mini/bin/dmake 44 | 45 | This will create the "OSD_CA01.sys" menu binary ready to be installed on a SD card. 46 | 47 | 48 | [1] http://www.obviously.com/dice/ 49 | [2] http://lallafa.de/blog/2011/06/dice-3-15-revisited-on-mac/ 50 | [3] http://aminet.net/dev/c/dice-3.16.lha 51 | 52 | -------------------------------------------------------------------------------- /unix/Makefile: -------------------------------------------------------------------------------- 1 | # unix Makefile for building minimig chameleon controller code 2 | # with the DICE cross compiler 3 | # 4 | # written by Christian Vogelgsang 5 | 6 | # location of DICE compiler 7 | DHOME=/opt/dice 8 | export DHOME 9 | 10 | DBIN=$(DHOME)/ubin 11 | PATH:=$(DBIN):$(PATH) 12 | export PATH 13 | DINCLUDE=$(DHOME)/include 14 | export DINCLUDE 15 | DLIB=$(DHOME)/dlib 16 | export DLIB 17 | 18 | DCC=$(DBIN)/dcc 19 | DCCOPTS=-// -D ROM 20 | DCCLINK=-rom -l rom.lib 21 | ROMABLE=$(DBIN)/romable 22 | ROM_ADDR=0x2000 23 | 24 | C_ASM=start.asm 25 | C_SRC=main.c fdd.c fat.c osd.c hardware.c fpga.c mmc.c hdd.c menu.c 26 | C_HDR=config.h errors.h fat.h fdd.h firmware.h fpga.h hardware.h hdd.h menu.h mmc.h osd.h 27 | ALL_SRC=$(patsubst %,../src/%,$(C_ASM) $(C_SRC)) 28 | ALL_HDR=$(patsubst %,../src/%,$(C_HDR)) 29 | 30 | REL_BIN=menu 31 | ABS_BIN=OSD_CA01.sys 32 | 33 | all: $(ABS_BIN) 34 | 35 | clean: 36 | rm -f $(REL_BIN) $(ABS_BIN) 37 | 38 | $(REL_BIN): $(ALL_SRC) $(ALL_HDR) 39 | $(DCC) $(DCCOPTS) $(ALL_SRC) -o $(REL_BIN) $(DCCLINK) 40 | 41 | $(ABS_BIN): $(REL_BIN) 42 | $(ROMABLE) $(REL_BIN) -o $(ABS_BIN) -DC -C $(ROM_ADDR) 43 | 44 | # ----- create Amiga ADF Developer Disk ----- 45 | ADF_DIR=../adf 46 | DISK_DIR=$(ADF_DIR)/MM_TC64 47 | ADF_FILE=$(ADF_DIR)/mm_tc64.adf 48 | AMIGA_DIR=../amiga 49 | 50 | .PHONY: clean_disk_dir prepare_disk_dir master_disk adf 51 | 52 | clean_amiga_dir: 53 | rm -f $(AMIGA_DIR)/OSD_CA01.sys $(AMIGA_DIR)/menu 54 | 55 | clean_disk_dir: 56 | rm -rf $(DISK_DIR) 57 | 58 | prepare_disk_dir: clean_disk_dir clean_amiga_dir 59 | mkdir -p $(DISK_DIR) 60 | cp -a ../src $(DISK_DIR) 61 | cp -a ../amiga $(DISK_DIR) 62 | cp ../README $(DISK_DIR) 63 | cp ../INSTALL $(DISK_DIR) 64 | 65 | master_disk: prepare_disk_dir 66 | xdftool $(ADF_FILE) pack $(DISK_DIR) 67 | 68 | adf: 69 | $(MAKE) master_disk 70 | $(MAKE) clean_disk_dir 71 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #include "fat.h" 2 | 3 | typedef struct 4 | { 5 | char name[8]; 6 | char long_name[16]; 7 | } kickstartTYPE; 8 | 9 | typedef struct 10 | { 11 | unsigned char lores; 12 | unsigned char hires; 13 | } filterTYPE; 14 | 15 | typedef struct 16 | { 17 | unsigned char speed; 18 | unsigned char drives; 19 | } floppyTYPE; 20 | 21 | typedef struct 22 | { 23 | unsigned char enabled; // 0: Disabled, 1: Hard file, 2: MMC (entire card), 3-6: Partition 1-4 of MMC card 24 | unsigned char present; 25 | char name[8]; 26 | char long_name[16]; 27 | } hardfileTYPE; 28 | 29 | typedef struct 30 | { 31 | char id[8]; 32 | unsigned long version; 33 | kickstartTYPE kickstart; 34 | filterTYPE filter; 35 | unsigned char memory; 36 | unsigned char chipset; 37 | floppyTYPE floppy; 38 | unsigned char disable_ar3; 39 | unsigned char enable_ide; 40 | unsigned char scanlines; 41 | unsigned char pad1; 42 | hardfileTYPE hardfile[2]; 43 | unsigned char cpu; 44 | unsigned char fastram; // Contains fast mem (bit 0 & 1) and turbo chipram (bit 7) settings. 45 | } configTYPE; 46 | 47 | extern fileTYPE file; // Temporary file available for use by other modules, to avoid repeated memory usage. 48 | // Shouldn't be considered persistent. 49 | 50 | extern configTYPE config; 51 | extern char DebugMode; 52 | 53 | char UploadKickstart(char *name); 54 | char UploadActionReplay(); 55 | void SetConfigurationFilename(int config); // Set configuration filename by slot number 56 | unsigned char LoadConfiguration(char *filename); // Can supply NULL to use filename previously set by slot number 57 | unsigned char SaveConfiguration(char *filename); // Can supply NULL to use filename previously set by slot number 58 | unsigned char ConfigurationExists(char *filename); 59 | void ApplyConfiguration(char reloadkickstart); 60 | 61 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | C_SRC=fat.c fdd.c fpga.c hardware.c hdd.c main.c menu.c mmc.c osd.c printf.c swap.c config.c rafile.c 2 | KLIBC_SRC=vsnprintf.c sprintf.c memcpy.c memcmp.c strcpy.c strcat.c strncat.c strncmp.c strlen.c memset.c strncpy.c strchr.c 3 | A_SRC=startup.s 4 | 5 | MEMCHECK_SRC=memcheck.c 6 | 7 | BUILD_DIR=BUILD 8 | C_OBJ=$(patsubst %.c,$(BUILD_DIR)/%.o,$(C_SRC)) 9 | LIBC_OBJ=$(patsubst %.c,$(BUILD_DIR)/%.o,$(KLIBC_SRC)) 10 | A_OBJ=$(patsubst %.s,$(BUILD_DIR)/%.o,$(A_SRC)) 11 | OBJ=$(C_OBJ) $(A_OBJ) 12 | 13 | MEMCHECK_OBJ=$(patsubst %.c,$(BUILD_DIR)/%.o,$(MEMCHECK_SRC)) $(A_OBJ) 14 | 15 | ARCH=68000 16 | CC=m68k-elf-gcc 17 | AR=m68k-elf-ar 18 | OBJCOPY=m68k-elf-objcopy 19 | CFLAGS+=-m$(ARCH) -Wall -Wno-char-subscripts -Os -fno-common -fomit-frame-pointer -I./include -DACTIONREPLAY_BROKEN 20 | LDFLAGS+=-m$(ARCH) -Xlinker -Map=menu.map -nostartfiles -L. 21 | 22 | ELF=menu.elf 23 | OUTPUT=OSD_CA01.sys 24 | LINK_SCRIPT=osdcpu.ld 25 | LIBC_TARGET=libc.a 26 | 27 | MEMCHECK_E=memcheck.elf 28 | MEMCHECK_O=memcheck.sys 29 | 30 | all: $(BUILD_DIR) $(LIBC_TARGET) $(OUTPUT) $(MEMCHECK_O) 31 | 32 | clean: 33 | rm -rf $(BUILD_DIR) $(LIBC_TARGET) $(ELF) $(OUTPUT) 34 | 35 | $(LIBC_TARGET): $(LIBC_OBJ) 36 | $(AR) -r $(LIBC_TARGET) $(LIBC_OBJ) 37 | 38 | $(OUTPUT): $(ELF) 39 | $(OBJCOPY) -O binary $(ELF) -j .code $(OUTPUT) 40 | 41 | $(ELF): $(OBJ) $(LINK_SCRIPT) 42 | $(CC) $(LDFLAGS) -o $@ -T $(LINK_SCRIPT) $(OBJ) $(NEWLIB) 43 | 44 | $(MEMCHECK_O): $(MEMCHECK_E) 45 | $(OBJCOPY) -O binary $(MEMCHECK_E) -j .code $(MEMCHECK_O) 46 | 47 | $(MEMCHECK_E): $(MEMCHECK_OBJ) $(LINK_SCRIPT) 48 | $(CC) $(LDFLAGS) -o $@ -T $(LINK_SCRIPT) $(MEMCHECK_OBJ) $(NEWLIB) 49 | 50 | $(BUILD_DIR): 51 | mkdir $(BUILD_DIR) 52 | 53 | $(BUILD_DIR)/%.o: %.c 54 | $(CC) $(CFLAGS) -c -o $@ $< 55 | 56 | $(BUILD_DIR)/%.o: klibc/%.c 57 | $(CC) $(CFLAGS) -c -o $@ $< 58 | 59 | $(BUILD_DIR)/%.o: %.s 60 | $(CC) $(CFLAGS) -c -o $@ $< 61 | -------------------------------------------------------------------------------- /src/include/sys/_types.h: -------------------------------------------------------------------------------- 1 | /* ANSI C namespace clean utility typedefs */ 2 | 3 | /* This file defines various typedefs needed by the system calls that support 4 | the C library. Basically, they're just the POSIX versions with an '_' 5 | prepended. This file lives in the `sys' directory so targets can provide 6 | their own if desired (or they can put target dependant conditionals here). 7 | */ 8 | 9 | #ifndef _SYS__TYPES_H 10 | #define _SYS__TYPES_H 11 | 12 | #include 13 | #include 14 | 15 | #ifndef __off_t_defined 16 | typedef long _off_t; 17 | #endif 18 | 19 | #if defined(__rtems__) 20 | /* device numbers are 32-bit major and and 32-bit minor */ 21 | typedef unsigned long long __dev_t; 22 | #else 23 | #ifndef __dev_t_defined 24 | typedef short __dev_t; 25 | #endif 26 | #endif 27 | 28 | #ifndef __uid_t_defined 29 | typedef unsigned short __uid_t; 30 | #endif 31 | #ifndef __gid_t_defined 32 | typedef unsigned short __gid_t; 33 | #endif 34 | 35 | #ifndef __off64_t_defined 36 | __extension__ typedef long long _off64_t; 37 | #endif 38 | 39 | /* 40 | * We need fpos_t for the following, but it doesn't have a leading "_", 41 | * so we use _fpos_t instead. 42 | */ 43 | #ifndef __fpos_t_defined 44 | typedef long _fpos_t; /* XXX must match off_t in */ 45 | /* (and must be `long' for now) */ 46 | #endif 47 | 48 | #ifdef __LARGE64_FILES 49 | #ifndef __fpos64_t_defined 50 | typedef _off64_t _fpos64_t; 51 | #endif 52 | #endif 53 | 54 | #ifndef __ssize_t_defined 55 | #if defined(__INT_MAX__) && __INT_MAX__ == 2147483647 56 | typedef int _ssize_t; 57 | #else 58 | typedef long _ssize_t; 59 | #endif 60 | #endif 61 | 62 | #define __need_wint_t 63 | #include 64 | 65 | #ifndef __mbstate_t_defined 66 | /* Conversion state information. */ 67 | typedef struct 68 | { 69 | int __count; 70 | union 71 | { 72 | wint_t __wch; 73 | unsigned char __wchb[4]; 74 | } __value; /* Value so far. */ 75 | } _mbstate_t; 76 | #endif 77 | 78 | #ifndef __flock_t_defined 79 | typedef _LOCK_RECURSIVE_T _flock_t; 80 | #endif 81 | 82 | #ifndef __iconv_t_defined 83 | /* Iconv descriptor type */ 84 | typedef void *_iconv_t; 85 | #endif 86 | 87 | #endif /* _SYS__TYPES_H */ 88 | -------------------------------------------------------------------------------- /amiga/s/Startup-sequence: -------------------------------------------------------------------------------- 1 | ;zkick devs:rom2.0 2 | 3 | c:setpatch >NIL: 4 | ;run >nil: c:iffboot c:amigawb.iff 5 | ;c:version >NIL: 6 | ;addbuffers >NIL: df0: 15 7 | Failat 21 8 | 9 | ;Resident >NIL: C:Execute PURE ADD 10 | 11 | ;c:noclick2.0 >NIL: 12 | makedir ram:T ram:Clipboards ram:env ram:env/sys 13 | copy >NIL: ENVARC: ram:env all quiet noreq 14 | 15 | assign ENV: ram:env 16 | assign T: ram:t ;set up T: directory for scripts 17 | assign CLIPS: ram:clipboards 18 | assign REXX: sys:rexx 19 | 20 | assign locale: sys:locale 21 | ;assign dopus: sys:dopus 22 | ;assign fms: ram: 23 | assign printers: devs:printers 24 | 25 | ;mount ff0: 26 | ;mount ff1: 27 | 28 | ;assign lc: dh0:Sprachen/lc/c 29 | ;assign Lib: lc:/lib 30 | ;assign include: lc:/include 31 | ;assign quad: ram: 32 | ;path lc: add 33 | 34 | ;if exists sys:Monitors 35 | ; join >NIL: sys:monitors/~(#?.info) as t:mon-start 36 | ; execute t:mon-start 37 | ; delete >NIL: t:mon-start 38 | ;endif 39 | 40 | devs:Monitors/super72 41 | devs:Monitors/multiscan 42 | BindDrivers 43 | 44 | ;suprapowerdown >nil: dh0: 5 45 | 46 | ;setenv Workbench $Workbench 47 | ;setenv Kickstart $Kickstart 48 | 49 | ;IPrefs 50 | 51 | ;echo "Amiga Release 2. Kickstart $Kickstart, Workbench $Workbench" 52 | 53 | ;conclip 54 | 55 | ;mount speak: 56 | ;mount aux: 57 | ;mount pipe: 58 | 59 | path ram: c: sys:utilities sys:rexxc sys:system sys:prefs add 60 | if exists sys:tools 61 | path sys:tools add 62 | if exists sys:tools/commodities 63 | path sys:tools/commodities add 64 | endif 65 | endif 66 | 67 | ; If this is the initial boot (i.e. keyboard env variable is not set) 68 | ; then execute PickMap which will query for a keymap and set the 69 | ; keyboard env variable. 70 | ; 71 | ; if keyboard env variable is set, set the keymap 72 | ;if ${sys/keyboard} NOT EQ "*${sys/keyboard}" 73 | ; setmap ${sys/keyboard} 74 | ;else 75 | ; PickMap sys: initial 76 | ;endif 77 | 78 | ;patchreq >nil: cache 79 | ;rtpatch >nil: 80 | 81 | ;rexxmast >NIL: 82 | 83 | ;if exists s:user-startup 84 | ; execute s:user-startup 85 | ;endif 86 | 87 | execute DCC:dice 88 | system/cli 89 | ;LoadWB 90 | 91 | ;cd sys:Diskettentools/ 92 | ;runback sys:Diskettentools/DOpus 93 | ;runback sys:tools/commodities/kcommodity CX_POPUP=NO 94 | endcli >NIL: 95 | 96 | ;ARM: 97 | ;cd arm 98 | ;execute make.txt 99 | 100 | -------------------------------------------------------------------------------- /src/rafile.c: -------------------------------------------------------------------------------- 1 | #include "rafile.h" 2 | 3 | int RARead(RAFile *file,unsigned char *pBuffer, unsigned long bytes) 4 | { 5 | int result=1; 6 | // Since we can only read from the SD card on 512-byte aligned boundaries, 7 | // we need to copy in multiple pieces. 8 | unsigned long blockoffset=file->ptr&511; // Offset within the current 512 block at which the previous read finished 9 | // Bytes blockoffset to 512 will be drained first, before reading new data. 10 | 11 | if(blockoffset) // If blockoffset is zero we'll just use aligned reads and don't need to drain the buffer. 12 | { 13 | int i; 14 | int l=bytes; 15 | if(l>512) 16 | l=512; 17 | for(i=blockoffset;ibuffer[i]; 20 | } 21 | file->ptr+=l-blockoffset; 22 | bytes-=l-blockoffset; 23 | } 24 | 25 | // We've now read any bytes left over from a previous read. If any data remains to be read we can read it 26 | // in 512-byte aligned chunks, until the last block. 27 | while(bytes>511) 28 | { 29 | result&=FileRead(&file->file,pBuffer); // Read direct to pBuffer 30 | FileNextSector(&file->file); 31 | bytes-=512; 32 | file->ptr+=512; 33 | pBuffer+=512; 34 | } 35 | 36 | if(bytes) // Do we have any bytes left to read? 37 | { 38 | int i; 39 | result&=FileRead(&file->file,file->buffer); // Read to temporary buffer, allowing us to preserve any leftover for the next read. 40 | FileNextSector(&file->file); 41 | for(i=0;ibuffer[i]; 44 | } 45 | file->ptr+=bytes; 46 | } 47 | return(result); 48 | } 49 | 50 | 51 | int RASeek(RAFile *file,unsigned long offset,unsigned long origin) 52 | { 53 | int result=1; 54 | unsigned long blockoffset; 55 | unsigned long blockaddress; 56 | if(origin==SEEK_CUR) 57 | offset+=file->ptr; 58 | blockoffset=offset&511; 59 | blockaddress=offset-blockoffset; // 512-byte-aligned... 60 | result&=FileSeek(&file->file,blockaddress,SEEK_SET); 61 | if(result && blockoffset) // If we're seeking into the middle of a block, we need to buffer it... 62 | { 63 | result&=FileRead(&file->file,file->buffer); 64 | FileNextSector(&file->file); 65 | } 66 | file->ptr=offset; 67 | return(result); 68 | } 69 | 70 | 71 | int RAOpen(RAFile *file,const char *filename) 72 | { 73 | int result=1; 74 | if(!file) 75 | return(0); 76 | result=FileOpen(&file->file,filename); 77 | file->size=file->file.size; 78 | file->ptr=0; 79 | return(result); 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/menu.h: -------------------------------------------------------------------------------- 1 | #ifndef MENU_H 2 | #define MENU_H 3 | 4 | #include "fdd.h" // for adfTYPE definition 5 | 6 | /*menu states*/ 7 | enum MENU 8 | { 9 | MENU_NONE1, 10 | MENU_NONE2, 11 | MENU_MAIN1, 12 | MENU_MAIN2, 13 | MENU_MISC1, 14 | MENU_MISC2, 15 | MENU_ABOUT1, 16 | MENU_ABOUT2, 17 | MENU_FILE_SELECT1, 18 | MENU_FILE_SELECT2, 19 | MENU_FILE_SELECTED, 20 | MENU_RESET1, 21 | MENU_RESET2, 22 | MENU_RECONF1, 23 | MENU_RECONF2, 24 | MENU_SETTINGS1, 25 | MENU_SETTINGS2, 26 | MENU_ROMFILE_SELECTED, 27 | MENU_ROMFILE_SELECTED1, 28 | MENU_ROMFILE_SELECTED2, 29 | MENU_SETTINGS_VIDEO1, 30 | MENU_SETTINGS_VIDEO2, 31 | MENU_SETTINGS_MEMORY1, 32 | MENU_SETTINGS_MEMORY2, 33 | MENU_SETTINGS_CHIPSET1, 34 | MENU_SETTINGS_CHIPSET2, 35 | MENU_SETTINGS_DRIVES1, 36 | MENU_SETTINGS_DRIVES2, 37 | MENU_SETTINGS_HARDFILE1, 38 | MENU_SETTINGS_HARDFILE2, 39 | MENU_HARDFILE_SELECT1, 40 | MENU_HARDFILE_SELECT2, 41 | MENU_HARDFILE_SELECTED, 42 | MENU_HARDFILE_EXIT, 43 | MENU_HARDFILE_CHANGED1, 44 | MENU_HARDFILE_CHANGED2, 45 | MENU_SYNTHRDB1, 46 | MENU_SYNTHRDB2, 47 | MENU_SYNTHRDB2_1, 48 | MENU_SYNTHRDB2_2, 49 | MENU_MAIN2_1, 50 | MENU_MAIN2_2, 51 | MENU_LOADCONFIG_1, 52 | MENU_LOADCONFIG_2, 53 | MENU_SAVECONFIG_1, 54 | MENU_SAVECONFIG_2, 55 | MENU_FIRMWARE1, 56 | MENU_FIRMWARE2, 57 | MENU_FIRMWARE_UPDATE1, 58 | MENU_FIRMWARE_UPDATE2, 59 | MENU_FIRMWARE_UPDATE_ERROR1, 60 | MENU_FIRMWARE_UPDATE_ERROR2, 61 | MENU_FIRMWARE_UPDATING1, 62 | MENU_FIRMWARE_UPDATING2, 63 | MENU_FIRMWARE_OPTIONS1, 64 | MENU_FIRMWARE_OPTIONS2, 65 | MENU_FIRMWARE_OPTIONS_ENABLE1, 66 | MENU_FIRMWARE_OPTIONS_ENABLE2, 67 | MENU_FIRMWARE_OPTIONS_ENABLED1, 68 | MENU_FIRMWARE_OPTIONS_ENABLED2, 69 | MENU_ERROR, 70 | MENU_INFO, 71 | }; 72 | 73 | // UI strings, used by boot messages 74 | extern const char *config_filter_msg[]; 75 | extern const char *config_memory_chip_msg[]; 76 | extern const char *config_memory_slow_msg[]; 77 | extern const char *config_scanline_msg[]; 78 | 79 | 80 | void InsertFloppy(adfTYPE *drive); 81 | void HandleUI(void); 82 | void PrintDirectory(void); 83 | void ScrollLongName(void); 84 | void ErrorMessage(char *message, unsigned char code); 85 | void InfoMessage(char *message); 86 | void DebugMessage(char *message); 87 | void _showdebugmessages(); 88 | void ShowSplash(); 89 | void HideSplash(); 90 | 91 | #endif 92 | 93 | -------------------------------------------------------------------------------- /amiga/dice_mini/include/string.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * $VER: string.h 1.0 (17.4.93) 4 | * 5 | * (c)Copyright 1992 Obvious Implementations Corp, All Rights Reserved 6 | */ 7 | 8 | #ifndef STRING_H 9 | #define STRING_H 10 | 11 | #ifndef STDDEF_H 12 | #include 13 | #endif 14 | 15 | 16 | extern int memcmp(const void *, const void *, size_t); 17 | extern int strcmp(const char *, const char *); 18 | extern int strcoll(const char *, const char *); 19 | extern int strncmp(const char *, const char *, size_t); 20 | extern size_t strxfrm(char *, const char *, size_t); 21 | 22 | extern char *strcat(char *, const char *); 23 | extern char *strncat(char *, const char *, size_t); 24 | 25 | extern void *memcpy(void *, const void *, size_t); 26 | extern void *memmove(void *, const void *, size_t); 27 | extern char *strcpy(char *, const char *); 28 | extern char *stpcpy(char *, const char *); 29 | extern char *strncpy(char *, const char *, size_t); 30 | extern void *memset(void *, int, size_t); 31 | extern char *strerror(int); 32 | extern size_t strlen(const char *); 33 | 34 | extern void *memchr(const void *, int, size_t); 35 | extern char *strchr(const char *, int); 36 | extern size_t strcspn(const char *, const char *); 37 | extern char *strpbrk(const char *, const char *); 38 | extern char *strrchr(const char *, int); 39 | extern size_t strspn(const char *, const char *); 40 | extern char *strstr(const char *, const char *); 41 | extern char *strtok(char *, const char *); 42 | 43 | extern double strtod(const char *, char **); 44 | extern long strtol(const char *, char **, int); 45 | extern unsigned long strtoul(const char *, char **, int); 46 | 47 | /* 48 | * Standard, but not ANSI 49 | */ 50 | 51 | extern void *movmem(const void *, const void *, size_t); 52 | extern void *setmem(void *, size_t, int); 53 | extern void *cmpmem(const void *, const void *, size_t); 54 | extern void *clrmem(void *, size_t); 55 | extern void *bzero(void *, size_t); 56 | extern void *bcopy(const void *, void *, size_t); 57 | extern void *bcmp(const void *, const void *, size_t); 58 | extern char *strupper(char *); 59 | 60 | /* 61 | * Other string routines 62 | */ 63 | 64 | extern int stricmp(const char *, const char *); 65 | extern int strnicmp(const char *, const char *, int); 66 | extern int strbpl(char **, int, const char *); 67 | extern void strins(char *, const char *); 68 | extern char *strdup(const char *); 69 | extern char *stpbrk(const char *, const char *); 70 | extern const char *stpchr(const char *, char); 71 | 72 | 73 | #endif 74 | 75 | -------------------------------------------------------------------------------- /src/hdd.h: -------------------------------------------------------------------------------- 1 | #define CMD_IDECMD 0x04 2 | #define CMD_IDEDAT 0x08 3 | 4 | #define CMD_IDE_REGS_RD 0x80 5 | #define CMD_IDE_REGS_WR 0x90 6 | #define CMD_IDE_DATA_WR 0xA0 7 | #define CMD_IDE_DATA_RD 0xB0 8 | #define CMD_IDE_STATUS_WR 0xF0 9 | 10 | #define IDE_STATUS_END 0x80 11 | #define IDE_STATUS_IRQ 0x10 12 | #define IDE_STATUS_RDY 0x08 13 | #define IDE_STATUS_REQ 0x04 14 | #define IDE_STATUS_ERR 0x01 15 | 16 | #define ACMD_RECALIBRATE 0x10 17 | #define ACMD_IDENTIFY_DEVICE 0xEC 18 | #define ACMD_INITIALIZE_DEVICE_PARAMETERS 0x91 19 | #define ACMD_READ_SECTORS 0x20 20 | #define ACMD_WRITE_SECTORS 0x30 21 | #define ACMD_READ_MULTIPLE 0xC4 22 | #define ACMD_WRITE_MULTIPLE 0xC5 23 | #define ACMD_SET_MULTIPLE_MODE 0xC6 24 | 25 | #define HDF_DISABLED 0 26 | #define HDF_FILE 1 27 | #define HDF_CARD 2 28 | #define HDF_CARDPART0 3 29 | #define HDF_CARDPART1 4 30 | #define HDF_CARDPART2 5 31 | #define HDF_CARDPART3 6 32 | #define HDF_TYPEMASK 15 33 | #define HDF_SYNTHRDB 128 // Flag to indicate whether we should auto-synthesize a RigidDiskBlock 34 | 35 | typedef struct 36 | { 37 | int type; // Are we using a file, the entire SD card or a partition on the SD card? 38 | fileTYPE file; 39 | unsigned short cylinders; 40 | unsigned short heads; 41 | unsigned short sectors; 42 | unsigned short sectors_per_block; 43 | unsigned short partition; // Partition no. 44 | long offset; // If a partition, the lba offset of the partition. Can be negative if we've synthesized an RDB. 45 | unsigned long index[1024]; 46 | unsigned long index_size; 47 | } hdfTYPE; 48 | 49 | void IdentifyDevice(unsigned short *pBuffer, unsigned char unit); 50 | unsigned long chs2lba(unsigned short cylinder, unsigned char head, unsigned short sector, unsigned char unit); 51 | void WriteTaskFile(unsigned char error, unsigned char sector_count, unsigned char sector_number, unsigned char cylinder_low, unsigned char cylinder_high, unsigned char drive_head); 52 | void WriteStatus(unsigned char status); 53 | void HandleHDD(unsigned char c1, unsigned char c2); 54 | void GetHardfileGeometry(hdfTYPE *hdf); 55 | void BuildHardfileIndex(hdfTYPE *hdf); 56 | unsigned char HardFileSeek(hdfTYPE *hdf, unsigned long lba); 57 | unsigned char OpenHardfile(unsigned char unit); 58 | 59 | #define HDF_FILETYPE_UNKNOWN 0 60 | #define HDF_FILETYPE_NOTFOUND 1 61 | #define HDF_FILETYPE_RDB 2 62 | #define HDF_FILETYPE_DOS 3 63 | 64 | unsigned char GetHDFFileType(char *filename); 65 | 66 | extern char debugmsg[40]; 67 | extern char debugmsg2[40]; 68 | 69 | extern hdfTYPE hdf[2]; 70 | 71 | -------------------------------------------------------------------------------- /fampiga/board/chameleon_phi_clock_e.vhd: -------------------------------------------------------------------------------- 1 | -- ----------------------------------------------------------------------- 2 | -- 3 | -- VGA-64 4 | -- 5 | -- Multi purpose FPGA expansion for the Commodore 64 computer 6 | -- 7 | -- ----------------------------------------------------------------------- 8 | -- Copyright 2005-2018 by Peter Wendrich (pwsoft@syntiac.com) 9 | -- http://www.syntiac.com/chameleon.html 10 | -- 11 | -- This source file is free software: you can redistribute it and/or modify 12 | -- it under the terms of the GNU Lesser General Public License as published 13 | -- by the Free Software Foundation, either version 3 of the License, or 14 | -- (at your option) any later version. 15 | -- 16 | -- This source file is distributed in the hope that it will be useful, 17 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | -- GNU General Public License for more details. 20 | -- 21 | -- You should have received a copy of the GNU General Public License 22 | -- along with this program. If not, see . 23 | -- 24 | -- ----------------------------------------------------------------------- 25 | -- 26 | -- C64 Phi2-clock regeneration and divider 27 | -- 28 | -- ----------------------------------------------------------------------- 29 | 30 | library IEEE; 31 | use IEEE.STD_LOGIC_1164.ALL; 32 | use IEEE.numeric_std.all; 33 | 34 | -- ----------------------------------------------------------------------- 35 | 36 | entity chameleon_phi_clock is 37 | generic ( 38 | phase_shift : integer := 8 39 | ); 40 | port ( 41 | clk : in std_logic; 42 | phi2_n : in std_logic; 43 | 44 | -- Standalone mode, 0=PAL and 1=NTSC 45 | mode : in std_logic := '0'; 46 | 47 | -- Buffered and inverted phi_n (delayed) 48 | phiLength : out unsigned(7 downto 0); 49 | 50 | -- no_clock is high when there are no phiIn changes detected. 51 | -- This signal allows switching between real I/O and internal emulation. 52 | no_clock : out std_logic; 53 | 54 | -- docking_station is high when there are no phiIn changes (no_clock) and 55 | -- the phi signal is low. Without docking station phi is pulled up. 56 | docking_station : out std_logic; 57 | 58 | -- Resynthesised Phi2 clock 59 | phiLocal : out std_logic; 60 | -- Cycle counter 61 | phiCnt : out unsigned(7 downto 0); 62 | -- Control pulses 63 | phiPreHalf : out std_logic; 64 | phiHalf : out std_logic; 65 | phiPreEnd : out std_logic; 66 | phiEnd : out std_logic; 67 | 68 | -- First cycle where phiLocal is changed. 69 | phiPost1 : out std_logic; 70 | -- Second cycle after phiLocal change. 71 | phiPost2 : out std_logic; 72 | -- Third cycle after phiLocal change. 73 | phiPost3 : out std_logic; 74 | -- Forth cycle after phiLocal change. 75 | phiPost4 : out std_logic 76 | ); 77 | end entity; 78 | 79 | 80 | -------------------------------------------------------------------------------- /fampiga/chameleon/syscontrol.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2011 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.1")) 22 | (symbol 23 | (rect 16 16 168 176) 24 | (text "syscontrol" (rect 5 0 75 12)(font "Arial" )) 25 | (text "inst" (rect 8 144 36 156)(font "Arial" )) 26 | (port 27 | (pt 0 32) 28 | (input) 29 | (text "clk" (rect 0 0 21 12)(font "Arial" )) 30 | (text "clk" (rect 21 27 42 39)(font "Arial" )) 31 | (line (pt 0 32)(pt 16 32)(line_width 1)) 32 | ) 33 | (port 34 | (pt 0 48) 35 | (input) 36 | (text "cnt" (rect 0 0 21 12)(font "Arial" )) 37 | (text "cnt" (rect 21 43 42 55)(font "Arial" )) 38 | (line (pt 0 48)(pt 16 48)(line_width 1)) 39 | ) 40 | (port 41 | (pt 0 64) 42 | (input) 43 | (text "locked" (rect 0 0 42 12)(font "Arial" )) 44 | (text "locked" (rect 21 59 63 71)(font "Arial" )) 45 | (line (pt 0 64)(pt 16 64)(line_width 1)) 46 | ) 47 | (port 48 | (pt 0 80) 49 | (input) 50 | (text "mrst" (rect 0 0 28 12)(font "Arial" )) 51 | (text "mrst" (rect 21 75 49 87)(font "Arial" )) 52 | (line (pt 0 80)(pt 16 80)(line_width 1)) 53 | ) 54 | (port 55 | (pt 0 96) 56 | (input) 57 | (text "boot_done" (rect 0 0 63 12)(font "Arial" )) 58 | (text "boot_done" (rect 21 91 84 103)(font "Arial" )) 59 | (line (pt 0 96)(pt 16 96)(line_width 1)) 60 | ) 61 | (port 62 | (pt 0 112) 63 | (input) 64 | (text "boot_rst" (rect 0 0 56 12)(font "Arial" )) 65 | (text "boot_rst" (rect 21 107 77 119)(font "Arial" )) 66 | (line (pt 0 112)(pt 16 112)(line_width 1)) 67 | ) 68 | (port 69 | (pt 152 32) 70 | (output) 71 | (text "reset" (rect 0 0 35 12)(font "Arial" )) 72 | (text "reset" (rect 96 27 131 39)(font "Arial" )) 73 | (line (pt 152 32)(pt 136 32)(line_width 1)) 74 | ) 75 | (port 76 | (pt 152 48) 77 | (output) 78 | (text "boot" (rect 0 0 28 12)(font "Arial" )) 79 | (text "boot" (rect 103 43 131 55)(font "Arial" )) 80 | (line (pt 152 48)(pt 136 48)(line_width 1)) 81 | ) 82 | (drawing 83 | (rectangle (rect 16 16 136 144)(line_width 1)) 84 | ) 85 | ) 86 | -------------------------------------------------------------------------------- /fampiga/board/chameleon_reconfigure.vhd: -------------------------------------------------------------------------------- 1 | -- Sending data to the Chameleon's microcontroller 2 | 3 | library IEEE; 4 | use IEEE.STD_LOGIC_1164.ALL; 5 | use IEEE.numeric_std.ALL; 6 | 7 | -- ----------------------------------------------------------------------- 8 | 9 | entity chameleon_reconfigure is 10 | generic ( 11 | resetCycles: integer := 131072 12 | ); 13 | port ( 14 | clk : in std_logic; 15 | -- reset : in std_logic; 16 | reconfigure : in std_logic; 17 | 18 | serial_clk : in std_logic; 19 | serial_txd : out std_logic; 20 | serial_cts_n : in std_logic := '0' 21 | ); 22 | end entity; 23 | 24 | -- ----------------------------------------------------------------------- 25 | 26 | architecture rtl of chameleon_reconfigure is 27 | type state_t is ( 28 | STATE_INIT, 29 | STATE_IDLE, 30 | STATE_XFER, 31 | STATE_STOP); 32 | 33 | signal resetcnt : integer range 0 to resetCycles := 0; 34 | signal reset : std_logic := '1' ; 35 | signal transmit_state : state_t := STATE_INIT; 36 | signal transmit_empty : std_logic := '1'; 37 | signal transmit_shift : unsigned(8 downto 0) := (others => '0'); 38 | signal transmit_cnt : integer range 0 to 8 := 0; 39 | signal scts_n : std_logic; 40 | signal sclk : std_logic; 41 | signal sclk_d : std_logic; 42 | signal reconfig_pending : std_logic :='0'; 43 | begin 44 | 45 | -- FIXME - need to filter sclk to avoid metastability issues. 46 | 47 | process(clk,serial_clk,serial_cts_n) 48 | begin 49 | if rising_edge(clk) then 50 | sclk<=serial_clk; 51 | sclk_d<=sclk; 52 | scts_n<=serial_cts_n; 53 | end if; 54 | end process; 55 | 56 | transmit_process: process(clk, serial_clk, reconfigure) 57 | begin 58 | 59 | if rising_edge(clk) then 60 | if reconfigure='1' then 61 | reconfig_pending<='1'; 62 | end if; 63 | 64 | if sclk='0' and sclk_d='1' then -- falling edge 65 | if resetcnt=(resetCycles-1) then 66 | reset <= '0'; 67 | else 68 | reset <= '1'; 69 | serial_txd<='1'; 70 | resetcnt <=resetcnt+1; 71 | end if; 72 | 73 | case transmit_state is 74 | when STATE_INIT => 75 | if reset='0' then 76 | transmit_shift <= "100101010"; -- 42, 0x12A 77 | transmit_empty <='0'; 78 | transmit_state<=STATE_IDLE; 79 | end if; 80 | when STATE_IDLE => 81 | transmit_cnt <= 0; 82 | 83 | if reconfig_pending='1' then 84 | transmit_shift <= "111110000"; 85 | transmit_empty <='0'; 86 | reconfig_pending<='0'; 87 | end if; 88 | if (transmit_empty = '0') and (scts_n = '0') then 89 | transmit_empty <= '1'; 90 | transmit_state <= STATE_XFER; 91 | serial_txd <= '0'; 92 | else 93 | serial_txd <= '1'; 94 | end if; 95 | when STATE_XFER => 96 | serial_txd <= transmit_shift(transmit_cnt); 97 | if transmit_cnt = 8 then 98 | transmit_state <= STATE_STOP; 99 | else 100 | transmit_cnt <= transmit_cnt + 1; 101 | end if; 102 | when STATE_STOP => 103 | serial_txd <= '1'; 104 | transmit_state <= STATE_IDLE; 105 | end case; 106 | end if; 107 | end if; 108 | end process; 109 | end architecture; 110 | -------------------------------------------------------------------------------- /fampiga/chameleon/fampiga.sdc: -------------------------------------------------------------------------------- 1 | #************************************************************ 2 | # THIS IS A WIZARD-GENERATED FILE. 3 | # 4 | # Version 11.1 Build 216 11/23/2011 Service Pack 1 SJ Web Edition 5 | # 6 | #************************************************************ 7 | 8 | # Copyright (C) 1991-2011 Altera Corporation 9 | # Your use of Altera Corporation's design tools, logic functions 10 | # and other software and tools, and its AMPP partner logic 11 | # functions, and any output files from any of the foregoing 12 | # (including device programming or simulation files), and any 13 | # associated documentation or information are expressly subject 14 | # to the terms and conditions of the Altera Program License 15 | # Subscription Agreement, Altera MegaCore Function License 16 | # Agreement, or other applicable license agreement, including, 17 | # without limitation, that your use is for the sole purpose of 18 | # programming logic devices manufactured by Altera and sold by 19 | # Altera or its authorized distributors. Please refer to the 20 | # applicable agreement for further details. 21 | 22 | 23 | 24 | # Clock constraints 25 | 26 | create_clock -name "clk8" -period 125.000ns [get_ports {clk8}] -waveform {0.000 62.500} 27 | 28 | # Automatically constrain PLL and other generated clocks 29 | derive_pll_clocks 30 | 31 | create_generated_clock -name sdram_clk_pin -source [get_nets {b2v_inst|altpll_component|auto_generated|wire_pll1_clk[0]}] [get_ports {sd_clk}] 32 | 33 | #************************************************************** 34 | # Set Clock Uncertainty 35 | #************************************************************** 36 | 37 | derive_clock_uncertainty; 38 | 39 | #************************************************************** 40 | # Set Input Delay 41 | #************************************************************** 42 | 43 | # Very narrow window here. 44 | set_input_delay -clock sdram_clk_pin -max [expr 5.4 + 1.0] [get_ports sd_data*] 45 | set_input_delay -clock sdram_clk_pin -min [expr 0 + 1.0 ] [get_ports sd_data*] 46 | 47 | #************************************************************** 48 | # Set Output Delay 49 | #************************************************************** 50 | 51 | # Routing delay on outputs should pretty much cancel out, since they'll apply to the clock too, yes? 52 | set_output_delay -clock sdram_clk_pin -max [expr 1.5 + 0.1] [get_ports sd_data*] 53 | set_output_delay -clock sdram_clk_pin -min [expr -1.0 - 0.1] [get_ports sd_data*] 54 | 55 | set_output_delay -clock sdram_clk_pin -max [expr 1.5 + 0.1] [get_ports sd_addr*] 56 | set_output_delay -clock sdram_clk_pin -min [expr -1.0 - 0.1] [get_ports sd_addr*] 57 | 58 | set_output_delay -clock sdram_clk_pin -max [expr 1.5 + 0.1] [get_ports {sd_ba_0 sd_ba_1 sd_cas_n sd_ldqm sd_ras_n sd_udqm sd_we_n}] 59 | set_output_delay -clock sdram_clk_pin -min [expr -1.0 - 0.1] [get_ports {sd_ba_0 sd_ba_1 sd_cas_n sd_ldqm sd_ras_n sd_udqm sd_we_n}] 60 | 61 | 62 | # Multicycles 63 | 64 | # Without this, Quartus shoots for the wrong clock edge on inputs, due to the phase-shifted clock. 65 | set_multicycle_path -from [get_clocks {sdram_clk_pin}] -to [get_clocks {b2v_inst|altpll_component|auto_generated|pll1|clk[1]}] -setup -end 2 66 | 67 | -------------------------------------------------------------------------------- /fampiga/chameleonv2/fampiga_v2.sdc: -------------------------------------------------------------------------------- 1 | #************************************************************ 2 | # THIS IS A WIZARD-GENERATED FILE. 3 | # 4 | # Version 11.1 Build 216 11/23/2011 Service Pack 1 SJ Web Edition 5 | # 6 | #************************************************************ 7 | 8 | # Copyright (C) 1991-2011 Altera Corporation 9 | # Your use of Altera Corporation's design tools, logic functions 10 | # and other software and tools, and its AMPP partner logic 11 | # functions, and any output files from any of the foregoing 12 | # (including device programming or simulation files), and any 13 | # associated documentation or information are expressly subject 14 | # to the terms and conditions of the Altera Program License 15 | # Subscription Agreement, Altera MegaCore Function License 16 | # Agreement, or other applicable license agreement, including, 17 | # without limitation, that your use is for the sole purpose of 18 | # programming logic devices manufactured by Altera and sold by 19 | # Altera or its authorized distributors. Please refer to the 20 | # applicable agreement for further details. 21 | 22 | 23 | 24 | # Clock constraints 25 | 26 | create_clock -name "clk50m" -period 20.000ns [get_ports {clk50m}] -waveform {0.000 10.00} 27 | 28 | # Automatically constrain PLL and other generated clocks 29 | derive_pll_clocks 30 | 31 | create_generated_clock -name sdram_clk_pin -source [get_nets {b2v_inst|altpll_component|auto_generated|wire_pll1_clk[0]}] [get_ports {ram_clk}] 32 | create_generated_clock -name spi_clk -source [get_nets {b2v_inst|altpll_component|auto_generated|wire_pll1_clk[1]}] -divide_by 8 [get_registers {cfide:b2v_inst3|sck}] 33 | #************************************************************** 34 | # Set Clock Uncertainty 35 | #************************************************************** 36 | 37 | derive_clock_uncertainty; 38 | 39 | #************************************************************** 40 | # Set Input Delay 41 | #************************************************************** 42 | 43 | # Very narrow window here. 44 | set_input_delay -clock sdram_clk_pin -max [expr 5.4 + 1.0 + 0.1] [get_ports ram_d*] 45 | set_input_delay -clock sdram_clk_pin -min [expr 1 + 0.1] [get_ports ram_d*] 46 | 47 | #************************************************************** 48 | # Set Output Delay 49 | #************************************************************** 50 | 51 | # Routing delay on outputs should pretty much cancel out, since they'll apply to the clock too, yes? 52 | set_output_delay -clock sdram_clk_pin -max [expr 1.5 + 0.1] [get_ports ram_d*] 53 | set_output_delay -clock sdram_clk_pin -min [expr -1.0 - 0.1] [get_ports ram_d*] 54 | 55 | set_output_delay -clock sdram_clk_pin -max [expr 1.5 + 0.1] [get_ports ram_a*] 56 | set_output_delay -clock sdram_clk_pin -min [expr -1.0 - 0.1] [get_ports ram_a*] 57 | 58 | set_output_delay -clock sdram_clk_pin -max [expr 1.5 + 0.1] [get_ports {ram_*dqm ram_*as ram_we ram_ba*}] 59 | set_output_delay -clock sdram_clk_pin -min [expr -1.0 - 0.1] [get_ports {ram_*dqm ram_*as ram_we ram_ba*}] 60 | 61 | 62 | 63 | # Multicycles 64 | 65 | # Without this, Quartus shoots for the wrong clock edge on inputs, due to the phase-shifted clock. 66 | set_multicycle_path -from [get_clocks {sdram_clk_pin}] -to [get_clocks {b2v_inst|altpll_component|auto_generated|pll1|clk[1]}] -setup -end 2 67 | 68 | -------------------------------------------------------------------------------- /fampiga/minimig/Clock.v: -------------------------------------------------------------------------------- 1 | // Copyright 2006, 2007 Dennis van Weeren 2 | // 3 | // This file is part of Minimig 4 | // 5 | // Minimig is free software; you can redistribute it and/or modify 6 | // it under the terms of the GNU General Public License as published by 7 | // the Free Software Foundation; either version 3 of the License, or 8 | // (at your option) any later version. 9 | // 10 | // Minimig is distributed in the hope that it will be useful, 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | // GNU General Public License for more details. 14 | // 15 | // You should have received a copy of the GNU General Public License 16 | // along with this program. If not, see . 17 | // 18 | // 19 | // 20 | 21 | // Master clock generator for minimig 22 | // This module generates all necessary clocks from the 4.433619 PAL clock 23 | // JB: 24 | // 2008-03-01 - added ddl for generating in phase system clock with 28MHz clock 25 | // 2008-09-23 - added c1 and c3 clock enable outputs 26 | // 2008-10-15 - adapted e clock enable to be in sync with cck 27 | // 2009-05-23 - eclk modification 28 | 29 | module clock_generator 30 | ( 31 | // input mclk, // 4.433619 MHz master clock input 32 | input clk28m, // 28.37516 MHz clock output 33 | output reg c1, // clk28m clock domain signal synchronous with clk signal 34 | output reg c3, // clk28m clock domain signal synchronous with clk signal delayed by 90 degrees 35 | output cck, // colour clock from Agnus hpos[0] (3.54 MHz) 36 | input clk, // 7.09379 MHz clock output 37 | // output cpu_clk, 38 | // input turbo, 39 | output [9:0] eclk // 0.709379 MHz clock enable output (clk domain pulse) 40 | ); 41 | 42 | // __ __ __ __ __ 43 | // clk28m __/ \__/ \__/ \__/ \__/ 44 | // ___________ __ 45 | // clk __/ \___________/ 46 | // ___________ __ 47 | // c1 __/ \___________/ <- clk28m domain 48 | // ___________ 49 | // c3 ________/ \________ <- clk28m domain 50 | // 51 | 52 | 53 | reg [3:0] e_cnt; //used to generate e clock enable 54 | 55 | // E clock counter 56 | always @(posedge clk) 57 | if (e_cnt[3] && e_cnt[0]) 58 | e_cnt[3:0] <= 0; 59 | else 60 | e_cnt[3:0] <= (e_cnt[3:0] + 1); 61 | 62 | // CCK clock output 63 | assign cck = (!e_cnt[0]); 64 | 65 | assign eclk[0] = ~e_cnt[3] & ~e_cnt[2] & ~e_cnt[1] & ~e_cnt[0]; // e_cnt == 0 66 | assign eclk[1] = ~e_cnt[3] & ~e_cnt[2] & ~e_cnt[1] & e_cnt[0]; // e_cnt == 1 67 | assign eclk[2] = ~e_cnt[3] & ~e_cnt[2] & e_cnt[1] & ~e_cnt[0]; // e_cnt == 2 68 | assign eclk[3] = ~e_cnt[3] & ~e_cnt[2] & e_cnt[1] & e_cnt[0]; // e_cnt == 3 69 | assign eclk[4] = ~e_cnt[3] & e_cnt[2] & ~e_cnt[1] & ~e_cnt[0]; // e_cnt == 4 70 | assign eclk[5] = ~e_cnt[3] & e_cnt[2] & ~e_cnt[1] & e_cnt[0]; // e_cnt == 5 71 | assign eclk[6] = ~e_cnt[3] & e_cnt[2] & e_cnt[1] & ~e_cnt[0]; // e_cnt == 6 72 | assign eclk[7] = ~e_cnt[3] & e_cnt[2] & e_cnt[1] & e_cnt[0]; // e_cnt == 7 73 | assign eclk[8] = e_cnt[3] & ~e_cnt[2] & ~e_cnt[1] & ~e_cnt[0]; // e_cnt == 8 74 | assign eclk[9] = e_cnt[3] & ~e_cnt[2] & ~e_cnt[1] & e_cnt[0]; // e_cnt == 9 75 | 76 | always @(posedge clk28m) 77 | c3 <= clk; 78 | 79 | always @(posedge clk28m) 80 | c1 <= ~c3; 81 | 82 | endmodule 83 | -------------------------------------------------------------------------------- /src/include/machine/_default_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * $Id: _default_types.h,v 1.2 2008/06/11 22:14:54 jjohnstn Exp $ 3 | */ 4 | 5 | #ifndef _MACHINE__DEFAULT_TYPES_H 6 | #define _MACHINE__DEFAULT_TYPES_H 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | /* 13 | * Guess on types by examining *_MIN / *_MAX defines. 14 | */ 15 | #if defined(__GNUC__) && ((__GNUC__ >= 4) || (__GNUC__ >= 3 ) \ 16 | && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ > 2 )) 17 | /* GCC >= 3.3.0 has ____ implicitly defined. */ 18 | #define __EXP(x) __##x##__ 19 | #else 20 | /* Fall back to POSIX versions from */ 21 | #define __EXP(x) x 22 | #include 23 | #endif 24 | 25 | #if __EXP(SCHAR_MAX) == 0x7f 26 | typedef signed char __int8_t ; 27 | typedef unsigned char __uint8_t ; 28 | #define ___int8_t_defined 1 29 | #endif 30 | 31 | #if __EXP(INT_MAX) == 0x7fff 32 | typedef signed int __int16_t; 33 | typedef unsigned int __uint16_t; 34 | #define ___int16_t_defined 1 35 | #elif __EXP(SHRT_MAX) == 0x7fff 36 | typedef signed short __int16_t; 37 | typedef unsigned short __uint16_t; 38 | #define ___int16_t_defined 1 39 | #elif __EXP(SCHAR_MAX) == 0x7fff 40 | typedef signed char __int16_t; 41 | typedef unsigned char __uint16_t; 42 | #define ___int16_t_defined 1 43 | #endif 44 | 45 | #if ___int16_t_defined 46 | typedef __int16_t __int_least16_t; 47 | typedef __uint16_t __uint_least16_t; 48 | #define ___int_least16_t_defined 1 49 | 50 | #if !___int8_t_defined 51 | typedef __int16_t __int_least8_t; 52 | typedef __uint16_t __uint_least8_t; 53 | #define ___int_least8_t_defined 1 54 | #endif 55 | #endif 56 | 57 | #if __EXP(INT_MAX) == 0x7fffffffL 58 | typedef signed int __int32_t; 59 | typedef unsigned int __uint32_t; 60 | #define ___int32_t_defined 1 61 | #elif __EXP(LONG_MAX) == 0x7fffffffL 62 | typedef signed long __int32_t; 63 | typedef unsigned long __uint32_t; 64 | #define ___int32_t_defined 1 65 | #elif __EXP(SHRT_MAX) == 0x7fffffffL 66 | typedef signed short __int32_t; 67 | typedef unsigned short __uint32_t; 68 | #define ___int32_t_defined 1 69 | #elif __EXP(SCHAR_MAX) == 0x7fffffffL 70 | typedef signed char __int32_t; 71 | typedef unsigned char __uint32_t; 72 | #define ___int32_t_defined 1 73 | #endif 74 | 75 | #if ___int32_t_defined 76 | typedef __int32_t __int_least32_t; 77 | typedef __uint32_t __uint_least32_t; 78 | #define ___int_least32_t_defined 1 79 | 80 | #if !___int8_t_defined 81 | typedef __int32_t __int_least8_t; 82 | typedef __uint32_t __uint_least8_t; 83 | #define ___int_least8_t_defined 1 84 | #endif 85 | #if !___int16_t_defined 86 | typedef __int32_t __int_least16_t; 87 | typedef __uint32_t __uint_least16_t; 88 | #define ___int_least16_t_defined 1 89 | #endif 90 | #endif 91 | 92 | #if __EXP(LONG_MAX) > 0x7fffffff 93 | typedef signed long __int64_t; 94 | typedef unsigned long __uint64_t; 95 | #define ___int64_t_defined 1 96 | 97 | /* GCC has __LONG_LONG_MAX__ */ 98 | #elif defined(__LONG_LONG_MAX__) && (__LONG_LONG_MAX__ > 0x7fffffff) 99 | typedef signed long long __int64_t; 100 | typedef unsigned long long __uint64_t; 101 | #define ___int64_t_defined 1 102 | 103 | /* POSIX mandates LLONG_MAX in */ 104 | #elif defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) 105 | typedef signed long long __int64_t; 106 | typedef unsigned long long __uint64_t; 107 | #define ___int64_t_defined 1 108 | 109 | #elif __EXP(INT_MAX) > 0x7fffffff 110 | typedef signed int __int64_t; 111 | typedef unsigned int __uint64_t; 112 | #define ___int64_t_defined 1 113 | #endif 114 | 115 | #undef __EXP 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | 121 | #endif /* _MACHINE__DEFAULT_TYPES_H */ 122 | -------------------------------------------------------------------------------- /src/hardware.h: -------------------------------------------------------------------------------- 1 | //#define MCLK 48000000 2 | //#define FWS 1 // Flash wait states 3 | // 4 | //#define DISKLED AT91C_PIO_PA10 5 | //#define MMC_CLKEN AT91C_PIO_PA24 6 | //#define MMC_SEL AT91C_PIO_PA27 7 | //#define DIN AT91C_PIO_PA20 8 | //#define CCLK AT91C_PIO_PA4 9 | //#define PROG_B AT91C_PIO_PA9 10 | //#define INIT_B AT91C_PIO_PA7 11 | //#define DONE AT91C_PIO_PA8 12 | //#define FPGA0 AT91C_PIO_PA26 13 | //#define FPGA1 AT91C_PIO_PA25 14 | //#define FPGA2 AT91C_PIO_PA15 15 | //#define BUTTON AT91C_PIO_PA28 16 | 17 | #define DISKLED_ON // *AT91C_PIOA_SODR = DISKLED; 18 | #define DISKLED_OFF // *AT91C_PIOA_CODR = DISKLED; 19 | 20 | #define EnableCard() *(volatile unsigned short *)0xda4004=0x02 21 | #define DisableCard() *(volatile unsigned short *)0xda4004=0x03 22 | #define EnableFpga() *(volatile unsigned short *)0xda4004=0x10 23 | #define DisableFpga() *(volatile unsigned short *)0xda4004=0x11 24 | #define EnableOsd() *(volatile unsigned short *)0xda4004=0x20 25 | #define DisableOsd() *(volatile unsigned short *)0xda4004=0x21 26 | #define EnableDMode() *(volatile unsigned short *)0xda4004=0x40 27 | #define DisableDMode() *(volatile unsigned short *)0xda4004=0x41 28 | 29 | #define SPI_slow() *(volatile unsigned short *)0xda4008=0x20 30 | #define SPI_fast() *(volatile unsigned short *)0xda4008=0x01 //14MHz/2 31 | 32 | #ifdef __GNUC__ 33 | // Yuk. The following monstrosity does a dummy read from the timer register, writes, then reads from 34 | // the SPI register. Doing it this way works around a timing issue with ADF writing when GCC optimisation is turned on. 35 | //#define SPI(x) (*(volatile unsigned short *)0xDEE010,*(volatile unsigned char *)0xda4000=x,*(volatile unsigned char *)0xda4000) 36 | 37 | #define SPI(x) (*(volatile unsigned char *)0xda4000=x,*(volatile unsigned char *)0xda4000) 38 | 39 | #define SPIN (*(volatile unsigned short *)0xDEE010) // Waste a few cycles to let the FPGA catch up 40 | 41 | // A 16-bit register for platform-specific config. 42 | // On read: 43 | // Bits 3:0 -> memory size. (1< Turbo chipram supported 45 | // Bit 5 -> Reconfig supportred 46 | 47 | // On write: 48 | // Bits 1:0 -> Zorro II Fast ram memory config: 00-> off, 01->2mb, 10->4mb, 11->8mb 49 | // Bit 15 -> Turbo chipram enable/disable 50 | 51 | #define PLATFORM (*(volatile unsigned short *)0xDEE014) 52 | #define PLATFORM_TURBOCHIP 4 53 | #define PLATFORM_RECONFIG 5 54 | #define PLATFORM_ACTIONREPLAY 6 55 | 56 | // Write to this register to reconfigure the FPGA on devices which support such operations. 57 | #define RECONFIGURE (*(volatile unsigned short *)0xDEE016) 58 | 59 | 60 | // static inline unsigned char SPI(unsigned char o) 61 | //{ 62 | // volatile unsigned char *ptr = (volatile unsigned char *)0xda4000; 63 | // *ptr = o; 64 | // return *ptr; 65 | //} 66 | #else 67 | #define SPI *(unsigned char *)0xda4000= 68 | #define SPIN 69 | #endif 70 | 71 | #define RDSPI *(volatile unsigned char *)0xda4001 72 | #define RS232 *(volatile unsigned char *)0xda8001= 73 | 74 | 75 | //void USART_Init(unsigned long baudrate); 76 | //void USART_Write(unsigned char c); 77 | // 78 | //void SPI_Init(void); 79 | //unsigned char SPI(unsigned char outByte); 80 | //void SPI_Wait4XferEnd(void); 81 | //void EnableCard(void); 82 | //void DisableCard(void); 83 | //void EnableFpga(void); 84 | //void DisableFpga(void); 85 | //void EnableOsd(void); 86 | //void DisableOsd(void); 87 | unsigned long CheckButton(void); 88 | void Timer_Init(void); 89 | unsigned long GetTimer(unsigned long offset); 90 | unsigned long CheckTimer(unsigned long t); 91 | void WaitTimer(unsigned long time); 92 | void ConfigFastRAM(unsigned char memory); 93 | void Reconfigure(); 94 | 95 | 96 | -------------------------------------------------------------------------------- /src/hdd_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef HDD_INTERNAL_H 2 | #define HDD_INTERNAL_H 3 | 4 | // Structure definitions for RDB emulation. 5 | // For hardfiles that have no RDB information, we'll just create a single-partition RDB and Part block 6 | // on blocks 0 and 1. All other blocks within the first cylinder will be translated into the hardfile 7 | 8 | struct RigidDiskBlock { 9 | unsigned long rdb_ID; // "RDSK" 10 | unsigned long rdb_Summedlongs; // 0x40 11 | long rdb_ChkSum; // Sum to zero 12 | unsigned long rdb_HostID; // 0x07 13 | unsigned long rdb_BlockBytes; // 0x200 14 | unsigned long rdb_Flags; // 0x12 (Disk ID valid, no LUNs after this one) 15 | unsigned long rdb_BadBlockList; // -1 since we don't provide one 16 | unsigned long rdb_PartitionList; // 1 17 | unsigned long rdb_FileSysHeaderList; // -1 18 | unsigned long rdb_DriveInit; // -1 19 | unsigned long rdb_Reserved1[6]; // 0xffffffff 20 | unsigned long rdb_Cylinders; 21 | unsigned long rdb_Sectors; 22 | unsigned long rdb_Heads; 23 | unsigned long rdb_Interleave; // 1 24 | unsigned long rdb_Park; // =Cylinder count 25 | unsigned long rdb_Reserved2[3]; 26 | unsigned long rdb_WritePreComp; // High cylinder ? 27 | unsigned long rdb_ReducedWrite; // High cylinder ? 28 | unsigned long rdb_StepRate; // 3 ? 29 | unsigned long rdb_Reserved3[5]; 30 | unsigned long rdb_RDBBlocksLo; // block zero 31 | unsigned long rdb_RDBBlocksHi; // block one 32 | unsigned long rdb_LoCylinder; // 1 33 | unsigned long rdb_HiCylinder; // From the hardfile: cylinder count -1 34 | unsigned long rdb_CylBlocks; // From the hardfile: heads * sectors 35 | unsigned long rdb_AutoParkSeconds; // zero 36 | unsigned long rdb_HighRDSKBlock; // 1 37 | unsigned long rdb_Reserved4; 38 | char rdb_DiskVendor[8]; // "Don't" 39 | char rdb_DiskProduct[16]; // " repartition!" 40 | char rdb_DiskRevision[4]; 41 | char rdb_ControllerVendor[8]; 42 | char rdb_ControllerProduct[16]; 43 | char rdb_ControllerRevision[4]; 44 | unsigned long rdb_Reserved5[10]; 45 | }; 46 | 47 | struct DosEnvec { 48 | unsigned long de_TableSize; // Size of Environment vector - 0x10 49 | unsigned long de_SizeBlock; // in longwords - 0x80 50 | unsigned long de_SecOrg; // 0 51 | unsigned long de_Surfaces; // Heads? 52 | unsigned long de_SectorPerBlock; // 1 53 | unsigned long de_BlocksPerTrack; 54 | unsigned long de_Reserved; // 2 ? 55 | unsigned long de_PreAlloc; // 0 56 | unsigned long de_Interleave; // 0 57 | unsigned long de_LowCyl; 58 | unsigned long de_HighCyl; 59 | unsigned long de_NumBuffers; // 30 60 | unsigned long de_BufMemType; // 0 - any available 61 | unsigned long de_MaxTransfer; // 0x00ffffff 62 | unsigned long de_Mask; // 0x7ffffffe 63 | long de_BootPri; // 0 64 | unsigned long de_DosType; // 0x444f5301 or 3 65 | // Extra fields 66 | unsigned long de_Baud; 67 | unsigned long de_Control; 68 | unsigned long de_BootBlocks; 69 | }; 70 | 71 | 72 | struct PartitionBlock { 73 | unsigned long pb_ID; // "PART" 74 | unsigned long pb_Summedlongs; // 0x40 75 | long pb_ChkSum; // Sum to zero 76 | unsigned long pb_HostID; // 0x07 77 | unsigned long pb_Next; // -1 78 | unsigned long pb_Flags; // 1 - Bootable 79 | unsigned long pb_Reserved1[2]; // 0 80 | unsigned long pb_DevFlags; // 0 81 | char pb_DriveName[32]; // 0x03"DH0" 82 | unsigned long pb_Reserved2[15]; 83 | struct DosEnvec pb_Environment; 84 | unsigned long pb_EReserved[12]; /* reserved for future environment vector */ 85 | }; 86 | 87 | #endif /* HDD_INTERNAL_H */ 88 | 89 | -------------------------------------------------------------------------------- /fampiga/chameleon/bank_mapper.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2011 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.1")) 22 | (symbol 23 | (rect 16 16 272 272) 24 | (text "bank_mapper" (rect 5 0 82 12)(font "Arial" )) 25 | (text "inst" (rect 8 240 36 252)(font "Arial" )) 26 | (port 27 | (pt 0 32) 28 | (input) 29 | (text "chip0" (rect 0 0 35 12)(font "Arial" )) 30 | (text "chip0" (rect 21 27 56 39)(font "Arial" )) 31 | (line (pt 0 32)(pt 16 32)(line_width 1)) 32 | ) 33 | (port 34 | (pt 0 48) 35 | (input) 36 | (text "chip1" (rect 0 0 35 12)(font "Arial" )) 37 | (text "chip1" (rect 21 43 56 55)(font "Arial" )) 38 | (line (pt 0 48)(pt 16 48)(line_width 1)) 39 | ) 40 | (port 41 | (pt 0 64) 42 | (input) 43 | (text "chip2" (rect 0 0 35 12)(font "Arial" )) 44 | (text "chip2" (rect 21 59 56 71)(font "Arial" )) 45 | (line (pt 0 64)(pt 16 64)(line_width 1)) 46 | ) 47 | (port 48 | (pt 0 80) 49 | (input) 50 | (text "chip3" (rect 0 0 35 12)(font "Arial" )) 51 | (text "chip3" (rect 21 75 56 87)(font "Arial" )) 52 | (line (pt 0 80)(pt 16 80)(line_width 1)) 53 | ) 54 | (port 55 | (pt 0 96) 56 | (input) 57 | (text "slow0" (rect 0 0 35 12)(font "Arial" )) 58 | (text "slow0" (rect 21 91 56 103)(font "Arial" )) 59 | (line (pt 0 96)(pt 16 96)(line_width 1)) 60 | ) 61 | (port 62 | (pt 0 112) 63 | (input) 64 | (text "slow1" (rect 0 0 35 12)(font "Arial" )) 65 | (text "slow1" (rect 21 107 56 119)(font "Arial" )) 66 | (line (pt 0 112)(pt 16 112)(line_width 1)) 67 | ) 68 | (port 69 | (pt 0 128) 70 | (input) 71 | (text "slow2" (rect 0 0 35 12)(font "Arial" )) 72 | (text "slow2" (rect 21 123 56 135)(font "Arial" )) 73 | (line (pt 0 128)(pt 16 128)(line_width 1)) 74 | ) 75 | (port 76 | (pt 0 144) 77 | (input) 78 | (text "kick" (rect 0 0 28 12)(font "Arial" )) 79 | (text "kick" (rect 21 139 49 151)(font "Arial" )) 80 | (line (pt 0 144)(pt 16 144)(line_width 1)) 81 | ) 82 | (port 83 | (pt 0 160) 84 | (input) 85 | (text "cart" (rect 0 0 28 12)(font "Arial" )) 86 | (text "cart" (rect 21 155 49 167)(font "Arial" )) 87 | (line (pt 0 160)(pt 16 160)(line_width 1)) 88 | ) 89 | (port 90 | (pt 0 176) 91 | (input) 92 | (text "aron" (rect 0 0 28 12)(font "Arial" )) 93 | (text "aron" (rect 21 171 49 183)(font "Arial" )) 94 | (line (pt 0 176)(pt 16 176)(line_width 1)) 95 | ) 96 | (port 97 | (pt 0 192) 98 | (input) 99 | (text "ecs" (rect 0 0 21 12)(font "Arial" )) 100 | (text "ecs" (rect 21 187 42 199)(font "Arial" )) 101 | (line (pt 0 192)(pt 16 192)(line_width 1)) 102 | ) 103 | (port 104 | (pt 0 208) 105 | (input) 106 | (text "memory_config[3..0]" (rect 0 0 134 12)(font "Arial" )) 107 | (text "memory_config[3..0]" (rect 21 203 155 215)(font "Arial" )) 108 | (line (pt 0 208)(pt 16 208)(line_width 3)) 109 | ) 110 | (port 111 | (pt 256 32) 112 | (output) 113 | (text "bank[7..0]" (rect 0 0 70 12)(font "Arial" )) 114 | (text "bank[7..0]" (rect 165 27 235 39)(font "Arial" )) 115 | (line (pt 256 32)(pt 240 32)(line_width 3)) 116 | ) 117 | (drawing 118 | (rectangle (rect 16 16 240 240)(line_width 1)) 119 | ) 120 | ) 121 | -------------------------------------------------------------------------------- /fampiga/board/chameleon2_io_shiftreg.vhd: -------------------------------------------------------------------------------- 1 | -- ----------------------------------------------------------------------- 2 | -- 3 | -- Turbo Chameleon 64 4 | -- 5 | -- Multi purpose FPGA expansion for the Commodore 64 computer 6 | -- 7 | -- ----------------------------------------------------------------------- 8 | -- Copyright 2005-2018 by Peter Wendrich (pwsoft@syntiac.com) 9 | -- http://www.syntiac.com 10 | -- 11 | -- This source file is free software: you can redistribute it and/or modify 12 | -- it under the terms of the GNU Lesser General Public License as published 13 | -- by the Free Software Foundation, either version 3 of the License, or 14 | -- (at your option) any later version. 15 | -- 16 | -- This source file is distributed in the hope that it will be useful, 17 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | -- GNU General Public License for more details. 20 | -- 21 | -- You should have received a copy of the GNU General Public License 22 | -- along with this program. If not, see . 23 | -- 24 | -- ----------------------------------------------------------------------- 25 | -- I/O controller entity for the shiftregister controlling PS/2, 26 | -- LEDs and reset signals on Turbo Chameleon 64 second edition. 27 | -- 28 | -- ----------------------------------------------------------------------- 29 | -- clk - System clock 30 | -- 31 | -- ser_out_clk - Serial clock, connect on toplevel to port with same name 32 | -- ser_out_dat - Serial data, connect on toplevel to port with same name 33 | -- ser_out_rclk - Serial strobe, connect on toplevel to port with same name 34 | -- 35 | -- reset_c64 - Active high, pulls reset on the cartridge port 36 | -- reset_iec - Active high, pulls reset on teh IEC connector 37 | -- ps2_mouse_clk - Open drain output for PS/2 mouse clock (active low) 38 | -- ps2_mouse_dat - Open drain output for PS/2 mouse data (active low) 39 | -- ps2_keybard_clk - Open drain output for PS/2 keyboard clock (active low) 40 | -- ps2_keybard_dat - Open drain output for PS/2 keyboard data (active low) 41 | -- led_green - Active high, enable the green LED 42 | -- led_red - Active high, enable the red LED 43 | -- ----------------------------------------------------------------------- 44 | 45 | library ieee; 46 | use ieee.std_logic_1164.all; 47 | use ieee.numeric_std.all; 48 | 49 | -- ----------------------------------------------------------------------- 50 | 51 | entity chameleon2_io_shiftreg is 52 | port ( 53 | clk : in std_logic; 54 | 55 | ser_out_clk : out std_logic; 56 | ser_out_dat : out std_logic; 57 | ser_out_rclk : out std_logic; 58 | 59 | reset_c64 : in std_logic; 60 | reset_iec : in std_logic; 61 | ps2_mouse_clk : in std_logic; 62 | ps2_mouse_dat : in std_logic; 63 | ps2_keyboard_clk : in std_logic; 64 | ps2_keyboard_dat : in std_logic; 65 | led_green : in std_logic; 66 | led_red : in std_logic 67 | ); 68 | end entity; 69 | 70 | architecture rtl of chameleon2_io_shiftreg is 71 | signal state_reg : unsigned(6 downto 0) := (others => '0'); 72 | signal clk_reg : std_logic := '0'; 73 | signal dat_reg : std_logic := '0'; 74 | signal rclk_reg : std_logic := '1'; 75 | begin 76 | ser_out_clk <= clk_reg; 77 | ser_out_dat <= dat_reg; 78 | ser_out_rclk <= rclk_reg; 79 | 80 | process(clk) 81 | begin 82 | if rising_edge(clk) then 83 | state_reg <= state_reg + 1; 84 | clk_reg <= state_reg(2) and (not state_reg(6)); 85 | rclk_reg <= state_reg(2) and state_reg(6); 86 | case state_reg(6 downto 3) is 87 | when "0000" => dat_reg <= reset_c64; 88 | when "0001" => dat_reg <= reset_iec; 89 | when "0010" => dat_reg <= not ps2_mouse_clk; 90 | when "0011" => dat_reg <= not ps2_mouse_dat; 91 | when "0100" => dat_reg <= not ps2_keyboard_clk; 92 | when "0101" => dat_reg <= not ps2_keyboard_dat; 93 | when "0110" => dat_reg <= not led_green; 94 | when "0111" => dat_reg <= not led_red; 95 | when "1000" => null; 96 | when others => state_reg <= (others => '0'); 97 | end case; 98 | end if; 99 | end process; 100 | end architecture; 101 | -------------------------------------------------------------------------------- /fampiga/board/chameleon2_e.vhd: -------------------------------------------------------------------------------- 1 | -- ----------------------------------------------------------------------- 2 | -- 3 | -- Turbo Chameleon 64 4 | -- 5 | -- Multi purpose FPGA expansion for the Commodore 64 computer 6 | -- 7 | -- ----------------------------------------------------------------------- 8 | -- Copyright 2005-2019 by Peter Wendrich (pwsoft@syntiac.com) 9 | -- http://www.syntiac.com 10 | -- 11 | -- This source file is free software: you can redistribute it and/or modify 12 | -- it under the terms of the GNU Lesser General Public License as published 13 | -- by the Free Software Foundation, either version 3 of the License, or 14 | -- (at your option) any later version. 15 | -- 16 | -- This source file is distributed in the hope that it will be useful, 17 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | -- GNU General Public License for more details. 20 | -- 21 | -- You should have received a copy of the GNU General Public License 22 | -- along with this program. If not, see . 23 | -- 24 | -- ----------------------------------------------------------------------- 25 | -- 26 | -- Default toplevel entity for the Turbo Chameleon 64 second edition 27 | -- 28 | -- ----------------------------------------------------------------------- 29 | 30 | library ieee; 31 | use ieee.std_logic_1164.all; 32 | use ieee.numeric_std.all; 33 | 34 | -- ----------------------------------------------------------------------- 35 | 36 | entity chameleon2 is 37 | port ( 38 | -- Clocks 39 | clk50m : in std_logic; 40 | phi2_n : in std_logic; 41 | dotclk_n : in std_logic; 42 | 43 | -- Buttons 44 | usart_cts : in std_logic; -- Left button 45 | freeze_btn : in std_logic; -- Middle button 46 | reset_btn : in std_logic; -- Right 47 | 48 | -- PS/2, IEC, LEDs 49 | iec_present : in std_logic; 50 | 51 | ps2iec_sel : out std_logic; 52 | ps2iec : in unsigned(3 downto 0); 53 | 54 | ser_out_clk : out std_logic; 55 | ser_out_dat : out std_logic; 56 | ser_out_rclk : out std_logic; 57 | 58 | iec_clk_out : out std_logic; 59 | iec_srq_out : out std_logic; 60 | iec_atn_out : out std_logic; 61 | iec_dat_out : out std_logic; 62 | 63 | -- SPI, Flash and SD-Card 64 | flash_cs : out std_logic; 65 | rtc_cs : out std_logic; 66 | mmc_cs : out std_logic; 67 | mmc_cd : in std_logic; 68 | mmc_wp : in std_logic; 69 | spi_clk : out std_logic; 70 | spi_miso : in std_logic; 71 | spi_mosi : out std_logic; 72 | 73 | -- Clock port 74 | clock_ior : out std_logic; 75 | clock_iow : out std_logic; 76 | 77 | -- C64 bus 78 | reset_in : in std_logic; 79 | 80 | ioef : in std_logic; 81 | romlh : in std_logic; 82 | 83 | dma_out : out std_logic; 84 | game_out : out std_logic; 85 | exrom_out : out std_logic; 86 | 87 | irq_in : in std_logic; 88 | irq_out : out std_logic; 89 | nmi_in : in std_logic; 90 | nmi_out : out std_logic; 91 | ba_in : in std_logic; 92 | rw_in : in std_logic; 93 | rw_out : out std_logic; 94 | 95 | sa_dir : out std_logic; 96 | sa_oe : out std_logic; 97 | sa15_out : out std_logic; 98 | low_a : inout unsigned(15 downto 0); 99 | 100 | sd_dir : out std_logic; 101 | sd_oe : out std_logic; 102 | low_d : inout unsigned(7 downto 0); 103 | 104 | -- SDRAM 105 | ram_clk : out std_logic; 106 | ram_ldqm : out std_logic; 107 | ram_udqm : out std_logic; 108 | ram_ras : out std_logic; 109 | ram_cas : out std_logic; 110 | ram_we : out std_logic; 111 | ram_ba : out unsigned(1 downto 0); 112 | ram_a : out unsigned(12 downto 0); 113 | ram_d : inout unsigned(15 downto 0); 114 | 115 | -- IR eye 116 | ir_data : in std_logic; 117 | 118 | -- USB micro 119 | usart_clk : in std_logic; 120 | usart_rts : in std_logic; 121 | usart_rx : out std_logic; 122 | usart_tx : in std_logic; 123 | 124 | -- Video output 125 | red : out unsigned(4 downto 0); 126 | grn : out unsigned(4 downto 0); 127 | blu : out unsigned(4 downto 0); 128 | hsync_n : out std_logic; 129 | vsync_n : out std_logic; 130 | 131 | -- Audio output 132 | sigma_l : out std_logic; 133 | sigma_r : out std_logic 134 | ); 135 | end entity; 136 | -------------------------------------------------------------------------------- /fampiga/board/chameleon2_io_ps2iec.vhd: -------------------------------------------------------------------------------- 1 | -- ----------------------------------------------------------------------- 2 | -- 3 | -- Turbo Chameleon 64 4 | -- 5 | -- Multi purpose FPGA expansion for the Commodore 64 computer 6 | -- 7 | -- ----------------------------------------------------------------------- 8 | -- Copyright 2005-2018 by Peter Wendrich (pwsoft@syntiac.com) 9 | -- http://www.syntiac.com 10 | -- 11 | -- This source file is free software: you can redistribute it and/or modify 12 | -- it under the terms of the GNU Lesser General Public License as published 13 | -- by the Free Software Foundation, either version 3 of the License, or 14 | -- (at your option) any later version. 15 | -- 16 | -- This source file is distributed in the hope that it will be useful, 17 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | -- GNU General Public License for more details. 20 | -- 21 | -- You should have received a copy of the GNU General Public License 22 | -- along with this program. If not, see . 23 | -- 24 | -- ----------------------------------------------------------------------- 25 | -- I/O controller entity for the PS2IEC multiplexer. 26 | -- This provides capturing and reading the state of the (multiplexed) 27 | -- PS/2 and IEC lines. 28 | -- 29 | -- ----------------------------------------------------------------------- 30 | -- clk - System clock 31 | -- ps2iec_sel - Select line, connect on toplevel to port with same name 32 | -- ps2iec - Multiplexed signals, connect on toplevel to port with same name 33 | -- 34 | -- ps2_mouse_clk - State of the PS/2 mouse clock signal 35 | -- ps2_mouse_dat - State of the PS/2 mouse data signal 36 | -- ps2_mouse_clk - State of the PS/2 keyboard clock signal 37 | -- ps2_mouse_dat - State of the PS/2 keyboard data signal 38 | -- 39 | -- iec_clk - State of the CLK line on the IEC bus 40 | -- iec_srq - State of the SRQ line on the IEC bus 41 | -- iec_atn - State of the ATN line on the IEC bus 42 | -- iec_dat - State of the DAT line on the IEC bus 43 | -- ----------------------------------------------------------------------- 44 | 45 | library ieee; 46 | use ieee.std_logic_1164.all; 47 | use ieee.numeric_std.all; 48 | 49 | -- ----------------------------------------------------------------------- 50 | 51 | entity chameleon2_io_ps2iec is 52 | port ( 53 | clk : in std_logic; 54 | 55 | -- Mux signals 56 | ps2iec_sel : out std_logic; 57 | ps2iec : in unsigned(3 downto 0); 58 | 59 | -- Decoded 60 | ps2_mouse_clk : out std_logic; 61 | ps2_mouse_dat : out std_logic; 62 | ps2_keyboard_clk : out std_logic; 63 | ps2_keyboard_dat : out std_logic; 64 | 65 | iec_clk : out std_logic; 66 | iec_srq : out std_logic; 67 | iec_atn : out std_logic; 68 | iec_dat : out std_logic 69 | ); 70 | end entity; 71 | 72 | architecture rtl of chameleon2_io_ps2iec is 73 | signal state_reg : unsigned(2 downto 0) := "000"; 74 | 75 | signal ps2iec_reg : unsigned(3 downto 0) := "1111"; 76 | 77 | signal ps2_mouse_clk_reg : std_logic := '1'; 78 | signal ps2_mouse_dat_reg : std_logic := '1'; 79 | signal ps2_keyboard_clk_reg : std_logic := '1'; 80 | signal ps2_keyboard_dat_reg : std_logic := '1'; 81 | 82 | signal iec_clk_reg : std_logic := '1'; 83 | signal iec_srq_reg : std_logic := '1'; 84 | signal iec_atn_reg : std_logic := '1'; 85 | signal iec_dat_reg : std_logic := '1'; 86 | begin 87 | ps2iec_sel <= state_reg(2); 88 | 89 | ps2_mouse_clk <= ps2_mouse_clk_reg; 90 | ps2_mouse_dat <= ps2_mouse_dat_reg; 91 | ps2_keyboard_clk <= ps2_keyboard_clk_reg; 92 | ps2_keyboard_dat <= ps2_keyboard_dat_reg; 93 | 94 | iec_clk <= iec_clk_reg; 95 | iec_srq <= iec_srq_reg; 96 | iec_atn <= iec_atn_reg; 97 | iec_dat <= iec_dat_reg; 98 | 99 | process(clk) 100 | begin 101 | if rising_edge(clk) then 102 | state_reg <= state_reg + 1; 103 | ps2iec_reg <= ps2iec; 104 | if state_reg = "011" then 105 | -- Capture PS2 lines 106 | ps2_mouse_dat_reg <= ps2iec_reg(0); 107 | ps2_mouse_clk_reg <= ps2iec_reg(1); 108 | ps2_keyboard_clk_reg <= ps2iec_reg(2); 109 | ps2_keyboard_dat_reg <= ps2iec_reg(3); 110 | end if; 111 | if state_reg = "111" then 112 | -- Capture IEC lines 113 | iec_atn_reg <= ps2iec_reg(0); 114 | iec_dat_reg <= ps2iec_reg(1); 115 | iec_clk_reg <= ps2iec_reg(2); 116 | iec_srq_reg <= ps2iec_reg(3); 117 | end if; 118 | end if; 119 | end process; 120 | end architecture; 121 | -------------------------------------------------------------------------------- /src/include/_ansi.h: -------------------------------------------------------------------------------- 1 | /* Provide support for both ANSI and non-ANSI environments. */ 2 | 3 | /* Some ANSI environments are "broken" in the sense that __STDC__ cannot be 4 | relied upon to have it's intended meaning. Therefore we must use our own 5 | concoction: _HAVE_STDC. Always use _HAVE_STDC instead of __STDC__ in newlib 6 | sources! 7 | 8 | To get a strict ANSI C environment, define macro __STRICT_ANSI__. This will 9 | "comment out" the non-ANSI parts of the ANSI header files (non-ANSI header 10 | files aren't affected). */ 11 | 12 | #ifndef _ANSIDECL_H_ 13 | #define _ANSIDECL_H_ 14 | 15 | #include 16 | #include 17 | 18 | /* First try to figure out whether we really are in an ANSI C environment. */ 19 | /* FIXME: This probably needs some work. Perhaps sys/config.h can be 20 | prevailed upon to give us a clue. */ 21 | 22 | #ifdef __STDC__ 23 | #define _HAVE_STDC 24 | #endif 25 | 26 | /* ISO C++. */ 27 | 28 | #ifdef __cplusplus 29 | #if !(defined(_BEGIN_STD_C) && defined(_END_STD_C)) 30 | #ifdef _HAVE_STD_CXX 31 | #define _BEGIN_STD_C namespace std { extern "C" { 32 | #define _END_STD_C } } 33 | #else 34 | #define _BEGIN_STD_C extern "C" { 35 | #define _END_STD_C } 36 | #endif 37 | #if defined(__GNUC__) && \ 38 | ( (__GNUC__ >= 4) || \ 39 | ( (__GNUC__ >= 3) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 3) ) ) 40 | #define _NOTHROW __attribute__ ((nothrow)) 41 | #else 42 | #define _NOTHROW throw() 43 | #endif 44 | #endif 45 | #else 46 | #define _BEGIN_STD_C 47 | #define _END_STD_C 48 | #define _NOTHROW 49 | #endif 50 | 51 | #ifdef _HAVE_STDC 52 | #define _PTR void * 53 | #define _AND , 54 | #define _NOARGS void 55 | #define _CONST const 56 | #define _VOLATILE volatile 57 | #define _SIGNED signed 58 | #define _DOTS , ... 59 | #define _VOID void 60 | #ifdef __CYGWIN__ 61 | #define _EXFUN_NOTHROW(name, proto) __cdecl name proto _NOTHROW 62 | #define _EXFUN(name, proto) __cdecl name proto 63 | #define _EXPARM(name, proto) (* __cdecl name) proto 64 | #define _EXFNPTR(name, proto) (__cdecl * name) proto 65 | #else 66 | #define _EXFUN_NOTHROW(name, proto) name proto _NOTHROW 67 | #define _EXFUN(name, proto) name proto 68 | #define _EXPARM(name, proto) (* name) proto 69 | #define _EXFNPTR(name, proto) (* name) proto 70 | #endif 71 | #define _DEFUN(name, arglist, args) name(args) 72 | #define _DEFUN_VOID(name) name(_NOARGS) 73 | #define _CAST_VOID (void) 74 | #ifndef _LONG_DOUBLE 75 | #define _LONG_DOUBLE long double 76 | #endif 77 | #ifndef _LONG_LONG_TYPE 78 | #define _LONG_LONG_TYPE long long 79 | #endif 80 | #ifndef _PARAMS 81 | #define _PARAMS(paramlist) paramlist 82 | #endif 83 | #else 84 | #define _PTR char * 85 | #define _AND ; 86 | #define _NOARGS 87 | #define _CONST 88 | #define _VOLATILE 89 | #define _SIGNED 90 | #define _DOTS 91 | #define _VOID void 92 | #define _EXFUN(name, proto) name() 93 | #define _EXFUN_NOTHROW(name, proto) name() 94 | #define _DEFUN(name, arglist, args) name arglist args; 95 | #define _DEFUN_VOID(name) name() 96 | #define _CAST_VOID 97 | #define _LONG_DOUBLE double 98 | #define _LONG_LONG_TYPE long 99 | #ifndef _PARAMS 100 | #define _PARAMS(paramlist) () 101 | #endif 102 | #endif 103 | 104 | /* Support gcc's __attribute__ facility. */ 105 | 106 | #ifdef __GNUC__ 107 | #define _ATTRIBUTE(attrs) __attribute__ (attrs) 108 | #else 109 | #define _ATTRIBUTE(attrs) 110 | #endif 111 | 112 | /* The traditional meaning of 'extern inline' for GCC is not 113 | to emit the function body unless the address is explicitly 114 | taken. However this behaviour is changing to match the C99 115 | standard, which uses 'extern inline' to indicate that the 116 | function body *must* be emitted. If we are using GCC, but do 117 | not have the new behaviour, we need to use extern inline; if 118 | we are using a new GCC with the C99-compatible behaviour, or 119 | a non-GCC compiler (which we will have to hope is C99, since 120 | there is no other way to achieve the effect of omitting the 121 | function if it isn't referenced) we just use plain 'inline', 122 | which c99 defines to mean more-or-less the same as the Gnu C 123 | 'extern inline'. */ 124 | #if defined(__GNUC__) && !defined(__GNUC_STDC_INLINE__) 125 | /* We're using GCC, but without the new C99-compatible behaviour. */ 126 | #define _ELIDABLE_INLINE extern __inline__ _ATTRIBUTE ((__always_inline__)) 127 | #else 128 | /* We're using GCC in C99 mode, or an unknown compiler which 129 | we just have to hope obeys the C99 semantics of inline. */ 130 | #define _ELIDABLE_INLINE __inline__ 131 | #endif 132 | 133 | #endif /* _ANSIDECL_H_ */ 134 | -------------------------------------------------------------------------------- /src/memcheck.c: -------------------------------------------------------------------------------- 1 | #include "fpga.h" 2 | #include "fdd.h" 3 | #include "hdd.h" 4 | 5 | extern void *heap_low; 6 | 7 | #define CYCLE_LFSR {lfsr<<=1; if(lfsr&0x400000) lfsr|=1; if(lfsr&0x200000) lfsr^=1;} 8 | 9 | #define LFSRSEED 12467 10 | 11 | #define CMD_HDRID 0xAACA 12 | #define SPI(x) (*(volatile unsigned char *)0xda4000=x,*(volatile unsigned char *)0xda4000) 13 | #define EnableFpga() *(volatile unsigned short *)0xda4004=0x10 14 | #define DisableFpga() *(volatile unsigned short *)0xda4004=0x11 15 | 16 | static char *hex(int val, char *buf) 17 | { 18 | int c; 19 | int i; 20 | int nz=1; 21 | if(val) 22 | { 23 | for(i=0;i<8;++i) 24 | { 25 | c=(val>>28)&0xf; 26 | val<<=4; 27 | if(c) 28 | nz=1; // Non-zero? Start printing then. 29 | if(c>9) 30 | c+='A'-10; 31 | else 32 | c+='0'; 33 | if(nz) // If we've encountered only zeroes so far we don't print. 34 | *buf++=c; 35 | } 36 | } 37 | return(buf); 38 | } 39 | 40 | // print message on the boot screen 41 | char BootPrint(const char *text) 42 | { 43 | unsigned char c1, c2, c3, c4; 44 | unsigned char cmd; 45 | const char *p; 46 | unsigned char n; 47 | 48 | p = text; 49 | n = 0; 50 | while (*p++ != 0) 51 | n++; // calculating string length 52 | 53 | cmd = 1; 54 | while (1) 55 | { 56 | EnableFpga(); 57 | c1 = SPI(0x10); // track read command 58 | c2 = SPI(0x01); // disk present 59 | SPI(0); 60 | SPI(0); 61 | c3 = SPI(0); 62 | c4 = SPI(0); 63 | 64 | if (c1 & CMD_RDTRK) 65 | { 66 | if (cmd) 67 | { // command phase 68 | if (c3 == 0x80 && c4 == 0x06) // command packet size must be 12 bytes 69 | { 70 | cmd = 0; 71 | SPI(CMD_HDRID >> 8); // command header 72 | SPI(CMD_HDRID & 0xFF); 73 | SPI(0x00); // cmd: 0x0001 = print text 74 | SPI(0x01); 75 | // data packet size in bytes 76 | SPI(0x00); 77 | SPI(0x00); 78 | SPI(0x00); 79 | SPI(n+2); // +2 because only even byte count is possible to send and we have to send termination zero byte 80 | // don't care 81 | SPI(0x00); 82 | SPI(0x00); 83 | SPI(0x00); 84 | SPI(0x00); 85 | } 86 | else 87 | break; 88 | } 89 | else 90 | { // data phase 91 | if (c3 == 0x80 && c4 == ((n + 2) >> 1)) 92 | { 93 | p = text; 94 | n = c4 << 1; 95 | while (n--) 96 | { 97 | c4 = *p; 98 | SPI(c4); 99 | if (c4) // if current character is not zero go to next one 100 | p++; 101 | } 102 | DisableFpga(); 103 | return 1; 104 | } 105 | else 106 | break; 107 | } 108 | } 109 | DisableFpga(); 110 | } 111 | DisableFpga(); 112 | return 0; 113 | } 114 | 115 | char textbuf[64]="Error at xxxxxxxx, xxxxxxxx, xxxxxxxx"; 116 | char textbuf2[64]="Writing xxxxxxxx longwords starting at xxxxxxxx"; 117 | 118 | int lfsrcheck(volatile int *base,unsigned int size) 119 | { 120 | int counter=size; 121 | int goodreads=0; 122 | int badreads=0; 123 | // Shift left 20 bits to convert to megabytes, then 2 bits right since we're dealing with longwords 124 | 125 | hex(size,&textbuf2[8]); 126 | *hex((int)base,&textbuf2[39])=0; 127 | BootPrint(textbuf2); 128 | 129 | unsigned int lfsr=LFSRSEED; 130 | while(--counter) 131 | { 132 | base[counter]=lfsr; 133 | CYCLE_LFSR; 134 | } 135 | counter=size; 136 | lfsr=LFSRSEED; 137 | while(--counter) 138 | { 139 | if(base[counter]==lfsr) 140 | ++goodreads; 141 | else 142 | { 143 | ++badreads; 144 | hex(4*(((int)base)+size),&textbuf[9]); 145 | hex(base[size],&textbuf[19]); 146 | *hex(lfsr,&textbuf[29])=0; 147 | BootPrint(textbuf); 148 | } 149 | CYCLE_LFSR; 150 | } 151 | return(badreads==0); 152 | } 153 | 154 | 155 | void c_entry(void) 156 | { 157 | char *base; 158 | int size; 159 | BootPrint("Memory checker\n"); 160 | base=(char *)(&heap_low); 161 | size=(512*1024)-(int)base; 162 | if(lfsrcheck((int *)base,size/4-1)) 163 | BootPrint("Passed"); 164 | else 165 | BootPrint("Failed"); 166 | while(1); 167 | } 168 | 169 | -------------------------------------------------------------------------------- /fampiga/board/palclk.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2012 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.2")) 22 | (symbol 23 | (rect 0 0 256 184) 24 | (text "palclk" (rect 111 0 151 16)(font "Arial" (font_size 10))) 25 | (text "inst" (rect 8 169 25 180)(font "Arial" )) 26 | (port 27 | (pt 0 64) 28 | (input) 29 | (text "inclk0" (rect 0 0 30 13)(font "Arial" (font_size 8))) 30 | (text "inclk0" (rect 4 51 29 63)(font "Arial" (font_size 8))) 31 | (line (pt 0 64)(pt 40 64)) 32 | ) 33 | (port 34 | (pt 256 64) 35 | (output) 36 | (text "c0" (rect 0 0 12 13)(font "Arial" (font_size 8))) 37 | (text "c0" (rect 241 51 251 63)(font "Arial" (font_size 8))) 38 | ) 39 | (port 40 | (pt 256 80) 41 | (output) 42 | (text "c1" (rect 0 0 12 13)(font "Arial" (font_size 8))) 43 | (text "c1" (rect 241 67 247 79)(font "Arial" (font_size 8))) 44 | ) 45 | (port 46 | (pt 256 96) 47 | (output) 48 | (text "c2" (rect 0 0 12 13)(font "Arial" (font_size 8))) 49 | (text "c2" (rect 241 83 251 95)(font "Arial" (font_size 8))) 50 | ) 51 | (port 52 | (pt 256 112) 53 | (output) 54 | (text "c3" (rect 0 0 12 13)(font "Arial" (font_size 8))) 55 | (text "c3" (rect 241 99 251 111)(font "Arial" (font_size 8))) 56 | ) 57 | (port 58 | (pt 256 128) 59 | (output) 60 | (text "locked" (rect 0 0 35 13)(font "Arial" (font_size 8))) 61 | (text "locked" (rect 222 115 251 127)(font "Arial" (font_size 8))) 62 | ) 63 | (drawing 64 | (text "Cyclone III" (rect 195 170 433 350)(font "Arial" )) 65 | (text "inclk0 frequency: 8.000 MHz" (rect 50 60 219 130)(font "Arial" )) 66 | (text "Operation Mode: Normal" (rect 50 72 201 154)(font "Arial" )) 67 | (text "Clk " (rect 51 91 112 192)(font "Arial" )) 68 | (text "Ratio" (rect 74 91 169 192)(font "Arial" )) 69 | (text "Ph (dg)" (rect 103 91 235 192)(font "Arial" )) 70 | (text "DC (%)" (rect 137 91 304 192)(font "Arial" )) 71 | (text "c0" (rect 54 104 117 218)(font "Arial" )) 72 | (text "156/11" (rect 72 104 168 218)(font "Arial" )) 73 | (text "-71.47" (rect 105 104 235 218)(font "Arial" )) 74 | (text "50.00" (rect 141 104 304 218)(font "Arial" )) 75 | (text "c1" (rect 54 117 115 244)(font "Arial" )) 76 | (text "156/11" (rect 72 117 168 244)(font "Arial" )) 77 | (text "0.00" (rect 109 117 235 244)(font "Arial" )) 78 | (text "50.00" (rect 141 117 304 244)(font "Arial" )) 79 | (text "c2" (rect 54 130 117 270)(font "Arial" )) 80 | (text "39/11" (rect 74 130 168 270)(font "Arial" )) 81 | (text "0.00" (rect 109 130 235 270)(font "Arial" )) 82 | (text "50.00" (rect 141 130 304 270)(font "Arial" )) 83 | (text "c3" (rect 54 143 117 296)(font "Arial" )) 84 | (text "39/44" (rect 74 143 170 296)(font "Arial" )) 85 | (text "0.00" (rect 109 143 235 296)(font "Arial" )) 86 | (text "50.00" (rect 141 143 304 296)(font "Arial" )) 87 | (line (pt 0 0)(pt 257 0)) 88 | (line (pt 257 0)(pt 257 185)) 89 | (line (pt 0 185)(pt 257 185)) 90 | (line (pt 0 0)(pt 0 185)) 91 | (line (pt 48 89)(pt 169 89)) 92 | (line (pt 48 101)(pt 169 101)) 93 | (line (pt 48 114)(pt 169 114)) 94 | (line (pt 48 127)(pt 169 127)) 95 | (line (pt 48 140)(pt 169 140)) 96 | (line (pt 48 153)(pt 169 153)) 97 | (line (pt 48 89)(pt 48 153)) 98 | (line (pt 69 89)(pt 69 153)(line_width 3)) 99 | (line (pt 100 89)(pt 100 153)(line_width 3)) 100 | (line (pt 134 89)(pt 134 153)(line_width 3)) 101 | (line (pt 168 89)(pt 168 153)) 102 | (line (pt 40 48)(pt 207 48)) 103 | (line (pt 207 48)(pt 207 167)) 104 | (line (pt 40 167)(pt 207 167)) 105 | (line (pt 40 48)(pt 40 167)) 106 | (line (pt 255 64)(pt 207 64)) 107 | (line (pt 255 80)(pt 207 80)) 108 | (line (pt 255 96)(pt 207 96)) 109 | (line (pt 255 112)(pt 207 112)) 110 | (line (pt 255 128)(pt 207 128)) 111 | ) 112 | ) 113 | -------------------------------------------------------------------------------- /fampiga/board/startram.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2009 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.1")) 22 | (symbol 23 | (rect 0 0 216 136) 24 | (text "startram" (rect 84 1 140 17)(font "Arial" (font_size 10))) 25 | (text "inst" (rect 8 120 25 132)(font "Arial" )) 26 | (port 27 | (pt 0 32) 28 | (input) 29 | (text "data[15..0]" (rect 0 0 60 14)(font "Arial" (font_size 8))) 30 | (text "data[15..0]" (rect 4 19 55 32)(font "Arial" (font_size 8))) 31 | (line (pt 0 32)(pt 88 32)(line_width 3)) 32 | ) 33 | (port 34 | (pt 0 48) 35 | (input) 36 | (text "wren" (rect 0 0 30 14)(font "Arial" (font_size 8))) 37 | (text "wren" (rect 4 35 26 48)(font "Arial" (font_size 8))) 38 | (line (pt 0 48)(pt 88 48)(line_width 1)) 39 | ) 40 | (port 41 | (pt 0 64) 42 | (input) 43 | (text "address[10..0]" (rect 0 0 82 14)(font "Arial" (font_size 8))) 44 | (text "address[10..0]" (rect 4 51 69 64)(font "Arial" (font_size 8))) 45 | (line (pt 0 64)(pt 88 64)(line_width 3)) 46 | ) 47 | (port 48 | (pt 0 80) 49 | (input) 50 | (text "byteena[1..0]" (rect 0 0 74 14)(font "Arial" (font_size 8))) 51 | (text "byteena[1..0]" (rect 4 67 66 80)(font "Arial" (font_size 8))) 52 | (line (pt 0 80)(pt 88 80)(line_width 3)) 53 | ) 54 | (port 55 | (pt 0 112) 56 | (input) 57 | (text "clock" (rect 0 0 29 14)(font "Arial" (font_size 8))) 58 | (text "clock" (rect 4 99 27 112)(font "Arial" (font_size 8))) 59 | (line (pt 0 112)(pt 80 112)(line_width 1)) 60 | ) 61 | (port 62 | (pt 216 32) 63 | (output) 64 | (text "q[15..0]" (rect 0 0 42 14)(font "Arial" (font_size 8))) 65 | (text "q[15..0]" (rect 177 19 213 32)(font "Arial" (font_size 8))) 66 | (line (pt 216 32)(pt 136 32)(line_width 3)) 67 | ) 68 | (drawing 69 | (text "16 bits" (rect 108 46 120 74)(font "Arial" )(vertical)) 70 | (text "2048 words" (rect 121 36 133 83)(font "Arial" )(vertical)) 71 | (text "Block type: M9K" (rect 41 116 110 128)(font "Arial" )) 72 | (line (pt 104 24)(pt 136 24)(line_width 1)) 73 | (line (pt 136 24)(pt 136 96)(line_width 1)) 74 | (line (pt 136 96)(pt 104 96)(line_width 1)) 75 | (line (pt 104 96)(pt 104 24)(line_width 1)) 76 | (line (pt 118 58)(pt 123 63)(line_width 1)) 77 | (line (pt 118 62)(pt 123 57)(line_width 1)) 78 | (line (pt 88 27)(pt 96 27)(line_width 1)) 79 | (line (pt 96 27)(pt 96 39)(line_width 1)) 80 | (line (pt 96 39)(pt 88 39)(line_width 1)) 81 | (line (pt 88 39)(pt 88 27)(line_width 1)) 82 | (line (pt 88 34)(pt 90 36)(line_width 1)) 83 | (line (pt 90 36)(pt 88 38)(line_width 1)) 84 | (line (pt 80 36)(pt 88 36)(line_width 1)) 85 | (line (pt 96 32)(pt 104 32)(line_width 3)) 86 | (line (pt 88 43)(pt 96 43)(line_width 1)) 87 | (line (pt 96 43)(pt 96 55)(line_width 1)) 88 | (line (pt 96 55)(pt 88 55)(line_width 1)) 89 | (line (pt 88 55)(pt 88 43)(line_width 1)) 90 | (line (pt 88 50)(pt 90 52)(line_width 1)) 91 | (line (pt 90 52)(pt 88 54)(line_width 1)) 92 | (line (pt 80 52)(pt 88 52)(line_width 1)) 93 | (line (pt 96 48)(pt 104 48)(line_width 1)) 94 | (line (pt 88 59)(pt 96 59)(line_width 1)) 95 | (line (pt 96 59)(pt 96 71)(line_width 1)) 96 | (line (pt 96 71)(pt 88 71)(line_width 1)) 97 | (line (pt 88 71)(pt 88 59)(line_width 1)) 98 | (line (pt 88 66)(pt 90 68)(line_width 1)) 99 | (line (pt 90 68)(pt 88 70)(line_width 1)) 100 | (line (pt 80 68)(pt 88 68)(line_width 1)) 101 | (line (pt 96 64)(pt 104 64)(line_width 3)) 102 | (line (pt 88 75)(pt 96 75)(line_width 1)) 103 | (line (pt 96 75)(pt 96 87)(line_width 1)) 104 | (line (pt 96 87)(pt 88 87)(line_width 1)) 105 | (line (pt 88 87)(pt 88 75)(line_width 1)) 106 | (line (pt 88 82)(pt 90 84)(line_width 1)) 107 | (line (pt 90 84)(pt 88 86)(line_width 1)) 108 | (line (pt 80 84)(pt 88 84)(line_width 1)) 109 | (line (pt 96 80)(pt 104 80)(line_width 3)) 110 | (line (pt 80 112)(pt 80 36)(line_width 1)) 111 | ) 112 | ) 113 | -------------------------------------------------------------------------------- /src/osd.h: -------------------------------------------------------------------------------- 1 | #ifndef OSD_H_INCLUDED 2 | #define OSD_H_INCLUDED 3 | 4 | /*constants*/ 5 | #define OSDCTRLUP 0x01 /*OSD up control*/ 6 | #define OSDCTRLDOWN 0x02 /*OSD down control*/ 7 | #define OSDCTRLSELECT 0x04 /*OSD select control*/ 8 | #define OSDCTRLMENU 0x08 /*OSD menu control*/ 9 | #define OSDCTRLRIGHT 0x10 /*OSD right control*/ 10 | #define OSDCTRLLEFT 0x20 /*OSD left control*/ 11 | 12 | // some constants 13 | #define OSDNLINE 8 // number of lines of OSD 14 | #define OSDLINELEN 256 // single line length in bytes 15 | #define OSDCMDREAD 0x00 // OSD read controller/key status 16 | #define OSDCMDWRITE 0x20 // OSD write video data command 17 | #define OSDCMDENABLE 0x41 // OSD enable command 18 | #define OSDCMDCOLOR 0x60 // OSD enable command 19 | #define OSDCMDDISABLE 0x40 // OSD disable command 20 | #define OSDCMDRST 0x80 // OSD reset command 21 | #define OSDCMDRECONFIG 0x82 // OSD reset command 22 | #define OSDCMDAUTOFIRE 0x84 // OSD autofire command 23 | #define OSDCMDCFGSCL 0xA0 // OSD settings: scanlines effect 24 | #define OSDCMDCFGIDE 0xB0 // OSD enable HDD command 25 | #define OSDCMDCFGFLP 0xC0 // OSD settings: floppy config 26 | #define OSDCMDCFGCHP 0xD0 // OSD settings: chipset config 27 | #define OSDCMDCFGFLT 0xE0 // OSD settings: filter 28 | #define OSDCMDCFGMEM 0xF0 // OSD settings: memory config 29 | #define OSDCMDCFGCPU 0xFC // OSD settings: CPU config 30 | 31 | #define OSDCOLORBITS 0x1F 32 | #define OSDENABLEPARAMBITS 0x1E 33 | #define DISABLE_KEYBOARD 0x02 // disable keyboard while OSD is active 34 | #define OSDINTENSITY 0x04 35 | 36 | #define REPEATDELAY 500 // repeat delay in 1ms units 37 | #define REPEATRATE 50 // repeat rate in 1ms units 38 | #define BUTTONDELAY 20 // repeat rate in 1ms units 39 | 40 | #define KEY_UPSTROKE 0x80 41 | #define KEY_MENU 0x69 42 | #define KEY_PGUP 0x6C 43 | #define KEY_PGDN 0x6D 44 | #define KEY_HOME 0x6A 45 | #define KEY_ESC 0x45 46 | #define KEY_ENTER 0x44 47 | #define KEY_BACK 0x41 48 | #define KEY_SPACE 0x40 49 | #define KEY_UP 0x4C 50 | #define KEY_DOWN 0x4D 51 | #define KEY_LEFT 0x4F 52 | #define KEY_RIGHT 0x4E 53 | #define KEY_F1 0x50 54 | #define KEY_F2 0x51 55 | #define KEY_F3 0x52 56 | #define KEY_F4 0x53 57 | #define KEY_F5 0x54 58 | #define KEY_F6 0x55 59 | #define KEY_F7 0x56 60 | #define KEY_F8 0x57 61 | #define KEY_F9 0x58 62 | #define KEY_F10 0x59 63 | #define KEY_CTRL 0x63 64 | #define KEY_LALT 0x64 65 | #define KEY_KPPLUS 0x5E 66 | #define KEY_KPMINUS 0x4A 67 | #define KEY_KP0 0x0F 68 | 69 | #define CONFIG_TURBO 1 70 | #define CONFIG_NTSC 2 71 | #define CONFIG_A1000 4 72 | #define CONFIG_ECS 8 73 | 74 | #define CONFIG_FLOPPY1X 0 75 | #define CONFIG_FLOPPY2X 1 76 | 77 | #define RESET_NORMAL 0 78 | #define RESET_BOOTLOADER 1 79 | 80 | #define OSD_ARROW_LEFT 1 81 | #define OSD_ARROW_RIGHT 2 82 | 83 | /*functions*/ 84 | void OsdSetTitle(char *s,int arrow); // arrow > 0 = display right arrow in bottom right, < 0 = display left arrow 85 | void OsdWrite(unsigned char n, char *s, unsigned char inver, unsigned char stipple); 86 | void OsdWriteOffset(unsigned char n, char *s, unsigned char inver, unsigned char stipple, char offset); // Used for scrolling "Exit" text downwards... 87 | void OsdClear(void); 88 | void OsdEnable(unsigned char mode); 89 | void OsdColor(unsigned char color); 90 | void OsdDisable(void); 91 | void OsdWaitVBL(void); 92 | void OsdReset(unsigned char boot); 93 | //void OsdReconfig(); // Reset to Chameleon core. 94 | void ConfigFilter(unsigned char lores, unsigned char hires); 95 | void ConfigMemory(unsigned char memory); 96 | void ConfigFastRAM(unsigned char memory); 97 | void ConfigCPU(unsigned char cpu); 98 | void ConfigChipset(unsigned char chipset); 99 | void ConfigFloppy(unsigned char drives, unsigned char speed); 100 | void ConfigScanlines(unsigned char scanlines); 101 | void ConfigIDE(unsigned char gayle, unsigned char master, unsigned char slave); 102 | void ConfigAutofire(unsigned char autofire); 103 | unsigned char OsdGetCtrl(void); 104 | unsigned char GetASCIIKey(unsigned char c); 105 | void OSD_PrintText(unsigned char line, char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert); 106 | void OsdWriteDoubleSize(unsigned char n, char *s, unsigned char pass); 107 | //void OsdDrawLogo(unsigned char n, char row); 108 | void OsdDrawLogo(unsigned char n, char row,char superimpose); 109 | void ScrollText(char n,const char *str, int len, int max_len,unsigned char invert); 110 | void ScrollReset(); 111 | void StarsInit(); 112 | void StarsUpdate(); 113 | #endif 114 | 115 | -------------------------------------------------------------------------------- /src/include/string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * string.h 3 | * 4 | * Definitions for memory and string functions. 5 | */ 6 | 7 | #ifndef _STRING_H_ 8 | #define _STRING_H_ 9 | 10 | #include "_ansi.h" 11 | #include 12 | #include 13 | 14 | #define __need_size_t 15 | #include 16 | 17 | #ifndef NULL 18 | #define NULL 0 19 | #endif 20 | 21 | _BEGIN_STD_C 22 | 23 | _PTR _EXFUN(memchr,(const _PTR, int, size_t)); 24 | int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); 25 | _PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t)); 26 | _PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); 27 | _PTR _EXFUN(memset,(_PTR, int, size_t)); 28 | char *_EXFUN(strcat,(char *, const char *)); 29 | char *_EXFUN(strchr,(const char *, int)); 30 | int _EXFUN(strcmp,(const char *, const char *)); 31 | int _EXFUN(strcoll,(const char *, const char *)); 32 | char *_EXFUN(strcpy,(char *, const char *)); 33 | size_t _EXFUN(strcspn,(const char *, const char *)); 34 | char *_EXFUN(strerror,(int)); 35 | size_t _EXFUN(strlen,(const char *)); 36 | char *_EXFUN(strncat,(char *, const char *, size_t)); 37 | int _EXFUN(strncmp,(const char *, const char *, size_t)); 38 | char *_EXFUN(strncpy,(char *, const char *, size_t)); 39 | char *_EXFUN(strpbrk,(const char *, const char *)); 40 | char *_EXFUN(strrchr,(const char *, int)); 41 | size_t _EXFUN(strspn,(const char *, const char *)); 42 | char *_EXFUN(strstr,(const char *, const char *)); 43 | 44 | #ifndef _REENT_ONLY 45 | char *_EXFUN(strtok,(char *, const char *)); 46 | #endif 47 | 48 | size_t _EXFUN(strxfrm,(char *, const char *, size_t)); 49 | 50 | #ifndef __STRICT_ANSI__ 51 | char *_EXFUN(strtok_r,(char *, const char *, char **)); 52 | 53 | int _EXFUN(bcmp,(const void *, const void *, size_t)); 54 | void _EXFUN(bcopy,(const void *, void *, size_t)); 55 | void _EXFUN(bzero,(void *, size_t)); 56 | int _EXFUN(ffs,(int)); 57 | char *_EXFUN(index,(const char *, int)); 58 | _PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t)); 59 | _PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); 60 | _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); 61 | char *_EXFUN(rindex,(const char *, int)); 62 | char *_EXFUN(stpcpy,(char *, const char *)); 63 | char *_EXFUN(stpncpy,(char *, const char *, size_t)); 64 | int _EXFUN(strcasecmp,(const char *, const char *)); 65 | char *_EXFUN(strcasestr,(const char *, const char *)); 66 | char *_EXFUN(strchrnul,(const char *, int)); 67 | char *_EXFUN(strdup,(const char *)); 68 | char *_EXFUN(_strdup_r,(struct _reent *, const char *)); 69 | char *_EXFUN(strndup,(const char *, size_t)); 70 | char *_EXFUN(_strndup_r,(struct _reent *, const char *, size_t)); 71 | /* There are two common strerror_r variants. If you request 72 | _GNU_SOURCE, you get the GNU version; otherwise you get the POSIX 73 | version. POSIX requires that #undef strerror_r will still let you 74 | invoke the underlying function, but that requires gcc support. */ 75 | #ifdef _GNU_SOURCE 76 | char *_EXFUN(strerror_r,(int, char *, size_t)); 77 | #else 78 | # ifdef __GNUC__ 79 | int _EXFUN(strerror_r,(int, char *, size_t)) __asm__ (__ASMNAME ("__xpg_strerror_r")); 80 | # else 81 | int _EXFUN(__xpg_strerror_r,(int, char *, size_t)); 82 | # define strerror_r __xpg_strerror_r 83 | # endif 84 | #endif 85 | size_t _EXFUN(strlcat,(char *, const char *, size_t)); 86 | size_t _EXFUN(strlcpy,(char *, const char *, size_t)); 87 | int _EXFUN(strncasecmp,(const char *, const char *, size_t)); 88 | size_t _EXFUN(strnlen,(const char *, size_t)); 89 | char *_EXFUN(strsep,(char **, const char *)); 90 | char *_EXFUN(strlwr,(char *)); 91 | char *_EXFUN(strupr,(char *)); 92 | #ifndef DEFS_H /* Kludge to work around problem compiling in gdb */ 93 | char *_EXFUN(strsignal, (int __signo)); 94 | #endif 95 | #ifdef __CYGWIN__ 96 | int _EXFUN(strtosigno, (const char *__name)); 97 | #endif 98 | 99 | /* Recursive version of strerror. */ 100 | char * _EXFUN(_strerror_r, (struct _reent *, int, int, int *)); 101 | 102 | #if defined _GNU_SOURCE && defined __GNUC__ 103 | #define strdupa(__s) \ 104 | (__extension__ ({const char *__in = (__s); \ 105 | size_t __len = strlen (__in) + 1; \ 106 | char * __out = (char *) __builtin_alloca (__len); \ 107 | (char *) memcpy (__out, __in, __len);})) 108 | #define strndupa(__s, __n) \ 109 | (__extension__ ({const char *__in = (__s); \ 110 | size_t __len = strnlen (__in, (__n)) + 1; \ 111 | char *__out = (char *) __builtin_alloca (__len); \ 112 | __out[__len-1] = '\0'; \ 113 | (char *) memcpy (__out, __in, __len-1);})) 114 | #endif /* _GNU_SOURCE && __GNUC__ */ 115 | 116 | /* These function names are used on Windows and perhaps other systems. */ 117 | #ifndef strcmpi 118 | #define strcmpi strcasecmp 119 | #endif 120 | #ifndef stricmp 121 | #define stricmp strcasecmp 122 | #endif 123 | #ifndef strncmpi 124 | #define strncmpi strncasecmp 125 | #endif 126 | #ifndef strnicmp 127 | #define strnicmp strncasecmp 128 | #endif 129 | 130 | #endif /* ! __STRICT_ANSI__ */ 131 | 132 | #include 133 | 134 | _END_STD_C 135 | 136 | #endif /* _STRING_H_ */ 137 | -------------------------------------------------------------------------------- /fampiga/chameleon/chameleon_docking_station.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2009 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.1")) 22 | (symbol 23 | (rect 16 16 264 240) 24 | (text "chameleon_docking_station" (rect 5 0 140 12)(font "Arial" )) 25 | (text "inst" (rect 8 208 25 220)(font "Arial" )) 26 | (port 27 | (pt 0 32) 28 | (input) 29 | (text "clk" (rect 0 0 14 12)(font "Arial" )) 30 | (text "clk" (rect 21 27 35 39)(font "Arial" )) 31 | (line (pt 0 32)(pt 16 32)(line_width 1)) 32 | ) 33 | (port 34 | (pt 0 48) 35 | (input) 36 | (text "dotclock_n" (rect 0 0 53 12)(font "Arial" )) 37 | (text "dotclock_n" (rect 21 43 74 55)(font "Arial" )) 38 | (line (pt 0 48)(pt 16 48)(line_width 1)) 39 | ) 40 | (port 41 | (pt 0 64) 42 | (input) 43 | (text "io_ef_n" (rect 0 0 36 12)(font "Arial" )) 44 | (text "io_ef_n" (rect 21 59 57 71)(font "Arial" )) 45 | (line (pt 0 64)(pt 16 64)(line_width 1)) 46 | ) 47 | (port 48 | (pt 0 80) 49 | (input) 50 | (text "rom_lh_n" (rect 0 0 44 12)(font "Arial" )) 51 | (text "rom_lh_n" (rect 21 75 65 87)(font "Arial" )) 52 | (line (pt 0 80)(pt 16 80)(line_width 1)) 53 | ) 54 | (port 55 | (pt 0 96) 56 | (input) 57 | (text "irq_d" (rect 0 0 23 12)(font "Arial" )) 58 | (text "irq_d" (rect 21 91 44 103)(font "Arial" )) 59 | (line (pt 0 96)(pt 16 96)(line_width 1)) 60 | ) 61 | (port 62 | (pt 0 112) 63 | (input) 64 | (text "amiga_power_led" (rect 0 0 83 12)(font "Arial" )) 65 | (text "amiga_power_led" (rect 21 107 104 119)(font "Arial" )) 66 | (line (pt 0 112)(pt 16 112)(line_width 1)) 67 | ) 68 | (port 69 | (pt 0 128) 70 | (input) 71 | (text "amiga_drive_led" (rect 0 0 80 12)(font "Arial" )) 72 | (text "amiga_drive_led" (rect 21 123 101 135)(font "Arial" )) 73 | (line (pt 0 128)(pt 16 128)(line_width 1)) 74 | ) 75 | (port 76 | (pt 248 32) 77 | (output) 78 | (text "irq_q" (rect 0 0 23 12)(font "Arial" )) 79 | (text "irq_q" (rect 204 27 227 39)(font "Arial" )) 80 | (line (pt 248 32)(pt 232 32)(line_width 1)) 81 | ) 82 | (port 83 | (pt 248 48) 84 | (output) 85 | (text "joystick1[5..0]" (rect 0 0 70 12)(font "Arial" )) 86 | (text "joystick1[5..0]" (rect 157 43 227 55)(font "Arial" )) 87 | (line (pt 248 48)(pt 232 48)(line_width 3)) 88 | ) 89 | (port 90 | (pt 248 64) 91 | (output) 92 | (text "joystick2[5..0]" (rect 0 0 70 12)(font "Arial" )) 93 | (text "joystick2[5..0]" (rect 157 59 227 71)(font "Arial" )) 94 | (line (pt 248 64)(pt 232 64)(line_width 3)) 95 | ) 96 | (port 97 | (pt 248 80) 98 | (output) 99 | (text "joystick3[5..0]" (rect 0 0 70 12)(font "Arial" )) 100 | (text "joystick3[5..0]" (rect 157 75 227 87)(font "Arial" )) 101 | (line (pt 248 80)(pt 232 80)(line_width 3)) 102 | ) 103 | (port 104 | (pt 248 96) 105 | (output) 106 | (text "joystick4[5..0]" (rect 0 0 70 12)(font "Arial" )) 107 | (text "joystick4[5..0]" (rect 157 91 227 103)(font "Arial" )) 108 | (line (pt 248 96)(pt 232 96)(line_width 3)) 109 | ) 110 | (port 111 | (pt 248 112) 112 | (output) 113 | (text "keys[63..0]" (rect 0 0 56 12)(font "Arial" )) 114 | (text "keys[63..0]" (rect 171 107 227 119)(font "Arial" )) 115 | (line (pt 248 112)(pt 232 112)(line_width 3)) 116 | ) 117 | (port 118 | (pt 248 128) 119 | (output) 120 | (text "restore_key_n" (rect 0 0 70 12)(font "Arial" )) 121 | (text "restore_key_n" (rect 157 123 227 135)(font "Arial" )) 122 | (line (pt 248 128)(pt 232 128)(line_width 1)) 123 | ) 124 | (port 125 | (pt 248 144) 126 | (output) 127 | (text "amiga_reset_n" (rect 0 0 71 12)(font "Arial" )) 128 | (text "amiga_reset_n" (rect 156 139 227 151)(font "Arial" )) 129 | (line (pt 248 144)(pt 232 144)(line_width 1)) 130 | ) 131 | (port 132 | (pt 248 160) 133 | (output) 134 | (text "amiga_trigger" (rect 0 0 66 12)(font "Arial" )) 135 | (text "amiga_trigger" (rect 161 155 227 167)(font "Arial" )) 136 | (line (pt 248 160)(pt 232 160)(line_width 1)) 137 | ) 138 | (port 139 | (pt 248 176) 140 | (output) 141 | (text "amiga_scancode[7..0]" (rect 0 0 108 12)(font "Arial" )) 142 | (text "amiga_scancode[7..0]" (rect 119 171 227 183)(font "Arial" )) 143 | (line (pt 248 176)(pt 232 176)(line_width 3)) 144 | ) 145 | (drawing 146 | (rectangle (rect 16 16 232 208)(line_width 1)) 147 | ) 148 | ) 149 | -------------------------------------------------------------------------------- /fampiga/chameleon/sram_bridge.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2011 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.1")) 22 | (symbol 23 | (rect 16 16 296 240) 24 | (text "sram_bridge" (rect 5 0 82 12)(font "Arial" )) 25 | (text "inst" (rect 8 208 36 220)(font "Arial" )) 26 | (port 27 | (pt 0 32) 28 | (input) 29 | (text "clk28m" (rect 0 0 42 12)(font "Arial" )) 30 | (text "clk28m" (rect 21 27 63 39)(font "Arial" )) 31 | (line (pt 0 32)(pt 16 32)(line_width 1)) 32 | ) 33 | (port 34 | (pt 0 48) 35 | (input) 36 | (text "c1" (rect 0 0 14 12)(font "Arial" )) 37 | (text "c1" (rect 21 43 35 55)(font "Arial" )) 38 | (line (pt 0 48)(pt 16 48)(line_width 1)) 39 | ) 40 | (port 41 | (pt 0 64) 42 | (input) 43 | (text "c3" (rect 0 0 14 12)(font "Arial" )) 44 | (text "c3" (rect 21 59 35 71)(font "Arial" )) 45 | (line (pt 0 64)(pt 16 64)(line_width 1)) 46 | ) 47 | (port 48 | (pt 0 80) 49 | (input) 50 | (text "bank[7..0]" (rect 0 0 70 12)(font "Arial" )) 51 | (text "bank[7..0]" (rect 21 75 91 87)(font "Arial" )) 52 | (line (pt 0 80)(pt 16 80)(line_width 3)) 53 | ) 54 | (port 55 | (pt 0 96) 56 | (input) 57 | (text "address_in[18..1]" (rect 0 0 120 12)(font "Arial" )) 58 | (text "address_in[18..1]" (rect 21 91 141 103)(font "Arial" )) 59 | (line (pt 0 96)(pt 16 96)(line_width 3)) 60 | ) 61 | (port 62 | (pt 0 112) 63 | (input) 64 | (text "data_in[15..0]" (rect 0 0 99 12)(font "Arial" )) 65 | (text "data_in[15..0]" (rect 21 107 120 119)(font "Arial" )) 66 | (line (pt 0 112)(pt 16 112)(line_width 3)) 67 | ) 68 | (port 69 | (pt 0 128) 70 | (input) 71 | (text "rd" (rect 0 0 14 12)(font "Arial" )) 72 | (text "rd" (rect 21 123 35 135)(font "Arial" )) 73 | (line (pt 0 128)(pt 16 128)(line_width 1)) 74 | ) 75 | (port 76 | (pt 0 144) 77 | (input) 78 | (text "hwr" (rect 0 0 21 12)(font "Arial" )) 79 | (text "hwr" (rect 21 139 42 151)(font "Arial" )) 80 | (line (pt 0 144)(pt 16 144)(line_width 1)) 81 | ) 82 | (port 83 | (pt 0 160) 84 | (input) 85 | (text "lwr" (rect 0 0 21 12)(font "Arial" )) 86 | (text "lwr" (rect 21 155 42 167)(font "Arial" )) 87 | (line (pt 0 160)(pt 16 160)(line_width 1)) 88 | ) 89 | (port 90 | (pt 0 176) 91 | (input) 92 | (text "ramdata_in[15..0]" (rect 0 0 120 12)(font "Arial" )) 93 | (text "ramdata_in[15..0]" (rect 21 171 141 183)(font "Arial" )) 94 | (line (pt 0 176)(pt 16 176)(line_width 3)) 95 | ) 96 | (port 97 | (pt 280 32) 98 | (output) 99 | (text "data_out[15..0]" (rect 0 0 106 12)(font "Arial" )) 100 | (text "data_out[15..0]" (rect 153 27 259 39)(font "Arial" )) 101 | (line (pt 280 32)(pt 264 32)(line_width 3)) 102 | ) 103 | (port 104 | (pt 280 48) 105 | (output) 106 | (text "_bhe" (rect 0 0 28 12)(font "Arial" )) 107 | (text "_bhe" (rect 231 43 259 55)(font "Arial" )) 108 | (line (pt 280 48)(pt 264 48)(line_width 1)) 109 | ) 110 | (port 111 | (pt 280 64) 112 | (output) 113 | (text "_ble" (rect 0 0 28 12)(font "Arial" )) 114 | (text "_ble" (rect 231 59 259 71)(font "Arial" )) 115 | (line (pt 280 64)(pt 264 64)(line_width 1)) 116 | ) 117 | (port 118 | (pt 280 80) 119 | (output) 120 | (text "_we" (rect 0 0 21 12)(font "Arial" )) 121 | (text "_we" (rect 238 75 259 87)(font "Arial" )) 122 | (line (pt 280 80)(pt 264 80)(line_width 1)) 123 | ) 124 | (port 125 | (pt 280 96) 126 | (output) 127 | (text "_oe" (rect 0 0 21 12)(font "Arial" )) 128 | (text "_oe" (rect 238 91 259 103)(font "Arial" )) 129 | (line (pt 280 96)(pt 264 96)(line_width 1)) 130 | ) 131 | (port 132 | (pt 280 112) 133 | (output) 134 | (text "_ce[3..0]" (rect 0 0 63 12)(font "Arial" )) 135 | (text "_ce[3..0]" (rect 196 107 259 119)(font "Arial" )) 136 | (line (pt 280 112)(pt 264 112)(line_width 3)) 137 | ) 138 | (port 139 | (pt 280 128) 140 | (output) 141 | (text "address[21..1]" (rect 0 0 99 12)(font "Arial" )) 142 | (text "address[21..1]" (rect 160 123 259 135)(font "Arial" )) 143 | (line (pt 280 128)(pt 264 128)(line_width 3)) 144 | ) 145 | (port 146 | (pt 280 144) 147 | (output) 148 | (text "data[15..0]" (rect 0 0 77 12)(font "Arial" )) 149 | (text "data[15..0]" (rect 182 139 259 151)(font "Arial" )) 150 | (line (pt 280 144)(pt 264 144)(line_width 3)) 151 | ) 152 | (drawing 153 | (rectangle (rect 16 16 264 208)(line_width 1)) 154 | ) 155 | ) 156 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2005, 2006, 2007 Dennis van Weeren 3 | Copyright 2008, 2009 Jakub Bednarski 4 | 5 | This file is part of Minimig 6 | 7 | Minimig is free software; you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation; either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | Minimig is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | */ 20 | 21 | // 2008-10-04 - porting to ARM 22 | // 2008-10-06 - support for 4 floppy drives 23 | // 2008-10-30 - hdd write support 24 | // 2009-05-01 - subdirectory support 25 | // 2009-06-26 - SDHC and FAT32 support 26 | // 2009-08-10 - hardfile selection 27 | // 2009-09-11 - minor changes to hardware initialization routine 28 | // 2009-10-10 - any length fpga core file support 29 | // 2009-11-14 - adapted floppy gap size 30 | // - changes to OSD labels 31 | // 2009-12-24 - updated version number 32 | // 2010-01-09 - changes to floppy handling 33 | // 2010-07-28 - improved menu button handling 34 | // - improved FPGA configuration routines 35 | // - added support for OSD vsync 36 | // 2010-08-15 - support for joystick emulation 37 | // 2010-08-18 - clean-up 38 | 39 | // FIXME - detect number of partitions on the SD card, and allow that many to be selected as hard files. 40 | 41 | //#include "AT91SAM7S256.h" 42 | //#include "stdio.h" 43 | //#include "string.h" 44 | #include "errors.h" 45 | #include "hardware.h" 46 | #include "mmc.h" 47 | #include "fat.h" 48 | #include "osd.h" 49 | #include "fpga.h" 50 | #include "fdd.h" 51 | #include "hdd.h" 52 | #include "firmware.h" 53 | #include "menu.h" 54 | #include "config.h" 55 | 56 | #include 57 | 58 | const char version[] = {"$VER:AYQ100818_RB2"}; 59 | 60 | extern adfTYPE df[4]; 61 | 62 | unsigned char Error; 63 | char s[40]; 64 | 65 | void FatalError(unsigned long error) 66 | { 67 | unsigned long i; 68 | 69 | sprintf(s,"Fatal error: %lu\n", error); 70 | BootPrint("FatalError...\n"); 71 | BootPrint(s); 72 | 73 | while (1) 74 | { 75 | for (i = 0; i < error; i++) 76 | { 77 | DISKLED_ON; 78 | WaitTimer(250); 79 | DISKLED_OFF; 80 | WaitTimer(250); 81 | } 82 | WaitTimer(1000); 83 | } 84 | } 85 | 86 | 87 | void HandleFpga(void) 88 | { 89 | unsigned char c1, c2; 90 | 91 | EnableFpga(); 92 | c1 = SPI(0); // cmd request and drive number 93 | c2 = SPI(0); // track number 94 | SPI(0); 95 | SPI(0); 96 | SPI(0); 97 | SPI(0); 98 | DisableFpga(); 99 | 100 | HandleFDD(c1, c2); 101 | HandleHDD(c1, c2); 102 | 103 | UpdateDriveStatus(); 104 | } 105 | 106 | #ifdef __GNUC__ 107 | void c_entry(void) 108 | #else 109 | __geta4 void main(void) 110 | #endif 111 | { 112 | debugmsg[0]=0; 113 | debugmsg2[0]=0; 114 | // unsigned long time; 115 | // unsigned short spiclk; 116 | 117 | ShowSplash(); 118 | 119 | BootPrint("OSD_CA01.SYS is here...\n"); 120 | 121 | DISKLED_ON; 122 | 123 | // Timer_Init(); 124 | // 125 | // USART_Init(115200); 126 | 127 | printf("\rMinimig by Dennis van Weeren"); 128 | printf("\rARM Controller by Jakub Bednarski\r\r"); 129 | printf("Version %s\r\r", version+5); 130 | 131 | sprintf(s, "** ARM firmware %s **\n", version + 5); 132 | BootPrint(s); 133 | 134 | // OsdDisable(); 135 | 136 | // SPI_Init(); 137 | 138 | // if (CheckButton()) // if menu button pressed fall back to slow SPI mode 139 | // SetSPIMode(SPIMODE_NORMAL); 140 | 141 | if (!MMC_Init()) 142 | FatalError(1); 143 | 144 | // BootPrint("Init done again - hunting for drive...\n"); 145 | 146 | // spiclk = 7;//MCLK / ((AT91C_SPI_CSR[0] & AT91C_SPI_SCBR) >> 8) / 1000000; 147 | // printf("spiclk: %u MHz\r", spiclk); 148 | 149 | BootPrint("hunting for drive...\n"); 150 | 151 | if (!FindDrive()) 152 | FatalError(2); 153 | 154 | BootPrint("found DRIVE...\n"); 155 | 156 | ChangeDirectory(DIRECTORY_ROOT); 157 | 158 | // time = GetTimer(0); 159 | // if (ConfigureFpga()) 160 | // { 161 | // time = GetTimer(0) - time; 162 | // printf("FPGA configured in %lu ms\r", time >> 20); 163 | // } 164 | // else 165 | // { 166 | // printf("FPGA configuration failed\r"); 167 | // FatalError(3); 168 | // } 169 | 170 | // WaitTimer(100); // let's wait some time till reset is inactive so we can get a valid keycode 171 | //eject all disk 172 | df[0].status = 0; 173 | df[1].status = 0; 174 | df[2].status = 0; 175 | df[3].status = 0; 176 | 177 | config.kickstart.name[0]=0; 178 | SetConfigurationFilename(0); // Use default config 179 | LoadConfiguration(0); // Use slot-based config filename 180 | 181 | // sprintf(s, "SPI clock: %u MHz\n", spiclk); 182 | // BootPrint(s); 183 | HideSplash(); 184 | 185 | while (1) 186 | { 187 | HandleFpga(); 188 | HandleUI(); 189 | } 190 | 191 | } 192 | 193 | -------------------------------------------------------------------------------- /src/mmc.h: -------------------------------------------------------------------------------- 1 | #ifndef MMC_H 2 | #define MMC_H 3 | 4 | #define CARDTYPE_NONE 0 5 | #define CARDTYPE_MMC 1 6 | #define CARDTYPE_SD 2 7 | #define CARDTYPE_SDHC 3 8 | 9 | // MMC commandset 10 | #define CMD0 0x40 /*Resets the multimedia card*/ 11 | #define CMD1 0x41 /*Activates the card's initialization process*/ 12 | #define CMD2 0x42 /*--*/ 13 | #define CMD3 0x43 /*--*/ 14 | #define CMD4 0x44 /*--*/ 15 | #define CMD5 0x45 /*reseved*/ 16 | #define CMD6 0x46 /*reserved*/ 17 | #define CMD7 0x47 /*--*/ 18 | #define CMD8 0x48 /*reserved*/ 19 | #define CMD9 0x49 /*CSD : Ask the selected card to send its card specific data*/ 20 | #define CMD10 0x4a /*CID : Ask the selected card to send its card identification*/ 21 | #define CMD11 0x4b /*--*/ 22 | #define CMD12 0x4c /*--*/ 23 | #define CMD13 0x4d /*Ask the selected card to send its status register*/ 24 | #define CMD14 0x4e /*--*/ 25 | #define CMD15 0x4f /*--*/ 26 | #define CMD16 0x50 /*Select a block length (in bytes) for all following block commands (Read:between 1-512 and Write:only 512)*/ 27 | #define CMD17 0x51 /*Reads a block of the size selected by the SET_BLOCKLEN command, the start address and block length must be set so that the data transferred will not cross a physical block boundry*/ 28 | #define CMD18 0x52 /*--*/ 29 | #define CMD19 0x53 /*reserved*/ 30 | #define CMD20 0x54 /*--*/ 31 | #define CMD21 0x55 /*reserved*/ 32 | #define CMD22 0x56 /*reserved*/ 33 | #define CMD23 0x57 /*reserved*/ 34 | #define CMD24 0x58 /*Writes a block of the size selected by CMD16, the start address must be alligned on a sector boundry, the block length is always 512 bytes*/ 35 | #define CMD25 0x59 /*--*/ 36 | #define CMD26 0x5a /*--*/ 37 | #define CMD27 0x5b /*Programming of the programmable bits of the CSD*/ 38 | #define CMD28 0x5c /*If the card has write protection features, this command sets the write protection bit of the addressed group. The porperties of the write protection are coded in the card specific data (WP_GRP_SIZE)*/ 39 | #define CMD29 0x5d /*If the card has write protection features, this command clears the write protection bit of the addressed group*/ 40 | #define CMD30 0x5e /*If the card has write protection features, this command asks the card to send the status of the write protection bits. 32 write protection bits (representing 32 write protect groups starting at the specific address) followed by 16 CRD bits are transferred in a payload format via the data line*/ 41 | #define CMD31 0x5f /*reserved*/ 42 | #define CMD32 0x60 /*sets the address of the first sector of the erase group*/ 43 | #define CMD33 0x61 /*Sets the address of the last sector in a cont. range within the selected erase group, or the address of a single sector to be selected for erase*/ 44 | #define CMD34 0x62 /*Removes on previously selected sector from the erase selection*/ 45 | #define CMD35 0x63 /*Sets the address of the first erase group within a range to be selected for erase*/ 46 | #define CMD36 0x64 /*Sets the address of the last erase group within a continuos range to be selected for erase*/ 47 | #define CMD37 0x65 /*Removes one previously selected erase group from the erase selection*/ 48 | #define CMD38 0x66 /*Erases all previously selected sectors*/ 49 | #define CMD39 0x67 /*--*/ 50 | #define CMD40 0x68 /*--*/ 51 | #define CMD41 0x69 /*reserved*/ 52 | #define CMD42 0x6a /*reserved*/ 53 | #define CMD43 0x6b /*reserved*/ 54 | #define CMD44 0x6c /*reserved*/ 55 | #define CMD45 0x6d /*reserved*/ 56 | #define CMD46 0x6e /*reserved*/ 57 | #define CMD47 0x6f /*reserved*/ 58 | #define CMD48 0x70 /*reserved*/ 59 | #define CMD49 0x71 /*reserved*/ 60 | #define CMD50 0x72 /*reserved*/ 61 | #define CMD51 0x73 /*reserved*/ 62 | #define CMD52 0x74 /*reserved*/ 63 | #define CMD53 0x75 /*reserved*/ 64 | #define CMD54 0x76 /*reserved*/ 65 | #define CMD55 0x77 /*reserved*/ 66 | #define CMD56 0x78 /*reserved*/ 67 | #define CMD57 0x79 /*reserved*/ 68 | #define CMD58 0x7a /*reserved*/ 69 | #define CMD59 0x7b /*Turns the CRC option ON or OFF. A '1' in the CRC option bit will turn the option ON, a '0' will turn it OFF*/ 70 | #define CMD60 0x7c /*--*/ 71 | #define CMD61 0x7d /*--*/ 72 | #define CMD62 0x7e /*--*/ 73 | #define CMD63 0x7f /*--*/ 74 | 75 | unsigned char MMC_Init(void); 76 | unsigned char MMC_Read(unsigned long lba, unsigned char *pReadBuffer); 77 | unsigned char MMC_Write(unsigned long lba, unsigned char *pWriteBuffer); 78 | unsigned char MMC_ReadMultiple(unsigned long lba, unsigned char *pReadBuffer, unsigned long nBlockCount); 79 | unsigned char MMC_GetCSD(); 80 | unsigned long MMC_GetCapacity(); // Returns the capacity in 512 byte blocks 81 | 82 | extern unsigned char CSDData[16]; 83 | 84 | #endif 85 | 86 | -------------------------------------------------------------------------------- /amiga/dice_mini/include/stdio.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * $VER: stdio.h 1.0 (17.4.93) 4 | * 5 | * (c)Copyright 1992 Obvious Implementations Corp, All Rights Reserved 6 | */ 7 | 8 | #ifndef STDIO_H 9 | #define STDIO_H 10 | 11 | #ifndef STDDEF_H 12 | #include 13 | #endif 14 | 15 | #ifndef STDARG_H 16 | typedef void *va_list; 17 | #endif 18 | 19 | typedef long fpos_t; 20 | 21 | typedef struct FILE { 22 | struct FILE *sd_Next; 23 | struct FILE **sd_Prev; 24 | unsigned char *sd_RBuf; 25 | unsigned char *sd_RPtr; 26 | unsigned char *sd_WBuf; 27 | unsigned char *sd_WPtr; 28 | long sd_BufSiz; 29 | int sd_RLeft; 30 | int sd_WLeft; 31 | int sd_Flags; 32 | int sd_Error; /* error: 0 / non-0 */ 33 | fpos_t sd_Offset; /* level 1 current off */ 34 | int sd_Fd; 35 | short sd_UC; /* ungotten character or -1 */ 36 | char *sd_Name; /* use for tmpfile() */ 37 | } FILE; 38 | 39 | typedef struct _IOFDS { 40 | long fd_Fh; 41 | long fd_Flags; 42 | long (*fd_Exec)(long, int, void *, void *); /* exec function */ 43 | char *fd_FileName; /* file name for fstat() under 1.3 */ 44 | } _IOFDS; 45 | 46 | extern FILE _Iob[3]; /* fixed fps */ 47 | extern FILE *_Iod; /* dynamic fps */ 48 | 49 | extern _IOFDS _IoStaticFD[3]; /* 0,1,2 */ 50 | extern _IOFDS *_IoFD; /* descriptors */ 51 | extern short _IoFDLimit; 52 | extern int _bufsiz; /* default BUFSIZ */ 53 | 54 | #define __SIF_ERROR 0x0001 /* XXX */ 55 | #define __SIF_EOF 0x0002 56 | #define __SIF_READ 0x0004 57 | #define __SIF_WRITE 0x0008 58 | #define __SIF_IOLBF 0x0010 59 | #define __SIF_REMOVE 0x0020 /* unlink file after closing */ 60 | #define __SIF_APPEND 0x0040 61 | #define __SIF_NOFREE 0x0080 /* not a freeable descriptor */ 62 | #define __SIF_OPEN 0x0100 /* file is open */ 63 | #define __SIF_MYBUF 0x0200 /* I allocated the buffer(s) */ 64 | #define __SIF_BINARY 0x0400 65 | #define __SIF_RAW 0x0800 /* RAW terminal , see setvbuf */ 66 | #define __SIF_FILE 0x1000 /* a seekable file */ 67 | 68 | #define _IOFBF -1 69 | #define _IOLBF __SIF_IOLBF 70 | #define _IONBF 0 71 | 72 | #define BUFSIZ 1024 73 | #define EOF -1 74 | #define FILENAME_MAX 1024 75 | #define FOPEN_MAX 20 /* lets be reasonable */ 76 | #define L_tmpnam 32 77 | #define SEEK_SET 0 78 | #define SEEK_CUR 1 79 | #define SEEK_END 2 80 | #define TMP_MAX 4096 81 | #define stdin (&_Iob[0]) 82 | #define stdout (&_Iob[1]) 83 | #define stderr (&_Iob[2]) 84 | 85 | #define clearerr(fi) (((fi)->sd_Flags &= ~__SIF_EOF), ((fi)->sd_Error = 0)) 86 | #define feof(fi) ((fi)->sd_Flags & __SIF_EOF) 87 | #define ferror(fi) ((fi)->sd_Error) 88 | #define fileno(fi) ((fi)->sd_Fd) 89 | 90 | extern void perror(const char *); 91 | 92 | extern int fclose(FILE *); 93 | extern int fflush(FILE *); 94 | extern FILE * fopen(const char *, const char *); 95 | extern FILE * freopen(const char *, const char *, FILE *); 96 | extern void setbuf(FILE *, char *); 97 | extern int setvbuf(FILE *, char *, int, size_t); 98 | 99 | extern int remove(const char *); 100 | extern int rename(const char *, const char *); 101 | extern FILE * tmpfile(void); 102 | extern char * tmpnam(char *); 103 | 104 | extern int fgetpos(FILE *, fpos_t *); 105 | extern int fseek(FILE *, long, int); 106 | extern int fsetpos(FILE *, const fpos_t *); 107 | extern long ftell(FILE *); 108 | extern void rewind(FILE *); 109 | 110 | extern int fgetc(FILE *); 111 | extern char * fgets(char *, int, FILE *); 112 | extern int fputc(unsigned char, FILE *); 113 | extern int fputs(const char *, FILE *); 114 | 115 | #define getc(fi) ( ((fi)->sd_UC >= 0) ? fgetc(fi) : ((fi)->sd_RLeft <= 0) ? fgetc(fi) : (--(fi)->sd_RLeft, (int)*(fi)->sd_RPtr++)) 116 | 117 | #ifdef NOTDEF /* old putc() would reference 'c' twice */ 118 | #define putc(c,fi) (((c) == '\n' || (fi)->sd_WLeft <= 0) ? fputc((c),(fi)) : (*(fi)->sd_WPtr++ = (c), --(fi)->sd_WLeft, (c))) 119 | #endif 120 | 121 | /* 122 | * new putc macro only references (c) once in the execution path, 123 | * also fixed bug with '\n' (would previously fflush() even if not 124 | * line buffered) 125 | */ 126 | 127 | #define putc(c,fi) (((fi)->sd_WLeft <= 0) ? fputc((c),(fi)) : \ 128 | (((--(fi)->sd_WLeft, ((*(fi)->sd_WPtr++ = (c))) == '\n') && ((fi)->sd_Flags & _IOLBF)) ? (fflush(fi), '\n') : ((fi)->sd_WPtr)[-1])) 129 | 130 | 131 | #define getchar() fgetc(stdin) 132 | #define putchar(c) fputc((c),stdout) 133 | 134 | extern char * gets(char *); 135 | extern int puts(const char *); 136 | extern int ungetc(int, FILE *); 137 | 138 | extern size_t fread(void *, size_t, size_t, FILE *); 139 | extern size_t fwrite(const void *, size_t, size_t, FILE *); 140 | 141 | extern int fprintf(FILE *, const char *, ...); 142 | extern int fscanf(FILE *, const char *, ...); 143 | extern int printf(const char *, ...); 144 | extern int scanf(const char *, ...); 145 | extern int sprintf(char *, const char *, ...); 146 | extern int sscanf(char *, const char *, ...); 147 | 148 | extern int vfprintf(FILE *, const char *, va_list); 149 | extern int vprintf(const char *, va_list); 150 | extern int vsprintf(char *, const char *, va_list); 151 | 152 | /* 153 | * Standard, but not ANSI 154 | */ 155 | 156 | extern FILE * fdopen(int, const char *); 157 | extern int chdir(const char *); 158 | extern char * getcwd(char *, int); 159 | extern int unlink(const char *); 160 | 161 | /* 162 | * Amiga specific 163 | */ 164 | 165 | extern int fhprintf(long, const char *, ...); 166 | extern int vfhprintf(long, const char *, va_list); 167 | 168 | #endif 169 | 170 | -------------------------------------------------------------------------------- /fampiga/chameleon/TG68KdotC_Kernel.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2009 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.1")) 22 | (symbol 23 | (rect 16 16 224 240) 24 | (text "TG68KdotC_Kernel" (rect 5 0 98 12)(font "Arial" )) 25 | (text "inst" (rect 8 208 25 220)(font "Arial" )) 26 | (port 27 | (pt 0 32) 28 | (input) 29 | (text "clk" (rect 0 0 14 12)(font "Arial" )) 30 | (text "clk" (rect 21 27 35 39)(font "Arial" )) 31 | (line (pt 0 32)(pt 16 32)(line_width 1)) 32 | ) 33 | (port 34 | (pt 0 48) 35 | (input) 36 | (text "nReset" (rect 0 0 35 12)(font "Arial" )) 37 | (text "nReset" (rect 21 43 56 55)(font "Arial" )) 38 | (line (pt 0 48)(pt 16 48)(line_width 1)) 39 | ) 40 | (port 41 | (pt 0 64) 42 | (input) 43 | (text "clkena_in" (rect 0 0 46 12)(font "Arial" )) 44 | (text "clkena_in" (rect 21 59 67 71)(font "Arial" )) 45 | (line (pt 0 64)(pt 16 64)(line_width 1)) 46 | ) 47 | (port 48 | (pt 0 80) 49 | (input) 50 | (text "data_in[15..0]" (rect 0 0 67 12)(font "Arial" )) 51 | (text "data_in[15..0]" (rect 21 75 88 87)(font "Arial" )) 52 | (line (pt 0 80)(pt 16 80)(line_width 3)) 53 | ) 54 | (port 55 | (pt 0 96) 56 | (input) 57 | (text "IPL[2..0]" (rect 0 0 42 12)(font "Arial" )) 58 | (text "IPL[2..0]" (rect 21 91 63 103)(font "Arial" )) 59 | (line (pt 0 96)(pt 16 96)(line_width 3)) 60 | ) 61 | (port 62 | (pt 0 112) 63 | (input) 64 | (text "IPL_autovector" (rect 0 0 75 12)(font "Arial" )) 65 | (text "IPL_autovector" (rect 21 107 96 119)(font "Arial" )) 66 | (line (pt 0 112)(pt 16 112)(line_width 1)) 67 | ) 68 | (port 69 | (pt 0 128) 70 | (input) 71 | (text "CPU[1..0]" (rect 0 0 49 12)(font "Arial" )) 72 | (text "CPU[1..0]" (rect 21 123 70 135)(font "Arial" )) 73 | (line (pt 0 128)(pt 16 128)(line_width 3)) 74 | ) 75 | (port 76 | (pt 208 32) 77 | (output) 78 | (text "addr[31..0]" (rect 0 0 53 12)(font "Arial" )) 79 | (text "addr[31..0]" (rect 134 27 187 39)(font "Arial" )) 80 | (line (pt 208 32)(pt 192 32)(line_width 3)) 81 | ) 82 | (port 83 | (pt 208 48) 84 | (output) 85 | (text "data_write[15..0]" (rect 0 0 81 12)(font "Arial" )) 86 | (text "data_write[15..0]" (rect 106 43 187 55)(font "Arial" )) 87 | (line (pt 208 48)(pt 192 48)(line_width 3)) 88 | ) 89 | (port 90 | (pt 208 64) 91 | (output) 92 | (text "nWr" (rect 0 0 20 12)(font "Arial" )) 93 | (text "nWr" (rect 167 59 187 71)(font "Arial" )) 94 | (line (pt 208 64)(pt 192 64)(line_width 1)) 95 | ) 96 | (port 97 | (pt 208 80) 98 | (output) 99 | (text "nUDS" (rect 0 0 29 12)(font "Arial" )) 100 | (text "nUDS" (rect 158 75 187 87)(font "Arial" )) 101 | (line (pt 208 80)(pt 192 80)(line_width 1)) 102 | ) 103 | (port 104 | (pt 208 96) 105 | (output) 106 | (text "nLDS" (rect 0 0 27 12)(font "Arial" )) 107 | (text "nLDS" (rect 160 91 187 103)(font "Arial" )) 108 | (line (pt 208 96)(pt 192 96)(line_width 1)) 109 | ) 110 | (port 111 | (pt 208 112) 112 | (output) 113 | (text "busstate[1..0]" (rect 0 0 68 12)(font "Arial" )) 114 | (text "busstate[1..0]" (rect 119 107 187 119)(font "Arial" )) 115 | (line (pt 208 112)(pt 192 112)(line_width 3)) 116 | ) 117 | (port 118 | (pt 208 128) 119 | (output) 120 | (text "nResetOut" (rect 0 0 53 12)(font "Arial" )) 121 | (text "nResetOut" (rect 134 123 187 135)(font "Arial" )) 122 | (line (pt 208 128)(pt 192 128)(line_width 1)) 123 | ) 124 | (port 125 | (pt 208 144) 126 | (output) 127 | (text "FC[2..0]" (rect 0 0 41 12)(font "Arial" )) 128 | (text "FC[2..0]" (rect 146 139 187 151)(font "Arial" )) 129 | (line (pt 208 144)(pt 192 144)(line_width 3)) 130 | ) 131 | (port 132 | (pt 208 160) 133 | (output) 134 | (text "skipFetch" (rect 0 0 48 12)(font "Arial" )) 135 | (text "skipFetch" (rect 139 155 187 167)(font "Arial" )) 136 | (line (pt 208 160)(pt 192 160)(line_width 1)) 137 | ) 138 | (port 139 | (pt 208 176) 140 | (output) 141 | (text "regin[31..0]" (rect 0 0 55 12)(font "Arial" )) 142 | (text "regin[31..0]" (rect 132 171 187 183)(font "Arial" )) 143 | (line (pt 208 176)(pt 192 176)(line_width 3)) 144 | ) 145 | (parameter 146 | "SR_Read" 147 | "2" 148 | "" 149 | (type "PARAMETER_SIGNED_DEC") ) 150 | (parameter 151 | "VBR_Stackframe" 152 | "2" 153 | "" 154 | (type "PARAMETER_SIGNED_DEC") ) 155 | (parameter 156 | "extAddr_Mode" 157 | "2" 158 | "" 159 | (type "PARAMETER_SIGNED_DEC") ) 160 | (parameter 161 | "MUL_Mode" 162 | "2" 163 | "" 164 | (type "PARAMETER_SIGNED_DEC") ) 165 | (parameter 166 | "DIV_Mode" 167 | "2" 168 | "" 169 | (type "PARAMETER_SIGNED_DEC") ) 170 | (parameter 171 | "BitField" 172 | "2" 173 | "" 174 | (type "PARAMETER_SIGNED_DEC") ) 175 | (drawing 176 | (rectangle (rect 16 16 192 208)(line_width 1)) 177 | ) 178 | (annotation_block (parameter)(rect 224 -64 324 16)) 179 | ) 180 | -------------------------------------------------------------------------------- /src/fat.h: -------------------------------------------------------------------------------- 1 | #ifndef _FAT16_H_INCLUDED 2 | #define _FAT16_H_INCLUDED 3 | 4 | #define MAXDIRENTRIES 8 5 | 6 | // FIXME - derive CHS address from FAT boot sector for card and partition mount modes. 7 | 8 | typedef struct 9 | { 10 | unsigned long sector; 11 | unsigned long index; 12 | } entryTYPE; 13 | 14 | typedef struct 15 | { 16 | char name[11]; /* name of file */ 17 | unsigned char attributes; /* file attributes */ 18 | entryTYPE entry; /* file entry location */ 19 | unsigned long sector; /* sector index in file */ 20 | unsigned long size; /* file size */ 21 | unsigned long cluster; /* current cluster */ 22 | unsigned long start_cluster; /* first cluster of file */ 23 | char long_name[261]; 24 | } fileTYPE; 25 | 26 | struct PartitionEntry 27 | { 28 | unsigned char geometry[8]; // ignored 29 | unsigned long startlba; 30 | unsigned long sectors; 31 | }; 32 | 33 | struct MasterBootRecord 34 | { 35 | unsigned char bootcode[446]; // ignored 36 | struct PartitionEntry Partition[4]; // We copy these (and byteswap if need be) 37 | unsigned short Signature; // This lets us detect an MBR (and the need for byteswapping). 38 | }; 39 | 40 | extern struct PartitionEntry partitions[4]; // FirstBlock and LastBlock will be byteswapped as necessary 41 | extern int partitioncount; 42 | 43 | typedef struct 44 | { 45 | unsigned char Name[8]; /* filename, blank filled */ 46 | #define SLOT_EMPTY 0x00 /* slot has never been used */ 47 | #define SLOT_E5 0x05 /* the real value is 0xe5 */ 48 | #define SLOT_DELETED 0xe5 /* file in this slot deleted */ 49 | unsigned char Extension[3]; /* extension, blank filled */ 50 | unsigned char Attributes; /* file attributes */ 51 | #define ATTR_NORMAL 0x00 /* normal file */ 52 | #define ATTR_READONLY 0x01 /* file is readonly */ 53 | #define ATTR_HIDDEN 0x02 /* file is hidden */ 54 | #define ATTR_SYSTEM 0x04 /* file is a system file */ 55 | #define ATTR_VOLUME 0x08 /* entry is a volume label */ 56 | #define ATTR_DIRECTORY 0x10 /* entry is a directory name */ 57 | #define ATTR_ARCHIVE 0x20 /* file is new or modified */ 58 | #define ATTR_LFN 0x0F /* long file name entry */ 59 | unsigned char LowerCase; /* NT VFAT lower case flags */ 60 | #define LCASE_BASE 0x08 /* filename base in lower case */ 61 | #define LCASE_EXT 0x10 /* filename extension in lower case */ 62 | unsigned char CreateHundredth; /* hundredth of seconds in CTime */ 63 | unsigned short CreateTime; /* create time */ 64 | unsigned short CreateDate; /* create date */ 65 | unsigned short AccessDate; /* access date */ 66 | unsigned short HighCluster; /* high bytes of cluster number */ 67 | unsigned short ModifyTime; /* last update time */ 68 | unsigned short ModifyDate; /* last update date */ 69 | unsigned short StartCluster; /* starting cluster of file */ 70 | unsigned long FileSize; /* size of file in bytes */ 71 | } DIRENTRY; 72 | 73 | typedef union { 74 | unsigned short fat16[256]; 75 | unsigned long fat32[128]; 76 | } FATBUFFER; 77 | 78 | #define FILETIME(h,m,s) (((h<<11)&0xF800)|((m<<5)&0x7E0)|((s/2)&0x1F)) 79 | #define FILEDATE(y,m,d) ((((y-1980)<<9)&0xFE00)|((m<<5)&0x1E0)|(d&0x1F)) 80 | 81 | // global sector buffer, data for read/write actions is stored here. 82 | // BEWARE, this buffer is also used and thus trashed by all other functions 83 | extern unsigned char sector_buffer[1024]; // sector buffer - room for 2 sectors, to ease reading data not sector-aligned... 84 | extern unsigned char cluster_size; 85 | extern unsigned long cluster_mask; 86 | extern unsigned char fat32; 87 | 88 | // constants 89 | #define DIRECTORY_ROOT 0 90 | 91 | // file seeking 92 | #define SEEK_SET 0 93 | #define SEEK_CUR 1 94 | 95 | // scanning flags 96 | #define SCAN_INIT 0 // start search from beginning of directory 97 | #define SCAN_NEXT 1 // find next file in directory 98 | #define SCAN_PREV -1 // find previous file in directory 99 | #define SCAN_NEXT_PAGE 2 // find next 8 files in directory 100 | #define SCAN_PREV_PAGE -2 // find previous 8 files in directory 101 | #define SCAN_INIT_FIRST 3 // search for an entry with given cluster number 102 | #define SCAN_INIT_NEXT 4 // search for entries higher than the first one 103 | 104 | // options flags 105 | #define SCAN_DIR 1 // include subdirectories 106 | #define SCAN_LFN 2 // include long file names 107 | #define FIND_DIR 4 // find first directory beginning with given charater 108 | #define FIND_FILE 8 // find first file entry beginning with given charater 109 | 110 | 111 | // functions 112 | unsigned char FindDrive(void); 113 | unsigned long GetFATLink(unsigned long cluster); 114 | unsigned char FileNextSector(fileTYPE *file); 115 | unsigned char FileOpen(fileTYPE *file, const char *name); 116 | unsigned char FileSeek(fileTYPE *file, unsigned long offset, unsigned long origin); 117 | unsigned char FileRead(fileTYPE *file, unsigned char *pBuffer); 118 | unsigned char FileWrite(fileTYPE *file, unsigned char *pBuffer); 119 | unsigned char FileReadEx(fileTYPE *file, unsigned char *pBuffer, unsigned long nSize); 120 | 121 | unsigned char FileCreate(unsigned long iDirectory, fileTYPE *file); 122 | unsigned char UpdateEntry(fileTYPE *file); 123 | 124 | char ScanDirectory(unsigned long mode, char *extension, unsigned char options); 125 | void ChangeDirectory(unsigned long iStartCluster); 126 | 127 | #endif 128 | 129 | -------------------------------------------------------------------------------- /src/include/sys/cdefs.h: -------------------------------------------------------------------------------- 1 | /* libc/sys/linux/sys/cdefs.h - Helper macros for K&R vs. ANSI C compat. */ 2 | 3 | /* Written 2000 by Werner Almesberger */ 4 | 5 | /* 6 | * Copyright (c) 1991, 1993 7 | * The Regents of the University of California. All rights reserved. 8 | * 9 | * This code is derived from software contributed to Berkeley by 10 | * Berkeley Software Design, Inc. 11 | * 12 | * Redistribution and use in source and binary forms, with or without 13 | * modification, are permitted provided that the following conditions 14 | * are met: 15 | * 1. Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * 2. Redistributions in binary form must reproduce the above copyright 18 | * notice, this list of conditions and the following disclaimer in the 19 | * documentation and/or other materials provided with the distribution. 20 | * 3. All advertising materials mentioning features or use of this software 21 | * must display the following acknowledgement: 22 | * This product includes software developed by the University of 23 | * California, Berkeley and its contributors. 24 | * 4. Neither the name of the University nor the names of its contributors 25 | * may be used to endorse or promote products derived from this software 26 | * without specific prior written permission. 27 | * 28 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38 | * SUCH DAMAGE. 39 | * 40 | * @(#)cdefs.h 8.8 (Berkeley) 1/9/95 41 | * $FreeBSD: src/sys/sys/cdefs.h,v 1.54 2002/05/11 03:58:24 alfred Exp $ 42 | */ 43 | 44 | #ifndef _SYS_CDEFS_H 45 | #define _SYS_CDEFS_H 46 | 47 | #define __FBSDID(x) /* nothing */ 48 | /* 49 | * Note: the goal here is not compatibility to K&R C. Since we know that we 50 | * have GCC which understands ANSI C perfectly well, we make use of this. 51 | */ 52 | 53 | #define __P(args) args 54 | #define __PMT(args) args 55 | #define __const const 56 | #define __signed signed 57 | #define __volatile volatile 58 | #define __DOTS , ... 59 | #define __THROW 60 | 61 | /* 62 | * The __CONCAT macro is used to concatenate parts of symbol names, e.g. 63 | * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo. 64 | * The __CONCAT macro is a bit tricky to use if it must work in non-ANSI 65 | * mode -- there must be no spaces between its arguments, and for nested 66 | * __CONCAT's, all the __CONCAT's must be at the left. __CONCAT can also 67 | * concatenate double-quoted strings produced by the __STRING macro, but 68 | * this only works with ANSI C. 69 | * 70 | * __XSTRING is like __STRING, but it expands any macros in its argument 71 | * first. It is only available with ANSI C. 72 | */ 73 | #define __CONCAT1(x,y) x ## y 74 | #define __CONCAT(x,y) __CONCAT1(x,y) 75 | #define __STRING(x) #x /* stringify without expanding x */ 76 | #define __XSTRING(x) __STRING(x) /* expand x, then stringify */ 77 | 78 | #ifdef __GNUC__ 79 | # define __ASMNAME(cname) __XSTRING (__USER_LABEL_PREFIX__) cname 80 | #endif 81 | 82 | #define __ptr_t void * 83 | #define __long_double_t long double 84 | 85 | #define __attribute_malloc__ 86 | #define __attribute_pure__ 87 | #define __attribute_format_strfmon__(a,b) 88 | #define __flexarr [0] 89 | 90 | #ifdef __cplusplus 91 | # define __BEGIN_DECLS extern "C" { 92 | # define __END_DECLS } 93 | #else 94 | # define __BEGIN_DECLS 95 | # define __END_DECLS 96 | #endif 97 | 98 | #ifndef __BOUNDED_POINTERS__ 99 | # define __bounded /* nothing */ 100 | # define __unbounded /* nothing */ 101 | # define __ptrvalue /* nothing */ 102 | #endif 103 | 104 | #ifdef __GNUC__ 105 | #define __strong_reference(sym,aliassym) \ 106 | extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym))); 107 | #ifdef __ELF__ 108 | #ifdef __STDC__ 109 | #define __weak_reference(sym,alias) \ 110 | __asm__(".weak " #alias); \ 111 | __asm__(".equ " #alias ", " #sym) 112 | #define __warn_references(sym,msg) \ 113 | __asm__(".section .gnu.warning." #sym); \ 114 | __asm__(".asciz \"" msg "\""); \ 115 | __asm__(".previous") 116 | #else 117 | #define __weak_reference(sym,alias) \ 118 | __asm__(".weak alias"); \ 119 | __asm__(".equ alias, sym") 120 | #define __warn_references(sym,msg) \ 121 | __asm__(".section .gnu.warning.sym"); \ 122 | __asm__(".asciz \"msg\""); \ 123 | __asm__(".previous") 124 | #endif /* __STDC__ */ 125 | #else /* !__ELF__ */ 126 | #ifdef __STDC__ 127 | #define __weak_reference(sym,alias) \ 128 | __asm__(".stabs \"_" #alias "\",11,0,0,0"); \ 129 | __asm__(".stabs \"_" #sym "\",1,0,0,0") 130 | #define __warn_references(sym,msg) \ 131 | __asm__(".stabs \"" msg "\",30,0,0,0"); \ 132 | __asm__(".stabs \"_" #sym "\",1,0,0,0") 133 | #else 134 | #define __weak_reference(sym,alias) \ 135 | __asm__(".stabs \"_/**/alias\",11,0,0,0"); \ 136 | __asm__(".stabs \"_/**/sym\",1,0,0,0") 137 | #define __warn_references(sym,msg) \ 138 | __asm__(".stabs msg,30,0,0,0"); \ 139 | __asm__(".stabs \"_/**/sym\",1,0,0,0") 140 | #endif /* __STDC__ */ 141 | #endif /* __ELF__ */ 142 | #endif /* __GNUC__ */ 143 | 144 | #endif /* _SYS_CDEFS_H */ 145 | -------------------------------------------------------------------------------- /fampiga/board/JBboot.tdf: -------------------------------------------------------------------------------- 1 | -- megafunction wizard: %ROM: 1-PORT% 2 | -- GENERATION: STANDARD 3 | -- VERSION: WM1.0 4 | -- MODULE: altsyncram 5 | 6 | -- ============================================================ 7 | -- File Name: JBboot.tdf 8 | -- Megafunction Name(s): 9 | -- altsyncram 10 | -- 11 | -- Simulation Library Files(s): 12 | -- altera_mf 13 | -- ============================================================ 14 | -- ************************************************************ 15 | -- THIS IS A WIZARD-GENERATED FILE. DO NOT EDIT THIS FILE! 16 | -- 17 | -- 9.0 Build 184 04/29/2009 SP 1 SJ Web Edition 18 | -- ************************************************************ 19 | 20 | 21 | --Copyright (C) 1991-2009 Altera Corporation 22 | --Your use of Altera Corporation's design tools, logic functions 23 | --and other software and tools, and its AMPP partner logic 24 | --functions, and any output files from any of the foregoing 25 | --(including device programming or simulation files), and any 26 | --associated documentation or information are expressly subject 27 | --to the terms and conditions of the Altera Program License 28 | --Subscription Agreement, Altera MegaCore Function License 29 | --Agreement, or other applicable license agreement, including, 30 | --without limitation, that your use is for the sole purpose of 31 | --programming logic devices manufactured by Altera and sold by 32 | --Altera or its authorized distributors. Please refer to the 33 | --applicable agreement for further details. 34 | 35 | INCLUDE "altsyncram.inc"; 36 | 37 | 38 | 39 | SUBDESIGN JBboot 40 | ( 41 | address[9..0] : INPUT; 42 | clock : INPUT = VCC; 43 | q[15..0] : OUTPUT; 44 | ) 45 | 46 | VARIABLE 47 | 48 | altsyncram_component : altsyncram WITH ( 49 | ADDRESS_ACLR_A = "NONE", 50 | CLOCK_ENABLE_INPUT_A = "BYPASS", 51 | CLOCK_ENABLE_OUTPUT_A = "BYPASS", 52 | INIT_FILE = "../firmware/hostboot.hex", 53 | INTENDED_DEVICE_FAMILY = "Cyclone III", 54 | LPM_HINT = "ENABLE_RUNTIME_MOD=NO", 55 | LPM_TYPE = "altsyncram", 56 | NUMWORDS_A = 1024, 57 | OPERATION_MODE = "ROM", 58 | OUTDATA_ACLR_A = "NONE", 59 | OUTDATA_REG_A = "UNREGISTERED", 60 | WIDTHAD_A = 10, 61 | WIDTH_A = 16, 62 | WIDTH_BYTEENA_A = 1 63 | ); 64 | 65 | BEGIN 66 | 67 | q[15..0] = altsyncram_component.q_a[15..0]; 68 | altsyncram_component.clock0 = clock; 69 | altsyncram_component.address_a[9..0] = address[9..0]; 70 | END; 71 | 72 | 73 | 74 | -- ============================================================ 75 | -- CNX file retrieval info 76 | -- ============================================================ 77 | -- Retrieval info: PRIVATE: ADDRESSSTALL_A NUMERIC "0" 78 | -- Retrieval info: PRIVATE: AclrAddr NUMERIC "0" 79 | -- Retrieval info: PRIVATE: AclrByte NUMERIC "0" 80 | -- Retrieval info: PRIVATE: AclrOutput NUMERIC "0" 81 | -- Retrieval info: PRIVATE: BYTE_ENABLE NUMERIC "0" 82 | -- Retrieval info: PRIVATE: BYTE_SIZE NUMERIC "8" 83 | -- Retrieval info: PRIVATE: BlankMemory NUMERIC "0" 84 | -- Retrieval info: PRIVATE: CLOCK_ENABLE_INPUT_A NUMERIC "0" 85 | -- Retrieval info: PRIVATE: CLOCK_ENABLE_OUTPUT_A NUMERIC "0" 86 | -- Retrieval info: PRIVATE: Clken NUMERIC "0" 87 | -- Retrieval info: PRIVATE: IMPLEMENT_IN_LES NUMERIC "0" 88 | -- Retrieval info: PRIVATE: INIT_FILE_LAYOUT STRING "PORT_A" 89 | -- Retrieval info: PRIVATE: INIT_TO_SIM_X NUMERIC "0" 90 | -- Retrieval info: PRIVATE: INTENDED_DEVICE_FAMILY STRING "Cyclone III" 91 | -- Retrieval info: PRIVATE: JTAG_ENABLED NUMERIC "0" 92 | -- Retrieval info: PRIVATE: JTAG_ID STRING "NONE" 93 | -- Retrieval info: PRIVATE: MAXIMUM_DEPTH NUMERIC "0" 94 | -- Retrieval info: PRIVATE: MIFfilename STRING "../firmware/hostboot.hex" 95 | -- Retrieval info: PRIVATE: NUMWORDS_A NUMERIC "1024" 96 | -- Retrieval info: PRIVATE: RAM_BLOCK_TYPE NUMERIC "0" 97 | -- Retrieval info: PRIVATE: RegAddr NUMERIC "1" 98 | -- Retrieval info: PRIVATE: RegOutput NUMERIC "0" 99 | -- Retrieval info: PRIVATE: SYNTH_WRAPPER_GEN_POSTFIX STRING "0" 100 | -- Retrieval info: PRIVATE: SingleClock NUMERIC "1" 101 | -- Retrieval info: PRIVATE: UseDQRAM NUMERIC "0" 102 | -- Retrieval info: PRIVATE: WidthAddr NUMERIC "10" 103 | -- Retrieval info: PRIVATE: WidthData NUMERIC "16" 104 | -- Retrieval info: PRIVATE: rden NUMERIC "0" 105 | -- Retrieval info: CONSTANT: ADDRESS_ACLR_A STRING "NONE" 106 | -- Retrieval info: CONSTANT: CLOCK_ENABLE_INPUT_A STRING "BYPASS" 107 | -- Retrieval info: CONSTANT: CLOCK_ENABLE_OUTPUT_A STRING "BYPASS" 108 | -- Retrieval info: CONSTANT: INIT_FILE STRING "../firmware/hostboot.hex" 109 | -- Retrieval info: CONSTANT: INTENDED_DEVICE_FAMILY STRING "Cyclone III" 110 | -- Retrieval info: CONSTANT: LPM_HINT STRING "ENABLE_RUNTIME_MOD=NO" 111 | -- Retrieval info: CONSTANT: LPM_TYPE STRING "altsyncram" 112 | -- Retrieval info: CONSTANT: NUMWORDS_A NUMERIC "1024" 113 | -- Retrieval info: CONSTANT: OPERATION_MODE STRING "ROM" 114 | -- Retrieval info: CONSTANT: OUTDATA_ACLR_A STRING "NONE" 115 | -- Retrieval info: CONSTANT: OUTDATA_REG_A STRING "UNREGISTERED" 116 | -- Retrieval info: CONSTANT: WIDTHAD_A NUMERIC "10" 117 | -- Retrieval info: CONSTANT: WIDTH_A NUMERIC "16" 118 | -- Retrieval info: CONSTANT: WIDTH_BYTEENA_A NUMERIC "1" 119 | -- Retrieval info: USED_PORT: address 0 0 10 0 INPUT NODEFVAL address[9..0] 120 | -- Retrieval info: USED_PORT: clock 0 0 0 0 INPUT VCC clock 121 | -- Retrieval info: USED_PORT: q 0 0 16 0 OUTPUT NODEFVAL q[15..0] 122 | -- Retrieval info: CONNECT: @address_a 0 0 10 0 address 0 0 10 0 123 | -- Retrieval info: CONNECT: q 0 0 16 0 @q_a 0 0 16 0 124 | -- Retrieval info: CONNECT: @clock0 0 0 0 0 clock 0 0 0 0 125 | -- Retrieval info: LIBRARY: altera_mf altera_mf.altera_mf_components.all 126 | -- Retrieval info: GEN_FILE: TYPE_NORMAL JBboot.tdf TRUE 127 | -- Retrieval info: GEN_FILE: TYPE_NORMAL JBboot.inc TRUE 128 | -- Retrieval info: GEN_FILE: TYPE_NORMAL JBboot.cmp TRUE 129 | -- Retrieval info: GEN_FILE: TYPE_NORMAL JBboot.bsf FALSE 130 | -- Retrieval info: GEN_FILE: TYPE_NORMAL JBboot_inst.tdf FALSE 131 | -- Retrieval info: GEN_FILE: TYPE_NORMAL JBboot_waveforms.html TRUE 132 | -- Retrieval info: GEN_FILE: TYPE_NORMAL JBboot_wave*.jpg FALSE 133 | -- Retrieval info: LIB_FILE: altera_mf 134 | -------------------------------------------------------------------------------- /fampiga/board/chameleon_phi_clock_a.vhd: -------------------------------------------------------------------------------- 1 | -- ----------------------------------------------------------------------- 2 | -- 3 | -- VGA-64 4 | -- 5 | -- Multi purpose FPGA expansion for the Commodore 64 computer 6 | -- 7 | -- ----------------------------------------------------------------------- 8 | -- Copyright 2005-2018 by Peter Wendrich (pwsoft@syntiac.com) 9 | -- http://www.syntiac.com/chameleon.html 10 | -- 11 | -- This source file is free software: you can redistribute it and/or modify 12 | -- it under the terms of the GNU Lesser General Public License as published 13 | -- by the Free Software Foundation, either version 3 of the License, or 14 | -- (at your option) any later version. 15 | -- 16 | -- This source file is distributed in the hope that it will be useful, 17 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 | -- GNU General Public License for more details. 20 | -- 21 | -- You should have received a copy of the GNU General Public License 22 | -- along with this program. If not, see . 23 | -- 24 | -- ----------------------------------------------------------------------- 25 | -- 26 | -- C64 Phi2-clock regeneration and divider 27 | -- 28 | -- ----------------------------------------------------------------------- 29 | 30 | library IEEE; 31 | use IEEE.STD_LOGIC_1164.ALL; 32 | use IEEE.numeric_std.all; 33 | 34 | -- ----------------------------------------------------------------------- 35 | 36 | architecture rtl of chameleon_phi_clock is 37 | constant guardBits : integer := 4; -- Extra bits to reduce rounding errors in calculations 38 | signal phi2_n_reg : unsigned(11 downto 0) := (others => '0'); 39 | signal phiSync : std_logic := '0'; 40 | 41 | signal locCnt : unsigned(7 downto 0) := (others => '0'); 42 | signal fracCnt : unsigned(guardBits-1 downto 0) := (others => '0'); 43 | signal c64Cnt : unsigned(7 downto 0) := (others => '0'); 44 | signal slvCnt : unsigned(7 downto 0) := (others => '0'); 45 | 46 | signal avgDelta : signed(8 downto 0) := (others => '0'); 47 | signal avgLen : unsigned((7+guardBits) downto 0) := (others => '0'); 48 | 49 | signal localPreHalf : std_logic := '0'; 50 | signal localHalf : std_logic := '0'; 51 | signal localPreEnd : std_logic := '0'; 52 | signal localEnd : std_logic := '0'; 53 | 54 | signal localPhi : std_logic := '0'; 55 | 56 | signal localPost1 : std_logic := '0'; 57 | signal localPost2 : std_logic := '0'; 58 | signal localPost3 : std_logic := '0'; 59 | signal localPost4 : std_logic := '0'; 60 | begin 61 | -- Average phi length 62 | phiLength <= avgLen((7+guardBits) downto guardBits); 63 | 64 | -- Local generated phi 65 | phiLocal <= localPhi; 66 | 67 | -- Cycle counter (add 1 to max-counter for each Mhz system clock) 68 | -- For 100Mhz the cycle-counter runs to about 97 (NTSC) or 102 (PAL) 69 | phiCnt <= locCnt; 70 | phiPreHalf <= localPreHalf; 71 | phiHalf <= localHalf; 72 | phiPreEnd <= localPreEnd; 73 | phiEnd <= localEnd; 74 | 75 | phiPost1 <= localPost1; 76 | phiPost2 <= localPost2; 77 | phiPost3 <= localPost3; 78 | phiPost4 <= localPost4; 79 | 80 | -- Input clock synchronizer 81 | process(clk) is 82 | begin 83 | if rising_edge(clk) then 84 | phiSync <= '0'; 85 | phi2_n_reg <= phi2_n_reg(phi2_n_reg'high-1 downto 0) & phi2_n; 86 | -- Detect falling edge of phi2 (is rising edge here as phi2_n input is inverted). 87 | if phi2_n_reg = "000000000001" then 88 | phiSync <= '1'; 89 | end if; 90 | end if; 91 | end process; 92 | 93 | -- Determine cycle length 94 | process(clk) is 95 | begin 96 | if rising_edge(clk) then 97 | no_clock <= '0'; 98 | docking_station <= '0'; 99 | avgDelta <= (others => '0'); 100 | avgLen <= unsigned(signed(avgLen) + avgDelta); 101 | 102 | if (not c64Cnt) /= 0 then 103 | c64Cnt <= c64Cnt + 1; 104 | else 105 | -- No Sync? Use internal speed. 106 | 107 | -- Values for avgLen are determined experimentally using the testbench to measure actually speed. 108 | -- Higher numbers slow down clock. Lower numbers speed clock up. Try a few times until optimum is reached 109 | -- for particular system clock (100 Mhz at time of writing). Clocks can be accurate to atleast 3 digits with 4 guard bits. 110 | -- PAL mode 0.985248 Mhz 111 | avgLen <= to_unsigned(1703, 8+guardBits); 112 | if mode = '1' then 113 | -- NTSC mode 1.022727 Mhz 114 | avgLen <= to_unsigned(1643, 8+guardBits); 115 | end if; 116 | if phi2_n_reg(11 downto 4) = "11111111" then 117 | docking_station <= '1'; 118 | end if; 119 | no_clock <= '1'; 120 | end if; 121 | if phiSync = '1' then 122 | avgDelta <= signed("0" & c64Cnt) - signed("0" & avgLen((7+guardBits) downto guardBits)); 123 | c64Cnt <= (others => '0'); 124 | end if; 125 | end if; 126 | end process; 127 | 128 | process(clk) is 129 | begin 130 | if rising_edge(clk) then 131 | localPost1 <= localHalf or localEnd; 132 | localPost2 <= localPost1; 133 | localPost3 <= localPost2; 134 | localPost4 <= localPost3; 135 | end if; 136 | end process; 137 | 138 | process(clk) is 139 | variable newFrac : unsigned(fracCnt'high+1 downto fracCnt'low); 140 | begin 141 | if rising_edge(clk) then 142 | localPreHalf <= '0'; 143 | localHalf <= localPreHalf; 144 | localPreEnd <= '0'; 145 | localEnd <= localPreEnd; 146 | 147 | locCnt <= locCnt + 1; 148 | if slvCnt >= avgLen((7+guardBits) downto guardBits) then 149 | slvCnt <= (others => '0'); 150 | else 151 | slvCnt <= slvCnt + 1; 152 | end if; 153 | 154 | if (slvCnt + phase_shift) = avgLen((7+guardBits) downto (1+guardBits)) then 155 | localPreHalf <= '1'; 156 | end if; 157 | if (slvCnt + phase_shift) = avgLen((7+guardBits) downto guardBits) 158 | and localPhi = '1' then 159 | localPreEnd <= '1'; 160 | end if; 161 | if localHalf = '1' then 162 | localPhi <= '1'; 163 | end if; 164 | if localEnd = '1' then 165 | -- Add fractional part to clock counter to have higher precision 166 | newFrac := ("0" & fracCnt) + ("0" & (not avgLen(guardBits-1 downto 0))); 167 | fracCnt <= newFrac(fracCnt'range); 168 | 169 | localPhi <= '0'; 170 | locCnt <= (others => '0'); 171 | slvCnt <= c64Cnt + ("0000000" & newFrac(newFrac'high)); 172 | end if; 173 | end if; 174 | end process; 175 | end architecture; 176 | -------------------------------------------------------------------------------- /src/logo.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGO_H 2 | #define LOGO_H 3 | const unsigned char logodata[5][227] = { 4 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 5 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 6 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xc0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xe0, 0xc0, 12 | 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 14 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 15 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 18 | 0x00, 0x00, 0x00}, 19 | {0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 20 | 0x03, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 21 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x83, 0x83, 0x83, 0x83, 22 | 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x83, 0x83, 0x83, 23 | 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 24 | 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 25 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x03, 0x03, 26 | 0x03, 0x00, 0x00, 0x80, 0x83, 0x87, 0x87, 0x8f, 0x8f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x9f, 0x0f, 27 | 0x0f, 0x07, 0x07, 0x03, 0x00, 0x00, 0x00, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 28 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 29 | 0x03, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 30 | 0x03, 0x03, 0x03, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 31 | 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x83, 0x83, 32 | 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x03, 0x03, 0x03, 0x83, 33 | 0x83, 0x03, 0x03}, 34 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0xf0, 35 | 0x7c, 0x1e, 0x07, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfc, 0xc0, 0x00, 0x00, 0x00, 0x80, 36 | 0x80, 0xc0, 0x60, 0x20, 0x30, 0x18, 0x8c, 0xc4, 0xf6, 0xfb, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 37 | 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xfc, 0xff, 0xff, 0xff, 38 | 0xff, 0x3f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0x3c, 39 | 0x0e, 0x07, 0x03, 0x07, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 40 | 0x00, 0x00, 0x00, 0xc0, 0xf0, 0x38, 0x1e, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x80, 0xe0, 0xf0, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x3f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x00, 0x80, 0xc0, 0xf0, 0x7c, 0x1e, 0x07, 0x03, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 43 | 0xfc, 0xc0, 0x00, 0x00, 0x00, 0x80, 0x80, 0xc0, 0x60, 0x20, 0x30, 0x18, 0x8c, 0xc4, 0xf6, 0xfb, 44 | 0xff, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 45 | 0xc0, 0xf0, 0xf8, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x1f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 46 | 0xe0, 0xf0, 0xf8, 0xfc, 0xfc, 0xfe, 0xfe, 0xfe, 0x3e, 0x1f, 0x0f, 0x07, 0x07, 0x03, 0x03, 0x01, 47 | 0x01, 0x41, 0x41, 0x40, 0x40, 0xc0, 0xc0, 0xc0, 0xc0, 0xc1, 0xc1, 0xc1, 0xc3, 0x47, 0x47, 0x43, 48 | 0x00, 0x00, 0x00}, 49 | {0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x30, 0x30, 0x38, 0x3e, 0x2f, 0x23, 0x20, 50 | 0x20, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x3f, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x06, 0x03, 0x21, 0x21, 51 | 0x20, 0x20, 0x20, 0x30, 0x38, 0x3e, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x27, 0x21, 0x20, 0x00, 52 | 0x00, 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x3c, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x27, 0x21, 53 | 0x20, 0x20, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x3c, 0x3f, 0x27, 0x21, 0x20, 0x20, 54 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 55 | 0x3f, 0x1e, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x3c, 0x3f, 56 | 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x27, 0x21, 0x20, 0x20, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x30, 57 | 0x30, 0x38, 0x3e, 0x2f, 0x23, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x3f, 0x3f, 0x1f, 0x1f, 58 | 0x0f, 0x07, 0x06, 0x03, 0x21, 0x21, 0x20, 0x20, 0x20, 0x30, 0x38, 0x3e, 0x3f, 0x3f, 0x3f, 0x3f, 59 | 0x3f, 0x3f, 0x27, 0x21, 0x20, 0x00, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x30, 0x38, 0x3e, 0x3f, 60 | 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x27, 0x21, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 61 | 0x03, 0x07, 0x0f, 0x0f, 0x1f, 0x1f, 0x1f, 0x3f, 0x38, 0x38, 0x30, 0x30, 0x20, 0x20, 0x20, 0x20, 62 | 0x20, 0x30, 0x38, 0x3c, 0x3f, 0x3f, 0x3f, 0x1f, 0x1f, 0x0f, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 63 | 0x00, 0x00, 0x00}, 64 | {0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 65 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 66 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 67 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 68 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 69 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 70 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 71 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 72 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 73 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 74 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 75 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 76 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 77 | 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 78 | 0x18, 0x18, 0x18} 79 | }; 80 | #endif 81 | -------------------------------------------------------------------------------- /src/hardware.c: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2008, 2009 Jakub Bednarski 3 | 4 | This file is part of Minimig 5 | 6 | Minimig is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | Minimig is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | */ 19 | 20 | //#include "stdio.h" 21 | #include "hardware.h" 22 | 23 | //void __init_hardware(void) 24 | //{ 25 | // *AT91C_WDTC_WDMR = AT91C_WDTC_WDDIS; // disable watchdog 26 | // *AT91C_RSTC_RMR = (0xA5 << 24) | AT91C_RSTC_URSTEN; // enable external user reset input 27 | // *AT91C_MC_FMR = FWS << 8; // Flash wait states 28 | // 29 | // // configure clock generator 30 | // *AT91C_CKGR_MOR = AT91C_CKGR_MOSCEN | (40 << 8); 31 | // while (!(*AT91C_PMC_SR & AT91C_PMC_MOSCS)); 32 | // 33 | // *AT91C_CKGR_PLLR = AT91C_CKGR_OUT_0 | AT91C_CKGR_USBDIV_1 | (25 << 16) | (40 << 8) | 5; // DIV=5 MUL=26 USBDIV=1 (2) PLLCOUNT=40 34 | // while (!(*AT91C_PMC_SR & AT91C_PMC_LOCK)); 35 | // 36 | // *AT91C_PMC_MCKR = AT91C_PMC_PRES_CLK_2; // master clock register: clock source selection 37 | // while (!(*AT91C_PMC_SR & AT91C_PMC_MCKRDY)); 38 | // 39 | // *AT91C_PMC_MCKR = AT91C_PMC_CSS_PLL_CLK | AT91C_PMC_PRES_CLK_2; // master clock register: clock source selection 40 | // while (!(*AT91C_PMC_SR & AT91C_PMC_MCKRDY)); 41 | // 42 | // *AT91C_PIOA_PER = 0xFFFFFFFF; // enable pio 43 | // *AT91C_PIOA_CODR = DISKLED; // clear output data register 44 | // *AT91C_PIOA_SODR = MMC_SEL | MMC_CLKEN | CCLK | DIN | PROG_B | FPGA0 | FPGA1 | FPGA2; // set output data register 45 | // 46 | // // output enable register 47 | // *AT91C_PIOA_OER = DISKLED | MMC_SEL | CCLK | DIN | PROG_B | FPGA0 | FPGA1 | FPGA2; 48 | // // pull-up disable register 49 | // *AT91C_PIOA_PPUDR = DISKLED | MMC_SEL | MMC_CLKEN | CCLK | DIN | PROG_B | FPGA0 | FPGA1 | FPGA2; 50 | // 51 | // // Enable peripheral clock in the PMC 52 | // AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PIOA; 53 | //} 54 | 55 | //void USART_Init(unsigned long baudrate) 56 | //{ 57 | // // Configure PA5 and PA6 for USART0 use 58 | // AT91C_BASE_PIOA->PIO_PDR = AT91C_PA5_RXD0 | AT91C_PA6_TXD0; 59 | // 60 | // // Enable the peripheral clock in the PMC 61 | // AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_US0; 62 | // 63 | // // Reset and disable receiver & transmitter 64 | // AT91C_BASE_US0->US_CR = AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS; 65 | // 66 | // // Configure USART0 mode 67 | // AT91C_BASE_US0->US_MR = AT91C_US_USMODE_NORMAL | AT91C_US_CLKS_CLOCK | AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE | AT91C_US_NBSTOP_1_BIT | AT91C_US_CHMODE_NORMAL; 68 | // 69 | // // Configure USART0 rate 70 | // AT91C_BASE_US0->US_BRGR = MCLK / 16 / baudrate; 71 | // 72 | // // Enable receiver & transmitter 73 | // AT91C_BASE_US0->US_CR = AT91C_US_RXEN | AT91C_US_TXEN; 74 | //} 75 | 76 | //void USART_Write(unsigned char c) 77 | //{ 78 | // while (!(AT91C_BASE_US0->US_CSR & AT91C_US_TXEMPTY)); 79 | // AT91C_BASE_US0->US_THR = c; 80 | //} 81 | 82 | //signed int fputc(unsigned char c, FILE *pStream) 83 | //{ 84 | // if ((pStream == stdout) || (pStream == stderr)) 85 | // { 86 | // USART_Write((unsigned char)c); 87 | // return c; 88 | // } 89 | // 90 | // return EOF; 91 | //} 92 | 93 | //void SPI_Init() 94 | //{ 95 | // // Enable the peripheral clock in the PMC 96 | // AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_SPI; 97 | // 98 | // // Enable SPI interface 99 | // *AT91C_SPI_CR = AT91C_SPI_SPIEN; 100 | // 101 | // // SPI Mode Register 102 | // *AT91C_SPI_MR = AT91C_SPI_MSTR | AT91C_SPI_MODFDIS | (0x0E << 16); 103 | // 104 | // // SPI CS register 105 | // AT91C_SPI_CSR[0] = AT91C_SPI_CPOL | (48 << 8) | (0x00 << 16) | (0x01 << 24); 106 | // 107 | // // Configure pins for SPI use 108 | // AT91C_BASE_PIOA->PIO_PDR = AT91C_PA14_SPCK | AT91C_PA13_MOSI | AT91C_PA12_MISO; 109 | //} 110 | 111 | //#pragma section_code_init 112 | //#pragma inline 113 | //unsigned char SPI(unsigned char outByte) 114 | //{ 115 | // unsigned long t = *AT91C_SPI_RDR; 116 | // while (!(*AT91C_SPI_SR & AT91C_SPI_TDRE)); 117 | // *AT91C_SPI_TDR = outByte; 118 | // while (!(*AT91C_SPI_SR & AT91C_SPI_RDRF)); 119 | // return((unsigned char)*AT91C_SPI_RDR); 120 | //} 121 | //#pragma noinline 122 | 123 | //#pragma inline 124 | //void SPI_Wait4XferEnd() 125 | //{ 126 | // while (!(*AT91C_SPI_SR & AT91C_SPI_TXEMPTY)); 127 | //} 128 | //#pragma noinline 129 | 130 | //#pragma inline 131 | //void EnableCard() 132 | //{ 133 | // *AT91C_PIOA_CODR = MMC_SEL; // clear output (MMC chip select enabled) 134 | //} 135 | //#pragma noinline 136 | // 137 | //#pragma inline 138 | //void DisableCard() 139 | //{ 140 | // SPI_Wait4XferEnd(); 141 | // *AT91C_PIOA_SODR = MMC_SEL; // set output (MMC chip select disabled) 142 | // SPI(0xFF); 143 | // SPI_Wait4XferEnd(); 144 | //} 145 | //#pragma noinline 146 | //#pragma section_no_code_init 147 | // 148 | //void EnableFpga() 149 | //{ 150 | // *AT91C_PIOA_CODR = FPGA0; // clear output 151 | //} 152 | // 153 | //void DisableFpga() 154 | //{ 155 | // SPI_Wait4XferEnd(); 156 | // *AT91C_PIOA_SODR = FPGA0; // set output 157 | //} 158 | // 159 | //void EnableOsd() 160 | //{ 161 | // *AT91C_PIOA_CODR = FPGA1; // clear output 162 | //} 163 | // 164 | //void DisableOsd() 165 | //{ 166 | // SPI_Wait4XferEnd(); 167 | // *AT91C_PIOA_SODR = FPGA1; // set output 168 | //} 169 | 170 | unsigned long CheckButton(void) 171 | { 172 | // return((~*AT91C_PIOA_PDSR) & BUTTON); 173 | return(0); 174 | } 175 | 176 | //void Timer_Init(void) 177 | //{ 178 | // *AT91C_PITC_PIMR = AT91C_PITC_PITEN | ((MCLK / 16 / 1000 - 1) & AT91C_PITC_PIV); // counting period 1ms 179 | //} 180 | // 181 | unsigned long GetTimer(unsigned long offset) 182 | { 183 | unsigned long systimer = (*(volatile unsigned short *)0xDEE010); 184 | systimer = systimer<< 16; 185 | systimer += offset << 16; 186 | return (systimer); // valid bits [31:16] 187 | } 188 | 189 | unsigned long CheckTimer(unsigned long time) 190 | { 191 | unsigned long systimer = (*(volatile unsigned short *)0xDEE010); 192 | systimer = systimer<< 16; 193 | // printf("systimer:%08X ",systimer); 194 | time -= systimer; 195 | if(time & 0x80000000) 196 | return(1); 197 | return(0); 198 | // return(time > systimer); 199 | } 200 | 201 | void WaitTimer(unsigned long time) 202 | { 203 | time = GetTimer(time); 204 | while (!CheckTimer(time)); 205 | } 206 | 207 | void ConfigFastRAM(unsigned char memory) 208 | { 209 | short mem=((memory&0x80)<<8)|(memory&0x07); // Map bit 8 to bit 16 (turbo chip) 210 | if(mem & 0x04) 211 | mem |=0x3; // Map 0x4 -> 0x7 212 | PLATFORM=mem; 213 | } 214 | 215 | 216 | void Reconfigure() 217 | { 218 | RECONFIGURE=0; // A write to this register triggers a reconfig 219 | } 220 | 221 | -------------------------------------------------------------------------------- /fampiga/chameleon/chameleon_cdtv_remote.bsf: -------------------------------------------------------------------------------- 1 | /* 2 | WARNING: Do NOT edit the input and output ports in this file in a text 3 | editor if you plan to continue editing the block that represents it in 4 | the Block Editor! File corruption is VERY likely to occur. 5 | */ 6 | /* 7 | Copyright (C) 1991-2009 Altera Corporation 8 | Your use of Altera Corporation's design tools, logic functions 9 | and other software and tools, and its AMPP partner logic 10 | functions, and any output files from any of the foregoing 11 | (including device programming or simulation files), and any 12 | associated documentation or information are expressly subject 13 | to the terms and conditions of the Altera Program License 14 | Subscription Agreement, Altera MegaCore Function License 15 | Agreement, or other applicable license agreement, including, 16 | without limitation, that your use is for the sole purpose of 17 | programming logic devices manufactured by Altera and sold by 18 | Altera or its authorized distributors. Please refer to the 19 | applicable agreement for further details. 20 | */ 21 | (header "symbol" (version "1.1")) 22 | (symbol 23 | (rect 16 16 192 464) 24 | (text "chameleon_cdtv_remote" (rect 5 0 126 12)(font "Arial" )) 25 | (text "inst" (rect 8 432 25 444)(font "Arial" )) 26 | (port 27 | (pt 0 32) 28 | (input) 29 | (text "clk" (rect 0 0 14 12)(font "Arial" )) 30 | (text "clk" (rect 21 27 35 39)(font "Arial" )) 31 | (line (pt 0 32)(pt 16 32)(line_width 1)) 32 | ) 33 | (port 34 | (pt 0 48) 35 | (input) 36 | (text "ena_1mhz" (rect 0 0 49 12)(font "Arial" )) 37 | (text "ena_1mhz" (rect 21 43 70 55)(font "Arial" )) 38 | (line (pt 0 48)(pt 16 48)(line_width 1)) 39 | ) 40 | (port 41 | (pt 0 64) 42 | (input) 43 | (text "ir" (rect 0 0 5 12)(font "Arial" )) 44 | (text "ir" (rect 21 59 26 71)(font "Arial" )) 45 | (line (pt 0 64)(pt 16 64)(line_width 1)) 46 | ) 47 | (port 48 | (pt 176 32) 49 | (output) 50 | (text "trigger" (rect 0 0 30 12)(font "Arial" )) 51 | (text "trigger" (rect 125 27 155 39)(font "Arial" )) 52 | (line (pt 176 32)(pt 160 32)(line_width 1)) 53 | ) 54 | (port 55 | (pt 176 48) 56 | (output) 57 | (text "key_1" (rect 0 0 30 12)(font "Arial" )) 58 | (text "key_1" (rect 125 43 155 55)(font "Arial" )) 59 | (line (pt 176 48)(pt 160 48)(line_width 1)) 60 | ) 61 | (port 62 | (pt 176 64) 63 | (output) 64 | (text "key_2" (rect 0 0 30 12)(font "Arial" )) 65 | (text "key_2" (rect 125 59 155 71)(font "Arial" )) 66 | (line (pt 176 64)(pt 160 64)(line_width 1)) 67 | ) 68 | (port 69 | (pt 176 80) 70 | (output) 71 | (text "key_3" (rect 0 0 30 12)(font "Arial" )) 72 | (text "key_3" (rect 125 75 155 87)(font "Arial" )) 73 | (line (pt 176 80)(pt 160 80)(line_width 1)) 74 | ) 75 | (port 76 | (pt 176 96) 77 | (output) 78 | (text "key_4" (rect 0 0 30 12)(font "Arial" )) 79 | (text "key_4" (rect 125 91 155 103)(font "Arial" )) 80 | (line (pt 176 96)(pt 160 96)(line_width 1)) 81 | ) 82 | (port 83 | (pt 176 112) 84 | (output) 85 | (text "key_5" (rect 0 0 30 12)(font "Arial" )) 86 | (text "key_5" (rect 125 107 155 119)(font "Arial" )) 87 | (line (pt 176 112)(pt 160 112)(line_width 1)) 88 | ) 89 | (port 90 | (pt 176 128) 91 | (output) 92 | (text "key_6" (rect 0 0 30 12)(font "Arial" )) 93 | (text "key_6" (rect 125 123 155 135)(font "Arial" )) 94 | (line (pt 176 128)(pt 160 128)(line_width 1)) 95 | ) 96 | (port 97 | (pt 176 144) 98 | (output) 99 | (text "key_7" (rect 0 0 30 12)(font "Arial" )) 100 | (text "key_7" (rect 125 139 155 151)(font "Arial" )) 101 | (line (pt 176 144)(pt 160 144)(line_width 1)) 102 | ) 103 | (port 104 | (pt 176 160) 105 | (output) 106 | (text "key_8" (rect 0 0 30 12)(font "Arial" )) 107 | (text "key_8" (rect 125 155 155 167)(font "Arial" )) 108 | (line (pt 176 160)(pt 160 160)(line_width 1)) 109 | ) 110 | (port 111 | (pt 176 176) 112 | (output) 113 | (text "key_9" (rect 0 0 30 12)(font "Arial" )) 114 | (text "key_9" (rect 125 171 155 183)(font "Arial" )) 115 | (line (pt 176 176)(pt 160 176)(line_width 1)) 116 | ) 117 | (port 118 | (pt 176 192) 119 | (output) 120 | (text "key_0" (rect 0 0 30 12)(font "Arial" )) 121 | (text "key_0" (rect 125 187 155 199)(font "Arial" )) 122 | (line (pt 176 192)(pt 160 192)(line_width 1)) 123 | ) 124 | (port 125 | (pt 176 208) 126 | (output) 127 | (text "key_escape" (rect 0 0 60 12)(font "Arial" )) 128 | (text "key_escape" (rect 95 203 155 215)(font "Arial" )) 129 | (line (pt 176 208)(pt 160 208)(line_width 1)) 130 | ) 131 | (port 132 | (pt 176 224) 133 | (output) 134 | (text "key_enter" (rect 0 0 49 12)(font "Arial" )) 135 | (text "key_enter" (rect 106 219 155 231)(font "Arial" )) 136 | (line (pt 176 224)(pt 160 224)(line_width 1)) 137 | ) 138 | (port 139 | (pt 176 240) 140 | (output) 141 | (text "key_genlock" (rect 0 0 62 12)(font "Arial" )) 142 | (text "key_genlock" (rect 93 235 155 247)(font "Arial" )) 143 | (line (pt 176 240)(pt 160 240)(line_width 1)) 144 | ) 145 | (port 146 | (pt 176 256) 147 | (output) 148 | (text "key_cdtv" (rect 0 0 47 12)(font "Arial" )) 149 | (text "key_cdtv" (rect 108 251 155 263)(font "Arial" )) 150 | (line (pt 176 256)(pt 160 256)(line_width 1)) 151 | ) 152 | (port 153 | (pt 176 272) 154 | (output) 155 | (text "key_power" (rect 0 0 53 12)(font "Arial" )) 156 | (text "key_power" (rect 102 267 155 279)(font "Arial" )) 157 | (line (pt 176 272)(pt 160 272)(line_width 1)) 158 | ) 159 | (port 160 | (pt 176 288) 161 | (output) 162 | (text "key_rew" (rect 0 0 41 12)(font "Arial" )) 163 | (text "key_rew" (rect 114 283 155 295)(font "Arial" )) 164 | (line (pt 176 288)(pt 160 288)(line_width 1)) 165 | ) 166 | (port 167 | (pt 176 304) 168 | (output) 169 | (text "key_play" (rect 0 0 46 12)(font "Arial" )) 170 | (text "key_play" (rect 109 299 155 311)(font "Arial" )) 171 | (line (pt 176 304)(pt 160 304)(line_width 1)) 172 | ) 173 | (port 174 | (pt 176 320) 175 | (output) 176 | (text "key_ff" (rect 0 0 34 12)(font "Arial" )) 177 | (text "key_ff" (rect 121 315 155 327)(font "Arial" )) 178 | (line (pt 176 320)(pt 160 320)(line_width 1)) 179 | ) 180 | (port 181 | (pt 176 336) 182 | (output) 183 | (text "key_stop" (rect 0 0 46 12)(font "Arial" )) 184 | (text "key_stop" (rect 109 331 155 343)(font "Arial" )) 185 | (line (pt 176 336)(pt 160 336)(line_width 1)) 186 | ) 187 | (port 188 | (pt 176 352) 189 | (output) 190 | (text "key_vol_up" (rect 0 0 57 12)(font "Arial" )) 191 | (text "key_vol_up" (rect 98 347 155 359)(font "Arial" )) 192 | (line (pt 176 352)(pt 160 352)(line_width 1)) 193 | ) 194 | (port 195 | (pt 176 368) 196 | (output) 197 | (text "key_vol_dn" (rect 0 0 57 12)(font "Arial" )) 198 | (text "key_vol_dn" (rect 98 363 155 375)(font "Arial" )) 199 | (line (pt 176 368)(pt 160 368)(line_width 1)) 200 | ) 201 | (port 202 | (pt 176 384) 203 | (output) 204 | (text "joystick_a[5..0]" (rect 0 0 76 12)(font "Arial" )) 205 | (text "joystick_a[5..0]" (rect 79 379 155 391)(font "Arial" )) 206 | (line (pt 176 384)(pt 160 384)(line_width 3)) 207 | ) 208 | (port 209 | (pt 176 400) 210 | (output) 211 | (text "joystick_b[5..0]" (rect 0 0 76 12)(font "Arial" )) 212 | (text "joystick_b[5..0]" (rect 79 395 155 407)(font "Arial" )) 213 | (line (pt 176 400)(pt 160 400)(line_width 3)) 214 | ) 215 | (drawing 216 | (rectangle (rect 16 16 160 432)(line_width 1)) 217 | ) 218 | ) 219 | --------------------------------------------------------------------------------