1 /*
2  * ted-timing.c - Timing related settings for the TED emulation.
3  *
4  * Written by
5  *  Andreas Boose <viceteam@t-online.de>
6  *  Tibor Biczo <crown@axelero.hu>
7  *
8  * This file is part of VICE, the Versatile Commodore Emulator.
9  * See README for copyright notice.
10  *
11  *  This program is free software; you can redistribute it and/or modify
12  *  it under the terms of the GNU General Public License as published by
13  *  the Free Software Foundation; either version 2 of the License, or
14  *  (at your option) any later version.
15  *
16  *  This program 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, write to the Free Software
23  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24  *  02111-1307  USA.
25  *
26  */
27 
28 #include "vice.h"
29 
30 #include "machine.h"
31 #include "plus4.h"
32 #include "resources.h"
33 #include "ted-timing.h"
34 #include "ted.h"
35 #include "tedtypes.h"
36 
37 /* Number of cycles per line.  */
38 #define TED_PAL_CYCLES_PER_LINE     PLUS4_PAL_CYCLES_PER_LINE
39 #define TED_NTSC_CYCLES_PER_LINE    PLUS4_NTSC_CYCLES_PER_LINE
40 
41 /* Cycle # at which the current raster line is re-drawn.  It is set to
42    `TED_CYCLES_PER_LINE', so this actually happens at the very beginning
43    (i.e. cycle 0) of the next line.  */
44 #define TED_PAL_DRAW_CYCLE          TED_PAL_CYCLES_PER_LINE
45 #define TED_NTSC_DRAW_CYCLE         TED_NTSC_CYCLES_PER_LINE
46 
ted_timing_set(machine_timing_t * machine_timing,int border_mode)47 void ted_timing_set(machine_timing_t *machine_timing, int border_mode)
48 {
49     int mode;
50 
51     resources_get_int("MachineVideoStandard", &mode);
52 
53     switch (mode) {
54         case MACHINE_SYNC_NTSC:
55             ted.screen_height = TED_NTSC_SCREEN_HEIGHT;
56             switch (border_mode) {
57                 default:
58                 case TED_NORMAL_BORDERS:
59                     ted.first_displayed_line = TED_NTSC_NORMAL_FIRST_DISPLAYED_LINE;
60                     ted.last_displayed_line = TED_NTSC_NORMAL_LAST_DISPLAYED_LINE;
61                     ted.screen_rightborderwidth = TED_SCREEN_NTSC_NORMAL_LEFTBORDERWIDTH;
62                     ted.screen_leftborderwidth = TED_SCREEN_NTSC_NORMAL_RIGHTBORDERWIDTH;
63                     break;
64                 case TED_FULL_BORDERS:
65                     ted.first_displayed_line = TED_NTSC_FULL_FIRST_DISPLAYED_LINE;
66                     ted.last_displayed_line = TED_NTSC_FULL_LAST_DISPLAYED_LINE;
67                     ted.screen_rightborderwidth = TED_SCREEN_NTSC_FULL_LEFTBORDERWIDTH;
68                     ted.screen_leftborderwidth = TED_SCREEN_NTSC_FULL_RIGHTBORDERWIDTH;
69                     break;
70                 case TED_DEBUG_BORDERS:
71                     ted.first_displayed_line = TED_NTSC_DEBUG_FIRST_DISPLAYED_LINE;
72                     ted.last_displayed_line = TED_NTSC_DEBUG_LAST_DISPLAYED_LINE;
73                     ted.screen_rightborderwidth = TED_SCREEN_NTSC_DEBUG_LEFTBORDERWIDTH;
74                     ted.screen_leftborderwidth = TED_SCREEN_NTSC_DEBUG_RIGHTBORDERWIDTH;
75                     break;
76                 case TED_NO_BORDERS:
77                     ted.first_displayed_line = TED_NTSC_NO_BORDER_FIRST_DISPLAYED_LINE;
78                     ted.last_displayed_line = TED_NTSC_NO_BORDER_LAST_DISPLAYED_LINE;
79                     ted.screen_rightborderwidth = 0;
80                     ted.screen_leftborderwidth = 0;
81                     break;
82             }
83             ted.row_25_start_line = TED_NTSC_25ROW_START_LINE;
84             ted.row_25_stop_line = TED_NTSC_25ROW_STOP_LINE;
85             ted.row_24_start_line = TED_NTSC_24ROW_START_LINE;
86             ted.row_24_stop_line = TED_NTSC_24ROW_STOP_LINE;
87             ted.cycles_per_line = TED_NTSC_CYCLES_PER_LINE;
88             ted.draw_cycle = TED_NTSC_DRAW_CYCLE;
89             ted.first_dma_line = TED_NTSC_FIRST_DMA_LINE;
90             ted.last_dma_line = TED_NTSC_LAST_DMA_LINE;
91             ted.offset = TED_NTSC_OFFSET;
92             ted.vsync_line = TED_NTSC_VSYNC_LINE;
93             break;
94         case MACHINE_SYNC_PAL:
95         default:
96             ted.screen_height = TED_PAL_SCREEN_HEIGHT;
97             switch (border_mode) {
98                 default:
99                 case TED_NORMAL_BORDERS:
100                     ted.first_displayed_line = TED_PAL_NORMAL_FIRST_DISPLAYED_LINE;
101                     ted.last_displayed_line = TED_PAL_NORMAL_LAST_DISPLAYED_LINE;
102                     ted.screen_rightborderwidth = TED_SCREEN_PAL_NORMAL_LEFTBORDERWIDTH;
103                     ted.screen_leftborderwidth = TED_SCREEN_PAL_NORMAL_RIGHTBORDERWIDTH;
104                     break;
105                 case TED_FULL_BORDERS:
106                     ted.first_displayed_line = TED_PAL_FULL_FIRST_DISPLAYED_LINE;
107                     ted.last_displayed_line = TED_PAL_FULL_LAST_DISPLAYED_LINE;
108                     ted.screen_rightborderwidth = TED_SCREEN_PAL_FULL_LEFTBORDERWIDTH;
109                     ted.screen_leftborderwidth = TED_SCREEN_PAL_FULL_RIGHTBORDERWIDTH;
110                     break;
111                 case TED_DEBUG_BORDERS:
112                     ted.first_displayed_line = TED_PAL_DEBUG_FIRST_DISPLAYED_LINE;
113                     ted.last_displayed_line = TED_PAL_DEBUG_LAST_DISPLAYED_LINE;
114                     ted.screen_rightborderwidth = TED_SCREEN_PAL_DEBUG_LEFTBORDERWIDTH;
115                     ted.screen_leftborderwidth = TED_SCREEN_PAL_DEBUG_RIGHTBORDERWIDTH;
116                     break;
117                 case TED_NO_BORDERS:
118                     ted.first_displayed_line = TED_PAL_NO_BORDER_FIRST_DISPLAYED_LINE;
119                     ted.last_displayed_line = TED_PAL_NO_BORDER_LAST_DISPLAYED_LINE;
120                     ted.screen_rightborderwidth = 0;
121                     ted.screen_leftborderwidth = 0;
122                     break;
123             }
124             ted.row_25_start_line = TED_PAL_25ROW_START_LINE;
125             ted.row_25_stop_line = TED_PAL_25ROW_STOP_LINE;
126             ted.row_24_start_line = TED_PAL_24ROW_START_LINE;
127             ted.row_24_stop_line = TED_PAL_24ROW_STOP_LINE;
128             ted.cycles_per_line = TED_PAL_CYCLES_PER_LINE;
129             ted.draw_cycle = TED_PAL_DRAW_CYCLE;
130             ted.first_dma_line = TED_PAL_FIRST_DMA_LINE;
131             ted.last_dma_line = TED_PAL_LAST_DMA_LINE;
132             ted.offset = TED_PAL_OFFSET;
133             ted.vsync_line = TED_PAL_VSYNC_LINE;
134             break;
135     }
136 }
137