]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Completely skip PC resolutions that don't fit in VRAM, even in 256 color mode.
authorToni Wilen <twilen@winuae.net>
Sun, 13 Aug 2017 13:04:19 +0000 (16:04 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 13 Aug 2017 13:04:19 +0000 (16:04 +0300)
od-win32/picasso96_win.cpp
od-win32/picasso96_win.h

index a8607bb85d3d0d9c908c40525db551e468e469f7..3b11ef7c267245b1b00c9b0089d07488e6028717 100644 (file)
@@ -42,6 +42,7 @@
 
 #define USE_HARDWARESPRITE 1
 #define P96TRACING_ENABLED 0
+#define P96TRACING_LEVEL 0
 #define P96TRACING_SETUP_ENABLED 0
 #define P96SPRTRACING_ENABLED 0
 
@@ -654,6 +655,7 @@ static void setupcursor (void)
                return;
        gfx_lock ();
        setupcursor_needed = 1;
+       LPDIRECT3DTEXTURE9 cursorsurfaced3d = D3D_getcursorsurface();
        if (cursorsurfaced3d) {
                if (SUCCEEDED (hr = cursorsurfaced3d->LockRect (0, &locked, NULL, 0))) {
                        dptr = (uae_u8*)locked.pBits;
@@ -2270,6 +2272,11 @@ static void picasso96_alloc2 (TrapContext *ctx)
                                i++;
                                continue;
                        }
+                       // Not even 256 color mode fits in VRAM? Ignore it completely.
+                       if (DisplayModes[i].res.width * DisplayModes[i].res.height > gfxmem_bank.allocated_size - 256) {
+                               i++;
+                               continue;
+                       }
                        j = i;
                        size += PSSO_LibResolution_sizeof;
                        while (missmodes[misscnt * 2] == 0)
@@ -2443,9 +2450,10 @@ static void inituaegfx(TrapContext *ctx, uaecptr ABI)
        inituaegfxfuncs(ctx, uaegfx_rom, ABI);
 }
 
-static void addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const TCHAR *name, int display, int *unkcnt)
+static bool addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, struct LibResolution *res, int w, int h, const TCHAR *name, int display, int *unkcnt)
 {
        int depth;
+       bool added = false;
 
        if (display > 0) {
                res->DisplayID = 0x51000000 + display * 0x100000;
@@ -2468,11 +2476,13 @@ static void addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, str
        for (depth = 8; depth <= 32; depth++) {
                if (!p96depth (depth))
                        continue;
-               if(gfxmem_bank.allocated_size >= w * h * (depth + 7) / 8) {
+               if(gfxmem_bank.allocated_size >= w * h * ((depth + 7) / 8)) {
                        FillBoardInfo(ctx, *amem, res, w, h, depth);
                        *amem += PSSO_ModeInfo_sizeof;
+                       added = true;
                }
        }
+       return added;
 }
 
 /****************************************
@@ -2484,7 +2494,7 @@ static void addmode(TrapContext *ctx, uaecptr AmigaBoardInfo, uaecptr *amem, str
 static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx)
 {
        int LibResolutionStructureCount = 0;
-       int i, j, unkcnt, cnt;
+       int i, unkcnt, cnt;
        uaecptr amem;
        uaecptr AmigaBoardInfo = trap_get_areg(ctx, 0);
 
@@ -2500,24 +2510,28 @@ static uae_u32 REGPARAM2 picasso_InitCard (TrapContext *ctx)
        unkcnt = cnt = 0;
        while (newmodes[i].depth >= 0) {
                struct LibResolution res = { 0 };
-               TCHAR *s;
-               j = i;
-               addmode(ctx, AmigaBoardInfo, &amem, &res, newmodes[i].res.width, newmodes[i].res.height, NULL, 0, &unkcnt);
-               s = au (res.Name);
-               write_log (_T("%2d: %08X %4dx%4d %s\n"), ++cnt, res.DisplayID, res.Width, res.Height, s);
-               xfree (s);
-               while (newmodes[i].depth >= 0
-                       && newmodes[i].res.width == newmodes[j].res.width
-                       && newmodes[i].res.height == newmodes[j].res.height)
-                       i++;
+               int j = i;
+               if (addmode(ctx, AmigaBoardInfo, &amem, &res, newmodes[i].res.width, newmodes[i].res.height, NULL, 0, &unkcnt)) {
+                       TCHAR *s;
+                       s = au (res.Name);
+                       write_log (_T("%2d: %08X %4dx%4d %s\n"), ++cnt, res.DisplayID, res.Width, res.Height, s);
+                       xfree (s);
+                       while (newmodes[i].depth >= 0
+                               && newmodes[i].res.width == newmodes[j].res.width
+                               && newmodes[i].res.height == newmodes[j].res.height)
+                               i++;
 
-               LibResolutionStructureCount++;
-               CopyLibResolutionStructureU2A(ctx, &res, amem);
+                       LibResolutionStructureCount++;
+                       CopyLibResolutionStructureU2A(ctx, &res, amem);
 #if P96TRACING_ENABLED && P96TRACING_LEVEL > 1
-               DumpLibResolutionStructurectx, (amem);
+                       DumpLibResolutionStructure(ctx, amem);
 #endif
-               AmigaListAddTail(ctx, AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amem);
-               amem += PSSO_LibResolution_sizeof;
+                       AmigaListAddTail(ctx, AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amem);
+                       amem += PSSO_LibResolution_sizeof;
+               } else {
+                       write_log (_T("--: %08X %4dx%4d Not enough VRAM\n"), res.DisplayID, res.Width, res.Height);
+                       i++;
+               }
        }
 #if MULTIDISPLAY
        for (i = 0; Displays[i].name; i++) {
@@ -2704,7 +2718,7 @@ static void init_picasso_screen (void)
 * This function is called whenever another ModeInfo has to be set. This
 * function simply sets up the CRTC and TS registers to generate the
 * timing used for that screen mode. You should not set the DAC, clocks
-* or linear start adress. They will be set when appropriate by their
+* or linear start address. They will be set when appropriate by their
 * own functions.
 */
 static uae_u32 REGPARAM2 picasso_SetGC (TrapContext *ctx)
index 9b4f9591b8fd003dbe0e8b022594ac23992f8824..3385d83147187e951d56ddc70f2c816fac8b61e8 100644 (file)
@@ -141,7 +141,7 @@ struct BitMap
 
 struct Settings {
     uae_u32                    BoardType;
-    /* a value discribing assignment to nth board local to boardtype
+    /* a value describing assignment to nth board local to boardtype
      * to be used for reassignment when boards are added or removed.  */
     uae_u16                    LocalOrdering;
     uae_s16                    LastSelected;
@@ -536,7 +536,7 @@ struct picasso96_state_struct
     uae_u8             *HostAddress; /* Active screen address (PC-side) */
     // host address is need because Windows
     // support NO direct access all the time to gfx Card
-    // everytime windows can remove your surface from card so the mainrender place
+    // every time windows can remove your surface from card so the mainrender place
     // must be in memory
     long               XYOffset;
 };