~ubuntu-branches/ubuntu/maverick/vice/maverick

« back to all changes in this revision

Viewing changes to src/arch/win32/video.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-02-01 11:30:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050201113026-3eyakzsmmheclvjg
Tags: 1.16-1
* New upstream version
* Fixes crash on 64-bit architectures (closes: #287640)
* x128 working again (closes: #286767)
* Works fine with /dev/dsp in use (not in the main changelog, but tested
  on my local machine as working).  Presumably, this also takes care of
  the issue with dsp being held.  I'm not sure if this is because I'm
  testing it on a 2.6 kernel now -- if you are still having problems
  with /dev/dsp, please reopen the bugs. (closes: #152952, #207942)
* Don't kill Makefile.in on clean

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
#include "ui.h"
47
47
#include "video.h"
48
48
#include "videoarch.h"
 
49
#include "viewport.h"
49
50
#include "vsyncapi.h"
50
51
#include "statusbar.h"
51
52
 
313
314
 
314
315
 
315
316
/* Set the palettes for canvas `c'.  */
316
 
int set_palette(video_canvas_t *c)
 
317
int video_set_palette(video_canvas_t *c)
317
318
{
318
319
    if (c->depth == 8) {
319
320
        HRESULT result;
335
336
    return 0;
336
337
}
337
338
 
338
 
int set_physical_colors(video_canvas_t *c)
 
339
int video_set_physical_colors(video_canvas_t *c)
339
340
{
340
341
    HDC hdc;
341
342
    DDSURFACEDESC ddsd;
577
578
        return TRUE;
578
579
}
579
580
 
580
 
/* try to allocate a triple buffer and a temporary buffer in video memory */
 
581
#if 0
 
582
/* Try to allocate a triple buffer and a temporary buffer in video memory.   */
581
583
 
582
 
int create_triple_surface(video_canvas_t *canvas, int width, int height)
 
584
int video_create_triple_surface(video_canvas_t *canvas, int width, int height)
583
585
{
584
586
    HRESULT ddresult;
585
587
    DDSURFACEDESC desc;
586
 
        DDSCAPS ddscaps;
 
588
    DDSCAPS ddscaps;
587
589
 
588
590
    memset(&desc, 0, sizeof(desc));
589
591
    desc.dwSize = sizeof(desc);
590
592
    desc.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
591
593
    desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX;
592
 
        desc.dwBackBufferCount = 2;
 
594
    desc.dwBackBufferCount = 2;
593
595
 
594
596
    ddresult = IDirectDraw2_CreateSurface(canvas->dd_object2, &desc,
595
597
                                          &canvas->primary_surface, NULL);
596
 
    if (ddresult != DD_OK) return FALSE;
 
598
    if (ddresult != DD_OK)
 
599
        return FALSE;
597
600
 
598
 
        ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
 
601
    ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
599
602
    ddresult = IDirectDrawSurface_GetAttachedSurface(canvas->primary_surface, &ddscaps, &canvas->back_surface);
600
 
        if (ddresult != DD_OK) {
 
603
        if (ddresult != DD_OK) {
601
604
        ui_error("Cannot get attached surface for primary surface:\n%s",
602
605
                 dd_error(ddresult));
603
606
    }
604
607
 
605
 
        attach_clipper(canvas);
 
608
    attach_clipper(canvas);
606
609
 
607
 
        if (!create_temporary_surface(canvas, width, height, TRUE))
608
 
        {
609
 
                /* triple buffering needs a temporary surface... */
610
 
            IDirectDrawSurface_Release(canvas->primary_surface);
611
 
                canvas->render_surface = NULL;
612
 
                canvas->primary_surface = NULL;
613
 
                canvas->back_surface = NULL;
614
 
                canvas->temporary_surface = NULL;
615
 
                return FALSE;
 
610
    if (!create_temporary_surface(canvas, width, height, TRUE)) {
 
611
        /* triple buffering needs a temporary surface... */
 
612
        IDirectDrawSurface_Release(canvas->primary_surface);
 
613
        canvas->render_surface = NULL;
 
614
        canvas->primary_surface = NULL;
 
615
        canvas->back_surface = NULL;
 
616
        canvas->temporary_surface = NULL;
 
617
        return FALSE;
616
618
    }
617
 
        canvas->render_surface = canvas->temporary_surface;
 
619
    canvas->render_surface = canvas->temporary_surface;
618
620
 
619
 
        return TRUE;
 
621
    return TRUE;
620
622
}
621
 
 
622
 
/* try to allocate a single buffer and a temporary buffer in video or system memory */
623
 
 
624
 
int create_single_surface(video_canvas_t *canvas, int width, int height)
 
623
#endif
 
624
 
 
625
/* Try to allocate a single buffer and a temporary buffer in video or system
 
626
   memory.   */
 
627
 
 
628
int video_create_single_surface(video_canvas_t *canvas, int width, int height)
625
629
{
626
630
    HRESULT ddresult;
627
631
    DDSURFACEDESC desc;
634
638
 
635
639
    ddresult = IDirectDraw2_CreateSurface(canvas->dd_object2, &desc,
636
640
                                          &canvas->primary_surface, NULL);
637
 
    if (ddresult != DD_OK) return FALSE;
638
 
 
639
 
        attach_clipper(canvas);
640
 
 
641
 
        if (!create_temporary_surface(canvas, width, height, FALSE))
642
 
                canvas->render_surface = canvas->primary_surface;
643
 
        else
644
 
                canvas->render_surface = canvas->temporary_surface;
645
 
 
646
 
        return TRUE;
 
641
    if (ddresult != DD_OK)
 
642
        return FALSE;
 
643
 
 
644
    attach_clipper(canvas);
 
645
 
 
646
    if (!create_temporary_surface(canvas, width, height, FALSE))
 
647
        canvas->render_surface = canvas->primary_surface;
 
648
    else
 
649
        canvas->render_surface = canvas->temporary_surface;
 
650
 
 
651
    return TRUE;
647
652
}
648
653
 
649
654
 
650
 
 
651
 
 
652
655
int video_number_of_canvases;
653
656
video_canvas_t *video_canvases[2];
654
657
extern int fullscreen_active;
765
768
    desc2.dwSize = sizeof(desc2);
766
769
    ddresult = IDirectDraw2_GetDisplayMode(canvas->dd_object2, &desc2);
767
770
 
768
 
    create_single_surface(canvas, desc2.dwWidth, desc2.dwHeight);
 
771
    video_create_single_surface(canvas, desc2.dwWidth, desc2.dwHeight);
769
772
 
770
773
    /* Create the temporary surface.  */
771
774
 /*   memset(&desc, 0, sizeof(desc));
814
817
        }
815
818
    }
816
819
 
817
 
    if (set_palette(canvas) < 0)
 
820
    if (video_set_palette(canvas) < 0)
818
821
        goto error;
819
822
 
820
 
    if (set_physical_colors(canvas) < 0)
 
823
    if (video_set_physical_colors(canvas) < 0)
821
824
        goto error;
822
825
 
823
826
    video_canvases[video_number_of_canvases++] = canvas;
900
903
        result = IDirectDraw2_CreatePalette(canvas->dd_object2, DDPCAPS_8BIT,
901
904
                                            ape, &canvas->dd_palette, NULL);
902
905
    }
903
 
    set_palette(canvas);
904
 
    set_physical_colors(canvas);
 
906
    video_set_palette(canvas);
 
907
    video_set_physical_colors(canvas);
905
908
    return 0;
906
909
}
907
910
 
984
987
extern int window_canvas_ysize[2];
985
988
//extern int status_height;
986
989
 
987
 
void canvas_update(HWND hwnd, HDC hdc, int xclient, int yclient, int w, int h)
 
990
void video_canvas_update(HWND hwnd, HDC hdc, int xclient, int yclient, int w,
 
991
                         int h)
988
992
{
989
993
    video_canvas_t *c;
990
994
    int xs;   //  upperleft x in framebuffer