]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/rtg/rtg_driver_amiga/pigfx-2.c
Fix P96 2.1E(?) issues
[pistorm] / platforms / amiga / rtg / rtg_driver_amiga / pigfx-2.c
index ebe9790bcd044939789069ba34b7b90244f56bce..6ac92290f34287f2d6317fba628a640b65d5f62e 100644 (file)
@@ -7,6 +7,7 @@
 #include <proto/expansion.h>
 #include <proto/dos.h>
 #include <proto/intuition.h>
+#include <proto/input.h>
 #include <exec/types.h>
 #include <exec/memory.h>
 #include <exec/libraries.h>
@@ -14,6 +15,7 @@
 #include <exec/resident.h>
 #include <exec/initializers.h>
 #include <clib/debug_protos.h>
+#include <devices/inputevent.h>
 #include <string.h>
 #include <stdint.h>
 #include "boardinfo.h"
@@ -80,6 +82,7 @@ void SetClearMask (__REGA0(struct BoardInfo *b), __REGD0(UBYTE mask));
 void SetReadPlane (__REGA0(struct BoardInfo *b), __REGD0(UBYTE plane));
 
 void WaitVerticalSync (__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle));
+BOOL GetVSyncState(__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle));
 
 void FillRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(ULONG color), __REGD5(UBYTE mask), __REGD7(RGBFTYPE format));
 void InvertRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(UBYTE mask), __REGD7(RGBFTYPE format));
@@ -213,6 +216,17 @@ int __attribute__((used)) FindCard(__REGA0(struct BoardInfo* b)) {
         return 0;
     }
 
+    struct IORequest io;
+    if (OpenDevice((STRPTR)"input.device", 0, &io, 0) == 0)
+    {
+        struct Library *InputBase = (struct Library *)io.io_Device;
+        UWORD qual = PeekQualifier();
+        CloseDevice(&io);
+
+        if (qual & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))
+            return(FALSE);
+    }
+
     struct ExpansionBase *ExpansionBase = NULL;
     struct DOSBase *DOSBase = NULL;
     struct IntuitionBase *IntuitionBase = NULL;
@@ -241,9 +255,9 @@ int __attribute__((used)) InitCard(__REGA0(struct BoardInfo* b)) {
     b->CardBase = (struct CardBase *)_gfxbase;
     b->ExecBase = SysBase;
     b->BoardName = "PiStorm RTG";
-    b->BoardType = BT_MNT_ZZ9000;
-    b->PaletteChipType = PCT_MNT_ZZ9000;
-    b->GraphicsControllerType = GCT_MNT_ZZ9000;
+    b->BoardType = 14;
+    b->PaletteChipType = PCT_S3ViRGE;
+    b->GraphicsControllerType = GCT_S3ViRGE;
 
     b->Flags = BIF_INDISPLAYCHAIN | BIF_GRANTDIRECTACCESS | BIF_HARDWARESPRITE | BIF_FLICKERFIXER;
     b->RGBFormats = 1 | 2 | 512 | 1024 | 2048;
@@ -305,7 +319,7 @@ int __attribute__((used)) InitCard(__REGA0(struct BoardInfo* b)) {
     //b->SetSplitPosition = (void *)NULL;
     //b->ReInitMemory = (void *)NULL;
     //b->WriteYUVRect = (void *)NULL;
-    //b->GetVSyncState = (void *)NULL;
+    b->GetVSyncState = (void *)GetVSyncState;
     //b->GetVBeamPos = (void *)NULL;
     //b->SetDPMSLevel = (void *)NULL;
     //b->ResetChip = (void *)NULL;
@@ -461,8 +475,18 @@ void SetClearMask (__REGA0(struct BoardInfo *b), __REGD0(UBYTE mask)) {
 void SetReadPlane (__REGA0(struct BoardInfo *b), __REGD0(UBYTE plane)) {
 }
 
+static uint16_t vblank;
+
 void WaitVerticalSync (__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle)) {
-    // I don't know why this one has a bool in D0, but it isn't used for anything.
+    vblank = 0;
+    do {
+        READSHORT(RTG_WAITVSYNC, vblank);
+    } while (!vblank);
+}
+
+BOOL GetVSyncState(__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle)) {
+    READSHORT(RTG_INVBLANK, vblank);
+    return vblank;
 }
 
 void FillRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(ULONG color), __REGD5(UBYTE mask), __REGD7(RGBFTYPE format)) {
@@ -552,7 +576,7 @@ void BlitRectNoMaskComplete (__REGA0(struct BoardInfo *b), __REGA1(struct Render
 }
 
 void BlitTemplate (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGA2(struct Template *t), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(UBYTE mask), __REGD7(RGBFTYPE format)) {
-#ifndef  IRTG
+#ifndef IRTG
     if (!r || !t) return;
     if (w < 1 || h < 1) return;
 
@@ -591,6 +615,7 @@ void BlitTemplate (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r),
 }
 
 void BlitPattern (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGA2(struct Pattern *p), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(UBYTE mask), __REGD7(RGBFTYPE format)) {
+#ifndef IRTG
     if (!r || !p) return;
     if (w < 1 || h < 1) return;
 
@@ -623,6 +648,9 @@ void BlitPattern (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), _
     WRITEBYTE(RTG_U82, p->DrawMode);
     WRITEBYTE(RTG_U83, (1 << p->Size));
     WRITESHORT(RTG_COMMAND, RTGCMD_BLITPATTERN);
+#else
+    IWRITECMD(RTGCMD_BLITPATTERN);
+#endif
 }
 
 void DrawLine (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGA2(struct Line *l), __REGD0(UBYTE mask), __REGD7(RGBFTYPE format)) {
@@ -657,6 +685,8 @@ void DrawLine (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __RE
 }
 
 void BlitPlanar2Chunky (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bm), __REGA2(struct RenderInfo *r), __REGD0(SHORT x), __REGD1(SHORT y), __REGD2(SHORT dx), __REGD3(SHORT dy), __REGD4(SHORT w), __REGD5(SHORT h), __REGD6(UBYTE minterm), __REGD7(UBYTE mask)) {
+// iRTG path disabled for now, since it's really slow, see note in rtg-gfx.c.
+//#ifndef IRTG    
     if (!b || !r)
         return;
 
@@ -714,6 +744,9 @@ void BlitPlanar2Chunky (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bm)
     WRITEBYTE(RTG_U83, bm->Depth);
 
     WRITESHORT(RTG_COMMAND, RTGCMD_P2C);
+//#else
+//    IWRITECMD(RTGCMD_P2C);
+//#endif
 }
 
 void BlitPlanar2Direct (__REGA0(struct BoardInfo *b), __REGA1(struct BitMap *bm), __REGA2(struct RenderInfo *r), __REGA3(struct ColorIndexMapping *clut), __REGD0(SHORT x), __REGD1(SHORT y), __REGD2(SHORT dx), __REGD3(SHORT dy), __REGD4(SHORT w), __REGD5(SHORT h), __REGD6(UBYTE minterm), __REGD7(UBYTE mask)) {