~ubuntu-branches/ubuntu/dapper/vice/dapper

« back to all changes in this revision

Viewing changes to src/raster/raster-canvas.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2004-08-26 13:35:51 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040826133551-gcje8j31q5cqgdq2
Tags: 1.14-3
Apply patch from Spiro Trikaliotis <vice@trikaliotis.net> to fix a
problem that some users were experiencing with a floating point
exception on startup related to the fullscreen option being enabled
during compile.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * raster-canvas.c - Raster-based video chip emulation helper.
 
3
 *
 
4
 * Written by
 
5
 *  Andreas Boose <viceteam@t-online.de>
 
6
 *  Ettore Perazzoli <ettore@comm2000.it>
 
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 <stdio.h>
 
31
 
 
32
#include "lib.h"
 
33
#include "machine.h"
 
34
#include "raster-canvas.h"
 
35
#include "raster.h"
 
36
#include "video.h"
 
37
#include "videoarch.h"
 
38
 
 
39
 
 
40
inline static void refresh_canvas(raster_t *raster)
 
41
{
 
42
    raster_canvas_area_t *update_area;
 
43
    viewport_t *viewport;
 
44
    int x, y, xx, yy;
 
45
    int w, h;
 
46
 
 
47
    update_area = raster->update_area;
 
48
    viewport = raster->canvas->viewport;
 
49
 
 
50
    if (update_area->is_null)
 
51
        return;
 
52
 
 
53
    x = update_area->xs;
 
54
    y = update_area->ys;
 
55
    xx = update_area->xs - viewport->first_x;
 
56
    yy = update_area->ys - viewport->first_line;
 
57
    w = update_area->xe - update_area->xs + 1;
 
58
    h = update_area->ye - update_area->ys + 1;
 
59
 
 
60
    if (video_render_get_fake_pal_state()) {
 
61
        /* if pal emu is activated, more pixels have to be updated */
 
62
        x -= 4;
 
63
        xx -= 4;
 
64
        w += 8;
 
65
        h ++;
 
66
    }
 
67
 
 
68
    if (xx < 0) {
 
69
        x -= xx;
 
70
        w += xx;
 
71
        xx = 0;
 
72
    }
 
73
 
 
74
    if (yy < 0) {
 
75
        y -= yy;
 
76
        h += yy;
 
77
        yy = 0;
 
78
    }
 
79
    x += raster->canvas->geometry->extra_offscreen_border_left;
 
80
 
 
81
    xx += viewport->x_offset;
 
82
    yy += viewport->y_offset;
 
83
 
 
84
    if ((int)(raster->canvas->draw_buffer->canvas_height) >= yy
 
85
        && (int)(raster->canvas->draw_buffer->canvas_width) >= xx)
 
86
        video_canvas_refresh(raster->canvas, x, y, xx, yy,
 
87
            MIN(w, (int)(raster->canvas->draw_buffer->canvas_width - xx)),
 
88
            MIN(h, (int)(raster->canvas->draw_buffer->canvas_height - yy)));
 
89
 
 
90
    update_area->is_null = 1;
 
91
}
 
92
 
 
93
void raster_canvas_handle_end_of_frame(raster_t *raster)
 
94
{
 
95
    if (console_mode || vsid_mode)
 
96
        return;
 
97
 
 
98
    if (raster->skip_frame)
 
99
        return;
 
100
 
 
101
    if (!raster->canvas->viewport->update_canvas)
 
102
        return;
 
103
 
 
104
    if (raster->dont_cache)
 
105
        video_canvas_refresh_all(raster->canvas);
 
106
    else
 
107
        refresh_canvas(raster);
 
108
}
 
109
 
 
110
void raster_canvas_init(raster_t *raster)
 
111
{
 
112
    raster->update_area = (raster_canvas_area_t *)lib_malloc(
 
113
                          sizeof(raster_canvas_area_t));
 
114
 
 
115
    raster->update_area->is_null = 1;
 
116
}
 
117
 
 
118
void raster_canvas_shutdown(raster_t *raster)
 
119
{
 
120
   lib_free(raster->update_area);
 
121
}
 
122