zemu 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (285) hide show
  1. checksums.yaml +7 -0
  2. data/lib/zemu/config.rb +312 -0
  3. data/lib/zemu/instance.rb +179 -0
  4. data/lib/zemu.rb +172 -0
  5. data/src/debug.c +118 -0
  6. data/src/debug.h +30 -0
  7. data/src/external/Z/API/Z/ABIs/generic/allocator.h +36 -0
  8. data/src/external/Z/API/Z/ABIs/generic/cipher.h +47 -0
  9. data/src/external/Z/API/Z/ABIs/generic/data codec.h +33 -0
  10. data/src/external/Z/API/Z/ABIs/generic/emulation.h +103 -0
  11. data/src/external/Z/API/Z/ABIs/generic/hash function.h +33 -0
  12. data/src/external/Z/API/Z/ABIs/generic/module.h +33 -0
  13. data/src/external/Z/API/Z/ABIs/generic/wave codec.h +40 -0
  14. data/src/external/Z/API/Z/classes/base/InitializerList.hpp +34 -0
  15. data/src/external/Z/API/Z/classes/base/OpaqueFunctionPointer.hpp +26 -0
  16. data/src/external/Z/API/Z/classes/base/OpaqueMemberFunctionPointer.hpp +26 -0
  17. data/src/external/Z/API/Z/classes/base/Pair.hpp +46 -0
  18. data/src/external/Z/API/Z/classes/base/Range.hpp +111 -0
  19. data/src/external/Z/API/Z/classes/base/SizedString.hpp +66 -0
  20. data/src/external/Z/API/Z/classes/base/Status.hpp +89 -0
  21. data/src/external/Z/API/Z/classes/base/Symbol.hpp +39 -0
  22. data/src/external/Z/API/Z/classes/base/Tuple.hpp +111 -0
  23. data/src/external/Z/API/Z/classes/base/Value2D.hpp +389 -0
  24. data/src/external/Z/API/Z/classes/base/Value3D.hpp +368 -0
  25. data/src/external/Z/API/Z/classes/buffering/RingBuffer.hpp +93 -0
  26. data/src/external/Z/API/Z/classes/buffering/TripleBuffer.hpp +68 -0
  27. data/src/external/Z/API/Z/classes/functional/Functor.hpp +265 -0
  28. data/src/external/Z/API/Z/classes/functional/MemberFunction.hpp +98 -0
  29. data/src/external/Z/API/Z/classes/functional/ObjectMemberFunction.hpp +172 -0
  30. data/src/external/Z/API/Z/classes/functional/ObjectSelector.hpp +219 -0
  31. data/src/external/Z/API/Z/classes/functional/Selector.hpp +146 -0
  32. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/AABB.hpp +81 -0
  33. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/AABR.hpp +685 -0
  34. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Box.hpp +219 -0
  35. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Circle.hpp +80 -0
  36. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Line2D.hpp +93 -0
  37. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Line3D.hpp +80 -0
  38. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Rectangle.hpp +675 -0
  39. data/src/external/Z/API/Z/classes/mathematics/geometry/euclidean/Sphere.hpp +0 -0
  40. data/src/external/Z/API/Z/classes/memory/Shared.hpp +90 -0
  41. data/src/external/Z/API/Z/constants/base.h +35 -0
  42. data/src/external/Z/API/Z/constants/chemical elements.h +6385 -0
  43. data/src/external/Z/API/Z/constants/numbers.h +963 -0
  44. data/src/external/Z/API/Z/constants/version.h +15 -0
  45. data/src/external/Z/API/Z/formats/character set/ASCII.h +158 -0
  46. data/src/external/Z/API/Z/formats/character set/DOS CP437.h +159 -0
  47. data/src/external/Z/API/Z/formats/character set/DOS CP737.h +159 -0
  48. data/src/external/Z/API/Z/formats/character set/DOS CP775.h +159 -0
  49. data/src/external/Z/API/Z/formats/character set/DOS CP850.h +159 -0
  50. data/src/external/Z/API/Z/formats/character set/DOS CP852.h +159 -0
  51. data/src/external/Z/API/Z/formats/character set/DOS CP855.h +159 -0
  52. data/src/external/Z/API/Z/formats/character set/DOS CP857.h +159 -0
  53. data/src/external/Z/API/Z/formats/character set/DOS CP858.h +159 -0
  54. data/src/external/Z/API/Z/formats/character set/DOS CP860.h +159 -0
  55. data/src/external/Z/API/Z/formats/character set/DOS CP861.h +159 -0
  56. data/src/external/Z/API/Z/formats/character set/DOS CP862.h +159 -0
  57. data/src/external/Z/API/Z/formats/character set/DOS CP863.h +159 -0
  58. data/src/external/Z/API/Z/formats/character set/DOS CP864.h +159 -0
  59. data/src/external/Z/API/Z/formats/character set/DOS CP865.h +159 -0
  60. data/src/external/Z/API/Z/formats/character set/DOS CP866.h +159 -0
  61. data/src/external/Z/API/Z/formats/character set/DOS CP869.h +159 -0
  62. data/src/external/Z/API/Z/formats/character set/DOS CP872.h +159 -0
  63. data/src/external/Z/API/Z/formats/character set/DOS CP874.h +159 -0
  64. data/src/external/Z/API/Z/formats/character set/Unicode.h +30119 -0
  65. data/src/external/Z/API/Z/formats/data model/I16LP32.h +19 -0
  66. data/src/external/Z/API/Z/formats/data model/ILP32.h +19 -0
  67. data/src/external/Z/API/Z/formats/data model/ILP64.h +19 -0
  68. data/src/external/Z/API/Z/formats/data model/IP16L32.h +19 -0
  69. data/src/external/Z/API/Z/formats/data model/LLP64.h +19 -0
  70. data/src/external/Z/API/Z/formats/data model/LP32.h +19 -0
  71. data/src/external/Z/API/Z/formats/data model/LP64.h +19 -0
  72. data/src/external/Z/API/Z/formats/data model/SILP64.h +19 -0
  73. data/src/external/Z/API/Z/formats/file system/FAT12.h +61 -0
  74. data/src/external/Z/API/Z/formats/floating-point/IEEE 754.h +141 -0
  75. data/src/external/Z/API/Z/formats/floating-point/x87.h +74 -0
  76. data/src/external/Z/API/Z/formats/image/ICNS.h +39 -0
  77. data/src/external/Z/API/Z/formats/keymap/Mac OS.h +284 -0
  78. data/src/external/Z/API/Z/formats/keymap/Z.h +141 -0
  79. data/src/external/Z/API/Z/formats/multimedia/Creative Voice.h +106 -0
  80. data/src/external/Z/API/Z/formats/multimedia/Microsoft Wave.h +49 -0
  81. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/ACH.h +44 -0
  82. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/FRZ.h +54 -0
  83. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/PRG.h +33 -0
  84. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SEM.h +46 -0
  85. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SIT.h +34 -0
  86. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SNA.h +117 -0
  87. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SNP.h +37 -0
  88. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/SP.h +62 -0
  89. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/Z80.h +117 -0
  90. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/ZX.h +56 -0
  91. data/src/external/Z/API/Z/formats/snapshot/machine/computer/ZX Spectrum/ZX82.h +70 -0
  92. data/src/external/Z/API/Z/formats/storage medium image/NES Game Pak/UNIF.h +26 -0
  93. data/src/external/Z/API/Z/formats/storage medium image/NES Game Pak/iNES.h +76 -0
  94. data/src/external/Z/API/Z/formats/storage medium image/audio/TAP.h +25 -0
  95. data/src/external/Z/API/Z/formats/storage medium image/audio/TZX.h +1185 -0
  96. data/src/external/Z/API/Z/formats/storage medium image/audio/Warajevo TAP.h +32 -0
  97. data/src/external/Z/API/Z/formats/storage medium image/floppy disk/FDI.h +45 -0
  98. data/src/external/Z/API/Z/functions/base/Z2D.h +583 -0
  99. data/src/external/Z/API/Z/functions/base/Z3D.h +712 -0
  100. data/src/external/Z/API/Z/functions/base/ZRange.h +137 -0
  101. data/src/external/Z/API/Z/functions/base/all.h +16 -0
  102. data/src/external/Z/API/Z/functions/base/casting.hpp +37 -0
  103. data/src/external/Z/API/Z/functions/base/character.h +38 -0
  104. data/src/external/Z/API/Z/functions/base/constructors.h +326 -0
  105. data/src/external/Z/API/Z/functions/base/structure.hpp +26 -0
  106. data/src/external/Z/API/Z/functions/base/type.hpp +60 -0
  107. data/src/external/Z/API/Z/functions/base/value.h +1901 -0
  108. data/src/external/Z/API/Z/functions/base/value.hpp +112 -0
  109. data/src/external/Z/API/Z/functions/buffering/ZRingBuffer.h +85 -0
  110. data/src/external/Z/API/Z/functions/buffering/ZTripleBuffer.h +65 -0
  111. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/Z2DLine.h +179 -0
  112. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/Z3DLine.h +168 -0
  113. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZAABB.h +361 -0
  114. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZAABR.h +1081 -0
  115. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZBox.h +340 -0
  116. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZCircle.h +142 -0
  117. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZRectangle.h +1267 -0
  118. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/ZSphere.h +156 -0
  119. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/all.h +18 -0
  120. data/src/external/Z/API/Z/functions/mathematics/geometry/euclidean/constructors.h +620 -0
  121. data/src/external/Z/API/Z/functions/time/date.h +29 -0
  122. data/src/external/Z/API/Z/hardware/CPU/architecture/6502.h +90 -0
  123. data/src/external/Z/API/Z/hardware/CPU/architecture/Z80.h +245 -0
  124. data/src/external/Z/API/Z/hardware/CPU/architecture/i4004.h +37 -0
  125. data/src/external/Z/API/Z/hardware/PSG/General Instrument/AY-3-891x.h +180 -0
  126. data/src/external/Z/API/Z/hardware/VDC/Ricoh/RP2C0x.h +625 -0
  127. data/src/external/Z/API/Z/hardware/bus/AGP.h +24 -0
  128. data/src/external/Z/API/Z/hardware/bus/USB.h +510 -0
  129. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/Inves Spectrum +.h +47 -0
  130. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/Pentagon.h +13 -0
  131. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/Scorpion.h +13 -0
  132. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum + 128K.h +158 -0
  133. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +.h +82 -0
  134. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +2.h +13 -0
  135. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +2A.h +13 -0
  136. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum +3.h +13 -0
  137. data/src/external/Z/API/Z/hardware/machine/model/computer/ZX Spectrum/ZX Spectrum.h +109 -0
  138. data/src/external/Z/API/Z/hardware/machine/model/console/Nintendo Entertainment System/NES-001 (NTSC).h +29 -0
  139. data/src/external/Z/API/Z/hardware/machine/model/console/Nintendo Entertainment System/NES-001 (PAL).h +29 -0
  140. data/src/external/Z/API/Z/hardware/machine/platform/computer/ZX Spectrum.h +405 -0
  141. data/src/external/Z/API/Z/hardware/machine/platform/console/Game Boy.h +49 -0
  142. data/src/external/Z/API/Z/hardware/machine/platform/console/Nintendo Entertainment System.h +350 -0
  143. data/src/external/Z/API/Z/hardware/storage medium/ROM cartridge/SNES Game Pak.h +238 -0
  144. data/src/external/Z/API/Z/inspection/C/completion.h +178 -0
  145. data/src/external/Z/API/Z/inspection/C/modules/C11.h +41 -0
  146. data/src/external/Z/API/Z/inspection/C/modules/C18.h +13 -0
  147. data/src/external/Z/API/Z/inspection/C/modules/C89.h +19 -0
  148. data/src/external/Z/API/Z/inspection/C/modules/C90.h +13 -0
  149. data/src/external/Z/API/Z/inspection/C/modules/C94.h +15 -0
  150. data/src/external/Z/API/Z/inspection/C/modules/C99.h +29 -0
  151. data/src/external/Z/API/Z/inspection/C/modules/KR C.h +19 -0
  152. data/src/external/Z/API/Z/inspection/C++/completion.h +512 -0
  153. data/src/external/Z/API/Z/inspection/C++/modules/C++03.h +15 -0
  154. data/src/external/Z/API/Z/inspection/C++/modules/C++11.h +80 -0
  155. data/src/external/Z/API/Z/inspection/C++/modules/C++14.h +26 -0
  156. data/src/external/Z/API/Z/inspection/C++/modules/C++17.h +55 -0
  157. data/src/external/Z/API/Z/inspection/C++/modules/C++85.h +11 -0
  158. data/src/external/Z/API/Z/inspection/C++/modules/C++89.h +13 -0
  159. data/src/external/Z/API/Z/inspection/C++/modules/C++98.h +17 -0
  160. data/src/external/Z/API/Z/inspection/C++.h +78 -0
  161. data/src/external/Z/API/Z/inspection/C.h +79 -0
  162. data/src/external/Z/API/Z/inspection/CPU/completion.h +56 -0
  163. data/src/external/Z/API/Z/inspection/CPU/detection.h +714 -0
  164. data/src/external/Z/API/Z/inspection/CPU/modules/6502.h +25 -0
  165. data/src/external/Z/API/Z/inspection/CPU/modules/AArch32.h +32 -0
  166. data/src/external/Z/API/Z/inspection/CPU/modules/AArch64.h +32 -0
  167. data/src/external/Z/API/Z/inspection/CPU/modules/Z80.h +26 -0
  168. data/src/external/Z/API/Z/inspection/CPU/modules/x86-32.h +31 -0
  169. data/src/external/Z/API/Z/inspection/CPU/modules/x86-64.h +312 -0
  170. data/src/external/Z/API/Z/inspection/CPU.h +209 -0
  171. data/src/external/Z/API/Z/inspection/OS/completion.h +36 -0
  172. data/src/external/Z/API/Z/inspection/OS/detection.h +768 -0
  173. data/src/external/Z/API/Z/inspection/OS/modules/Linux.h +22 -0
  174. data/src/external/Z/API/Z/inspection/OS/modules/MS-DOS.h +16 -0
  175. data/src/external/Z/API/Z/inspection/OS/modules/Mac OS X.h +23 -0
  176. data/src/external/Z/API/Z/inspection/OS/modules/Windows.h +19 -0
  177. data/src/external/Z/API/Z/inspection/OS/modules/iPhone OS.h +23 -0
  178. data/src/external/Z/API/Z/inspection/OS.h +236 -0
  179. data/src/external/Z/API/Z/inspection/Objective-C/completion.h +8 -0
  180. data/src/external/Z/API/Z/inspection/Objective-C/modules/Objective-C v1.0.h +11 -0
  181. data/src/external/Z/API/Z/inspection/Objective-C/modules/Objective-C v2.0.h +15 -0
  182. data/src/external/Z/API/Z/inspection/Objective-C.h +51 -0
  183. data/src/external/Z/API/Z/inspection/Z.h +19 -0
  184. data/src/external/Z/API/Z/inspection/build.h +22 -0
  185. data/src/external/Z/API/Z/inspection/character set.h +66 -0
  186. data/src/external/Z/API/Z/inspection/compiler/completion.h +2885 -0
  187. data/src/external/Z/API/Z/inspection/compiler/modules/Apple LLVM.h +26 -0
  188. data/src/external/Z/API/Z/inspection/compiler/modules/Clang.h +1664 -0
  189. data/src/external/Z/API/Z/inspection/compiler/modules/GCC.h +1366 -0
  190. data/src/external/Z/API/Z/inspection/compiler/modules/SCCZ80.h +473 -0
  191. data/src/external/Z/API/Z/inspection/compiler/modules/Visual C++.h +606 -0
  192. data/src/external/Z/API/Z/inspection/compiler/modules/cc65.h +529 -0
  193. data/src/external/Z/API/Z/inspection/compiler/modules/generic.h +13 -0
  194. data/src/external/Z/API/Z/inspection/compiler/modules/template.h +650 -0
  195. data/src/external/Z/API/Z/inspection/compiler.h +299 -0
  196. data/src/external/Z/API/Z/inspection/data model/completion.h +128 -0
  197. data/src/external/Z/API/Z/inspection/data model/deduction.h +9 -0
  198. data/src/external/Z/API/Z/inspection/data model/detection.h +45 -0
  199. data/src/external/Z/API/Z/inspection/data model.h +362 -0
  200. data/src/external/Z/API/Z/inspection/floating-point/completion.h +50 -0
  201. data/src/external/Z/API/Z/inspection/floating-point.h +324 -0
  202. data/src/external/Z/API/Z/inspection/language.h +163 -0
  203. data/src/external/Z/API/Z/inspection/platform/detection.h +9 -0
  204. data/src/external/Z/API/Z/inspection/platform.h +29 -0
  205. data/src/external/Z/API/Z/keys/C++.h +27 -0
  206. data/src/external/Z/API/Z/keys/C.h +29 -0
  207. data/src/external/Z/API/Z/keys/CPU.h +80 -0
  208. data/src/external/Z/API/Z/keys/OS.h +182 -0
  209. data/src/external/Z/API/Z/keys/Objective-C.h +17 -0
  210. data/src/external/Z/API/Z/keys/chemistry.h +26 -0
  211. data/src/external/Z/API/Z/keys/compiler.h +178 -0
  212. data/src/external/Z/API/Z/keys/data model.h +32 -0
  213. data/src/external/Z/API/Z/keys/endianness.h +24 -0
  214. data/src/external/Z/API/Z/keys/language.h +21 -0
  215. data/src/external/Z/API/Z/keys/layout.h +20 -0
  216. data/src/external/Z/API/Z/keys/mathematics/geometry.h +29 -0
  217. data/src/external/Z/API/Z/keys/mathematics/number.h +21 -0
  218. data/src/external/Z/API/Z/keys/order.h +18 -0
  219. data/src/external/Z/API/Z/keys/platform.h +87 -0
  220. data/src/external/Z/API/Z/keys/program.h +39 -0
  221. data/src/external/Z/API/Z/keys/science/chemical elements.h +200 -0
  222. data/src/external/Z/API/Z/keys/science/electricity.h +18 -0
  223. data/src/external/Z/API/Z/keys/science/magnetism.h +19 -0
  224. data/src/external/Z/API/Z/keys/status.h +69 -0
  225. data/src/external/Z/API/Z/keys/text.h +27 -0
  226. data/src/external/Z/API/Z/keys/value.h +88 -0
  227. data/src/external/Z/API/Z/macros/arguments.h +25 -0
  228. data/src/external/Z/API/Z/macros/casting.h +22 -0
  229. data/src/external/Z/API/Z/macros/character.h +159 -0
  230. data/src/external/Z/API/Z/macros/date.h +14 -0
  231. data/src/external/Z/API/Z/macros/key.h +20 -0
  232. data/src/external/Z/API/Z/macros/language.h +126 -0
  233. data/src/external/Z/API/Z/macros/language.hpp +81 -0
  234. data/src/external/Z/API/Z/macros/members.h +86 -0
  235. data/src/external/Z/API/Z/macros/pasting.h +308 -0
  236. data/src/external/Z/API/Z/macros/pointer.h +33 -0
  237. data/src/external/Z/API/Z/macros/repetition.h +283 -0
  238. data/src/external/Z/API/Z/macros/structure.h +104 -0
  239. data/src/external/Z/API/Z/macros/templating.h +407 -0
  240. data/src/external/Z/API/Z/macros/tokens.h +14 -0
  241. data/src/external/Z/API/Z/macros/type enumeration.h +43 -0
  242. data/src/external/Z/API/Z/macros/type selection.hpp +76 -0
  243. data/src/external/Z/API/Z/macros/value.h +489 -0
  244. data/src/external/Z/API/Z/macros/variadic pasting.h +21 -0
  245. data/src/external/Z/API/Z/macros/variadic selection.h +56 -0
  246. data/src/external/Z/API/Z/macros/variadic.h +46 -0
  247. data/src/external/Z/API/Z/macros/version.h +17 -0
  248. data/src/external/Z/API/Z/network/3/IP.h +36 -0
  249. data/src/external/Z/API/Z/network/4/TCP.h +24 -0
  250. data/src/external/Z/API/Z/network/4/UDP.h +26 -0
  251. data/src/external/Z/API/Z/network/7/ED2K.h +104 -0
  252. data/src/external/Z/API/Z/network/7/HTTP.h +100 -0
  253. data/src/external/Z/API/Z/traits/SelectType.hpp +71 -0
  254. data/src/external/Z/API/Z/traits/TernaryType.hpp +20 -0
  255. data/src/external/Z/API/Z/traits/Type.hpp +4516 -0
  256. data/src/external/Z/API/Z/traits/TypeCount.hpp +52 -0
  257. data/src/external/Z/API/Z/traits/TypeList.hpp +376 -0
  258. data/src/external/Z/API/Z/traits/base.hpp +19 -0
  259. data/src/external/Z/API/Z/traits/filtering.hpp +30 -0
  260. data/src/external/Z/API/Z/traits/mathematics.hpp +48 -0
  261. data/src/external/Z/API/Z/types/arguments.h +19 -0
  262. data/src/external/Z/API/Z/types/base.h +1655 -0
  263. data/src/external/Z/API/Z/types/base.hpp +169 -0
  264. data/src/external/Z/API/Z/types/buffering.h +27 -0
  265. data/src/external/Z/API/Z/types/mathematics.h +135 -0
  266. data/src/external/Z/API/Z/types/time.h +23 -0
  267. data/src/external/Z/COPYING.LESSER +165 -0
  268. data/src/external/Z/development/Qt Creator/Z.pro +253 -0
  269. data/src/external/Z/distribution/CocoaPods/Zeta.podspec +18 -0
  270. data/src/external/Z/distribution/Gentoo Linux/Zeta-0.1.ebuild +22 -0
  271. data/src/external/Z/distribution/Gentoo Linux/metadata.xml +8 -0
  272. data/src/external/Z/distribution/Homebrew/Zeta.rb +11 -0
  273. data/src/external/z80/API/emulation/CPU/Z80.h +201 -0
  274. data/src/external/z80/README.md +229 -0
  275. data/src/external/z80/building/premake4.lua +33 -0
  276. data/src/external/z80/development/Xcode/Z80.xcodeproj/project.pbxproj +520 -0
  277. data/src/external/z80/sources/Z80.c +1660 -0
  278. data/src/interrupt.c +6 -0
  279. data/src/interrupt.h +3 -0
  280. data/src/io.c.erb +115 -0
  281. data/src/io.h.erb +18 -0
  282. data/src/main.c +69 -0
  283. data/src/memory.c.erb +43 -0
  284. data/src/memory.h.erb +9 -0
  285. metadata +329 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 98e90e196dcbb84331f8dab176c2b83610180e7ddd11df63f481328cab4b7d7a
4
+ data.tar.gz: c3cb5cde5230d2dbe34d228a170fa5cd35a6607614c215ea5c01792c1634ee08
5
+ SHA512:
6
+ metadata.gz: 7359557085c2f32b9222c7836c0af65a1104e158f8f9c58d118a5dabbd50fdcb2cfe793957b41cded14af45566a2ddaad4d3148ee736da922e1347bde1bf0091
7
+ data.tar.gz: d20ce84cc9c41e11203b08e44865b6addf53d63846004f4aa575eb54f58b69200c454c18713569e94220dd6ea49a3dea84634870bfef5a32f58a81f7a04daf49
@@ -0,0 +1,312 @@
1
+ module Zemu
2
+ # Abstract configuration object.
3
+ # All configuration objects should inherit from this.
4
+ class ConfigObject
5
+ # Defines the parameters of this configuration object.
6
+ def params
7
+ raise NotImplementedError, "params must be overridden by inheriting class."
8
+ end
9
+
10
+ protected :params
11
+
12
+ # Defines the initial values of parameters, if any.
13
+ def params_init
14
+ return {}
15
+ end
16
+
17
+ protected :params_init
18
+
19
+ def initialize(&block)
20
+ if self.class == Zemu::ConfigObject
21
+ raise NotImplementedError, "Cannot construct an instance of the abstract class Zemu::ConfigObject."
22
+ end
23
+
24
+ @initialized = false
25
+
26
+ # Initialize each parameter to nil
27
+ params.each do |p|
28
+ if params_init[p].nil?
29
+ instance_variable_set("@#{p}", nil)
30
+ else
31
+ instance_variable_set("@#{p}", params_init[p])
32
+ end
33
+ end
34
+
35
+ # Instance eval the block.
36
+ instance_eval(&block)
37
+
38
+ # Raise a ConfigError if any of the parameters are unset.
39
+ params.each do |p|
40
+ if instance_variable_get("@#{p}").nil?
41
+ raise ConfigError, "The #{p} parameter of a #{self.class.name} configuration object must be set."
42
+ end
43
+ end
44
+
45
+ @initialized = true
46
+ end
47
+
48
+ # This allows some metaprogramming magic to allow the user to set instance variables
49
+ # (config parameters) while initializing the configuration object, but ensures
50
+ # that these parameters are readonly once the object is initialized.
51
+ def method_missing(m, *args, &block)
52
+ params.each do |v|
53
+ # We don't allow the setting of instance variables if the object
54
+ # has been initialized.
55
+ if m == "#{v}".to_sym
56
+ if args.size == 1 && !@initialized
57
+ instance_variable_set("@#{v}", args[0])
58
+ return
59
+ elsif args.size == 0
60
+ return instance_variable_get("@#{v}")
61
+ end
62
+ end
63
+ end
64
+
65
+ # Otherwise just call super's method_missing
66
+ super
67
+ end
68
+ end
69
+
70
+ # Configuration object.
71
+ #
72
+ # An object which represents the configuration of a Zemu emulator.
73
+ #
74
+ # @param [String] name The name of the configuration.
75
+ # @param [String] compiler The path to the compiler to be used for compiling the emulator executable.
76
+ #
77
+ class Config < ConfigObject
78
+ # Memory object.
79
+ #
80
+ # This is an abstract class from which all other memory objects inherit.
81
+ class Memory < ConfigObject
82
+ # Constructor.
83
+ #
84
+ # Do not use, as this is an abstract class. Use one of the subclasses instead.
85
+ def initialize
86
+ if self.class == Zemu::Config::Memory
87
+ raise NotImplementedError, "Cannot construct an instance of the abstract class Zemu::Config::Memory."
88
+ end
89
+
90
+ @contents = []
91
+
92
+ super
93
+
94
+ # Pad contents with 0x00 bytes.
95
+ (@size - @contents.size).times do
96
+ @contents << 0x00
97
+ end
98
+ end
99
+
100
+ # Gets or sets an array of bytes representing the initial state
101
+ # of this memory block.
102
+ def contents(*args)
103
+ if args.size.zero?
104
+ return @contents
105
+ else
106
+ @contents = args[0]
107
+ end
108
+ end
109
+
110
+ # @return [Boolean] true if this memory section is readonly, false otherwise.
111
+ def readonly?
112
+ return false
113
+ end
114
+
115
+ # Valid parameters for this object.
116
+ # Should be extended by subclasses but NOT REPLACED.
117
+ def params
118
+ return %w(name address size)
119
+ end
120
+
121
+ # Reads the contents of a file in binary format and
122
+ # returns them as an array.
123
+ def from_binary(file)
124
+ return File.open(file, "rb") do |f|
125
+ bin = []
126
+
127
+ f.each_byte { |b| bin << b }
128
+
129
+ bin
130
+ end
131
+ end
132
+ end
133
+
134
+ # Read-Only Memory object
135
+ #
136
+ # Represents a block of memory which is read-only.
137
+ class ROM < Memory
138
+ # Constructor.
139
+ #
140
+ # Takes a block in which the parameters of the memory block
141
+ # can be initialized.
142
+ #
143
+ # All parameters can be set within this block.
144
+ # They become readonly as soon as the block completes.
145
+ #
146
+ # @example
147
+ #
148
+ # Zemu::Config::ROM.new do
149
+ # address 0x8000
150
+ # size 256
151
+ # end
152
+ #
153
+ #
154
+ def initialize
155
+ super
156
+ end
157
+
158
+ def readonly?
159
+ return true
160
+ end
161
+ end
162
+
163
+ # Random-access Memory object
164
+ #
165
+ # Represents a block of memory which can be read and written.
166
+ class RAM < Memory
167
+ end
168
+
169
+ # Input/Output Port object
170
+ #
171
+ # Represents an input/output device assigned to one or more ports.
172
+ class IOPort < ConfigObject
173
+ attr_reader :io_type
174
+
175
+ # Constructor.
176
+ #
177
+ # Do not use, as this is an abstract class. Use one of the subclasses instead.
178
+ def initialize
179
+ if self.class == Zemu::Config::IOPort
180
+ raise NotImplementedError, "Cannot construct an instance of the abstract class Zemu::Config::IOPort."
181
+ end
182
+
183
+ @ports = []
184
+
185
+ super
186
+ end
187
+
188
+ # Valid parameters for this object.
189
+ # Should be extended by subclasses but NOT REPLACED.
190
+ def params
191
+ %w(name)
192
+ end
193
+ end
194
+
195
+ # Serial Input/Output object
196
+ #
197
+ # Represents a serial connection between the emulated CPU
198
+ # and the host machine, with input and output mapped to Z80 I/O
199
+ # ports.
200
+ class SerialPort < IOPort
201
+ # Constructor.
202
+ #
203
+ # Takes a block in which the parameters of the serial port
204
+ # can be initialized.
205
+ #
206
+ # All parameters can be set within this block.
207
+ # They become readonly as soon as the block completes.
208
+ #
209
+ # @example
210
+ #
211
+ # Zemu::Config::SerialPort.new do
212
+ # name "serial"
213
+ # in_port 0x00
214
+ # out_port 0x01
215
+ # end
216
+ #
217
+ #
218
+ def initialize
219
+ super
220
+
221
+ @io_type = :serial
222
+ end
223
+
224
+ # Valid parameters for a SerialPort, along with those
225
+ # defined in [Zemu::Config::IOPort].
226
+ def params
227
+ super + %w(in_port out_port)
228
+ end
229
+ end
230
+
231
+ # Gets a binding for this object.
232
+ def get_binding
233
+ return binding
234
+ end
235
+
236
+ # The memory sections of this configuration object.
237
+ attr_reader :memory
238
+
239
+ # The IO devices of this configuration object.
240
+ attr_reader :io
241
+
242
+ # Parameters accessible by this configuration object.
243
+ def params
244
+ return %w(name compiler output_directory)
245
+ end
246
+
247
+ # Initial value for parameters of this configuration object.
248
+ def params_init
249
+ return {
250
+ "compiler" => "clang",
251
+ "output_directory" => "bin"
252
+ }
253
+ end
254
+
255
+ # Constructor.
256
+ #
257
+ # Takes a block in which parameters of the configuration
258
+ # can be initialized.
259
+ #
260
+ # All parameters can be set within this block.
261
+ # They become readonly as soon as the block completes.
262
+ #
263
+ # @example
264
+ #
265
+ # Zemu::Config.new do
266
+ # name "my_config"
267
+ #
268
+ # add_memory Zemu::Config::ROM.new do
269
+ # name "rom"
270
+ # address 0x0000
271
+ # size 0x1000
272
+ # end
273
+ # end
274
+ #
275
+ # @raise [Zemu::ConfigError] Raised if the +name+ parameter is not set, or contains whitespace.
276
+ def initialize
277
+ @memory = []
278
+ @io = []
279
+
280
+ super
281
+
282
+ if @name.empty?
283
+ raise ConfigError, "The name parameter of a Zemu::Config configuration object cannot be empty."
284
+ end
285
+
286
+ if /\s/ =~ @name
287
+ raise ConfigError, "The name parameter of a Zemu::Config configuration object cannot contain whitespace."
288
+ end
289
+ end
290
+
291
+ # Adds a new memory section to this configuration.
292
+ #
293
+ # @param [Zemu::Config::Memory] mem The memory object to add.
294
+ def add_memory(mem)
295
+ @memory << mem
296
+ end
297
+
298
+ # Adds a new IO device to this configuration.
299
+ #
300
+ # @param [Zemu::Config::IOPort] io The IO device to add.
301
+ def add_io(io)
302
+ @io << io
303
+ end
304
+ end
305
+
306
+ # Error raised when a configuration is initialized incorrectly.
307
+ class ConfigError < StandardError
308
+ def initialize(msg="The configuration is invalid.")
309
+ super
310
+ end
311
+ end
312
+ end
@@ -0,0 +1,179 @@
1
+ require 'ffi'
2
+ require 'ostruct'
3
+
4
+ module Zemu
5
+ # Represents an instance of a Zemu emulator.
6
+ #
7
+ # Provides methods by which the state of the emulator can be observed
8
+ # and the execution of the program controlled.
9
+ class Instance
10
+ # Mapping of register names to the ID numbers used to identify them
11
+ # by the debug functionality of the built library.
12
+ REGISTERS = {
13
+ # Special purpose registers
14
+ "PC" => 0,
15
+ "SP" => 1,
16
+ "IY" => 2,
17
+ "IX" => 3,
18
+
19
+ # Main register set
20
+ "A" => 4,
21
+ "F" => 5,
22
+ "B" => 6,
23
+ "C" => 7,
24
+ "D" => 8,
25
+ "E" => 9,
26
+ "H" => 10,
27
+ "L" => 11,
28
+
29
+ # Alternate register set
30
+ "A'" => 12,
31
+ "F'" => 13,
32
+ "B'" => 14,
33
+ "C'" => 15,
34
+ "D'" => 16,
35
+ "E'" => 17,
36
+ "H'" => 18,
37
+ "L'" => 19
38
+ }
39
+
40
+ def initialize(configuration)
41
+ @wrapper = make_wrapper(configuration)
42
+
43
+ @serial = []
44
+
45
+ @instance = @wrapper.zemu_init
46
+ @wrapper.zemu_power_on(@instance)
47
+ @wrapper.zemu_reset(@instance)
48
+ end
49
+
50
+ # Returns a hash containing current values of the emulated
51
+ # machine's registers. All names are as those given in the Z80
52
+ # reference manual.
53
+ #
54
+ # 16-bit general-purpose registers must be accessed by their 8-bit
55
+ # component registers.
56
+ def registers
57
+ r = {}
58
+
59
+ REGISTERS.each do |reg, num|
60
+ r[reg] = @wrapper.zemu_debug_register(@instance, num)
61
+ end
62
+
63
+ return r
64
+ end
65
+
66
+ # Access the value in memory at a given address.
67
+ #
68
+ # @param address The address in memory to be accessed.
69
+ #
70
+ # Returns 0 if the memory address is not mapped, otherwise
71
+ # returns the value in the given memory location.
72
+ def memory(address)
73
+ return @wrapper.zemu_debug_get_memory(address)
74
+ end
75
+
76
+ # Write a string to the serial line of the emulated CPU.
77
+ #
78
+ # @param string The string to be sent.
79
+ #
80
+ # Sends each character in the string to the receive buffer of the
81
+ # emulated machine.
82
+ def serial_puts(string)
83
+ string.each_char do |c|
84
+ @wrapper.zemu_io_serial_master_puts(c.ord)
85
+ end
86
+ end
87
+
88
+ # Get a number of characters from the serial line of the emulated CPU.
89
+ #
90
+ # @param count The number of characters to get, or nil if all characters in the buffer
91
+ # should be retrieved.
92
+ #
93
+ # Gets the given number of characters from the emulated machine's send buffer.
94
+ #
95
+ # Note: If count is greater than the number of characters currently in the buffer,
96
+ # the returned string may have invalid characters appended to the end.
97
+ def serial_gets(count=nil)
98
+ return_string = ""
99
+
100
+ if count.nil?
101
+ count = @wrapper.zemu_io_serial_buffer_size()
102
+ end
103
+
104
+ count.to_i.times do
105
+ return_string += @wrapper.zemu_io_serial_master_gets().chr
106
+ end
107
+
108
+ return return_string
109
+ end
110
+
111
+ # Continue running this instance until either:
112
+ # * A HALT instruction is executed
113
+ # * A breakpoint is hit
114
+ def continue
115
+ @wrapper.zemu_debug_continue(@instance)
116
+ end
117
+
118
+ # Set a breakpoint of the given type at the given address.
119
+ #
120
+ # @param address The address of the breakpoint
121
+ # @param type The type of breakpoint:
122
+ # * :program => Break when the program counter hits the address given.
123
+ def break(address, type)
124
+ @wrapper.zemu_debug_set_breakpoint(address)
125
+ end
126
+
127
+ # Returns true if the CPU has halted, false otherwise.
128
+ def halted?
129
+ return @wrapper.zemu_debug_halted
130
+ end
131
+
132
+ # Returns true if a breakpoint has been hit, false otherwise.
133
+ def break?
134
+ return @wrapper.zemu_debug_break
135
+ end
136
+
137
+ # Powers off the emulated CPU and destroys this instance.
138
+ def quit
139
+ @wrapper.zemu_power_off(@instance)
140
+ @wrapper.zemu_free(@instance)
141
+ end
142
+
143
+ # Creates a wrapper around the Zemu module built with the given configuration.
144
+ def make_wrapper(configuration)
145
+ wrapper = Module.new
146
+
147
+ wrapper.extend FFI::Library
148
+
149
+ wrapper.ffi_lib [File.join(configuration.output_directory, "#{configuration.name}.so")]
150
+
151
+ wrapper.attach_function :zemu_init, [], :pointer
152
+ wrapper.attach_function :zemu_free, [:pointer], :void
153
+
154
+ wrapper.attach_function :zemu_power_on, [:pointer], :void
155
+ wrapper.attach_function :zemu_power_off, [:pointer], :void
156
+
157
+ wrapper.attach_function :zemu_reset, [:pointer], :void
158
+
159
+ wrapper.attach_function :zemu_debug_continue, [:pointer], :void
160
+
161
+ wrapper.attach_function :zemu_debug_halted, [], :bool
162
+ wrapper.attach_function :zemu_debug_break, [], :bool
163
+
164
+ wrapper.attach_function :zemu_debug_set_breakpoint, [:uint16], :void
165
+
166
+ wrapper.attach_function :zemu_debug_register, [:pointer, :uint16], :uint16
167
+
168
+ wrapper.attach_function :zemu_debug_get_memory, [:uint16], :uint8
169
+
170
+ wrapper.attach_function :zemu_io_serial_master_puts, [:uint8], :void
171
+ wrapper.attach_function :zemu_io_serial_master_gets, [], :uint8
172
+ wrapper.attach_function :zemu_io_serial_buffer_size, [], :uint64
173
+
174
+ return wrapper
175
+ end
176
+
177
+ private :make_wrapper
178
+ end
179
+ end
data/lib/zemu.rb ADDED
@@ -0,0 +1,172 @@
1
+ require 'erb'
2
+
3
+ require_relative 'zemu/config'
4
+ require_relative 'zemu/instance'
5
+
6
+ # Zemu
7
+ #
8
+ # Zemu is a module providing an interface to build and interact with
9
+ # configurable Z80 emulators.
10
+ #
11
+ # Configurations can be defined in a declarative syntax, from which
12
+ # an emulator executable can be compiled. This executable can then be run
13
+ # from within Zemu and controlled programmatically.
14
+ #
15
+ # Please note: The example below does not currently work, as not all features
16
+ # have been implemented.
17
+ #
18
+ # @example
19
+ #
20
+ # require 'zemu'
21
+ #
22
+ # # A simple configuration with a ROM block
23
+ # # and a RAM block.
24
+ # conf = Zemu::Config.new do
25
+ # name "zemu_emulator"
26
+ #
27
+ # add_memory Zemu::Config::ROM.new do
28
+ # name "rom"
29
+ # address 0x0000
30
+ # size 0x4000
31
+ #
32
+ # contents from_binary("app.bin")
33
+ # end
34
+ #
35
+ # add_memory Zemu::Config::RAM.new do
36
+ # name "ram"
37
+ # address 0x8000
38
+ # size 0x1000
39
+ # end
40
+ # end
41
+ #
42
+ # # Start a new instance with this configuration.
43
+ # instance = Zemu.start(conf)
44
+ #
45
+ # # Program breakpoint.
46
+ # # Will trigger if the emulator is about to execute an
47
+ # # instruction at 0x102.
48
+ # instance.break 0x102, :program
49
+ #
50
+ # # Continue. Emulator will run until HALT or until
51
+ # # the breakpoint (set above) is hit.
52
+ # instance.continue
53
+ #
54
+ # # Display the value of the A register (accumulator)
55
+ # # at the breakpoint.
56
+ # puts instance.register["A"]
57
+ #
58
+ # # Close the instance.
59
+ # instance.quit
60
+ #
61
+ module Zemu
62
+ # Location of C source for the emulator.
63
+ SRC = File.join(__dir__, "..", "src")
64
+
65
+ # Build and start an emulator according to the given configuration.
66
+ #
67
+ # @param [Zemu::Config] configuration The configuration for which an emulator will be generated.
68
+ def Zemu::start(configuration)
69
+ build(configuration)
70
+
71
+ return Instance.new(configuration)
72
+ end
73
+
74
+ # Builds a library according to the given configuration.
75
+ #
76
+ # @param [Zemu::Config] configuration The configuration for which an emulator will be generated.
77
+ #
78
+ # @returns true if the build is a success, false (build failed) or nil (compiler not found) otherwise.
79
+ def Zemu::build(configuration)
80
+ # Create the output directory unless it already exists.
81
+ unless Dir.exist? configuration.output_directory
82
+ Dir.mkdir configuration.output_directory
83
+ end
84
+
85
+ # Generate the autogenerated source files.
86
+ generate(configuration)
87
+
88
+ output = File.join(configuration.output_directory, "#{configuration.name}.so")
89
+
90
+ autogen = File.join(configuration.output_directory, "autogen_#{configuration.name}")
91
+
92
+ compiler = configuration.compiler
93
+
94
+ inputs = [
95
+ "main.c", # main library functionality
96
+ "debug.c", # debug functionality
97
+ "interrupt.c", # interrupt functionality
98
+ "external/z80/sources/Z80.c" # z80 core library
99
+ ]
100
+
101
+ inputs_str = inputs.map { |i| File.join(SRC, i) }.join(" ")
102
+
103
+ inputs_str += " " + File.join(autogen, "memory.c") + " " + File.join(autogen, "io.c")
104
+
105
+ defines = {
106
+ "CPU_Z80_STATIC" => 1,
107
+ "CPU_Z80_USE_LOCAL_HEADER" => 1
108
+ }
109
+
110
+ defines_str = defines.map { |d, v| "-D#{d}=#{v}" }.join(" ")
111
+
112
+ includes = [
113
+ "external/Z/API",
114
+ "external/z80/API",
115
+ "external/z80/API/emulation/CPU",
116
+ "."
117
+ ]
118
+
119
+ includes_str = includes.map { |i| "-I#{File.join(SRC, i)}" }.join(" ")
120
+
121
+ includes_str += " -I" + autogen
122
+
123
+ command = "#{compiler} -Werror -Wno-unknown-warning-option -fPIC -shared -Wl,-undefined -Wl,dynamic_lookup #{includes_str} #{defines_str} -o #{output} #{inputs_str}"
124
+
125
+ # Run the compiler and generate a library.
126
+ return system(command)
127
+ end
128
+
129
+ # Generates the prerequisite source and header files for a given configuration.
130
+ #
131
+ # @param [Zemu::Config] configuration The configuration for which an emulator will be generated.
132
+ def Zemu::generate(configuration)
133
+ generate_memory(configuration)
134
+ generate_io(configuration)
135
+ end
136
+
137
+ # Generates the memory.c and memory.h files for a given configuration.
138
+ def Zemu::generate_memory(configuration)
139
+ header_template = ERB.new File.read(File.join(SRC, "memory.h.erb"))
140
+ source_template = ERB.new File.read(File.join(SRC, "memory.c.erb"))
141
+
142
+ autogen = File.join(configuration.output_directory, "autogen_#{configuration.name}")
143
+
144
+ unless Dir.exist? autogen
145
+ Dir.mkdir autogen
146
+ end
147
+
148
+ File.write(File.join(autogen, "memory.h"),
149
+ header_template.result(configuration.get_binding))
150
+
151
+ File.write(File.join(autogen, "memory.c"),
152
+ source_template.result(configuration.get_binding))
153
+ end
154
+
155
+ # Generates the io.c and io.h files for a given configuration.
156
+ def Zemu::generate_io(configuration)
157
+ header_template = ERB.new File.read(File.join(SRC, "io.h.erb"))
158
+ source_template = ERB.new File.read(File.join(SRC, "io.c.erb"))
159
+
160
+ autogen = File.join(configuration.output_directory, "autogen_#{configuration.name}")
161
+
162
+ unless Dir.exist? autogen
163
+ Dir.mkdir autogen
164
+ end
165
+
166
+ File.write(File.join(autogen, "io.h"),
167
+ header_template.result(configuration.get_binding))
168
+
169
+ File.write(File.join(autogen, "io.c"),
170
+ source_template.result(configuration.get_binding))
171
+ end
172
+ end