]> Shamusworld >> Repos - thunder/blobdiff - test/union.cpp
Code cleanup, final fix for sprite lag problem.
[thunder] / test / union.cpp
index ef052abe4e1cc60122d17b4c5e4b4af53495ec3d..99c32a3cdbaaf26dae2178af4fd7ecb2860c6b99 100644 (file)
@@ -1,82 +1,49 @@
 // Union bit fields...
 
-//#include <dos.h>
-//#include <conio.h>
-#include <fstream>
-#include <iostream>
+#include <dos.h>
+#include <conio.h>
+#include <fstream.h>
 #include <string.h>
-#include <iomanip>
+#include <iomanip.h>
 #include <stdio.h>
 #include <stdlib.h>
 
-using namespace std;
-
 union {
-       struct {
-               unsigned char C: 1;   // Carry flag 
-               unsigned char V: 1;   // oVerflow flag
-               unsigned char Z: 1;   // Zero flag
-               unsigned char N: 1;   // Negative flag
-               unsigned char I: 1;   // IRQ flag
-               unsigned char H: 1;   // Half carry flag
-               unsigned char F: 1;   // Fast IRQ flag
-               unsigned char E: 1;   // Entire flag
-               } flag;
-       unsigned char byte; } cc;
+  struct {
+    unsigned char C: 1;   // Carry flag 
+    unsigned char V: 1;   // oVerflow flag
+    unsigned char Z: 1;   // Zero flag
+    unsigned char N: 1;   // Negative flag
+    unsigned char I: 1;   // IRQ flag
+    unsigned char H: 1;   // Half carry flag
+    unsigned char F: 1;   // Fast IRQ flag
+    unsigned char E: 1;   // Entire flag
+    } flag;
+  unsigned char byte; } cc;
 
 union BYTE {
-       struct {
-               unsigned char b0: 1;  unsigned char b1: 1;  unsigned char b2: 1;
-               unsigned char b3: 1;  unsigned char b4: 1;  unsigned char b5: 1;
-               unsigned char b6: 1;  unsigned char b7: 1;
-               } bit;
-       unsigned char byte; };
+  struct {
+    unsigned char b0: 1;  unsigned char b1: 1;  unsigned char b2: 1;
+    unsigned char b3: 1;  unsigned char b4: 1;  unsigned char b5: 1;
+    unsigned char b6: 1;  unsigned char b7: 1;
+    } bit;
+  unsigned char byte; };
 
 union WORD {
-       struct { unsigned char lo: 8;  unsigned char hi: 8; } b;
-       unsigned int word; } hilo;
-
+  struct { unsigned char lo: 8;  unsigned char hi: 8; } b;
+  unsigned int word; } hilo;
 
-int main(int, char * [])
+void main()
 {
-       for(int i=0; i<256; i++)
-       {
-               cc.byte = i;
-               cout << (cc.flag.E ? "1" : ".") << " " << (cc.flag.F ? "1" : ".") << " "
-                       << (cc.flag.H ? "1" : ".") << " " << (cc.flag.I ? "1" : ".") << " "
-                       << (cc.flag.N ? "1" : ".") << " " << (cc.flag.Z ? "1" : ".") << " "
-                       << (cc.flag.V ? "1" : ".") << " " << (cc.flag.C ? "1" : ".") << endl;
-       }
-
-       hilo.word = 0x6A44;
-       cout << hex << hilo.word << " "
-               << (int) hilo.b.lo << " " << (int) hilo.b.hi << endl;
-
-       BYTE b;
-       b.byte = (unsigned char)0xA5;
-       cout << "Byte = " << hex << (int)b.byte << ", bits = "
-               << (b.bit.b7 ? "1" : "0")
-               << (b.bit.b6 ? "1" : "0")
-               << (b.bit.b5 ? "1" : "0")
-               << (b.bit.b4 ? "1" : "0")
-               << (b.bit.b3 ? "1" : "0")
-               << (b.bit.b2 ? "1" : "0")
-               << (b.bit.b1 ? "1" : "0")
-               << (b.bit.b0 ? "1" : "0")
-               << endl;
-
-       b.bit.b4 ^= 1;
-       cout << "Byte = " << hex << (int)b.byte << ", bits = "
-               << (b.bit.b7 ? "1" : "0")
-               << (b.bit.b6 ? "1" : "0")
-               << (b.bit.b5 ? "1" : "0")
-               << (b.bit.b4 ? "1" : "0")
-               << (b.bit.b3 ? "1" : "0")
-               << (b.bit.b2 ? "1" : "0")
-               << (b.bit.b1 ? "1" : "0")
-               << (b.bit.b0 ? "1" : "0")
-               << endl;
-
-       return 0;
+  for(int i=0; i<256; i++)
+  {
+    cc.byte = i;
+    cout << cc.flag.E << " " << cc.flag.F << " "
+         << cc.flag.H << " " << cc.flag.I << " "
+         << cc.flag.N << " " << cc.flag.Z << " "
+         << cc.flag.V << " " << cc.flag.C << endl;
+  }
+  hilo.word = 0x6A44;
+  cout << hex << hilo.word << " "
+       << (int) hilo.b.lo << " " << (int) hilo.b.hi << endl;
 }
-