OSDN Git Service

[VM][FMTOWNS][VRAM][SPRITE] Fix crash on VIEW POINT's demonstration.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 10 Aug 2020 05:10:59 +0000 (14:10 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 10 Aug 2020 05:10:59 +0000 (14:10 +0900)
source/src/vm/fmtowns/towns_vram.h

index 2622a34..8835a78 100644 (file)
@@ -124,17 +124,17 @@ public:
        virtual bool __FASTCALL set_buffer_to_vram(uint32_t offset, uint8_t *buf, int words)
        {
                offset &= 0x7ffff;
-               if(words > 16) return false;
+//             if(words > 16) return false;
                if(words <= 0) return false;
                uint8_t* p = &(vram[offset]);
-               if((offset + words) < 0x80000) {
+               if((offset + (words << 1)) <= 0x80000) {
                        memcpy(p, buf, words << 1);
                } else {
                        int nb = 0x80000 - offset;
-                       memcpy(p, buf, nb << 1);
-                       int nnb = words - nb;
+                       memcpy(p, buf, nb);
+                       int nnb = (words << 1) - nb;
                        if(nnb > 0) {
-                               memcpy(vram, &(buf[nb << 1]), nnb << 1);
+                               memcpy(vram, &(buf[nb]), nnb);
                        }
                }
                return true;
@@ -142,17 +142,17 @@ public:
        virtual bool __FASTCALL get_vram_to_buffer(uint32_t offset, uint8_t *buf, int words)
        {
                offset &= 0x7ffff;
-               if(words > 16) return false;
+//             if(words > 16) return false;
                if(words <= 0) return false;
                uint8_t* p = &(vram[offset]);
-               if((offset + words) < 0x80000) {
+               if((offset + (words << 1)) <= 0x80000) {
                        memcpy(buf, p, words << 1);
                } else {
                        uint32_t nb = 0x80000 - offset;
-                       memcpy(buf, p, nb << 1);
-                       int nnb = words - nb;
+                       memcpy(buf, p, nb);
+                       int nnb = (words << 1) - nb;
                        if(nnb > 0) {
-                               memcpy(&(buf[nb << 1]), vram, nnb << 1);
+                               memcpy(&(buf[nb]), vram, nnb);
                        }
                }
                return true;