~ubuntu-branches/ubuntu/raring/vice/raring

« back to all changes in this revision

Viewing changes to src/arch/unix/gp2x/video.c

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2009-03-31 00:37:15 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 17.
  • Revision ID: james.westby@ubuntu.com-20090331003715-mzclchtl0dp7fcl0
Tags: upstream-2.1.dfsg
ImportĀ upstreamĀ versionĀ 2.1.dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Written by
5
5
 *  Mike Dawson <mike@gp2x.org>
 
6
 *  Mustafa 'GnoStiC' Tufan <mtufan@gmail.com>
6
7
 *
7
8
 * This file is part of VICE, the Versatile Commodore Emulator.
8
9
 * See README for copyright notice.
36
37
#include "videoarch.h"
37
38
#include "palette.h"
38
39
#include "machine.h"
 
40
#include "input_gp2x.h"
 
41
#include "vsync.h"
 
42
#include "interrupt.h"
39
43
 
40
44
int machine_ui_done=0;
41
45
int vicii_setup_delay=0;
42
46
 
43
 
extern unsigned short *gp2x_memregs;
 
47
extern volatile unsigned short *gp2x_memregs;
44
48
 
45
49
video_canvas_t *current_canvas;
46
50
 
48
52
int xoffset_centred, yoffset_centred;
49
53
int xoffset_uncentred, yoffset_uncentred;
50
54
 
51
 
int video_init() {
52
 
        return 0;
53
 
}
54
 
 
55
 
int video_init_cmdline_options() {
56
 
        return 0;
57
 
}
58
 
 
59
 
void video_shutdown() {
60
 
}
61
 
 
62
 
video_canvas_t *video_canvas_create(video_canvas_t *canvas, 
63
 
                unsigned int *width, unsigned int *height, int mapped) {
64
 
        static int vicii_setup=0;
65
 
 
66
 
        display_width=320;
67
 
 
68
 
        canvas->depth=8;
69
 
        canvas->width=320;
70
 
        canvas->height=240;
 
55
int video_init()
 
56
{
 
57
        return 0;
 
58
}
 
59
 
 
60
int video_init_cmdline_options()
 
61
{
 
62
        return 0;
 
63
}
 
64
 
 
65
void video_shutdown()
 
66
{
 
67
}
 
68
 
 
69
video_canvas_t *video_canvas_create(video_canvas_t *canvas, unsigned int *width, unsigned int *height, int mapped)
 
70
{
 
71
        static int vicii_setup = 0;
 
72
 
 
73
        display_width = 320;
 
74
 
 
75
        canvas->depth = 8;
 
76
        canvas->width = 320;
 
77
        canvas->height = 240;
71
78
 
72
79
        video_canvas_set_palette(canvas, canvas->palette);
73
80
 
78
85
        }
79
86
 
80
87
        tvout_pal=1;
81
 
        if(gp2x_memregs[0x2800>>1]&0x100) {
 
88
        if (gp2x_memregs[0x2800>>1]&0x100) {
82
89
                tvout=1;
83
90
                hwscaling=1;
84
 
#if 0
85
 
                tvout_pal=gp2x_memregs[0x2800>>1]&0x1000;
86
 
#endif
87
 
                if(gp2x_memregs[0x2818>>1]==239) tvout_pal=0;
88
 
                printf("\n0x2818=%d\n", gp2x_memregs[0x2818>>1]);
 
91
                if (gp2x_memregs[0x2818>>1]==239) tvout_pal=0;
 
92
                //printf("\n0x2818=%d\n", gp2x_memregs[0x2818>>1]);
89
93
                display_set();
90
94
        }
91
95
 
92
 
        current_canvas=canvas;
 
96
        current_canvas = canvas;
93
97
        return canvas;
94
98
}
95
99
 
96
 
void video_canvas_destroy(struct video_canvas_s *canvas) {
97
 
#if 0
98
 
        fprintf(stderr, "calling undefined function %s\n", __func__);
99
 
#endif
 
100
void video_canvas_destroy(struct video_canvas_s *canvas)
 
101
{
100
102
}
101
103
 
102
 
void video_arch_canvas_init(struct video_canvas_s *canvas) {
 
104
void video_arch_canvas_init(struct video_canvas_s *canvas)
 
105
{
103
106
        canvas->video_draw_buffer_callback=NULL;
104
107
}
105
108
 
 
109
static void pause_trap(WORD addr, void *data)
 
110
{
 
111
        vsync_suspend_speed_eval();
 
112
        while (prefs_open) {
 
113
                usleep (20000);
 
114
                gp2x_poll_input();
 
115
                draw_prefs(gp2x_screen8);
 
116
                gp2x_video_flip();
 
117
        }
 
118
}
 
119
 
106
120
void video_canvas_refresh(struct video_canvas_s *canvas,
107
121
                                 unsigned int xs, unsigned int ys,
108
122
                                 unsigned int xi, unsigned int yi,
109
 
                                 unsigned int w, unsigned int h) {
110
 
#if 0
111
 
        fprintf(stderr, "calling %s\n", __func__);
112
 
        fprintf(stderr, "refresh xs=%d, ys=%d, xi=%d, yi=%d, w=%d, h=%d\n",
113
 
                        xs, ys, xi, yi, w, h);
114
 
#endif
 
123
                                 unsigned int w, unsigned int h)
 
124
{
115
125
        BYTE *source;
116
 
        register int x, y;
 
126
        register unsigned int x, y;
117
127
        register int buf_width;
118
 
#if 0
119
 
        register BYTE pixel;
120
 
#endif
121
128
        register int xoff;
122
129
        register int yoff;
123
130
 
124
 
        if(canvas->width==0) return;
 
131
        if (canvas->width==0) return;
125
132
 
126
133
        if (machine_ui_done==0) return;
127
134
 
128
 
      if (xoffset_centred==0)
 
135
        if (xoffset_centred==0)
129
136
        {
130
 
                xoffset_centred=(canvas->draw_buffer->draw_buffer_width-320)/2;
131
 
                xoffset=xoffset_centred;
 
137
                xoffset_centred = (canvas->draw_buffer->draw_buffer_width-320)/2;
 
138
                xoffset = xoffset_centred;
132
139
        }
133
140
        if (yoffset_centred==0)
134
141
        {
135
 
                yoffset_centred=(canvas->draw_buffer->draw_buffer_height-240)/2;
136
 
                yoffset=xoffset_centred;
 
142
                yoffset_centred = (canvas->draw_buffer->draw_buffer_height-240)/2;
 
143
                yoffset = yoffset_centred;
137
144
        }
138
145
 
139
 
        xoff=xoffset;
140
 
        yoff=yoffset;
141
 
 
142
 
        source=canvas->draw_buffer->draw_buffer;
143
 
        buf_width=canvas->draw_buffer->draw_buffer_width;
144
 
 
145
 
        register unsigned long *screen32=(unsigned long *)gp2x_screen8;
146
 
        register unsigned long *source32=(unsigned long *)source;
147
 
 
148
 
        if(hwscaling) {
149
 
                for(y=0; y<272; y++) {
150
 
                        for(x=0; x<384/4; x++) {
151
 
                                screen32[(y*(384/4))+x]=
152
 
                                        source32[((y+(yoff-16))*(buf_width/4))+x+((xoff-32)/4)];
 
146
        xoff = xoffset;
 
147
        yoff = yoffset;
 
148
 
 
149
        source = canvas->draw_buffer->draw_buffer;
 
150
        buf_width = canvas->draw_buffer->draw_buffer_width/4;
 
151
 
 
152
        register unsigned long *source32 = (unsigned long *)source;
 
153
        register unsigned long *screen32 = (unsigned long *)gp2x_screen8;
 
154
 
 
155
        if (hwscaling) {
 
156
                for (y=272; y--;) {
 
157
                        for (x=384/4; x--;) {
 
158
                                screen32[(y*(384/4))+x] = source32[((y+(yoff-16))*(buf_width))+x+((xoff-32)/4)];
153
159
                        }
154
160
                }
155
161
        } else {
156
 
                for(y=0; y<240; y++) {
157
 
                        for(x=0; x<320/4; x++) {
158
 
                                screen32[(y*(320/4))+x]=
159
 
                                        source32[((y+yoff)*(buf_width/4))+x+(xoff/4)];
 
162
                for (y=240; y--;) {
 
163
                        for (x=320/4; x--;) {
 
164
                                screen32[(y*(320/4))+x] = source32[((y+yoff)*(buf_width))+x+(xoff/4)];
160
165
                        }
161
166
                }
162
167
        }
163
168
 
164
169
        gp2x_poll_input();
165
 
        if(stats_open) draw_stats(gp2x_screen8);
166
 
        if(prefs_open) draw_prefs(gp2x_screen8);
167
 
        else if(vkeyb_open) draw_vkeyb(gp2x_screen8);
 
170
 
 
171
        if (stats_open) draw_stats(gp2x_screen8);
 
172
        if (prefs_open) { interrupt_maincpu_trigger_trap(pause_trap, 0);
 
173
        } else if (vkeyb_open) draw_vkeyb(gp2x_screen8);
168
174
        
169
175
        gp2x_video_flip();
 
176
 
170
177
}
171
178
 
172
 
int video_canvas_set_palette(struct video_canvas_s *canvas,
173
 
                                    struct palette_s *palette) {
174
 
        fprintf(stderr, "calling %s\n", __func__);
175
 
        int i;
 
179
int video_canvas_set_palette(struct video_canvas_s *canvas, struct palette_s *palette)
 
180
{
 
181
//      fprintf(stderr, "calling %s\n", __func__);
 
182
        unsigned int i;
176
183
        for(i=0; i<palette->num_entries; i++) {
177
 
                gp2x_palette[i*2]=
178
 
                        ((palette->entries[i].green)<<8)
179
 
                        | (palette->entries[i].blue);
180
 
                gp2x_palette[i*2+1]=palette->entries[i].red;
 
184
                gp2x_palette[i*2]       = ((palette->entries[i].green)<<8) | (palette->entries[i].blue);
 
185
                gp2x_palette[i*2+1]     = palette->entries[i].red;
181
186
        }
182
187
        gp2x_video_setpalette();
183
 
}
184
 
 
185
 
int video_arch_resources_init() {
186
 
#if 0
187
 
        fprintf(stderr, "calling undefined function %s\n", __func__);
188
 
#endif
189
 
}
190
 
 
191
 
void video_canvas_resize(struct video_canvas_s *canvas,
192
 
                                unsigned int width, unsigned int height) {
193
 
#if 0
194
 
        fprintf(stderr, "calling undefined function %s\n", __func__);
195
 
#endif
196
 
}
197
 
 
198
 
void video_arch_resources_shutdown() {
199
 
#if 0
200
 
        fprintf(stderr, "calling undefined function %s\n", __func__);
201
 
#endif
202
 
}
203
 
 
204
 
void video_add_handlers() {
205
 
#if 0
206
 
        fprintf(stderr, "calling undefined function %s\n", __func__);
207
 
#endif
208
 
}
209
 
 
210
 
void fullscreen_capability() {
211
 
#if 0
212
 
        fprintf(stderr, "calling undefined function %s\n", __func__);
213
 
#endif
 
188
 
 
189
        return 0;
 
190
}
 
191
 
 
192
int video_arch_resources_init()
 
193
{
 
194
    return 0;
 
195
}
 
196
 
 
197
void video_canvas_resize(struct video_canvas_s *canvas, unsigned int width, unsigned int height)
 
198
{
 
199
}
 
200
 
 
201
void video_arch_resources_shutdown()
 
202
{
 
203
}
 
204
 
 
205
void video_add_handlers()
 
206
{
 
207
}
 
208
 
 
209
void fullscreen_capability()
 
210
{
214
211
}