summaryrefslogtreecommitdiff
path: root/demontsc/lib/TVout/spec
diff options
context:
space:
mode:
Diffstat (limited to 'demontsc/lib/TVout/spec')
-rwxr-xr-xdemontsc/lib/TVout/spec/asm_macros.h144
-rwxr-xr-xdemontsc/lib/TVout/spec/hardware_setup.h146
-rwxr-xr-xdemontsc/lib/TVout/spec/video_properties.h67
3 files changed, 357 insertions, 0 deletions
diff --git a/demontsc/lib/TVout/spec/asm_macros.h b/demontsc/lib/TVout/spec/asm_macros.h
new file mode 100755
index 0000000..1f91c11
--- /dev/null
+++ b/demontsc/lib/TVout/spec/asm_macros.h
@@ -0,0 +1,144 @@
+/*
+ Copyright (c) 2010 Myles Metzer
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include "hardware_setup.h"
+
+#ifndef ASM_MACROS_H
+#define ASM_MACROS_H
+
+// delay macros
+__asm__ __volatile__ (
+ // delay 1 clock cycle.
+ ".macro delay1\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 2 clock cycles
+ ".macro delay2\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 3 clock cyles
+ ".macro delay3\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 4 clock cylces
+ ".macro delay4\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 5 clock cylces
+ ".macro delay5\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 6 clock cylces
+ ".macro delay6\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 7 clock cylces
+ ".macro delay7\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 8 clock cylces
+ ".macro delay8\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 9 clock cylces
+ ".macro delay9\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+
+ // delay 10 clock cylces
+ ".macro delay10\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "nop\n"
+ ".endm\n"
+); // end of delay macros
+
+// common output macros, specific output macros at top of file
+__asm__ __volatile__ (
+
+ // save port 16 and clear the video bit
+ ".macro svprt p\n\t"
+ "in r16,\\p\n\t"
+ ANDI_HWS
+ ".endm\n"
+
+ // ouput 1 bit port safe
+ ".macro o1bs p\n\t"
+ BLD_HWS
+ "out \\p,r16\n"
+ ".endm\n"
+); // end of output macros
+#endif \ No newline at end of file
diff --git a/demontsc/lib/TVout/spec/hardware_setup.h b/demontsc/lib/TVout/spec/hardware_setup.h
new file mode 100755
index 0000000..c11e18c
--- /dev/null
+++ b/demontsc/lib/TVout/spec/hardware_setup.h
@@ -0,0 +1,146 @@
+/*
+ Copyright (c) 2010 Myles Metzer
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+// sound is output on OC2A
+// sync output is on OC1A
+
+//ENABLE_FAST_OUTPUT chooses the highest bit of a port over the original output method
+//comment out this line to switch back to the original output pins.
+#define ENABLE_FAST_OUTPUT
+
+#ifndef HARDWARE_SETUP_H
+#define HARDWARE_SETUP_H
+
+// device specific settings.
+#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__)
+#if defined(ENABLE_FAST_OUTPUT)
+#define PORT_VID PORTA
+#define DDR_VID DDRA
+#define VID_PIN 7
+#else
+//video
+#define PORT_VID PORTB
+#define DDR_VID DDRB
+#define VID_PIN 6
+#endif
+//sync
+#define PORT_SYNC PORTB
+#define DDR_SYNC DDRB
+#define SYNC_PIN 5
+//sound
+#define PORT_SND PORTB
+#define DDR_SND DDRB
+#define SND_PIN 4
+
+#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284__) || defined(__AVR_ATmega1284P__)
+//video
+#if defined(ENABLE_FAST_OUTPUT)
+#define PORT_VID PORTA
+#define DDR_VID DDRA
+#define VID_PIN 7
+#else
+#define PORT_VID PORTD
+#define DDR_VID DDRD
+#define VID_PIN 4
+#endif
+//sync
+#define PORT_SYNC PORTD
+#define DDR_SYNC DDRD
+#define SYNC_PIN 5
+//sound
+#define PORT_SND PORTD
+#define DDR_SND DDRD
+#define SND_PIN 7
+
+#elif defined(__AVR_ATmega8__) || defined(__AVR_ATmega88__) || defined(__AVR_ATmega168P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__) || defined(__AVR_ATmega328__)
+//video
+#if defined(ENABLE_FAST_OUTPUT)
+#define PORT_VID PORTD
+#define DDR_VID DDRD
+#define VID_PIN 7
+#else
+#define PORT_VID PORTB
+#define DDR_VID DDRB
+#define VID_PIN 0
+#endif
+//sync
+#define PORT_SYNC PORTB
+#define DDR_SYNC DDRB
+#define SYNC_PIN 1
+//sound
+#define PORT_SND PORTB
+#define DDR_SND DDRB
+#define SND_PIN 3
+
+#elif defined (__AVR_AT90USB1286__)
+//video
+#define PORT_VID PORTF
+#define DDR_VID DDRF
+#define VID_PIN 7
+//sync
+#define PORT_SYNC PORTB
+#define DDR_SYNC DDRB
+#define SYNC_PIN 5
+//sound
+#define PORT_SND PORTB
+#define DDR_SND DDRB
+#define SND_PIN 4
+#endif
+
+//automatic BST/BLD/ANDI macro definition
+#if VID_PIN == 0
+#define BLD_HWS "bld r16,0\n\t"
+#define BST_HWS "bst r16,0\n\t"
+#define ANDI_HWS "andi r16,0xFE\n"
+#elif VID_PIN == 1
+#define BLD_HWS "bld r16,1\n\t"
+#define BST_HWS "bst r16,1\n\t"
+#define ANDI_HWS "andi r16,0xFD\n"
+#elif VID_PIN == 2
+#define BLD_HWS "bld r16,2\n\t"
+#define BST_HWS "bst r16,2\n\t"
+#define ANDI_HWS "andi r16,0xFB\n"
+#elif VID_PIN == 3
+#define BLD_HWS "bld r16,3\n\t"
+#define BST_HWS "bst r16,3\n\t"
+#define ANDI_HWS "andi r16,0xF7\n"
+#elif VID_PIN == 4
+#define BLD_HWS "bld r16,4\n\t"
+#define BST_HWS "bst r16,4\n\t"
+#define ANDI_HWS "andi r16,0xEF\n"
+#elif VID_PIN == 5
+#define BLD_HWS "bld r16,5\n\t"
+#define BST_HWS "bst r16,5\n\t"
+#define ANDI_HWS "andi r16,0xDF\n"
+#elif VID_PIN == 6
+#define BLD_HWS "bld r16,6\n\t"
+#define BST_HWS "bst r16,6\n\t"
+#define ANDI_HWS "andi r16,0xBF\n"
+#elif VID_PIN == 7
+#define BLD_HWS "bld r16,7\n\t"
+#define BST_HWS "bst r16,7\n\t"
+#define ANDI_HWS "andi r16,0x7F\n"
+#endif
+#endif \ No newline at end of file
diff --git a/demontsc/lib/TVout/spec/video_properties.h b/demontsc/lib/TVout/spec/video_properties.h
new file mode 100755
index 0000000..006cf37
--- /dev/null
+++ b/demontsc/lib/TVout/spec/video_properties.h
@@ -0,0 +1,67 @@
+/*
+ Copyright (c) 2010 Myles Metzer
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation
+ files (the "Software"), to deal in the Software without
+ restriction, including without limitation the rights to use,
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following
+ conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/*
+ This File contains the timing definitions for the TVout AVR composite video
+ generation Library
+*/
+#ifndef VIDEO_TIMING_H
+#define VIDEO_TIMING_H
+
+#define _CYCLES_PER_US (F_CPU / 1000000)
+
+#define _TIME_HORZ_SYNC 4.7
+#define _TIME_VIRT_SYNC 58.85
+#define _TIME_ACTIVE 46
+#define _CYCLES_VIRT_SYNC ((_TIME_VIRT_SYNC * _CYCLES_PER_US) - 1)
+#define _CYCLES_HORZ_SYNC ((_TIME_HORZ_SYNC * _CYCLES_PER_US) - 1)
+
+//Timing settings for NTSC
+#define _NTSC_TIME_SCANLINE 63.55
+#define _NTSC_TIME_OUTPUT_START 12
+
+#define _NTSC_LINE_FRAME 262
+#define _NTSC_LINE_START_VSYNC 0
+#define _NTSC_LINE_STOP_VSYNC 3
+#define _NTSC_LINE_DISPLAY 216
+#define _NTSC_LINE_MID ((_NTSC_LINE_FRAME - _NTSC_LINE_DISPLAY)/2 + _NTSC_LINE_DISPLAY/2)
+
+#define _NTSC_CYCLES_SCANLINE ((_NTSC_TIME_SCANLINE * _CYCLES_PER_US) - 1)
+#define _NTSC_CYCLES_OUTPUT_START ((_NTSC_TIME_OUTPUT_START * _CYCLES_PER_US) - 1)
+
+//Timing settings for PAL
+#define _PAL_TIME_SCANLINE 64
+#define _PAL_TIME_OUTPUT_START 12.5
+
+#define _PAL_LINE_FRAME 312
+#define _PAL_LINE_START_VSYNC 0
+#define _PAL_LINE_STOP_VSYNC 7
+#define _PAL_LINE_DISPLAY 260
+#define _PAL_LINE_MID ((_PAL_LINE_FRAME - _PAL_LINE_DISPLAY)/2 + _PAL_LINE_DISPLAY/2)
+
+#define _PAL_CYCLES_SCANLINE ((_PAL_TIME_SCANLINE * _CYCLES_PER_US) - 1)
+#define _PAL_CYCLES_OUTPUT_START ((_PAL_TIME_OUTPUT_START * _CYCLES_PER_US) - 1)
+
+#endif \ No newline at end of file