Browse Source

[Cosmetics]
- Update some headers that was incorrect
- Reformat the code in all files to match the same code style
- Removal of unwanted/unneeded files

Godzil 6 years ago
parent
commit
cdda587579
77 changed files with 3209 additions and 4252 deletions
  1. 1 1
      CMakeLists.txt
  2. 1 1
      src/CMakeLists.txt
  3. 58 53
      src/NESCarts.c
  4. 1 1
      src/apu/CMakeLists.txt
  5. 1 1
      src/apu/apu.c
  6. 2 2
      src/corecpu/CMakeLists.txt
  7. 356 321
      src/corecpu/corecpu.c
  8. 0 1039
      src/include/MIDIFreq.h
  9. 8 8
      src/include/NESCarts.h
  10. 0 232
      src/include/Sound.h
  11. 1 1
      src/include/apu/apu.h
  12. 3 8
      src/include/color.h
  13. 41 40
      src/include/corecpu.h
  14. 3 8
      src/include/log.h
  15. 16 16
      src/include/mappers/manager.h
  16. 2 13
      src/include/memory/manager.h
  17. 9 9
      src/include/os_dependent.h
  18. 5 13
      src/include/paddle.h
  19. 257 257
      src/include/palette.h
  20. 7 10
      src/include/plugins/manager.h
  21. 1 1
      src/include/ppu/ppu.debug.h
  22. 2 10
      src/include/ppu/ppu.h
  23. 2 5
      src/include/ppu/ppu.memory.h
  24. 1 1
      src/include/types.h
  25. 114 90
      src/log.c
  26. 598 582
      src/main.c
  27. 1 1
      src/mappersmanager/CMakeLists.txt
  28. 39 37
      src/mappersmanager/manager.c
  29. 25 21
      src/mappersmanager/mappers/aorom.c
  30. 3 2
      src/mappersmanager/mappers/aorom.h
  31. 11 11
      src/mappersmanager/mappers/cnrom.c
  32. 3 2
      src/mappersmanager/mappers/cnrom.h
  33. 2 2
      src/mappersmanager/mappers/genericmapper.c.template
  34. 73 73
      src/mappersmanager/mappers/iremh3001.c
  35. 3 2
      src/mappersmanager/mappers/iremh3001.h
  36. 123 116
      src/mappersmanager/mappers/mmc1.c
  37. 5 4
      src/mappersmanager/mappers/mmc1.h
  38. 219 187
      src/mappersmanager/mappers/mmc3.c
  39. 3 2
      src/mappersmanager/mappers/mmc3.h
  40. 49 43
      src/mappersmanager/mappers/mmc4.c
  41. 3 2
      src/mappersmanager/mappers/mmc4.h
  42. 23 22
      src/mappersmanager/mappers/norom.c
  43. 5 4
      src/mappersmanager/mappers/norom.h
  44. 14 12
      src/mappersmanager/mappers/unrom.c
  45. 3 2
      src/mappersmanager/mappers/unrom.h
  46. 10 9
      src/mappersmanager/mappers/unrom512.c
  47. 3 2
      src/mappersmanager/mappers/unrom512.h
  48. 1 1
      src/mappersmanager/mappers_list.h
  49. 3 3
      src/mappersmanager/unused/genericmapper.h
  50. 152 146
      src/mappersmanager/unused/mmc1.h
  51. 2 2
      src/mappersmanager/utils.c
  52. 1 1
      src/memorymanager/CMakeLists.txt
  53. 69 40
      src/memorymanager/memory.c
  54. 2 2
      src/os/macos/CMakeLists.txt
  55. 2 2
      src/os/macos/graphics.c
  56. 1 1
      src/os/macos/loadfile.c
  57. 2 2
      src/os/ti68k/CMakeLists.txt
  58. 3 8
      src/os/ti68k/loadfile.c
  59. 1 1
      src/os/unix/CMakeLists.txt
  60. 300 287
      src/os/unix/graphics.c
  61. 17 17
      src/os/unix/graphics_dummy.c
  62. 20 18
      src/os/unix/io.c
  63. 14 14
      src/os/unix/loadfile.c
  64. 1 1
      src/os/win32/CMakeLists.txt
  65. 1 1
      src/os/win32/graphics.c
  66. 79 64
      src/paddle.c
  67. 1 1
      src/pluginsmanager/CMakeLists.txt
  68. 38 29
      src/pluginsmanager/manager.c
  69. 280 221
      src/pluginsmanager/plugins/gamegenie.c
  70. 1 1
      src/pluginsmanager/plugins/gamegenie.h
  71. 5 5
      src/pluginsmanager/plugins_list.h
  72. 2 2
      src/ppu/CMakeLists.txt
  73. 1 1
      src/ppu/debug/ppu.debug.c
  74. 2 8
      src/ppu/ppu.c
  75. 5 5
      src/ppu/ppu.memory.c
  76. 79 75
      src/utils/bin2h/bin2h.c
  77. 14 14
      src/utils/sendromdata.py

+ 1 - 1
CMakeLists.txt

@@ -2,7 +2,7 @@
 # peTI-NESulator CMake
 #
 # Created by Manoel TRAPIER.
-# Copyright (c) 2003-2018 986Corp. All rights reserved.
+# Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$
 # $Author$

+ 1 - 1
src/CMakeLists.txt

@@ -1,7 +1,7 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
+# Created by Manoël TRAPIER.
 # Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$

+ 58 - 53
src/NESCarts.c

@@ -2,13 +2,14 @@
  *  Cart manager - The peTI-NESulator Project
  *  NESCart.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 /* System Headers */
 #if !defined(__TIGCC__) && !defined(__GCC4TI__) && !defined(__GTC__)
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <memory.h>
@@ -26,89 +27,93 @@
 #include <mappers/manager.h>
 #include <sys/mman.h>
 
-void DumpCartProperties(FILE *out, NesCart * cart)
+void DumpCartProperties(FILE *out, NesCart *cart)
 {
     console_printf(Console_Verbose,
-            "'%s' informations:\n"
-            "   Total ROM Size       : 0x%06lX    | Total VROM Size      : 0x%06lX\n"
-            "   Mapper ID            : 0x%06X    | Mirroring ?          : %s\n"
-            "   Battery ?            : %s         | 4 Screen ?           : %s   \n"
-            "   PROMBanks start at   : %p  |\n"
-            "   VROMBanks start at   : %p  |\n",
-            cart->FileName,
-            cart->PROMSize,
-            cart->VROMSize,
-            cart->MapperID,
-           (cart->Flags & iNES_MIRROR) ? "Horizontal" : "Vertical",
-           (cart->Flags & iNES_BATTERY)? "Yes": "No ",
-           (cart->Flags & iNES_4SCREEN)? "Yes": "No ",
-            cart->PROMBanks,
-            cart->VROMBanks);
+                   "'%s' informations:\n"
+                           "   Total ROM Size       : 0x%06lX    | Total VROM Size      : 0x%06lX\n"
+                           "   Mapper ID            : 0x%06X    | Mirroring ?          : %s\n"
+                           "   Battery ?            : %s         | 4 Screen ?           : %s   \n"
+                           "   PROMBanks start at   : %p  |\n"
+                           "   VROMBanks start at   : %p  |\n",
+                   cart->FileName,
+                   cart->PROMSize,
+                   cart->VROMSize,
+                   cart->MapperID,
+                   (cart->Flags & iNES_MIRROR) ? "Horizontal" : "Vertical",
+                   (cart->Flags & iNES_BATTERY) ? "Yes" : "No ",
+                   (cart->Flags & iNES_4SCREEN) ? "Yes" : "No ",
+                   cart->PROMBanks,
+                   cart->VROMBanks);
 }
 
-int LoadCart(const char *filename, NesCart * cart) 
+int LoadCart(const char *filename, NesCart *cart)
 {
     char buffer[6];
     /* Load the cart into memory */
     cart->File = (uint8_t *)LoadFilePtr((char *)filename);
-    
-    
+
+
     if ((cart->File == NULL) || (cart->File == MAP_FAILED))
-      return -1;
-    
-	sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
-	
-	/* Verify that this is a real iNES valid file */
-	if (memcmp(cart->File, buffer, 4))
-		return -1;
-    
+    {
+        return -1;
+    }
+
+    sprintf(buffer, "%c%c%c%c", 0x4E, 0x45, 0x53, 0x1A);
+
+    /* Verify that this is a real iNES valid file */
+    if (memcmp(cart->File, buffer, 4) != 0)
+    {
+        return -1;
+    }
+
     /* Before go elsewhere, verify that the header is clean !
            (aka no DiskDude! in it) */
-    if (memcmp(cart->File+7, "DiskDude!", 9) == 0)
+    if (memcmp(cart->File + 7, "DiskDude!", 9) == 0)
     {
         console_printf(Console_Warning, "\n"
-               "*******************WARNING****************\n"
-               "* The header of this game is not clean   *\n"
-               "* (DiskDude! pollution) I will only use  *\n"
-               "* basic MapperID (mapper 0-15). This can *\n"
-               "* led to unexpected behavior...          *\n"
-               "*                                        *\n"
-               "*        PLEASE CLEAN THIS FILE!         *\n"
-               "******************WARNING*****************\n\n");
+                "*******************WARNING****************\n"
+                "* The header of this game is not clean   *\n"
+                "* (DiskDude! pollution) I will only use  *\n"
+                "* basic MapperID (mapper 0-15). This can *\n"
+                "* led to unexpected behavior...          *\n"
+                "*                                        *\n"
+                "*        PLEASE CLEAN THIS FILE!         *\n"
+                "******************WARNING*****************\n\n");
         /* So this rom file is not clean, we can only rely on the "basic" mapperID */
-        cart->MapperID = cart->File[6]>>4;  /* Mapper Type */
+        cart->MapperID = cart->File[6] >> 4;  /* Mapper Type */
 
     }
     else
     {   /* This rom file is clean, we can read the extended MapperID */
-        cart->MapperID = (cart->File[6]>>4)|(cart->File[7]&0xF0);  /* Mapper Type */
+        cart->MapperID = (cart->File[6] >> 4) | (cart->File[7] & 0xF0);  /* Mapper Type */
     }
 
     /* Now fill the structure */
     cart->FileName = (char *)filename;
 
-    cart->PROMSize = cart->File[4] * 16 * 1024;               /* Size of PROM */
-    cart->VROMSize = cart->File[5] *  8 * 1024;               /* Size of VROM */   
+    cart->PROMSize = cart->File[4] * 16U * 1024U;               /* Size of PROM */
+    cart->VROMSize = cart->File[5] * 8U * 1024U;               /* Size of VROM */
     cart->Flags = cart->File[6] & 0x0F;
-    
+
     /* We don't and we will never support trainer-ed ROM */
     if (cart->Flags & iNES_TRAINER)
     {
         console_printf(Console_Error, "\n"
-               "********************ERROR*****************\n"
-               "* This cart have an embedded trainer.    *\n"
-               "* There is NO support for them.          *\n"
-               "* Please use a CLEAN dump if you want    *\n"
-               "* to play this game.                     *\n"
-               "********************ERROR*****************\n\n");
-        return -1; 
+                "********************ERROR*****************\n"
+                "* This cart have an embedded trainer.    *\n"
+                "* There is NO support for them.          *\n"
+                "* Please use a CLEAN dump if you want    *\n"
+                "* to play this game.                     *\n"
+                "********************ERROR*****************\n\n");
+        return -1;
     }
-    
+
     cart->PROMBanks = cart->File + 16;                     /* Pointer on the first PROM */
-    
-    cart->VROMBanks = cart->PROMBanks + cart->PROMSize;    /* Pointer on the first VROM */       
+
+    cart->VROMBanks = cart->PROMBanks + cart->PROMSize;    /* Pointer on the first VROM */
 
     DumpCartProperties(stdout, cart);
 
-    return 0;    
+    return 0;
 } 

+ 1 - 1
src/apu/CMakeLists.txt

@@ -1,7 +1,7 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
+# Created by Manoël TRAPIER.
 # Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$

+ 1 - 1
src/apu/apu.c

@@ -2,7 +2,7 @@
  *  APU emulation - The peTI-NESulator Project
  *  apu.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */

+ 2 - 2
src/corecpu/CMakeLists.txt

@@ -1,8 +1,8 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
-# Copyright (c) 2003-2008 986Corp. All rights reserved.
+# Created by Manoël TRAPIER.
+# Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$
 # $Author$

File diff suppressed because it is too large
+ 356 - 321
src/corecpu/corecpu.c


+ 0 - 1039
src/include/MIDIFreq.h

@@ -1,1039 +0,0 @@
-/** EMULib Emulation Library *********************************/
-/**                                                         **/
-/**                       MIDIFreq.h                        **/
-/**                                                         **/
-/** This file contains a table to convert sound frequencies **/
-/** into MIDI octave/note numbers. It is included from the  **/
-/** Sound.c and SndWin.c files.                             **/
-/**                                                         **/
-/** Copyright (C) Marat Fayzullin 1996-2007                 **/
-/**     You are not allowed to distribute this software     **/
-/**     commercially. Please, notify me, if you make any    **/
-/**     changes to this file.                               **/
-/*************************************************************/
-/*/
-
-{ -36, 8063 },{ -12, 8063 },{  -3, 8298 },{   3, 8358 },
-{   8, 8201 },{  12, 8063 },{  15, 8054 },{  17, 8238 },
-{  19, 8311 },{  21, 8298 },{  23, 8217 },{  25, 8080 },
-{  26, 8238 },{  27, 8358 },{  29, 8102 },{  30, 8159 },
-{  31, 8191 },{  32, 8201 },{  33, 8191 },{  34, 8164 },
-{  35, 8121 },{  36, 8063 },{  36, 8334 },{  37, 8251 },
-{  38, 8158 },{  39, 8054 },{  39, 8283 },{  40, 8162 },
-{  41, 8033 },{  41, 8238 },{  42, 8095 },{  42, 8287 },
-{  43, 8131 },{  43, 8311 },{  44, 8144 },{  44, 8314 },
-{  45, 8137 },{  45, 8298 },{  46, 8113 },{  46, 8265 },
-{  47, 8072 },{  47, 8217 },{  47, 8358 },{  48, 8155 },
-{  48, 8289 },{  49, 8080 },{  49, 8209 },{  49, 8335 },
-{  50, 8117 },{  50, 8238 },{  50, 8357 },{  51, 8132 },
-{  51, 8246 },{  51, 8358 },{  52, 8126 },{  52, 8234 },
-{  52, 8340 },{  53, 8102 },{  53, 8204 },{  53, 8305 },
-{  54, 8062 },{  54, 8159 },{  54, 8255 },{  54, 8349 },
-{  55, 8100 },{  55, 8191 },{  55, 8281 },{  56, 8028 },
-{  56, 8115 },{  56, 8201 },{  56, 8286 },{  57, 8028 },
-{  57, 8110 },{  57, 8191 },{  57, 8271 },{  57, 8350 },
-{  58, 8087 },{  58, 8164 },{  58, 8240 },{  58, 8315 },
-{  59, 8047 },{  59, 8121 },{  59, 8193 },{  59, 8264 },
-{  59, 8335 },{  60, 8063 },{  60, 8132 },{  60, 8200 },
-{  60, 8267 },{  60, 8334 },{  61, 8058 },{  61, 8123 },
-{  61, 8188 },{  61, 8251 },{  61, 8314 },{  62, 8035 },
-{  62, 8097 },{  62, 8158 },{  62, 8218 },{  62, 8278 },
-{  62, 8337 },{  63, 8054 },{  63, 8112 },{  63, 8170 },
-{  63, 8227 },{  63, 8283 },{  63, 8339 },{  64, 8053 },
-{  64, 8108 },{  64, 8162 },{  64, 8216 },{  64, 8269 },
-{  64, 8322 },{  65, 8033 },{  65, 8085 },{  65, 8137 },
-{  65, 8188 },{  65, 8238 },{  65, 8288 },{  65, 8338 },
-{  66, 8046 },{  66, 8095 },{  66, 8143 },{  66, 8191 },
-{  66, 8239 },{  66, 8287 },{  66, 8334 },{  67, 8039 },
-{  67, 8085 },{  67, 8131 },{  67, 8176 },{  67, 8222 },
-{  67, 8266 },{  67, 8311 },{  67, 8355 },{  68, 8057 },
-{  68, 8101 },{  68, 8144 },{  68, 8187 },{  68, 8230 },
-{  68, 8272 },{  68, 8314 },{  68, 8356 },{  69, 8056 },
-{  69, 8097 },{  69, 8137 },{  69, 8178 },{  69, 8218 },
-{  69, 8258 },{  69, 8298 },{  69, 8337 },{  70, 8035 },
-{  70, 8074 },{  70, 8113 },{  70, 8151 },{  70, 8189 },
-{  70, 8227 },{  70, 8265 },{  70, 8302 },{  70, 8340 },
-{  71, 8035 },{  71, 8072 },{  71, 8108 },{  71, 8145 },
-{  71, 8181 },{  71, 8217 },{  71, 8252 },{  71, 8288 },
-{  71, 8323 },{  71, 8358 },{  72, 8051 },{  72, 8086 },
-{  72, 8120 },{  72, 8155 },{  72, 8189 },{  72, 8222 },
-{  72, 8256 },{  72, 8289 },{  72, 8323 },{  72, 8356 },
-{  73, 8047 },{  73, 8080 },{  73, 8112 },{  73, 8145 },
-{  73, 8177 },{  73, 8209 },{  73, 8241 },{  73, 8272 },
-{  73, 8304 },{  73, 8335 },{  74, 8025 },{  74, 8056 },
-{  74, 8087 },{  74, 8117 },{  74, 8148 },{  74, 8178 },
-{  74, 8208 },{  74, 8238 },{  74, 8268 },{  74, 8298 },
-{  74, 8327 },{  74, 8357 },{  75, 8045 },{  75, 8074 },
-{  75, 8103 },{  75, 8132 },{  75, 8160 },{  75, 8189 },
-{  75, 8217 },{  75, 8246 },{  75, 8274 },{  75, 8302 },
-{  75, 8330 },{  75, 8358 },{  76, 8044 },{  76, 8071 },
-{  76, 8099 },{  76, 8126 },{  76, 8153 },{  76, 8180 },
-{  76, 8207 },{  76, 8234 },{  76, 8260 },{  76, 8287 },
-{  76, 8313 },{  76, 8340 },{  77, 8024 },{  77, 8051 },
-{  77, 8076 },{  77, 8102 },{  77, 8128 },{  77, 8154 },
-{  77, 8179 },{  77, 8204 },{  77, 8230 },{  77, 8255 },
-{  77, 8280 },{  77, 8305 },{  77, 8330 },{  77, 8354 },
-{  78, 8038 },{  78, 8062 },{  78, 8087 },{  78, 8111 },
-{  78, 8135 },{  78, 8159 },{  78, 8183 },{  78, 8207 },
-{  78, 8231 },{  78, 8255 },{  78, 8279 },{  78, 8302 },
-{  78, 8326 },{  78, 8349 },{  79, 8031 },{  79, 8054 },
-{  79, 8077 },{  79, 8100 },{  79, 8123 },{  79, 8146 },
-{  79, 8169 },{  79, 8191 },{  79, 8214 },{  79, 8237 },
-{  79, 8259 },{  79, 8281 },{  79, 8303 },{  79, 8326 },
-{  79, 8348 },{  80, 8028 },{  80, 8050 },{  80, 8072 },
-{  80, 8094 },{  80, 8115 },{  80, 8137 },{  80, 8159 },
-{  80, 8180 },{  80, 8201 },{  80, 8223 },{  80, 8244 },
-{  80, 8265 },{  80, 8286 },{  80, 8307 },{  80, 8328 },
-{  80, 8349 },{  81, 8028 },{  81, 8049 },{  81, 8069 },
-{  81, 8090 },{  81, 8110 },{  81, 8131 },{  81, 8151 },
-{  81, 8171 },{  81, 8191 },{  81, 8212 },{  81, 8232 },
-{  81, 8252 },{  81, 8271 },{  81, 8291 },{  81, 8311 },
-{  81, 8331 },{  81, 8350 },{  82, 8029 },{  82, 8048 },
-{  82, 8068 },{  82, 8087 },{  82, 8106 },{  82, 8126 },
-{  82, 8145 },{  82, 8164 },{  82, 8183 },{  82, 8202 },
-{  82, 8221 },{  82, 8240 },{  82, 8259 },{  82, 8277 },
-{  82, 8296 },{  82, 8315 },{  82, 8333 },{  82, 8352 },
-{  83, 8029 },{  83, 8047 },{  83, 8066 },{  83, 8084 },
-{  83, 8102 },{  83, 8121 },{  83, 8139 },{  83, 8157 },
-{  83, 8175 },{  83, 8193 },{  83, 8211 },{  83, 8229 },
-{  83, 8246 },{  83, 8264 },{  83, 8282 },{  83, 8299 },
-{  83, 8317 },{  83, 8335 },{  83, 8352 },{  84, 8028 },
-{  84, 8046 },{  84, 8063 },{  84, 8080 },{  84, 8097 },
-{  84, 8115 },{  84, 8132 },{  84, 8149 },{  84, 8166 },
-{  84, 8183 },{  84, 8200 },{  84, 8217 },{  84, 8234 },
-{  84, 8250 },{  84, 8267 },{  84, 8284 },{  84, 8300 },
-{  84, 8317 },{  84, 8334 },{  84, 8350 },{  85, 8025 },
-{  85, 8042 },{  85, 8058 },{  85, 8074 },{  85, 8091 },
-{  85, 8107 },{  85, 8123 },{  85, 8139 },{  85, 8155 },
-{  85, 8171 },{  85, 8188 },{  85, 8203 },{  85, 8219 },
-{  85, 8235 },{  85, 8251 },{  85, 8267 },{  85, 8283 },
-{  85, 8298 },{  85, 8314 },{  85, 8330 },{  85, 8345 },
-{  85, 8361 },{  86, 8035 },{  86, 8051 },{  86, 8066 },
-{  86, 8081 },{  86, 8097 },{  86, 8112 },{  86, 8127 },
-{  86, 8143 },{  86, 8158 },{  86, 8173 },{  86, 8188 },
-{  86, 8203 },{  86, 8218 },{  86, 8233 },{  86, 8248 },
-{  86, 8263 },{  86, 8278 },{  86, 8293 },{  86, 8308 },
-{  86, 8322 },{  86, 8337 },{  86, 8352 },{  87, 8025 },
-{  87, 8040 },{  87, 8054 },{  87, 8069 },{  87, 8084 },
-{  87, 8098 },{  87, 8112 },{  87, 8127 },{  87, 8141 },
-{  87, 8156 },{  87, 8170 },{  87, 8184 },{  87, 8198 },
-{  87, 8213 },{  87, 8227 },{  87, 8241 },{  87, 8255 },
-{  87, 8269 },{  87, 8283 },{  87, 8297 },{  87, 8311 },
-{  87, 8325 },{  87, 8339 },{  87, 8353 },{  88, 8025 },
-{  88, 8039 },{  88, 8053 },{  88, 8067 },{  88, 8081 },
-{  88, 8094 },{  88, 8108 },{  88, 8121 },{  88, 8135 },
-{  88, 8149 },{  88, 8162 },{  88, 8176 },{  88, 8189 },
-{  88, 8203 },{  88, 8216 },{  88, 8229 },{  88, 8243 },
-{  88, 8256 },{  88, 8269 },{  88, 8283 },{  88, 8296 },
-{  88, 8309 },{  88, 8322 },{  88, 8335 },{  88, 8348 },
-{  88, 8361 },{  89, 8033 },{  89, 8046 },{  89, 8059 },
-{  89, 8072 },{  89, 8085 },{  89, 8098 },{  89, 8111 },
-{  89, 8124 },{  89, 8137 },{  89, 8149 },{  89, 8162 },
-{  89, 8175 },{  89, 8188 },{  89, 8200 },{  89, 8213 },
-{  89, 8226 },{  89, 8238 },{  89, 8251 },{  89, 8263 },
-{  89, 8276 },{  89, 8288 },{  89, 8301 },{  89, 8313 },
-{  89, 8326 },{  89, 8338 },{  89, 8350 },{  90, 8021 },
-{  90, 8034 },{  90, 8046 },{  90, 8058 },{  90, 8070 },
-{  90, 8083 },{  90, 8095 },{  90, 8107 },{  90, 8119 },
-{  90, 8131 },{  90, 8143 },{  90, 8155 },{  90, 8167 },
-{  90, 8179 },{  90, 8191 },{  90, 8203 },{  90, 8215 },
-{  90, 8227 },{  90, 8239 },{  90, 8251 },{  90, 8263 },
-{  90, 8275 },{  90, 8287 },{  90, 8298 },{  90, 8310 },
-{  90, 8322 },{  90, 8334 },{  90, 8345 },{  90, 8357 },
-{  91, 8027 },{  91, 8039 },{  91, 8050 },{  91, 8062 },
-{  91, 8073 },{  91, 8085 },{  91, 8096 },{  91, 8108 },
-{  91, 8119 },{  91, 8131 },{  91, 8142 },{  91, 8154 },
-{  91, 8165 },{  91, 8176 },{  91, 8188 },{  91, 8199 },
-{  91, 8210 },{  91, 8222 },{  91, 8233 },{  91, 8244 },
-{  91, 8255 },{  91, 8266 },{  91, 8278 },{  91, 8289 },
-{  91, 8300 },{  91, 8311 },{  91, 8322 },{  91, 8333 },
-{  91, 8344 },{  91, 8355 },{  92, 8025 },{  92, 8036 },
-{  92, 8047 },{  92, 8057 },{  92, 8068 },{  92, 8079 },
-{  92, 8090 },{  92, 8101 },{  92, 8112 },{  92, 8123 },
-{  92, 8133 },{  92, 8144 },{  92, 8155 },{  92, 8166 },
-{  92, 8176 },{  92, 8187 },{  92, 8198 },{  92, 8208 },
-{  92, 8219 },{  92, 8230 },{  92, 8240 },{  92, 8251 },
-{  92, 8261 },{  92, 8272 },{  92, 8282 },{  92, 8293 },
-{  92, 8303 },{  92, 8314 },{  92, 8324 },{  92, 8335 },
-{  92, 8345 },{  92, 8356 },{  93, 8025 },{  93, 8035 },
-{  93, 8045 },{  93, 8056 },{  93, 8066 },{  93, 8076 },
-{  93, 8086 },{  93, 8097 },{  93, 8107 },{  93, 8117 },
-{  93, 8127 },{  93, 8137 },{  93, 8148 },{  93, 8158 },
-{  93, 8168 },{  93, 8178 },{  93, 8188 },{  93, 8198 },
-{  93, 8208 },{  93, 8218 },{  93, 8228 },{  93, 8238 },
-{  93, 8248 },{  93, 8258 },{  93, 8268 },{  93, 8278 },
-{  93, 8288 },{  93, 8298 },{  93, 8308 },{  93, 8318 },
-{  93, 8327 },{  93, 8337 },{  93, 8347 },{  93, 8357 },
-{  94, 8025 },{  94, 8035 },{  94, 8045 },{  94, 8055 },
-{  94, 8064 },{  94, 8074 },{  94, 8084 },{  94, 8093 },
-{  94, 8103 },{  94, 8113 },{  94, 8122 },{  94, 8132 },
-{  94, 8142 },{  94, 8151 },{  94, 8161 },{  94, 8170 },
-{  94, 8180 },{  94, 8189 },{  94, 8199 },{  94, 8208 },
-{  94, 8218 },{  94, 8227 },{  94, 8237 },{  94, 8246 },
-{  94, 8256 },{  94, 8265 },{  94, 8274 },{  94, 8284 },
-{  94, 8293 },{  94, 8302 },{  94, 8312 },{  94, 8321 },
-{  94, 8330 },{  94, 8340 },{  94, 8349 },{  94, 8358 },
-{  95, 8026 },{  95, 8035 },{  95, 8044 },{  95, 8054 },
-{  95, 8063 },{  95, 8072 },{  95, 8081 },{  95, 8090 },
-{  95, 8099 },{  95, 8108 },{  95, 8118 },{  95, 8127 },
-{  95, 8136 },{  95, 8145 },{  95, 8154 },{  95, 8163 },
-{  95, 8172 },{  95, 8181 },{  95, 8190 },{  95, 8199 },
-{  95, 8208 },{  95, 8217 },{  95, 8226 },{  95, 8235 },
-{  95, 8243 },{  95, 8252 },{  95, 8261 },{  95, 8270 },
-{  95, 8279 },{  95, 8288 },{  95, 8297 },{  95, 8305 },
-{  95, 8314 },{  95, 8323 },{  95, 8332 },{  95, 8340 },
-{  95, 8349 },{  95, 8358 },{  96, 8025 },{  96, 8034 },
-{  96, 8043 },{  96, 8051 },{  96, 8060 },{  96, 8069 },
-{  96, 8077 },{  96, 8086 },{  96, 8095 },{  96, 8103 },
-{  96, 8112 },{  96, 8120 },{  96, 8129 },{  96, 8137 },
-{  96, 8146 },{  96, 8155 },{  96, 8163 },{  96, 8172 },
-{  96, 8180 },{  96, 8189 },{  96, 8197 },{  96, 8205 },
-{  96, 8214 },{  96, 8222 },{  96, 8231 },{  96, 8239 },
-{  96, 8248 },{  96, 8256 },{  96, 8264 },{  96, 8273 },
-{  96, 8281 },{  96, 8289 },{  96, 8298 },{  96, 8306 },
-{  96, 8314 },{  96, 8323 },{  96, 8331 },{  96, 8339 },
-{  96, 8347 },{  96, 8356 },{  97, 8023 },{  97, 8031 },
-{  97, 8039 },{  97, 8047 },{  97, 8055 },{  97, 8064 },
-{  97, 8072 },{  97, 8080 },{  97, 8088 },{  97, 8096 },
-{  97, 8104 },{  97, 8112 },{  97, 8120 },{  97, 8129 },
-{  97, 8137 },{  97, 8145 },{  97, 8153 },{  97, 8161 },
-{  97, 8169 },{  97, 8177 },{  97, 8185 },{  97, 8193 },
-{  97, 8201 },{  97, 8209 },{  97, 8217 },{  97, 8225 },
-{  97, 8233 },{  97, 8241 },{  97, 8249 },{  97, 8256 },
-{  97, 8264 },{  97, 8272 },{  97, 8280 },{  97, 8288 },
-{  97, 8296 },{  97, 8304 },{  97, 8312 },{  97, 8319 },
-{  97, 8327 },{  97, 8335 },{  97, 8343 },{  97, 8351 },
-{  97, 8358 },{  98, 8025 },{  98, 8033 },{  98, 8040 },
-{  98, 8048 },{  98, 8056 },{  98, 8063 },{  98, 8071 },
-{  98, 8079 },{  98, 8087 },{  98, 8094 },{  98, 8102 },
-{  98, 8110 },{  98, 8117 },{  98, 8125 },{  98, 8132 },
-{  98, 8140 },{  98, 8148 },{  98, 8155 },{  98, 8163 },
-{  98, 8170 },{  98, 8178 },{  98, 8186 },{  98, 8193 },
-{  98, 8201 },{  98, 8208 },{  98, 8216 },{  98, 8223 },
-{  98, 8231 },{  98, 8238 },{  98, 8246 },{  98, 8253 },
-{  98, 8261 },{  98, 8268 },{  98, 8276 },{  98, 8283 },
-{  98, 8290 },{  98, 8298 },{  98, 8305 },{  98, 8313 },
-{  98, 8320 },{  98, 8327 },{  98, 8335 },{  98, 8342 },
-{  98, 8349 },{  98, 8357 },{  99, 8023 },{  99, 8030 },
-{  99, 8037 },{  99, 8045 },{  99, 8052 },{  99, 8059 },
-{  99, 8067 },{  99, 8074 },{  99, 8081 },{  99, 8088 },
-{  99, 8096 },{  99, 8103 },{  99, 8110 },{  99, 8117 },
-{  99, 8125 },{  99, 8132 },{  99, 8139 },{  99, 8146 },
-{  99, 8153 },{  99, 8160 },{  99, 8168 },{  99, 8175 },
-{  99, 8182 },{  99, 8189 },{  99, 8196 },{  99, 8203 },
-{  99, 8210 },{  99, 8217 },{  99, 8225 },{  99, 8232 },
-{  99, 8239 },{  99, 8246 },{  99, 8253 },{  99, 8260 },
-{  99, 8267 },{  99, 8274 },{  99, 8281 },{  99, 8288 },
-{  99, 8295 },{  99, 8302 },{  99, 8309 },{  99, 8316 },
-{  99, 8323 },{  99, 8330 },{  99, 8337 },{  99, 8344 },
-{  99, 8351 },{  99, 8358 },{ 100, 8023 },{ 100, 8030 },
-{ 100, 8037 },{ 100, 8044 },{ 100, 8051 },{ 100, 8058 },
-{ 100, 8065 },{ 100, 8071 },{ 100, 8078 },{ 100, 8085 },
-{ 100, 8092 },{ 100, 8099 },{ 100, 8106 },{ 100, 8112 },
-{ 100, 8119 },{ 100, 8126 },{ 100, 8133 },{ 100, 8140 },
-{ 100, 8146 },{ 100, 8153 },{ 100, 8160 },{ 100, 8167 },
-{ 100, 8173 },{ 100, 8180 },{ 100, 8187 },{ 100, 8194 },
-{ 100, 8200 },{ 100, 8207 },{ 100, 8214 },{ 100, 8220 },
-{ 100, 8227 },{ 100, 8234 },{ 100, 8240 },{ 100, 8247 },
-{ 100, 8254 },{ 100, 8260 },{ 100, 8267 },{ 100, 8274 },
-{ 100, 8280 },{ 100, 8287 },{ 100, 8294 },{ 100, 8300 },
-{ 100, 8307 },{ 100, 8313 },{ 100, 8320 },{ 100, 8326 },
-{ 100, 8333 },{ 100, 8340 },{ 100, 8346 },{ 100, 8353 },
-{ 100, 8359 },{ 101, 8024 },{ 101, 8031 },{ 101, 8037 },
-{ 101, 8044 },{ 101, 8051 },{ 101, 8057 },{ 101, 8063 },
-{ 101, 8070 },{ 101, 8076 },{ 101, 8083 },{ 101, 8089 },
-{ 101, 8096 },{ 101, 8102 },{ 101, 8109 },{ 101, 8115 },
-{ 101, 8122 },{ 101, 8128 },{ 101, 8134 },{ 101, 8141 },
-{ 101, 8147 },{ 101, 8154 },{ 101, 8160 },{ 101, 8166 },
-{ 101, 8173 },{ 101, 8179 },{ 101, 8185 },{ 101, 8192 },
-{ 101, 8198 },{ 101, 8204 },{ 101, 8211 },{ 101, 8217 },
-{ 101, 8223 },{ 101, 8230 },{ 101, 8236 },{ 101, 8242 },
-{ 101, 8249 },{ 101, 8255 },{ 101, 8261 },{ 101, 8267 },
-{ 101, 8274 },{ 101, 8280 },{ 101, 8286 },{ 101, 8292 },
-{ 101, 8299 },{ 101, 8305 },{ 101, 8311 },{ 101, 8317 },
-{ 101, 8324 },{ 101, 8330 },{ 101, 8336 },{ 101, 8342 },
-{ 101, 8348 },{ 101, 8354 },{ 101, 8361 },{ 102, 8025 },
-{ 102, 8032 },{ 102, 8038 },{ 102, 8044 },{ 102, 8050 },
-{ 102, 8056 },{ 102, 8062 },{ 102, 8068 },{ 102, 8075 },
-{ 102, 8081 },{ 102, 8087 },{ 102, 8093 },{ 102, 8099 },
-{ 102, 8105 },{ 102, 8111 },{ 102, 8117 },{ 102, 8123 },
-{ 102, 8129 },{ 102, 8135 },{ 102, 8141 },{ 102, 8147 },
-{ 102, 8153 },{ 102, 8159 },{ 102, 8165 },{ 102, 8171 },
-{ 102, 8177 },{ 102, 8183 },{ 102, 8189 },{ 102, 8195 },
-{ 102, 8201 },{ 102, 8207 },{ 102, 8213 },{ 102, 8219 },
-{ 102, 8225 },{ 102, 8231 },{ 102, 8237 },{ 102, 8243 },
-{ 102, 8249 },{ 102, 8255 },{ 102, 8261 },{ 102, 8267 },
-{ 102, 8273 },{ 102, 8279 },{ 102, 8285 },{ 102, 8290 },
-{ 102, 8296 },{ 102, 8302 },{ 102, 8308 },{ 102, 8314 },
-{ 102, 8320 },{ 102, 8326 },{ 102, 8332 },{ 102, 8337 },
-{ 102, 8343 },{ 102, 8349 },{ 102, 8355 },{ 102, 8361 },
-{ 103, 8025 },{ 103, 8031 },{ 103, 8037 },{ 103, 8043 },
-{ 103, 8048 },{ 103, 8054 },{ 103, 8060 },{ 103, 8066 },
-{ 103, 8072 },{ 103, 8077 },{ 103, 8083 },{ 103, 8089 },
-{ 103, 8095 },{ 103, 8100 },{ 103, 8106 },{ 103, 8112 },
-{ 103, 8118 },{ 103, 8123 },{ 103, 8129 },{ 103, 8135 },
-{ 103, 8140 },{ 103, 8146 },{ 103, 8152 },{ 103, 8157 },
-{ 103, 8163 },{ 103, 8169 },{ 103, 8174 },{ 103, 8180 },
-{ 103, 8186 },{ 103, 8191 },{ 103, 8197 },{ 103, 8203 },
-{ 103, 8208 },{ 103, 8214 },{ 103, 8220 },{ 103, 8225 },
-{ 103, 8231 },{ 103, 8237 },{ 103, 8242 },{ 103, 8248 },
-{ 103, 8253 },{ 103, 8259 },{ 103, 8265 },{ 103, 8270 },
-{ 103, 8276 },{ 103, 8281 },{ 103, 8287 },{ 103, 8292 },
-{ 103, 8298 },{ 103, 8303 },{ 103, 8309 },{ 103, 8315 },
-{ 103, 8320 },{ 103, 8326 },{ 103, 8331 },{ 103, 8337 },
-{ 103, 8342 },{ 103, 8348 },{ 103, 8353 },{ 103, 8359 },
-{ 104, 8023 },{ 104, 8028 },{ 104, 8034 },{ 104, 8039 },
-{ 104, 8045 },{ 104, 8050 },{ 104, 8056 },{ 104, 8061 },
-{ 104, 8067 },{ 104, 8072 },{ 104, 8077 },{ 104, 8083 },
-{ 104, 8088 },{ 104, 8094 },{ 104, 8099 },{ 104, 8105 },
-{ 104, 8110 },{ 104, 8115 },{ 104, 8121 },{ 104, 8126 },
-{ 104, 8132 },{ 104, 8137 },{ 104, 8142 },{ 104, 8148 },
-{ 104, 8153 },{ 104, 8159 },{ 104, 8164 },{ 104, 8169 },
-{ 104, 8175 },{ 104, 8180 },{ 104, 8185 },{ 104, 8191 },
-{ 104, 8196 },{ 104, 8201 },{ 104, 8207 },{ 104, 8212 },
-{ 104, 8217 },{ 104, 8223 },{ 104, 8228 },{ 104, 8233 },
-{ 104, 8238 },{ 104, 8244 },{ 104, 8249 },{ 104, 8254 },
-{ 104, 8260 },{ 104, 8265 },{ 104, 8270 },{ 104, 8275 },
-{ 104, 8281 },{ 104, 8286 },{ 104, 8291 },{ 104, 8296 },
-{ 104, 8302 },{ 104, 8307 },{ 104, 8312 },{ 104, 8317 },
-{ 104, 8323 },{ 104, 8328 },{ 104, 8333 },{ 104, 8338 },
-{ 104, 8343 },{ 104, 8349 },{ 104, 8354 },{ 104, 8359 },
-{ 105, 8023 },{ 105, 8028 },{ 105, 8033 },{ 105, 8038 },
-{ 105, 8044 },{ 105, 8049 },{ 105, 8054 },{ 105, 8059 },
-{ 105, 8064 },{ 105, 8069 },{ 105, 8074 },{ 105, 8080 },
-{ 105, 8085 },{ 105, 8090 },{ 105, 8095 },{ 105, 8100 },
-{ 105, 8105 },{ 105, 8110 },{ 105, 8115 },{ 105, 8120 },
-{ 105, 8126 },{ 105, 8131 },{ 105, 8136 },{ 105, 8141 },
-{ 105, 8146 },{ 105, 8151 },{ 105, 8156 },{ 105, 8161 },
-{ 105, 8166 },{ 105, 8171 },{ 105, 8176 },{ 105, 8181 },
-{ 105, 8186 },{ 105, 8191 },{ 105, 8196 },{ 105, 8201 },
-{ 105, 8206 },{ 105, 8212 },{ 105, 8217 },{ 105, 8222 },
-{ 105, 8227 },{ 105, 8232 },{ 105, 8237 },{ 105, 8242 },
-{ 105, 8247 },{ 105, 8252 },{ 105, 8257 },{ 105, 8261 },
-{ 105, 8266 },{ 105, 8271 },{ 105, 8276 },{ 105, 8281 },
-{ 105, 8286 },{ 105, 8291 },{ 105, 8296 },{ 105, 8301 },
-{ 105, 8306 },{ 105, 8311 },{ 105, 8316 },{ 105, 8321 },
-{ 105, 8326 },{ 105, 8331 },{ 105, 8336 },{ 105, 8341 },
-{ 105, 8345 },{ 105, 8350 },{ 105, 8355 },{ 105, 8360 },
-{ 106, 8024 },{ 106, 8029 },{ 106, 8034 },{ 106, 8038 },
-{ 106, 8043 },{ 106, 8048 },{ 106, 8053 },{ 106, 8058 },
-{ 106, 8063 },{ 106, 8068 },{ 106, 8072 },{ 106, 8077 },
-{ 106, 8082 },{ 106, 8087 },{ 106, 8092 },{ 106, 8097 },
-{ 106, 8101 },{ 106, 8106 },{ 106, 8111 },{ 106, 8116 },
-{ 106, 8121 },{ 106, 8126 },{ 106, 8130 },{ 106, 8135 },
-{ 106, 8140 },{ 106, 8145 },{ 106, 8150 },{ 106, 8154 },
-{ 106, 8159 },{ 106, 8164 },{ 106, 8169 },{ 106, 8173 },
-{ 106, 8178 },{ 106, 8183 },{ 106, 8188 },{ 106, 8192 },
-{ 106, 8197 },{ 106, 8202 },{ 106, 8207 },{ 106, 8211 },
-{ 106, 8216 },{ 106, 8221 },{ 106, 8226 },{ 106, 8230 },
-{ 106, 8235 },{ 106, 8240 },{ 106, 8245 },{ 106, 8249 },
-{ 106, 8254 },{ 106, 8259 },{ 106, 8263 },{ 106, 8268 },
-{ 106, 8273 },{ 106, 8277 },{ 106, 8282 },{ 106, 8287 },
-{ 106, 8291 },{ 106, 8296 },{ 106, 8301 },{ 106, 8305 },
-{ 106, 8310 },{ 106, 8315 },{ 106, 8319 },{ 106, 8324 },
-{ 106, 8329 },{ 106, 8333 },{ 106, 8338 },{ 106, 8343 },
-{ 106, 8347 },{ 106, 8352 },{ 106, 8357 },{ 106, 8361 },
-{ 107, 8024 },{ 107, 8029 },{ 107, 8034 },{ 107, 8038 },
-{ 107, 8043 },{ 107, 8047 },{ 107, 8052 },{ 107, 8057 },
-{ 107, 8061 },{ 107, 8066 },{ 107, 8070 },{ 107, 8075 },
-{ 107, 8080 },{ 107, 8084 },{ 107, 8089 },{ 107, 8093 },
-{ 107, 8098 },{ 107, 8102 },{ 107, 8107 },{ 107, 8111 },
-{ 107, 8116 },{ 107, 8121 },{ 107, 8125 },{ 107, 8130 },
-{ 107, 8134 },{ 107, 8139 },{ 107, 8143 },{ 107, 8148 },
-{ 107, 8152 },{ 107, 8157 },{ 107, 8161 },{ 107, 8166 },
-{ 107, 8170 },{ 107, 8175 },{ 107, 8179 },{ 107, 8184 },
-{ 107, 8188 },{ 107, 8193 },{ 107, 8197 },{ 107, 8202 },
-{ 107, 8206 },{ 107, 8211 },{ 107, 8215 },{ 107, 8220 },
-{ 107, 8224 },{ 107, 8229 },{ 107, 8233 },{ 107, 8237 },
-{ 107, 8242 },{ 107, 8246 },{ 107, 8251 },{ 107, 8255 },
-{ 107, 8260 },{ 107, 8264 },{ 107, 8269 },{ 107, 8273 },
-{ 107, 8277 },{ 107, 8282 },{ 107, 8286 },{ 107, 8291 },
-{ 107, 8295 },{ 107, 8299 },{ 107, 8304 },{ 107, 8308 },
-{ 107, 8313 },{ 107, 8317 },{ 107, 8321 },{ 107, 8326 },
-{ 107, 8330 },{ 107, 8335 },{ 107, 8339 },{ 107, 8343 },
-{ 107, 8348 },{ 107, 8352 },{ 107, 8356 },{ 107, 8361 },
-{ 108, 8024 },{ 108, 8028 },{ 108, 8033 },{ 108, 8037 },
-{ 108, 8041 },{ 108, 8046 },{ 108, 8050 },{ 108, 8054 },
-{ 108, 8059 },{ 108, 8063 },{ 108, 8067 },{ 108, 8072 },
-{ 108, 8076 },{ 108, 8080 },{ 108, 8085 },{ 108, 8089 },
-{ 108, 8093 },{ 108, 8097 },{ 108, 8102 },{ 108, 8106 },
-{ 108, 8110 },{ 108, 8115 },{ 108, 8119 },{ 108, 8123 },
-{ 108, 8128 },{ 108, 8132 },{ 108, 8136 },{ 108, 8140 },
-{ 108, 8145 },{ 108, 8149 },{ 108, 8153 },{ 108, 8157 },
-{ 108, 8162 },{ 108, 8166 },{ 108, 8170 },{ 108, 8174 },
-{ 108, 8179 },{ 108, 8183 },{ 108, 8187 },{ 108, 8191 },
-{ 108, 8196 },{ 108, 8200 },{ 108, 8204 },{ 108, 8208 },
-{ 108, 8213 },{ 108, 8217 },{ 108, 8221 },{ 108, 8225 },
-{ 108, 8229 },{ 108, 8234 },{ 108, 8238 },{ 108, 8242 },
-{ 108, 8246 },{ 108, 8250 },{ 108, 8255 },{ 108, 8259 },
-{ 108, 8263 },{ 108, 8267 },{ 108, 8271 },{ 108, 8275 },
-{ 108, 8280 },{ 108, 8284 },{ 108, 8288 },{ 108, 8292 },
-{ 108, 8296 },{ 108, 8300 },{ 108, 8305 },{ 108, 8309 },
-{ 108, 8313 },{ 108, 8317 },{ 108, 8321 },{ 108, 8325 },
-{ 108, 8330 },{ 108, 8334 },{ 108, 8338 },{ 108, 8342 },
-{ 108, 8346 },{ 108, 8350 },{ 108, 8354 },{ 108, 8358 },
-{ 109, 8021 },{ 109, 8025 },{ 109, 8029 },{ 109, 8034 },
-{ 109, 8038 },{ 109, 8042 },{ 109, 8046 },{ 109, 8050 },
-{ 109, 8054 },{ 109, 8058 },{ 109, 8062 },{ 109, 8066 },
-{ 109, 8070 },{ 109, 8074 },{ 109, 8079 },{ 109, 8083 },
-{ 109, 8087 },{ 109, 8091 },{ 109, 8095 },{ 109, 8099 },
-{ 109, 8103 },{ 109, 8107 },{ 109, 8111 },{ 109, 8115 },
-{ 109, 8119 },{ 109, 8123 },{ 109, 8127 },{ 109, 8131 },
-{ 109, 8135 },{ 109, 8139 },{ 109, 8143 },{ 109, 8147 },
-{ 109, 8151 },{ 109, 8155 },{ 109, 8159 },{ 109, 8163 },
-{ 109, 8167 },{ 109, 8171 },{ 109, 8175 },{ 109, 8179 },
-{ 109, 8184 },{ 109, 8188 },{ 109, 8192 },{ 109, 8195 },
-{ 109, 8199 },{ 109, 8203 },{ 109, 8207 },{ 109, 8211 },
-{ 109, 8215 },{ 109, 8219 },{ 109, 8223 },{ 109, 8227 },
-{ 109, 8231 },{ 109, 8235 },{ 109, 8239 },{ 109, 8243 },
-{ 109, 8247 },{ 109, 8251 },{ 109, 8255 },{ 109, 8259 },
-{ 109, 8263 },{ 109, 8267 },{ 109, 8271 },{ 109, 8275 },
-{ 109, 8279 },{ 109, 8283 },{ 109, 8287 },{ 109, 8291 },
-{ 109, 8295 },{ 109, 8298 },{ 109, 8302 },{ 109, 8306 },
-{ 109, 8310 },{ 109, 8314 },{ 109, 8318 },{ 109, 8322 },
-{ 109, 8326 },{ 109, 8330 },{ 109, 8334 },{ 109, 8338 },
-{ 109, 8341 },{ 109, 8345 },{ 109, 8349 },{ 109, 8353 },
-{ 109, 8357 },{ 109, 8361 },{ 110, 8023 },{ 110, 8027 },
-{ 110, 8031 },{ 110, 8035 },{ 110, 8039 },{ 110, 8043 },
-{ 110, 8047 },{ 110, 8051 },{ 110, 8054 },{ 110, 8058 },
-{ 110, 8062 },{ 110, 8066 },{ 110, 8070 },{ 110, 8074 },
-{ 110, 8078 },{ 110, 8081 },{ 110, 8085 },{ 110, 8089 },
-{ 110, 8093 },{ 110, 8097 },{ 110, 8101 },{ 110, 8104 },
-{ 110, 8108 },{ 110, 8112 },{ 110, 8116 },{ 110, 8120 },
-{ 110, 8124 },{ 110, 8127 },{ 110, 8131 },{ 110, 8135 },
-{ 110, 8139 },{ 110, 8143 },{ 110, 8146 },{ 110, 8150 },
-{ 110, 8154 },{ 110, 8158 },{ 110, 8162 },{ 110, 8165 },
-{ 110, 8169 },{ 110, 8173 },{ 110, 8177 },{ 110, 8181 },
-{ 110, 8184 },{ 110, 8188 },{ 110, 8192 },{ 110, 8196 },
-{ 110, 8199 },{ 110, 8203 },{ 110, 8207 },{ 110, 8211 },
-{ 110, 8214 },{ 110, 8218 },{ 110, 8222 },{ 110, 8226 },
-{ 110, 8229 },{ 110, 8233 },{ 110, 8237 },{ 110, 8241 },
-{ 110, 8244 },{ 110, 8248 },{ 110, 8252 },{ 110, 8256 },
-{ 110, 8259 },{ 110, 8263 },{ 110, 8267 },{ 110, 8271 },
-{ 110, 8274 },{ 110, 8278 },{ 110, 8282 },{ 110, 8285 },
-{ 110, 8289 },{ 110, 8293 },{ 110, 8297 },{ 110, 8300 },
-{ 110, 8304 },{ 110, 8308 },{ 110, 8311 },{ 110, 8315 },
-{ 110, 8319 },{ 110, 8322 },{ 110, 8326 },{ 110, 8330 },
-{ 110, 8334 },{ 110, 8337 },{ 110, 8341 },{ 110, 8345 },
-{ 110, 8348 },{ 110, 8352 },{ 110, 8356 },{ 110, 8359 },
-{ 111, 8022 },{ 111, 8025 },{ 111, 8029 },{ 111, 8033 },
-{ 111, 8036 },{ 111, 8040 },{ 111, 8044 },{ 111, 8047 },
-{ 111, 8051 },{ 111, 8054 },{ 111, 8058 },{ 111, 8062 },
-{ 111, 8065 },{ 111, 8069 },{ 111, 8073 },{ 111, 8076 },
-{ 111, 8080 },{ 111, 8084 },{ 111, 8087 },{ 111, 8091 },
-{ 111, 8094 },{ 111, 8098 },{ 111, 8102 },{ 111, 8105 },
-{ 111, 8109 },{ 111, 8112 },{ 111, 8116 },{ 111, 8120 },
-{ 111, 8123 },{ 111, 8127 },{ 111, 8131 },{ 111, 8134 },
-{ 111, 8138 },{ 111, 8141 },{ 111, 8145 },{ 111, 8148 },
-{ 111, 8152 },{ 111, 8156 },{ 111, 8159 },{ 111, 8163 },
-{ 111, 8166 },{ 111, 8170 },{ 111, 8174 },{ 111, 8177 },
-{ 111, 8181 },{ 111, 8184 },{ 111, 8188 },{ 111, 8191 },
-{ 111, 8195 },{ 111, 8198 },{ 111, 8202 },{ 111, 8206 },
-{ 111, 8209 },{ 111, 8213 },{ 111, 8216 },{ 111, 8220 },
-{ 111, 8223 },{ 111, 8227 },{ 111, 8230 },{ 111, 8234 },
-{ 111, 8237 },{ 111, 8241 },{ 111, 8245 },{ 111, 8248 },
-{ 111, 8252 },{ 111, 8255 },{ 111, 8259 },{ 111, 8262 },
-{ 111, 8266 },{ 111, 8269 },{ 111, 8273 },{ 111, 8276 },
-{ 111, 8280 },{ 111, 8283 },{ 111, 8287 },{ 111, 8290 },
-{ 111, 8294 },{ 111, 8297 },{ 111, 8301 },{ 111, 8304 },
-{ 111, 8308 },{ 111, 8311 },{ 111, 8315 },{ 111, 8318 },
-{ 111, 8322 },{ 111, 8325 },{ 111, 8329 },{ 111, 8332 },
-{ 111, 8336 },{ 111, 8339 },{ 111, 8343 },{ 111, 8346 },
-{ 111, 8349 },{ 111, 8353 },{ 111, 8356 },{ 111, 8360 },
-{ 112, 8022 },{ 112, 8025 },{ 112, 8029 },{ 112, 8032 },
-{ 112, 8036 },{ 112, 8039 },{ 112, 8043 },{ 112, 8046 },
-{ 112, 8050 },{ 112, 8053 },{ 112, 8056 },{ 112, 8060 },
-{ 112, 8063 },{ 112, 8067 },{ 112, 8070 },{ 112, 8074 },
-{ 112, 8077 },{ 112, 8081 },{ 112, 8084 },{ 112, 8087 },
-{ 112, 8091 },{ 112, 8094 },{ 112, 8098 },{ 112, 8101 },
-{ 112, 8104 },{ 112, 8108 },{ 112, 8111 },{ 112, 8115 },
-{ 112, 8118 },{ 112, 8121 },{ 112, 8125 },{ 112, 8128 },
-{ 112, 8132 },{ 112, 8135 },{ 112, 8138 },{ 112, 8142 },
-{ 112, 8145 },{ 112, 8149 },{ 112, 8152 },{ 112, 8155 },
-{ 112, 8159 },{ 112, 8162 },{ 112, 8166 },{ 112, 8169 },
-{ 112, 8172 },{ 112, 8176 },{ 112, 8179 },{ 112, 8182 },
-{ 112, 8186 },{ 112, 8189 },{ 112, 8192 },{ 112, 8196 },
-{ 112, 8199 },{ 112, 8203 },{ 112, 8206 },{ 112, 8209 },
-{ 112, 8213 },{ 112, 8216 },{ 112, 8219 },{ 112, 8223 },
-{ 112, 8226 },{ 112, 8229 },{ 112, 8233 },{ 112, 8236 },
-{ 112, 8239 },{ 112, 8243 },{ 112, 8246 },{ 112, 8249 },
-{ 112, 8253 },{ 112, 8256 },{ 112, 8259 },{ 112, 8263 },
-{ 112, 8266 },{ 112, 8269 },{ 112, 8273 },{ 112, 8276 },
-{ 112, 8279 },{ 112, 8283 },{ 112, 8286 },{ 112, 8289 },
-{ 112, 8292 },{ 112, 8296 },{ 112, 8299 },{ 112, 8302 },
-{ 112, 8306 },{ 112, 8309 },{ 112, 8312 },{ 112, 8316 },
-{ 112, 8319 },{ 112, 8322 },{ 112, 8325 },{ 112, 8329 },
-{ 112, 8332 },{ 112, 8335 },{ 112, 8339 },{ 112, 8342 },
-{ 112, 8345 },{ 112, 8348 },{ 112, 8352 },{ 112, 8355 },
-{ 112, 8358 },{ 112, 8361 },{ 113, 8023 },{ 113, 8027 },
-{ 113, 8030 },{ 113, 8033 },{ 113, 8036 },{ 113, 8040 },
-{ 113, 8043 },{ 113, 8046 },{ 113, 8049 },{ 113, 8053 },
-{ 113, 8056 },{ 113, 8059 },{ 113, 8062 },{ 113, 8066 },
-{ 113, 8069 },{ 113, 8072 },{ 113, 8075 },{ 113, 8079 },
-{ 113, 8082 },{ 113, 8085 },{ 113, 8088 },{ 113, 8092 },
-{ 113, 8095 },{ 113, 8098 },{ 113, 8101 },{ 113, 8104 },
-{ 113, 8108 },{ 113, 8111 },{ 113, 8114 },{ 113, 8117 },
-{ 113, 8120 },{ 113, 8124 },{ 113, 8127 },{ 113, 8130 },
-{ 113, 8133 },{ 113, 8137 },{ 113, 8140 },{ 113, 8143 },
-{ 113, 8146 },{ 113, 8149 },{ 113, 8153 },{ 113, 8156 },
-{ 113, 8159 },{ 113, 8162 },{ 113, 8165 },{ 113, 8168 },
-{ 113, 8172 },{ 113, 8175 },{ 113, 8178 },{ 113, 8181 },
-{ 113, 8184 },{ 113, 8188 },{ 113, 8191 },{ 113, 8194 },
-{ 113, 8197 },{ 113, 8200 },{ 113, 8203 },{ 113, 8207 },
-{ 113, 8210 },{ 113, 8213 },{ 113, 8216 },{ 113, 8219 },
-{ 113, 8222 },{ 113, 8226 },{ 113, 8229 },{ 113, 8232 },
-{ 113, 8235 },{ 113, 8238 },{ 113, 8241 },{ 113, 8244 },
-{ 113, 8248 },{ 113, 8251 },{ 113, 8254 },{ 113, 8257 },
-{ 113, 8260 },{ 113, 8263 },{ 113, 8266 },{ 113, 8270 },
-{ 113, 8273 },{ 113, 8276 },{ 113, 8279 },{ 113, 8282 },
-{ 113, 8285 },{ 113, 8288 },{ 113, 8291 },{ 113, 8295 },
-{ 113, 8298 },{ 113, 8301 },{ 113, 8304 },{ 113, 8307 },
-{ 113, 8310 },{ 113, 8313 },{ 113, 8316 },{ 113, 8319 },
-{ 113, 8322 },{ 113, 8326 },{ 113, 8329 },{ 113, 8332 },
-{ 113, 8335 },{ 113, 8338 },{ 113, 8341 },{ 113, 8344 },
-{ 113, 8347 },{ 113, 8350 },{ 113, 8353 },{ 113, 8357 },
-{ 113, 8360 },{ 114, 8021 },{ 114, 8024 },{ 114, 8028 },
-{ 114, 8031 },{ 114, 8034 },{ 114, 8037 },{ 114, 8040 },
-{ 114, 8043 },{ 114, 8046 },{ 114, 8049 },{ 114, 8052 },
-{ 114, 8055 },{ 114, 8058 },{ 114, 8061 },{ 114, 8064 },
-{ 114, 8067 },{ 114, 8070 },{ 114, 8074 },{ 114, 8077 },
-{ 114, 8080 },{ 114, 8083 },{ 114, 8086 },{ 114, 8089 },
-{ 114, 8092 },{ 114, 8095 },{ 114, 8098 },{ 114, 8101 },
-{ 114, 8104 },{ 114, 8107 },{ 114, 8110 },{ 114, 8113 },
-{ 114, 8116 },{ 114, 8119 },{ 114, 8122 },{ 114, 8125 },
-{ 114, 8128 },{ 114, 8131 },{ 114, 8134 },{ 114, 8137 },
-{ 114, 8140 },{ 114, 8143 },{ 114, 8146 },{ 114, 8149 },
-{ 114, 8152 },{ 114, 8155 },{ 114, 8158 },{ 114, 8161 },
-{ 114, 8164 },{ 114, 8167 },{ 114, 8170 },{ 114, 8173 },
-{ 114, 8176 },{ 114, 8179 },{ 114, 8182 },{ 114, 8185 },
-{ 114, 8188 },{ 114, 8191 },{ 114, 8194 },{ 114, 8197 },
-{ 114, 8200 },{ 114, 8203 },{ 114, 8206 },{ 114, 8209 },
-{ 114, 8212 },{ 114, 8215 },{ 114, 8218 },{ 114, 8221 },
-{ 114, 8224 },{ 114, 8227 },{ 114, 8230 },{ 114, 8233 },
-{ 114, 8236 },{ 114, 8239 },{ 114, 8242 },{ 114, 8245 },
-{ 114, 8248 },{ 114, 8251 },{ 114, 8254 },{ 114, 8257 },
-{ 114, 8260 },{ 114, 8263 },{ 114, 8266 },{ 114, 8269 },
-{ 114, 8272 },{ 114, 8275 },{ 114, 8278 },{ 114, 8281 },
-{ 114, 8284 },{ 114, 8287 },{ 114, 8289 },{ 114, 8292 },
-{ 114, 8295 },{ 114, 8298 },{ 114, 8301 },{ 114, 8304 },
-{ 114, 8307 },{ 114, 8310 },{ 114, 8313 },{ 114, 8316 },
-{ 114, 8319 },{ 114, 8322 },{ 114, 8325 },{ 114, 8328 },
-{ 114, 8331 },{ 114, 8334 },{ 114, 8336 },{ 114, 8339 },
-{ 114, 8342 },{ 114, 8345 },{ 114, 8348 },{ 114, 8351 },
-{ 114, 8354 },{ 114, 8357 },{ 114, 8360 },{ 115, 8021 },
-{ 115, 8024 },{ 115, 8027 },{ 115, 8030 },{ 115, 8033 },
-{ 115, 8036 },{ 115, 8039 },{ 115, 8042 },{ 115, 8045 },
-{ 115, 8047 },{ 115, 8050 },{ 115, 8053 },{ 115, 8056 },
-{ 115, 8059 },{ 115, 8062 },{ 115, 8065 },{ 115, 8068 },
-{ 115, 8071 },{ 115, 8073 },{ 115, 8076 },{ 115, 8079 },
-{ 115, 8082 },{ 115, 8085 },{ 115, 8088 },{ 115, 8091 },
-{ 115, 8094 },{ 115, 8096 },{ 115, 8099 },{ 115, 8102 },
-{ 115, 8105 },{ 115, 8108 },{ 115, 8111 },{ 115, 8114 },
-{ 115, 8117 },{ 115, 8119 },{ 115, 8122 },{ 115, 8125 },
-{ 115, 8128 },{ 115, 8131 },{ 115, 8134 },{ 115, 8137 },
-{ 115, 8139 },{ 115, 8142 },{ 115, 8145 },{ 115, 8148 },
-{ 115, 8151 },{ 115, 8154 },{ 115, 8157 },{ 115, 8159 },
-{ 115, 8162 },{ 115, 8165 },{ 115, 8168 },{ 115, 8171 },
-{ 115, 8174 },{ 115, 8176 },{ 115, 8179 },{ 115, 8182 },
-{ 115, 8185 },{ 115, 8188 },{ 115, 8191 },{ 115, 8193 },
-{ 115, 8196 },{ 115, 8199 },{ 115, 8202 },{ 115, 8205 },
-{ 115, 8207 },{ 115, 8210 },{ 115, 8213 },{ 115, 8216 },
-{ 115, 8219 },{ 115, 8222 },{ 115, 8224 },{ 115, 8227 },
-{ 115, 8230 },{ 115, 8233 },{ 115, 8236 },{ 115, 8238 },
-{ 115, 8241 },{ 115, 8244 },{ 115, 8247 },{ 115, 8250 },
-{ 115, 8252 },{ 115, 8255 },{ 115, 8258 },{ 115, 8261 },
-{ 115, 8264 },{ 115, 8266 },{ 115, 8269 },{ 115, 8272 },
-{ 115, 8275 },{ 115, 8278 },{ 115, 8280 },{ 115, 8283 },
-{ 115, 8286 },{ 115, 8289 },{ 115, 8291 },{ 115, 8294 },
-{ 115, 8297 },{ 115, 8300 },{ 115, 8303 },{ 115, 8305 },
-{ 115, 8308 },{ 115, 8311 },{ 115, 8314 },{ 115, 8316 },
-{ 115, 8319 },{ 115, 8322 },{ 115, 8325 },{ 115, 8327 },
-{ 115, 8330 },{ 115, 8333 },{ 115, 8336 },{ 115, 8338 },
-{ 115, 8341 },{ 115, 8344 },{ 115, 8347 },{ 115, 8350 },
-{ 115, 8352 },{ 115, 8355 },{ 115, 8358 },{ 115, 8361 },
-{ 116, 8022 },{ 116, 8025 },{ 116, 8027 },{ 116, 8030 },
-{ 116, 8033 },{ 116, 8036 },{ 116, 8038 },{ 116, 8041 },
-{ 116, 8044 },{ 116, 8047 },{ 116, 8049 },{ 116, 8052 },
-{ 116, 8055 },{ 116, 8057 },{ 116, 8060 },{ 116, 8063 },
-{ 116, 8066 },{ 116, 8068 },{ 116, 8071 },{ 116, 8074 },
-{ 116, 8077 },{ 116, 8079 },{ 116, 8082 },{ 116, 8085 },
-{ 116, 8087 },{ 116, 8090 },{ 116, 8093 },{ 116, 8096 },
-{ 116, 8098 },{ 116, 8101 },{ 116, 8104 },{ 116, 8106 },
-{ 116, 8109 },{ 116, 8112 },{ 116, 8115 },{ 116, 8117 },
-{ 116, 8120 },{ 116, 8123 },{ 116, 8125 },{ 116, 8128 },
-{ 116, 8131 },{ 116, 8133 },{ 116, 8136 },{ 116, 8139 },
-{ 116, 8142 },{ 116, 8144 },{ 116, 8147 },{ 116, 8150 },
-{ 116, 8152 },{ 116, 8155 },{ 116, 8158 },{ 116, 8160 },
-{ 116, 8163 },{ 116, 8166 },{ 116, 8168 },{ 116, 8171 },
-{ 116, 8174 },{ 116, 8176 },{ 116, 8179 },{ 116, 8182 },
-{ 116, 8184 },{ 116, 8187 },{ 116, 8190 },{ 116, 8192 },
-{ 116, 8195 },{ 116, 8198 },{ 116, 8200 },{ 116, 8203 },
-{ 116, 8206 },{ 116, 8208 },{ 116, 8211 },{ 116, 8214 },
-{ 116, 8216 },{ 116, 8219 },{ 116, 8222 },{ 116, 8224 },
-{ 116, 8227 },{ 116, 8230 },{ 116, 8232 },{ 116, 8235 },
-{ 116, 8238 },{ 116, 8240 },{ 116, 8243 },{ 116, 8246 },
-{ 116, 8248 },{ 116, 8251 },{ 116, 8253 },{ 116, 8256 },
-{ 116, 8259 },{ 116, 8261 },{ 116, 8264 },{ 116, 8267 },
-{ 116, 8269 },{ 116, 8272 },{ 116, 8275 },{ 116, 8277 },
-{ 116, 8280 },{ 116, 8282 },{ 116, 8285 },{ 116, 8288 },
-{ 116, 8290 },{ 116, 8293 },{ 116, 8296 },{ 116, 8298 },
-{ 116, 8301 },{ 116, 8303 },{ 116, 8306 },{ 116, 8309 },
-{ 116, 8311 },{ 116, 8314 },{ 116, 8316 },{ 116, 8319 },
-{ 116, 8322 },{ 116, 8324 },{ 116, 8327 },{ 116, 8330 },
-{ 116, 8332 },{ 116, 8335 },{ 116, 8337 },{ 116, 8340 },
-{ 116, 8343 },{ 116, 8345 },{ 116, 8348 },{ 116, 8350 },
-{ 116, 8353 },{ 116, 8356 },{ 116, 8358 },{ 116, 8361 },
-{ 117, 8022 },{ 117, 8025 },{ 117, 8027 },{ 117, 8030 },
-{ 117, 8032 },{ 117, 8035 },{ 117, 8037 },{ 117, 8040 },
-{ 117, 8043 },{ 117, 8045 },{ 117, 8048 },{ 117, 8050 },
-{ 117, 8053 },{ 117, 8056 },{ 117, 8058 },{ 117, 8061 },
-{ 117, 8063 },{ 117, 8066 },{ 117, 8068 },{ 117, 8071 },
-{ 117, 8074 },{ 117, 8076 },{ 117, 8079 },{ 117, 8081 },
-{ 117, 8084 },{ 117, 8086 },{ 117, 8089 },{ 117, 8092 },
-{ 117, 8094 },{ 117, 8097 },{ 117, 8099 },{ 117, 8102 },
-{ 117, 8104 },{ 117, 8107 },{ 117, 8109 },{ 117, 8112 },
-{ 117, 8115 },{ 117, 8117 },{ 117, 8120 },{ 117, 8122 },
-{ 117, 8125 },{ 117, 8127 },{ 117, 8130 },{ 117, 8132 },
-{ 117, 8135 },{ 117, 8137 },{ 117, 8140 },{ 117, 8143 },
-{ 117, 8145 },{ 117, 8148 },{ 117, 8150 },{ 117, 8153 },
-{ 117, 8155 },{ 117, 8158 },{ 117, 8160 },{ 117, 8163 },
-{ 117, 8165 },{ 117, 8168 },{ 117, 8170 },{ 117, 8173 },
-{ 117, 8175 },{ 117, 8178 },{ 117, 8180 },{ 117, 8183 },
-{ 117, 8186 },{ 117, 8188 },{ 117, 8191 },{ 117, 8193 },
-{ 117, 8196 },{ 117, 8198 },{ 117, 8201 },{ 117, 8203 },
-{ 117, 8206 },{ 117, 8208 },{ 117, 8211 },{ 117, 8213 },
-{ 117, 8216 },{ 117, 8218 },{ 117, 8221 },{ 117, 8223 },
-{ 117, 8226 },{ 117, 8228 },{ 117, 8231 },{ 117, 8233 },
-{ 117, 8236 },{ 117, 8238 },{ 117, 8241 },{ 117, 8243 },
-{ 117, 8246 },{ 117, 8248 },{ 117, 8251 },{ 117, 8253 },
-{ 117, 8256 },{ 117, 8258 },{ 117, 8261 },{ 117, 8263 },
-{ 117, 8266 },{ 117, 8268 },{ 117, 8271 },{ 117, 8273 },
-{ 117, 8276 },{ 117, 8278 },{ 117, 8281 },{ 117, 8283 },
-{ 117, 8285 },{ 117, 8288 },{ 117, 8290 },{ 117, 8293 },
-{ 117, 8295 },{ 117, 8298 },{ 117, 8300 },{ 117, 8303 },
-{ 117, 8305 },{ 117, 8308 },{ 117, 8310 },{ 117, 8313 },
-{ 117, 8315 },{ 117, 8318 },{ 117, 8320 },{ 117, 8323 },
-{ 117, 8325 },{ 117, 8327 },{ 117, 8330 },{ 117, 8332 },
-{ 117, 8335 },{ 117, 8337 },{ 117, 8340 },{ 117, 8342 },
-{ 117, 8345 },{ 117, 8347 },{ 117, 8350 },{ 117, 8352 },
-{ 117, 8354 },{ 117, 8357 },{ 117, 8359 },{ 117, 8362 },
-{ 118, 8023 },{ 118, 8025 },{ 118, 8028 },{ 118, 8030 },
-{ 118, 8033 },{ 118, 8035 },{ 118, 8038 },{ 118, 8040 },
-{ 118, 8042 },{ 118, 8045 },{ 118, 8047 },{ 118, 8050 },
-{ 118, 8052 },{ 118, 8055 },{ 118, 8057 },{ 118, 8060 },
-{ 118, 8062 },{ 118, 8064 },{ 118, 8067 },{ 118, 8069 },
-{ 118, 8072 },{ 118, 8074 },{ 118, 8077 },{ 118, 8079 },
-{ 118, 8081 },{ 118, 8084 },{ 118, 8086 },{ 118, 8089 },
-{ 118, 8091 },{ 118, 8093 },{ 118, 8096 },{ 118, 8098 },
-{ 118, 8101 },{ 118, 8103 },{ 118, 8106 },{ 118, 8108 },
-{ 118, 8110 },{ 118, 8113 },{ 118, 8115 },{ 118, 8118 },
-{ 118, 8120 },{ 118, 8122 },{ 118, 8125 },{ 118, 8127 },
-{ 118, 8130 },{ 118, 8132 },{ 118, 8134 },{ 118, 8137 },
-{ 118, 8139 },{ 118, 8142 },{ 118, 8144 },{ 118, 8146 },
-{ 118, 8149 },{ 118, 8151 },{ 118, 8154 },{ 118, 8156 },
-{ 118, 8158 },{ 118, 8161 },{ 118, 8163 },{ 118, 8165 },
-{ 118, 8168 },{ 118, 8170 },{ 118, 8173 },{ 118, 8175 },
-{ 118, 8177 },{ 118, 8180 },{ 118, 8182 },{ 118, 8185 },
-{ 118, 8187 },{ 118, 8189 },{ 118, 8192 },{ 118, 8194 },
-{ 118, 8196 },{ 118, 8199 },{ 118, 8201 },{ 118, 8204 },
-{ 118, 8206 },{ 118, 8208 },{ 118, 8211 },{ 118, 8213 },
-{ 118, 8215 },{ 118, 8218 },{ 118, 8220 },{ 118, 8223 },
-{ 118, 8225 },{ 118, 8227 },{ 118, 8230 },{ 118, 8232 },
-{ 118, 8234 },{ 118, 8237 },{ 118, 8239 },{ 118, 8241 },
-{ 118, 8244 },{ 118, 8246 },{ 118, 8248 },{ 118, 8251 },
-{ 118, 8253 },{ 118, 8256 },{ 118, 8258 },{ 118, 8260 },
-{ 118, 8263 },{ 118, 8265 },{ 118, 8267 },{ 118, 8270 },
-{ 118, 8272 },{ 118, 8274 },{ 118, 8277 },{ 118, 8279 },
-{ 118, 8281 },{ 118, 8284 },{ 118, 8286 },{ 118, 8288 },
-{ 118, 8291 },{ 118, 8293 },{ 118, 8295 },{ 118, 8298 },
-{ 118, 8300 },{ 118, 8302 },{ 118, 8305 },{ 118, 8307 },
-{ 118, 8309 },{ 118, 8312 },{ 118, 8314 },{ 118, 8316 },
-{ 118, 8319 },{ 118, 8321 },{ 118, 8323 },{ 118, 8326 },
-{ 118, 8328 },{ 118, 8330 },{ 118, 8333 },{ 118, 8335 },
-{ 118, 8337 },{ 118, 8340 },{ 118, 8342 },{ 118, 8344 },
-{ 118, 8347 },{ 118, 8349 },{ 118, 8351 },{ 118, 8353 },
-{ 118, 8356 },{ 118, 8358 },{ 118, 8360 },{ 119, 8021 },
-{ 119, 8024 },{ 119, 8026 },{ 119, 8028 },{ 119, 8031 },
-{ 119, 8033 },{ 119, 8035 },{ 119, 8038 },{ 119, 8040 },
-{ 119, 8042 },{ 119, 8044 },{ 119, 8047 },{ 119, 8049 },
-{ 119, 8051 },{ 119, 8054 },{ 119, 8056 },{ 119, 8058 },
-{ 119, 8060 },{ 119, 8063 },{ 119, 8065 },{ 119, 8067 },
-{ 119, 8070 },{ 119, 8072 },{ 119, 8074 },{ 119, 8077 },
-{ 119, 8079 },{ 119, 8081 },{ 119, 8083 },{ 119, 8086 },
-{ 119, 8088 },{ 119, 8090 },{ 119, 8093 },{ 119, 8095 },
-{ 119, 8097 },{ 119, 8099 },{ 119, 8102 },{ 119, 8104 },
-{ 119, 8106 },{ 119, 8108 },{ 119, 8111 },{ 119, 8113 },
-{ 119, 8115 },{ 119, 8118 },{ 119, 8120 },{ 119, 8122 },
-{ 119, 8124 },{ 119, 8127 },{ 119, 8129 },{ 119, 8131 },
-{ 119, 8133 },{ 119, 8136 },{ 119, 8138 },{ 119, 8140 },
-{ 119, 8142 },{ 119, 8145 },{ 119, 8147 },{ 119, 8149 },
-{ 119, 8152 },{ 119, 8154 },{ 119, 8156 },{ 119, 8158 },
-{ 119, 8161 },{ 119, 8163 },{ 119, 8165 },{ 119, 8167 },
-{ 119, 8170 },{ 119, 8172 },{ 119, 8174 },{ 119, 8176 },
-{ 119, 8179 },{ 119, 8181 },{ 119, 8183 },{ 119, 8185 },
-{ 119, 8188 },{ 119, 8190 },{ 119, 8192 },{ 119, 8194 },
-{ 119, 8197 },{ 119, 8199 },{ 119, 8201 },{ 119, 8203 },
-{ 119, 8205 },{ 119, 8208 },{ 119, 8210 },{ 119, 8212 },
-{ 119, 8214 },{ 119, 8217 },{ 119, 8219 },{ 119, 8221 },
-{ 119, 8223 },{ 119, 8226 },{ 119, 8228 },{ 119, 8230 },
-{ 119, 8232 },{ 119, 8235 },{ 119, 8237 },{ 119, 8239 },
-{ 119, 8241 },{ 119, 8243 },{ 119, 8246 },{ 119, 8248 },
-{ 119, 8250 },{ 119, 8252 },{ 119, 8255 },{ 119, 8257 },
-{ 119, 8259 },{ 119, 8261 },{ 119, 8263 },{ 119, 8266 },
-{ 119, 8268 },{ 119, 8270 },{ 119, 8272 },{ 119, 8274 },
-{ 119, 8277 },{ 119, 8279 },{ 119, 8281 },{ 119, 8283 },
-{ 119, 8286 },{ 119, 8288 },{ 119, 8290 },{ 119, 8292 },
-{ 119, 8294 },{ 119, 8297 },{ 119, 8299 },{ 119, 8301 },
-{ 119, 8303 },{ 119, 8305 },{ 119, 8308 },{ 119, 8310 },
-{ 119, 8312 },{ 119, 8314 },{ 119, 8316 },{ 119, 8319 },
-{ 119, 8321 },{ 119, 8323 },{ 119, 8325 },{ 119, 8327 },
-{ 119, 8330 },{ 119, 8332 },{ 119, 8334 },{ 119, 8336 },
-{ 119, 8338 },{ 119, 8340 },{ 119, 8343 },{ 119, 8345 },
-{ 119, 8347 },{ 119, 8349 },{ 119, 8351 },{ 119, 8354 },
-{ 119, 8356 },{ 119, 8358 },{ 119, 8360 },{ 120, 8021 },
-{ 120, 8023 },{ 120, 8025 },{ 120, 8027 },{ 120, 8030 },
-{ 120, 8032 },{ 120, 8034 },{ 120, 8036 },{ 120, 8038 },
-{ 120, 8041 },{ 120, 8043 },{ 120, 8045 },{ 120, 8047 },
-{ 120, 8049 },{ 120, 8051 },{ 120, 8054 },{ 120, 8056 },
-{ 120, 8058 },{ 120, 8060 },{ 120, 8062 },{ 120, 8064 },
-{ 120, 8067 },{ 120, 8069 },{ 120, 8071 },{ 120, 8073 },
-{ 120, 8075 },{ 120, 8077 },{ 120, 8080 },{ 120, 8082 },
-{ 120, 8084 },{ 120, 8086 },{ 120, 8088 },{ 120, 8090 },
-{ 120, 8092 },{ 120, 8095 },{ 120, 8097 },{ 120, 8099 },
-{ 120, 8101 },{ 120, 8103 },{ 120, 8105 },{ 120, 8108 },
-{ 120, 8110 },{ 120, 8112 },{ 120, 8114 },{ 120, 8116 },
-{ 120, 8118 },{ 120, 8120 },{ 120, 8123 },{ 120, 8125 },
-{ 120, 8127 },{ 120, 8129 },{ 120, 8131 },{ 120, 8133 },
-{ 120, 8135 },{ 120, 8137 },{ 120, 8140 },{ 120, 8142 },
-{ 120, 8144 },{ 120, 8146 },{ 120, 8148 },{ 120, 8150 },
-{ 120, 8152 },{ 120, 8155 },{ 120, 8157 },{ 120, 8159 },
-{ 120, 8161 },{ 120, 8163 },{ 120, 8165 },{ 120, 8167 },
-{ 120, 8169 },{ 120, 8172 },{ 120, 8174 },{ 120, 8176 },
-{ 120, 8178 },{ 120, 8180 },{ 120, 8182 },{ 120, 8184 },
-{ 120, 8186 },{ 120, 8189 },{ 120, 8191 },{ 120, 8193 },
-{ 120, 8195 },{ 120, 8197 },{ 120, 8199 },{ 120, 8201 },
-{ 120, 8203 },{ 120, 8205 },{ 120, 8208 },{ 120, 8210 },
-{ 120, 8212 },{ 120, 8214 },{ 120, 8216 },{ 120, 8218 },
-{ 120, 8220 },{ 120, 8222 },{ 120, 8224 },{ 120, 8227 },
-{ 120, 8229 },{ 120, 8231 },{ 120, 8233 },{ 120, 8235 },
-{ 120, 8237 },{ 120, 8239 },{ 120, 8241 },{ 120, 8243 },
-{ 120, 8245 },{ 120, 8248 },{ 120, 8250 },{ 120, 8252 },
-{ 120, 8254 },{ 120, 8256 },{ 120, 8258 },{ 120, 8260 },
-{ 120, 8262 },{ 120, 8264 },{ 120, 8266 },{ 120, 8269 },
-{ 120, 8271 },{ 120, 8273 },{ 120, 8275 },{ 120, 8277 },
-{ 120, 8279 },{ 120, 8281 },{ 120, 8283 },{ 120, 8285 },
-{ 120, 8287 },{ 120, 8289 },{ 120, 8291 },{ 120, 8294 },
-{ 120, 8296 },{ 120, 8298 },{ 120, 8300 },{ 120, 8302 },
-{ 120, 8304 },{ 120, 8306 },{ 120, 8308 },{ 120, 8310 },
-{ 120, 8312 },{ 120, 8314 },{ 120, 8316 },{ 120, 8318 },
-{ 120, 8321 },{ 120, 8323 },{ 120, 8325 },{ 120, 8327 },
-{ 120, 8329 },{ 120, 8331 },{ 120, 8333 },{ 120, 8335 },
-{ 120, 8337 },{ 120, 8339 },{ 120, 8341 },{ 120, 8343 },
-{ 120, 8345 },{ 120, 8347 },{ 120, 8349 },{ 120, 8352 },
-{ 120, 8354 },{ 120, 8356 },{ 120, 8358 },{ 120, 8360 },
-{ 120, 8362 },{ 121, 8023 },{ 121, 8025 },{ 121, 8027 },
-{ 121, 8029 },{ 121, 8031 },{ 121, 8033 },{ 121, 8035 },
-{ 121, 8037 },{ 121, 8039 },{ 121, 8041 },{ 121, 8043 },
-{ 121, 8045 },{ 121, 8047 },{ 121, 8049 },{ 121, 8051 },
-{ 121, 8053 },{ 121, 8055 },{ 121, 8057 },{ 121, 8059 },
-{ 121, 8062 },{ 121, 8064 },{ 121, 8066 },{ 121, 8068 },
-{ 121, 8070 },{ 121, 8072 },{ 121, 8074 },{ 121, 8076 },
-{ 121, 8078 },{ 121, 8080 },{ 121, 8082 },{ 121, 8084 },
-{ 121, 8086 },{ 121, 8088 },{ 121, 8090 },{ 121, 8092 },
-{ 121, 8094 },{ 121, 8096 },{ 121, 8098 },{ 121, 8100 },
-{ 121, 8102 },{ 121, 8104 },{ 121, 8106 },{ 121, 8108 },
-{ 121, 8110 },{ 121, 8112 },{ 121, 8114 },{ 121, 8116 },
-{ 121, 8118 },{ 121, 8120 },{ 121, 8122 },{ 121, 8125 },
-{ 121, 8127 },{ 121, 8129 },{ 121, 8131 },{ 121, 8133 },
-{ 121, 8135 },{ 121, 8137 },{ 121, 8139 },{ 121, 8141 },
-{ 121, 8143 },{ 121, 8145 },{ 121, 8147 },{ 121, 8149 },
-{ 121, 8151 },{ 121, 8153 },{ 121, 8155 },{ 121, 8157 },
-{ 121, 8159 },{ 121, 8161 },{ 121, 8163 },{ 121, 8165 },
-{ 121, 8167 },{ 121, 8169 },{ 121, 8171 },{ 121, 8173 },
-{ 121, 8175 },{ 121, 8177 },{ 121, 8179 },{ 121, 8181 },
-{ 121, 8183 },{ 121, 8185 },{ 121, 8187 },{ 121, 8189 },
-{ 121, 8191 },{ 121, 8193 },{ 121, 8195 },{ 121, 8197 },
-{ 121, 8199 },{ 121, 8201 },{ 121, 8203 },{ 121, 8205 },
-{ 121, 8207 },{ 121, 8209 },{ 121, 8211 },{ 121, 8213 },
-{ 121, 8215 },{ 121, 8217 },{ 121, 8219 },{ 121, 8221 },
-{ 121, 8223 },{ 121, 8225 },{ 121, 8227 },{ 121, 8229 },
-{ 121, 8231 },{ 121, 8233 },{ 121, 8235 },{ 121, 8237 },
-{ 121, 8239 },{ 121, 8241 },{ 121, 8243 },{ 121, 8245 },
-{ 121, 8247 },{ 121, 8249 },{ 121, 8251 },{ 121, 8252 },
-{ 121, 8254 },{ 121, 8256 },{ 121, 8258 },{ 121, 8260 },
-{ 121, 8262 },{ 121, 8264 },{ 121, 8266 },{ 121, 8268 },
-{ 121, 8270 },{ 121, 8272 },{ 121, 8274 },{ 121, 8276 },
-{ 121, 8278 },{ 121, 8280 },{ 121, 8282 },{ 121, 8284 },
-{ 121, 8286 },{ 121, 8288 },{ 121, 8290 },{ 121, 8292 },
-{ 121, 8294 },{ 121, 8296 },{ 121, 8298 },{ 121, 8300 },
-{ 121, 8302 },{ 121, 8304 },{ 121, 8306 },{ 121, 8308 },
-{ 121, 8310 },{ 121, 8312 },{ 121, 8313 },{ 121, 8315 },
-{ 121, 8317 },{ 121, 8319 },{ 121, 8321 },{ 121, 8323 },
-{ 121, 8325 },{ 121, 8327 },{ 121, 8329 },{ 121, 8331 },
-{ 121, 8333 },{ 121, 8335 },{ 121, 8337 },{ 121, 8339 },
-{ 121, 8341 },{ 121, 8343 },{ 121, 8345 },{ 121, 8347 },
-{ 121, 8349 },{ 121, 8351 },{ 121, 8353 },{ 121, 8354 },
-{ 121, 8356 },{ 121, 8358 },{ 121, 8360 },{ 122, 8021 },
-{ 122, 8023 },{ 122, 8025 },{ 122, 8027 },{ 122, 8029 },
-{ 122, 8031 },{ 122, 8033 },{ 122, 8034 },{ 122, 8036 },
-{ 122, 8038 },{ 122, 8040 },{ 122, 8042 },{ 122, 8044 },
-{ 122, 8046 },{ 122, 8048 },{ 122, 8050 },{ 122, 8052 },
-{ 122, 8054 },{ 122, 8056 },{ 122, 8058 },{ 122, 8060 },
-{ 122, 8062 },{ 122, 8063 },{ 122, 8065 },{ 122, 8067 },
-{ 122, 8069 },{ 122, 8071 },{ 122, 8073 },{ 122, 8075 },
-{ 122, 8077 },{ 122, 8079 },{ 122, 8081 },{ 122, 8083 },
-{ 122, 8085 },{ 122, 8087 },{ 122, 8088 },{ 122, 8090 },
-{ 122, 8092 },{ 122, 8094 },{ 122, 8096 },{ 122, 8098 },
-{ 122, 8100 },{ 122, 8102 },{ 122, 8104 },{ 122, 8106 },
-{ 122, 8108 },{ 122, 8110 },{ 122, 8111 },{ 122, 8113 },
-{ 122, 8115 },{ 122, 8117 },{ 122, 8119 },{ 122, 8121 },
-{ 122, 8123 },{ 122, 8125 },{ 122, 8127 },{ 122, 8129 },
-{ 122, 8131 },{ 122, 8132 },{ 122, 8134 },{ 122, 8136 },
-{ 122, 8138 },{ 122, 8140 },{ 122, 8142 },{ 122, 8144 },
-{ 122, 8146 },{ 122, 8148 },{ 122, 8150 },{ 122, 8151 },
-{ 122, 8153 },{ 122, 8155 },{ 122, 8157 },{ 122, 8159 },
-{ 122, 8161 },{ 122, 8163 },{ 122, 8165 },{ 122, 8167 },
-{ 122, 8169 },{ 122, 8170 },{ 122, 8172 },{ 122, 8174 },
-{ 122, 8176 },{ 122, 8178 },{ 122, 8180 },{ 122, 8182 },
-{ 122, 8184 },{ 122, 8186 },{ 122, 8187 },{ 122, 8189 },
-{ 122, 8191 },{ 122, 8193 },{ 122, 8195 },{ 122, 8197 },
-{ 122, 8199 },{ 122, 8201 },{ 122, 8203 },{ 122, 8204 },
-{ 122, 8206 },{ 122, 8208 },{ 122, 8210 },{ 122, 8212 },
-{ 122, 8214 },{ 122, 8216 },{ 122, 8218 },{ 122, 8219 },
-{ 122, 8221 },{ 122, 8223 },{ 122, 8225 },{ 122, 8227 },
-{ 122, 8229 },{ 122, 8231 },{ 122, 8233 },{ 122, 8234 },
-{ 122, 8236 },{ 122, 8238 },{ 122, 8240 },{ 122, 8242 },
-{ 122, 8244 },{ 122, 8246 },{ 122, 8248 },{ 122, 8249 },
-{ 122, 8251 },{ 122, 8253 },{ 122, 8255 },{ 122, 8257 },
-{ 122, 8259 },{ 122, 8261 },{ 122, 8262 },{ 122, 8264 },
-{ 122, 8266 },{ 122, 8268 },{ 122, 8270 },{ 122, 8272 },
-{ 122, 8274 },{ 122, 8276 },{ 122, 8277 },{ 122, 8279 },
-{ 122, 8281 },{ 122, 8283 },{ 122, 8285 },{ 122, 8287 },
-{ 122, 8289 },{ 122, 8290 },{ 122, 8292 },{ 122, 8294 },
-{ 122, 8296 },{ 122, 8298 },{ 122, 8300 },{ 122, 8301 },
-{ 122, 8303 },{ 122, 8305 },{ 122, 8307 },{ 122, 8309 },
-{ 122, 8311 },{ 122, 8313 },{ 122, 8314 },{ 122, 8316 },
-{ 122, 8318 },{ 122, 8320 },{ 122, 8322 },{ 122, 8324 },
-{ 122, 8326 },{ 122, 8327 },{ 122, 8329 },{ 122, 8331 },
-{ 122, 8333 },{ 122, 8335 },{ 122, 8337 },{ 122, 8338 },
-{ 122, 8340 },{ 122, 8342 },{ 122, 8344 },{ 122, 8346 },
-{ 122, 8348 },{ 122, 8349 },{ 122, 8351 },{ 122, 8353 },
-{ 122, 8355 },{ 122, 8357 },{ 122, 8359 },{ 122, 8360 },
-{ 123, 8021 },{ 123, 8023 },{ 123, 8025 },{ 123, 8026 },
-{ 123, 8028 },{ 123, 8030 },{ 123, 8032 },{ 123, 8034 },
-{ 123, 8036 },{ 123, 8037 },{ 123, 8039 },{ 123, 8041 },
-{ 123, 8043 },{ 123, 8045 },{ 123, 8047 },{ 123, 8048 },
-{ 123, 8050 },{ 123, 8052 },{ 123, 8054 },{ 123, 8056 },
-{ 123, 8057 },{ 123, 8059 },{ 123, 8061 },{ 123, 8063 },
-{ 123, 8065 },{ 123, 8067 },{ 123, 8068 },{ 123, 8070 },
-{ 123, 8072 },{ 123, 8074 },{ 123, 8076 },{ 123, 8077 },
-{ 123, 8079 },{ 123, 8081 },{ 123, 8083 },{ 123, 8085 },
-{ 123, 8087 },{ 123, 8088 },{ 123, 8090 },{ 123, 8092 },
-{ 123, 8094 },{ 123, 8096 },{ 123, 8097 },{ 123, 8099 },
-{ 123, 8101 },{ 123, 8103 },{ 123, 8105 },{ 123, 8106 },
-{ 123, 8108 },{ 123, 8110 },{ 123, 8112 },{ 123, 8114 },
-{ 123, 8115 },{ 123, 8117 },{ 123, 8119 },{ 123, 8121 },
-{ 123, 8123 },{ 123, 8125 },{ 123, 8126 },{ 123, 8128 },
-{ 123, 8130 },{ 123, 8132 },{ 123, 8134 },{ 123, 8135 },
-{ 123, 8137 },{ 123, 8139 },{ 123, 8141 },{ 123, 8142 },
-{ 123, 8144 },{ 123, 8146 },{ 123, 8148 },{ 123, 8150 },
-{ 123, 8151 },{ 123, 8153 },{ 123, 8155 },{ 123, 8157 },
-{ 123, 8159 },{ 123, 8160 },{ 123, 8162 },{ 123, 8164 },
-{ 123, 8166 },{ 123, 8168 },{ 123, 8169 },{ 123, 8171 },
-{ 123, 8173 },{ 123, 8175 },{ 123, 8177 },{ 123, 8178 },
-{ 123, 8180 },{ 123, 8182 },{ 123, 8184 },{ 123, 8185 },
-{ 123, 8187 },{ 123, 8189 },{ 123, 8191 },{ 123, 8193 },
-{ 123, 8194 },{ 123, 8196 },{ 123, 8198 },{ 123, 8200 },
-{ 123, 8201 },{ 123, 8203 },{ 123, 8205 },{ 123, 8207 },
-{ 123, 8209 },{ 123, 8210 },{ 123, 8212 },{ 123, 8214 },
-{ 123, 8216 },{ 123, 8217 },{ 123, 8219 },{ 123, 8221 },
-{ 123, 8223 },{ 123, 8225 },{ 123, 8226 },{ 123, 8228 },
-{ 123, 8230 },{ 123, 8232 },{ 123, 8233 },{ 123, 8235 },
-{ 123, 8237 },{ 123, 8239 },{ 123, 8240 },{ 123, 8242 },
-{ 123, 8244 },{ 123, 8246 },{ 123, 8247 },{ 123, 8249 },
-{ 123, 8251 },{ 123, 8253 },{ 123, 8255 },{ 123, 8256 },
-{ 123, 8258 },{ 123, 8260 },{ 123, 8262 },{ 123, 8263 },
-{ 123, 8265 },{ 123, 8267 },{ 123, 8269 },{ 123, 8270 },
-{ 123, 8272 },{ 123, 8274 },{ 123, 8276 },{ 123, 8277 },
-{ 123, 8279 },{ 123, 8281 },{ 123, 8283 },{ 123, 8284 },
-{ 123, 8286 },{ 123, 8288 },{ 123, 8290 },{ 123, 8291 },
-{ 123, 8293 },{ 123, 8295 },{ 123, 8297 },{ 123, 8298 },
-{ 123, 8300 },{ 123, 8302 },{ 123, 8304 },{ 123, 8305 },
-{ 123, 8307 },{ 123, 8309 },{ 123, 8311 },{ 123, 8312 },
-{ 123, 8314 },{ 123, 8316 },{ 123, 8318 },{ 123, 8319 },
-{ 123, 8321 },{ 123, 8323 },{ 123, 8325 },{ 123, 8326 },
-{ 123, 8328 },{ 123, 8330 },{ 123, 8332 },{ 123, 8333 },
-{ 123, 8335 },{ 123, 8337 },{ 123, 8338 },{ 123, 8340 },
-{ 123, 8342 },{ 123, 8344 },{ 123, 8345 },{ 123, 8347 },
-{ 123, 8349 },{ 123, 8351 },{ 123, 8352 },{ 123, 8354 },
-{ 123, 8356 },{ 123, 8358 },{ 123, 8359 },{ 123, 8361 },
-{ 124, 8021 },{ 124, 8023 },{ 124, 8025 },{ 124, 8027 },
-{ 124, 8028 },{ 124, 8030 },{ 124, 8032 },{ 124, 8034 },
-{ 124, 8035 },{ 124, 8037 },{ 124, 8039 },{ 124, 8040 },
-{ 124, 8042 },{ 124, 8044 },{ 124, 8046 },{ 124, 8047 },
-{ 124, 8049 },{ 124, 8051 },{ 124, 8052 },{ 124, 8054 },
-{ 124, 8056 },{ 124, 8058 },{ 124, 8059 },{ 124, 8061 },
-{ 124, 8063 },{ 124, 8065 },{ 124, 8066 },{ 124, 8068 },
-{ 124, 8070 },{ 124, 8071 },{ 124, 8073 },{ 124, 8075 },
-{ 124, 8077 },{ 124, 8078 },{ 124, 8080 },{ 124, 8082 },
-{ 124, 8083 },{ 124, 8085 },{ 124, 8087 },{ 124, 8089 },
-{ 124, 8090 },{ 124, 8092 },{ 124, 8094 },{ 124, 8095 },
-{ 124, 8097 },{ 124, 8099 },{ 124, 8100 },{ 124, 8102 },
-{ 124, 8104 },{ 124, 8106 },{ 124, 8107 },{ 124, 8109 },
-{ 124, 8111 },{ 124, 8112 },{ 124, 8114 },{ 124, 8116 },
-{ 124, 8118 },{ 124, 8119 },{ 124, 8121 },{ 124, 8123 },
-{ 124, 8124 },{ 124, 8126 },{ 124, 8128 },{ 124, 8129 },
-{ 124, 8131 },{ 124, 8133 },{ 124, 8134 },{ 124, 8136 },
-{ 124, 8138 },{ 124, 8140 },{ 124, 8141 },{ 124, 8143 },
-{ 124, 8145 },{ 124, 8146 },{ 124, 8148 },{ 124, 8150 },
-{ 124, 8151 },{ 124, 8153 },{ 124, 8155 },{ 124, 8157 },
-{ 124, 8158 },{ 124, 8160 },{ 124, 8162 },{ 124, 8163 },
-{ 124, 8165 },{ 124, 8167 },{ 124, 8168 },{ 124, 8170 },
-{ 124, 8172 },{ 124, 8173 },{ 124, 8175 },{ 124, 8177 },
-{ 124, 8178 },{ 124, 8180 },{ 124, 8182 },{ 124, 8184 },
-{ 124, 8185 },{ 124, 8187 },{ 124, 8189 },{ 124, 8190 },
-{ 124, 8192 },{ 124, 8194 },{ 124, 8195 },{ 124, 8197 },
-{ 124, 8199 },{ 124, 8200 },{ 124, 8202 },{ 124, 8204 },
-{ 124, 8205 },{ 124, 8207 },{ 124, 8209 },{ 124, 8210 },
-{ 124, 8212 },{ 124, 8214 },{ 124, 8215 },{ 124, 8217 },
-{ 124, 8219 },{ 124, 8220 },{ 124, 8222 },{ 124, 8224 },
-{ 124, 8225 },{ 124, 8227 },{ 124, 8229 },{ 124, 8230 },
-{ 124, 8232 },{ 124, 8234 },{ 124, 8235 },{ 124, 8237 },
-{ 124, 8239 },{ 124, 8240 },{ 124, 8242 },{ 124, 8244 },
-{ 124, 8245 },{ 124, 8247 },{ 124, 8249 },{ 124, 8250 },
-{ 124, 8252 },{ 124, 8254 },{ 124, 8255 },{ 124, 8257 },
-{ 124, 8259 },{ 124, 8260 },{ 124, 8262 },{ 124, 8264 },
-{ 124, 8265 },{ 124, 8267 },{ 124, 8269 },{ 124, 8270 },
-{ 124, 8272 },{ 124, 8274 },{ 124, 8275 },{ 124, 8277 },
-{ 124, 8279 },{ 124, 8280 },{ 124, 8282 },{ 124, 8284 },
-{ 124, 8285 },{ 124, 8287 },{ 124, 8289 },{ 124, 8290 },
-{ 124, 8292 },{ 124, 8294 },{ 124, 8295 },{ 124, 8297 },
-{ 124, 8299 },{ 124, 8300 },{ 124, 8302 },{ 124, 8303 },
-{ 124, 8305 },{ 124, 8307 },{ 124, 8308 },{ 124, 8310 },
-{ 124, 8312 },{ 124, 8313 },{ 124, 8315 },{ 124, 8317 },
-{ 124, 8318 },{ 124, 8320 },{ 124, 8322 },{ 124, 8323 },
-{ 124, 8325 },{ 124, 8326 },{ 124, 8328 },{ 124, 8330 },
-{ 124, 8331 },{ 124, 8333 },{ 124, 8335 },{ 124, 8336 },
-{ 124, 8338 },{ 124, 8340 },{ 124, 8341 },{ 124, 8343 },
-{ 124, 8345 },{ 124, 8346 },{ 124, 8348 },{ 124, 8349 },
-{ 124, 8351 },{ 124, 8353 },{ 124, 8354 },{ 124, 8356 },
-{ 124, 8358 },{ 124, 8359 },{ 124, 8361 },{ 125, 8021 },
-{ 125, 8023 },{ 125, 8024 },{ 125, 8026 },{ 125, 8028 },
-{ 125, 8029 },{ 125, 8031 },{ 125, 8033 },{ 125, 8034 },
-{ 125, 8036 },{ 125, 8037 },{ 125, 8039 },{ 125, 8041 },
-{ 125, 8042 },{ 125, 8044 },{ 125, 8046 },{ 125, 8047 },
-{ 125, 8049 },{ 125, 8051 },{ 125, 8052 },{ 125, 8054 },
-{ 125, 8055 },{ 125, 8057 },{ 125, 8059 },{ 125, 8060 },
-{ 125, 8062 },{ 125, 8063 },{ 125, 8065 },{ 125, 8067 },
-{ 125, 8068 },{ 125, 8070 },{ 125, 8072 },{ 125, 8073 },
-{ 125, 8075 },{ 125, 8076 },{ 125, 8078 },{ 125, 8080 },
-{ 125, 8081 },{ 125, 8083 },{ 125, 8085 },{ 125, 8086 },
-{ 125, 8088 },{ 125, 8089 },{ 125, 8091 },{ 125, 8093 },
-{ 125, 8094 },{ 125, 8096 },{ 125, 8097 },{ 125, 8099 },
-{ 125, 8101 },{ 125, 8102 },{ 125, 8104 },{ 125, 8105 },
-{ 125, 8107 },{ 125, 8109 },{ 125, 8110 },{ 125, 8112 },
-{ 125, 8114 },{ 125, 8115 },{ 125, 8117 },{ 125, 8118 },
-{ 125, 8120 },{ 125, 8122 },{ 125, 8123 },{ 125, 8125 },
-{ 125, 8126 },{ 125, 8128 },{ 125, 8130 },{ 125, 8131 },
-{ 125, 8133 },{ 125, 8134 },{ 125, 8136 },{ 125, 8138 },
-{ 125, 8139 },{ 125, 8141 },{ 125, 8142 },{ 125, 8144 },
-{ 125, 8146 },{ 125, 8147 },{ 125, 8149 },{ 125, 8150 },
-{ 125, 8152 },{ 125, 8154 },{ 125, 8155 },{ 125, 8157 },
-{ 125, 8158 },{ 125, 8160 },{ 125, 8162 },{ 125, 8163 },
-{ 125, 8165 },{ 125, 8166 },{ 125, 8168 },{ 125, 8170 },
-{ 125, 8171 },{ 125, 8173 },{ 125, 8174 },{ 125, 8176 },
-{ 125, 8177 },{ 125, 8179 },{ 125, 8181 },{ 125, 8182 },
-{ 125, 8184 },{ 125, 8185 },{ 125, 8187 },{ 125, 8189 },
-{ 125, 8190 },{ 125, 8192 },{ 125, 8193 },{ 125, 8195 },
-{ 125, 8197 },{ 125, 8198 },{ 125, 8200 },{ 125, 8201 },
-{ 125, 8203 },{ 125, 8204 },{ 125, 8206 },{ 125, 8208 },
-{ 125, 8209 },{ 125, 8211 },{ 125, 8212 },{ 125, 8214 },
-{ 125, 8216 },{ 125, 8217 },{ 125, 8219 },{ 125, 8220 },
-{ 125, 8222 },{ 125, 8223 },{ 125, 8225 },{ 125, 8227 },
-{ 125, 8228 },{ 125, 8230 },{ 125, 8231 },{ 125, 8233 },
-{ 125, 8234 },{ 125, 8236 },{ 125, 8238 },{ 125, 8239 },
-{ 125, 8241 },{ 125, 8242 },{ 125, 8244 },{ 125, 8245 },
-{ 125, 8247 },{ 125, 8249 },{ 125, 8250 },{ 125, 8252 },
-{ 125, 8253 },{ 125, 8255 },{ 125, 8256 },{ 125, 8258 },
-{ 125, 8260 },{ 125, 8261 },{ 125, 8263 },{ 125, 8264 },
-{ 125, 8266 },{ 125, 8267 },{ 125, 8269 },{ 125, 8271 },
-{ 125, 8272 },{ 125, 8274 },{ 125, 8275 },{ 125, 8277 },
-{ 125, 8278 },{ 125, 8280 },{ 125, 8281 },{ 125, 8283 },
-{ 125, 8285 },{ 125, 8286 },{ 125, 8288 },{ 125, 8289 },
-{ 125, 8291 },{ 125, 8292 },{ 125, 8294 },{ 125, 8296 },
-{ 125, 8297 },{ 125, 8299 },{ 125, 8300 },{ 125, 8302 },
-{ 125, 8303 },{ 125, 8305 },{ 125, 8306 },{ 125, 8308 },
-{ 125, 8310 },{ 125, 8311 },{ 125, 8313 },{ 125, 8314 },
-{ 125, 8316 },{ 125, 8317 },{ 125, 8319 },{ 125, 8320 },
-{ 125, 8322 },{ 125, 8324 },{ 125, 8325 },{ 125, 8327 },
-{ 125, 8328 },{ 125, 8330 },{ 125, 8331 },{ 125, 8333 },
-{ 125, 8334 },{ 125, 8336 },{ 125, 8337 },{ 125, 8339 },
-{ 125, 8341 },{ 125, 8342 },{ 125, 8344 },{ 125, 8345 },
-{ 125, 8347 },{ 125, 8348 },{ 125, 8350 },{ 125, 8351 },
-{ 125, 8353 },{ 125, 8354 },{ 125, 8356 },{ 125, 8358 },
-{ 125, 8359 },{ 125, 8361 },{ 126, 8021 },{ 126, 8022 },
-{ 126, 8024 },{ 126, 8025 },{ 126, 8027 },{ 126, 8029 },
-{ 126, 8030 },{ 126, 8032 },{ 126, 8033 },{ 126, 8035 },
-{ 126, 8036 },{ 126, 8038 },{ 126, 8039 },{ 126, 8041 },
-{ 126, 8042 },{ 126, 8044 },{ 126, 8045 },{ 126, 8047 },
-{ 126, 8049 },{ 126, 8050 },{ 126, 8052 },{ 126, 8053 },
-{ 126, 8055 },{ 126, 8056 },{ 126, 8058 },{ 126, 8059 },
-{ 126, 8061 },{ 126, 8062 },{ 126, 8064 },{ 126, 8065 },
-{ 126, 8067 },{ 126, 8068 },{ 126, 8070 },{ 126, 8071 },
-{ 126, 8073 },{ 126, 8075 },{ 126, 8076 },{ 126, 8078 },
-{ 126, 8079 },{ 126, 8081 },{ 126, 8082 },{ 126, 8084 },
-{ 126, 8085 },{ 126, 8087 },{ 126, 8088 },{ 126, 8090 },
-{ 126, 8091 },{ 126, 8093 },{ 126, 8094 },{ 126, 8096 },
-{ 126, 8097 },{ 126, 8099 },{ 126, 8100 },{ 126, 8102 },
-{ 126, 8103 },{ 126, 8105 },{ 126, 8107 },{ 126, 8108 },
-{ 126, 8110 },{ 126, 8111 },{ 126, 8113 },{ 126, 8114 },
-{ 126, 8116 },{ 126, 8117 },{ 126, 8119 },{ 126, 8120 },
-{ 126, 8122 },{ 126, 8123 },{ 126, 8125 },{ 126, 8126 },
-{ 126, 8128 },{ 126, 8129 },{ 126, 8131 },{ 126, 8132 },
-{ 126, 8134 },{ 126, 8135 },{ 126, 8137 },{ 126, 8138 },
-{ 126, 8140 },{ 126, 8141 },{ 126, 8143 },{ 126, 8144 },
-{ 126, 8146 },{ 126, 8147 },{ 126, 8149 },{ 126, 8150 },
-{ 126, 8152 },{ 126, 8153 },{ 126, 8155 },{ 126, 8156 },
-{ 126, 8158 },{ 126, 8159 },{ 126, 8161 },{ 126, 8162 },
-{ 126, 8164 },{ 126, 8165 },{ 126, 8167 },{ 126, 8168 },
-{ 126, 8170 },{ 126, 8171 },{ 126, 8173 },{ 126, 8174 },
-{ 126, 8176 },{ 126, 8177 },{ 126, 8179 },{ 126, 8180 },
-{ 126, 8182 },{ 126, 8183 },{ 126, 8185 },{ 126, 8186 },
-{ 126, 8188 },{ 126, 8189 },{ 126, 8191 },{ 126, 8192 },
-{ 126, 8194 },{ 126, 8195 },{ 126, 8197 },{ 126, 8198 },
-{ 126, 8200 },{ 126, 8201 },{ 126, 8203 },{ 126, 8204 },
-{ 126, 8206 },{ 126, 8207 },{ 126, 8209 },{ 126, 8210 },
-{ 126, 8212 },{ 126, 8213 },{ 126, 8215 },{ 126, 8216 },
-{ 126, 8218 },{ 126, 8219 },{ 126, 8221 },{ 126, 8222 },
-{ 126, 8224 },{ 126, 8225 },{ 126, 8227 },{ 126, 8228 },
-{ 126, 8230 },{ 126, 8231 },{ 126, 8233 },{ 126, 8234 },
-{ 126, 8236 },{ 126, 8237 },{ 126, 8239 },{ 126, 8240 },
-{ 126, 8242 },{ 126, 8243 },{ 126, 8245 },{ 126, 8246 },
-{ 126, 8248 },{ 126, 8249 },{ 126, 8251 },{ 126, 8252 },
-{ 126, 8254 },{ 126, 8255 },{ 126, 8257 },{ 126, 8258 },
-{ 126, 8259 },{ 126, 8261 },{ 126, 8262 },{ 126, 8264 },
-{ 126, 8265 },{ 126, 8267 },{ 126, 8268 },{ 126, 8270 },
-{ 126, 8271 },{ 126, 8273 },{ 126, 8274 },{ 126, 8276 },
-{ 126, 8277 },{ 126, 8279 },{ 126, 8280 },{ 126, 8282 },
-{ 126, 8283 },{ 126, 8285 },{ 126, 8286 },{ 126, 8288 },
-{ 126, 8289 },{ 126, 8290 },{ 126, 8292 },{ 126, 8293 },
-{ 126, 8295 },{ 126, 8296 },{ 126, 8298 },{ 126, 8299 },
-{ 126, 8301 },{ 126, 8302 },{ 126, 8304 },{ 126, 8305 },
-{ 126, 8307 },{ 126, 8308 },{ 126, 8310 },{ 126, 8311 },
-{ 126, 8313 },{ 126, 8314 },{ 126, 8315 },{ 126, 8317 },
-{ 126, 8318 },{ 126, 8320 },{ 126, 8321 },{ 126, 8323 },
-{ 126, 8324 },{ 126, 8326 },{ 126, 8327 },{ 126, 8329 },
-{ 126, 8330 },{ 126, 8332 },{ 126, 8333 },{ 126, 8334 },
-{ 126, 8336 },{ 126, 8337 },{ 126, 8339 },{ 126, 8340 },
-{ 126, 8342 },{ 126, 8343 },{ 126, 8345 },{ 126, 8346 },
-{ 126, 8348 },{ 126, 8349 },{ 126, 8351 },{ 126, 8352 },
-{ 126, 8353 },{ 126, 8355 },{ 126, 8356 },{ 126, 8358 },
-{ 126, 8359 },{ 126, 8361 },{ 127, 8021 },{ 127, 8022 },
-{ 127, 8024 },{ 127, 8025 },{ 127, 8027 },{ 127, 8028 },
-{ 127, 8030 },{ 127, 8031 },{ 127, 8032 },{ 127, 8034 },
-{ 127, 8035 },{ 127, 8037 },{ 127, 8038 },{ 127, 8040 },
-{ 127, 8041 },{ 127, 8043 },{ 127, 8044 },{ 127, 8046 },
-{ 127, 8047 },{ 127, 8048 },{ 127, 8050 },{ 127, 8051 },
-{ 127, 8053 },{ 127, 8054 },{ 127, 8056 },{ 127, 8057 },
-{ 127, 8059 },{ 127, 8060 },{ 127, 8061 },{ 127, 8063 },
-{ 127, 8064 },{ 127, 8066 },{ 127, 8067 },{ 127, 8069 }

+ 8 - 8
src/include/NESCarts.h

@@ -2,7 +2,7 @@
  *  Cart manager - The peTI-NESulator Project
  *  NESCart.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  */
 
@@ -18,18 +18,18 @@
 #define iNES_4SCREEN 0x08
 
 typedef struct NesCart_
-{  
+{
     uint32_t PROMSize,  /* Size of PROM */
-             VROMSize;  /* Size of VROM */
-    char     MapperID;  /* Mapper Type */
-    uint8_t  Flags;
-    char    *FileName;
+            VROMSize;  /* Size of VROM */
+    char MapperID;  /* Mapper Type */
+    uint8_t Flags;
+    char *FileName;
     uint8_t *File;      /* Pointer on the file in memory */
     uint8_t *PROMBanks; /* Pointer on the first PROM */
     uint8_t *VROMBanks; /* Pointer on the first VROM */
 } NesCart;
 
-void DumpCartProperties(FILE *out, NesCart * cart);
-int LoadCart(const char *filename, NesCart * cart);
+void DumpCartProperties(FILE *out, NesCart *cart);
+int LoadCart(const char *filename, NesCart *cart);
 
 #endif

+ 0 - 232
src/include/Sound.h

@@ -1,232 +0,0 @@
-/** EMULib Emulation Library *********************************/
-/**                                                         **/
-/**                          Sound.h                        **/
-/**                                                         **/
-/** This file defines standard sound generation API and     **/
-/** functions needed to log soundtrack into a MIDI file.    **/
-/** See Sound.c and the sound drivers for the code.         **/ 
-/**                                                         **/
-/** Copyright (C) Marat Fayzullin 1996-2007                 **/
-/**     You are not allowed to distribute this software     **/
-/**     commercially. Please, notify me, if you make any    **/
-/**     changes to this file.                               **/
-/*************************************************************/
-/*/
-
-#ifndef SOUND_H
-#define SOUND_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-                               /* SetSound() arguments:      */
-#define SND_MELODIC     0      /* Melodic sound (default)    */
-#define SND_RECTANGLE   0      /* Rectangular wave           */
-#define SND_QS_DU0        5
-#define SND_QS_DU1        6
-#define SND_QS_DU2        7
-#define SND_QS_DU3        8
-#define SND_TRIANGLE    1      /* Triangular wave (1/2 rect.)*/
-#define SND_NOISE       2      /* White noise                */
-#define SND_PERIODIC    3      /* Periodic noise (not im-ed) */
-#define SND_WAVE        4      /* Wave sound set by SetWave()*/
-#define SND_MIDI        0x100  /* MIDI instrument (ORable)   */
-
-                               /* Drum() arguments:          */
-#define DRM_CLICK       0      /* Click (default)            */
-#define DRM_MIDI        0x100  /* MIDI drum (ORable)         */
-
-                               /* MIDI characteristics:      */
-#define MIDI_CHANNELS   16     /* Number of MIDI channels    */
-#define MIDI_MINFREQ    9      /* Min MIDI frequency (Hz)    */
-#define MIDI_MAXFREQ    12285  /* Max MIDI frequency (Hz)    */
-#define MIDI_DIVISIONS  1000   /* Number of ticks per second */
-
-                               /* MIDILogging() arguments:   */
-#define MIDI_OFF        0      /* Turn MIDI logging off      */
-#define MIDI_ON         1      /* Turn MIDI logging on       */
-#define MIDI_TOGGLE     2      /* Toggle MIDI logging        */
-#define MIDI_QUERY      3      /* Query MIDI logging status  */
-
-/** TrashSound() *********************************************/
-/** Shut down sound driver. Each driver implements its own  **/
-/** TrashSound() function.                                  **/
-/*************************************************************/
-void TrashSound(void);
-
-/** Sound() **************************************************/
-/** Generate sound of given frequency (Hz) and volume       **/
-/** (0..255) via given channel. Setting Freq=0 or Volume=0  **/
-/** turns sound off.                                        **/
-/*************************************************************/
-void Sound(int Channel,int Freq,int Volume);
-
-/** Drum() ***************************************************/
-/** Hit a drum of given type with given force (0..255).     **/
-/** MIDI drums can be used by ORing their numbers with      **/
-/** SND_MIDI.                                               **/
-/*************************************************************/
-void Drum(int Type,int Force);
-
-/** SetSound() ***********************************************/
-/** Set sound type at a given channel. MIDI instruments can **/
-/** be set directly by ORing their numbers with SND_MIDI.   **/
-/*************************************************************/
-void SetSound(int Channel,int NewType);
-
-/** SetChannels() ********************************************/
-/** Set master volume (0..255) and switch channels on/off.  **/
-/** Each channel N has corresponding bit 2^N in Switch. Set **/
-/** or reset this bit to turn the channel on or off.        **/ 
-/*************************************************************/
-void SetChannels(int Volume,int Switch);
-
-/** SetWave() ************************************************/
-/** Set waveform for a given channel. The channel will be   **/
-/** marked with sound type SND_WAVE. Set Rate=0 if you want **/
-/** waveform to be an instrument or set it to the waveform  **/
-/** own playback rate.                                      **/
-/*************************************************************/
-void SetWave(int Channel,signed char *Data,int Length,int Rate);
-
-/** GetWave() ************************************************/
-/** Get current read position for the buffer set with the   **/
-/** SetWave() call. Returns 0 if no buffer has been set, or **/
-/** if there is no playrate set (i.e. wave is instrument).  **/
-/*************************************************************/
-const signed char *GetWave(int Channel);
-
-/** InitMIDI() ***********************************************/
-/** Initialize soundtrack logging into MIDI file FileName.  **/
-/** Repeated calls to InitMIDI() will close current MIDI    **/
-/** file and continue logging into a new one.               **/ 
-/*************************************************************/
-void InitMIDI(const char *FileName);
-
-/** TrashMIDI() **********************************************/
-/** Finish logging soundtrack and close the MIDI file.      **/
-/*************************************************************/
-void TrashMIDI(void);
-
-/** MIDILogging() ********************************************/
-/** Turn soundtrack logging on/off and return its current   **/
-/** status. Possible values of Switch are MIDI_OFF (turn    **/
-/** logging off), MIDI_ON (turn logging on), MIDI_TOGGLE    **/
-/** (toggle logging), and MIDI_QUERY (just return current   **/
-/** state of logging).                                      **/
-/*************************************************************/
-int MIDILogging(int Switch);
-
-/** MIDITicks() **********************************************/
-/** Log N 1ms MIDI ticks.                                   **/
-/*************************************************************/
-void MIDITicks(int N);
-
-//#ifdef UNIX
-#define SND_CHANNELS    4   /* Number of channels           */
-#define SND_SAMPLESIZE  256  /* Max. SetWave() sample size   */
-#define SND_BUFSIZE     256  /* Buffer size, <= 2^SND_BITS   */
-#define SND_BITS        8    /* Number of bits in a fragment */
-#define SND_BUFFERS     64   /* Number of fragments, >= 2    */
-    /* Bigger value results in better behaviour on loaded    */
-    /* but output gets more delayed.                         */
-
-/** InitSound() **********************************************/
-/** Initialize Unix sound driver with given synthesis rate. **/
-/** Returns Rate on success, 0 otherwise. Pass Rate=0 to    **/
-/** skip initialization and be silent. Pass Verbose!=0 to   **/
-/** see initialization messages.                            **/
-/*************************************************************/
-int InitSound(int Rate,int Verbose);
-
-/** StopSound() **********************************************/
-/** Temporarily suspend sound.                              **/
-/*************************************************************/
-void StopSound(void);
-
-/** ResumeSound() ********************************************/
-/** Resume sound after StopSound().                         **/
-/*************************************************************/
-void ResumeSound(void);
-//#endif /* UNIX */
-
-#ifdef MSDOS
-#define SND_CHANNELS    16     /* Number of sound channels   */
-#define OPL_CHANNELS    7      /* Number of Adlib channels   */
-#define SND_SAMPLESIZE  256    /* Max. SetWave() sample size */
-#define SND_BUFSIZE     512    /* Buffer size for DMA        */
-#define SND_MAXDELAY    10     /* Maximal sound delay 1/n s  */
-
-/** InitSound() **********************************************/
-/** Initialize sound. Returns Rate on success, 0 otherwise. **/
-/** Rate=0 to skip initialization (will be silent).         **/
-/*************************************************************/
-int InitSound(uint32_t Rate,uint32_t Latency);
-#endif /* MSDOS */
-
-#ifdef WINDOWS
-#define SND_CHANNELS    16     /* Number of channels         */
-#define SND_SAMPLESIZE  256    /* Max. SetWave() sample size */
-#define SND_BUFSIZE     512    /* Size of a wave buffer      */
-#define SND_BUFFERS     32     /* Number of wave buffers     */
-
-#include <Windows.h>
-
-/** InitSound() **********************************************/
-/** Initialize Windows sound driver with given synthesis    **/
-/** rate. Returns Rate on success, 0 otherwise. Pass Rate=0 **/
-/** to skip initialization and be silent. Pass Rate=1 to    **/
-/** use MIDI (midiOut). Pass Rate=8192..44100 to use wave   **/
-/** synthesis (waveOut). Number of wave synthesis buffers   **/
-/** must be in 2..SND_BUFFERS range.                        **/
-/*************************************************************/
-uint32_t InitSound(uint32_t Rate,uint32_t Delay);
-#endif /* WINDOWS */
-
-
-#if 0
-   
-#ifndef MSDOS
-#ifndef WINDOWS
-#ifndef UNIX
-#define SND_CHANNELS MIDI_CHANNELS         /* Default number */
-#endif
-#endif
-#endif
-
-/** InitSound() **********************************************/
-/** Initialize Series60 sound driver with given synthesis   **/
-/** rate. Returns Rate on success, 0 otherwise. Pass Rate=0 **/
-/** to skip initialization and be silent.                   **/
-/*************************************************************/
-uint32_t InitSound(uint32_t Rate,uint32_t Delay);
-#endif
-
-/** RenderAudio() ********************************************/
-/** Render given number of melodic sound samples. Returns   **/
-/** number of samples actually rendered.                    **/
-/*************************************************************/
-uint32_t RenderAudio(uint32_t Samples);
-
-/** SndDriver ************************************************/
-/** Each sound driver should fill this structure with       **/
-/** pointers to hardware-dependent handlers. This has to be **/
-/** done inside the InitSound() function.                   **/
-/*************************************************************/
-struct SndDriverStruct
-{
-  void (*SetSound)(int Channel,int NewType);
-  void (*Drum)(int Type,int Force);
-  void (*SetChannels)(int Volume,int Switch);
-  void (*Sound)(int Channel,int NewFreq,int NewVolume);
-  void (*SetWave)(int Channel,signed char *Data,int Length,int Freq);
-  const signed char *(*GetWave)(int Channel);
-};
-extern struct SndDriverStruct SndDriver;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SOUND_H */

+ 1 - 1
src/include/apu/apu.h

@@ -2,7 +2,7 @@
  *  APU emulation - The peTI-NESulator Project
  *  apu.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */

+ 3 - 8
src/include/color.h

@@ -2,18 +2,13 @@
  *  ANSI Color definition - The Quick6502 Project
  *  include/color.h
  *
- *  Created by Manoel Trapier on 25/06/10
+ *  Created by Manoël Trapier on 25/06/10
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
- *  $LastChangedDate:$
- *  $Author:$
- *  $HeadURL:$
- *  $Revision:$
- *
  */
 
 #ifndef COLOR_H
-#define	COLOR_H
+#define COLOR_H
 
 #define ALLOW_COLORS
 
@@ -44,5 +39,5 @@
 
 #define CNORMAL ANSI_COLOR("0")
 
-#endif	/* COLOR_H */
+#endif    /* COLOR_H */
 

+ 41 - 40
src/include/corecpu.h

@@ -2,7 +2,7 @@
  *  CoreCPU - The Quick6502 Project
  *  corecpu.h
  *
- *  Created by Manoel Trapier on 24/02/08
+ *  Created by Manoël Trapier on 24/02/08
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -37,52 +37,52 @@ typedef void (*quick6502_MemoryWriteFunction)(uint16_t addr, uint8_t value);
 
 typedef struct quick6502_cpu_
 {
-   /* 6502 registers */
-   uint8_t reg_A, reg_X, reg_Y;
-   uint8_t reg_P, reg_S;
-   uint16_t reg_PC;
-
-   /* Read/Write memory functions */
-   quick6502_MemoryReadFunction  memory_read;
-   quick6502_MemoryWriteFunction memory_write;
-   quick6502_MemoryReadFunction  memory_page0_read;
-   quick6502_MemoryWriteFunction memory_page0_write;
-   quick6502_MemoryReadFunction  memory_stack_read;
-   quick6502_MemoryWriteFunction memory_stack_write;
-   quick6502_MemoryReadFunction  memory_opcode_read;
-
-   /* Timing related */
-   long cycle_done;
-   uint8_t exit_loop;
-   uint8_t int_pending;
-
-   /* Other config options */
-   uint8_t running; /* This field is used to prevent cpu free if this cpu is running */
-   uint8_t page_crossed;
-   
-   /* TODO add support for Inst/MemAccess breakpoints */
-   
+    /* 6502 registers */
+    uint8_t reg_A, reg_X, reg_Y;
+    uint8_t reg_P, reg_S;
+    uint16_t reg_PC;
+
+    /* Read/Write memory functions */
+    quick6502_MemoryReadFunction memory_read;
+    quick6502_MemoryWriteFunction memory_write;
+    quick6502_MemoryReadFunction memory_page0_read;
+    quick6502_MemoryWriteFunction memory_page0_write;
+    quick6502_MemoryReadFunction memory_stack_read;
+    quick6502_MemoryWriteFunction memory_stack_write;
+    quick6502_MemoryReadFunction memory_opcode_read;
+
+    /* Timing related */
+    long cycle_done;
+    uint8_t exit_loop;
+    uint8_t int_pending;
+
+    /* Other config options */
+    uint8_t running; /* This field is used to prevent cpu free if this cpu is running */
+    uint8_t page_crossed;
+
+    /* TODO add support for Inst/MemAccess breakpoints */
+
 } quick6502_cpu;
 
 typedef struct quick6502_cpuconfig_
 {
-   /* Read/Write memory functions */
-   quick6502_MemoryReadFunction  memory_read;
-   quick6502_MemoryWriteFunction memory_write;
-   quick6502_MemoryReadFunction  memory_page0_read;
-   quick6502_MemoryWriteFunction memory_page0_write;
-   quick6502_MemoryReadFunction  memory_stack_read;
-   quick6502_MemoryWriteFunction memory_stack_write;
-   quick6502_MemoryReadFunction  memory_opcode_read;
+    /* Read/Write memory functions */
+    quick6502_MemoryReadFunction memory_read;
+    quick6502_MemoryWriteFunction memory_write;
+    quick6502_MemoryReadFunction memory_page0_read;
+    quick6502_MemoryWriteFunction memory_page0_write;
+    quick6502_MemoryReadFunction memory_stack_read;
+    quick6502_MemoryWriteFunction memory_stack_write;
+    quick6502_MemoryReadFunction memory_opcode_read;
 } quick6502_cpuconfig;
 
 /*** Signal that we can send to the CPU ***/
 typedef enum
 {
-   Q6502_NO_SIGNAL = 0,
-   Q6502_IRQ_SIGNAL,
-   Q6502_NMI_SIGNAL,
-   Q6502_STOPLOOP_SIGNAL
+    Q6502_NO_SIGNAL = 0,
+    Q6502_IRQ_SIGNAL,
+    Q6502_NMI_SIGNAL,
+    Q6502_STOPLOOP_SIGNAL
 } quick6502_signal;
 
 /*** Some 6502 related definitions ***/
@@ -134,7 +134,7 @@ void quick6502_reset(quick6502_cpu *cpu);
  *
  * int: (Number of cycle really done) - (Number of cycle asked)
  */
-int quick6502_run(quick6502_cpu *cpu, int cycles);
+uint32_t quick6502_run(quick6502_cpu *cpu, uint32_t cycles);
 
 /** Loop CPU until explicit quit */
 void quick6502_loop(quick6502_cpu *cpu);
@@ -146,13 +146,14 @@ void quick6502_exec(quick6502_cpu *cpu);
 void quick6502_int(quick6502_cpu *cpu, quick6502_signal signal);
 
 /** Dump CPU State to the given file */
-void quick6502_dump(quick6502_cpu *cpu, FILE * fp);
+void quick6502_dump(quick6502_cpu *cpu, FILE *fp);
 
 /** Get current instruction name at specified address and put it into buffer */
 #define MINE
 
 int quick6502_getinstruction(quick6502_cpu *cpu, char interpret,
                              uint16_t addr, char *buffer, int *strlength);
+
 /**
  * Free the CPU 
  *

+ 3 - 8
src/include/log.h

@@ -2,18 +2,13 @@
  *  Log Facility - The Quick6502 Project
  *  include/log.h
  *
- *  Created by Manoel Trapier on 19/05/10
+ *  Created by Manoël Trapier on 19/05/10
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
- *  $LastChangedDate:$
- *  $Author:$
- *  $HeadURL:$
- *  $Revision:$
- *
  */
 
 #ifndef _LOG_H
-#define	_LOG_H
+#define _LOG_H
 
 enum
 {
@@ -38,5 +33,5 @@ void log_real(int level, char *user, char *fmt, ...);
     if ((_level <= MAX_DEBUG_LEVEL) || (_level <= LOG_PANIC)) \
        do { _code; printf("\n"); } while(0)
 
-#endif	/* _LOG_H */
+#endif /* _LOG_H */
 

+ 16 - 16
src/include/mappers/manager.h

@@ -2,8 +2,8 @@
  *  Mappers manager & facilities - The peTI-NESulator Project
  *  mappers.h
  *
- *  Created by Manoel TRAPIER.
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
+ *  Created by Manoël TRAPIER.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
@@ -14,11 +14,10 @@
 #include <stdio.h>
 #include <NESCarts.h>
 
-typedef int (*MapperInit)      (NesCart * cart);
-typedef int (*MapperWriteHook) (register uint16_t Addr,
-                                register uint8_t Value);
-typedef int (*MapperIRQ)       (int cycledone);
-typedef void (*MapperDump)     (FILE *fp);
+typedef int (*MapperInit)(NesCart *cart);
+typedef int (*MapperWriteHook)(register uint16_t Addr, register uint8_t Value);
+typedef int (*MapperIRQ)(int cycledone);
+typedef void (*MapperDump)(FILE *fp);
 
 #ifdef __TINES_MAPPERS__
 
@@ -33,24 +32,25 @@ extern NesCart *Cart;
 #define GETLAST16KBANK(c) ((c->PROMSize>>14)-1)
 #define GETLAST32KBANK(c) ((c->PROMSize>>15)-1)
 
-void set_vrom_bank_1k(uint16_t addr,int slot);
-void set_vrom_bank_2k(uint16_t addr,int slot);
-void set_vrom_bank_4k(uint16_t addr,int slot);
+void set_vrom_bank_1k(uint16_t addr, int slot);
+void set_vrom_bank_2k(uint16_t addr, int slot);
+void set_vrom_bank_4k(uint16_t addr, int slot);
 void set_vrom_bank_8k(uint16_t addr, int slot);
 
-void set_prom_bank_8k(uint16_t addr,int slot);
-void set_prom_bank_16k(uint16_t addr,int slot);
-void set_prom_bank_32k(uint16_t addr,int slot);
+void set_prom_bank_8k(uint16_t addr, int slot);
+void set_prom_bank_16k(uint16_t addr, int slot);
+void set_prom_bank_32k(uint16_t addr, int slot);
 
 #else /* __TINES_MAPPERS__ */
 
 /* Available functions outside of mappers */
 
 void mapper_list();
-int  mapper_init(NesCart *cart);
 
-extern MapperIRQ       mapper_irqloop;
-extern MapperDump      mapper_dump;
+int mapper_init(NesCart *cart);
+
+extern MapperIRQ mapper_irqloop;
+extern MapperDump mapper_dump;
 extern MapperWriteHook mapper_hook;
 
 #endif /* __TINES_MAPPERS__ */

+ 2 - 13
src/include/memory/manager.h

@@ -2,7 +2,7 @@
  *  6502 Memory manager - The peTI-NESulator Project
  *  memory.h - Taken from the Quick6502 project
  *
- *  Created by Manoel Trapier on 18/09/06.
+ *  Created by Manoël Trapier on 18/09/06.
  *  Copyright 2003-2008 986 Corp. All rights reserved.
  *
  */
@@ -19,6 +19,7 @@
 #define ATTR_PAGE_MAPPED         0x01
 
 typedef uint8_t (*func_rdhook)(uint8_t /* addr */);
+
 typedef void (*func_wrhook)(uint8_t addr, uint8_t data);
 
 /* Functions to manage pages data */
@@ -29,35 +30,23 @@ void set_page_ptr_4k(uint8_t page, uint8_t *ptr);
 void set_page_ptr_8k(uint8_t page, uint8_t *ptr);
 void set_page_ptr_16k(uint8_t page, uint8_t *ptr);
 void set_page_ptr_32k(uint8_t page, uint8_t *ptr);
-
 uint8_t *get_page_ptr(uint8_t page);
 
 
 /* Functions to set pages attributes */
-
 void set_page_rd_hook(uint8_t page, func_rdhook func);
-
 void set_page_wr_hook(uint8_t page, func_wrhook func);
-
 void set_page_readable(uint8_t page, uint8_t value);
-
 void set_page_writeable(uint8_t page, uint8_t value);
-
 void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost);
-
 uint8_t get_page_attributes(uint8_t page);
-
 func_rdhook get_page_rdhook(uint8_t page);
-
 func_wrhook get_page_wrhook(uint8_t page);
 
 /* Generalist functions */
-
 void InitMemory();
-
 uint8_t ReadMemory(uint8_t page, uint8_t addr);
 void WriteMemory(uint8_t page, uint8_t addr, uint8_t value);
-
 void DumpMemoryState(FILE *fp);
 
 #endif

+ 9 - 9
src/include/os_dependent.h

@@ -2,7 +2,7 @@
  *  OS Dependent functions - The peTI-NESulator Project
  *  os_dependent.h
  *
- *  Created by Manoel TRAPIER on 08/05/08.
+ *  Created by Manoël TRAPIER on 08/05/08.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -21,7 +21,7 @@ int graphics_drawline(long x, long y, long x1, long y1, long color);
 
 typedef struct Palette_t
 {
-   uint8_t r,g,b,a;
+    uint8_t r, g, b, a;
 } Palette;
 
 int getKeyStatus(int key);
@@ -29,17 +29,17 @@ int getKeyStatus(int key);
 /* Sound related functions */
 
 /* IO functions */
-void *LoadFilePtr(char * filename);
+void *LoadFilePtr(char *filename);
 
 /* Console functions */
 typedef enum ConsoleLevel_t
 {
-   Console_Error = 0,
-   Console_Warning,
-   Console_Alert,
-   Console_Default,
-   Console_Verbose,
-   Console_Debug,
+    Console_Error = 0,
+    Console_Warning,
+    Console_Alert,
+    Console_Default,
+    Console_Verbose,
+    Console_Debug,
 } ConsoleLevel;
 
 int console_init(ConsoleLevel DefaultLevel);

+ 5 - 13
src/include/paddle.h

@@ -2,7 +2,7 @@
  *  Paddle manager - The peTI-NESulator Project
  *  paddle.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -10,22 +10,14 @@
 #ifndef PADDLE_H
 #define PADDLE_H
 
-typedef struct Paddle_ 
+typedef struct Paddle_
 {
-    
     uint8_t Bit;
-    
     uint8_t LastWrite;
-    
 } Paddle;
 
-
-uint8_t ReadPaddle(Paddle * pdl);
-
-
-void InitPaddle(Paddle * pdl);
-
-void WritePaddle(Paddle * pdl, uint8_t val);
-
+uint8_t ReadPaddle(Paddle *pdl);
+void InitPaddle(Paddle *pdl);
+void WritePaddle(Paddle *pdl, uint8_t val);
 
 #endif

+ 257 - 257
src/include/palette.h

@@ -1,260 +1,260 @@
 /* Generated data file from file 'stdin' */
 
 Palette basicPalette[] = {
-       { 0x1E, 0x1E, 0x1E, 0x07 },
-       { 0x03, 0x09, 0x28, 0xB7 },
-       { 0x0A, 0x04, 0x2B, 0x0D },
-       { 0x17, 0x02, 0x28, 0x00 },
-       { 0x22, 0x00, 0x1D, 0xB7 },
-       { 0x24, 0x01, 0x0A, 0xB7 },
-       { 0x24, 0x04, 0x02, 0xB7 },
-       { 0x1B, 0x09, 0x01, 0xB7 },
-       { 0x11, 0x10, 0x01, 0x00 },
-       { 0x05, 0x15, 0x01, 0x00 },
-       { 0x01, 0x17, 0x02, 0xB7 },
-       { 0x00, 0x14, 0x0B, 0xBF },
-       { 0x01, 0x11, 0x1B, 0xBF },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x2F, 0x30, 0x2F, 0xB7 },
-       { 0x05, 0x1A, 0x37, 0xBF },
-       { 0x12, 0x10, 0x3B, 0xBF },
-       { 0x23, 0x09, 0x38, 0xB7 },
-       { 0x31, 0x06, 0x2E, 0xBF },
-       { 0x35, 0x08, 0x18, 0xB7 },
-       { 0x35, 0x0D, 0x08, 0x00 },
-       { 0x2D, 0x16, 0x03, 0xB7 },
-       { 0x22, 0x1E, 0x01, 0x00 },
-       { 0x0E, 0x24, 0x01, 0x00 },
-       { 0x05, 0x26, 0x06, 0x00 },
-       { 0x02, 0x26, 0x16, 0xB7 },
-       { 0x02, 0x22, 0x2A, 0xBF },
-       { 0x0B, 0x0B, 0x0B, 0xBF },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x3D, 0x3D, 0x3E, 0x00 },
-       { 0x12, 0x2C, 0x3E, 0xB7 },
-       { 0x22, 0x25, 0x3F, 0xB7 },
-       { 0x30, 0x1E, 0x3E, 0xB7 },
-       { 0x3A, 0x1B, 0x3B, 0xBF },
-       { 0x3D, 0x1D, 0x2E, 0xB7 },
-       { 0x3D, 0x20, 0x1B, 0xB7 },
-       { 0x3B, 0x28, 0x11, 0x07 },
-       { 0x35, 0x30, 0x08, 0x01 },
-       { 0x26, 0x35, 0x08, 0x00 },
-       { 0x14, 0x37, 0x11, 0x00 },
-       { 0x0F, 0x37, 0x25, 0x00 },
-       { 0x0A, 0x36, 0x37, 0xB7 },
-       { 0x18, 0x19, 0x19, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x3E, 0x3E, 0x3E, 0xB7 },
-       { 0x2D, 0x37, 0x3E, 0xB7 },
-       { 0x33, 0x34, 0x3F, 0x10 },
-       { 0x37, 0x31, 0x3E, 0x00 },
-       { 0x3C, 0x30, 0x3D, 0x00 },
-       { 0x3D, 0x30, 0x38, 0x00 },
-       { 0x3D, 0x33, 0x30, 0x00 },
-       { 0x3D, 0x36, 0x2B, 0x00 },
-       { 0x3B, 0x39, 0x26, 0x00 },
-       { 0x34, 0x3B, 0x27, 0x00 },
-       { 0x2E, 0x3C, 0x2D, 0x00 },
-       { 0x2C, 0x3C, 0x36, 0x00 },
-       { 0x29, 0x3C, 0x3C, 0x00 },
-       { 0x32, 0x31, 0x32, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x1E, 0x1E, 0x1E, 0xB7 },
-       { 0x03, 0x09, 0x28, 0xB7 },
-       { 0x0A, 0x04, 0x2B, 0xBF },
-       { 0x17, 0x02, 0x28, 0xB7 },
-       { 0x22, 0x00, 0x1D, 0xB7 },
-       { 0x24, 0x01, 0x0A, 0xB7 },
-       { 0x24, 0x04, 0x02, 0x00 },
-       { 0x1B, 0x09, 0x01, 0x00 },
-       { 0x11, 0x10, 0x01, 0x00 },
-       { 0x05, 0x15, 0x01, 0xB7 },
-       { 0x01, 0x17, 0x02, 0x00 },
-       { 0x00, 0x14, 0x0B, 0xB7 },
-       { 0x01, 0x11, 0x1B, 0x50 },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x2F, 0x30, 0x2F, 0xBF },
-       { 0x05, 0x1A, 0x37, 0xB7 },
-       { 0x12, 0x10, 0x3B, 0xB7 },
-       { 0x23, 0x09, 0x38, 0x20 },
-       { 0x31, 0x06, 0x2E, 0xBF },
-       { 0x35, 0x08, 0x18, 0xB7 },
-       { 0x35, 0x0D, 0x08, 0xBF },
-       { 0x2D, 0x16, 0x03, 0xBF },
-       { 0x22, 0x1E, 0x01, 0xB7 },
-       { 0x0E, 0x24, 0x01, 0xBF },
-       { 0x05, 0x26, 0x06, 0xB7 },
-       { 0x02, 0x26, 0x16, 0xBF },
-       { 0x02, 0x22, 0x2A, 0xBF },
-       { 0x0B, 0x0B, 0x0B, 0x00 },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x3D, 0x3D, 0x3E, 0xBF },
-       { 0x12, 0x2C, 0x3E, 0x53 },
-       { 0x22, 0x25, 0x3F, 0x54 },
-       { 0x30, 0x1E, 0x3E, 0x46 },
-       { 0x3A, 0x1B, 0x3B, 0x31 },
-       { 0x3D, 0x1D, 0x2E, 0x3A },
-       { 0x3D, 0x20, 0x1B, 0x32 },
-       { 0x3B, 0x28, 0x11, 0x54 },
-       { 0x35, 0x30, 0x08, 0x30 },
-       { 0x26, 0x35, 0x08, 0x00 },
-       { 0x14, 0x37, 0x11, 0x00 },
-       { 0x0F, 0x37, 0x25, 0x00 },
-       { 0x0A, 0x36, 0x37, 0x00 },
-       { 0x18, 0x19, 0x19, 0x00 },
-       { 0x01, 0x01, 0x01, 0x00 },
-       { 0x01, 0x01, 0x01, 0x00 },
-       { 0x3E, 0x3E, 0x3E, 0x00 },
-       { 0x2D, 0x37, 0x3E, 0x00 },
-       { 0x33, 0x34, 0x3F, 0x00 },
-       { 0x37, 0x31, 0x3E, 0x00 },
-       { 0x3C, 0x30, 0x3D, 0x00 },
-       { 0x3D, 0x30, 0x38, 0x00 },
-       { 0x3D, 0x33, 0x30, 0xB7 },
-       { 0x3D, 0x36, 0x2B, 0xB7 },
-       { 0x3B, 0x39, 0x26, 0x00 },
-       { 0x34, 0x3B, 0x27, 0xBF },
-       { 0x2E, 0x3C, 0x2D, 0xB7 },
-       { 0x2C, 0x3C, 0x36, 0xB7 },
-       { 0x29, 0x3C, 0x3C, 0xB7 },
-       { 0x32, 0x31, 0x32, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x1E, 0x1E, 0x1E, 0x07 },
-       { 0x03, 0x09, 0x28, 0xB7 },
-       { 0x0A, 0x04, 0x2B, 0x0D },
-       { 0x17, 0x02, 0x28, 0x00 },
-       { 0x22, 0x00, 0x1D, 0xB7 },
-       { 0x24, 0x01, 0x0A, 0xB7 },
-       { 0x24, 0x04, 0x02, 0xB7 },
-       { 0x1B, 0x09, 0x01, 0xB7 },
-       { 0x11, 0x10, 0x01, 0x00 },
-       { 0x05, 0x15, 0x01, 0x00 },
-       { 0x01, 0x17, 0x02, 0xB7 },
-       { 0x00, 0x14, 0x0B, 0x00 },
-       { 0x01, 0x11, 0x1B, 0xB7 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x2F, 0x30, 0x2F, 0xB7 },
-       { 0x05, 0x1A, 0x37, 0xBF },
-       { 0x12, 0x10, 0x3B, 0xB7 },
-       { 0x23, 0x09, 0x38, 0xB7 },
-       { 0x31, 0x06, 0x2E, 0x00 },
-       { 0x35, 0x08, 0x18, 0xBF },
-       { 0x35, 0x0D, 0x08, 0xB7 },
-       { 0x2D, 0x16, 0x03, 0xB7 },
-       { 0x22, 0x1E, 0x01, 0xB7 },
-       { 0x0E, 0x24, 0x01, 0x00 },
-       { 0x05, 0x26, 0x06, 0x00 },
-       { 0x02, 0x26, 0x16, 0xB7 },
-       { 0x02, 0x22, 0x2A, 0x06 },
-       { 0x0B, 0x0B, 0x0B, 0xB7 },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x00, 0x00, 0x00, 0x00 },
-       { 0x3D, 0x3D, 0x3E, 0xB7 },
-       { 0x12, 0x2C, 0x3E, 0xB7 },
-       { 0x22, 0x25, 0x3F, 0xB7 },
-       { 0x30, 0x1E, 0x3E, 0xB7 },
-       { 0x3A, 0x1B, 0x3B, 0x00 },
-       { 0x3D, 0x1D, 0x2E, 0x00 },
-       { 0x3D, 0x20, 0x1B, 0xB7 },
-       { 0x3B, 0x28, 0x11, 0xB7 },
-       { 0x35, 0x30, 0x08, 0x03 },
-       { 0x26, 0x35, 0x08, 0xB7 },
-       { 0x14, 0x37, 0x11, 0xBF },
-       { 0x0F, 0x37, 0x25, 0x00 },
-       { 0x0A, 0x36, 0x37, 0xB7 },
-       { 0x18, 0x19, 0x19, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x3E, 0x3E, 0x3E, 0x00 },
-       { 0x2D, 0x37, 0x3E, 0x00 },
-       { 0x33, 0x34, 0x3F, 0xB7 },
-       { 0x37, 0x31, 0x3E, 0xB7 },
-       { 0x3C, 0x30, 0x3D, 0x00 },
-       { 0x3D, 0x30, 0x38, 0x00 },
-       { 0x3D, 0x33, 0x30, 0xB7 },
-       { 0x3D, 0x36, 0x2B, 0xB7 },
-       { 0x3B, 0x39, 0x26, 0xB7 },
-       { 0x34, 0x3B, 0x27, 0xBF },
-       { 0x2E, 0x3C, 0x2D, 0xBF },
-       { 0x2C, 0x3C, 0x36, 0xB7 },
-       { 0x29, 0x3C, 0x3C, 0xBF },
-       { 0x32, 0x31, 0x32, 0xB7 },
-       { 0x01, 0x01, 0x01, 0x00 },
-       { 0x01, 0x01, 0x01, 0xB7 },
-       { 0x1E, 0x1E, 0x1E, 0xB7 },
-       { 0x03, 0x09, 0x28, 0x08 },
-       { 0x0A, 0x04, 0x2B, 0xBF },
-       { 0x17, 0x02, 0x28, 0xB7 },
-       { 0x22, 0x00, 0x1D, 0x08 },
-       { 0x24, 0x01, 0x0A, 0xB7 },
-       { 0x24, 0x04, 0x02, 0x08 },
-       { 0x1B, 0x09, 0x01, 0xB7 },
-       { 0x11, 0x10, 0x01, 0x00 },
-       { 0x05, 0x15, 0x01, 0xBF },
-       { 0x01, 0x17, 0x02, 0xB7 },
-       { 0x00, 0x14, 0x0B, 0xB7 },
-       { 0x01, 0x11, 0x1B, 0x08 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x00, 0x00, 0x00, 0x08 },
-       { 0x2F, 0x30, 0x2F, 0x01 },
-       { 0x05, 0x1A, 0x37, 0x08 },
-       { 0x12, 0x10, 0x3B, 0x0D },
-       { 0x23, 0x09, 0x38, 0x00 },
-       { 0x31, 0x06, 0x2E, 0xB7 },
-       { 0x35, 0x08, 0x18, 0xB7 },
-       { 0x35, 0x0D, 0x08, 0xB7 },
-       { 0x2D, 0x16, 0x03, 0xB7 },
-       { 0x22, 0x1E, 0x01, 0x00 },
-       { 0x0E, 0x24, 0x01, 0x00 },
-       { 0x05, 0x26, 0x06, 0xB7 },
-       { 0x02, 0x26, 0x16, 0x00 },
-       { 0x02, 0x22, 0x2A, 0xB7 },
-       { 0x0B, 0x0B, 0x0B, 0xB7 },
-       { 0x00, 0x00, 0x00, 0x08 },
-       { 0x00, 0x00, 0x00, 0xB7 },
-       { 0x3D, 0x3D, 0x3E, 0xB7 },
-       { 0x12, 0x2C, 0x3E, 0xBF },
-       { 0x22, 0x25, 0x3F, 0xBF },
-       { 0x30, 0x1E, 0x3E, 0xB7 },
-       { 0x3A, 0x1B, 0x3B, 0xBF },
-       { 0x3D, 0x1D, 0x2E, 0xB7 },
-       { 0x3D, 0x20, 0x1B, 0x00 },
-       { 0x3B, 0x28, 0x11, 0xB7 },
-       { 0x35, 0x30, 0x08, 0x00 },
-       { 0x26, 0x35, 0x08, 0x00 },
-       { 0x14, 0x37, 0x11, 0x00 },
-       { 0x0F, 0x37, 0x25, 0xB7 },
-       { 0x0A, 0x36, 0x37, 0xB7 },
-       { 0x18, 0x19, 0x19, 0x00 },
-       { 0x01, 0x01, 0x01, 0x00 },
-       { 0x01, 0x01, 0x01, 0x00 },
-       { 0x3E, 0x3E, 0x3E, 0x00 },
-       { 0x2D, 0x37, 0x3E, 0xB7 },
-       { 0x33, 0x34, 0x3F, 0x00 },
-       { 0x37, 0x31, 0x3E, 0xB7 },
-       { 0x3C, 0x30, 0x3D, 0xBF },
-       { 0x3D, 0x30, 0x38, 0xB7 },
-       { 0x3D, 0x33, 0x30, 0x08 },
-       { 0x3D, 0x36, 0x2B, 0x01 },
-       { 0x3B, 0x39, 0x26, 0x01 },
-       { 0x34, 0x3B, 0x27, 0x00 },
-       { 0x2E, 0x3C, 0x2D, 0xB7 },
-       { 0x2C, 0x3C, 0x36, 0xB7 },
-       { 0x29, 0x3C, 0x3C, 0x08 },
-       { 0x32, 0x31, 0x32, 0xB7 },
-       { 0x01, 0x01, 0x01, 0x08 },
-       { 0x01, 0x01, 0x01, 0xBF },
-      };
+        { 0x1E, 0x1E, 0x1E, 0x07 },
+        { 0x03, 0x09, 0x28, 0xB7 },
+        { 0x0A, 0x04, 0x2B, 0x0D },
+        { 0x17, 0x02, 0x28, 0x00 },
+        { 0x22, 0x00, 0x1D, 0xB7 },
+        { 0x24, 0x01, 0x0A, 0xB7 },
+        { 0x24, 0x04, 0x02, 0xB7 },
+        { 0x1B, 0x09, 0x01, 0xB7 },
+        { 0x11, 0x10, 0x01, 0x00 },
+        { 0x05, 0x15, 0x01, 0x00 },
+        { 0x01, 0x17, 0x02, 0xB7 },
+        { 0x00, 0x14, 0x0B, 0xBF },
+        { 0x01, 0x11, 0x1B, 0xBF },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x2F, 0x30, 0x2F, 0xB7 },
+        { 0x05, 0x1A, 0x37, 0xBF },
+        { 0x12, 0x10, 0x3B, 0xBF },
+        { 0x23, 0x09, 0x38, 0xB7 },
+        { 0x31, 0x06, 0x2E, 0xBF },
+        { 0x35, 0x08, 0x18, 0xB7 },
+        { 0x35, 0x0D, 0x08, 0x00 },
+        { 0x2D, 0x16, 0x03, 0xB7 },
+        { 0x22, 0x1E, 0x01, 0x00 },
+        { 0x0E, 0x24, 0x01, 0x00 },
+        { 0x05, 0x26, 0x06, 0x00 },
+        { 0x02, 0x26, 0x16, 0xB7 },
+        { 0x02, 0x22, 0x2A, 0xBF },
+        { 0x0B, 0x0B, 0x0B, 0xBF },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x3D, 0x3D, 0x3E, 0x00 },
+        { 0x12, 0x2C, 0x3E, 0xB7 },
+        { 0x22, 0x25, 0x3F, 0xB7 },
+        { 0x30, 0x1E, 0x3E, 0xB7 },
+        { 0x3A, 0x1B, 0x3B, 0xBF },
+        { 0x3D, 0x1D, 0x2E, 0xB7 },
+        { 0x3D, 0x20, 0x1B, 0xB7 },
+        { 0x3B, 0x28, 0x11, 0x07 },
+        { 0x35, 0x30, 0x08, 0x01 },
+        { 0x26, 0x35, 0x08, 0x00 },
+        { 0x14, 0x37, 0x11, 0x00 },
+        { 0x0F, 0x37, 0x25, 0x00 },
+        { 0x0A, 0x36, 0x37, 0xB7 },
+        { 0x18, 0x19, 0x19, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x3E, 0x3E, 0x3E, 0xB7 },
+        { 0x2D, 0x37, 0x3E, 0xB7 },
+        { 0x33, 0x34, 0x3F, 0x10 },
+        { 0x37, 0x31, 0x3E, 0x00 },
+        { 0x3C, 0x30, 0x3D, 0x00 },
+        { 0x3D, 0x30, 0x38, 0x00 },
+        { 0x3D, 0x33, 0x30, 0x00 },
+        { 0x3D, 0x36, 0x2B, 0x00 },
+        { 0x3B, 0x39, 0x26, 0x00 },
+        { 0x34, 0x3B, 0x27, 0x00 },
+        { 0x2E, 0x3C, 0x2D, 0x00 },
+        { 0x2C, 0x3C, 0x36, 0x00 },
+        { 0x29, 0x3C, 0x3C, 0x00 },
+        { 0x32, 0x31, 0x32, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x1E, 0x1E, 0x1E, 0xB7 },
+        { 0x03, 0x09, 0x28, 0xB7 },
+        { 0x0A, 0x04, 0x2B, 0xBF },
+        { 0x17, 0x02, 0x28, 0xB7 },
+        { 0x22, 0x00, 0x1D, 0xB7 },
+        { 0x24, 0x01, 0x0A, 0xB7 },
+        { 0x24, 0x04, 0x02, 0x00 },
+        { 0x1B, 0x09, 0x01, 0x00 },
+        { 0x11, 0x10, 0x01, 0x00 },
+        { 0x05, 0x15, 0x01, 0xB7 },
+        { 0x01, 0x17, 0x02, 0x00 },
+        { 0x00, 0x14, 0x0B, 0xB7 },
+        { 0x01, 0x11, 0x1B, 0x50 },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x2F, 0x30, 0x2F, 0xBF },
+        { 0x05, 0x1A, 0x37, 0xB7 },
+        { 0x12, 0x10, 0x3B, 0xB7 },
+        { 0x23, 0x09, 0x38, 0x20 },
+        { 0x31, 0x06, 0x2E, 0xBF },
+        { 0x35, 0x08, 0x18, 0xB7 },
+        { 0x35, 0x0D, 0x08, 0xBF },
+        { 0x2D, 0x16, 0x03, 0xBF },
+        { 0x22, 0x1E, 0x01, 0xB7 },
+        { 0x0E, 0x24, 0x01, 0xBF },
+        { 0x05, 0x26, 0x06, 0xB7 },
+        { 0x02, 0x26, 0x16, 0xBF },
+        { 0x02, 0x22, 0x2A, 0xBF },
+        { 0x0B, 0x0B, 0x0B, 0x00 },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x3D, 0x3D, 0x3E, 0xBF },
+        { 0x12, 0x2C, 0x3E, 0x53 },
+        { 0x22, 0x25, 0x3F, 0x54 },
+        { 0x30, 0x1E, 0x3E, 0x46 },
+        { 0x3A, 0x1B, 0x3B, 0x31 },
+        { 0x3D, 0x1D, 0x2E, 0x3A },
+        { 0x3D, 0x20, 0x1B, 0x32 },
+        { 0x3B, 0x28, 0x11, 0x54 },
+        { 0x35, 0x30, 0x08, 0x30 },
+        { 0x26, 0x35, 0x08, 0x00 },
+        { 0x14, 0x37, 0x11, 0x00 },
+        { 0x0F, 0x37, 0x25, 0x00 },
+        { 0x0A, 0x36, 0x37, 0x00 },
+        { 0x18, 0x19, 0x19, 0x00 },
+        { 0x01, 0x01, 0x01, 0x00 },
+        { 0x01, 0x01, 0x01, 0x00 },
+        { 0x3E, 0x3E, 0x3E, 0x00 },
+        { 0x2D, 0x37, 0x3E, 0x00 },
+        { 0x33, 0x34, 0x3F, 0x00 },
+        { 0x37, 0x31, 0x3E, 0x00 },
+        { 0x3C, 0x30, 0x3D, 0x00 },
+        { 0x3D, 0x30, 0x38, 0x00 },
+        { 0x3D, 0x33, 0x30, 0xB7 },
+        { 0x3D, 0x36, 0x2B, 0xB7 },
+        { 0x3B, 0x39, 0x26, 0x00 },
+        { 0x34, 0x3B, 0x27, 0xBF },
+        { 0x2E, 0x3C, 0x2D, 0xB7 },
+        { 0x2C, 0x3C, 0x36, 0xB7 },
+        { 0x29, 0x3C, 0x3C, 0xB7 },
+        { 0x32, 0x31, 0x32, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x1E, 0x1E, 0x1E, 0x07 },
+        { 0x03, 0x09, 0x28, 0xB7 },
+        { 0x0A, 0x04, 0x2B, 0x0D },
+        { 0x17, 0x02, 0x28, 0x00 },
+        { 0x22, 0x00, 0x1D, 0xB7 },
+        { 0x24, 0x01, 0x0A, 0xB7 },
+        { 0x24, 0x04, 0x02, 0xB7 },
+        { 0x1B, 0x09, 0x01, 0xB7 },
+        { 0x11, 0x10, 0x01, 0x00 },
+        { 0x05, 0x15, 0x01, 0x00 },
+        { 0x01, 0x17, 0x02, 0xB7 },
+        { 0x00, 0x14, 0x0B, 0x00 },
+        { 0x01, 0x11, 0x1B, 0xB7 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x2F, 0x30, 0x2F, 0xB7 },
+        { 0x05, 0x1A, 0x37, 0xBF },
+        { 0x12, 0x10, 0x3B, 0xB7 },
+        { 0x23, 0x09, 0x38, 0xB7 },
+        { 0x31, 0x06, 0x2E, 0x00 },
+        { 0x35, 0x08, 0x18, 0xBF },
+        { 0x35, 0x0D, 0x08, 0xB7 },
+        { 0x2D, 0x16, 0x03, 0xB7 },
+        { 0x22, 0x1E, 0x01, 0xB7 },
+        { 0x0E, 0x24, 0x01, 0x00 },
+        { 0x05, 0x26, 0x06, 0x00 },
+        { 0x02, 0x26, 0x16, 0xB7 },
+        { 0x02, 0x22, 0x2A, 0x06 },
+        { 0x0B, 0x0B, 0x0B, 0xB7 },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x00, 0x00, 0x00, 0x00 },
+        { 0x3D, 0x3D, 0x3E, 0xB7 },
+        { 0x12, 0x2C, 0x3E, 0xB7 },
+        { 0x22, 0x25, 0x3F, 0xB7 },
+        { 0x30, 0x1E, 0x3E, 0xB7 },
+        { 0x3A, 0x1B, 0x3B, 0x00 },
+        { 0x3D, 0x1D, 0x2E, 0x00 },
+        { 0x3D, 0x20, 0x1B, 0xB7 },
+        { 0x3B, 0x28, 0x11, 0xB7 },
+        { 0x35, 0x30, 0x08, 0x03 },
+        { 0x26, 0x35, 0x08, 0xB7 },
+        { 0x14, 0x37, 0x11, 0xBF },
+        { 0x0F, 0x37, 0x25, 0x00 },
+        { 0x0A, 0x36, 0x37, 0xB7 },
+        { 0x18, 0x19, 0x19, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x3E, 0x3E, 0x3E, 0x00 },
+        { 0x2D, 0x37, 0x3E, 0x00 },
+        { 0x33, 0x34, 0x3F, 0xB7 },
+        { 0x37, 0x31, 0x3E, 0xB7 },
+        { 0x3C, 0x30, 0x3D, 0x00 },
+        { 0x3D, 0x30, 0x38, 0x00 },
+        { 0x3D, 0x33, 0x30, 0xB7 },
+        { 0x3D, 0x36, 0x2B, 0xB7 },
+        { 0x3B, 0x39, 0x26, 0xB7 },
+        { 0x34, 0x3B, 0x27, 0xBF },
+        { 0x2E, 0x3C, 0x2D, 0xBF },
+        { 0x2C, 0x3C, 0x36, 0xB7 },
+        { 0x29, 0x3C, 0x3C, 0xBF },
+        { 0x32, 0x31, 0x32, 0xB7 },
+        { 0x01, 0x01, 0x01, 0x00 },
+        { 0x01, 0x01, 0x01, 0xB7 },
+        { 0x1E, 0x1E, 0x1E, 0xB7 },
+        { 0x03, 0x09, 0x28, 0x08 },
+        { 0x0A, 0x04, 0x2B, 0xBF },
+        { 0x17, 0x02, 0x28, 0xB7 },
+        { 0x22, 0x00, 0x1D, 0x08 },
+        { 0x24, 0x01, 0x0A, 0xB7 },
+        { 0x24, 0x04, 0x02, 0x08 },
+        { 0x1B, 0x09, 0x01, 0xB7 },
+        { 0x11, 0x10, 0x01, 0x00 },
+        { 0x05, 0x15, 0x01, 0xBF },
+        { 0x01, 0x17, 0x02, 0xB7 },
+        { 0x00, 0x14, 0x0B, 0xB7 },
+        { 0x01, 0x11, 0x1B, 0x08 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x00, 0x00, 0x00, 0x08 },
+        { 0x2F, 0x30, 0x2F, 0x01 },
+        { 0x05, 0x1A, 0x37, 0x08 },
+        { 0x12, 0x10, 0x3B, 0x0D },
+        { 0x23, 0x09, 0x38, 0x00 },
+        { 0x31, 0x06, 0x2E, 0xB7 },
+        { 0x35, 0x08, 0x18, 0xB7 },
+        { 0x35, 0x0D, 0x08, 0xB7 },
+        { 0x2D, 0x16, 0x03, 0xB7 },
+        { 0x22, 0x1E, 0x01, 0x00 },
+        { 0x0E, 0x24, 0x01, 0x00 },
+        { 0x05, 0x26, 0x06, 0xB7 },
+        { 0x02, 0x26, 0x16, 0x00 },
+        { 0x02, 0x22, 0x2A, 0xB7 },
+        { 0x0B, 0x0B, 0x0B, 0xB7 },
+        { 0x00, 0x00, 0x00, 0x08 },
+        { 0x00, 0x00, 0x00, 0xB7 },
+        { 0x3D, 0x3D, 0x3E, 0xB7 },
+        { 0x12, 0x2C, 0x3E, 0xBF },
+        { 0x22, 0x25, 0x3F, 0xBF },
+        { 0x30, 0x1E, 0x3E, 0xB7 },
+        { 0x3A, 0x1B, 0x3B, 0xBF },
+        { 0x3D, 0x1D, 0x2E, 0xB7 },
+        { 0x3D, 0x20, 0x1B, 0x00 },
+        { 0x3B, 0x28, 0x11, 0xB7 },
+        { 0x35, 0x30, 0x08, 0x00 },
+        { 0x26, 0x35, 0x08, 0x00 },
+        { 0x14, 0x37, 0x11, 0x00 },
+        { 0x0F, 0x37, 0x25, 0xB7 },
+        { 0x0A, 0x36, 0x37, 0xB7 },
+        { 0x18, 0x19, 0x19, 0x00 },
+        { 0x01, 0x01, 0x01, 0x00 },
+        { 0x01, 0x01, 0x01, 0x00 },
+        { 0x3E, 0x3E, 0x3E, 0x00 },
+        { 0x2D, 0x37, 0x3E, 0xB7 },
+        { 0x33, 0x34, 0x3F, 0x00 },
+        { 0x37, 0x31, 0x3E, 0xB7 },
+        { 0x3C, 0x30, 0x3D, 0xBF },
+        { 0x3D, 0x30, 0x38, 0xB7 },
+        { 0x3D, 0x33, 0x30, 0x08 },
+        { 0x3D, 0x36, 0x2B, 0x01 },
+        { 0x3B, 0x39, 0x26, 0x01 },
+        { 0x34, 0x3B, 0x27, 0x00 },
+        { 0x2E, 0x3C, 0x2D, 0xB7 },
+        { 0x2C, 0x3C, 0x36, 0xB7 },
+        { 0x29, 0x3C, 0x3C, 0x08 },
+        { 0x32, 0x31, 0x32, 0xB7 },
+        { 0x01, 0x01, 0x01, 0x08 },
+        { 0x01, 0x01, 0x01, 0xBF },
+};

+ 7 - 10
src/include/plugins/manager.h

@@ -2,20 +2,20 @@
  *  Plugins manager - The peTI-NESulator Project
  *  plugins.h
  *
- *  Created by Manoel TRAPIER on 02/04/07.
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
+ *  Created by Manoël TRAPIER on 02/04/07.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
-#ifndef PLUGINS_H 
-#define PLUGINS_H 
+#ifndef PLUGINS_H
+#define PLUGINS_H
 
 #include <types.h>
 
 /* Function pointer for prototyping function that plugins may export */
-typedef int (*PluginInit) (void);
-typedef int (*PluginDeinit) (void);
-typedef void (*PluginKeypress) (void);
+typedef int (*PluginInit)(void);
+typedef int (*PluginDeinit)(void);
+typedef void (*PluginKeypress)(void);
 
 #ifdef __TINES_PLUGINS__
 
@@ -30,12 +30,9 @@ int plugin_keypress(uint8_t key);
 
 /* Real Prototype: TBD */
 void plugin_list();
-
 int plugin_load(int id);
-
 int plugin_unload(int id);
 
-
 #endif /* __TINES_PLUGINS__ */
 
 #endif /* PLUGINS_H */

+ 1 - 1
src/include/ppu/ppu.debug.h

@@ -2,7 +2,7 @@
  *  PPU debug utilities - The peTI-NESulator Project
  *  ppu.debug.h
  *
- *  Created by Manoel Trapier on 12/04/07.
+ *  Created by Manoël Trapier on 12/04/07.
  *  Copyright 2003-2008 986 Corp. All rights reserved.
  *
  */

+ 2 - 10
src/include/ppu/ppu.h

@@ -4,7 +4,7 @@
  *  
  *  Define and emulate the PPU (Picture Processing Unit) of the real NES
  * 
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -26,13 +26,9 @@ typedef struct PPU_Sprite_
 PPU must be initialized after memory initialisation..
 */
 int ppu_init();
-
 int ppu_hblank(uint16_t scanline);
-
 uint8_t ppu_readReg(uint8_t id);
-
 void ppu_writeReg(uint8_t id, uint8_t val);
-
 void ppu_fillSprRamDMA(uint8_t value);
 
 #define PPU_MIRROR_HORIZTAL 0
@@ -50,13 +46,9 @@ void ppu_fillSprRamDMA(uint8_t value);
 void ppu_setMirroring(uint8_t direction);
 void ppu_setSingleScreen(uint8_t screen);
 void ppu_setScreenMode(uint8_t mode);
-
-
 PPU_Sprite ppu_getSprite(uint16_t i);
-
 uint8_t ppu_memoryRead(uint8_t page, uint8_t addr);
-void          ppu_memoryWrite(uint8_t page, uint8_t addr, uint8_t value);
-
+void ppu_memoryWrite(uint8_t page, uint8_t addr, uint8_t value);
 void ppu_debugSprites();
 void ppu_debugColor();
 

+ 2 - 5
src/include/ppu/ppu.memory.h

@@ -2,7 +2,7 @@
  *  PPU Memory manager - The peTI-NESulator Project
  *  ppu.memory.h - Inspired from the memory manager of the Quick6502 Project.
  *
- *  Created by Manoel Trapier on 12/04/07.
+ *  Created by Manoël Trapier on 12/04/07.
  *  Copyright 2003-2008 986 Corp. All rights reserved.
  *
  */
@@ -11,17 +11,14 @@
 
 int ppu_initMemory();
 
-void ppu_setPagePtr  (uint8_t page, uint8_t *ptr);
+void ppu_setPagePtr(uint8_t page, uint8_t *ptr);
 void ppu_setPagePtr1k(uint8_t page, uint8_t *ptr);
 void ppu_setPagePtr2k(uint8_t page, uint8_t *ptr);
 void ppu_setPagePtr4k(uint8_t page, uint8_t *ptr);
 void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
-
 void ppu_memoryDumpState(FILE *fp);
-
 uint8_t ppu_readMemory(uint8_t page, uint8_t addr);
 void ppu_writeMemory(uint8_t page, uint8_t addr, uint8_t value);
-
 void ppu_setPageGhost(uint8_t page, uint8_t value, uint8_t ghost);
 
 #else

+ 1 - 1
src/include/types.h

@@ -2,7 +2,7 @@
  *  Base type definitions - The peTI-NESulator Project
  *  types.h - Taken from the Quick6502 project
  *
- *  Created by Manoel Trapier on 18/09/06.
+ *  Created by Manoël Trapier on 18/09/06.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */

+ 114 - 90
src/log.c

@@ -2,14 +2,9 @@
  *  Log Facility - The Quick6502 Project
  *  log.c
  *
- *  Created by Manoel Trapier on 19/05/10
+ *  Created by Manoël Trapier on 19/05/10
  *  Copyright 2010 986 Corp. All rights reserved.
  *
- *  $LastChangedDate:$
- *  $Author:$
- *  $HeadURL:$
- *  $Revision:$
- *
  */
 
 #include <stdlib.h>
@@ -22,104 +17,133 @@
 #include <time.h>
 
 #ifdef TIME_STAMP_LOG
+
 void time_stamp_line(void)
 {
-   /* Time "0" will be thefirst log line */
-   static char firstRun = 1;
-   static struct timeval firstTime;
-   struct timeval curTime; 
-
-   int cMin, cSec;
-   long long cMSec;
-
-   /* Get datetime */
-   gettimeofday(&curTime, NULL);
-
-   if (firstRun == 1)
-   {
-      firstRun = 0;
-      firstTime.tv_sec = curTime.tv_sec;
-      firstTime.tv_usec = curTime.tv_usec;
-   }
-
-   cMSec = ((curTime.tv_sec - firstTime.tv_sec)* 1000) + (curTime.tv_usec - firstTime.tv_usec)/1000;
-   cSec = (cMSec/1000);
-   cMSec %= 1000;
-
-   cMin = cSec / 60;
-
-   cSec %= 60;
-
-   /* Put cursor at start of line */
-   printf("%c[s", 0x1B);
-   printf("%c[7000D", 0x1B);
-   printf("%c[1C", 0x1B);
-   printf(FWHITE"[" FYELLOW "%03d" FRED "." FBLUE "%02d" FRED "." FGREEN "%03lld" FWHITE "]" CNORMAL, cMin, cSec, cMSec);
-   printf("%c[u", 0x1B);
+    /* Time "0" will be thefirst log line */
+    static char firstRun = 1;
+    static struct timeval firstTime;
+    struct timeval curTime;
+
+    int cMin, cSec;
+    long long cMSec;
+
+    /* Get datetime */
+    gettimeofday(&curTime, NULL);
+
+    if (firstRun == 1)
+    {
+        firstRun = 0;
+        firstTime.tv_sec = curTime.tv_sec;
+        firstTime.tv_usec = curTime.tv_usec;
+    }
+
+    cMSec = ((curTime.tv_sec - firstTime.tv_sec) * 1000) + (curTime.tv_usec - firstTime.tv_usec) / 1000;
+    cSec = (cMSec / 1000);
+    cMSec %= 1000;
+
+    cMin = cSec / 60;
+
+    cSec %= 60;
+
+    /* Put cursor at start of line */
+    printf("%c[s", 0x1B);
+    printf("%c[7000D", 0x1B);
+    printf("%c[1C", 0x1B);
+    printf(FWHITE"[" FYELLOW "%03d" FRED "." FBLUE "%02d" FRED "." FGREEN "%03lld" FWHITE "]" CNORMAL, cMin, cSec,
+           cMSec);
+    printf("%c[u", 0x1B);
 }
+
 #endif /* TIME_STAMP_LOG */
 
 void log_real(int level, char *user, char *fmt, ...)
 {
-   /* The LOG_PANIC must always be displayed */
-   if ((level <= MAX_DEBUG_LEVEL) || (level <= LOG_PANIC))
-   {
-      va_list va;
-
-      switch(level)
-      {
-      case LOG_PANIC: printf(BRED FWHITE); break;
-      case LOG_ERROR:  printf(FRED); break;
-      case LOG_WARNING: printf(FYELLOW); break;
-      default:
-      case LOG_NORMAL: printf(FGREEN); break;
-      case LOG_VERBOSE: printf(FCYAN); break;
-      case LOG_DEBUG: printf(BBLUE FWHITE); break;
-      }
+    /* The LOG_PANIC must always be displayed */
+    if ((level <= MAX_DEBUG_LEVEL) || (level <= LOG_PANIC))
+    {
+        va_list va;
+
+        switch (level)
+        {
+        case LOG_PANIC:
+            printf(BRED FWHITE);
+            break;
+        case LOG_ERROR:
+            printf(FRED);
+            break;
+        case LOG_WARNING:
+            printf(FYELLOW);
+            break;
+        default:
+        case LOG_NORMAL:
+            printf(FGREEN);
+            break;
+        case LOG_VERBOSE:
+            printf(FCYAN);
+            break;
+        case LOG_DEBUG:
+            printf(BBLUE FWHITE);
+            break;
+        }
 
 #ifdef TIME_STAMP_LOG
-      printf("           ");
+        printf("           ");
 #endif
 
-      if (user != NULL)
-      {
-         int i;
-         i = strlen(user);
-         if (i < 12)
-         {
-            i = 12 - i;
-            for (; i >= 0; i--)
-               putchar(' ');
-         }
-         printf("%s", user);
-      }
-      else
-      {
-         switch(level)
-         {     
-         case LOG_PANIC:   printf("   PANIC"); break;
-         case LOG_ERROR:   printf("   Error"); break;
-         case LOG_WARNING: printf(" Warning"); break;
-         default:
-         case LOG_NORMAL:  printf("    Info"); break;
-         case LOG_VERBOSE: printf(" Verbose"); break;
-         case LOG_DEBUG:   printf("   Debug"); break;
-         }
-      }
-      
-      printf(CNORMAL ": ");
+        if (user != NULL)
+        {
+            int i;
+            i = strlen(user);
+            if (i < 12)
+            {
+                i = 12 - i;
+                for (; i >= 0 ; i--)
+                {
+                    putchar(' ');
+                }
+            }
+            printf("%s", user);
+        }
+        else
+        {
+            switch (level)
+            {
+            case LOG_PANIC:
+                printf("   PANIC");
+                break;
+            case LOG_ERROR:
+                printf("   Error");
+                break;
+            case LOG_WARNING:
+                printf(" Warning");
+                break;
+            default:
+            case LOG_NORMAL:
+                printf("    Info");
+                break;
+            case LOG_VERBOSE:
+                printf(" Verbose");
+                break;
+            case LOG_DEBUG:
+                printf("   Debug");
+                break;
+            }
+        }
+
+        printf(CNORMAL ": ");
 
 #ifdef TIME_STAMP_LOG
-         time_stamp_line();
+        time_stamp_line();
 #endif /* TIME_STAMP_LOG */
 
-      va_start(va, fmt);
-      vprintf(fmt, va);
-      va_end(va);
+        va_start(va, fmt);
+        vprintf(fmt, va);
+        va_end(va);
 
-      if (fmt[0] != 0)
-      {      
-         printf("\n");
-      }
-   }
+        if (fmt[0] != 0)
+        {
+            printf("\n");
+        }
+    }
 }

File diff suppressed because it is too large
+ 598 - 582
src/main.c


+ 1 - 1
src/mappersmanager/CMakeLists.txt

@@ -1,7 +1,7 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
+# Created by Manoël TRAPIER.
 # Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$

+ 39 - 37
src/mappersmanager/manager.c

@@ -2,7 +2,7 @@
  *  Mapper manager - The peTI-NESulator Project
  *  manager.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -14,53 +14,55 @@
 
 #include <os_dependent.h>
 
-MapperIRQ       mapper_irqloop;
-MapperDump      mapper_dump;
+MapperIRQ mapper_irqloop;
+MapperDump mapper_dump;
 MapperWriteHook mapper_hook;
 
 typedef struct Mapper_
-{   
-   uint8_t id;
-   char *name;
+{
+    uint8_t id;
+    char *name;
 
-   MapperInit      init;
-   MapperIRQ       irq;
-   MapperDump      dump;
+    MapperInit init;
+    MapperIRQ irq;
+    MapperDump dump;
 
 } Mapper;
 
 #include "mappers_list.h"
 
-void mapper_list ()
+void mapper_list()
 {
-   Mapper *ptr = &(Mappers[0]);
-   console_printf(Console_Default, "Available mapers:\n");
-   while(ptr->name != NULL)
-   {
-      console_printf(Console_Default, "%d - %s\n", ptr->id, ptr->name);
-      ptr++;
-   }
+    Mapper *ptr = &(Mappers[0]);
+    console_printf(Console_Default, "Available mappers:\n");
+    while (ptr->name != NULL)
+    {
+        console_printf(Console_Default, "%d - %s\n", ptr->id, ptr->name);
+        ptr++;
+    }
 }
 
-int mapper_init (NesCart *cart)
+int mapper_init(NesCart *cart)
 {
-   Mapper *ptr = &(Mappers[0]);
-   console_printf (Console_Default, "Search for a compatible mapper ID #%d:\n", cart->MapperID);
-   while (ptr->name != NULL)
-   {
-      if (ptr->id == cart->MapperID)
-      {
-         console_printf (Console_Default, "Found mapper ID #%d - '%s'\n", ptr->id, ptr->name);
-         if (ptr->init)
-            ptr->init (cart);
-         
-         mapper_irqloop = ptr->irq;
-         mapper_dump    = ptr->dump;
-         
-         return 0;
-      }
-      ptr++;
-   }
-   console_printf (Console_Default, "No compatible mapper found!\n");
-   return -1;
+    Mapper *ptr = &(Mappers[0]);
+    console_printf(Console_Default, "Search for a compatible mapper ID #%d:\n", cart->MapperID);
+    while (ptr->name != NULL)
+    {
+        if (ptr->id == cart->MapperID)
+        {
+            console_printf(Console_Default, "Found mapper ID #%d - '%s'\n", ptr->id, ptr->name);
+            if (ptr->init)
+            {
+                ptr->init(cart);
+            }
+
+            mapper_irqloop = ptr->irq;
+            mapper_dump = ptr->dump;
+
+            return 0;
+        }
+        ptr++;
+    }
+    console_printf(Console_Default, "No compatible mapper found!\n");
+    return -1;
 }

+ 25 - 21
src/mappersmanager/mappers/aorom.c

@@ -2,7 +2,7 @@
  *  AOROM Mapper - The peTI-NESulator Project
  *  aorom.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -15,46 +15,50 @@ void aorom_MapperWriteHook(register uint8_t Addr, register uint8_t Value);
 
 extern uint8_t *ppu_mem_nameTables;
 
-int aorom_InitMapper(NesCart * cart) 
-{    
+int aorom_InitMapper(NesCart *cart)
+{
     int i;
-    
-    set_prom_bank_32k(0x8000,0);
-  
+
+    set_prom_bank_32k(0x8000, 0);
+
     ppu_setScreenMode(PPU_SCMODE_SINGLE);
-    
+
     aorom_load_bank = 0;
 
     /* Register the write hook */
-    for (i = 0x80; i < 0x100; i++)
+    for (i = 0x80 ; i < 0x100 ; i++)
     {
         set_page_wr_hook(i, aorom_MapperWriteHook);
         set_page_writeable(i, true);
     }
-    
+
 
     return 0;
-    
-} 
+
+}
 
 void aorom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
 {
     int BankNb;
 
-        if (Value & (1 << 4))
-            ppu_setSingleScreen(PPU_SCREEN_000);
-        else
-            ppu_setSingleScreen(PPU_SCREEN_400);
+    if (Value & (1 << 4))
+    {
+        ppu_setSingleScreen(PPU_SCREEN_000);
+    }
+    else
+    {
+        ppu_setSingleScreen(PPU_SCREEN_400);
+    }
 
-        BankNb = Value & 0x0F;
+    BankNb = Value & 0x0F;
 
-        aorom_load_bank = BankNb;
+    aorom_load_bank = BankNb;
 
-        //console_printf(Console_Default, "aorom: Asking bank %d - NT is 0x%04X\n",BankNb,(Value&0x10)?0x2400:0x2000);
-        set_prom_bank_32k(0x8000,BankNb);
-} 
+    //console_printf(Console_Default, "aorom: Asking bank %d - NT is 0x%04X\n",BankNb,(Value&0x10)?0x2400:0x2000);
+    set_prom_bank_32k(0x8000, BankNb);
+}
 
 void aorom_MapperDump(FILE *fp)
 {
-    fprintf(fp,"aorom: bank:%d\n",aorom_load_bank);
+    fprintf(fp, "aorom: bank:%d\n", aorom_load_bank);
 }

+ 3 - 2
src/mappersmanager/mappers/aorom.h

@@ -2,13 +2,14 @@
  *  AOROM Mapper - The peTI-NESulator Project
  *  aorom.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
-int aorom_InitMapper(NesCart * cart);
+int aorom_InitMapper(NesCart *cart);
 void aorom_MapperDump(FILE *fp);

+ 11 - 11
src/mappersmanager/mappers/cnrom.c

@@ -2,7 +2,7 @@
  *  CNROM Mapper - The peTI-NESulator Project
  *  cnrom.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -13,32 +13,32 @@ uint8_t cnrom_load_bank;
 
 void cnrom_MapperWriteHook(register uint8_t Addr, register uint8_t Value);
 
-int cnrom_InitMapper(NesCart * cart) 
+int cnrom_InitMapper(NesCart *cart)
 {
     int i;
-    
-    set_prom_bank_16k(0x8000,  0);
+
+    set_prom_bank_16k(0x8000, 0);
     set_prom_bank_16k(0xC000, GETLAST16KBANK(cart)); /* Set the last one */
     cnrom_load_bank = 0;
-    
+
     /* Register the write hook */
-    for (i = 0x80; i < 0x100; i++)
+    for (i = 0x80 ; i < 0x100 ; i++)
     {
         set_page_wr_hook(i, cnrom_MapperWriteHook);
         set_page_writeable(i, true);
     }
-    
+
     return 0;
-} 
+}
 
 
 void cnrom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
 {
-    set_prom_bank_16k(0x8000,Value);
+    set_prom_bank_16k(0x8000, Value);
     cnrom_load_bank = Value;
 }
- 
+
 void cnrom_MapperDump(FILE *fp)
 {
-    fprintf(fp,"cnrom: bank:%d\n",cnrom_load_bank);
+    fprintf(fp, "cnrom: bank:%d\n", cnrom_load_bank);
 }

+ 3 - 2
src/mappersmanager/mappers/cnrom.h

@@ -2,13 +2,14 @@
  *  CNROM Mapper - The peTI-NESulator Project
  *  cnrom.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
-int cnrom_InitMapper(NesCart * cart);
+int cnrom_InitMapper(NesCart *cart);
 void cnrom_MapperDump(FILE *fp);

+ 2 - 2
src/mappersmanager/mappers/genericmapper.c.template

@@ -2,8 +2,8 @@
  *  Generic mapper implementation - The peTI-NESulator Project
  *  genericmapper.h
  *
- *  Created by Manoel TRAPIER.
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
+ *  Created by Manoël TRAPIER.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
  

+ 73 - 73
src/mappersmanager/mappers/iremh3001.c

@@ -2,7 +2,7 @@
  *  IREMH3001 Mapper - The peTI-NESulator Project
  *  iremh3001.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -13,17 +13,17 @@ uint16_t iremh3001_prom_slot[3];
 
 uint16_t iremh3001_vrom_slot[8];
 
-int iremh3001_InitMapper(NesCart * cart) 
+int iremh3001_InitMapper(NesCart *cart)
 {
-    
+
     set_prom_bank_16k(0x8000, 0);
     set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
-    
+
     iremh3001_prom_slot[0] = 0;
     iremh3001_prom_slot[1] = 1;
     iremh3001_prom_slot[2] = GETLAST16KBANK(cart);
 
-    set_vrom_bank_8k(0x0000,4);
+    set_vrom_bank_8k(0x0000, 4);
 
     iremh3001_vrom_slot[0] = 0;
     iremh3001_vrom_slot[1] = 0;
@@ -35,88 +35,88 @@ int iremh3001_InitMapper(NesCart * cart)
     iremh3001_vrom_slot[7] = 0;
 
     return 0;
-    
-} 
+
+}
 
 int iremh3001_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
 {
 #if 0
-  switch(Addr)
-  {
-  case 0x8000: /* Set 8k PROM @ 8000 */
-    console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
-    set_prom_bank_8k(0x8000, Value);
-    iremh3001_prom_slot[0] = Value;
-    break;
-
-  case 0x9003: /* Mirroring ??? */
-    console_printf(Console_Default, "iremh3001: Mirroring[0x%X:%d] ?\n", Value, Value);
-    break;
-
-  case 0x9005: /* IRQ ??? */
-    console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
-    break;
-
-  case 0x9006: /* IRQ ??? */
-    console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
-    break;
-
-  case 0xA000: /* Set 8k PROM @ A000 */
-    console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
-    set_prom_bank_8k(0xA000, Value);
-    iremh3001_prom_slot[1] = Value;
-    break;
-
-  case 0xB000: /* Set 1k VROM @ 0000 */
-  case 0xB001: /* Set 1k VROM @ 0400 */
-  case 0xB002: /* Set 1k VROM @ 0800 */
-  case 0xB003: /* Set 1k VROM @ 0C00 */
-  case 0xB004: /* Set 1k VROM @ 1000 */
-  case 0xB005: /* Set 1k VROM @ 1400 */
-  case 0xB006: /* Set 1k VROM @ 1800 */
-  case 0xB007: /* Set 1k VROM @ 1C00 */
-    console_printf(Console_Default, "iremh3001: %X: change VROM to %d[%X]\n", (Addr&0x0F)<<10, Value, Value);
-    set_vrom_bank_1k((Addr&0xF)<<10, Value);
-    iremh3001_vrom_slot[Addr&0x0F] = Value;
-    break;
-
-  case 0xC000: /* Set 8k PROM @ C000 */
-    console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
-    set_prom_bank_8k(0xC000, Value);
-    iremh3001_prom_slot[2] = Value;
-    break;
-
-  default:
-    console_printf(Console_Default, "@:%X -- V:%X", Addr, Value);
-    return 0;
-
-  }
+    switch(Addr)
+    {
+    case 0x8000: /* Set 8k PROM @ 8000 */
+      console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
+      set_prom_bank_8k(0x8000, Value);
+      iremh3001_prom_slot[0] = Value;
+      break;
+
+    case 0x9003: /* Mirroring ??? */
+      console_printf(Console_Default, "iremh3001: Mirroring[0x%X:%d] ?\n", Value, Value);
+      break;
+
+    case 0x9005: /* IRQ ??? */
+      console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
+      break;
+
+    case 0x9006: /* IRQ ??? */
+      console_printf(Console_Default, "iremh3001: IRQ[0x%X:%d] ?\n", Value, Value);
+      break;
+
+    case 0xA000: /* Set 8k PROM @ A000 */
+      console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
+      set_prom_bank_8k(0xA000, Value);
+      iremh3001_prom_slot[1] = Value;
+      break;
+
+    case 0xB000: /* Set 1k VROM @ 0000 */
+    case 0xB001: /* Set 1k VROM @ 0400 */
+    case 0xB002: /* Set 1k VROM @ 0800 */
+    case 0xB003: /* Set 1k VROM @ 0C00 */
+    case 0xB004: /* Set 1k VROM @ 1000 */
+    case 0xB005: /* Set 1k VROM @ 1400 */
+    case 0xB006: /* Set 1k VROM @ 1800 */
+    case 0xB007: /* Set 1k VROM @ 1C00 */
+      console_printf(Console_Default, "iremh3001: %X: change VROM to %d[%X]\n", (Addr&0x0F)<<10, Value, Value);
+      set_vrom_bank_1k((Addr&0xF)<<10, Value);
+      iremh3001_vrom_slot[Addr&0x0F] = Value;
+      break;
+
+    case 0xC000: /* Set 8k PROM @ C000 */
+      console_printf(Console_Default, "iremh3001: %X: change PROM to %d[%X]\n", Addr, Value, Value);
+      set_prom_bank_8k(0xC000, Value);
+      iremh3001_prom_slot[2] = Value;
+      break;
+
+    default:
+      console_printf(Console_Default, "@:%X -- V:%X", Addr, Value);
+      return 0;
+
+    }
 #endif
-  return 1;
-} 
+    return 1;
+}
 
 void iremh3001_MapperDump(FILE *fp)
 {
-    fprintf(fp,"iremh3001: prom: $8000:%d $A000:%d $C000:%d\n",
-        iremh3001_prom_slot[0], 
-        iremh3001_prom_slot[1],
-        iremh3001_prom_slot[2]);
+    fprintf(fp, "iremh3001: prom: $8000:%d $A000:%d $C000:%d\n",
+            iremh3001_prom_slot[0],
+            iremh3001_prom_slot[1],
+            iremh3001_prom_slot[2]);
 
-    fprintf(fp,"iremh3001: vrom: $0000:%d $0400:%d $0800:%d $0C00:%d\n" \
+    fprintf(fp, "iremh3001: vrom: $0000:%d $0400:%d $0800:%d $0C00:%d\n" \
            "                 $1000:%d $1400:%d $1800:%d $1C00:%d\n",
-        iremh3001_vrom_slot[0], 
-        iremh3001_vrom_slot[1],
-        iremh3001_vrom_slot[2], 
-        iremh3001_vrom_slot[3],
-        iremh3001_vrom_slot[4], 
-        iremh3001_vrom_slot[5],
-        iremh3001_vrom_slot[6],
-        iremh3001_vrom_slot[7]);
+            iremh3001_vrom_slot[0],
+            iremh3001_vrom_slot[1],
+            iremh3001_vrom_slot[2],
+            iremh3001_vrom_slot[3],
+            iremh3001_vrom_slot[4],
+            iremh3001_vrom_slot[5],
+            iremh3001_vrom_slot[6],
+            iremh3001_vrom_slot[7]);
 }
 
 
 int iremh3001_MapperIRQ(int cycledone)
 {
 
-  return 0;
+    return 0;
 }

+ 3 - 2
src/mappersmanager/mappers/iremh3001.h

@@ -2,14 +2,15 @@
  *  IREMH3001 Mapper - The peTI-NESulator Project
  *  iremh3001.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
-int iremh3001_InitMapper(NesCart * cart);
+int iremh3001_InitMapper(NesCart *cart);
 void iremh3001_MapperDump(FILE *fp);
 int iremh3001_MapperIRQ(int cycledone);

+ 123 - 116
src/mappersmanager/mappers/mmc1.c

@@ -2,7 +2,7 @@
  *  MMC1 Mapper - The peTI-NESulator Project
  *  mmc1.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -39,10 +39,10 @@ uint8_t mmc1_CurrentBank;
 #define MMC1_R3_RESET     0x80
 
 
-#define MMC1_REG0_DEFAULT MMC1_R0_PRGSIZE | MMC1_R0_PRGAREA
-#define MMC1_REG1_DEFAULT 0
-#define MMC1_REG2_DEFAULT 0
-#define MMC1_REG3_DEFAULT 0
+#define MMC1_REG0_DEFAULT (MMC1_R0_PRGSIZE | MMC1_R0_PRGAREA)
+#define MMC1_REG1_DEFAULT (0)
+#define MMC1_REG2_DEFAULT (0)
+#define MMC1_REG3_DEFAULT (0)
 
 void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value);
 void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value);
@@ -51,55 +51,57 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value);
 
 void mmc1_MapperDump(FILE *fp)
 {
-    fprintf(fp,"MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n",MMC1_reg0,MMC1_reg1,MMC1_reg2,MMC1_reg3);
+    fprintf(fp, "MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n", MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
 }
 
-int mmc1_InitMapper(NesCart * cart) 
+int mmc1_InitMapper(NesCart *cart)
 {
     int i;
-    
-       MMC1_reg0 = MMC1_REG0_DEFAULT;
-       
-       MMC1_reg1 = MMC1_REG1_DEFAULT;
-       
-       MMC1_reg2 = MMC1_REG2_DEFAULT;
-       
-       MMC1_reg3 = MMC1_REG3_DEFAULT;
-        
-       set_prom_bank_16k(0x8000,0);
-       set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
-       
-       mmc1_CurrentBank = 0;
-       
-       if (cart->VROMSize > 0)
-           set_vrom_bank_4k(0x0000,0);
-
-       
-       /* Mapper should register itself for write hook */
-    for (i = 0x80; i < 0xA0 ; i++)
+
+    MMC1_reg0 = MMC1_REG0_DEFAULT;
+
+    MMC1_reg1 = MMC1_REG1_DEFAULT;
+
+    MMC1_reg2 = MMC1_REG2_DEFAULT;
+
+    MMC1_reg3 = MMC1_REG3_DEFAULT;
+
+    set_prom_bank_16k(0x8000, 0);
+    set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
+
+    mmc1_CurrentBank = 0;
+
+    if (cart->VROMSize > 0)
+    {
+        set_vrom_bank_4k(0x0000, 0);
+    }
+
+
+    /* Mapper should register itself for write hook */
+    for (i = 0x80 ; i < 0xA0 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg0);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xA0; i < 0xC0 ; i++)
+        set_page_wr_hook(i, mmc1_MapperWriteReg0);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xA0 ; i < 0xC0 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg1);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xC0; i < 0xE0 ; i++)
+        set_page_wr_hook(i, mmc1_MapperWriteReg1);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xC0 ; i < 0xE0 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg2);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xE0; i < 0x100 ; i++)
+        set_page_wr_hook(i, mmc1_MapperWriteReg2);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xE0 ; i < 0x100 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg3);
-       set_page_writeable(i, true);       
+        set_page_wr_hook(i, mmc1_MapperWriteReg3);
+        set_page_writeable(i, true);
     }
-    
+
     return 0;
-       
-} 
+
+}
 
 
 /*
@@ -120,24 +122,26 @@ Reg 0
             F : 1111
             
               ((Addr & 0x6000) >> 13) <- port number
-*/ 
-#define MMC1_GetReg(a) ((a & 0x6000) >> 13)
-/* (Val & 0x01) recuperation du bit */ 
-#define MMC1_GetBit(v) (v & 0x01)
-/* ( ( b & (1 << Bit)) | (v << Bit) ) Ajout du bit */ 
-#define MMC1_AddBit(b,v) ( ( b & ~(1 << Bit)) | (v << Bit) )
-
-void mmc1_ApplyReg0Mod() 
+*/
+
+#define MMC1_GetReg(_a) (((_a) & 0x6000) >> 13)
+/* (Val & 0x01) recuperation du bit */
+#define MMC1_GetBit(_v) ((_v) & 0x01)
+/* ( ( b & (1 << Bit)) | (v << Bit) ) Ajout du bit */
+#define MMC1_AddBit(_b, _v) ( ( (_b) & ~(1 << Bit)) | ( (_v) << Bit) )
+
+void mmc1_ApplyReg0Mod()
 {
-    
+
     static uint8_t OldSwitchArea = MMC1_R0_PRGAREA;
-    
-    
-       
+
+
+
     //console_printf(Console_Default, "Change to reg0 done ! (0x%x)\n\tMiror flag : %d\n\tOneScreen Flag : %d\n\tPRG Size : %d\n\tPRG Area : %d\n\tVROM Switch size : %d\n", MMC1_reg0, MMC1_reg0 & MMC1_R0_MIRROR, MMC1_reg0 & MMC1_R0_ONESCREEN, MMC1_reg0 & MMC1_R0_PRGAREA, MMC1_reg0 & MMC1_R0_PRGSIZE, MMC1_reg0 & MMC1_R0_VROMSW);
-        
+
     switch (MMC1_reg0 & 0x03)
     {
+    default:
     case 0:
         ppu_setScreenMode(PPU_SCMODE_SINGLE);
         ppu_setSingleScreen(PPU_SCREEN_000);
@@ -155,27 +159,27 @@ void mmc1_ApplyReg0Mod()
         ppu_setMirroring(PPU_MIRROR_HORIZTAL);
         break;
     }
-       
-    if ( (OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 ) )
+
+    if ((OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0))
     {
-           
+
         if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
         {        /* 0x8000 area */
-            set_prom_bank_16k(0x8000,mmc1_CurrentBank);
+            set_prom_bank_16k(0x8000, mmc1_CurrentBank);
             set_prom_bank_16k(0xC000, GETLAST16KBANK(Cart));
-        } 
+        }
         else
         {        /* 0xC000 area */
-    
-            set_prom_bank_16k(0x8000,0);
-            set_prom_bank_16k(0xC000,mmc1_CurrentBank);
 
-        } 
-           
+            set_prom_bank_16k(0x8000, 0);
+            set_prom_bank_16k(0xC000, mmc1_CurrentBank);
+
+        }
+
         OldSwitchArea = (MMC1_reg0 & MMC1_R0_PRGAREA);
     }
-       
-} 
+
+}
 
 uint32_t VROMBankNb;
 uint8_t Bit = 0;
@@ -183,10 +187,10 @@ uint8_t BitBuf = 0;
 
 void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg0 = MMC1_REG0_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg0 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg0 Reset occurred !\n");
         mmc1_ApplyReg0Mod();
     }
     else
@@ -195,25 +199,25 @@ void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
         {        /* Pas encore ecrit les 5 bits  */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
-            
+
             MMC1_reg0 = BitBuf;
-            
+
             mmc1_ApplyReg0Mod();
         }
-    }               
+    }
 }
 
 void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg1 = MMC1_REG1_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg1 Reset occurred !\n");
     }
     else
     {
@@ -221,31 +225,32 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
         {        /* Pas encore ecrit les 5 bits  */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
-            
+
             MMC1_reg1 = BitBuf;
-                        
+
             VROMBankNb = (MMC1_reg1 /* & MMC1_R1_VROMB1 */ );
 
             if (Cart->VROMSize == 0)
             {
-                console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n", VROMBankNb);
+                console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n",
+                               VROMBankNb);
                 return;
             }
-                
-            if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
+
+            if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
             {    /* 4K vram */
                 //console_printf(Console_Default, "Switching VROM at 0x0000 to 4k bank %d\n", VROMBankNb);
-                set_vrom_bank_4k(0x0000,VROMBankNb);
+                set_vrom_bank_4k(0x0000, VROMBankNb);
             }
             else
             {    /* 8K vram */
                 //console_printf(Console_Default, "Switching VROM at 0x0000 to 8k bank %d\n", VROMBankNb>>1);
-                set_vrom_bank_8k(0x0000,VROMBankNb>>1);
+                set_vrom_bank_8k(0x0000, VROMBankNb >> 1);
             }
         }
     }
@@ -253,10 +258,10 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
 
 void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg2 = MMC1_REG2_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg2 Reset occurred !\n");
     }
     else
     {
@@ -264,32 +269,32 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
         {        /* Pas encore ecrit les 5 bits  */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
 
             MMC1_reg2 = BitBuf;
-            
+
             VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
-            
+
             //console_printf(Console_Default, "Want to switch VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
             if (Cart->VROMSize == 0)
             {
                 //console_printf(Console_Default, ": No\n");
                 return;
             }
-            
-            if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
+
+            if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
             {    /* 4K vram */
                 //console_printf(Console_Default, "Switching VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
-                set_vrom_bank_4k(0x1000,VROMBankNb);
+                set_vrom_bank_4k(0x1000, VROMBankNb);
             }
             else
             {    /* 8K vram */
-            //       console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
-            //       set_vrom_bank_8k(0x1000,VROMBankNb>>1);
+                //       console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
+                //       set_vrom_bank_8k(0x1000,VROMBankNb>>1);
             }
         }
     }
@@ -297,10 +302,10 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
 
 void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg3 = MMC1_REG3_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg3 Reset occurred !\n");
     }
     else
     {
@@ -308,36 +313,38 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
         {        /* Pas encore ecrit les 5 bits  */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
-        
+
             MMC1_reg3 = BitBuf;
-            
-            if ( ((uint32_t)MMC1_reg3 << 14) > Cart->PROMSize)
+
+            if (((uint32_t)MMC1_reg3 << 14) > Cart->PROMSize)
+            {
                 return;
-                
-            if ( (MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 )
+            }
+
+            if ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0)
             {    /* 16K Switch */
-                if ( (MMC1_reg0 & MMC1_R0_PRGAREA) != 0 )
+                if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
                 {    /* 0x8000 switch */
-                    set_prom_bank_16k(0x8000,MMC1_reg3);
+                    set_prom_bank_16k(0x8000, MMC1_reg3);
                     //console_printf(Console_Default, "LowBank is now %d ( 0x%p )\n", MMC1_reg3, mLBank);
                 }
                 else
                 {    /* 0xC000 switch */
-                    set_prom_bank_16k(0xC000,MMC1_reg3);
+                    set_prom_bank_16k(0xC000, MMC1_reg3);
                     //console_printf(Console_Default, "HighBank is now %d ( 0x%p )\n", MMC1_reg3, mUBank);
                 }
             }
             else
             {    /* 32K Switch */
-                set_prom_bank_32k(0x8000,MMC1_reg3>>1);
+                set_prom_bank_32k(0x8000, MMC1_reg3 >> 1);
             }
-            
-            if ( ( MMC1_reg3 & MMC1_R3_SAVECE ) != 0)   
+
+            if ((MMC1_reg3 & MMC1_R3_SAVECE) != 0)
             {
                 unmap_sram();
             }
@@ -347,6 +354,6 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
             }
         }
     }
-}    
-        
-        //console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
+}
+
+//console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);

+ 5 - 4
src/mappersmanager/mappers/mmc1.h

@@ -2,14 +2,15 @@
  *  MMC1 Mapper - The peTI-NESulator Project
  *  mmc1.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
-int mmc1_InitMapper  (NesCart *cart);
-int mmc1_MapperIRQ   (int cycledone);
-void mmc1_MapperDump (FILE *fp);
+int mmc1_InitMapper(NesCart *cart);
+int mmc1_MapperIRQ(int cycledone);
+void mmc1_MapperDump(FILE *fp);

+ 219 - 187
src/mappersmanager/mappers/mmc3.c

@@ -2,7 +2,7 @@
  *  MMC3 Mapper - The peTI-NESulator Project
  *  mmc3.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -19,7 +19,7 @@ uint8_t mmc3_irq_enable;
 uint16_t mmc3_first_prom_page;
 uint16_t mmc3_second_prom_page;
 
-uint8_t  mmc3_use_xor;
+uint8_t mmc3_use_xor;
 uint8_t mmc3_last_vrom[6];
 
 uint8_t mmc3_last_prom[2];
@@ -27,186 +27,194 @@ uint8_t mmc3_last_prom_switch;
 
 uint16_t dummy;
 
-void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t value);
-void mmc3_MapperWriteA0Hook(uint8_t addr, uint8_t value);
-void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t value);
-void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t value);
+void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value);
+void mmc3_MapperWriteA0Hook(uint8_t addr, uint8_t Value);
+void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t Value);
+void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t Value);
 
 void mmc3_MapperDump(FILE *fp)
 {
-    fprintf(fp,"MMC3: CMD:%d IC:%d IR:%d IE:%d FPP:0x%04X SPP:0x%04X UX:%d\n",mmc3_command,mmc3_irq_counter,mmc3_irq_counter_reload,mmc3_irq_enable,mmc3_first_prom_page,mmc3_second_prom_page,mmc3_use_xor);
-    fprintf(fp,"MMC3: LV0:%d LV1:%d LV2:%d LV3:%d LV4:%d LV5:%d\n",mmc3_last_vrom[0],mmc3_last_vrom[1],mmc3_last_vrom[2],mmc3_last_vrom[3],mmc3_last_vrom[4],mmc3_last_vrom[5]);
-    fprintf(fp,"MMC3: LP0:%d LP1:%d LPS:%d\n",mmc3_last_prom[0],mmc3_last_prom[1],mmc3_last_prom_switch);
+    fprintf(fp, "MMC3: CMD:%d IC:%d IR:%d IE:%d FPP:0x%04X SPP:0x%04X UX:%d\n", mmc3_command, mmc3_irq_counter,
+            mmc3_irq_counter_reload, mmc3_irq_enable, mmc3_first_prom_page, mmc3_second_prom_page, mmc3_use_xor);
+    fprintf(fp, "MMC3: LV0:%d LV1:%d LV2:%d LV3:%d LV4:%d LV5:%d\n", mmc3_last_vrom[0], mmc3_last_vrom[1],
+            mmc3_last_vrom[2], mmc3_last_vrom[3], mmc3_last_vrom[4], mmc3_last_vrom[5]);
+    fprintf(fp, "MMC3: LP0:%d LP1:%d LPS:%d\n", mmc3_last_prom[0], mmc3_last_prom[1], mmc3_last_prom_switch);
 }
 
-int mmc3_InitMapper(NesCart * cart) 
+int mmc3_InitMapper(NesCart *cart)
 {
     set_prom_bank_16k(0x8000, 0);
     set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
 
-    if ( Cart->VROMSize > 0)
+    if (Cart->VROMSize > 0)
     {
-         set_vrom_bank_8k(0, 0x0000);
+        set_vrom_bank_8k(0, 0x0000);
     }
-    
+
     mmc3_command = -1;
 
     mmc3_irq_counter = -1;
     mmc3_irq_enable = 0;
     mmc3_irq_counter_reload = 0;
-    
+
     mmc3_use_xor = 0x42;
-    
+
     mmc3_last_prom_switch = 0x42;
-    
+
     mmc3_last_prom[0] = 0;
     mmc3_last_prom[1] = 1;
-    
+
     mmc3_last_vrom[0] = 0;
     mmc3_last_vrom[1] = 2;
     mmc3_last_vrom[2] = 3;
     mmc3_last_vrom[3] = 4;
     mmc3_last_vrom[4] = 5;
     mmc3_last_vrom[5] = 6;
-    
+
     mmc3_first_prom_page = 0x8000;
-    mmc3_second_prom_page = 0xA000; 
-    
+    mmc3_second_prom_page = 0xA000;
+
     /* Register mapper write hook */
     set_page_wr_hook(0x80, mmc3_MapperWrite80Hook);
     set_page_writeable(0x80, true);
-    
+
     set_page_wr_hook(0xA0, mmc3_MapperWriteA0Hook);
     set_page_writeable(0xA0, true);
-    
+
     set_page_wr_hook(0xC0, mmc3_MapperWriteC0Hook);
     set_page_writeable(0xC0, true);
-    
+
     set_page_wr_hook(0xE0, mmc3_MapperWriteE0Hook);
     set_page_writeable(0xE0, true);
 
     return 0;
-} 
+}
 
 void mmc3_MapperWrite80Hook(uint8_t addr, uint8_t Value)
 {
     //console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
     if (addr > 0x01)
+    {
         return;
+    }
 
     if (!addr)
     {
 
-        if ((Cart->VROMSize > 0) && ( mmc3_use_xor != (Value & 0x80) ))
+        if ((Cart->VROMSize > 0) && (mmc3_use_xor != (Value & 0x80)))
         {
-    		if (Value & 0x80)
-    		{
-    			set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
-    			set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
-    			set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
-    			set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
-    			set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
-    			set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
-    			//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
-    		}
-    		else
-    		{
-    		    set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
-    			set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
-    			set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
-    			set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
-    			set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
-    			set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
-    			//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
-    		}
-   			mmc3_use_xor = (Value & 0x80);
-    	}
-    	
-		
-		if (mmc3_last_prom_switch != (Value & 0x40))
-		{
-    		if (!(Value & 0x40))
-    		{
-              console_printf(Console_Default, "MMC3: Switch -> 8/A\n");
-    		    mmc3_first_prom_page = 0x8000;
-    		    mmc3_second_prom_page = 0xA000;
-    		    
-    		    set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
-    		    set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
-    		    
-    		    set_prom_bank_8k(0xC000, GETLAST08KBANK(Cart)-1);
-    		    //set_prom_bank_8k(0xE000, GETLAST08KBANK(cart));
-    			//prg_bank(prg0,prg1,max_prg-1,max_prg);
-    		}
-    		else
-    		{
-    		    console_printf(Console_Default, "MMC3: Switch -> C/A\n");
-    		    mmc3_first_prom_page = 0xC000;
-    		    mmc3_second_prom_page = 0xA000;
-    		
-    		    set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
-    		    set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
-    		    
-    		    set_prom_bank_8k(0x8000, GETLAST08KBANK(Cart)-1);
-    
-        	
-    			//prg_bank(max_prg-1,prg1,prg0,max_prg);
-    		}
-          mmc3_last_prom_switch = (Value & 0x40);	
-    	}
-     mmc3_command = Value & 0x07;
-		
-		
-
-    } else { /* 8001 */
-		switch (mmc3_command)
-		{
-		case 0: 
-		case 1: 
-		case 2:
-		case 3: 
-		case 4: 
-		case 5:  
-		    if (Cart->VROMSize == 0)
-		        return;
-
-		    mmc3_last_vrom[mmc3_command] = Value;
-		    
-		    if (mmc3_use_xor)
-    		{
-    			set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
-    			set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
-    			set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
-    			set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
-    			set_vrom_bank_2k(0x1000, mmc3_last_vrom[0]>>1);
-    			set_vrom_bank_2k(0x1800, mmc3_last_vrom[1]>>1);
-    			//chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
-    		}
-    		else
-    		{
-    		    set_vrom_bank_2k(0x0000, mmc3_last_vrom[0]>>1);
-    			set_vrom_bank_2k(0x0800, mmc3_last_vrom[1]>>1);
-    			set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
-    			set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
-    			set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
-    			set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
-    			//chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
-    		}
-		    
-			break;
-			
-		case 6: 
-		    mmc3_last_prom[0] = Value;
+            if (Value & 0x80)
+            {
+                set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
+                set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
+                set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
+                set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
+                set_vrom_bank_2k(0x1000, mmc3_last_vrom[0] >> 1);
+                set_vrom_bank_2k(0x1800, mmc3_last_vrom[1] >> 1);
+                //chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
+            }
+            else
+            {
+                set_vrom_bank_2k(0x0000, mmc3_last_vrom[0] >> 1);
+                set_vrom_bank_2k(0x0800, mmc3_last_vrom[1] >> 1);
+                set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
+                set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
+                set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
+                set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
+                //chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
+            }
+            mmc3_use_xor = (Value & 0x80);
+        }
+
+
+        if (mmc3_last_prom_switch != (Value & 0x40))
+        {
+            if (!(Value & 0x40))
+            {
+                console_printf(Console_Default, "MMC3: Switch -> 8/A\n");
+                mmc3_first_prom_page = 0x8000;
+                mmc3_second_prom_page = 0xA000;
+
+                set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
+                set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
+
+                set_prom_bank_8k(0xC000, GETLAST08KBANK(Cart) - 1);
+                //set_prom_bank_8k(0xE000, GETLAST08KBANK(cart));
+                //prg_bank(prg0,prg1,max_prg-1,max_prg);
+            }
+            else
+            {
+                console_printf(Console_Default, "MMC3: Switch -> C/A\n");
+                mmc3_first_prom_page = 0xC000;
+                mmc3_second_prom_page = 0xA000;
+
+                set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
+                set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
+
+                set_prom_bank_8k(0x8000, GETLAST08KBANK(Cart) - 1);
+
+
+                //prg_bank(max_prg-1,prg1,prg0,max_prg);
+            }
+            mmc3_last_prom_switch = (Value & 0x40);
+        }
+        mmc3_command = Value & 0x07;
+
+
+    }
+    else
+    { /* 8001 */
+        switch (mmc3_command)
+        {
+        default:
+        case 0:
+        case 1:
+        case 2:
+        case 3:
+        case 4:
+        case 5:
+            if (Cart->VROMSize == 0)
+            {
+                return;
+            }
+
+            mmc3_last_vrom[mmc3_command] = Value;
+
+            if (mmc3_use_xor)
+            {
+                set_vrom_bank_1k(0x0000, mmc3_last_vrom[2]);
+                set_vrom_bank_1k(0x0400, mmc3_last_vrom[3]);
+                set_vrom_bank_1k(0x0800, mmc3_last_vrom[4]);
+                set_vrom_bank_1k(0x0C00, mmc3_last_vrom[5]);
+                set_vrom_bank_2k(0x1000, mmc3_last_vrom[0] >> 1);
+                set_vrom_bank_2k(0x1800, mmc3_last_vrom[1] >> 1);
+                //chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1
+            }
+            else
+            {
+                set_vrom_bank_2k(0x0000, mmc3_last_vrom[0] >> 1);
+                set_vrom_bank_2k(0x0800, mmc3_last_vrom[1] >> 1);
+                set_vrom_bank_1k(0x1000, mmc3_last_vrom[2]);
+                set_vrom_bank_1k(0x1400, mmc3_last_vrom[3]);
+                set_vrom_bank_1k(0x1800, mmc3_last_vrom[4]);
+                set_vrom_bank_1k(0x1C00, mmc3_last_vrom[5]);
+                //chr01,chr01+1,chr23,chr23+1,chr4,chr5,chr6,chr7
+            }
+
+            break;
+
+        case 6:
+            mmc3_last_prom[0] = Value;
             set_prom_bank_8k(mmc3_first_prom_page, mmc3_last_prom[0]);
-			break;
-			
-		case 7:
-		    mmc3_last_prom[1] = Value;
+            break;
+
+        case 7:
+            mmc3_last_prom[1] = Value;
             set_prom_bank_8k(mmc3_second_prom_page, mmc3_last_prom[1]);
-			break;
-			
-		}
-		
+            break;
+
+        }
+
         /*if(mmc3_use_xor)
     	    chr_bank(chr4,chr5,chr6,chr7,chr01,chr01+1,chr23,chr23+1);
         else
@@ -220,45 +228,59 @@ void mmc3_MapperWriteA0Hook(uint8_t addr, uint8_t Value)
 {
     //console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
     if (addr > 0x01)
+    {
         return;
-    
-    if (!addr)    
-    {    
-      //console_printf(Console_Default, "MMC3: Select mirroring (0xA000) : 0x%X\n",Value);
-      
-      if (Value & 0x1)
-        ppu_setMirroring(PPU_MIRROR_HORIZTAL);
-      else
-        ppu_setMirroring(PPU_MIRROR_VERTICAL);
-
-    } 
+    }
+
+    if (!addr)
+    {
+        //console_printf(Console_Default, "MMC3: Select mirroring (0xA000) : 0x%X\n",Value);
+
+        if (Value & 0x1)
+        {
+            ppu_setMirroring(PPU_MIRROR_HORIZTAL);
+        }
+        else
+        {
+            ppu_setMirroring(PPU_MIRROR_VERTICAL);
+        }
+
+    }
     else
     {
-      //console_printf(Console_Default, "MMC3: SaveRAM Toggle (0xA001) : 0x%X\n",Value);
-      if (Value)
-          map_sram();
-      else
-          unmap_sram();
+        //console_printf(Console_Default, "MMC3: SaveRAM Toggle (0xA001) : 0x%X\n",Value);
+        if (Value)
+        {
+            map_sram();
+        }
+        else
+        {
+            unmap_sram();
+        }
     }
-      
+
 }
 
 void mmc3_MapperWriteC0Hook(uint8_t addr, uint8_t Value)
 {
     //console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
     if (addr > 0x01)
+    {
         return;
-        
+    }
+
     if (!addr)
     {
-     mmc3_irq_counter_reload = Value;
-     mmc3_irq_counter = Value;
-     //console_printf(Console_Default, "MMC3 IRQ[%d]: SetIRQ reload to %d\n", ScanLine, Value);
-     
-    }else{ /* C001 */
-      //console_printf(Console_Default, "MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
-      //console_printf(Console_Default, "MMC3 IRQ[%d]: Reset IRQ counter to val %d [Value = %d]\n", ScanLine, mmc3_irq_counter_reload, Value);
-      mmc3_irq_counter = Value;
+        mmc3_irq_counter_reload = Value;
+        mmc3_irq_counter = Value;
+        //console_printf(Console_Default, "MMC3 IRQ[%d]: SetIRQ reload to %d\n", ScanLine, Value);
+
+    }
+    else
+    { /* C001 */
+        //console_printf(Console_Default, "MMC3: New tmp IRQ value (0xC001) : 0x%X\n",Value);
+        //console_printf(Console_Default, "MMC3 IRQ[%d]: Reset IRQ counter to val %d [Value = %d]\n", ScanLine, mmc3_irq_counter_reload, Value);
+        mmc3_irq_counter = Value;
     }
 }
 
@@ -266,43 +288,53 @@ void mmc3_MapperWriteE0Hook(uint8_t addr, uint8_t Value)
 {
     //console_printf(Console_Default, "%s(0x%02X, 0x%02X)\n", __func__, addr, Value);
     if (addr > 0x01)
+    {
         return;
-        
+    }
+
     if (!addr)
     {
-      //console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
-      //console_printf(Console_Default, "MMC3 IRQ[%d]: IRQ disabled\n", ScanLine);
-      mmc3_irq_enable = 0;
-      //MapperWantIRQ = 1;
-      // Add a way to raise an IRQ
-      
-     }else{ /* E001 */
-      //console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
-      //console_printf(Console_Default, "MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
-      //console_printf(Console_Default, "MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
-      mmc3_irq_enable = 1;
+        //console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
+        //console_printf(Console_Default, "MMC3 IRQ[%d]: IRQ disabled\n", ScanLine);
+        mmc3_irq_enable = 0;
+        //MapperWantIRQ = 1;
+        // Add a way to raise an IRQ
+
+    }
+    else
+    { /* E001 */
+        //console_printf(Console_Default, "MMC3: Writing to 0xE001 : 0x%X\n",Value);
+        //console_printf(Console_Default, "MMC3: IRQ Enabled (value : %d)\n",mmc3_irq_counter);
+        //console_printf(Console_Default, "MMC3 IRQ[%d]: Enable IRQ\nr", ScanLine);
+        mmc3_irq_enable = 1;
     }
 }
 
 int mmc3_MapperIRQ(int cycledone)
 {
- if (((cycledone > 0) && (cycledone < 241)) /*&&
+    if (((cycledone > 0) && (cycledone < 241)) /*&&
       (ppu.ControlRegister2.b & (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)) == (PPU_CR2_BGVISIBILITY | PPU_CR2_SPRTVISIBILITY)*/)
-  {
-
-    if ((mmc3_irq_counter --) > 0 )return 0;   
-    
-    
-    /* Load next counter position */
-    mmc3_irq_counter = mmc3_irq_counter_reload;
-    
-    if (mmc3_irq_enable == 0) return 0;
-    
-    mmc3_irq_enable = 0;
-    
-    //console_printf(Console_Default, "MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
-    
-    return 1;
-  }
-  return 0;
+    {
+
+        if ((mmc3_irq_counter--) > 0)
+        {
+            return 0;
+        }
+
+
+        /* Load next counter position */
+        mmc3_irq_counter = mmc3_irq_counter_reload;
+
+        if (mmc3_irq_enable == 0)
+        {
+            return 0;
+        }
+
+        mmc3_irq_enable = 0;
+
+        //console_printf(Console_Default, "MMC3 IRQ[%d]: Tick next at %d\n", ScanLine, mmc3_irq_counter_reload);
+
+        return 1;
+    }
+    return 0;
 }

+ 3 - 2
src/mappersmanager/mappers/mmc3.h

@@ -2,14 +2,15 @@
  *  MMC3 Mapper - The peTI-NESulator Project
  *  mmc3.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
 void mmc3_MapperDump(FILE *fp);
-int mmc3_InitMapper(NesCart * cart); 
+int mmc3_InitMapper(NesCart *cart);
 int mmc3_MapperIRQ(int cycledone);

+ 49 - 43
src/mappersmanager/mappers/mmc4.c

@@ -2,7 +2,7 @@
  *  MMC4 Mapper - The peTI-NESulator Project
  *  mmc4.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -19,7 +19,7 @@ uint8_t mmc4_RegF;
 #ifdef DEBUG
 #define LOG(s) printf s
 #else
-#define LOG(s) { }  
+#define LOG(s) { }
 #endif
 
 /* MAPPER WARNING: This mapper need to attach to the PPU memory... Need more work on this parts.. */
@@ -28,57 +28,61 @@ void mmc4_MapperWriteRegA(register uint8_t Addr, register uint8_t Value)
 {
     LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
     mmc4_RegA = Value;
-    
+
     set_prom_bank_16k(0x8000, Value & 0x0F);
-    
+
 }
 
 void mmc4_MapperWriteRegB(register uint8_t Addr, register uint8_t Value)
 {
     LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
-    mmc4_RegB = Value;    
-    
+    mmc4_RegB = Value;
+
     set_vrom_bank_4k(0x0000, Value & 0x1F);
 }
 
 void mmc4_MapperWriteRegC(register uint8_t Addr, register uint8_t Value)
 {
     LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
-    mmc4_RegC = Value;    
+    mmc4_RegC = Value;
     set_vrom_bank_4k(0x0000, Value & 0x1F);
 }
 
 void mmc4_MapperWriteRegD(register uint8_t Addr, register uint8_t Value)
 {
     LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
-    mmc4_RegD = Value;    
+    mmc4_RegD = Value;
     set_vrom_bank_4k(0x1000, Value & 0x1F);
 }
 
 void mmc4_MapperWriteRegE(register uint8_t Addr, register uint8_t Value)
 {
     LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
-    mmc4_RegE = Value;  
-    set_vrom_bank_4k(0x1000, Value & 0x1F);  
+    mmc4_RegE = Value;
+    set_vrom_bank_4k(0x1000, Value & 0x1F);
 }
 
 void mmc4_MapperWriteRegF(register uint8_t Addr, register uint8_t Value)
 {
     LOG(("%s(%02X, %02X)\n", __func__, Addr, Value));
-    mmc4_RegF = Value;    
+    mmc4_RegF = Value;
     if (Value & 0x01)
+    {
         ppu_setMirroring(PPU_MIRROR_HORIZTAL);
+    }
     else
+    {
         ppu_setMirroring(PPU_MIRROR_VERTICAL);
+    }
 }
 
 
 void mmc4_MapperDump(FILE *fp)
 {
-    
+
 }
 
-int mmc4_InitMapper(NesCart * cart) 
+int mmc4_InitMapper(NesCart *cart)
 {
     int i;
 
@@ -86,50 +90,52 @@ int mmc4_InitMapper(NesCart * cart)
     set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
 
     if (cart->VROMSize > 0)
-        set_vrom_bank_8k(0x0000,0);
-    
+    {
+        set_vrom_bank_8k(0x0000, 0);
+    }
+
     /* Mapper should register itself for write hook */
-    for (i = 0xA0; i < 0xB0 ; i++)
+    for (i = 0xA0 ; i < 0xB0 ; i++)
     {
-       set_page_wr_hook(i, mmc4_MapperWriteRegA);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xB0; i < 0xC0 ; i++)
+        set_page_wr_hook(i, mmc4_MapperWriteRegA);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xB0 ; i < 0xC0 ; i++)
     {
-       set_page_wr_hook(i, mmc4_MapperWriteRegB);
-       set_page_writeable(i, true);       
+        set_page_wr_hook(i, mmc4_MapperWriteRegB);
+        set_page_writeable(i, true);
     }
-    for (i = 0xC0; i < 0xD0 ; i++)
+    for (i = 0xC0 ; i < 0xD0 ; i++)
     {
-       set_page_wr_hook(i, mmc4_MapperWriteRegC);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xD0; i < 0xE0 ; i++)
+        set_page_wr_hook(i, mmc4_MapperWriteRegC);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xD0 ; i < 0xE0 ; i++)
     {
-       set_page_wr_hook(i, mmc4_MapperWriteRegD);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xE0; i < 0xF0 ; i++)
+        set_page_wr_hook(i, mmc4_MapperWriteRegD);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xE0 ; i < 0xF0 ; i++)
     {
-       set_page_wr_hook(i, mmc4_MapperWriteRegE);
-       set_page_writeable(i, true);       
+        set_page_wr_hook(i, mmc4_MapperWriteRegE);
+        set_page_writeable(i, true);
     }
-    for (i = 0xF0; i < 0x100 ; i++)
+    for (i = 0xF0 ; i < 0x100 ; i++)
     {
-       set_page_wr_hook(i, mmc4_MapperWriteRegF);
-       set_page_writeable(i, true);       
+        set_page_wr_hook(i, mmc4_MapperWriteRegF);
+        set_page_writeable(i, true);
     }
-    
-    for (i = 0x60; i < 0x80 ; i++)
+
+    for (i = 0x60 ; i < 0x80 ; i++)
     {
-       set_page_writeable(i, true);
-       set_page_readable(i, true);
+        set_page_writeable(i, true);
+        set_page_readable(i, true);
     }
-    
+
     //ppu_setScreenMode(PPU_SCMODE_NORMAL);
     //ppu_setMirroring(PPU_MIRROR_HORIZTAL);
-    
+
     return 0;
-       
+
 }
 

+ 3 - 2
src/mappersmanager/mappers/mmc4.h

@@ -2,13 +2,14 @@
  *  MMC4 Mapper - The peTI-NESulator Project
  *  mmc4.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
 void mmc4_MapperDump(FILE *fp);
-int mmc4_InitMapper(NesCart * cart);
+int mmc4_InitMapper(NesCart *cart);

+ 23 - 22
src/mappersmanager/mappers/norom.c

@@ -2,45 +2,46 @@
  *  NOROM Mapper - The peTI-NESulator Project
  *  norom.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #include "norom.h"
 
-int norom_InitMapper(NesCart *cart) 
+int norom_InitMapper(NesCart *cart)
 {
-   set_page_ptr_16k(0x80, cart->PROMBanks); 
-   
-   /* mUBank = 0xC000 */   
-   if (cart->PROMSize > (16*1024))
-   {
-      set_prom_bank_16k(0xC000, 1);
-   }
-   else        
-   {
-      set_prom_bank_16k(0xC000, 0);
-   }
-   
-   if (cart->VROMSize > 0)
-      set_vrom_bank_8k(0x2000, 0);
-   
-   return 0;
+    set_page_ptr_16k(0x80, cart->PROMBanks);
+
+    /* mUBank = 0xC000 */
+    if (cart->PROMSize > (16 * 1024))
+    {
+        set_prom_bank_16k(0xC000, 1);
+    }
+    else
+    {
+        set_prom_bank_16k(0xC000, 0);
+    }
+
+    if (cart->VROMSize > 0)
+    {
+        set_vrom_bank_8k(0x2000, 0);
+    }
+
+    return 0;
 }
 
 int norom_MapperIRQ(int cycledone)
 {
-   return 0;
+    return 0;
 }
 
 void norom_MapperWriteHook(register uint8_t Addr, register uint8_t Value)
 {
-   /* Nothing to do */
-   return;
+    /* Nothing to do */
 }
 
 void norom_MapperDump(FILE *fp)
 {
-   fprintf(fp, "norom mapper have nothing to dump");
+    fprintf(fp, "norom mapper have nothing to dump");
 }

+ 5 - 4
src/mappersmanager/mappers/norom.h

@@ -2,14 +2,15 @@
  *  NOROM Mapper - The peTI-NESulator Project
  *  norom.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
-int norom_InitMapper  (NesCart *cart);
-int norom_MapperIRQ   (int cycledone);
-void norom_MapperDump (FILE *fp);
+int norom_InitMapper(NesCart *cart);
+int norom_MapperIRQ(int cycledone);
+void norom_MapperDump(FILE *fp);

+ 14 - 12
src/mappersmanager/mappers/unrom.c

@@ -2,7 +2,7 @@
  *  UNROM Mapper - The peTI-NESulator Project
  *  unrom.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -13,36 +13,38 @@ uint8_t unrom_load_vbank;
 
 void unrom_MapperWriteHook(uint8_t Addr, uint8_t Value);
 
-int unrom_InitMapper(NesCart * cart) 
+int unrom_InitMapper(NesCart *cart)
 {
     int i;
-    
+
     set_prom_bank_16k(0xC000, 0);
     set_prom_bank_16k(0x8000, GETLAST16KBANK(cart)); /* Set the last one */
 
     if (Cart->VROMSize > 0)
-        set_vrom_bank_8k(0x0000,0);
+    {
+        set_vrom_bank_8k(0x0000, 0);
+    }
 
     unrom_load_vbank = 0;
-    
+
     /* Register the write hook */
-    for (i = 0x80; i < 0x100; i++)
+    for (i = 0x80 ; i < 0x100 ; i++)
     {
         set_page_wr_hook(i, unrom_MapperWriteHook);
         set_page_writeable(i, true);
     }
-    
+
     return 0;
-} 
+}
 
 
 void unrom_MapperWriteHook(uint8_t Addr, uint8_t Value)
-{    
-    set_vrom_bank_8k(0x0000,Value);
+{
+    set_vrom_bank_8k(0x0000, Value);
     unrom_load_vbank = Value;
-} 
+}
 
 void unrom_MapperDump(FILE *fp)
 {
-    fprintf(fp,"unrom: vbank:%d\n",unrom_load_vbank);
+    fprintf(fp, "unrom: vbank:%d\n", unrom_load_vbank);
 }

+ 3 - 2
src/mappersmanager/mappers/unrom.h

@@ -2,13 +2,14 @@
  *  UNROM Mapper - The peTI-NESulator Project
  *  unrom.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
-int unrom_InitMapper(NesCart * cart); 
+int unrom_InitMapper(NesCart *cart);
 void unrom_MapperDump(FILE *fp);

+ 10 - 9
src/mappersmanager/mappers/unrom512.c

@@ -2,7 +2,7 @@
  *  UNROM Mapper - The peTI-NESulator Project
  *  unrom.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -19,6 +19,7 @@ static uint8_t loaded_pbank;
  * 32K on such a cart
  */
 static uint8_t vram[32768];
+
 void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr);
 
 static void unrom512_applyValues()
@@ -39,13 +40,13 @@ static void unrom512_applyValues()
 static void unrom512_MapperWriteHook(uint8_t Addr, uint8_t Value)
 {
     mirroring_set = (Value >> 7) & 0x01;
-    loaded_vbank  = (Value >> 5) & 0x03;
-    loaded_pbank  = (Value     ) & 0x1F;
+    loaded_vbank = (Value >> 5) & 0x03;
+    loaded_pbank = (Value) & 0x1F;
 
     unrom512_applyValues();
 }
 
-int unrom512_InitMapper(NesCart * cart)
+int unrom512_InitMapper(NesCart *cart)
 {
     int i;
 
@@ -54,18 +55,18 @@ int unrom512_InitMapper(NesCart * cart)
     set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
 
     unrom512_applyValues();
-    
+
     /* Register the write hook */
-    for (i = 0x80; i < 0x100; i++)
+    for (i = 0x80 ; i < 0x100 ; i++)
     {
         set_page_wr_hook(i, unrom512_MapperWriteHook);
         set_page_writeable(i, true);
     }
-    
+
     return 0;
-} 
+}
 
 void unrom512_MapperDump(FILE *fp)
 {
-    fprintf(fp,"unrom512: vbank:%d pbank:%d\n", loaded_vbank, loaded_pbank);
+    fprintf(fp, "unrom512: vbank:%d pbank:%d\n", loaded_vbank, loaded_pbank);
 }

+ 3 - 2
src/mappersmanager/mappers/unrom512.h

@@ -2,13 +2,14 @@
  *  UNROM Mapper - The peTI-NESulator Project
  *  unrom.h
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
 #define __TINES_MAPPERS__
+
 #include <mappers/manager.h>
 
-int unrom512_InitMapper(NesCart * cart);
+int unrom512_InitMapper(NesCart *cart);
 void unrom512_MapperDump(FILE *fp);

+ 1 - 1
src/mappersmanager/mappers_list.h

@@ -2,7 +2,7 @@
  *  Mapper list - The peTI-NESulator Project
  *  mappers_list.h
  *
- *  Created by Manoel TRAPIER on 25/10/07.
+ *  Created by Manoël TRAPIER on 25/10/07.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */

+ 3 - 3
src/mappersmanager/unused/genericmapper.h

@@ -2,8 +2,8 @@
  *  Generic mapper implementation - The peTI-NESulator Project
  *  genericmapper.h
  *
- *  Created by Manoel TRAPIER.
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
+ *  Created by Manoël TRAPIER.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
  
@@ -22,7 +22,7 @@ int _MapperWriteHook(register word Addr, register uint8_t Value)
     
     if (Addr > 0x7FFF)    /* Try to write to the rom */
     {
-        set_vrom_bank_8k(0x0000,Value) 
+        set_vrom_bank_8k(0x0000,Value);
         
         return 1;
     } 

+ 152 - 146
src/mappersmanager/unused/mmc1.h

@@ -2,18 +2,14 @@
  *  MMC1 Mapper - The peTI-NESulator Project
  *  mmc1.h
  *
- *  Created by Manoel TRAPIER.
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
+ *  Created by Manoël TRAPIER.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 uint8_t MMC1_reg0;
-
 uint8_t MMC1_reg1;
-
 uint8_t MMC1_reg2;
-
 uint8_t MMC1_reg3;
-
 uint8_t mmc1_CurrentBank;
 
 #define MMC1_R0_MIRROR    0x01
@@ -49,91 +45,86 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value);
 
 void mmc1_MapperDump(FILE *fp)
 {
-    fprintf(fp,"MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n",MMC1_reg0,MMC1_reg1,MMC1_reg2,MMC1_reg3);
+    fprintf(fp, "MMC1: r0:0x%02X r1:0x%02X r2:0x%02X r3:0x%02X\n", MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
 }
 
-int mmc1_InitMapper(NesCart * cart) 
+int mmc1_InitMapper(NesCart *cart)
 {
     int i;
-    
-       MMC1_reg0 = MMC1_REG0_DEFAULT;
-       
-       MMC1_reg1 = MMC1_REG1_DEFAULT;
-       
-       MMC1_reg2 = MMC1_REG2_DEFAULT;
-       
-       MMC1_reg3 = MMC1_REG3_DEFAULT;
-        
-       set_prom_bank_16k(0x8000,0);
-       set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
-       
-       mmc1_CurrentBank = 0;
-       
-       if (cart->VROMSize > 0)
-           set_vrom_bank_4k(0x0000,0);
-
-       
-       /* Mapper should register itself for write hook */
-    for (i = 0x80; i < 0xA0 ; i++)
+
+    MMC1_reg0 = MMC1_REG0_DEFAULT;
+    MMC1_reg1 = MMC1_REG1_DEFAULT;
+    MMC1_reg2 = MMC1_REG2_DEFAULT;
+    MMC1_reg3 = MMC1_REG3_DEFAULT;
+
+    set_prom_bank_16k(0x8000, 0);
+    set_prom_bank_16k(0xC000, GETLAST16KBANK(cart));
+
+    mmc1_CurrentBank = 0;
+
+    if (cart->VROMSize > 0)
+    {
+        set_vrom_bank_4k(0x0000, 0);
+    }
+
+
+    /* Mapper should register itself for write hook */
+    for (i = 0x80 ; i < 0xA0 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg0);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xA0; i < 0xC0 ; i++)
+        set_page_wr_hook(i, mmc1_MapperWriteReg0);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xA0 ; i < 0xC0 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg1);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xC0; i < 0xE0 ; i++)
+        set_page_wr_hook(i, mmc1_MapperWriteReg1);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xC0 ; i < 0xE0 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg2);
-       set_page_writeable(i, true);       
-    } 
-    for (i = 0xE0; i < 0x100 ; i++)
+        set_page_wr_hook(i, mmc1_MapperWriteReg2);
+        set_page_writeable(i, true);
+    }
+    for (i = 0xE0 ; i < 0x100 ; i++)
     {
-       set_page_wr_hook(i, mmc1_MapperWriteReg3);
-       set_page_writeable(i, true);       
+        set_page_wr_hook(i, mmc1_MapperWriteReg3);
+        set_page_writeable(i, true);
     }
-    
+
     return 0;
-       
-} 
+
+}
 
 
 /*
-Reg 0
-8 : 1000
-9 : 1001
-
-        Reg 1
-        A : 1010
-        B : 1011
-        
-          Reg 2
-          C : 1100
-          D : 1101
-          
-            Reg 3
-            E : 1110
-            F : 1111
-            
-              ((Addr & 0x6000) >> 13) <- port number
-*/ 
+ * Reg 0
+ * 8 : 1000
+ * 9 : 1001
+ *
+ * Reg 1
+ * A : 1010
+ * B : 1011
+ *
+ * Reg 2
+ * C : 1100
+ * D : 1101
+ *
+ * Reg 3
+ * E : 1110
+ * F : 1111
+ *
+ * ((Addr & 0x6000) >> 13) <- port number
+ */
 #define MMC1_GetReg(a) ((a & 0x6000) >> 13)
-/* (Val & 0x01) recuperation du bit */ 
 #define MMC1_GetBit(v) (v & 0x01)
-/* ( ( b & (1 << Bit)) | (v << Bit) ) Ajout du bit */ 
-#define MMC1_AddBit(b,v) ( ( b & ~(1 << Bit)) | (v << Bit) )
+#define MMC1_AddBit(b, v) ( ( b & ~(1 << Bit)) | (v << Bit) )
 
-void mmc1_ApplyReg0Mod() 
+void mmc1_ApplyReg0Mod()
 {
-    
+
     static uint8_t OldSwitchArea = MMC1_R0_PRGAREA;
-    
-    
-       
-    //console_printf(Console_Default, "Change to reg0 done ! (0x%x)\n\tMiror flag : %d\n\tOneScreen Flag : %d\n\tPRG Size : %d\n\tPRG Area : %d\n\tVROM Switch size : %d\n", MMC1_reg0, MMC1_reg0 & MMC1_R0_MIRROR, MMC1_reg0 & MMC1_R0_ONESCREEN, MMC1_reg0 & MMC1_R0_PRGAREA, MMC1_reg0 & MMC1_R0_PRGSIZE, MMC1_reg0 & MMC1_R0_VROMSW);
-        
+
+    //console_printf(Console_Default, "Change to reg0 done ! (0x%x)\n\tMirror flag : %d\n\tOneScreen Flag : %d\n\tPRG Size : %d\n\tPRG Area : %d\n\tVROM Switch size : %d\n", MMC1_reg0, MMC1_reg0 & MMC1_R0_MIRROR, MMC1_reg0 & MMC1_R0_ONESCREEN, MMC1_reg0 & MMC1_R0_PRGAREA, MMC1_reg0 & MMC1_R0_PRGSIZE, MMC1_reg0 & MMC1_R0_VROMSW);
+
     switch (MMC1_reg0 & 0x03)
     {
     case 0:
@@ -153,27 +144,27 @@ void mmc1_ApplyReg0Mod()
         ppu_setMirroring(PPU_MIRROR_HORIZTAL);
         break;
     }
-       
-    if ( (OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 ) )
+
+    if ((OldSwitchArea != (MMC1_reg0 & MMC1_R0_PRGAREA)) && ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0))
     {
-           
+
         if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
-        {        /* 0x8000 area */
-            set_prom_bank_16k(0x8000,mmc1_CurrentBank);
+        {
+            /* 0x8000 area */
+            set_prom_bank_16k(0x8000, mmc1_CurrentBank);
             set_prom_bank_16k(0xC000, GETLAST16KBANK(Cart));
-        } 
+        }
         else
-        {        /* 0xC000 area */
-    
-            set_prom_bank_16k(0x8000,0);
-            set_prom_bank_16k(0xC000,mmc1_CurrentBank);
+        {
+            /* 0xC000 area */
+            set_prom_bank_16k(0x8000, 0);
+            set_prom_bank_16k(0xC000, mmc1_CurrentBank);
+        }
 
-        } 
-           
         OldSwitchArea = (MMC1_reg0 & MMC1_R0_PRGAREA);
     }
-       
-} 
+
+}
 
 int VROMBankNb;
 uint8_t Bit = 0;
@@ -181,69 +172,74 @@ uint8_t BitBuf = 0;
 
 void mmc1_MapperWriteReg0(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg0 = MMC1_REG0_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg0 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg0 Reset occurred !\n");
         mmc1_ApplyReg0Mod();
     }
     else
     {
         if (Bit < 4)
-        {        /* Pas encore ecrit les 5 bits  */
+        {
+            /* Haven't written the 5 bits yet */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
-            
+
             MMC1_reg0 = BitBuf;
-            
+
             mmc1_ApplyReg0Mod();
         }
-    }               
+    }
 }
 
 void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg1 = MMC1_REG1_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg1 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg1 Reset occurred !\n");
     }
     else
     {
         if (Bit < 4)
-        {        /* Pas encore ecrit les 5 bits  */
+        {
+            /* Haven't written the 5 bits yet */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
-            
+
             MMC1_reg1 = BitBuf;
-                        
+
             VROMBankNb = (MMC1_reg1 /* & MMC1_R1_VROMB1 */ );
 
             if (Cart->VROMSize == 0)
             {
-                console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n", VROMBankNb);
+                console_printf(Console_Default, "Try to change VROM but with didn't have any VROM ! [%04X]\n",
+                               VROMBankNb);
                 return;
             }
-                
-            if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
-            {    /* 4K vram */
+
+            if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
+            {
+                /* 4K vram */
                 //console_printf(Console_Default, "Switching VROM at 0x0000 to 4k bank %d\n", VROMBankNb);
-                set_vrom_bank_4k(0x0000,VROMBankNb);
+                set_vrom_bank_4k(0x0000, VROMBankNb);
             }
             else
-            {    /* 8K vram */
+            {
+                /* 8K vram */
                 //console_printf(Console_Default, "Switching VROM at 0x0000 to 8k bank %d\n", VROMBankNb>>1);
-                set_vrom_bank_8k(0x0000,VROMBankNb>>1);
+                set_vrom_bank_8k(0x0000, VROMBankNb >> 1);
             }
         }
     }
@@ -251,43 +247,46 @@ void mmc1_MapperWriteReg1(register uint8_t Addr, register uint8_t Value)
 
 void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg2 = MMC1_REG2_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg2 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg2 Reset occurred !\n");
     }
     else
     {
         if (Bit < 4)
-        {        /* Pas encore ecrit les 5 bits  */
+        {
+            /* Haven't written the 5 bits yet */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
 
             MMC1_reg2 = BitBuf;
-            
+
             VROMBankNb = (MMC1_reg2 /* & MMC1_R2_VROMB2 */ );
-            
+
             //console_printf(Console_Default, "Want to switch VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
             if (Cart->VROMSize == 0)
             {
                 //console_printf(Console_Default, ": No\n");
                 return;
             }
-            
-            if ( (MMC1_reg0 & MMC1_R0_VROMSW) != 0 )
-            {    /* 4K vram */
+
+            if ((MMC1_reg0 & MMC1_R0_VROMSW) != 0)
+            {
+                /* 4K vram */
                 //console_printf(Console_Default, "Switching VROM at 0x1000 to 4k bank %d\n", VROMBankNb);
-                set_vrom_bank_4k(0x1000,VROMBankNb);
+                set_vrom_bank_4k(0x1000, VROMBankNb);
             }
             else
-            {    /* 8K vram */
-            //       console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
-            //       set_vrom_bank_8k(0x1000,VROMBankNb>>1);
+            {
+                /* 8K vram */
+                //       console_printf(Console_Default, "Switching VROM at 0x1000 to 8k bank %d\n", VROMBankNb>>1);
+                //       set_vrom_bank_8k(0x1000,VROMBankNb>>1);
             }
         }
     }
@@ -295,47 +294,54 @@ void mmc1_MapperWriteReg2(register uint8_t Addr, register uint8_t Value)
 
 void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
 {
-    if (Value & 0x80) 
-    {   
+    if (Value & 0x80)
+    {
         MMC1_reg3 = MMC1_REG3_DEFAULT;
-        console_printf(Console_Default, "MMC1: Reg3 Reset occured !\n");
+        console_printf(Console_Default, "MMC1: Reg3 Reset occurred !\n");
     }
     else
     {
         if (Bit < 4)
-        {        /* Pas encore ecrit les 5 bits  */
+        {
+            /* Haven't written the 5 bits yet */
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit++;
-        } 
+        }
         else
         {
             BitBuf = MMC1_AddBit(BitBuf, MMC1_GetBit(Value));
             Bit = 0;
-        
+
             MMC1_reg3 = BitBuf;
-            
-            if (MMC1_reg3<<14 > Cart->PROMSize)
+
+            if (MMC1_reg3 << 14 > Cart->PROMSize)
+            {
                 return;
-                
-            if ( (MMC1_reg0 & MMC1_R0_PRGSIZE) != 0 )
-            {    /* 16K Switch */
-                if ( (MMC1_reg0 & MMC1_R0_PRGAREA) != 0 )
-                {    /* 0x8000 switch */
-                    set_prom_bank_16k(0x8000,MMC1_reg3);
+            }
+
+            if ((MMC1_reg0 & MMC1_R0_PRGSIZE) != 0)
+            {
+                /* 16K Switch */
+                if ((MMC1_reg0 & MMC1_R0_PRGAREA) != 0)
+                {
+                    /* 0x8000 switch */
+                    set_prom_bank_16k(0x8000, MMC1_reg3);
                     //console_printf(Console_Default, "LowBank is now %d ( 0x%p )\n", MMC1_reg3, mLBank);
                 }
                 else
-                {    /* 0xC000 switch */
-                    set_prom_bank_16k(0xC000,MMC1_reg3);
+                {
+                    /* 0xC000 switch */
+                    set_prom_bank_16k(0xC000, MMC1_reg3);
                     //console_printf(Console_Default, "HighBank is now %d ( 0x%p )\n", MMC1_reg3, mUBank);
                 }
             }
             else
-            {    /* 32K Switch */
-                set_prom_bank_32k(0x8000,MMC1_reg3>>1);
+            {
+                /* 32K Switch */
+                set_prom_bank_32k(0x8000, MMC1_reg3 >> 1);
             }
-            
-            if ( ( MMC1_reg3 & MMC1_R3_SAVECE ) != 0)   
+
+            if ((MMC1_reg3 & MMC1_R3_SAVECE) != 0)
             {
                 unmap_sram();
             }
@@ -345,6 +351,6 @@ void mmc1_MapperWriteReg3(register uint8_t Addr, register uint8_t Value)
             }
         }
     }
-}    
-        
-        //console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);
+}
+
+//console_printf(Console_Default, "MMC1: Debug (Reg:%d,Val:0x%02X,reg0:0x%02X,reg1:0x%02X,reg2:0x%02X,reg3:0x%02X)\n", MMC1_GetReg(Addr), Value, MMC1_reg0, MMC1_reg1, MMC1_reg2, MMC1_reg3);

+ 2 - 2
src/mappersmanager/utils.c

@@ -2,7 +2,7 @@
  *  Mapper facilities - The peTI-NESulator Project
  *  mappers.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */ 
@@ -27,7 +27,7 @@ extern NesCart *Cart;
 extern char MapperWantIRQ;
 
 /*
- Here are some fonction useful for mappers
+ * Here are some function useful for mappers
  */
 
 void set_vrom_bank_1k(uint16_t addr,int slot)

+ 1 - 1
src/memorymanager/CMakeLists.txt

@@ -1,7 +1,7 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
+# Created by Manoël TRAPIER.
 # Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$

+ 69 - 40
src/memorymanager/memory.c

@@ -2,11 +2,11 @@
  *  6502 Memory manager - The peTI-NESulator Project
  *  memory.c - Taken from the Quick6502 project
  *
- *  Created by Manoel Trapier on 18/09/06.
+ *  Created by Manoël Trapier on 18/09/06.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
- 
+
 #include <stdio.h>
 #include <types.h>
 
@@ -16,14 +16,14 @@
 
 /* Private structures */
 
-#define Kuint8_t * (1024)
+#define KByte * (1024)
 
 /* 
 * What inside memory manager:
  *
  * Table of attributes
  * Table of original page ptr
- * Table of moded page ptr
+ * Table of modded page ptr
  * 
  */
 
@@ -55,7 +55,7 @@ void set_page_ptr_1k(uint8_t page, uint8_t *ptr)
 {   /* 1k = 4 * 256 */
     LOG(console_printf(Console_Default, "Set page(1k) 0x%X to ptr %p\n", page, ptr));
     memory_pages[page + 0] = ptr;
-    memory_pages[page + 1] = ptr +  0x100;
+    memory_pages[page + 1] = ptr + 0x100;
     memory_pages[page + 2] = ptr + (0x100 * 2);
     memory_pages[page + 3] = ptr + (0x100 * 3);
 }
@@ -64,7 +64,7 @@ void set_page_ptr_2k(uint8_t page, uint8_t *ptr)
 {
     LOG(console_printf(Console_Default, "Set page(2k) 0x%X to ptr %p\n", page, ptr));
     memory_pages[page + 0] = ptr;
-    memory_pages[page + 1] = ptr +  0x100;
+    memory_pages[page + 1] = ptr + 0x100;
     memory_pages[page + 2] = ptr + (0x100 * 2);
     memory_pages[page + 3] = ptr + (0x100 * 3);
     memory_pages[page + 4] = ptr + (0x100 * 4);
@@ -77,26 +77,26 @@ void set_page_ptr_4k(uint8_t page, uint8_t *ptr)
 {
     LOG(console_printf(Console_Default, "Set page(4k) 0x%X to ptr %p\n", page, ptr));
     set_page_ptr_2k(page, ptr);
-    set_page_ptr_2k(page+((4 Kuint8_t / 256) / 2), ptr + 2 Kuint8_t);
+    set_page_ptr_2k(page + ((4 KByte / 256) / 2), ptr + 2 KByte);
 }
 
 void set_page_ptr_8k(uint8_t page, uint8_t *ptr)
 {
     LOG(console_printf(Console_Default, "Set page(8k) 0x%X to ptr %p\n", page, ptr));
     set_page_ptr_4k(page, ptr);
-    set_page_ptr_4k(page+((8 Kuint8_t / 256) / 2), ptr + 4 Kuint8_t);
+    set_page_ptr_4k(page + ((8 KByte / 256) / 2), ptr + 4 KByte);
 }
 
 void set_page_ptr_16k(uint8_t page, uint8_t *ptr)
 {
     set_page_ptr_8k(page, ptr);
-    set_page_ptr_8k(page+((16 Kuint8_t / 256) / 2), ptr + 8 Kuint8_t);
+    set_page_ptr_8k(page + ((16 KByte / 256) / 2), ptr + 8 KByte);
 }
 
 void set_page_ptr_32k(uint8_t page, uint8_t *ptr)
 {
     set_page_ptr_16k(page, ptr);
-    set_page_ptr_16k(page+((32 Kuint8_t / 256) / 2), ptr + 16 Kuint8_t);
+    set_page_ptr_16k(page + ((32 KByte / 256) / 2), ptr + 16 KByte);
 }
 
 uint8_t *get_page_ptr(uint8_t page)
@@ -113,15 +113,19 @@ void set_page_rd_hook(uint8_t page, func_rdhook func)
     {
         memory_pages_attr[page] &= (~ATTR_PAGE_HAVE_RDHOOK);
         if (memory_pages[page] == (uint8_t *)0x01)
+        {
             memory_pages[page] = NULL;
+        }
     }
     else
     {
         memory_pages_attr[page] |= ATTR_PAGE_HAVE_RDHOOK;
         if (memory_pages[page] == NULL)
+        {
             memory_pages[page] = (uint8_t *)0x01;
+        }
     }
-    
+
     rdh_table[page] = func;
 }
 
@@ -130,34 +134,46 @@ void set_page_wr_hook(uint8_t page, func_wrhook func)
     if (func == NULL)
     {
         memory_pages_attr[page] &= (~ATTR_PAGE_HAVE_WRHOOK);
-        if (memory_pages[page] == (uint8_t*)0x01)
+        if (memory_pages[page] == (uint8_t *)0x01)
+        {
             memory_pages[page] = NULL;
+        }
 
     }
     else
     {
         memory_pages_attr[page] |= ATTR_PAGE_HAVE_WRHOOK;
         if (memory_pages[page] == NULL)
+        {
             memory_pages[page] = (uint8_t *)0x01;
+        }
     }
-    
-    wrh_table[page] = func;    
+
+    wrh_table[page] = func;
 }
 
 void set_page_readable(uint8_t page, uint8_t value)
 {
     if (value == true)
+    {
         memory_pages_attr[page] |= ATTR_PAGE_READABLE;
+    }
     else
-        memory_pages_attr[page] &= (~ATTR_PAGE_READABLE);    
+    {
+        memory_pages_attr[page] &= (~ATTR_PAGE_READABLE);
+    }
 }
 
 void set_page_writeable(uint8_t page, uint8_t value)
 {
     if (value == true)
+    {
         memory_pages_attr[page] |= ATTR_PAGE_WRITEABLE;
+    }
     else
-        memory_pages_attr[page] &= (~ATTR_PAGE_WRITEABLE);        
+    {
+        memory_pages_attr[page] &= (~ATTR_PAGE_WRITEABLE);
+    }
 }
 
 void set_page_ghost(uint8_t page, uint8_t value, uint8_t ghost)
@@ -179,37 +195,45 @@ uint8_t get_page_attributes(uint8_t page)
 func_rdhook get_page_rdhook(uint8_t page)
 {
     if (memory_pages_attr[page] & ATTR_PAGE_HAVE_RDHOOK)
+    {
         return rdh_table[page];
-    
+    }
+
     return NULL;
 }
 
 func_wrhook get_page_wrhook(uint8_t page)
 {
     if (memory_pages_attr[page] & ATTR_PAGE_HAVE_WRHOOK)
+    {
         return wrh_table[page];
-    
+    }
+
     return NULL;
 }
 
 uint8_t ReadMemory(uint8_t page, uint8_t addr)
 {
-    static uint8_t LastRetuint8_t = 0xA5;
+    static uint8_t LastRetByte = 0xA5;
     uint8_t *page_ptr;
     uint8_t attributes;
     LOG(console_printf(Console_Default, "Read @ 0x%X-%X\n", page, addr));
     /* Est-ce que la page est mappé ? && Est-ce que la page est "readable" ? */
     if ((page_ptr = memory_pages[page]) &&
-          ( (attributes = memory_pages_attr[page]) & ATTR_PAGE_READABLE) )
+        ((attributes = memory_pages_attr[page]) & ATTR_PAGE_READABLE))
     {
         LOG(console_printf(Console_Default, "Page is non null & readable\n"));
-        if ( attributes & ATTR_PAGE_HAVE_RDHOOK )
-            return ( LastRetuint8_t = rdh_table[page](addr) );
+        if (attributes & ATTR_PAGE_HAVE_RDHOOK)
+        {
+            return (LastRetByte = rdh_table[page](addr));
+        }
         else
-            return ( LastRetuint8_t = page_ptr[addr] );
+        {
+            return (LastRetByte = page_ptr[addr]);
+        }
     }
     //console_printf(Console_Default, "Trying to read @ 0x%X-%X\n", page, addr);
-    return LastRetuint8_t;
+    return LastRetByte;
 }
 
 void WriteMemory(uint8_t page, uint8_t addr, uint8_t value)
@@ -218,10 +242,10 @@ void WriteMemory(uint8_t page, uint8_t addr, uint8_t value)
     uint8_t attributes;
     LOG(console_printf(Console_Default, "Write 0x%x @ 0x%X-%X\n", value, page, addr));
     /* Est-ce que la page est mappé ? && Est-ce que la page est "writable" ? */
-    if ( (page_ptr = memory_pages[page]) &&
-         ( (attributes = memory_pages_attr[page]) & ATTR_PAGE_WRITEABLE) )
+    if ((page_ptr = memory_pages[page]) &&
+        ((attributes = memory_pages_attr[page]) & ATTR_PAGE_WRITEABLE))
     {
-        if ( attributes & ATTR_PAGE_HAVE_WRHOOK )
+        if (attributes & ATTR_PAGE_HAVE_WRHOOK)
         {
 #ifdef DETECT_BUS_CONFLICT
             if ((page >= 0x80) && (memory_pages[page][addr] != value))
@@ -230,40 +254,45 @@ void WriteMemory(uint8_t page, uint8_t addr, uint8_t value)
             wrh_table[page](addr, value);
         }
         else
+        {
             page_ptr[addr] = value;
+        }
+    }
+    else
+    {
+        console_printf(Console_Default, "Trying to write 0x%X @ 0x%X-%X\n", value, page, addr);
     }
-    else { console_printf(Console_Default, "Trying to write 0x%X @ 0x%X-%X\n", value, page, addr); }
 }
 
 void DumpMemoryState(FILE *fp)
 {
     int i;
-    
-    for (i = 0x00; i < 0x100; i++)
+
+    for (i = 0x00 ; i < 0x100 ; i++)
     {
         fprintf(fp,
                 "Page 0x%02X : [%c%c%c%c%c%c] RdH:%p WrH:%p ptr:%p\n",
                 i,
-                (memory_pages_attr[i]&ATTR_PAGE_HAVE_RDHOOK)?'r':'.',
-                (memory_pages_attr[i]&ATTR_PAGE_HAVE_WRHOOK)?'w':'.',
-                (memory_pages_attr[i]&ATTR_PAGE_READABLE)?'R':'.',
-                (memory_pages_attr[i]&ATTR_PAGE_WRITEABLE)?'W':'.',                        
-                (memory_pages_attr[i]&ATTR_PAGE_GHOST)?'G':'.',
-                (memory_pages_attr[i]&ATTR_PAGE_MAPPED)?'M':'.',
+                (memory_pages_attr[i] & ATTR_PAGE_HAVE_RDHOOK) ? 'r' : '.',
+                (memory_pages_attr[i] & ATTR_PAGE_HAVE_WRHOOK) ? 'w' : '.',
+                (memory_pages_attr[i] & ATTR_PAGE_READABLE) ? 'R' : '.',
+                (memory_pages_attr[i] & ATTR_PAGE_WRITEABLE) ? 'W' : '.',
+                (memory_pages_attr[i] & ATTR_PAGE_GHOST) ? 'G' : '.',
+                (memory_pages_attr[i] & ATTR_PAGE_MAPPED) ? 'M' : '.',
                 rdh_table[i],
                 wrh_table[i],
                 memory_pages[i]
-                );
+        );
     }
 }
 
 void InitMemory()
 {
     int page;
-    
-    for(page = 0 ; page < 0x100 ; page++)
+
+    for (page = 0 ; page < 0x100 ; page++)
     {
-        set_page_ptr(page,NULL);
+        set_page_ptr(page, NULL);
         memory_pages_attr[page] = 0x00;
     }
 }

+ 2 - 2
src/os/macos/CMakeLists.txt

@@ -1,8 +1,8 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
-# Copyright (c) 2003-2008 986Corp. All rights reserved.
+# Created by Manoël TRAPIER.
+# Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$
 # $Author$

+ 2 - 2
src/os/macos/graphics.c

@@ -2,8 +2,8 @@
  *  Graphic Manager - The peTI-NESulator Project
  *  os/macos/graphics.c
  *
- *  Created by Manoel TRAPIER on 08/05/08.
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
+ *  Created by Manoël TRAPIER on 08/05/08.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 #include <os_dependent.h>

+ 1 - 1
src/os/macos/loadfile.c

@@ -2,7 +2,7 @@
  *  File functions - The peTI-NESulator Project
  *  os/macos/load.c
  *
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 

+ 2 - 2
src/os/ti68k/CMakeLists.txt

@@ -1,8 +1,8 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
-# Copyright (c) 2003-2008 986Corp. All rights reserved.
+# Created by Manoël TRAPIER.
+# Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$
 # $Author$

+ 3 - 8
src/os/ti68k/loadfile.c

@@ -2,13 +2,8 @@
  *  TI-68k Loading external file functions - The peTI-NESulator Project
  *  ti68k/loadfile.c
  *
- *  Created by Manoel TRAPIER.
- *  Copyright (c) 2003-2008 986Corp. All rights reserved.
- *
- *  $LastChangedDate:$
- *  $Author:$
- *  $HeadURL:$
- *  $Revision:$
+ *  Created by Manoël TRAPIER.
+ *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
 
@@ -24,7 +19,7 @@ void *LoadFilePtr(char * filename)
    if ((fp = fopen(filename,"rb")) == NULL)
       return -1;
    
-   /* TI Related stuff, very uggly, and need to be changed.. */
+   /* TI Related stuff, very ugly, and need to be changed.. */
    HeapLock(fp->handle);
    RetPtr = 2 + HeapDeref(fp->handle);
    

+ 1 - 1
src/os/unix/CMakeLists.txt

@@ -1,7 +1,7 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
+# Created by Manoël TRAPIER.
 # Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$

+ 300 - 287
src/os/unix/graphics.c

@@ -2,7 +2,7 @@
  *  Graphic Manager - The peTI-NESulator Project
  *  os/macos/graphics.c
  *
- *  Created by Manoel TRAPIER on 08/05/08.
+ *  Created by Manoël TRAPIER on 08/05/08.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -14,6 +14,7 @@
 #include <os_dependent.h>
 
 #define GLFW_INCLUDE_GLEXT
+
 #include <GLFW/glfw3.h>
 
 /* "Apple" fix */
@@ -27,414 +28,426 @@ typedef struct GLWindow_t GLWindow;
 
 struct KeyArray
 {
-   uint8_t lastState;
-   uint8_t curState;
-   uint8_t debounced;
-   GLFWwindow* window;
+    uint8_t lastState;
+    uint8_t curState;
+    uint8_t debounced;
+    GLFWwindow *window;
 };
 
 struct GLWindow_t
 {
-   struct KeyArray keyArray[512];
-   GLFWwindow* windows;
-   uint8_t *videoMemory;
-   GLint videoTexture;
-   int WIDTH;
-   int HEIGHT;
+    struct KeyArray keyArray[512];
+    GLFWwindow *windows;
+    uint8_t *videoMemory;
+    GLuint videoTexture;
+    int WIDTH;
+    int HEIGHT;
 };
 
 static int window_num = 0;
 
 void GLWindowInitEx(GLWindow *g, int w, int h)
 {
-   g->WIDTH  = w;
-   g->HEIGHT = h;
-   g->videoTexture = window_num++;
+    g->WIDTH = w;
+    g->HEIGHT = h;
+    g->videoTexture = window_num++;
 }
 
 void GLWindowInit(GLWindow *g)
 {
-   GLWindowInitEx(g, 100, 100);
+    GLWindowInitEx(g, 100, 100);
 }
 
 void ShowScreen(GLWindow *g, int w, int h)
 {
-   glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
+    glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
 
-   // glTexSubImage2D is faster when not using a texture range
-   glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
-   glBegin(GL_QUADS);
+    // glTexSubImage2D is faster when not using a texture range
+    glTexSubImage2D(GL_TEXTURE_RECTANGLE, 0, 0, 0, w, h, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
+    glBegin(GL_QUADS);
 
-   glTexCoord2f(0.0f, 0.0f);
-   glVertex2f(-1.0f,1.0f);
+    glTexCoord2f(0.0f, 0.0f);
+    glVertex2f(-1.0f, 1.0f);
 
-   glTexCoord2f(0.0f, h);
-   glVertex2f(-1.0f, -1.0f);
+    glTexCoord2f(0.0f, h);
+    glVertex2f(-1.0f, -1.0f);
 
-   glTexCoord2f(w, h);
-   glVertex2f(1.0f, -1.0f);
+    glTexCoord2f(w, h);
+    glVertex2f(1.0f, -1.0f);
 
-   glTexCoord2f(w, 0.0f);
-   glVertex2f(1.0f, 1.0f);
-   glEnd();
+    glTexCoord2f(w, 0.0f);
+    glVertex2f(1.0f, 1.0f);
+    glEnd();
 
-   glFlush();
+    glFlush();
 }
 
 void setupGL(GLWindow *g, int w, int h)
 {
-   g->videoMemory = (uint8_t*)malloc(w*h*sizeof(uint32_t));
-   memset(g->videoMemory, 0,w*h*sizeof(uint32_t));
-   //Tell OpenGL how to convert from coordinates to pixel values
-   glViewport(0, 0, w, h);
+    g->videoMemory = (uint8_t *)malloc(w * h * sizeof(uint32_t));
+    memset(g->videoMemory, 0, w * h * sizeof(uint32_t));
+    //Tell OpenGL how to convert from coordinates to pixel values
+    glViewport(0, 0, w, h);
 
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-   glClearColor(1.0f, 0.f, 1.0f, 1.0f);
-   glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+    glClearColor(1.0f, 0.f, 1.0f, 1.0f);
+    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
 
-   glMatrixMode(GL_PROJECTION);
-   glLoadIdentity();
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
 
-   glMatrixMode(GL_MODELVIEW);
-   glLoadIdentity();
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
 
-   glDisable(GL_TEXTURE_2D);
-   glEnable(GL_TEXTURE_RECTANGLE);
-   glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
+    glDisable(GL_TEXTURE_2D);
+    glEnable(GL_TEXTURE_RECTANGLE);
+    glBindTexture(GL_TEXTURE_RECTANGLE, g->videoTexture);
 
-   //  glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);
+    //  glTextureRangeAPPLE(GL_TEXTURE_RECTANGLE_NV_EXT, 0, NULL);
 
-   //  glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
-   //  glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
-   glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
-   glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-   glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-   glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-   glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+    //  glTexParameteri(GL_TEXTURE_RECTANGLE_NV_EXT, GL_TEXTURE_STORAGE_HINT_APPLE , GL_STORAGE_CACHED_APPLE);
+    //  glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);
+    glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+    glTexParameteri(GL_TEXTURE_RECTANGLE, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
 
-   glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, w,
-                h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
+    glTexImage2D(GL_TEXTURE_RECTANGLE, 0, GL_RGBA, w,
+                 h, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, g->videoMemory);
 
-   glDisable(GL_DEPTH_TEST);
+    glDisable(GL_DEPTH_TEST);
 }
 
 void restoreGL(GLWindow *g, int w, int h)
 {
-   //Tell OpenGL how to convert from coordinates to pixel values
-   glViewport(0, 0, w, h);
-
-   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
-   glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
-   glClearColor(1.0f, 0.f, 1.0f, 1.0f);
-   glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-   glClear(GL_COLOR_BUFFER_BIT);
-   glMatrixMode(GL_PROJECTION);
-   glLoadIdentity();
-
-   glMatrixMode(GL_MODELVIEW);
-   glLoadIdentity();
-
-   glDisable(GL_TEXTURE_2D);
-   glEnable(GL_TEXTURE_RECTANGLE);
-   glDisable(GL_DEPTH_TEST);
+    //Tell OpenGL how to convert from coordinates to pixel values
+    glViewport(0, 0, w, h);
+
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+    glClearColor(1.0f, 0.f, 1.0f, 1.0f);
+    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+    glClear(GL_COLOR_BUFFER_BIT);
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+
+    glMatrixMode(GL_MODELVIEW);
+    glLoadIdentity();
+
+    glDisable(GL_TEXTURE_2D);
+    glEnable(GL_TEXTURE_RECTANGLE);
+    glDisable(GL_DEPTH_TEST);
 }
 
-void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
+void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
 {
-   struct KeyArray *keyArray;
-
-   keyArray = (struct KeyArray*) glfwGetWindowUserPointer(window);
-
-   keyArray[key].lastState=keyArray[key].curState;
-   if (action==GLFW_RELEASE)
-   {
-      keyArray[key].curState=GLFW_RELEASE;
-   }
-   else
-   {
-      keyArray[key].curState=GLFW_PRESS;
-   }
-   keyArray[key].debounced |= (keyArray[key].lastState==GLFW_RELEASE)&&(keyArray[key].curState==GLFW_PRESS);
-   keyArray[key].window = window;
+    struct KeyArray *keyArray;
+
+    keyArray = (struct KeyArray *)glfwGetWindowUserPointer(window);
+
+    keyArray[key].lastState = keyArray[key].curState;
+    if (action == GLFW_RELEASE)
+    {
+        keyArray[key].curState = GLFW_RELEASE;
+    }
+    else
+    {
+        keyArray[key].curState = GLFW_PRESS;
+    }
+    keyArray[key].debounced |= (keyArray[key].lastState == GLFW_RELEASE) && (keyArray[key].curState == GLFW_PRESS);
+    keyArray[key].window = window;
 }
 
-void sizeHandler(GLFWwindow* window,int xs,int ys)
+void sizeHandler(GLFWwindow *window, int xs, int ys)
 {
-   glfwMakeContextCurrent(window);
-   glViewport(0, 0, xs, ys);
+    glfwMakeContextCurrent(window);
+    glViewport(0, 0, xs, ys);
 }
 
-static void error_callback(int error, const char* description)
+static void error_callback(int error, const char *description)
 {
-   puts(description);
+    puts(description);
 }
 
 void initDisplay(GLWindow *g)
 {
-   int h = g->HEIGHT;
-   int w = g->WIDTH;
+    int h = g->HEIGHT;
+    int w = g->WIDTH;
 
-   /// Initialize GLFW
-   glfwInit();
+    /// Initialize GLFW
+    glfwInit();
 
-   glfwSetErrorCallback(error_callback);
+    glfwSetErrorCallback(error_callback);
 
-   // Open screen OpenGL window
-   if( !(g->windows=glfwCreateWindow( g->WIDTH, g->HEIGHT, "Main", NULL, NULL)) )
-   {
-      glfwTerminate();
-      fprintf(stderr, "Window creation error...\n");
-      abort();
-   }
+    // Open screen OpenGL window
+    if (!(g->windows = glfwCreateWindow(g->WIDTH, g->HEIGHT, "Main", NULL, NULL)))
+    {
+        glfwTerminate();
+        fprintf(stderr, "Window creation error...\n");
+        abort();
+    }
 
-   glfwSetWindowAspectRatio(g->windows, 4, 3);
+    glfwSetWindowAspectRatio(g->windows, 4, 3);
 
-   glfwMakeContextCurrent(g->windows);
-   setupGL(g, g->WIDTH, g->HEIGHT);
+    glfwMakeContextCurrent(g->windows);
+    setupGL(g, g->WIDTH, g->HEIGHT);
 
-   glfwSwapInterval(0);            // Disable VSYNC
+    glfwSwapInterval(0);            // Disable VSYNC
 
-   glfwGetWindowSize(g->windows, &w, &h);
+    glfwGetWindowSize(g->windows, &w, &h);
 
-   glfwSetWindowUserPointer(g->windows, g->keyArray);
+    glfwSetWindowUserPointer(g->windows, g->keyArray);
 
-   glfwSetKeyCallback(g->windows, kbHandler);
-   glfwSetWindowSizeCallback(g->windows, sizeHandler);
+    glfwSetKeyCallback(g->windows, kbHandler);
+    glfwSetWindowSizeCallback(g->windows, sizeHandler);
 }
 
 void drawPixel(GLWindow *gw, int x, int y, uint32_t colour)
 {
-   uint8_t r,g,b,a;
+    uint8_t r, g, b, a;
 
-   uint32_t offset = (y*gw->WIDTH*4)+4*x;
+    uint32_t offset = (y * gw->WIDTH * 4U) + 4U * x;
 
-   if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
-      return;
+    if ((x < 0) || (x > gw->WIDTH) || (y < 0) || (y > gw->HEIGHT))
+    {
+        return;
+    }
 
-   b =  colour        & 0xFF;
-   g = (colour >>  8) & 0xFF;
-   r = (colour >> 16) & 0xFF;
-   a = (colour >> 24) & 0xFF;
+    b = colour & 0xFF;
+    g = (colour >> 8) & 0xFF;
+    r = (colour >> 16) & 0xFF;
+    a = (colour >> 24) & 0xFF;
 
-   gw->videoMemory[offset + 0] = a;
-   gw->videoMemory[offset + 1] = r;
-   gw->videoMemory[offset + 2] = g;
-   gw->videoMemory[offset + 3] = b;
+    gw->videoMemory[offset + 0] = a;
+    gw->videoMemory[offset + 1] = r;
+    gw->videoMemory[offset + 2] = g;
+    gw->videoMemory[offset + 3] = b;
 }
 
 void drawLine(GLWindow *g, int x0, int y0, int x1, int y1, uint32_t colour)
 {
-   int d, dx, dy, aincr, bincr, xincr, yincr, x, y;
-   if (abs(x1 - x0) < abs(y1 - y0))
-   {
-      /* parcours par l'axe vertical */
-      if (y0 > y1)
-      {
-         drawLine(g, x1, y1, x0, y0, colour);
-         goto exit;
-      }
-
-      xincr = x1 > x0 ? 1 : -1;
-      dy = y1 - y0;
-      dx = abs(x1 - x0);
-      d = 2 * dx - dy;
-      aincr = 2 * (dx - dy);
-      bincr = 2 * dx;
-      x = x0;
-      y = y0;
-
-      drawPixel(g, x, y, colour);
-
-      for (y = y0+1; y <= y1; y++)
-      {
-         if (d >= 0)
-         {
-            x += xincr;
-            d += aincr;
-         }
-         else
-         {
-            d += bincr;
-         }
-
-         drawPixel(g, x, y, colour);
-      }
-
-   }
-   else
-   {
-      /* parcours par l'axe horizontal */
-      if (x0 > x1)
-      {
-         drawLine(g, x1, y1, x0, y0, colour);
-         goto exit;
-      }
-      yincr = y1 > y0 ? 1 : -1;
-      dx = x1 - x0;
-      dy = abs(y1 - y0);
-      d = 2 * dy - dx;
-      aincr = 2 * (dy - dx);
-      bincr = 2 * dy;
-      x = x0;
-      y = y0;
-
-      drawPixel(g, x, y, colour);
-
-      for (x = x0+1; x <= x1; ++x)
-      {
-         if (d >= 0)
-         {
-            y += yincr;
-            d += aincr;
-         }
-         else
-         {
-            d += bincr;
-         }
-
-         drawPixel(g, x, y, colour);
-      }
-   }
-
-   exit:
-   return;
+    int d, dx, dy, aincr, bincr, xincr, yincr, x, y;
+    if (abs(x1 - x0) < abs(y1 - y0))
+    {
+        /* parcours par l'axe vertical */
+        if (y0 > y1)
+        {
+            drawLine(g, x1, y1, x0, y0, colour);
+            goto exit;
+        }
+
+        xincr = x1 > x0 ? 1 : -1;
+        dy = y1 - y0;
+        dx = abs(x1 - x0);
+        d = 2 * dx - dy;
+        aincr = 2 * (dx - dy);
+        bincr = 2 * dx;
+        x = x0;
+        y = y0;
+
+        drawPixel(g, x, y, colour);
+
+        for (y = y0 + 1 ; y <= y1 ; y++)
+        {
+            if (d >= 0)
+            {
+                x += xincr;
+                d += aincr;
+            }
+            else
+            {
+                d += bincr;
+            }
+
+            drawPixel(g, x, y, colour);
+        }
+
+    }
+    else
+    {
+        /* parcours par l'axe horizontal */
+        if (x0 > x1)
+        {
+            drawLine(g, x1, y1, x0, y0, colour);
+            goto exit;
+        }
+        yincr = y1 > y0 ? 1 : -1;
+        dx = x1 - x0;
+        dy = abs(y1 - y0);
+        d = 2 * dy - dx;
+        aincr = 2 * (dy - dx);
+        bincr = 2 * dy;
+        x = x0;
+        y = y0;
+
+        drawPixel(g, x, y, colour);
+
+        for (x = x0 + 1 ; x <= x1 ; ++x)
+        {
+            if (d >= 0)
+            {
+                y += yincr;
+                d += aincr;
+            }
+            else
+            {
+                d += bincr;
+            }
+
+            drawPixel(g, x, y, colour);
+        }
+    }
+
+exit:
+    return;
 }
 
 void drawCircle(GLWindow *g, int xc, int yc, int radius, uint32_t colour)
 {
-   int f = 1 - radius;
-   int ddF_x = 0;
-   int ddF_y = -2 * radius;
-   int x = 0;
-   int y = radius;
-   int pX, pY;
-
-   pX = xc; pY = yc + radius;
-   drawPixel(g, pX, pY, colour);
-   pY -=  (2*radius);
-   drawPixel(g, pX, pY, colour);
-   pY += radius; pX += radius;
-   drawPixel(g, pX, pY, colour);
-   pX -= (2*radius);
-   drawPixel(g, pX, pY, colour);
-
-   while(x < y)
-   {
-      if(f >= 0)
-      {
-         y--;
-         ddF_y += 2;
-         f += ddF_y;
-      }
-      x++;
-      ddF_x += 2;
-      f += ddF_x + 1;
-      pX = xc+x ; pY = yc+y;
-      drawPixel(g, pX, pY, colour);
-      pX = xc-x ; pY = yc+y;
-      drawPixel(g, pX, pY, colour);
-      pX = xc+x ; pY = yc-y;
-      drawPixel(g, pX, pY, colour);
-      pX = xc-x ; pY = yc-y;
-      drawPixel(g, pX, pY, colour);
-      pX = xc+y ; pY = yc+x;
-      drawPixel(g, pX, pY, colour);
-      pX = xc-y ; pY = yc+x;
-      drawPixel(g, pX, pY, colour);
-      pX = xc+y ; pY = yc-x;
-      drawPixel(g, pX, pY, colour);
-      pX = xc-y ; pY = yc-x;
-      drawPixel(g, pX, pY, colour);
-   }
-
-   return;
+    int f = 1 - radius;
+    int ddF_x = 0;
+    int ddF_y = -2 * radius;
+    int x = 0;
+    int y = radius;
+    int pX, pY;
+
+    pX = xc;
+    pY = yc + radius;
+    drawPixel(g, pX, pY, colour);
+    pY -= (2 * radius);
+    drawPixel(g, pX, pY, colour);
+    pY += radius;
+    pX += radius;
+    drawPixel(g, pX, pY, colour);
+    pX -= (2 * radius);
+    drawPixel(g, pX, pY, colour);
+
+    while (x < y)
+    {
+        if (f >= 0)
+        {
+            y--;
+            ddF_y += 2;
+            f += ddF_y;
+        }
+        x++;
+        ddF_x += 2;
+        f += ddF_x + 1;
+        pX = xc + x;
+        pY = yc + y;
+        drawPixel(g, pX, pY, colour);
+        pX = xc - x;
+        pY = yc + y;
+        drawPixel(g, pX, pY, colour);
+        pX = xc + x;
+        pY = yc - y;
+        drawPixel(g, pX, pY, colour);
+        pX = xc - x;
+        pY = yc - y;
+        drawPixel(g, pX, pY, colour);
+        pX = xc + y;
+        pY = yc + x;
+        drawPixel(g, pX, pY, colour);
+        pX = xc - y;
+        pY = yc + x;
+        drawPixel(g, pX, pY, colour);
+        pX = xc + y;
+        pY = yc - x;
+        drawPixel(g, pX, pY, colour);
+        pX = xc - y;
+        pY = yc - x;
+        drawPixel(g, pX, pY, colour);
+    }
 }
 
 void drawRect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
 {
-   drawLine(g, x0    , y0    , x0 + w, y0    , colour);
-   drawLine(g, x0 + w, y0    , x0 + w, y0 + h, colour);
-   drawLine(g, x0 + w, y0 + h, x0    , y0 + h, colour);
-   drawLine(g, x0    , y0 + h, x0    , y0    , colour);
+    drawLine(g, x0, y0, x0 + w, y0, colour);
+    drawLine(g, x0 + w, y0, x0 + w, y0 + h, colour);
+    drawLine(g, x0 + w, y0 + h, x0, y0 + h, colour);
+    drawLine(g, x0, y0 + h, x0, y0, colour);
 }
 
 void drawFillrect(GLWindow *g, int x0, int y0, int w, int h, uint32_t colour)
 {
-   int i;
-   for(i = 0; i < h; i++)
-      drawLine(g, x0, y0+i, x0+w, y0+i, colour);
+    int i;
+    for (i = 0 ; i < h ; i++)
+    {
+        drawLine(g, x0, y0 + i, x0 + w, y0 + i, colour);
+    }
 }
 
 void clearScreen(GLWindow *g)
 {
-   memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
+    memset(g->videoMemory, 0, sizeof(uint8_t) * g->WIDTH * g->HEIGHT * 4);
 }
 
 void updateScreen(GLWindow *g)
 {
-   /*Update windows code */
-   glfwMakeContextCurrent(g->windows);
-   ShowScreen(g, g->WIDTH, g->HEIGHT);
-   glfwSwapBuffers(g->windows);
-   glfwPollEvents();
+    /*Update windows code */
+    glfwMakeContextCurrent(g->windows);
+    ShowScreen(g, g->WIDTH, g->HEIGHT);
+    glfwSwapBuffers(g->windows);
+    glfwPollEvents();
 }
 
 void updateScreenAndWait(GLWindow *g)
 {
-   while (glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_PRESS)
-   {
-      updateScreen(g);
-
-      glfwPollEvents();
-   }
-   while(glfwGetKey(g->windows,GLFW_KEY_ESCAPE) != GLFW_RELEASE)
-   {
-      glfwPollEvents();
-   }
+    while (glfwGetKey(g->windows, GLFW_KEY_ESCAPE) != GLFW_PRESS)
+    {
+        updateScreen(g);
+
+        glfwPollEvents();
+    }
+    while (glfwGetKey(g->windows, GLFW_KEY_ESCAPE) != GLFW_RELEASE)
+    {
+        glfwPollEvents();
+    }
 }
 
 GLWindow mainWindow;
 
 int graphics_init()
 {
-   GLWindowInitEx(&mainWindow, 256, 240);
-   initDisplay(&mainWindow);
-   clearScreen(&mainWindow);
-   updateScreen(&mainWindow);
-   return 0;
+    GLWindowInitEx(&mainWindow, 256, 240);
+    initDisplay(&mainWindow);
+    clearScreen(&mainWindow);
+    updateScreen(&mainWindow);
+    return 0;
 }
 
 static uint32_t getColour(long color)
 {
-   Palette *pal = &basicPalette[color];
-   uint8_t r, g, b, a;
-   r = pal->r;
-   b = pal->b;
-   g = pal->g;
-   a = 255;//pal->a;
-   return (b << 24) | (g << 16) | (r << 8) | a;
+    Palette *pal = &basicPalette[color];
+    uint8_t r, g, b, a;
+    r = pal->r;
+    b = pal->b;
+    g = pal->g;
+    a = 255;//pal->a;
+    return (b << 24) | (g << 16) | (r << 8) | a;
 }
 
 int graphics_drawpixel(long x, long y, long color)
 {
-   drawPixel(&mainWindow, x, y, getColour(color));
-   return 0;
+    drawPixel(&mainWindow, x, y, getColour(color));
+    return 0;
 }
 
 int graphics_drawline(long x, long y, long x1, long y1, long color)
 {
-   drawLine(&mainWindow, x, y, x1, y1, getColour(color));
-   return 0;
+    drawLine(&mainWindow, x, y, x1, y1, getColour(color));
+    return 0;
 }
 
 int graphics_blit(long x, long y, long w, long h)
 {
-   updateScreen(&mainWindow);
-   return 0;
+    updateScreen(&mainWindow);
+    return 0;
 }
 
 int getKeyStatus(int key)
 {
-   return mainWindow.keyArray[key].curState;
+    return mainWindow.keyArray[key].curState;
 }

+ 17 - 17
src/os/unix/graphics_dummy.c

@@ -2,7 +2,7 @@
  *  Graphic Manager - The peTI-NESulator Project
  *  os/macos/graphics.c
  *
- *  Created by Manoel TRAPIER on 08/05/08.
+ *  Created by Manoël TRAPIER on 08/05/08.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -22,19 +22,19 @@ typedef struct GLWindow_t GLWindow;
 
 struct KeyArray
 {
-   uint8_t lastState;
-   uint8_t curState;
-   uint8_t debounced;
+    uint8_t lastState;
+    uint8_t curState;
+    uint8_t debounced;
 };
 
 struct GLWindow_t
 {
-   struct KeyArray keyArray[512];
-   GLFWwindow* windows;
-   uint8_t *videoMemory;
-   GLint videoTexture;
-   int WIDTH;
-   int HEIGHT;
+    struct KeyArray keyArray[512];
+    GLFWwindow *windows;
+    uint8_t *videoMemory;
+    GLint videoTexture;
+    int WIDTH;
+    int HEIGHT;
 };
 
 #ifndef GL_TEXTURE_RECTANGLE_EXT
@@ -61,11 +61,11 @@ void restoreGL(GLWindow *g, int w, int h)
 {
 }
 
-void kbHandler(GLFWwindow* window, int key, int scan, int action, int mod )
+void kbHandler(GLFWwindow *window, int key, int scan, int action, int mod)
 {
 }
 
-void sizeHandler(GLFWwindow* window,int xs,int ys)
+void sizeHandler(GLFWwindow *window, int xs, int ys)
 {
 }
 
@@ -108,25 +108,25 @@ void updateScreenAndWait(GLWindow *g)
 
 int graphics_init()
 {
-   return 0;
+    return 0;
 }
 
 int graphics_drawpixel(long x, long y, long color)
 {
-   return 0;
+    return 0;
 }
 
 int graphics_drawline(long x, long y, long x1, long y1, long color)
 {
-   return 0;
+    return 0;
 }
 
 int graphics_blit(long x, long y, long w, long h)
 {
-   return 0;
+    return 0;
 }
 
 int getKeyStatus(int key)
 {
-   return 0;
+    return 0;
 }

+ 20 - 18
src/os/unix/io.c

@@ -12,46 +12,48 @@
 
 #include <os_dependent.h>
 
-char LevelChar[] = { 'E', 'W', 'A', 'N', 'V',  'D'};
+char LevelChar[] = { 'E', 'W', 'A', 'N', 'V', 'D' };
 
 ConsoleLevel console_ActualLevel = Console_Default;
 
 /* Actually nothing to do */
 int console_init(ConsoleLevel DefaultLevel)
 {
-   console_ActualLevel = DefaultLevel;
-   return 0;
+    console_ActualLevel = DefaultLevel;
+    return 0;
 }
 
 /* Actually a simple printf with levels */
 int console_vprintf(const ConsoleLevel level, const char *format, va_list ap)
 {
-   if (console_ActualLevel >= level)
-      vprintf(format, ap);
-   
-   return 0;
+    if (console_ActualLevel >= level)
+    {
+        vprintf(format, ap);
+    }
+
+    return 0;
 }
 
 
 int console_printf(const ConsoleLevel level, const char *format, ...)
 {
-   va_list ap;
-   va_start(ap, format);
+    va_list ap;
+    va_start(ap, format);
 
-   console_vprintf(level, format, ap);
+    console_vprintf(level, format, ap);
 
-   va_end(ap);
-   return 0;
+    va_end(ap);
+    return 0;
 }
 
 int console_printf_d(const char *format, ...)
 {
-   va_list ap;
-   va_start(ap, format);
-   
-   console_vprintf (Console_Debug, format, ap);
+    va_list ap;
+    va_start(ap, format);
+
+    console_vprintf(Console_Debug, format, ap);
 
-   va_end(ap);
+    va_end(ap);
 
-   return 0;
+    return 0;
 }

+ 14 - 14
src/os/unix/loadfile.c

@@ -16,24 +16,24 @@
 
 
 /* Map a file in memory */
-void *LoadFilePtr(char * filename)
+void *LoadFilePtr(char *filename)
 {
-	int fd;
-	void *RetPtr;
-	struct stat FileStat;
+    int fd;
+    void *RetPtr;
+    struct stat FileStat;
 
-	fd = open(filename, O_RDONLY);
+    fd = open(filename, O_RDONLY);
 
-	fstat(fd, &FileStat);
+    fstat(fd, &FileStat);
 
-	RetPtr = mmap(NULL, FileStat.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
-	
-	close(fd);
+    RetPtr = mmap(NULL, FileStat.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
 
-	if ( RetPtr == MAP_FAILED )
-	{
-                RetPtr = NULL;
-	}
+    close(fd);
 
-	return RetPtr;
+    if (RetPtr == MAP_FAILED)
+    {
+        RetPtr = NULL;
+    }
+
+    return RetPtr;
 }

+ 1 - 1
src/os/win32/CMakeLists.txt

@@ -1,7 +1,7 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
+# Created by Manoël TRAPIER.
 # Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$

+ 1 - 1
src/os/win32/graphics.c

@@ -2,7 +2,7 @@
  *  Graphic Manager - The peTI-NESulator Project
  *  os/macos/graphics.c
  *
- *  Created by Manoel TRAPIER on 08/05/08.
+ *  Created by Manoël TRAPIER on 08/05/08.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */

+ 79 - 64
src/paddle.c

@@ -2,7 +2,7 @@
  *  Paddle manager - The peTI-NESulator Project
  *  paddle.c
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -13,77 +13,92 @@
 
 void InitPaddle(Paddle *pdl)
 {
-   pdl->Bit = 1;
-   pdl->LastWrite = 0;
+    pdl->Bit = 1;
+    pdl->LastWrite = 0;
 }
 
 
 void WritePaddle(Paddle *pdl, uint8_t val)
 {
-   if ( ( pdl->LastWrite == 1 ) && ( val == 0 ) )
-      InitPaddle(pdl);
+    if ((pdl->LastWrite == 1) && (val == 0))
+    {
+        InitPaddle(pdl);
+    }
 
-   pdl->LastWrite = val;
+    pdl->LastWrite = val;
 }
 
 uint8_t ReadPaddle(Paddle *pdl)
 {
-   switch(pdl->Bit++)
-   {
-
-   case 1:
-      if ( getKeyStatus('O') )
-         return 0x41;
-      break;
-
-   case 2:
-      if ( getKeyStatus('P') )
-         return 0x41;
-      break;
-
-   case 3:
-      if ( getKeyStatus('I') )
-         return 0x41;
-      break;
-
-   case 4:
-      if ( getKeyStatus('U') )
-         return 0x41;
-      break;
-
-   case 5:
-      if ( getKeyStatus('W') )
-         return 0x41;
-      break;
-
-   case 6:
-      if ( getKeyStatus('S') )
-         return 0x41;
-      break;
-
-   case 7:
-      if ( getKeyStatus('A') )
-         return 0x41;
-      break;
-
-   case 8:
-      if ( getKeyStatus('D') )
-         return 0x41;
-      break;
-
-   case 20:
-      return 0x40;
-      break;
-
-   case 24:
-      pdl->Bit = 1;
-      return 0x40;
-
-   default:
-      return 0x40;
-      break;
-
-   }
-
-   return 0x40;
+    switch (pdl->Bit++)
+    {
+
+    case 1:
+        if (getKeyStatus('O'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 2:
+        if (getKeyStatus('P'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 3:
+        if (getKeyStatus('I'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 4:
+        if (getKeyStatus('U'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 5:
+        if (getKeyStatus('W'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 6:
+        if (getKeyStatus('S'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 7:
+        if (getKeyStatus('A'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 8:
+        if (getKeyStatus('D'))
+        {
+            return 0x41;
+        }
+        break;
+
+    case 20:
+        return 0x40;
+
+    case 24:
+        pdl->Bit = 1;
+        return 0x40;
+
+    default:
+        return 0x40;
+    }
+
+    return 0x40;
 } 

+ 1 - 1
src/pluginsmanager/CMakeLists.txt

@@ -1,7 +1,7 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
+# Created by Manoël TRAPIER.
 # Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$

+ 38 - 29
src/pluginsmanager/manager.c

@@ -2,7 +2,7 @@
  *  Plugins manager - The peTI-NESulator Project
  *  plugins.c
  *
- *  Created by Manoel TRAPIER on 02/04/07.
+ *  Created by Manoël TRAPIER on 02/04/07.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -15,9 +15,9 @@
 #include <plugins/manager.h>
 
 typedef struct Plugin_
-{   
+{
     char *name;
-    
+
     PluginInit init;
     PluginDeinit deinit;
 
@@ -26,11 +26,11 @@ typedef struct Plugin_
 typedef struct KeyHandler_
 {
     uint8_t key;
-    
+
     PluginKeypress func;
-    
+
     struct KeyHandler_ *next;
-    
+
 } KeyHandler;
 
 KeyHandler *keyHandlersList = NULL;
@@ -42,10 +42,11 @@ void plugin_list()
     Plugin *ptr = &(Plugins[0]);
     int i = 1;
     console_printf(Console_Default, "Available plugins:\n");
-    while(ptr->name != NULL)
+    while (ptr->name != NULL)
     {
         console_printf(Console_Default, "%d - %s\n", i, ptr->name);
-        ptr++; i++;
+        ptr++;
+        i++;
     }
 }
 
@@ -53,17 +54,19 @@ int plugin_load(int id)
 {
     Plugin *ptr = &(Plugins[0]);
     int i = id;
-    
+
     console_printf(Console_Default, "%s(%d)", __func__, id);
-    
-    for ( ; i > 1 && ptr->name != NULL; i -- )
+
+    for (; i > 1 && ptr->name != NULL ; i--)
     {
         console_printf(Console_Default, "%d - %s\n", i, ptr->name);
-        ptr ++;        
+        ptr++;
     }
 
     if (ptr == NULL)
+    {
         return -1;
+    }
 
     return ptr->init();
 }
@@ -71,12 +74,16 @@ int plugin_load(int id)
 int plugin_unload(int id)
 {
     Plugin *ptr = &(Plugins[0]);
-    
-    for ( ; id == 0 && ptr != NULL; id -- )
-        ptr ++;
+
+    for (; id == 0 && ptr != NULL ; id--)
+    {
+        ptr++;
+    }
 
     if (ptr == NULL)
+    {
         return -1;
+    }
 
     return ptr->deinit();
 }
@@ -86,32 +93,34 @@ int plugin_unload(int id)
 int plugin_install_keypressHandler(uint8_t key, PluginKeypress func)
 {
     KeyHandler *ptr;
-    
+
     if (keyHandlersList == NULL)
     {
-        keyHandlersList = (KeyHandler*) malloc(sizeof(KeyHandler));
-        
+        keyHandlersList = (KeyHandler *)malloc(sizeof(KeyHandler));
+
         keyHandlersList->key = key;
         keyHandlersList->func = func;
         keyHandlersList->next = NULL;
     }
     else
-    { 
+    {
         ptr = keyHandlersList;
-        
-        while(ptr->next != NULL)
+
+        while (ptr->next != NULL)
+        {
             ptr = ptr->next;
-        
-        ptr->next = (KeyHandler*) malloc(sizeof(KeyHandler));
-        
+        }
+
+        ptr->next = (KeyHandler *)malloc(sizeof(KeyHandler));
+
         ptr = ptr->next;
-        
+
         ptr->key = key;
         ptr->func = func;
         ptr->next = NULL;
 
     }
-    
+
     return 0;
 }
 
@@ -125,8 +134,8 @@ int plugin_remove_keypressHandler(uint8_t key, PluginKeypress func)
 int plugin_keypress(uint8_t key)
 {
     KeyHandler *ptr = keyHandlersList;
-    
-    while(ptr != NULL)
+
+    while (ptr != NULL)
     {
         if (ptr->key == key)
         {
@@ -134,6 +143,6 @@ int plugin_keypress(uint8_t key)
         }
         ptr = ptr->next;
     }
-    
+
     return 0;
 }

+ 280 - 221
src/pluginsmanager/plugins/gamegenie.c

@@ -2,7 +2,7 @@
  *  Code Breaker plugin - The peTI-NESulator Project
  *  gamegenie.c: Hack your games with unlimited lives of add new powers!
  *
- *  Created by Manoel Trapier.
+ *  Created by Manoël Trapier.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -13,22 +13,15 @@
 #include <os_dependent.h>
 
 #define __TINES_PLUGINS__
+
 #include <plugins/manager.h>
+
 #undef  __TINES_PLUGINS_
 
 #include <memory/manager.h>
 #include <types.h>
 
 #if 0
-/* Allegro includes */
-#ifdef __APPLE__
-#define USE_CONSOLE
-#include <Allegro/allegro.h>
-#else
-#define USE_CONSOLE
-#include <allegro.h>
-#endif
-
 
 typedef enum gg_States_
 {
@@ -76,85 +69,95 @@ uint8_t gg_RdHookPatch##d(uint8_t addr) \
 #define GG_MAX_PATCH 10
 /* Defines the rdhook patches */
 GG_RDHOOKPATCH(0)
+
 GG_RDHOOKPATCH(1)
+
 GG_RDHOOKPATCH(2)
+
 GG_RDHOOKPATCH(3)
+
 GG_RDHOOKPATCH(4)
+
 GG_RDHOOKPATCH(5)
+
 GG_RDHOOKPATCH(6)
+
 GG_RDHOOKPATCH(7)
+
 GG_RDHOOKPATCH(8)
+
 GG_RDHOOKPATCH(9)
 
 void gg_SetPatch(int id, uint8_t page, uint8_t addr, uint8_t value)
 {
     func_rdhook fptr;
-    
+
     if (id >= GG_MAX_PATCH)
+    {
         return;
-        
+    }
+
     /* Set parameters for the patch */
     if (gg_PatchUsed[id] == 0x00)
     {
-        gg_rdhookPtr[id] = get_page_rdhook(page);    
-    }    
-    
+        gg_rdhookPtr[id] = get_page_rdhook(page);
+    }
+
     gg_PatchedPage[id] = page;
     gg_PatchedAddr[id] = addr;
     gg_PatchedValue[id] = value;
     gg_PatchUsed[id] = 0xFF;
-    
+
     /* Set a ReadHook on the page */
-    
-    switch(id)
+
+    switch (id)
     {
     default:
     case 0:
         fptr = gg_RdHookPatch0;
         break;
-        
+
     case 1:
         fptr = gg_RdHookPatch1;
         break;
-        
+
     case 2:
         fptr = gg_RdHookPatch2;
         break;
-        
+
     case 3:
         fptr = gg_RdHookPatch3;
         break;
-        
+
     case 4:
         fptr = gg_RdHookPatch4;
         break;
-        
+
     case 5:
         fptr = gg_RdHookPatch5;
-        break;   
-        
+        break;
+
     case 6:
         fptr = gg_RdHookPatch6;
         break;
-        
+
     case 7:
         fptr = gg_RdHookPatch7;
         break;
-        
+
     case 8:
         fptr = gg_RdHookPatch8;
         break;
-        
+
     case 9:
         fptr = gg_RdHookPatch9;
-        break;        
+        break;
     }
 
     set_page_rd_hook(page, fptr);
 }
 
 
-
 /* Access to the bitmap Buffer */
 extern BITMAP *Buffer;
 BITMAP *gg_Buffer;
@@ -164,28 +167,28 @@ void MessageBox(char *title, char *msg)
 
     int sc_w, sc_h;
     int box_h, box_t, box_l, box_w;
-    
+
     sc_w = screen->w;
     sc_h = screen->h;
-    
+
     gg_Buffer = create_bitmap(sc_w, sc_h);
-    
+
     blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
-    
+
     box_w = text_length(font, title) + 10;
-    
-    box_w = (box_w>text_length(font, msg))?box_w:text_length(font, msg);
-    
+
+    box_w = (box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
+
     box_w += 15 * 2; /*sc_w/2;*/
-    box_h = 15*2 + 10;
-    
+    box_h = 15 * 2 + 10;
+
     /* Set the box center */
     box_t = (sc_h - box_h) / 2;
     box_l = (sc_w - box_w) / 2;
 
     rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
     rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
-    
+
     /* Display the title */
     textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
 
@@ -195,7 +198,7 @@ void MessageBox(char *title, char *msg)
     blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
 
     sleep(1);
-    
+
     release_bitmap(gg_Buffer);
 
 }
@@ -205,43 +208,43 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
 
     int sc_w, sc_h;
     int box_h, box_t, box_l, box_w;
-    
+
     char valueText[10];
-    
+
     uint16_t value;
     uint8_t digit = 0;
-    
+
     sc_w = screen->w;
     sc_h = screen->h;
-    
+
     gg_Buffer = create_bitmap(sc_w, sc_h);
-    
+
     blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
-    
+
     box_w = text_length(font, title) + 10;
-    
-    box_w = (box_w>text_length(font, msg))?box_w:text_length(font, msg);
-    
+
+    box_w = (box_w > text_length(font, msg)) ? box_w : text_length(font, msg);
+
     sprintf(valueText, "0000");
-        
-    box_w = (box_w>text_length(font, valueText))?box_w:text_length(font, msg);
-    
+
+    box_w = (box_w > text_length(font, valueText)) ? box_w : text_length(font, msg);
+
     box_w += 15 * 2; /*sc_w/2;*/
-    box_h = 15*2 + 30;
-    
+    box_h = 15 * 2 + 30;
+
     /* Set the box center */
     box_t = (sc_h - box_h) / 2;
     box_l = (sc_w - box_w) / 2;
-    
+
 
     value = 0;
-    
-    while(!key[KEY_ENTER])
+
+    while (!key[KEY_ENTER])
     {
-    
+
         rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
         rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
-    
+
         /* Display the title */
         textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
 
@@ -249,163 +252,193 @@ uint16_t SelectNumber(char *title, char *msg, uint8_t size)
         textout_centre_ex(gg_Buffer, font, msg, box_w / 2 + box_l, 15 + box_t + 2, 34, 60);
 
         if (size == 2)
-            sprintf(valueText, "  %02X", value&0xFF);
+        {
+            sprintf(valueText, "  %02X", value & 0xFF);
+        }
         else
+        {
             sprintf(valueText, "%04X", value);
+        }
 
-        textout_centre_ex(gg_Buffer, font, valueText, box_w / 2 + box_l , 15 + box_t + 2 + 10, 34, 60);
-        
-        switch(digit)
+        textout_centre_ex(gg_Buffer, font, valueText, box_w / 2 + box_l, 15 + box_t + 2 + 10, 34, 60);
+
+        switch (digit)
         {
         default:
         case 0:
-            textout_centre_ex(gg_Buffer, font, "   ^", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);
+            textout_centre_ex(gg_Buffer, font, "   ^", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
             break;
         case 1:
-            textout_centre_ex(gg_Buffer, font, "  ^ ", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);        
+            textout_centre_ex(gg_Buffer, font, "  ^ ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
             break;
-            
+
         case 2:
-            textout_centre_ex(gg_Buffer, font, " ^  ", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);        
+            textout_centre_ex(gg_Buffer, font, " ^  ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
             break;
-            
+
         case 3:
-            textout_centre_ex(gg_Buffer, font, "^   ", box_w / 2 + box_l , 15 + box_t + 2 + 20, 34, 60);
+            textout_centre_ex(gg_Buffer, font, "^   ", box_w / 2 + box_l, 15 + box_t + 2 + 20, 34, 60);
             break;
         }
-                
-        blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);    
-        
+
+        blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
+
         if (key[KEY_UP])
         {
             usleep(100000);
-            value += ((digit==0)?0x0001:((digit==1)?0x0010:((digit==2)?0x0100:0x1000)));
-            value &= (size==2)?0xFF:0xFFFF;
+            value += ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
+            value &= (size == 2) ? 0xFF : 0xFFFF;
         }
-        
+
         if (key[KEY_DOWN])
         {
             usleep(100000);
-            value -= ((digit==0)?0x0001:((digit==1)?0x0010:((digit==2)?0x0100:0x1000)));
-            value &= (size==2)?0xFF:0xFFFF;
+            value -= ((digit == 0) ? 0x0001 : ((digit == 1) ? 0x0010 : ((digit == 2) ? 0x0100 : 0x1000)));
+            value &= (size == 2) ? 0xFF : 0xFFFF;
         }
 
         if (key[KEY_RIGHT])
         {
             usleep(100000);
             if (digit <= 0)
-                digit = size-1;
-            else            
-                digit --;
+            {
+                digit = size - 1;
+            }
+            else
+            {
+                digit--;
+            }
         }
-        
+
         if (key[KEY_LEFT])
         {
             usleep(100000);
-            if (digit >= size-1)
+            if (digit >= size - 1)
+            {
                 digit = 0;
+            }
             else
-                digit ++;
+            {
+                digit++;
+            }
         }
 
     }
     release_bitmap(gg_Buffer);
-    while(key[KEY_ENTER]);
+    while (key[KEY_ENTER])
+    {
+    }
     return value;
 }
 
 int DispMenu(int itemc, char *itemv[], char *title)
 {
     //console_printf(Console_Default, "%s(%d, %p, \"%s\");\n", __func__, itemc, itemv, title);
-    
+
     int selection = 0;
     int i;
     int sc_w, sc_h;
     int box_h, box_t, box_l, box_w;
-    
+
     sc_w = screen->w;
     sc_h = screen->h;
-    
+
     gg_Buffer = create_bitmap(sc_w, sc_h);
-    
+
     blit(Buffer, gg_Buffer, 0, 0, 0, 0, 512 + 256, 480);
-    
+
     box_w = text_length(font, title) + 10;
-    
-    for (i = 0; i < itemc; i ++)
-        box_w = (box_w>text_length(font, itemv[i]))?box_w:text_length(font, itemv[i]);
-    
+
+    for (i = 0 ; i < itemc ; i++)
+    {
+        box_w = (box_w > text_length(font, itemv[i])) ? box_w : text_length(font, itemv[i]);
+    }
+
     box_w += 15 * 2; /*sc_w/2;*/
-    box_h = 15*2 + itemc*10;
-    
+    box_h = 15 * 2 + itemc * 10;
+
     /* Set the box center */
     box_t = (sc_h - box_h) / 2;
     box_l = (sc_w - box_w) / 2;
-    
-    
-    while(!key[KEY_ENTER])
+
+
+    while (!key[KEY_ENTER])
     {
         /* Draw the box and highlight the selected item */
         rectfill(gg_Buffer, box_l, box_t, box_l + box_w, box_t + box_h, 60);
         rect(gg_Buffer, box_l + 5, box_t + 5, box_l + box_w - 5, box_t + box_h - 5, 34);
-    
+
         /* Display the title */
         textout_centre_ex(gg_Buffer, font, title, box_w / 2 + box_l, box_t + 2, 34, 60);
-        
+
         /* Display the highlight item */
-        rectfill(gg_Buffer, box_l+15, 15 + box_t + (selection * 10) , box_l + box_w - 15, 15 + box_t + (selection * 10) + 10, 34);
-        textout_centre_ex(gg_Buffer, font, itemv[selection], box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60, 34);
-        
+        rectfill(gg_Buffer, box_l + 15, 15 + box_t + (selection * 10), box_l + box_w - 15,
+                 15 + box_t + (selection * 10) + 10, 34);
+        textout_centre_ex(gg_Buffer, font, itemv[selection], box_w / 2 + box_l, 15 + box_t + (selection * 10) + 2, 60,
+                          34);
+
         /* Display other items */
-        for (i = 0; i < itemc; i ++)     
+        for (i = 0 ; i < itemc ; i++)
         {
             if (i != selection)
+            {
                 textout_centre_ex(gg_Buffer, font, itemv[i], box_w / 2 + box_l, 15 + box_t + (i * 10) + 2, 34, 60);
+            }
         }
 
-    
+
         /* Blit the screen buffer */
         blit(gg_Buffer, screen, 0, 0, 0, 0, 512 + 256, 480);
-        
+
         /* Now get the keyboard state */
         if (key[KEY_UP])
         {
             usleep(100000);
             if (selection <= 0)
+            {
                 selection = itemc - 1;
-            else            
-                selection --;
+            }
+            else
+            {
+                selection--;
+            }
         }
-        
+
         if (key[KEY_DOWN])
         {
             usleep(100000);
             if (selection >= (itemc - 1))
+            {
                 selection = 0;
+            }
             else
-                selection ++;
+            {
+                selection++;
+            }
         }
-        
+
     }
 
     release_bitmap(gg_Buffer);
-    while(key[KEY_ENTER]);
+    while (key[KEY_ENTER])
+    {
+    }
     return selection;
 }
 
 uint8_t AskYesNo(char *title)
 {
     char *YesNo[] = { "No", "Yes" };
-    
+
     return DispMenu(2, YesNo, title);
 }
 
 uint8_t gg_CalcChk(uint16_t addr, uint8_t value)
 {
     int chk = 0x42;
-    chk += (addr  & 0xFF00) >> 8;
-    chk -= (addr  & 0x00FF);
-    chk += (value & 0x00FF);   
+    chk += (addr & 0xFF00) >> 8;
+    chk -= (addr & 0x00FF);
+    chk += (value & 0x00FF);
     return chk;
 }
 
@@ -420,7 +453,7 @@ uint32_t gg_MakeCode(uint16_t addr, uint8_t value)
     uint32_t code = addr << 16;
     code |= (value << 8);
     code |= (gg_CalcChk(addr, value) & 0x00FF);
-    
+
     return code ^ 0x246FF53A;
 }
 
@@ -430,33 +463,41 @@ uint8_t gg_SelectPatch()
     char *tmp;
     int i;
     uint8_t ret;
-    
-    for (i = 0; i < GG_MAX_PATCH; i++)
+
+    for (i = 0 ; i < GG_MAX_PATCH ; i++)
     {
-        tmp = (char*) malloc(0x100);
-        console_printf(Console_Default, "Items[%d]: %p\n", i, tmp);        
+        tmp = (char *)malloc(0x100);
+        console_printf(Console_Default, "Items[%d]: %p\n", i, tmp);
         if (gg_PatchUsed[i] == 0x00)
+        {
             sprintf(tmp, "Patch %d: Not used", i);
+        }
         else
+        {
             sprintf(tmp, "Patch %d: Put 0x%02X on address 0x%02X%02X (Code: %08lX)",
                     i, gg_PatchedValue[i], gg_PatchedPage[i], gg_PatchedAddr[i],
-                    gg_MakeCode((gg_PatchedPage[i]<<8) | gg_PatchedAddr[i], gg_PatchedValue[i]));
-        
+                    gg_MakeCode((gg_PatchedPage[i] << 8) | gg_PatchedAddr[i], gg_PatchedValue[i]));
+        }
+
         Items[i] = tmp;
     }
-               
-    tmp = (char*) malloc(0x100);
+
+    tmp = (char *)malloc(0x100);
     sprintf(tmp, "Return");
     Items[GG_MAX_PATCH] = tmp;
-    
+
     ret = DispMenu(GG_MAX_PATCH + 1, Items, "Code Breaker - Select a patch");
-    
-    for(i = 0; i < GG_MAX_PATCH; i++)
+
+    for (i = 0 ; i < GG_MAX_PATCH ; i++)
+    {
         free(Items[i]);
-    
+    }
+
     if (ret == GG_MAX_PATCH)
+    {
         return 0xFF;
-    
+    }
+
     return ret;
 }
 
@@ -468,23 +509,23 @@ void gg_PatchManager()
 void gg_InitSearch()
 {
     uint16_t addr;
-    
-    for(addr = 0x000; addr < 0x800; addr ++)
+
+    for (addr = 0x000 ; addr < 0x800 ; addr++)
     {
-        gg_MainRAM[addr] = ReadMemory((addr&0xFF00)>>8,addr&0x00FF);
+        gg_MainRAM[addr] = ReadMemory((addr & 0xFF00) >> 8, addr & 0x00FF);
         gg_use_MainRAM[addr] = 0xFF;
     }
-    
+
     gg_ResultNumber = 0x800;
 }
 
-typedef enum gg_SearchForMode_ 
+typedef enum gg_SearchForMode_
 {
     GG_SEARCHFOR_LOWER = 0,
     GG_SEARCHFOR_HIGHER,
     GG_SEARCHFOR_IDENTIC,
     GG_SEARCHFOR_DIFFERENT
-       
+
 } gg_SearchForMode;
 
 void gg_SearchForValue(uint8_t value)
@@ -493,16 +534,16 @@ void gg_SearchForValue(uint8_t value)
     //uint8_t oldValue;
     uint8_t currentValue;
     gg_ResultNumber = 0x00;
-    for(addr = 0x000; addr < 0x800; addr ++)
+    for (addr = 0x000 ; addr < 0x800 ; addr++)
     {
         if (gg_use_MainRAM[addr] == 0xFF)
         {
             /* "Backup" the old ram */
             memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
-            
+
             //oldValue = gg_MainRAM[addr];
-            currentValue = ReadMemory((addr&0xFF00)>>8,addr&0x00FF);
-            
+            currentValue = ReadMemory((addr & 0xFF00) >> 8, addr & 0x00FF);
+
             if (currentValue != value)
             { /* This is not the good one ! */
                 gg_use_MainRAM[addr] = 0x00;
@@ -522,17 +563,17 @@ void gg_SearchFor(gg_SearchForMode mode)
     uint8_t oldValue;
     uint8_t currentValue;
     gg_ResultNumber = 0x00;
-    for(addr = 0x000; addr < 0x800; addr ++)
+    for (addr = 0x000 ; addr < 0x800 ; addr++)
     {
         if (gg_use_MainRAM[addr] == 0xFF)
         {
             /* "Backup" the old ram */
             memcpy(gg_OldMainRAM, gg_MainRAM, 0x800);
-            
+
             oldValue = gg_MainRAM[addr];
-            currentValue = ReadMemory((addr&0xFF00)>>8,addr&0x00FF);
-            
-            switch(mode)
+            currentValue = ReadMemory((addr & 0xFF00) >> 8, addr & 0x00FF);
+
+            switch (mode)
             {
             case GG_SEARCHFOR_LOWER:
                 if (currentValue >= oldValue)
@@ -554,7 +595,7 @@ void gg_SearchFor(gg_SearchForMode mode)
                 else
                 { /* This can be the good one ! */
                     gg_ResultNumber++;
-                    gg_MainRAM[addr] = currentValue;                    
+                    gg_MainRAM[addr] = currentValue;
                 }
                 break;
 
@@ -566,7 +607,7 @@ void gg_SearchFor(gg_SearchForMode mode)
                 else
                 { /* This can be the good one ! */
                     gg_ResultNumber++;
-                    gg_MainRAM[addr] = currentValue;                    
+                    gg_MainRAM[addr] = currentValue;
                 }
                 break;
             case GG_SEARCHFOR_DIFFERENT:
@@ -577,7 +618,7 @@ void gg_SearchFor(gg_SearchForMode mode)
                 else
                 { /* This can be the good one ! */
                     gg_ResultNumber++;
-                    gg_MainRAM[addr] = currentValue;                    
+                    gg_MainRAM[addr] = currentValue;
                 }
                 break;
             }
@@ -591,7 +632,7 @@ uint8_t gg_DisplayResults()
     char *tmp;
     int i, addr = 0x0000;
     uint8_t ret = 0;
-                
+
     uint16_t AddrList[21];
     if (gg_ResultNumber > 20)
     {
@@ -599,42 +640,46 @@ uint8_t gg_DisplayResults()
     }
     else
     {
-        for (i = 0; i < gg_ResultNumber; i++)
-                {
-                    while(gg_use_MainRAM[addr] != 0xFF)
-                        addr ++;
-                    console_printf(Console_Default, "0x%04X [%d]\n", addr, i);
-                    tmp = (char*) malloc(0x100);
-                    sprintf(tmp,"Patch: %08XAddress 0x%04X - Was: 0x%02X - Actual: 0x%02X",
-                            i,
-                            addr,
-                            gg_OldMainRAM[addr],
-                            gg_MainRAM[addr]);        
-                    Items[i] = tmp;
-                    AddrList[i] = addr;
-                    
-                    addr++;
-                }
-                tmp = (char*) malloc(0x100);
-                sprintf(tmp, "Return");
-                Items[i] = tmp;
-                
-                ret = DispMenu(gg_ResultNumber + 1, Items, "Code Breaker - Search");
-                if (ret < i)
-                {
-                    if (AskYesNo("Code Breaker: Apply this patch?"))
-                    {
-                        /* Now patch it ! */
-                        gg_SetPatch(gg_SelectPatch(), (AddrList[ret]&0xFF00)>>8, (AddrList[ret]&0x00FF),
-                                    SelectNumber("Code Breaker", "Value to apply:", 2) & 0x00FF);
-                        ret = 1;
-                    }
-                }
-                
-                for(i=0 ; i<gg_ResultNumber+1; i++)
-                    free(Items[i]);
+        for (i = 0 ; i < gg_ResultNumber ; i++)
+        {
+            while (gg_use_MainRAM[addr] != 0xFF)
+            {
+                addr++;
             }
-            
+            console_printf(Console_Default, "0x%04X [%d]\n", addr, i);
+            tmp = (char *)malloc(0x100);
+            sprintf(tmp, "Patch: %08XAddress 0x%04X - Was: 0x%02X - Actual: 0x%02X",
+                    i,
+                    addr,
+                    gg_OldMainRAM[addr],
+                    gg_MainRAM[addr]);
+            Items[i] = tmp;
+            AddrList[i] = addr;
+
+            addr++;
+        }
+        tmp = (char *)malloc(0x100);
+        sprintf(tmp, "Return");
+        Items[i] = tmp;
+
+        ret = DispMenu(gg_ResultNumber + 1, Items, "Code Breaker - Search");
+        if (ret < i)
+        {
+            if (AskYesNo("Code Breaker: Apply this patch?"))
+            {
+                /* Now patch it ! */
+                gg_SetPatch(gg_SelectPatch(), (AddrList[ret] & 0xFF00) >> 8, (AddrList[ret] & 0x00FF),
+                            SelectNumber("Code Breaker", "Value to apply:", 2) & 0x00FF);
+                ret = 1;
+            }
+        }
+
+        for (i = 0 ; i < gg_ResultNumber + 1 ; i++)
+        {
+            free(Items[i]);
+        }
+    }
+
     return ret;
 }
 
@@ -642,23 +687,23 @@ void gg_Start()
 {
     char *S00_MenuList[] = { "Search a specific Value", "Search for an Unknown Value", "Enter code",
                              "Manage Patches", "Exit" };
-    
+
     char *S01_MenuList[] = { "Value is identical", "New Value...", "Value is different",
                              "Value is greater", "Value is lower", "Result", "Restart", "Exit" };
-    
+
     char *S02_MenuList[] = { "Value is identical", "Value is different", "Value is greater",
-                             "Value is lower", "Result", "Restart", "Exit" };                            
-    
+                             "Value is lower", "Result", "Restart", "Exit" };
+
     char Buffer[100];
     int ret;
     uint8_t value;
     uint16_t addr;
-    switch(gg_state)
+    switch (gg_state)
     {
     default:
     case GG_S00_MAIN_STATE:
         ret = DispMenu(5, S00_MenuList, "Code Breaker - Main");
-        
+
         switch (ret)
         {
         case 0:
@@ -666,9 +711,9 @@ void gg_Start()
             gg_InitSearch();
             gg_state = GG_S01_SEARCH_VALUE;
             value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
-            
+
             gg_SearchForValue(value);
-            
+
             MessageBox("Code Breaker", "Search initialized !");
             break;
         case 1:
@@ -679,29 +724,29 @@ void gg_Start()
         case 2: /* Enter code */
             addr = SelectNumber("Code Breaker", "Select the address", 4);
             value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
-            
-             if (AskYesNo("Code Breaker: Apply this patch?"))
-             {
+
+            if (AskYesNo("Code Breaker: Apply this patch?"))
+            {
                 /* Now patch it ! */
                 gg_SetPatch(gg_SelectPatch(),
-                            (addr&0xFF00)>>8, (addr&0x00FF),
+                            (addr & 0xFF00) >> 8, (addr & 0x00FF),
                             value);
-             }
-            
+            }
+
             break;
-        
+
         case 3: /* Patch manager */
             gg_PatchManager();
             break;
         }
-        
-        
+
+
         break;
-        
+
     case GG_S01_SEARCH_VALUE:
-S01_MENU:     
+    S01_MENU:
         ret = DispMenu(8, S01_MenuList, "Code Breaker - Search");
-        switch(ret)
+        switch (ret)
         {
         case 0:
             gg_SearchFor(GG_SEARCHFOR_IDENTIC);
@@ -709,10 +754,10 @@ S01_MENU:
             break;
         case 1:
             value = SelectNumber("Code Breaker", "Select the value:", 2) & 0x00FF;
-            
+
             gg_SearchForValue(value);
             break;
-            
+
         case 2:
             gg_SearchFor(GG_SEARCHFOR_DIFFERENT);
             //goto S02_MENU;
@@ -730,11 +775,15 @@ S01_MENU:
 
         case 5: /* Results */
             if (gg_DisplayResults() == 1)
+            {
                 gg_state = GG_S00_MAIN_STATE;
+            }
             else
+            {
                 goto S01_MENU;
+            }
             break;
-            
+
         case 6:
             if (AskYesNo("Code Breaker: Restart?"))
             {
@@ -742,19 +791,21 @@ S01_MENU:
                 gg_Start();
             }
             else
+            {
                 goto S01_MENU;
+            }
             break;
-            
+
         }
-        sprintf(Buffer,"Results found: %d", gg_ResultNumber);
+        sprintf(Buffer, "Results found: %d", gg_ResultNumber);
         MessageBox("Code Breaker", Buffer);
-        
+
         break;
-    
+
     case GG_S02_SEARCH_BAR:
-S02_MENU:    
+    S02_MENU:
         ret = DispMenu(7, S02_MenuList, "Code Breaker - Search");
-        switch(ret)
+        switch (ret)
         {
         case 0:
             gg_SearchFor(GG_SEARCHFOR_IDENTIC);
@@ -778,11 +829,15 @@ S02_MENU:
 
         case 4: /* Results */
             if (gg_DisplayResults() == 1)
+            {
                 gg_state = GG_S00_MAIN_STATE;
+            }
             else
+            {
                 goto S02_MENU;
+            }
             break;
-            
+
         case 5:
             if (AskYesNo("Code Breaker: Restart?"))
             {
@@ -790,28 +845,31 @@ S02_MENU:
                 gg_Start();
             }
             else
+            {
                 goto S02_MENU;
+            }
             break;
-            
+
         }
-        sprintf(Buffer,"Results found: %d", gg_ResultNumber);
+        sprintf(Buffer, "Results found: %d", gg_ResultNumber);
         MessageBox("Code Breaker", Buffer);
         break;
     }
 }
 
 
-
 int gg_Init()
 {
     int i;
     console_printf(Console_Default, "Initializing GG plugin...\n");
-    
+
     plugin_install_keypressHandler('g', gg_Start);
 
-    for ( i = 0; i < GG_MAX_PATCH; i++)
+    for (i = 0 ; i < GG_MAX_PATCH ; i++)
+    {
         gg_PatchUsed[i] = 0x00;
-    
+    }
+
     return 0;
 }
 
@@ -820,4 +878,5 @@ int gg_Deinit()
 {
     return 0;
 }
+
 #endif

+ 1 - 1
src/pluginsmanager/plugins/gamegenie.h

@@ -2,7 +2,7 @@
  *  Code Breaker plugin - The peTI-NESulator Project
  *  gamegenie.h
  *
- *  Created by Manoel Trapier.
+ *  Created by Manoël Trapier.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */

+ 5 - 5
src/pluginsmanager/plugins_list.h

@@ -2,7 +2,7 @@
  *  Plugin Manager plugint list - The peTI-NESulator Project
  *  plugins_list.h
  *
- *  Created by Manoel Trapier.
+ *  Created by Manoël Trapier.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -12,8 +12,8 @@
 #include "plugins/gamegenie.h"
 
 Plugin Plugins[] = {
-    //    { "Game Genie", gg_Init, gg_Deinit },
- 
+        //    { "Game Genie", gg_Init, gg_Deinit },
+
 /* EOL tag */
-         { NULL, NULL, NULL }
-                   };
+        { NULL, NULL, NULL }
+};

+ 2 - 2
src/ppu/CMakeLists.txt

@@ -1,8 +1,8 @@
 #
 # peTI-NESulator CMake
 #
-# Created by Manoel TRAPIER.
-# Copyright (c) 2003-2008 986Corp. All rights reserved.
+# Created by Manoël TRAPIER.
+# Copyright (c) 2003-2018 986-Studio. All rights reserved.
 #
 # $LastChangedDate$
 # $Author$

+ 1 - 1
src/ppu/debug/ppu.debug.c

@@ -2,7 +2,7 @@
  *  PPU Debug utilities - The peTI-NESulator Project
  *  ppu.debug.c
  *
- *  Created by Manoel Trapier.
+ *  Created by Manoël Trapier.
  *  Copyright 2003-2008 986 Corp. All rights reserved.
  *
  */

+ 2 - 8
src/ppu/ppu.c

@@ -4,7 +4,7 @@
  *
  *  Define and emulate the PPU (Picture Processing Unit) of the real NES
  *
- *  Created by Manoel TRAPIER.
+ *  Created by Manoël TRAPIER.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -55,12 +55,6 @@ typedef struct spriteData
 
 /* PPU registers */
 
-/* NT: Name Table */
-uint8_t PPU_Reg_NT;
-
-/* AT: Attribute/Color Table */
-uint8_t PPU_Reg_AT;
-
 /* FV: Fine Vertical Scroll latch/counter */
 uint8_t PPU_Reg_FV;
 
@@ -79,7 +73,7 @@ uint8_t PPU_Reg_V;
 /* H: Horizontal Name Table Selection latch/counter */
 uint8_t PPU_Reg_H;
 
-/* S: Playfield pattern table selection latch */
+/* S: Play-field pattern table selection latch */
 uint16_t PPU_Reg_S;
 
 /* PAR: Picture Address Register */

+ 5 - 5
src/ppu/ppu.memory.c

@@ -2,7 +2,7 @@
  *  PPU Memory manager - The peTI-NESulator Project
  *  ppu.memory.c - Inspired from the memory manager of the Quick6502 Project.
  *
- *  Created by Manoel Trapier on 12/04/07.
+ *  Created by Manoël Trapier on 12/04/07.
  *  Copyright (c) 2003-2018 986-Studio. All rights reserved.
  *
  */
@@ -20,7 +20,7 @@
 #include <types.h>
 
 /* Simple definition only for readability */
-#define Kuint8_t * (1024)
+#define KByte * (1024)
 
 /* Internal representation of the PPU memory */ 
 uint8_t *ppu_memoryPages[0x40];
@@ -102,13 +102,13 @@ void ppu_setPagePtr2k(uint8_t page, uint8_t *ptr)
 void ppu_setPagePtr4k(uint8_t page, uint8_t *ptr)
 {
     ppu_setPagePtr2k(page, ptr);
-    ppu_setPagePtr2k(page+((4 Kuint8_t / 256) / 2), ptr + 2 Kuint8_t);
+    ppu_setPagePtr2k(page+((4 KByte / 256) / 2), ptr + 2 KByte);
 }
 
 void ppu_setPagePtr8k(uint8_t page, uint8_t *ptr)
 {
     ppu_setPagePtr4k(page, ptr);
-    ppu_setPagePtr4k(page+((8 Kuint8_t / 256) / 2), ptr + 4 Kuint8_t);
+    ppu_setPagePtr4k(page+((8 KByte / 256) / 2), ptr + 4 KByte);
 }
 
 void ppu_setPageGhost(uint8_t page, uint8_t value, uint8_t ghost)
@@ -149,7 +149,7 @@ void ppu_writeMemory(uint8_t page, uint8_t addr, uint8_t value)
 {
     if (page == 0x3F)
     {
-        /* Here we will cheat with the palette miroring, since we didn't write
+        /* Here we will cheat with the palette mirroring, since we didn't write
            as often as we read the palette, we will mirror here */
         //console_printf(Console_Default, "%s palette: color %02X new value : %02d (0x%02X%02X)\n", ((addr&0x10)< 0x10) ? "Bgnd" : "Sprt", addr&0x1F, value & 0x3F, page, addr);
         if ((addr & 0xEF) == 0x00)

+ 79 - 75
src/utils/bin2h/bin2h.c

@@ -2,7 +2,7 @@
  *  bin to header - Part of The peTI-NESulator Project
  *  bin2h.c: Convert a binary file to a table of uint8_t in a C header file.
  *
- *  Created by Manoel Trapier.
+ *  Created by Manoël Trapier.
  *  Copyright 2003-2008 986 Corp. All rights reserved.
  *
  */
@@ -13,81 +13,85 @@
 
 int main(int argc, char *argv[])
 {
-	int i;
-	char *infile;
-	FILE *fpin = stdin;
-	FILE *fpout = stdout;
-	short c;
-	infile = "stdin";
-	if (argc > 1)
-	{
-	
-		for(i = 1; argv[i] && argv[i][0] == '-'; i++)
-		{
-			if (i < argc)
-			{
-				switch(argv[i][1])
-				{
-				case 'i':
-					fpin = fopen(argv[i+1], "rb");
-					infile = argv[i+1];
-					if (fpin == NULL)
-					{
-						fprintf (stderr, "Error: cannot open in file '%s'\n", argv[i+1]);
-						exit(-1);
-					}
-					i++;
-					break;
-					
-				case 'o':
-				
-					fpout = fopen(argv[i+1], "wb");
-					if (fpout == NULL)
-					{
-						fprintf (stderr, "Error: cannot open out file '%s'\n", argv[i+1]);
-						exit(-1);
-					}
-					i++;
-					break;
-					
-				default:
-					fprintf (stderr, "Error: unknown argument: %s\n", argv[i]);
-					exit(-1);
-				}
-			}
-		}
-	}
+    int i;
+    char *infile;
+    FILE *fpin = stdin;
+    FILE *fpout = stdout;
+    short c;
+    infile = "stdin";
+    if (argc > 1)
+    {
 
-	fprintf(fpout, "/* Generated data file from file '%s' */\n\n\n", infile);
-	
-	fprintf(fpout, "uint8_t data[] = {\n");
-	i = 0;
-	while((c = fgetc(fpin)) >= 0)
-	{
-		if (i == 0)
-			fprintf(fpout, "\t\t0x%02X", (uint8_t)c);
-		else
-			fprintf(fpout, ", 0x%02X", (uint8_t)c);
-			
-		i++;
-		if (i > 10)
-		{
-			fprintf(fpout,", \\\n");
-			i = 0;
-		}
-	
-	
-	}
-	fprintf(fpout, "\n\t\t};\n");
+        for (i = 1 ; argv[i] && argv[i][0] == '-' ; i++)
+        {
+            if (i < argc)
+            {
+                switch (argv[i][1])
+                {
+                case 'i':
+                    fpin = fopen(argv[i + 1], "rb");
+                    infile = argv[i + 1];
+                    if (fpin == NULL)
+                    {
+                        fprintf(stderr, "Error: cannot open in file '%s'\n", argv[i + 1]);
+                        exit(-1);
+                    }
+                    i++;
+                    break;
 
-	if (fpin != stdin)
-	{
-		fclose(fpin);
-	}
-	if (fpout != stdout)
-	{
-		fclose(fpout);
-	}
+                case 'o':
 
-	return 0;
+                    fpout = fopen(argv[i + 1], "wb");
+                    if (fpout == NULL)
+                    {
+                        fprintf(stderr, "Error: cannot open out file '%s'\n", argv[i + 1]);
+                        exit(-1);
+                    }
+                    i++;
+                    break;
+
+                default:
+                    fprintf(stderr, "Error: unknown argument: %s\n", argv[i]);
+                    exit(-1);
+                }
+            }
+        }
+    }
+
+    fprintf(fpout, "/* Generated data file from file '%s' */\n\n\n", infile);
+
+    fprintf(fpout, "uint8_t data[] = {\n");
+    i = 0;
+    while ((c = fgetc(fpin)) >= 0)
+    {
+        if (i == 0)
+        {
+            fprintf(fpout, "\t\t0x%02X", (uint8_t)c);
+        }
+        else
+        {
+            fprintf(fpout, ", 0x%02X", (uint8_t)c);
+        }
+
+        i++;
+        if (i > 10)
+        {
+            fprintf(fpout, ", \\\n");
+            i = 0;
+        }
+
+
+    }
+    fprintf(fpout, "\n\t\t};\n");
+
+    if (fpin != stdin)
+    {
+        fclose(fpin);
+    }
+    if (fpout != stdout)
+    {
+        fclose(fpout);
+    }
+
+    return 0;
 }

+ 14 - 14
src/utils/sendromdata.py

@@ -12,6 +12,7 @@ import sys
 import hashlib.md5 as md5
 import hashlib.sha as sha
 
+
 def get_page(theurl, post_data=None):
     """
     Helper method that gets the given URL
@@ -37,25 +38,25 @@ if __name__ == '__main__':
                 DiskDude = 0
                 if fs[7:16] == "DiskDude!":
                     DiskDude = 1
-                    
+
                 mapperID = ord(fs[6]) >> 4
                 if DiskDude == 0:
                     mapperID = mapperID | (ord(fs[7]) & 0xF0)
-                    
+
                 prgsize = ord(fs[4]) * 16 * 1024
-                chrsize = ord(fs[5]) *  8 * 1024
+                chrsize = ord(fs[5]) * 8 * 1024
                 mirror = 0
                 if Flags & 0x01:
                     mirror = 1
-                    
+
                 sram = 0
                 if Flags & 0x02:
                     sram = 1
-                    
-                Trainer = 0               
+
+                Trainer = 0
                 if Flags & 0x04:
                     Trainer = 1
-                
+
                 print(" <game>")
                 print("  <name>{filename}</name>".format(filename=filename))
                 print("  <sha>{sha}</sha>".format(sha=sha.new(fs).hexdigest()))
@@ -68,11 +69,10 @@ if __name__ == '__main__':
                 print("  <trainer>{trainer}</trainer>".format(trainer=Trainer))
                 print("  <diskdude>{diskdude}</diskdude>".format(diskdude=DiskDude))
                 print(" </game>")
-                 
-                 
-                #will fill the DB :
+
+                # will fill the DB :
                 url = "http://127.0.0.1/nesstat/add.php"
-                
+
                 html = get_page(url, urllib.urlencode({
                     'n': filename,
                     'md5': md5.new(fs).hexdigest(),
@@ -85,9 +85,9 @@ if __name__ == '__main__':
                     't': Trainer,
                     'd': DiskDude,
                 }))
-                
+
                 print(html)
         finally:
             f.close()
-            
-    #print("</gamelist>")
+
+    # print("</gamelist>")

Some files were not shown because too many files changed in this diff