~ubuntu-branches/ubuntu/trusty/vice/trusty

« back to all changes in this revision

Viewing changes to src/crtc/crtc.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2013-07-28 20:38:23 UTC
  • mfrom: (1.2.5)
  • mto: This revision was merged to the branch mainline in revision 27.
  • Revision ID: package-import@ubuntu.com-20130728203823-w495rps5wuykespp
Tags: upstream-2.4.dfsg
ImportĀ upstreamĀ versionĀ 2.4.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 *
30
30
 */
31
31
 
 
32
/* #define DEBUG_CRTC */
 
33
 
 
34
#ifdef DEBUG_CRTC
 
35
#define DBG(_x_)        log_debug _x_
 
36
#else
 
37
#define DBG(_x_)
 
38
#endif
 
39
 
32
40
#include "vice.h"
33
41
 
34
42
#include <stdio.h>
47
55
#include "machine.h"
48
56
#include "maincpu.h"
49
57
#include "raster-canvas.h"
 
58
#include "raster-changes.h"
50
59
#include "raster-line.h"
51
60
#include "raster-modes.h"
52
61
#include "resources.h"
54
63
#include "types.h"
55
64
#include "vsync.h"
56
65
#include "video.h"
 
66
#include "viewport.h"
57
67
 
58
68
 
59
69
#define crtc_min(a,b)   (((a)<(b))?(a):(b))
77
87
    1,              /* hw_cols */
78
88
    0,              /* hw_blank */
79
89
    0x3ff,          /* vaddr_mask */
80
 
    0x800,          /* vaddr_charswitch */
 
90
    0x2000,         /* vaddr_charswitch */
81
91
    512,            /* vaddr_charoffset */
82
92
    0x1000          /* vaddr_revswitch */
83
93
};
99
109
#define CRTC_FIRST_DISPLAYED_LINE \
100
110
    CRTC_SCREEN_BORDERHEIGHT
101
111
#define CRTC_LAST_DISPLAYED_LINE \
102
 
    (crtc.screen_height - 2 * CRTC_SCREEN_BORDERHEIGHT)
 
112
    (crtc.screen_height - CRTC_SCREEN_BORDERHEIGHT - 1)
103
113
 
104
114
#define CRTC_CYCLES_PER_LINE() \
105
115
    crtc.regs[0]
229
239
/* return pixel aspect ratio for current video mode */
230
240
/* FIXME: calculate proper values.
231
241
   look at http://www.codebase64.org/doku.php?id=base:pixel_aspect_ratio&s[]=aspect
232
 
   for an example calculation
 
242
   for an example calculation.
 
243
   The Fat-40 models have a different aspect ratio than the older,
 
244
   CRTC-less models, since they display their 40 characters in the same
 
245
   space as 80 characters, and the screen is wider than before.
233
246
*/
234
247
static float crtc_get_pixel_aspect(void)
235
248
{
244
257
            return 0.75f;
245
258
    }
246
259
*/
247
 
    return 1.0f; /* assume 1:1 for CRTC */
 
260
    return 1.0f; /* assume 1:1 for CRTC; corrected by 1x2 render mode */
248
261
}
249
262
 
250
263
/* return type of monitor used for current video mode */
256
269
/* update screen window */
257
270
void crtc_update_window(void)
258
271
{
259
 
    if (!crtc.initialized)
 
272
    if (!crtc.initialized) {
260
273
        return;
 
274
    }
261
275
 
262
276
    crtc.raster.display_ystart = CRTC_SCREEN_BORDERHEIGHT;
263
277
    crtc.raster.display_ystop = crtc.screen_height
266
280
    crtc.raster.display_xstop = crtc.screen_width
267
281
                                - 2 * CRTC_SCREEN_BORDERWIDTH;
268
282
 
 
283
    crtc_update_renderer();
 
284
 
269
285
    raster_set_geometry(&crtc.raster,
270
 
                        crtc.screen_width, crtc.screen_height,
 
286
                        crtc.screen_width, crtc.screen_height - 2 * CRTC_SCREEN_BORDERHEIGHT,
271
287
                        crtc.screen_width, crtc.screen_height,
272
288
                        crtc.screen_width - 2 * CRTC_SCREEN_BORDERWIDTH,
273
289
                        crtc.screen_height - 2 * CRTC_SCREEN_BORDERHEIGHT,
274
290
                        CRTC_SCREEN_TEXTCOLS(), CRTC_SCREEN_TEXTLINES(),
275
 
                        0, 0,
 
291
                        CRTC_SCREEN_BORDERWIDTH, CRTC_SCREEN_BORDERHEIGHT,
276
292
                        0,
277
 
                        CRTC_SCREEN_BORDERHEIGHT,
278
 
                        crtc.screen_height - 2 * CRTC_SCREEN_BORDERHEIGHT,
 
293
                        CRTC_FIRST_DISPLAYED_LINE,
 
294
                        CRTC_LAST_DISPLAYED_LINE,
279
295
                        0, 0);
280
296
 
281
297
    crtc.raster.geometry->pixel_aspect_ratio = crtc_get_pixel_aspect();
307
323
 
308
324
void crtc_set_screen_options(int num_cols, int rasterlines)
309
325
{
310
 
    crtc.screen_width = (num_cols + CRTC_EXTRA_COLS) * 8
311
 
                        + 2 * CRTC_SCREEN_BORDERWIDTH;
312
 
    crtc.screen_height = rasterlines + CRTC_EXTRA_RASTERLINES
313
 
                         + 2 * CRTC_SCREEN_BORDERHEIGHT;
 
326
    crtc.screen_width = (num_cols + CRTC_EXTRA_COLS) * 8 + 2 * CRTC_SCREEN_BORDERWIDTH;
 
327
    crtc.screen_height = rasterlines + CRTC_EXTRA_RASTERLINES + 2 * CRTC_SCREEN_BORDERHEIGHT;
314
328
 
315
 
#if 0
316
 
    log_debug("crtc_set_screen_options: cols=%d, rl=%d -> w=%d, h=%d\n",
317
 
              num_cols, rasterlines, crtc.screen_width, crtc.screen_height);
318
 
#endif
 
329
    DBG(("crtc_set_screen_options: cols=%d, rl=%d -> w=%d, h=%d",
 
330
              num_cols, rasterlines, crtc.screen_width, crtc.screen_height));
319
331
 
320
332
    crtc_update_window();
321
333
    resources_touch("CrtcDoubleSize");
322
334
 
323
 
    if (crtc.raster.canvas != NULL)
324
 
        video_viewport_resize(crtc.raster.canvas);
 
335
    if (crtc.raster.canvas != NULL) {
 
336
        video_viewport_resize(crtc.raster.canvas, 1);
 
337
    }
325
338
}
326
339
 
327
340
void crtc_set_hw_options(int hwflag, int vmask, int vchar, int vcoffset,
368
381
{
369
382
    raster_t *raster;
370
383
 
 
384
    DBG(("crtc_init"));
 
385
 
371
386
    crtc.log = log_open("CRTC");
372
387
 
373
388
    crtc.raster_draw_alarm = alarm_new(maincpu_alarm_context, "CrtcRasterDraw",